react-resizable 3.0.5 → 3.1.1
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/.claude/settings.local.json +18 -0
- package/CHANGELOG.md +15 -0
- package/CLAUDE.md +71 -0
- package/README.md +1 -1
- package/build/Resizable.js +121 -115
- package/build/Resizable.js.flow +15 -2
- package/build/ResizableBox.js +56 -59
- package/build/propTypes.js +14 -15
- package/build/propTypes.js.flow +2 -1
- package/build/utils.js +7 -7
- package/dist/bundle.js +488 -6
- package/package.json +28 -28
- package/.eslintrc +0 -38
package/build/ResizableBox.js
CHANGED
|
@@ -6,47 +6,44 @@ var React = _interopRequireWildcard(require("react"));
|
|
|
6
6
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
7
7
|
var _Resizable = _interopRequireDefault(require("./Resizable"));
|
|
8
8
|
var _propTypes2 = require("./propTypes");
|
|
9
|
-
|
|
10
|
-
function _interopRequireDefault(
|
|
11
|
-
function
|
|
12
|
-
function
|
|
13
|
-
function
|
|
14
|
-
function
|
|
15
|
-
function
|
|
16
|
-
function
|
|
17
|
-
function
|
|
18
|
-
function
|
|
19
|
-
function _objectWithoutPropertiesLoose(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
propsWidth: _this.props.width,
|
|
34
|
-
propsHeight: _this.props.height
|
|
9
|
+
const _excluded = ["handle", "handleSize", "onResize", "onResizeStart", "onResizeStop", "draggableOpts", "minConstraints", "maxConstraints", "lockAspectRatio", "axis", "width", "height", "resizeHandles", "style", "transformScale"];
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
12
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
13
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
14
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
15
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
16
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
17
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
18
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
19
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
20
|
+
// ElementConfig gives us an object type where all items present in `defaultProps` are made optional.
|
|
21
|
+
// <ResizableBox> does not have defaultProps, so we can use this type to tell Flow that we don't
|
|
22
|
+
// care about that and will handle it in <Resizable> instead.
|
|
23
|
+
// A <ResizableBox> can also have a `style` property.
|
|
24
|
+
|
|
25
|
+
class ResizableBox extends React.Component {
|
|
26
|
+
constructor() {
|
|
27
|
+
super(...arguments);
|
|
28
|
+
this.state = {
|
|
29
|
+
width: this.props.width,
|
|
30
|
+
height: this.props.height,
|
|
31
|
+
propsWidth: this.props.width,
|
|
32
|
+
propsHeight: this.props.height
|
|
35
33
|
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
34
|
+
this.onResize = (e, data) => {
|
|
35
|
+
const {
|
|
36
|
+
size
|
|
37
|
+
} = data;
|
|
38
|
+
if (this.props.onResize) {
|
|
39
|
+
e.persist?.();
|
|
40
|
+
this.setState(size, () => this.props.onResize && this.props.onResize(e, data));
|
|
43
41
|
} else {
|
|
44
|
-
|
|
42
|
+
this.setState(size);
|
|
45
43
|
}
|
|
46
44
|
};
|
|
47
|
-
return _this;
|
|
48
45
|
}
|
|
49
|
-
|
|
46
|
+
static getDerivedStateFromProps(props, state) {
|
|
50
47
|
// If parent changes height/width, set that in our state.
|
|
51
48
|
if (state.propsWidth !== props.width || state.propsHeight !== props.height) {
|
|
52
49
|
return {
|
|
@@ -57,29 +54,30 @@ var ResizableBox = /*#__PURE__*/function (_React$Component) {
|
|
|
57
54
|
};
|
|
58
55
|
}
|
|
59
56
|
return null;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
_proto.render = function render() {
|
|
57
|
+
}
|
|
58
|
+
render() {
|
|
63
59
|
// Basic wrapper around a Resizable instance.
|
|
64
60
|
// If you use Resizable directly, you are responsible for updating the child component
|
|
65
61
|
// with a new width and height.
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
62
|
+
const _this$props = this.props,
|
|
63
|
+
{
|
|
64
|
+
handle,
|
|
65
|
+
handleSize,
|
|
66
|
+
onResize,
|
|
67
|
+
onResizeStart,
|
|
68
|
+
onResizeStop,
|
|
69
|
+
draggableOpts,
|
|
70
|
+
minConstraints,
|
|
71
|
+
maxConstraints,
|
|
72
|
+
lockAspectRatio,
|
|
73
|
+
axis,
|
|
74
|
+
width,
|
|
75
|
+
height,
|
|
76
|
+
resizeHandles,
|
|
77
|
+
style,
|
|
78
|
+
transformScale
|
|
79
|
+
} = _this$props,
|
|
80
|
+
props = _objectWithoutProperties(_this$props, _excluded);
|
|
83
81
|
return /*#__PURE__*/React.createElement(_Resizable.default, {
|
|
84
82
|
axis: axis,
|
|
85
83
|
draggableOpts: draggableOpts,
|
|
@@ -101,9 +99,8 @@ var ResizableBox = /*#__PURE__*/function (_React$Component) {
|
|
|
101
99
|
height: this.state.height + 'px'
|
|
102
100
|
})
|
|
103
101
|
})));
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
}(React.Component);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
107
104
|
exports.default = ResizableBox;
|
|
108
105
|
// PropTypes are identical to <Resizable>, except that children are not strictly required to be present.
|
|
109
106
|
ResizableBox.propTypes = _objectSpread(_objectSpread({}, _propTypes2.resizableProps), {}, {
|
package/build/propTypes.js
CHANGED
|
@@ -4,8 +4,10 @@ exports.__esModule = true;
|
|
|
4
4
|
exports.resizableProps = void 0;
|
|
5
5
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
6
6
|
var _reactDraggable = require("react-draggable");
|
|
7
|
-
function _interopRequireDefault(
|
|
8
|
-
|
|
7
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
|
+
/* global Element */
|
|
9
|
+
// <Resizable>
|
|
10
|
+
const resizableProps = exports.resizableProps = {
|
|
9
11
|
/*
|
|
10
12
|
* Restricts resizing to a particular axis (default: 'both')
|
|
11
13
|
* 'both' - allows resizing by width or height
|
|
@@ -28,7 +30,7 @@ var resizableProps = {
|
|
|
28
30
|
children: _propTypes.default.node,
|
|
29
31
|
disabled: _propTypes.default.bool,
|
|
30
32
|
enableUserSelectHack: _propTypes.default.bool,
|
|
31
|
-
offsetParent: _propTypes.default.
|
|
33
|
+
offsetParent: _propTypes.default.instanceOf(Element),
|
|
32
34
|
grid: _propTypes.default.arrayOf(_propTypes.default.number),
|
|
33
35
|
handle: _propTypes.default.string,
|
|
34
36
|
nodeRef: _propTypes.default.object,
|
|
@@ -41,17 +43,16 @@ var resizableProps = {
|
|
|
41
43
|
/*
|
|
42
44
|
* Initial height
|
|
43
45
|
* */
|
|
44
|
-
height: function
|
|
46
|
+
height: function () {
|
|
45
47
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
46
48
|
args[_key] = arguments[_key];
|
|
47
49
|
}
|
|
48
|
-
|
|
50
|
+
const [props] = args;
|
|
49
51
|
// Required if resizing height or both
|
|
50
52
|
if (props.axis === 'both' || props.axis === 'y') {
|
|
51
|
-
|
|
52
|
-
return (_PropTypes$number = _propTypes.default.number).isRequired.apply(_PropTypes$number, args);
|
|
53
|
+
return _propTypes.default.number.isRequired(...args);
|
|
53
54
|
}
|
|
54
|
-
return _propTypes.default.number
|
|
55
|
+
return _propTypes.default.number(...args);
|
|
55
56
|
},
|
|
56
57
|
/*
|
|
57
58
|
* Customize cursor resize handle
|
|
@@ -101,17 +102,15 @@ var resizableProps = {
|
|
|
101
102
|
/*
|
|
102
103
|
* Initial width
|
|
103
104
|
*/
|
|
104
|
-
width: function
|
|
105
|
+
width: function () {
|
|
105
106
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
106
107
|
args[_key2] = arguments[_key2];
|
|
107
108
|
}
|
|
108
|
-
|
|
109
|
+
const [props] = args;
|
|
109
110
|
// Required if resizing width or both
|
|
110
111
|
if (props.axis === 'both' || props.axis === 'x') {
|
|
111
|
-
|
|
112
|
-
return (_PropTypes$number2 = _propTypes.default.number).isRequired.apply(_PropTypes$number2, args);
|
|
112
|
+
return _propTypes.default.number.isRequired(...args);
|
|
113
113
|
}
|
|
114
|
-
return _propTypes.default.number
|
|
114
|
+
return _propTypes.default.number(...args);
|
|
115
115
|
}
|
|
116
|
-
};
|
|
117
|
-
exports.resizableProps = resizableProps;
|
|
116
|
+
};
|
package/build/propTypes.js.flow
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// @flow
|
|
2
|
+
/* global Element */
|
|
2
3
|
import PropTypes from 'prop-types';
|
|
3
4
|
import {DraggableCore} from "react-draggable";
|
|
4
5
|
import type {Element as ReactElement, ElementConfig} from 'react';
|
|
@@ -75,7 +76,7 @@ export const resizableProps: Object = {
|
|
|
75
76
|
children: PropTypes.node,
|
|
76
77
|
disabled: PropTypes.bool,
|
|
77
78
|
enableUserSelectHack: PropTypes.bool,
|
|
78
|
-
offsetParent: PropTypes.
|
|
79
|
+
offsetParent: PropTypes.instanceOf(Element),
|
|
79
80
|
grid: PropTypes.arrayOf(PropTypes.number),
|
|
80
81
|
handle: PropTypes.string,
|
|
81
82
|
nodeRef: PropTypes.object,
|
package/build/utils.js
CHANGED
|
@@ -3,19 +3,19 @@
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.cloneElement = cloneElement;
|
|
5
5
|
var _react = _interopRequireDefault(require("react"));
|
|
6
|
-
function _interopRequireDefault(
|
|
7
|
-
function ownKeys(
|
|
8
|
-
function _objectSpread(
|
|
9
|
-
function _defineProperty(
|
|
10
|
-
function _toPropertyKey(
|
|
11
|
-
function _toPrimitive(
|
|
6
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
8
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
9
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
10
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
11
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
12
12
|
// React.addons.cloneWithProps look-alike that merges style & className.
|
|
13
13
|
function cloneElement(element, props) {
|
|
14
14
|
if (props.style && element.props.style) {
|
|
15
15
|
props.style = _objectSpread(_objectSpread({}, element.props.style), props.style);
|
|
16
16
|
}
|
|
17
17
|
if (props.className && element.props.className) {
|
|
18
|
-
props.className = element.props.className
|
|
18
|
+
props.className = `${element.props.className} ${props.className}`;
|
|
19
19
|
}
|
|
20
20
|
return /*#__PURE__*/_react.default.cloneElement(element, props);
|
|
21
21
|
}
|