@hi-ui/layout 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/README.md +11 -0
  2. package/lib/cjs/Content.js +48 -0
  3. package/lib/cjs/Layout.js +48 -0
  4. package/lib/cjs/SearchTrigger.js +55 -0
  5. package/lib/cjs/Sider.js +100 -0
  6. package/lib/cjs/_virtual/Draggable.js +16 -0
  7. package/lib/cjs/_virtual/DraggableCore.js +16 -0
  8. package/lib/cjs/_virtual/Resizable.js +16 -0
  9. package/lib/cjs/_virtual/ResizableBox.js +16 -0
  10. package/lib/cjs/_virtual/cjs.js +18 -0
  11. package/lib/cjs/_virtual/domFns.js +16 -0
  12. package/lib/cjs/_virtual/getPrefix.js +16 -0
  13. package/lib/cjs/_virtual/index.js +18 -0
  14. package/lib/cjs/_virtual/index2.js +18 -0
  15. package/lib/cjs/_virtual/index3.js +18 -0
  16. package/lib/cjs/_virtual/index4.js +18 -0
  17. package/lib/cjs/_virtual/log.js +16 -0
  18. package/lib/cjs/_virtual/positionFns.js +16 -0
  19. package/lib/cjs/_virtual/propTypes.js +16 -0
  20. package/lib/cjs/_virtual/react-is.development.js +16 -0
  21. package/lib/cjs/_virtual/react-is.production.min.js +16 -0
  22. package/lib/cjs/_virtual/shims.js +16 -0
  23. package/lib/cjs/_virtual/utils.js +16 -0
  24. package/lib/cjs/index.js +24 -0
  25. package/lib/cjs/node_modules/classnames/index.js +62 -0
  26. package/lib/cjs/node_modules/object-assign/index.js +94 -0
  27. package/lib/cjs/node_modules/prop-types/checkPropTypes.js +101 -0
  28. package/lib/cjs/node_modules/prop-types/factoryWithThrowingShims.js +68 -0
  29. package/lib/cjs/node_modules/prop-types/factoryWithTypeCheckers.js +553 -0
  30. package/lib/cjs/node_modules/prop-types/index.js +36 -0
  31. package/lib/cjs/node_modules/prop-types/lib/ReactPropTypesSecret.js +25 -0
  32. package/lib/cjs/node_modules/react-draggable/build/cjs/Draggable.js +655 -0
  33. package/lib/cjs/node_modules/react-draggable/build/cjs/DraggableCore.js +670 -0
  34. package/lib/cjs/node_modules/react-draggable/build/cjs/cjs.js +23 -0
  35. package/lib/cjs/node_modules/react-draggable/build/cjs/utils/domFns.js +366 -0
  36. package/lib/cjs/node_modules/react-draggable/build/cjs/utils/getPrefix.js +69 -0
  37. package/lib/cjs/node_modules/react-draggable/build/cjs/utils/log.js +19 -0
  38. package/lib/cjs/node_modules/react-draggable/build/cjs/utils/positionFns.js +176 -0
  39. package/lib/cjs/node_modules/react-draggable/build/cjs/utils/shims.js +57 -0
  40. package/lib/cjs/node_modules/react-is/cjs/react-is.development.js +182 -0
  41. package/lib/cjs/node_modules/react-is/cjs/react-is.production.min.js +132 -0
  42. package/lib/cjs/node_modules/react-is/index.js +21 -0
  43. package/lib/cjs/node_modules/react-resizable/build/Resizable.js +366 -0
  44. package/lib/cjs/node_modules/react-resizable/build/ResizableBox.js +244 -0
  45. package/lib/cjs/node_modules/react-resizable/build/propTypes.js +115 -0
  46. package/lib/cjs/node_modules/react-resizable/build/utils.js +86 -0
  47. package/lib/cjs/node_modules/react-resizable/index.js +25 -0
  48. package/lib/cjs/packages/icons/lib/esm/components/common/search-outlined.js +65 -0
  49. package/lib/cjs/packages/icons/lib/esm/styles/index.scss.js +35 -0
  50. package/lib/cjs/styles/index.scss.js +18 -0
  51. package/lib/esm/Content.js +36 -0
  52. package/lib/esm/Layout.js +36 -0
  53. package/lib/esm/SearchTrigger.js +43 -0
  54. package/lib/esm/Sider.js +88 -0
  55. package/lib/esm/_virtual/Draggable.js +11 -0
  56. package/lib/esm/_virtual/DraggableCore.js +11 -0
  57. package/lib/esm/_virtual/Resizable.js +11 -0
  58. package/lib/esm/_virtual/ResizableBox.js +11 -0
  59. package/lib/esm/_virtual/cjs.js +13 -0
  60. package/lib/esm/_virtual/domFns.js +11 -0
  61. package/lib/esm/_virtual/getPrefix.js +11 -0
  62. package/lib/esm/_virtual/index.js +13 -0
  63. package/lib/esm/_virtual/index2.js +13 -0
  64. package/lib/esm/_virtual/index3.js +13 -0
  65. package/lib/esm/_virtual/index4.js +13 -0
  66. package/lib/esm/_virtual/log.js +11 -0
  67. package/lib/esm/_virtual/positionFns.js +11 -0
  68. package/lib/esm/_virtual/propTypes.js +11 -0
  69. package/lib/esm/_virtual/react-is.development.js +11 -0
  70. package/lib/esm/_virtual/react-is.production.min.js +11 -0
  71. package/lib/esm/_virtual/shims.js +11 -0
  72. package/lib/esm/_virtual/utils.js +11 -0
  73. package/lib/esm/index.js +14 -0
  74. package/lib/esm/node_modules/classnames/index.js +60 -0
  75. package/lib/esm/node_modules/object-assign/index.js +88 -0
  76. package/lib/esm/node_modules/prop-types/checkPropTypes.js +96 -0
  77. package/lib/esm/node_modules/prop-types/factoryWithThrowingShims.js +63 -0
  78. package/lib/esm/node_modules/prop-types/factoryWithTypeCheckers.js +548 -0
  79. package/lib/esm/node_modules/prop-types/index.js +34 -0
  80. package/lib/esm/node_modules/prop-types/lib/ReactPropTypesSecret.js +19 -0
  81. package/lib/esm/node_modules/react-draggable/build/cjs/Draggable.js +645 -0
  82. package/lib/esm/node_modules/react-draggable/build/cjs/DraggableCore.js +660 -0
  83. package/lib/esm/node_modules/react-draggable/build/cjs/cjs.js +21 -0
  84. package/lib/esm/node_modules/react-draggable/build/cjs/utils/domFns.js +361 -0
  85. package/lib/esm/node_modules/react-draggable/build/cjs/utils/getPrefix.js +67 -0
  86. package/lib/esm/node_modules/react-draggable/build/cjs/utils/log.js +17 -0
  87. package/lib/esm/node_modules/react-draggable/build/cjs/utils/positionFns.js +171 -0
  88. package/lib/esm/node_modules/react-draggable/build/cjs/utils/shims.js +52 -0
  89. package/lib/esm/node_modules/react-is/cjs/react-is.development.js +177 -0
  90. package/lib/esm/node_modules/react-is/cjs/react-is.production.min.js +127 -0
  91. package/lib/esm/node_modules/react-is/index.js +19 -0
  92. package/lib/esm/node_modules/react-resizable/build/Resizable.js +358 -0
  93. package/lib/esm/node_modules/react-resizable/build/ResizableBox.js +236 -0
  94. package/lib/esm/node_modules/react-resizable/build/propTypes.js +110 -0
  95. package/lib/esm/node_modules/react-resizable/build/utils.js +74 -0
  96. package/lib/esm/node_modules/react-resizable/index.js +20 -0
  97. package/lib/esm/packages/icons/lib/esm/components/common/search-outlined.js +53 -0
  98. package/lib/esm/packages/icons/lib/esm/styles/index.scss.js +23 -0
  99. package/lib/esm/styles/index.scss.js +13 -0
  100. package/lib/types/Content.d.ts +8 -0
  101. package/lib/types/Layout.d.ts +8 -0
  102. package/lib/types/SearchTrigger.d.ts +10 -0
  103. package/lib/types/Sider.d.ts +10 -0
  104. package/lib/types/index.d.ts +6 -0
  105. package/package.json +61 -0
