138 lines
6.9 KiB
JavaScript
138 lines
6.9 KiB
JavaScript
"use strict";
|
|
|
|
exports.__esModule = true;
|
|
exports.default = void 0;
|
|
|
|
var React = _interopRequireWildcard(require("react"));
|
|
|
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
|
var _Resizable = _interopRequireDefault(require("./Resizable"));
|
|
|
|
var _propTypes2 = require("./propTypes");
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
|
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
|
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
|
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
|
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
|
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
|
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
|
|
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
|
|
|
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
|
|
var ResizableBox = /*#__PURE__*/function (_React$Component) {
|
|
_inheritsLoose(ResizableBox, _React$Component);
|
|
|
|
function ResizableBox() {
|
|
var _this;
|
|
|
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
args[_key] = arguments[_key];
|
|
}
|
|
|
|
_this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
|
|
|
|
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
width: _this.props.width,
|
|
height: _this.props.height,
|
|
propsWidth: _this.props.width,
|
|
propsHeight: _this.props.height
|
|
});
|
|
|
|
_defineProperty(_assertThisInitialized(_this), "onResize", function (e, data) {
|
|
var size = data.size;
|
|
|
|
if (_this.props.onResize) {
|
|
e.persist && e.persist();
|
|
|
|
_this.setState(size, function () {
|
|
return _this.props.onResize && _this.props.onResize(e, data);
|
|
});
|
|
} else {
|
|
_this.setState(size);
|
|
}
|
|
});
|
|
|
|
return _this;
|
|
}
|
|
|
|
ResizableBox.getDerivedStateFromProps = function getDerivedStateFromProps(props, state) {
|
|
// If parent changes height/width, set that in our state.
|
|
if (state.propsWidth !== props.width || state.propsHeight !== props.height) {
|
|
return {
|
|
width: props.width,
|
|
height: props.height,
|
|
propsWidth: props.width,
|
|
propsHeight: props.height
|
|
};
|
|
}
|
|
|
|
return null;
|
|
};
|
|
|
|
var _proto = ResizableBox.prototype;
|
|
|
|
_proto.render = function render() {
|
|
// Basic wrapper around a Resizable instance.
|
|
// If you use Resizable directly, you are responsible for updating the child component
|
|
// with a new width and height.
|
|
var _this$props = this.props,
|
|
handle = _this$props.handle,
|
|
handleSize = _this$props.handleSize,
|
|
onResize = _this$props.onResize,
|
|
onResizeStart = _this$props.onResizeStart,
|
|
onResizeStop = _this$props.onResizeStop,
|
|
draggableOpts = _this$props.draggableOpts,
|
|
minConstraints = _this$props.minConstraints,
|
|
maxConstraints = _this$props.maxConstraints,
|
|
lockAspectRatio = _this$props.lockAspectRatio,
|
|
axis = _this$props.axis,
|
|
width = _this$props.width,
|
|
height = _this$props.height,
|
|
resizeHandles = _this$props.resizeHandles,
|
|
style = _this$props.style,
|
|
transformScale = _this$props.transformScale,
|
|
props = _objectWithoutPropertiesLoose(_this$props, ["handle", "handleSize", "onResize", "onResizeStart", "onResizeStop", "draggableOpts", "minConstraints", "maxConstraints", "lockAspectRatio", "axis", "width", "height", "resizeHandles", "style", "transformScale"]);
|
|
|
|
return /*#__PURE__*/React.createElement(_Resizable.default, {
|
|
axis: axis,
|
|
draggableOpts: draggableOpts,
|
|
handle: handle,
|
|
handleSize: handleSize,
|
|
height: this.state.height,
|
|
lockAspectRatio: lockAspectRatio,
|
|
maxConstraints: maxConstraints,
|
|
minConstraints: minConstraints,
|
|
onResizeStart: onResizeStart,
|
|
onResize: this.onResize,
|
|
onResizeStop: onResizeStop,
|
|
resizeHandles: resizeHandles,
|
|
transformScale: transformScale,
|
|
width: this.state.width
|
|
}, /*#__PURE__*/React.createElement("div", _extends({}, props, {
|
|
style: _objectSpread(_objectSpread({}, style), {}, {
|
|
width: this.state.width + 'px',
|
|
height: this.state.height + 'px'
|
|
})
|
|
})));
|
|
};
|
|
|
|
return ResizableBox;
|
|
}(React.Component);
|
|
|
|
exports.default = ResizableBox;
|
|
|
|
_defineProperty(ResizableBox, "propTypes", _objectSpread(_objectSpread({}, _propTypes2.resizableProps), {}, {
|
|
children: _propTypes.default.element
|
|
})); |