react-resizable 1.7.5 → 1.11.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.
- package/.babelrc +10 -4
- package/.browserslistrc +3 -0
- package/.eslintrc +10 -6
- package/.flowconfig +9 -11
- package/CHANGELOG.md +59 -29
- package/LICENSE +21 -0
- package/README.md +18 -5
- package/__tests__/Resizable.test.js +245 -0
- package/__tests__/ResizableBox.test.js +99 -0
- package/__tests__/__snapshots__/Resizable.test.js.snap +29 -0
- package/__tests__/__snapshots__/ResizableBox.test.js.snap +23 -0
- package/build/Resizable.js +183 -177
- package/build/Resizable.js.flow +115 -152
- package/build/ResizableBox.js +95 -75
- package/build/ResizableBox.js.flow +61 -34
- package/build/propTypes.js +112 -0
- package/build/propTypes.js.flow +135 -0
- package/build/utils.js +27 -0
- package/build/{cloneElement.js.flow → utils.js.flow} +2 -2
- package/coverage/clover.xml +107 -0
- package/coverage/coverage-final.json +5 -0
- package/coverage/lcov-report/Resizable.js.html +665 -0
- package/coverage/lcov-report/ResizableBox.js.html +374 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +79 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/flow-typed/npm/index.html +111 -0
- package/coverage/lcov-report/flow-typed/npm/jest_v26.x.x.js.html +3734 -0
- package/coverage/lcov-report/index.html +156 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/propTypes.js.html +485 -0
- package/coverage/lcov-report/react-resizable/dist/bundle.js.html +95 -0
- package/coverage/lcov-report/react-resizable/dist/index.html +111 -0
- package/coverage/lcov-report/react-resizable/flow-typed/npm/index.html +111 -0
- package/coverage/lcov-report/react-resizable/flow-typed/npm/jest_v26.x.x.js.html +3734 -0
- package/coverage/lcov-report/react-resizable/index.html +111 -0
- package/coverage/lcov-report/react-resizable/index.js.html +101 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +170 -0
- package/coverage/lcov-report/utils.js.html +122 -0
- package/coverage/lcov.info +233 -0
- package/css/styles.css +53 -5
- package/dist/bundle.js +6 -0
- package/flow-typed/npm/jest_v26.x.x.js +1218 -0
- package/package.json +33 -25
- package/setupTests/enzyme.js +4 -0
- package/.github/ISSUE_TEMPLATE.md +0 -23
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -6
- package/build/cloneElement.js +0 -20
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`render Resizable snapshot default props 1`] = `
|
|
4
|
+
<div
|
|
5
|
+
className="test-classname react-resizable"
|
|
6
|
+
style={
|
|
7
|
+
Object {
|
|
8
|
+
"height": "50px",
|
|
9
|
+
"width": "50px",
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
>
|
|
13
|
+
<span
|
|
14
|
+
className="children"
|
|
15
|
+
/>
|
|
16
|
+
<span
|
|
17
|
+
className="react-resizable-handle react-resizable-handle-se"
|
|
18
|
+
onMouseDown={[Function]}
|
|
19
|
+
onMouseUp={[Function]}
|
|
20
|
+
onTouchEnd={[Function]}
|
|
21
|
+
/>
|
|
22
|
+
<span
|
|
23
|
+
className="react-resizable-handle react-resizable-handle-e"
|
|
24
|
+
onMouseDown={[Function]}
|
|
25
|
+
onMouseUp={[Function]}
|
|
26
|
+
onTouchEnd={[Function]}
|
|
27
|
+
/>
|
|
28
|
+
</div>
|
|
29
|
+
`;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`render ResizableBox snapshot default props 1`] = `
|
|
4
|
+
<div
|
|
5
|
+
className="react-resizable"
|
|
6
|
+
style={
|
|
7
|
+
Object {
|
|
8
|
+
"height": "50px",
|
|
9
|
+
"width": "50px",
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
>
|
|
13
|
+
<span
|
|
14
|
+
className="children"
|
|
15
|
+
/>
|
|
16
|
+
<span
|
|
17
|
+
className="test-class-w"
|
|
18
|
+
onMouseDown={[Function]}
|
|
19
|
+
onMouseUp={[Function]}
|
|
20
|
+
onTouchEnd={[Function]}
|
|
21
|
+
/>
|
|
22
|
+
</div>
|
|
23
|
+
`;
|
package/build/Resizable.js
CHANGED
|
@@ -1,95 +1,101 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
+
exports.default = void 0;
|
|
4
5
|
|
|
5
|
-
var
|
|
6
|
+
var _react = _interopRequireDefault(require("react"));
|
|
6
7
|
|
|
7
|
-
var
|
|
8
|
+
var _reactDraggable = require("react-draggable");
|
|
8
9
|
|
|
9
|
-
var
|
|
10
|
+
var _utils = require("./utils");
|
|
10
11
|
|
|
11
|
-
var _propTypes = require(
|
|
12
|
+
var _propTypes = require("./propTypes");
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var _reactDraggable = require('react-draggable');
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
15
|
|
|
17
|
-
var
|
|
16
|
+
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); }
|
|
18
17
|
|
|
19
|
-
var
|
|
18
|
+
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; }
|
|
20
19
|
|
|
21
|
-
function
|
|
20
|
+
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; }
|
|
22
21
|
|
|
23
|
-
function
|
|
22
|
+
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; }
|
|
24
23
|
|
|
25
|
-
function
|
|
24
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
26
25
|
|
|
27
|
-
function
|
|
26
|
+
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
|
|
28
27
|
|
|
29
|
-
function
|
|
28
|
+
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; }
|
|
30
29
|
|
|
31
|
-
var Resizable = function (_React$Component) {
|
|
32
|
-
|
|
30
|
+
var Resizable = /*#__PURE__*/function (_React$Component) {
|
|
31
|
+
_inheritsLoose(Resizable, _React$Component);
|
|
33
32
|
|
|
34
33
|
function Resizable() {
|
|
35
|
-
var
|
|
36
|
-
|
|
37
|
-
_classCallCheck(this, Resizable);
|
|
34
|
+
var _this;
|
|
38
35
|
|
|
39
|
-
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
|
36
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
40
37
|
args[_key] = arguments[_key];
|
|
41
38
|
}
|
|
42
39
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
40
|
+
_this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
|
|
41
|
+
|
|
42
|
+
_defineProperty(_assertThisInitialized(_this), "state", undefined);
|
|
43
|
+
|
|
44
|
+
_defineProperty(_assertThisInitialized(_this), "lastHandleRect", null);
|
|
45
|
+
|
|
46
|
+
_defineProperty(_assertThisInitialized(_this), "slack", null);
|
|
47
|
+
|
|
48
|
+
return _this;
|
|
48
49
|
}
|
|
49
50
|
|
|
50
|
-
Resizable.prototype
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
width: nextProps.width,
|
|
55
|
-
height: nextProps.height
|
|
56
|
-
});
|
|
57
|
-
}
|
|
51
|
+
var _proto = Resizable.prototype;
|
|
52
|
+
|
|
53
|
+
_proto.componentWillUnmount = function componentWillUnmount() {
|
|
54
|
+
this.resetData();
|
|
58
55
|
};
|
|
59
56
|
|
|
60
|
-
|
|
57
|
+
_proto.lockAspectRatio = function lockAspectRatio(width, height, aspectRatio) {
|
|
61
58
|
height = width / aspectRatio;
|
|
62
59
|
width = height * aspectRatio;
|
|
63
60
|
return [width, height];
|
|
64
61
|
};
|
|
65
62
|
|
|
66
|
-
|
|
63
|
+
_proto.resetData = function resetData() {
|
|
64
|
+
this.lastHandleRect = this.slack = null;
|
|
65
|
+
} // Clamp width and height within provided constraints
|
|
66
|
+
;
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
Resizable.prototype.runConstraints = function runConstraints(width, height) {
|
|
68
|
+
_proto.runConstraints = function runConstraints(width, height) {
|
|
70
69
|
var _ref = [this.props.minConstraints, this.props.maxConstraints],
|
|
71
70
|
min = _ref[0],
|
|
72
71
|
max = _ref[1];
|
|
73
|
-
|
|
72
|
+
if (!min && !max) return [width, height]; // If constraining to min and max, we need to also fit width and height to aspect ratio.
|
|
74
73
|
|
|
75
74
|
if (this.props.lockAspectRatio) {
|
|
76
|
-
var
|
|
77
|
-
height = width / ratio;
|
|
78
|
-
width = height * ratio;
|
|
79
|
-
}
|
|
75
|
+
var resizingHorizontally = height === this.props.height;
|
|
80
76
|
|
|
81
|
-
|
|
77
|
+
if (resizingHorizontally) {
|
|
78
|
+
var ratio = this.props.width / this.props.height;
|
|
79
|
+
height = width / ratio;
|
|
80
|
+
width = height * ratio;
|
|
81
|
+
} else {
|
|
82
|
+
// Take into account vertical resize with N/S handles on locked aspect
|
|
83
|
+
// ratio. Calculate the change height-first, instead of width-first
|
|
84
|
+
var _ratio = this.props.height / this.props.width;
|
|
82
85
|
|
|
83
|
-
|
|
84
|
-
|
|
86
|
+
width = height / _ratio;
|
|
87
|
+
height = width * _ratio;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
85
90
|
|
|
86
|
-
|
|
91
|
+
var oldW = width,
|
|
92
|
+
oldH = height; // Add slack to the values used to calculate bound position. This will ensure that if
|
|
87
93
|
// we start removing slack, the element won't react to it right away until it's been
|
|
88
94
|
// completely removed.
|
|
89
95
|
|
|
90
|
-
var
|
|
91
|
-
slackW =
|
|
92
|
-
slackH =
|
|
96
|
+
var _ref2 = this.slack || [0, 0],
|
|
97
|
+
slackW = _ref2[0],
|
|
98
|
+
slackH = _ref2[1];
|
|
93
99
|
|
|
94
100
|
width += slackW;
|
|
95
101
|
height += slackH;
|
|
@@ -98,168 +104,168 @@ var Resizable = function (_React$Component) {
|
|
|
98
104
|
width = Math.max(min[0], width);
|
|
99
105
|
height = Math.max(min[1], height);
|
|
100
106
|
}
|
|
107
|
+
|
|
101
108
|
if (max) {
|
|
102
109
|
width = Math.min(max[0], width);
|
|
103
110
|
height = Math.min(max[1], height);
|
|
104
|
-
}
|
|
111
|
+
} // If the width or height changed, we must have introduced some slack. Record it for the next iteration.
|
|
105
112
|
|
|
106
|
-
// If the numbers changed, we must have introduced some slack. Record it for the next iteration.
|
|
107
|
-
slackW += oldW - width;
|
|
108
|
-
slackH += oldH - height;
|
|
109
|
-
if (slackW !== this.state.slackW || slackH !== this.state.slackH) {
|
|
110
|
-
this.setState({ slackW: slackW, slackH: slackH });
|
|
111
|
-
}
|
|
112
113
|
|
|
114
|
+
this.slack = [slackW + (oldW - width), slackH + (oldH - height)];
|
|
113
115
|
return [width, height];
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
+
}
|
|
116
117
|
/**
|
|
117
118
|
* Wrapper around drag events to provide more useful data.
|
|
118
119
|
*
|
|
119
120
|
* @param {String} handlerName Handler name to wrap.
|
|
120
121
|
* @return {Function} Handler function.
|
|
121
122
|
*/
|
|
123
|
+
;
|
|
122
124
|
|
|
123
|
-
|
|
124
|
-
Resizable.prototype.resizeHandler = function resizeHandler(handlerName) {
|
|
125
|
+
_proto.resizeHandler = function resizeHandler(handlerName, axis) {
|
|
125
126
|
var _this2 = this;
|
|
126
127
|
|
|
127
|
-
return function (e,
|
|
128
|
-
var node =
|
|
129
|
-
deltaX =
|
|
130
|
-
deltaY =
|
|
128
|
+
return function (e, _ref3) {
|
|
129
|
+
var node = _ref3.node,
|
|
130
|
+
deltaX = _ref3.deltaX,
|
|
131
|
+
deltaY = _ref3.deltaY;
|
|
132
|
+
// Reset data in case it was left over somehow (should not be possible)
|
|
133
|
+
if (handlerName === 'onResizeStart') _this2.resetData(); // Axis restrictions
|
|
131
134
|
|
|
135
|
+
var canDragX = (_this2.props.axis === 'both' || _this2.props.axis === 'x') && axis !== 'n' && axis !== 's';
|
|
136
|
+
var canDragY = (_this2.props.axis === 'both' || _this2.props.axis === 'y') && axis !== 'e' && axis !== 'w'; // No dragging possible.
|
|
132
137
|
|
|
133
|
-
//
|
|
134
|
-
var canDragX = _this2.props.axis === 'both' || _this2.props.axis === 'x';
|
|
135
|
-
var canDragY = _this2.props.axis === 'both' || _this2.props.axis === 'y';
|
|
138
|
+
if (!canDragX && !canDragY) return; // Decompose axis for later use
|
|
136
139
|
|
|
137
|
-
|
|
138
|
-
var
|
|
139
|
-
|
|
140
|
+
var axisV = axis[0];
|
|
141
|
+
var axisH = axis[axis.length - 1]; // intentionally not axis[1], so that this catches axis === 'w' for example
|
|
142
|
+
// Track the element being dragged to account for changes in position.
|
|
143
|
+
// If a handle's position is changed between callbacks, we need to factor this in to the next callback.
|
|
144
|
+
// Failure to do so will cause the element to "skip" when resized upwards or leftwards.
|
|
140
145
|
|
|
141
|
-
|
|
142
|
-
var widthChanged = width !== _this2.state.width,
|
|
143
|
-
heightChanged = height !== _this2.state.height;
|
|
144
|
-
if (handlerName === 'onResize' && !widthChanged && !heightChanged) return;
|
|
146
|
+
var handleRect = node.getBoundingClientRect();
|
|
145
147
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
+
if (_this2.lastHandleRect != null) {
|
|
149
|
+
// If the handle has repositioned on either axis since last render,
|
|
150
|
+
// we need to increase our callback values by this much.
|
|
151
|
+
// Only checking 'n', 'w' since resizing by 's', 'w' won't affect the overall position on page,
|
|
152
|
+
if (axisH === 'w') {
|
|
153
|
+
var deltaLeftSinceLast = handleRect.left - _this2.lastHandleRect.left;
|
|
154
|
+
deltaX += deltaLeftSinceLast;
|
|
155
|
+
}
|
|
148
156
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
157
|
+
if (axisV === 'n') {
|
|
158
|
+
var deltaTopSinceLast = handleRect.top - _this2.lastHandleRect.top;
|
|
159
|
+
deltaY += deltaTopSinceLast;
|
|
160
|
+
}
|
|
161
|
+
} // Storage of last rect so we know how much it has really moved.
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
_this2.lastHandleRect = handleRect; // Reverse delta if using top or left drag handles.
|
|
165
|
+
|
|
166
|
+
if (axisH === 'w') deltaX = -deltaX;
|
|
167
|
+
if (axisV === 'n') deltaY = -deltaY; // Update w/h by the deltas. Also factor in transformScale.
|
|
168
|
+
|
|
169
|
+
var width = _this2.props.width + (canDragX ? deltaX / _this2.props.transformScale : 0);
|
|
170
|
+
var height = _this2.props.height + (canDragY ? deltaY / _this2.props.transformScale : 0); // Run user-provided constraints.
|
|
171
|
+
|
|
172
|
+
var _this2$runConstraints = _this2.runConstraints(width, height);
|
|
163
173
|
|
|
164
|
-
|
|
165
|
-
|
|
174
|
+
width = _this2$runConstraints[0];
|
|
175
|
+
height = _this2$runConstraints[1];
|
|
176
|
+
var dimensionsChanged = width !== _this2.props.width || height !== _this2.props.height; // Call user-supplied callback if present.
|
|
177
|
+
|
|
178
|
+
var cb = typeof _this2.props[handlerName] === 'function' ? _this2.props[handlerName] : null; // Don't call 'onResize' if dimensions haven't changed.
|
|
179
|
+
|
|
180
|
+
var shouldSkipCb = handlerName === 'onResize' && !dimensionsChanged;
|
|
181
|
+
|
|
182
|
+
if (cb && !shouldSkipCb) {
|
|
166
183
|
if (typeof e.persist === 'function') e.persist();
|
|
167
|
-
|
|
168
|
-
|
|
184
|
+
cb(e, {
|
|
185
|
+
node: node,
|
|
186
|
+
size: {
|
|
187
|
+
width: width,
|
|
188
|
+
height: height
|
|
189
|
+
},
|
|
190
|
+
handle: axis
|
|
169
191
|
});
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
|
|
192
|
+
} // Reset internal data
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
if (handlerName === 'onResizeStop') _this2.resetData();
|
|
173
196
|
};
|
|
174
197
|
};
|
|
175
198
|
|
|
176
|
-
|
|
199
|
+
_proto.renderResizeHandle = function renderResizeHandle(resizeHandleAxis) {
|
|
200
|
+
var handle = this.props.handle;
|
|
201
|
+
|
|
202
|
+
if (handle) {
|
|
203
|
+
if (typeof handle === 'function') {
|
|
204
|
+
return handle(resizeHandleAxis);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return handle;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
return /*#__PURE__*/_react.default.createElement("span", {
|
|
211
|
+
className: "react-resizable-handle react-resizable-handle-" + resizeHandleAxis
|
|
212
|
+
});
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
_proto.render = function render() {
|
|
216
|
+
var _this3 = this;
|
|
217
|
+
|
|
218
|
+
// Pass along only props not meant for the `<Resizable>`.`
|
|
177
219
|
// eslint-disable-next-line no-unused-vars
|
|
178
|
-
var
|
|
179
|
-
children =
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
220
|
+
var _this$props = this.props,
|
|
221
|
+
children = _this$props.children,
|
|
222
|
+
className = _this$props.className,
|
|
223
|
+
draggableOpts = _this$props.draggableOpts,
|
|
224
|
+
width = _this$props.width,
|
|
225
|
+
height = _this$props.height,
|
|
226
|
+
handle = _this$props.handle,
|
|
227
|
+
handleSize = _this$props.handleSize,
|
|
228
|
+
lockAspectRatio = _this$props.lockAspectRatio,
|
|
229
|
+
axis = _this$props.axis,
|
|
230
|
+
minConstraints = _this$props.minConstraints,
|
|
231
|
+
maxConstraints = _this$props.maxConstraints,
|
|
232
|
+
onResize = _this$props.onResize,
|
|
233
|
+
onResizeStop = _this$props.onResizeStop,
|
|
234
|
+
onResizeStart = _this$props.onResizeStart,
|
|
235
|
+
resizeHandles = _this$props.resizeHandles,
|
|
236
|
+
transformScale = _this$props.transformScale,
|
|
237
|
+
p = _objectWithoutPropertiesLoose(_this$props, ["children", "className", "draggableOpts", "width", "height", "handle", "handleSize", "lockAspectRatio", "axis", "minConstraints", "maxConstraints", "onResize", "onResizeStop", "onResizeStart", "resizeHandles", "transformScale"]); // What we're doing here is getting the child of this element, and cloning it with this element's props.
|
|
196
238
|
// We are then defining its children as:
|
|
197
239
|
// Its original children (resizable's child's children), and
|
|
198
|
-
//
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
)
|
|
240
|
+
// One or more draggable handles.
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
return (0, _utils.cloneElement)(children, _objectSpread(_objectSpread({}, p), {}, {
|
|
244
|
+
className: (className ? className + " " : '') + "react-resizable",
|
|
245
|
+
children: [].concat(children.props.children, resizeHandles.map(function (handleAxis) {
|
|
246
|
+
return /*#__PURE__*/_react.default.createElement(_reactDraggable.DraggableCore, _extends({}, draggableOpts, {
|
|
247
|
+
key: "resizableHandle-" + handleAxis,
|
|
248
|
+
onStop: _this3.resizeHandler('onResizeStop', handleAxis),
|
|
249
|
+
onStart: _this3.resizeHandler('onResizeStart', handleAxis),
|
|
250
|
+
onDrag: _this3.resizeHandler('onResize', handleAxis)
|
|
251
|
+
}), _this3.renderResizeHandle(handleAxis));
|
|
252
|
+
}))
|
|
211
253
|
}));
|
|
212
254
|
};
|
|
213
255
|
|
|
214
256
|
return Resizable;
|
|
215
|
-
}(
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
// Require that one and only one child be present.
|
|
223
|
-
children: _propTypes2.default.element.isRequired,
|
|
224
|
-
|
|
225
|
-
// Initial w/h
|
|
226
|
-
width: _propTypes2.default.number.isRequired,
|
|
227
|
-
height: _propTypes2.default.number.isRequired,
|
|
228
|
-
|
|
229
|
-
//
|
|
230
|
-
// Optional props
|
|
231
|
-
//
|
|
232
|
-
|
|
233
|
-
// If you change this, be sure to update your css
|
|
234
|
-
handleSize: _propTypes2.default.array,
|
|
235
|
-
|
|
236
|
-
// If true, will only allow width/height to move in lockstep
|
|
237
|
-
lockAspectRatio: _propTypes2.default.bool,
|
|
238
|
-
|
|
239
|
-
// Restricts resizing to a particular axis (default: 'both')
|
|
240
|
-
// 'both' - allows resizing by width or height
|
|
241
|
-
// 'x' - only allows the width to be changed
|
|
242
|
-
// 'y' - only allows the height to be changed
|
|
243
|
-
// 'none' - disables resizing altogether
|
|
244
|
-
axis: _propTypes2.default.oneOf(['both', 'x', 'y', 'none']),
|
|
245
|
-
|
|
246
|
-
// Min/max size
|
|
247
|
-
minConstraints: _propTypes2.default.arrayOf(_propTypes2.default.number),
|
|
248
|
-
maxConstraints: _propTypes2.default.arrayOf(_propTypes2.default.number),
|
|
249
|
-
|
|
250
|
-
// Callbacks
|
|
251
|
-
onResizeStop: _propTypes2.default.func,
|
|
252
|
-
onResizeStart: _propTypes2.default.func,
|
|
253
|
-
onResize: _propTypes2.default.func,
|
|
254
|
-
|
|
255
|
-
// These will be passed wholesale to react-draggable's DraggableCore
|
|
256
|
-
draggableOpts: _propTypes2.default.object
|
|
257
|
-
};
|
|
258
|
-
Resizable.defaultProps = {
|
|
257
|
+
}(_react.default.Component);
|
|
258
|
+
|
|
259
|
+
exports.default = Resizable;
|
|
260
|
+
|
|
261
|
+
_defineProperty(Resizable, "propTypes", _propTypes.resizableProps);
|
|
262
|
+
|
|
263
|
+
_defineProperty(Resizable, "defaultProps", {
|
|
259
264
|
handleSize: [20, 20],
|
|
260
265
|
lockAspectRatio: false,
|
|
261
266
|
axis: 'both',
|
|
262
267
|
minConstraints: [20, 20],
|
|
263
|
-
maxConstraints: [Infinity, Infinity]
|
|
264
|
-
|
|
265
|
-
|
|
268
|
+
maxConstraints: [Infinity, Infinity],
|
|
269
|
+
resizeHandles: ['se'],
|
|
270
|
+
transformScale: 1
|
|
271
|
+
});
|