@@ -0,0 +1,366 @@
1
+ /** @LICENSE
2
+ * @hi-ui/layout
3
+ * https://github.com/XiaoMi/hiui/tree/master/packages/ui/layout#readme
4
+ *
5
+ * Copyright (c) HiUI <mi-hiui@xiaomi.com>.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
10
+ 'use strict';
11
+
12
+ var _typeof = require("@babel/runtime/helpers/typeof");
13
+ var Resizable$1 = require('../../../_virtual/Resizable.js');
14
+ var React$1 = require('react');
15
+ require('../../react-draggable/build/cjs/cjs.js');
16
+ require('./utils.js');
17
+ require('./propTypes.js');
18
+ var propTypes = require('../../../_virtual/propTypes.js');
19
+ var cjs = require('../../../_virtual/cjs.js');
20
+ var utils = require('../../../_virtual/utils.js');
21
+ function _interopDefaultCompat(e) {
22
+ return e && _typeof(e) === 'object' && 'default' in e ? e : {
23
+ 'default': e
24
+ };
25
+ }
26
+ var React__default = /*#__PURE__*/_interopDefaultCompat(React$1);
27
+ Resizable$1.__exports.__esModule = true;
28
+ Resizable$1.__exports["default"] = void 0;
29
+ var React = _interopRequireWildcard(React__default["default"]);
30
+ var _reactDraggable = cjs.cjs.exports;
31
+ var _utils = utils.__exports;
32
+ var _propTypes = propTypes.__exports;
33
+ var _excluded = ["children", "className", "draggableOpts", "width", "height", "handle", "handleSize", "lockAspectRatio", "axis", "minConstraints", "maxConstraints", "onResize", "onResizeStop", "onResizeStart", "resizeHandles", "transformScale"];
34
+ function _getRequireWildcardCache(nodeInterop) {
35
+ if (typeof WeakMap !== "function") return null;
36
+ var cacheBabelInterop = new WeakMap();
37
+ var cacheNodeInterop = new WeakMap();
38
+ return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) {
39
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
40
+ })(nodeInterop);
41
+ }
42
+ function _interopRequireWildcard(obj, nodeInterop) {
43
+ if (!nodeInterop && obj && obj.__esModule) {
44
+ return obj;
45
+ }
46
+ if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") {
47
+ return {
48
+ "default": obj
49
+ };
50
+ }
51
+ var cache = _getRequireWildcardCache(nodeInterop);
52
+ if (cache && cache.has(obj)) {
53
+ return cache.get(obj);
54
+ }
55
+ var newObj = {};
56
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
57
+ for (var key in obj) {
58
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
59
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
60
+ if (desc && (desc.get || desc.set)) {
61
+ Object.defineProperty(newObj, key, desc);
62
+ } else {
63
+ newObj[key] = obj[key];
64
+ }
65
+ }
66
+ }
67
+ newObj["default"] = obj;
68
+ if (cache) {
69
+ cache.set(obj, newObj);
70
+ }
71
+ return newObj;
72
+ }
73
+ function _extends() {
74
+ _extends = Object.assign || function (target) {
75
+ for (var i = 1; i < arguments.length; i++) {
76
+ var source = arguments[i];
77
+ for (var key in source) {
78
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
79
+ target[key] = source[key];
80
+ }
81
+ }
82
+ }
83
+ return target;
84
+ };
85
+ return _extends.apply(this, arguments);
86
+ }
87
+ function _objectWithoutPropertiesLoose(source, excluded) {
88
+ if (source == null) return {};
89
+ var target = {};
90
+ var sourceKeys = Object.keys(source);
91
+ var key, i;
92
+ for (i = 0; i < sourceKeys.length; i++) {
93
+ key = sourceKeys[i];
94
+ if (excluded.indexOf(key) >= 0) continue;
95
+ target[key] = source[key];
96
+ }
97
+ return target;
98
+ }
99
+ function ownKeys(object, enumerableOnly) {
100
+ var keys = Object.keys(object);
101
+ if (Object.getOwnPropertySymbols) {
102
+ var symbols = Object.getOwnPropertySymbols(object);
103
+ if (enumerableOnly) {
104
+ symbols = symbols.filter(function (sym) {
105
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
106
+ });
107
+ }
108
+ keys.push.apply(keys, symbols);
109
+ }
110
+ return keys;
111
+ }
112
+ function _objectSpread(target) {
113
+ for (var i = 1; i < arguments.length; i++) {
114
+ var source = arguments[i] != null ? arguments[i] : {};
115
+ if (i % 2) {
116
+ ownKeys(Object(source), true).forEach(function (key) {
117
+ _defineProperty(target, key, source[key]);
118
+ });
119
+ } else if (Object.getOwnPropertyDescriptors) {
120
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
121
+ } else {
122
+ ownKeys(Object(source)).forEach(function (key) {
123
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
124
+ });
125
+ }
126
+ }
127
+ return target;
128
+ }
129
+ function _defineProperty(obj, key, value) {
130
+ if (key in obj) {
131
+ Object.defineProperty(obj, key, {
132
+ value: value,
133
+ enumerable: true,
134
+ configurable: true,
135
+ writable: true
136
+ });
137
+ } else {
138
+ obj[key] = value;
139
+ }
140
+ return obj;
141
+ }
142
+ function _inheritsLoose(subClass, superClass) {
143
+ subClass.prototype = Object.create(superClass.prototype);
144
+ subClass.prototype.constructor = subClass;
145
+ _setPrototypeOf(subClass, superClass);
146
+ }
147
+ function _setPrototypeOf(o, p) {
148
+ _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
149
+ o.__proto__ = p;
150
+ return o;
151
+ };
152
+ return _setPrototypeOf(o, p);
153
+ }
154
+
155
+ // The base <Resizable> component.
156
+ // This component does not have state and relies on the parent to set its props based on callback data.
157
+ var Resizable = /*#__PURE__*/function (_React$Component) {
158
+ _inheritsLoose(Resizable, _React$Component);
159
+ function Resizable() {
160
+ var _this;
161
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
162
+ args[_key] = arguments[_key];
163
+ }
164
+ _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
165
+ _this.handleRefs = {};
166
+ _this.lastHandleRect = null;
167
+ _this.slack = null;
168
+ return _this;
169
+ }
170
+ var _proto = Resizable.prototype;
171
+ _proto.componentWillUnmount = function componentWillUnmount() {
172
+ this.resetData();
173
+ };
174
+ _proto.resetData = function resetData() {
175
+ this.lastHandleRect = this.slack = null;
176
+ } // Clamp width and height within provided constraints
177
+ ;
178
+
179
+ _proto.runConstraints = function runConstraints(width, height) {
180
+ var _this$props = this.props,
181
+ minConstraints = _this$props.minConstraints,
182
+ maxConstraints = _this$props.maxConstraints,
183
+ lockAspectRatio = _this$props.lockAspectRatio; // short circuit
184
+
185
+ if (!minConstraints && !maxConstraints && !lockAspectRatio) return [width, height]; // If constraining to min and max, we need to also fit width and height to aspect ratio.
186
+
187
+ if (lockAspectRatio) {
188
+ var ratio = this.props.width / this.props.height;
189
+ var deltaW = width - this.props.width;
190
+ var deltaH = height - this.props.height; // Find which coordinate was greater and should push the other toward it.
191
+ // E.g.:
192
+ // ratio = 1, deltaW = 10, deltaH = 5, deltaH should become 10.
193
+ // ratio = 2, deltaW = 10, deltaH = 6, deltaW should become 12.
194
+
195
+ if (Math.abs(deltaW) > Math.abs(deltaH * ratio)) {
196
+ height = width / ratio;
197
+ } else {
198
+ width = height * ratio;
199
+ }
200
+ }
201
+ var oldW = width,
202
+ oldH = height; // Add slack to the values used to calculate bound position. This will ensure that if
203
+ // we start removing slack, the element won't react to it right away until it's been
204
+ // completely removed.
205
+
206
+ var _ref = this.slack || [0, 0],
207
+ slackW = _ref[0],
208
+ slackH = _ref[1];
209
+ width += slackW;
210
+ height += slackH;
211
+ if (minConstraints) {
212
+ width = Math.max(minConstraints[0], width);
213
+ height = Math.max(minConstraints[1], height);
214
+ }
215
+ if (maxConstraints) {
216
+ width = Math.min(maxConstraints[0], width);
217
+ height = Math.min(maxConstraints[1], height);
218
+ } // If the width or height changed, we must have introduced some slack. Record it for the next iteration.
219
+
220
+ this.slack = [slackW + (oldW - width), slackH + (oldH - height)];
221
+ return [width, height];
222
+ }
223
+ /**
224
+ * Wrapper around drag events to provide more useful data.
225
+ *
226
+ * @param {String} handlerName Handler name to wrap.
227
+ * @return {Function} Handler function.
228
+ */;
229
+
230
+ _proto.resizeHandler = function resizeHandler(handlerName, axis) {
231
+ var _this2 = this;
232
+ return function (e, _ref2) {
233
+ var node = _ref2.node,
234
+ deltaX = _ref2.deltaX,
235
+ deltaY = _ref2.deltaY;
236
+ // Reset data in case it was left over somehow (should not be possible)
237
+ if (handlerName === 'onResizeStart') _this2.resetData(); // Axis restrictions
238
+
239
+ var canDragX = (_this2.props.axis === 'both' || _this2.props.axis === 'x') && axis !== 'n' && axis !== 's';
240
+ var canDragY = (_this2.props.axis === 'both' || _this2.props.axis === 'y') && axis !== 'e' && axis !== 'w'; // No dragging possible.
241
+
242
+ if (!canDragX && !canDragY) return; // Decompose axis for later use
243
+
244
+ var axisV = axis[0];
245
+ var axisH = axis[axis.length - 1]; // intentionally not axis[1], so that this catches axis === 'w' for example
246
+ // Track the element being dragged to account for changes in position.
247
+ // If a handle's position is changed between callbacks, we need to factor this in to the next callback.
248
+ // Failure to do so will cause the element to "skip" when resized upwards or leftwards.
249
+
250
+ var handleRect = node.getBoundingClientRect();
251
+ if (_this2.lastHandleRect != null) {
252
+ // If the handle has repositioned on either axis since last render,
253
+ // we need to increase our callback values by this much.
254
+ // Only checking 'n', 'w' since resizing by 's', 'w' won't affect the overall position on page,
255
+ if (axisH === 'w') {
256
+ var deltaLeftSinceLast = handleRect.left - _this2.lastHandleRect.left;
257
+ deltaX += deltaLeftSinceLast;
258
+ }
259
+ if (axisV === 'n') {
260
+ var deltaTopSinceLast = handleRect.top - _this2.lastHandleRect.top;
261
+ deltaY += deltaTopSinceLast;
262
+ }
263
+ } // Storage of last rect so we know how much it has really moved.
264
+
265
+ _this2.lastHandleRect = handleRect; // Reverse delta if using top or left drag handles.
266
+
267
+ if (axisH === 'w') deltaX = -deltaX;
268
+ if (axisV === 'n') deltaY = -deltaY; // Update w/h by the deltas. Also factor in transformScale.
269
+
270
+ var width = _this2.props.width + (canDragX ? deltaX / _this2.props.transformScale : 0);
271
+ var height = _this2.props.height + (canDragY ? deltaY / _this2.props.transformScale : 0); // Run user-provided constraints.
272
+
273
+ var _this2$runConstraints = _this2.runConstraints(width, height);
274
+ width = _this2$runConstraints[0];
275
+ height = _this2$runConstraints[1];
276
+ var dimensionsChanged = width !== _this2.props.width || height !== _this2.props.height; // Call user-supplied callback if present.
277
+
278
+ var cb = typeof _this2.props[handlerName] === 'function' ? _this2.props[handlerName] : null; // Don't call 'onResize' if dimensions haven't changed.
279
+
280
+ var shouldSkipCb = handlerName === 'onResize' && !dimensionsChanged;
281
+ if (cb && !shouldSkipCb) {
282
+ e.persist == null ? void 0 : e.persist();
283
+ cb(e, {
284
+ node: node,
285
+ size: {
286
+ width: width,
287
+ height: height
288
+ },
289
+ handle: axis
290
+ });
291
+ } // Reset internal data
292
+
293
+ if (handlerName === 'onResizeStop') _this2.resetData();
294
+ };
295
+ } // Render a resize handle given an axis & DOM ref. Ref *must* be attached for
296
+ // the underlying draggable library to work properly.
297
+ ;
298
+
299
+ _proto.renderResizeHandle = function renderResizeHandle(handleAxis, ref) {
300
+ var handle = this.props.handle; // No handle provided, make the default
301
+
302
+ if (!handle) {
303
+ return /*#__PURE__*/React.createElement("span", {
304
+ className: "react-resizable-handle react-resizable-handle-" + handleAxis,
305
+ ref: ref
306
+ });
307
+ } // Handle is a function, such as:
308
+ // `handle={(handleAxis) => <span className={...} />}`
309
+
310
+ if (typeof handle === 'function') {
311
+ return handle(handleAxis, ref);
312
+ } // Handle is a React component (composite or DOM).
313
+
314
+ var isDOMElement = typeof handle.type === 'string';
315
+ var props = _objectSpread({
316
+ ref: ref
317
+ }, isDOMElement ? {} : {
318
+ handleAxis: handleAxis
319
+ });
320
+ return /*#__PURE__*/React.cloneElement(handle, props);
321
+ };
322
+ _proto.render = function render() {
323
+ var _this3 = this;
324
+
325
+ // Pass along only props not meant for the `<Resizable>`.`
326
+ // eslint-disable-next-line no-unused-vars
327
+ var _this$props2 = this.props,
328
+ children = _this$props2.children,
329
+ className = _this$props2.className,
330
+ draggableOpts = _this$props2.draggableOpts,
331
+ resizeHandles = _this$props2.resizeHandles,
332
+ p = _objectWithoutPropertiesLoose(_this$props2, _excluded); // What we're doing here is getting the child of this element, and cloning it with this element's props.
333
+ // We are then defining its children as:
334
+ // 1. Its original children (resizable's child's children), and
335
+ // 2. One or more draggable handles.
336
+
337
+ return (0, _utils.cloneElement)(children, _objectSpread(_objectSpread({}, p), {}, {
338
+ className: (className ? className + " " : '') + "react-resizable",
339
+ children: [].concat(children.props.children, resizeHandles.map(function (handleAxis) {
340
+ var _this3$handleRefs$han;
341
+
342
+ // Create a ref to the handle so that `<DraggableCore>` doesn't have to use ReactDOM.findDOMNode().
343
+ var ref = (_this3$handleRefs$han = _this3.handleRefs[handleAxis]) != null ? _this3$handleRefs$han : _this3.handleRefs[handleAxis] = /*#__PURE__*/React.createRef();
344
+ return /*#__PURE__*/React.createElement(_reactDraggable.DraggableCore, _extends({}, draggableOpts, {
345
+ nodeRef: ref,
346
+ key: "resizableHandle-" + handleAxis,
347
+ onStop: _this3.resizeHandler('onResizeStop', handleAxis),
348
+ onStart: _this3.resizeHandler('onResizeStart', handleAxis),
349
+ onDrag: _this3.resizeHandler('onResize', handleAxis)
350
+ }), _this3.renderResizeHandle(handleAxis, ref));
351
+ }))
352
+ }));
353
+ };
354
+ return Resizable;
355
+ }(React.Component);
356
+ Resizable$1.__exports["default"] = Resizable;
357
+ Resizable.propTypes = _propTypes.resizableProps;
358
+ Resizable.defaultProps = {
359
+ axis: 'both',
360
+ handleSize: [20, 20],
361
+ lockAspectRatio: false,
362
+ minConstraints: [20, 20],
363
+ maxConstraints: [Infinity, Infinity],
364
+ resizeHandles: ['se'],
365
+ transformScale: 1
366
+ };
@@ -0,0 +1,244 @@
1
+ /** @LICENSE
2
+ * @hi-ui/layout
3
+ * https://github.com/XiaoMi/hiui/tree/master/packages/ui/layout#readme
4
+ *
5
+ * Copyright (c) HiUI <mi-hiui@xiaomi.com>.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
10
+ 'use strict';
11
+
12
+ var _typeof = require("@babel/runtime/helpers/typeof");
13
+ var ResizableBox$1 = require('../../../_virtual/ResizableBox.js');
14
+ var React$1 = require('react');
15
+ require('../../prop-types/index.js');
16
+ require('./Resizable.js');
17
+ require('./propTypes.js');
18
+ var propTypes = require('../../../_virtual/propTypes.js');
19
+ var index = require('../../../_virtual/index2.js');
20
+ var Resizable = require('../../../_virtual/Resizable.js');
21
+ function _interopDefaultCompat(e) {
22
+ return e && _typeof(e) === 'object' && 'default' in e ? e : {
23
+ 'default': e
24
+ };
25
+ }
26
+ var React__default = /*#__PURE__*/_interopDefaultCompat(React$1);
27
+ ResizableBox$1.__exports.__esModule = true;
28
+ ResizableBox$1.__exports["default"] = void 0;
29
+ var React = _interopRequireWildcard(React__default["default"]);
30
+ var _propTypes = _interopRequireDefault(index.propTypes.exports);
31
+ var _Resizable = _interopRequireDefault(Resizable.__exports);
32
+ var _propTypes2 = propTypes.__exports;
33
+ var _excluded = ["handle", "handleSize", "onResize", "onResizeStart", "onResizeStop", "draggableOpts", "minConstraints", "maxConstraints", "lockAspectRatio", "axis", "width", "height", "resizeHandles", "style", "transformScale"];
34
+ function _interopRequireDefault(obj) {
35
+ return obj && obj.__esModule ? obj : {
36
+ "default": obj
37
+ };
38
+ }
39
+ function _getRequireWildcardCache(nodeInterop) {
40
+ if (typeof WeakMap !== "function") return null;
41
+ var cacheBabelInterop = new WeakMap();
42
+ var cacheNodeInterop = new WeakMap();
43
+ return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) {
44
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
45
+ })(nodeInterop);
46
+ }
47
+ function _interopRequireWildcard(obj, nodeInterop) {
48
+ if (!nodeInterop && obj && obj.__esModule) {
49
+ return obj;
50
+ }
51
+ if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") {
52
+ return {
53
+ "default": obj
54
+ };
55
+ }
56
+ var cache = _getRequireWildcardCache(nodeInterop);
57
+ if (cache && cache.has(obj)) {
58
+ return cache.get(obj);
59
+ }
60
+ var newObj = {};
61
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
62
+ for (var key in obj) {
63
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
64
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
65
+ if (desc && (desc.get || desc.set)) {
66
+ Object.defineProperty(newObj, key, desc);
67
+ } else {
68
+ newObj[key] = obj[key];
69
+ }
70
+ }
71
+ }
72
+ newObj["default"] = obj;
73
+ if (cache) {
74
+ cache.set(obj, newObj);
75
+ }
76
+ return newObj;
77
+ }
78
+ function _extends() {
79
+ _extends = Object.assign || function (target) {
80
+ for (var i = 1; i < arguments.length; i++) {
81
+ var source = arguments[i];
82
+ for (var key in source) {
83
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
84
+ target[key] = source[key];
85
+ }
86
+ }
87
+ }
88
+ return target;
89
+ };
90
+ return _extends.apply(this, arguments);
91
+ }
92
+ function ownKeys(object, enumerableOnly) {
93
+ var keys = Object.keys(object);
94
+ if (Object.getOwnPropertySymbols) {
95
+ var symbols = Object.getOwnPropertySymbols(object);
96
+ if (enumerableOnly) {
97
+ symbols = symbols.filter(function (sym) {
98
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
99
+ });
100
+ }
101
+ keys.push.apply(keys, symbols);
102
+ }
103
+ return keys;
104
+ }
105
+ function _objectSpread(target) {
106
+ for (var i = 1; i < arguments.length; i++) {
107
+ var source = arguments[i] != null ? arguments[i] : {};
108
+ if (i % 2) {
109
+ ownKeys(Object(source), true).forEach(function (key) {
110
+ _defineProperty(target, key, source[key]);
111
+ });
112
+ } else if (Object.getOwnPropertyDescriptors) {
113
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
114
+ } else {
115
+ ownKeys(Object(source)).forEach(function (key) {
116
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
117
+ });
118
+ }
119
+ }
120
+ return target;
121
+ }
122
+ function _defineProperty(obj, key, value) {
123
+ if (key in obj) {
124
+ Object.defineProperty(obj, key, {
125
+ value: value,
126
+ enumerable: true,
127
+ configurable: true,
128
+ writable: true
129
+ });
130
+ } else {
131
+ obj[key] = value;
132
+ }
133
+ return obj;
134
+ }
135
+ function _objectWithoutPropertiesLoose(source, excluded) {
136
+ if (source == null) return {};
137
+ var target = {};
138
+ var sourceKeys = Object.keys(source);
139
+ var key, i;
140
+ for (i = 0; i < sourceKeys.length; i++) {
141
+ key = sourceKeys[i];
142
+ if (excluded.indexOf(key) >= 0) continue;
143
+ target[key] = source[key];
144
+ }
145
+ return target;
146
+ }
147
+ function _inheritsLoose(subClass, superClass) {
148
+ subClass.prototype = Object.create(superClass.prototype);
149
+ subClass.prototype.constructor = subClass;
150
+ _setPrototypeOf(subClass, superClass);
151
+ }
152
+ function _setPrototypeOf(o, p) {
153
+ _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
154
+ o.__proto__ = p;
155
+ return o;
156
+ };
157
+ return _setPrototypeOf(o, p);
158
+ }
159
+ var ResizableBox = /*#__PURE__*/function (_React$Component) {
160
+ _inheritsLoose(ResizableBox, _React$Component);
161
+ function ResizableBox() {
162
+ var _this;
163
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
164
+ args[_key] = arguments[_key];
165
+ }
166
+ _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
167
+ _this.state = {
168
+ width: _this.props.width,
169
+ height: _this.props.height,
170
+ propsWidth: _this.props.width,
171
+ propsHeight: _this.props.height
172
+ };
173
+ _this.onResize = function (e, data) {
174
+ var size = data.size;
175
+ if (_this.props.onResize) {
176
+ e.persist == null ? void 0 : e.persist();
177
+ _this.setState(size, function () {
178
+ return _this.props.onResize && _this.props.onResize(e, data);
179
+ });
180
+ } else {
181
+ _this.setState(size);
182
+ }
183
+ };
184
+ return _this;
185
+ }
186
+ ResizableBox.getDerivedStateFromProps = function getDerivedStateFromProps(props, state) {
187
+ // If parent changes height/width, set that in our state.
188
+ if (state.propsWidth !== props.width || state.propsHeight !== props.height) {
189
+ return {
190
+ width: props.width,
191
+ height: props.height,
192
+ propsWidth: props.width,
193
+ propsHeight: props.height
194
+ };
195
+ }
196
+ return null;
197
+ };
198
+ var _proto = ResizableBox.prototype;
199
+ _proto.render = function render() {
200
+ // Basic wrapper around a Resizable instance.
201
+ // If you use Resizable directly, you are responsible for updating the child component
202
+ // with a new width and height.
203
+ var _this$props = this.props,
204
+ handle = _this$props.handle,
205
+ handleSize = _this$props.handleSize,
206
+ onResizeStart = _this$props.onResizeStart,
207
+ onResizeStop = _this$props.onResizeStop,
208
+ draggableOpts = _this$props.draggableOpts,
209
+ minConstraints = _this$props.minConstraints,
210
+ maxConstraints = _this$props.maxConstraints,
211
+ lockAspectRatio = _this$props.lockAspectRatio,
212
+ axis = _this$props.axis,
213
+ resizeHandles = _this$props.resizeHandles,
214
+ style = _this$props.style,
215
+ transformScale = _this$props.transformScale,
216
+ props = _objectWithoutPropertiesLoose(_this$props, _excluded);
217
+ return /*#__PURE__*/React.createElement(_Resizable["default"], {
218
+ axis: axis,
219
+ draggableOpts: draggableOpts,
220
+ handle: handle,
221
+ handleSize: handleSize,
222
+ height: this.state.height,
223
+ lockAspectRatio: lockAspectRatio,
224
+ maxConstraints: maxConstraints,
225
+ minConstraints: minConstraints,
226
+ onResizeStart: onResizeStart,
227
+ onResize: this.onResize,
228
+ onResizeStop: onResizeStop,
229
+ resizeHandles: resizeHandles,
230
+ transformScale: transformScale,
231
+ width: this.state.width
232
+ }, /*#__PURE__*/React.createElement("div", _extends({}, props, {
233
+ style: _objectSpread(_objectSpread({}, style), {}, {
234
+ width: this.state.width + 'px',
235
+ height: this.state.height + 'px'
236
+ })
237
+ })));
238
+ };
239
+ return ResizableBox;
240
+ }(React.Component);
241
+ ResizableBox$1.__exports["default"] = ResizableBox;
242
+ ResizableBox.propTypes = _objectSpread(_objectSpread({}, _propTypes2.resizableProps), {}, {
243
+ children: _propTypes["default"].element
244
+ });