react-resizable 3.0.3 → 3.0.5

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/.flowconfig CHANGED
@@ -1,10 +1,9 @@
1
1
  [version]
2
- ^0.150.1
2
+ ^0.153.0
3
3
 
4
4
  [ignore]
5
5
  .*/node_modules/@babel.*
6
- .*/node_modules/express/.*
7
- .*/node_modules/serve-index/.*
6
+ .*/node_modules/.*/malformed_package_json/.*
8
7
  <PROJECT_ROOT>/build/.*
9
8
 
10
9
  [include]
package/.packj.yaml ADDED
@@ -0,0 +1,153 @@
1
+ #
2
+ # Audit policies
3
+ #
4
+ audit:
5
+ alerts:
6
+ #
7
+ # category: malicious packages (publicly known and unknown)
8
+ #
9
+ malicious:
10
+ contains known malware:
11
+ - reason: package is known to contain a dangerous malware
12
+ - enabled: true
13
+ typo-squatting or repo-jacking package:
14
+ - reason: package impersonates another popular package to propagate malware
15
+ - enabled: true
16
+
17
+ #
18
+ # alert category: suspicious packages (potentially malicious)
19
+ #
20
+ suspicious:
21
+ inconsistent with repo source:
22
+ - reason: package code inconsistent with the public repo source code
23
+ - enabled: false # WIP
24
+ overwrites system binaries:
25
+ - reason: package code inconsistent with the public repo source code
26
+ - enabled: false # WIP
27
+
28
+ #
29
+ # alert category: packages vulnerable to code exploits
30
+ #
31
+ vulnerable:
32
+ contains known vulnerabilities:
33
+ - reason: known vulnerabilities (CVEs) in package code could be exploited
34
+ - enabled: true
35
+ insecure network communication:
36
+ - reason: package code uses insecure network communication (not https)
37
+ - enabled: false # WIP
38
+
39
+ #
40
+ # packages with undesirable or "risky" attributes
41
+ #
42
+ undesirable:
43
+ package is old or abandoned:
44
+ - reason: old or abandoned packages receive no security updates and are risky
45
+ - enabled: true
46
+
47
+ invalid or no author email:
48
+ - reason: a package with lack of or invalid author email suggests 2FA not enabled
49
+ - enabled: true
50
+
51
+ invalid or no homepage:
52
+ - reason: a package with no or invalid homepage may not be preferable
53
+ - enabled: false
54
+
55
+ no source repo:
56
+ - reason: lack of public source repo may suggest malicious intention
57
+ - enabled: true
58
+
59
+ fewer downloads:
60
+ - reason: a package with few downloads may not be preferable
61
+ - enabled: true
62
+
63
+ no or insufficient readme:
64
+ - reason: a package with lack of documentation may not be preferable
65
+ - enabled: false
66
+
67
+ fewer versions or releases:
68
+ - reason: few versions suggest unstable or inactive project
69
+ - enabled: true
70
+
71
+ too many dependencies:
72
+ - reason: too many dependencies increase attack surface
73
+ - enabled: false
74
+
75
+ version release after a long gap:
76
+ - reason: a release after a long time may indicate account hijacking
77
+ - enabled: false
78
+
79
+ contains custom installation hooks:
80
+ - reason: custom installation hooks may download or execute malicious code
81
+ - enabled: false # WIP
82
+
83
+ #
84
+ # type: repo stats
85
+ #
86
+ few source repo stars:
87
+ - reason: a package with few repo stars may not be preferable
88
+ - enabled: false
89
+
90
+ few source repo forks:
91
+ - reason: a package with few repo forks may not be preferable
92
+ - enabled: false
93
+
94
+ forked source repo:
95
+ - reason: a forked copy of a popular package may contain malicious code
96
+ - enabled: true
97
+
98
+ #
99
+ # type: APIs and permissions
100
+ #
101
+ generates new code:
102
+ - reason: package generates new code at runtime, which could be malicious
103
+ - enabled: false
104
+ forks or exits OS processes:
105
+ - reason: package spawns new operating system processes, which could be malicious
106
+ - enabled: false
107
+ accesses obfuscated (hidden) code:
108
+ - enabled: true
109
+ accesses environment variables:
110
+ - enabled: false
111
+ changes system/environment variables:
112
+ - enabled: false
113
+ accesses files and dirs:
114
+ - enabled: false
115
+ communicates with external network:
116
+ - enabled: false
117
+ reads user input:
118
+ - enabled: false
119
+
120
+ #
121
+ # Sandboxing policies
122
+ #
123
+ sandbox:
124
+ rules:
125
+ #
126
+ # File system (allow or block accesses to file/dirs)
127
+ #
128
+ # ~/ represents home dir
129
+ # . represents cwd dir
130
+ #
131
+ # NOTE: only ONE 'allow' and 'block' lines are allowed
132
+ #
133
+ fs:
134
+ # TODO: customize as per your threat model
135
+
136
+ # block access to home dir and all other locations (except the ones below)
137
+ block: ~/, /
138
+ allow: ., ~/.cache, ~/.npm, ~/.local, ~/.ruby, /tmp, /proc, /etc, /var, /bin, /usr/include, /usr/local, /usr/bin, /usr/lib, /usr/share, /lib
139
+
140
+ #
141
+ # Network (allow or block domains/ports)
142
+ #
143
+ # NOTE: only ONE 'allow' and 'block' lines are allowed
144
+ #
145
+ network:
146
+
147
+ # TODO: customize as per your threat model
148
+
149
+ # block all external network communication (except the ones below)
150
+ block: 0.0.0.0
151
+
152
+ # For NPM packages
153
+ allow: registry.yarnpkg.com:0, npmjs.org:0, npmjs.com:0
package/CHANGELOG.md CHANGED
@@ -1,30 +1,42 @@
1
1
  # Changelog
2
2
 
3
+ ### 3.0.5 (Mar 21, 2023)
4
+
5
+ - 🐛 Bugfix: Make `width` and `height` conditionally required if an `axis` is set. See [#196](https://github.com/react-grid-layout/react-resizable/issues/196)
6
+ - ✏ Chore: Minor dependency upgrades.
7
+ - ✏ Chore: Fix documentation of `onResize` callback arity.
8
+
9
+ ### 3.0.4 (Jun 15, 2021)
10
+
11
+ - 🐛 Bugfix: Fix incorrect fix for `handleAxis` on DOM elements. [#175](https://github.com/react-grid-layout/react-resizable/issues/175)
12
+ - ✏ Chore:Upgrade dependencies.
13
+
3
14
  ### 3.0.3 (Jun 14, 2021)
4
15
 
5
- - Fix unknown prop `handleAxis` making it to DOM elements, causing a warning in dev.
6
- - Rewrote `lockAspectRatio` logic to be more accurate and shorter.
16
+ - 🐛 Bugfix: Remove unknown prop `handleAxis` making it to DOM elements, causing a warning in dev.
17
+ - ✏ Chore: Rewrote `lockAspectRatio` logic to be more accurate and shorter.
7
18
 
8
19
  ### 3.0.2 (Jun 8, 2021)
9
20
 
10
- - Add documentation for resize handles and fix a mistake where the `handleAxis` prop was not being passed to custom components.
21
+ - ✏ Chore: Add documentation for resize handles and fix a mistake where the `handleAxis` prop was not being passed to custom components.
11
22
  - See [Resize Handles](README.md#resize-handle)
12
23
 
13
24
  ### 3.0.1 (May 10, 2021)
14
25
 
15
- - Reduce package size through `.npmignore`.
26
+ - ✏ Chore: Reduce package size through `.npmignore`.
16
27
 
17
28
  ### 3.0.0 (May 10, 2021)
18
29
 
19
30
  #### Breaking
20
- - Fixed handling of the `nodeRef` that needs to be passed to `<DraggableCore>` to avoid use of ReactDOM. This means that vanilla usage of `react-resizable` no longer requires ReactDOM. No code changes are needed in the usual case, except:
31
+
32
+ - 🐛 Bugfix: Fixed handling of the `nodeRef` that needs to be passed to `<DraggableCore>` to avoid use of ReactDOM. This means that vanilla usage of `react-resizable` no longer requires ReactDOM. No code changes are needed in the usual case, except:
21
33
  * React `>= 16.3` is required due to use of `React.createRef()`, and
22
34
  * The `handle` prop now sends a `ReactRef<HTMLElement>` as its second argument and expects it to be used on your returned component.
23
35
  * If you do not attach the `ref`, you will receive the following error: `"<DraggableCore> not mounted on DragStart!"` This is due to the ref being present but not attached to any node.
24
36
 
25
37
  ### 1.11.1 (Mar 5, 2021)
26
38
 
27
- - Added React 17 to peerDependencies.
39
+ - ✏ Chore: Added React 17 to peerDependencies.
28
40
 
29
41
  ### 1.11.0 (Sep 3, 2020)
30
42
 
package/README.md CHANGED
@@ -1,12 +1,12 @@
1
1
  ### React-Resizable
2
2
 
3
- [View the Demo](https://react-grid-layout.github.io/react-resizable/examples/1.html)
3
+ [View the Demo](https://react-grid-layout.github.io/react-resizable/index.html)
4
4
 
5
5
  A simple widget that can be resized via one or more handles.
6
6
 
7
7
  You can either use the `<Resizable>` element directly, or use the much simpler `<ResizableBox>` element.
8
8
 
9
- See the example and associated code in [TestLayout](/examples/TestLayout.js) and
9
+ See the example and associated code in [ExampleLayout](/examples/ExampleLayout.js) and
10
10
  [ResizableBox](/lib/ResizableBox.js) for more details.
11
11
 
12
12
  Make sure you use the associated styles in [/css/styles.css](/css/styles.css), as without them, you will have
@@ -49,7 +49,7 @@ class Example extends React.Component {
49
49
  };
50
50
 
51
51
  // On top layout
52
- onResize = (event, {element, size, handle}) => {
52
+ onResize = (event, {node, size, handle}) => {
53
53
  this.setState({width: size.width, height: size.height});
54
54
  };
55
55
 
@@ -2,145 +2,125 @@
2
2
 
3
3
  exports.__esModule = true;
4
4
  exports.default = void 0;
5
-
6
5
  var React = _interopRequireWildcard(require("react"));
7
-
8
6
  var _reactDraggable = require("react-draggable");
9
-
10
7
  var _utils = require("./utils");
11
-
12
8
  var _propTypes = require("./propTypes");
13
-
14
9
  var _excluded = ["children", "className", "draggableOpts", "width", "height", "handle", "handleSize", "lockAspectRatio", "axis", "minConstraints", "maxConstraints", "onResize", "onResizeStop", "onResizeStart", "resizeHandles", "transformScale"];
15
-
16
10
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
-
18
11
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }
19
-
20
- 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); }
21
-
12
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
22
13
  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; }
23
-
24
- 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; }
25
-
26
- 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; }
27
-
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; }
29
-
14
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
15
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
16
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
17
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
18
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
30
19
  function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
31
-
32
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
33
-
20
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
34
21
  // The base <Resizable> component.
35
22
  // This component does not have state and relies on the parent to set its props based on callback data.
36
23
  var Resizable = /*#__PURE__*/function (_React$Component) {
37
24
  _inheritsLoose(Resizable, _React$Component);
38
-
39
25
  function Resizable() {
40
26
  var _this;
41
-
42
27
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
43
28
  args[_key] = arguments[_key];
44
29
  }
45
-
46
30
  _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
47
31
  _this.handleRefs = {};
48
32
  _this.lastHandleRect = null;
49
33
  _this.slack = null;
50
34
  return _this;
51
35
  }
52
-
53
36
  var _proto = Resizable.prototype;
54
-
55
37
  _proto.componentWillUnmount = function componentWillUnmount() {
56
38
  this.resetData();
57
39
  };
58
-
59
40
  _proto.resetData = function resetData() {
60
41
  this.lastHandleRect = this.slack = null;
61
- } // Clamp width and height within provided constraints
62
- ;
42
+ }
63
43
 
44
+ // Clamp width and height within provided constraints
45
+ ;
64
46
  _proto.runConstraints = function runConstraints(width, height) {
65
47
  var _this$props = this.props,
66
- minConstraints = _this$props.minConstraints,
67
- maxConstraints = _this$props.maxConstraints,
68
- lockAspectRatio = _this$props.lockAspectRatio; // short circuit
69
-
70
- if (!minConstraints && !maxConstraints && !lockAspectRatio) return [width, height]; // If constraining to min and max, we need to also fit width and height to aspect ratio.
48
+ minConstraints = _this$props.minConstraints,
49
+ maxConstraints = _this$props.maxConstraints,
50
+ lockAspectRatio = _this$props.lockAspectRatio;
51
+ // short circuit
52
+ if (!minConstraints && !maxConstraints && !lockAspectRatio) return [width, height];
71
53
 
54
+ // If constraining to min and max, we need to also fit width and height to aspect ratio.
72
55
  if (lockAspectRatio) {
73
56
  var ratio = this.props.width / this.props.height;
74
57
  var deltaW = width - this.props.width;
75
- var deltaH = height - this.props.height; // Find which coordinate was greater and should push the other toward it.
58
+ var deltaH = height - this.props.height;
59
+
60
+ // Find which coordinate was greater and should push the other toward it.
76
61
  // E.g.:
77
62
  // ratio = 1, deltaW = 10, deltaH = 5, deltaH should become 10.
78
63
  // ratio = 2, deltaW = 10, deltaH = 6, deltaW should become 12.
79
-
80
64
  if (Math.abs(deltaW) > Math.abs(deltaH * ratio)) {
81
65
  height = width / ratio;
82
66
  } else {
83
67
  width = height * ratio;
84
68
  }
85
69
  }
86
-
87
70
  var oldW = width,
88
- oldH = height; // Add slack to the values used to calculate bound position. This will ensure that if
71
+ oldH = height;
72
+
73
+ // Add slack to the values used to calculate bound position. This will ensure that if
89
74
  // we start removing slack, the element won't react to it right away until it's been
90
75
  // completely removed.
91
-
92
76
  var _ref = this.slack || [0, 0],
93
- slackW = _ref[0],
94
- slackH = _ref[1];
95
-
77
+ slackW = _ref[0],
78
+ slackH = _ref[1];
96
79
  width += slackW;
97
80
  height += slackH;
98
-
99
81
  if (minConstraints) {
100
82
  width = Math.max(minConstraints[0], width);
101
83
  height = Math.max(minConstraints[1], height);
102
84
  }
103
-
104
85
  if (maxConstraints) {
105
86
  width = Math.min(maxConstraints[0], width);
106
87
  height = Math.min(maxConstraints[1], height);
107
- } // If the width or height changed, we must have introduced some slack. Record it for the next iteration.
108
-
88
+ }
109
89
 
90
+ // If the width or height changed, we must have introduced some slack. Record it for the next iteration.
110
91
  this.slack = [slackW + (oldW - width), slackH + (oldH - height)];
111
92
  return [width, height];
112
93
  }
94
+
113
95
  /**
114
96
  * Wrapper around drag events to provide more useful data.
115
97
  *
116
98
  * @param {String} handlerName Handler name to wrap.
117
99
  * @return {Function} Handler function.
118
- */
119
- ;
120
-
100
+ */;
121
101
  _proto.resizeHandler = function resizeHandler(handlerName, axis) {
122
102
  var _this2 = this;
123
-
124
103
  return function (e, _ref2) {
125
104
  var node = _ref2.node,
126
- deltaX = _ref2.deltaX,
127
- deltaY = _ref2.deltaY;
105
+ deltaX = _ref2.deltaX,
106
+ deltaY = _ref2.deltaY;
128
107
  // Reset data in case it was left over somehow (should not be possible)
129
- if (handlerName === 'onResizeStart') _this2.resetData(); // Axis restrictions
108
+ if (handlerName === 'onResizeStart') _this2.resetData();
130
109
 
110
+ // Axis restrictions
131
111
  var canDragX = (_this2.props.axis === 'both' || _this2.props.axis === 'x') && axis !== 'n' && axis !== 's';
132
- var canDragY = (_this2.props.axis === 'both' || _this2.props.axis === 'y') && axis !== 'e' && axis !== 'w'; // No dragging possible.
133
-
134
- if (!canDragX && !canDragY) return; // Decompose axis for later use
112
+ var canDragY = (_this2.props.axis === 'both' || _this2.props.axis === 'y') && axis !== 'e' && axis !== 'w';
113
+ // No dragging possible.
114
+ if (!canDragX && !canDragY) return;
135
115
 
116
+ // Decompose axis for later use
136
117
  var axisV = axis[0];
137
118
  var axisH = axis[axis.length - 1]; // intentionally not axis[1], so that this catches axis === 'w' for example
119
+
138
120
  // Track the element being dragged to account for changes in position.
139
121
  // If a handle's position is changed between callbacks, we need to factor this in to the next callback.
140
122
  // Failure to do so will cause the element to "skip" when resized upwards or leftwards.
141
-
142
123
  var handleRect = node.getBoundingClientRect();
143
-
144
124
  if (_this2.lastHandleRect != null) {
145
125
  // If the handle has repositioned on either axis since last render,
146
126
  // we need to increase our callback values by this much.
@@ -149,34 +129,34 @@ var Resizable = /*#__PURE__*/function (_React$Component) {
149
129
  var deltaLeftSinceLast = handleRect.left - _this2.lastHandleRect.left;
150
130
  deltaX += deltaLeftSinceLast;
151
131
  }
152
-
153
132
  if (axisV === 'n') {
154
133
  var deltaTopSinceLast = handleRect.top - _this2.lastHandleRect.top;
155
134
  deltaY += deltaTopSinceLast;
156
135
  }
157
- } // Storage of last rect so we know how much it has really moved.
158
-
159
-
160
- _this2.lastHandleRect = handleRect; // Reverse delta if using top or left drag handles.
136
+ }
137
+ // Storage of last rect so we know how much it has really moved.
138
+ _this2.lastHandleRect = handleRect;
161
139
 
140
+ // Reverse delta if using top or left drag handles.
162
141
  if (axisH === 'w') deltaX = -deltaX;
163
- if (axisV === 'n') deltaY = -deltaY; // Update w/h by the deltas. Also factor in transformScale.
142
+ if (axisV === 'n') deltaY = -deltaY;
164
143
 
144
+ // Update w/h by the deltas. Also factor in transformScale.
165
145
  var width = _this2.props.width + (canDragX ? deltaX / _this2.props.transformScale : 0);
166
- var height = _this2.props.height + (canDragY ? deltaY / _this2.props.transformScale : 0); // Run user-provided constraints.
146
+ var height = _this2.props.height + (canDragY ? deltaY / _this2.props.transformScale : 0);
167
147
 
148
+ // Run user-provided constraints.
168
149
  var _this2$runConstraints = _this2.runConstraints(width, height);
169
-
170
150
  width = _this2$runConstraints[0];
171
151
  height = _this2$runConstraints[1];
172
- var dimensionsChanged = width !== _this2.props.width || height !== _this2.props.height; // Call user-supplied callback if present.
173
-
174
- var cb = typeof _this2.props[handlerName] === 'function' ? _this2.props[handlerName] : null; // Don't call 'onResize' if dimensions haven't changed.
152
+ var dimensionsChanged = width !== _this2.props.width || height !== _this2.props.height;
175
153
 
154
+ // Call user-supplied callback if present.
155
+ var cb = typeof _this2.props[handlerName] === 'function' ? _this2.props[handlerName] : null;
156
+ // Don't call 'onResize' if dimensions haven't changed.
176
157
  var shouldSkipCb = handlerName === 'onResize' && !dimensionsChanged;
177
-
178
158
  if (cb && !shouldSkipCb) {
179
- if (typeof e.persist === 'function') e.persist();
159
+ e.persist == null ? void 0 : e.persist();
180
160
  cb(e, {
181
161
  node: node,
182
162
  size: {
@@ -185,76 +165,70 @@ var Resizable = /*#__PURE__*/function (_React$Component) {
185
165
  },
186
166
  handle: axis
187
167
  });
188
- } // Reset internal data
189
-
168
+ }
190
169
 
170
+ // Reset internal data
191
171
  if (handlerName === 'onResizeStop') _this2.resetData();
192
172
  };
193
- } // Render a resize handle given an axis & DOM ref. Ref *must* be attached for
173
+ }
174
+
175
+ // Render a resize handle given an axis & DOM ref. Ref *must* be attached for
194
176
  // the underlying draggable library to work properly.
195
177
  ;
196
-
197
178
  _proto.renderResizeHandle = function renderResizeHandle(handleAxis, ref) {
198
- var handle = this.props.handle; // No handle provided, make the default
199
-
179
+ var handle = this.props.handle;
180
+ // No handle provided, make the default
200
181
  if (!handle) {
201
182
  return /*#__PURE__*/React.createElement("span", {
202
183
  className: "react-resizable-handle react-resizable-handle-" + handleAxis,
203
184
  ref: ref
204
185
  });
205
- } // Handle is a function, such as:
186
+ }
187
+ // Handle is a function, such as:
206
188
  // `handle={(handleAxis) => <span className={...} />}`
207
-
208
-
209
189
  if (typeof handle === 'function') {
210
190
  return handle(handleAxis, ref);
211
- } // Handle is a React component (composite or DOM).
212
-
213
-
214
- var isDOMElement = handle.type === 'string';
215
-
191
+ }
192
+ // Handle is a React component (composite or DOM).
193
+ var isDOMElement = typeof handle.type === 'string';
216
194
  var props = _objectSpread({
217
195
  ref: ref
218
196
  }, isDOMElement ? {} : {
219
197
  handleAxis: handleAxis
220
198
  });
221
-
222
199
  return /*#__PURE__*/React.cloneElement(handle, props);
223
200
  };
224
-
225
201
  _proto.render = function render() {
226
202
  var _this3 = this;
227
-
228
203
  // Pass along only props not meant for the `<Resizable>`.`
229
204
  // eslint-disable-next-line no-unused-vars
230
205
  var _this$props2 = this.props,
231
- children = _this$props2.children,
232
- className = _this$props2.className,
233
- draggableOpts = _this$props2.draggableOpts,
234
- width = _this$props2.width,
235
- height = _this$props2.height,
236
- handle = _this$props2.handle,
237
- handleSize = _this$props2.handleSize,
238
- lockAspectRatio = _this$props2.lockAspectRatio,
239
- axis = _this$props2.axis,
240
- minConstraints = _this$props2.minConstraints,
241
- maxConstraints = _this$props2.maxConstraints,
242
- onResize = _this$props2.onResize,
243
- onResizeStop = _this$props2.onResizeStop,
244
- onResizeStart = _this$props2.onResizeStart,
245
- resizeHandles = _this$props2.resizeHandles,
246
- transformScale = _this$props2.transformScale,
247
- 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.
206
+ children = _this$props2.children,
207
+ className = _this$props2.className,
208
+ draggableOpts = _this$props2.draggableOpts,
209
+ width = _this$props2.width,
210
+ height = _this$props2.height,
211
+ handle = _this$props2.handle,
212
+ handleSize = _this$props2.handleSize,
213
+ lockAspectRatio = _this$props2.lockAspectRatio,
214
+ axis = _this$props2.axis,
215
+ minConstraints = _this$props2.minConstraints,
216
+ maxConstraints = _this$props2.maxConstraints,
217
+ onResize = _this$props2.onResize,
218
+ onResizeStop = _this$props2.onResizeStop,
219
+ onResizeStart = _this$props2.onResizeStart,
220
+ resizeHandles = _this$props2.resizeHandles,
221
+ transformScale = _this$props2.transformScale,
222
+ p = _objectWithoutPropertiesLoose(_this$props2, _excluded);
223
+
224
+ // What we're doing here is getting the child of this element, and cloning it with this element's props.
248
225
  // We are then defining its children as:
249
226
  // 1. Its original children (resizable's child's children), and
250
227
  // 2. One or more draggable handles.
251
-
252
-
253
228
  return (0, _utils.cloneElement)(children, _objectSpread(_objectSpread({}, p), {}, {
254
229
  className: (className ? className + " " : '') + "react-resizable",
255
230
  children: [].concat(children.props.children, resizeHandles.map(function (handleAxis) {
256
231
  var _this3$handleRefs$han;
257
-
258
232
  // Create a ref to the handle so that `<DraggableCore>` doesn't have to use ReactDOM.findDOMNode().
259
233
  var ref = (_this3$handleRefs$han = _this3.handleRefs[handleAxis]) != null ? _this3$handleRefs$han : _this3.handleRefs[handleAxis] = /*#__PURE__*/React.createRef();
260
234
  return /*#__PURE__*/React.createElement(_reactDraggable.DraggableCore, _extends({}, draggableOpts, {
@@ -267,10 +241,8 @@ var Resizable = /*#__PURE__*/function (_React$Component) {
267
241
  }))
268
242
  }));
269
243
  };
270
-
271
244
  return Resizable;
272
245
  }(React.Component);
273
-
274
246
  exports.default = Resizable;
275
247
  Resizable.propTypes = _propTypes.resizableProps;
276
248
  Resizable.defaultProps = {
@@ -139,7 +139,7 @@ export default class Resizable extends React.Component<Props, void> {
139
139
  // Don't call 'onResize' if dimensions haven't changed.
140
140
  const shouldSkipCb = handlerName === 'onResize' && !dimensionsChanged;
141
141
  if (cb && !shouldSkipCb) {
142
- if (typeof e.persist === 'function') e.persist();
142
+ e.persist?.();
143
143
  cb(e, {node, size: {width, height}, handle: axis});
144
144
  }
145
145
 
@@ -162,7 +162,7 @@ export default class Resizable extends React.Component<Props, void> {
162
162
  return handle(handleAxis, ref);
163
163
  }
164
164
  // Handle is a React component (composite or DOM).
165
- const isDOMElement = handle.type === 'string';
165
+ const isDOMElement = typeof handle.type === 'string';
166
166
  const props = {
167
167
  ref,
168
168
  // Add `handleAxis` prop iff this is not a DOM element,
@@ -2,47 +2,30 @@
2
2
 
3
3
  exports.__esModule = true;
4
4
  exports.default = void 0;
5
-
6
5
  var React = _interopRequireWildcard(require("react"));
7
-
8
6
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
-
10
7
  var _Resizable = _interopRequireDefault(require("./Resizable"));
11
-
12
8
  var _propTypes2 = require("./propTypes");
13
-
14
9
  var _excluded = ["handle", "handleSize", "onResize", "onResizeStart", "onResizeStop", "draggableOpts", "minConstraints", "maxConstraints", "lockAspectRatio", "axis", "width", "height", "resizeHandles", "style", "transformScale"];
15
-
16
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
18
11
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
-
20
12
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }
21
-
22
- 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); }
23
-
24
- 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; }
25
-
26
- 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; }
27
-
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; }
29
-
13
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
14
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
15
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
16
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
17
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
18
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
30
19
  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; }
31
-
32
20
  function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
33
-
34
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
35
-
21
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
36
22
  var ResizableBox = /*#__PURE__*/function (_React$Component) {
37
23
  _inheritsLoose(ResizableBox, _React$Component);
38
-
39
24
  function ResizableBox() {
40
25
  var _this;
41
-
42
26
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
43
27
  args[_key] = arguments[_key];
44
28
  }
45
-
46
29
  _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
47
30
  _this.state = {
48
31
  width: _this.props.width,
@@ -50,13 +33,10 @@ var ResizableBox = /*#__PURE__*/function (_React$Component) {
50
33
  propsWidth: _this.props.width,
51
34
  propsHeight: _this.props.height
52
35
  };
53
-
54
36
  _this.onResize = function (e, data) {
55
37
  var size = data.size;
56
-
57
38
  if (_this.props.onResize) {
58
- e.persist && e.persist();
59
-
39
+ e.persist == null ? void 0 : e.persist();
60
40
  _this.setState(size, function () {
61
41
  return _this.props.onResize && _this.props.onResize(e, data);
62
42
  });
@@ -64,10 +44,8 @@ var ResizableBox = /*#__PURE__*/function (_React$Component) {
64
44
  _this.setState(size);
65
45
  }
66
46
  };
67
-
68
47
  return _this;
69
48
  }
70
-
71
49
  ResizableBox.getDerivedStateFromProps = function getDerivedStateFromProps(props, state) {
72
50
  // If parent changes height/width, set that in our state.
73
51
  if (state.propsWidth !== props.width || state.propsHeight !== props.height) {
@@ -78,34 +56,30 @@ var ResizableBox = /*#__PURE__*/function (_React$Component) {
78
56
  propsHeight: props.height
79
57
  };
80
58
  }
81
-
82
59
  return null;
83
60
  };
84
-
85
61
  var _proto = ResizableBox.prototype;
86
-
87
62
  _proto.render = function render() {
88
63
  // Basic wrapper around a Resizable instance.
89
64
  // If you use Resizable directly, you are responsible for updating the child component
90
65
  // with a new width and height.
91
66
  var _this$props = this.props,
92
- handle = _this$props.handle,
93
- handleSize = _this$props.handleSize,
94
- onResize = _this$props.onResize,
95
- onResizeStart = _this$props.onResizeStart,
96
- onResizeStop = _this$props.onResizeStop,
97
- draggableOpts = _this$props.draggableOpts,
98
- minConstraints = _this$props.minConstraints,
99
- maxConstraints = _this$props.maxConstraints,
100
- lockAspectRatio = _this$props.lockAspectRatio,
101
- axis = _this$props.axis,
102
- width = _this$props.width,
103
- height = _this$props.height,
104
- resizeHandles = _this$props.resizeHandles,
105
- style = _this$props.style,
106
- transformScale = _this$props.transformScale,
107
- props = _objectWithoutPropertiesLoose(_this$props, _excluded);
108
-
67
+ handle = _this$props.handle,
68
+ handleSize = _this$props.handleSize,
69
+ onResize = _this$props.onResize,
70
+ onResizeStart = _this$props.onResizeStart,
71
+ onResizeStop = _this$props.onResizeStop,
72
+ draggableOpts = _this$props.draggableOpts,
73
+ minConstraints = _this$props.minConstraints,
74
+ maxConstraints = _this$props.maxConstraints,
75
+ lockAspectRatio = _this$props.lockAspectRatio,
76
+ axis = _this$props.axis,
77
+ width = _this$props.width,
78
+ height = _this$props.height,
79
+ resizeHandles = _this$props.resizeHandles,
80
+ style = _this$props.style,
81
+ transformScale = _this$props.transformScale,
82
+ props = _objectWithoutPropertiesLoose(_this$props, _excluded);
109
83
  return /*#__PURE__*/React.createElement(_Resizable.default, {
110
84
  axis: axis,
111
85
  draggableOpts: draggableOpts,
@@ -128,11 +102,10 @@ var ResizableBox = /*#__PURE__*/function (_React$Component) {
128
102
  })
129
103
  })));
130
104
  };
131
-
132
105
  return ResizableBox;
133
106
  }(React.Component);
134
-
135
107
  exports.default = ResizableBox;
108
+ // PropTypes are identical to <Resizable>, except that children are not strictly required to be present.
136
109
  ResizableBox.propTypes = _objectSpread(_objectSpread({}, _propTypes2.resizableProps), {}, {
137
110
  children: _propTypes.default.element
138
111
  });
@@ -44,7 +44,7 @@ export default class ResizableBox extends React.Component<ResizableBoxProps, Res
44
44
  onResize: (e: SyntheticEvent<>, data: ResizeCallbackData) => void = (e, data) => {
45
45
  const {size} = data;
46
46
  if (this.props.onResize) {
47
- e.persist && e.persist();
47
+ e.persist?.();
48
48
  this.setState(size, () => this.props.onResize && this.props.onResize(e, data));
49
49
  } else {
50
50
  this.setState(size);
@@ -2,13 +2,9 @@
2
2
 
3
3
  exports.__esModule = true;
4
4
  exports.resizableProps = void 0;
5
-
6
5
  var _propTypes = _interopRequireDefault(require("prop-types"));
7
-
8
6
  var _reactDraggable = require("react-draggable");
9
-
10
7
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
8
  var resizableProps = {
13
9
  /*
14
10
  * Restricts resizing to a particular axis (default: 'both')
@@ -19,12 +15,10 @@ var resizableProps = {
19
15
  * */
20
16
  axis: _propTypes.default.oneOf(['both', 'x', 'y', 'none']),
21
17
  className: _propTypes.default.string,
22
-
23
18
  /*
24
19
  * Require that one and only one child be present.
25
20
  * */
26
21
  children: _propTypes.default.element.isRequired,
27
-
28
22
  /*
29
23
  * These will be passed wholesale to react-draggable's DraggableCore
30
24
  * */
@@ -44,48 +38,50 @@ var resizableProps = {
44
38
  onMouseDown: _propTypes.default.func,
45
39
  scale: _propTypes.default.number
46
40
  }),
47
-
48
41
  /*
49
42
  * Initial height
50
43
  * */
51
- height: _propTypes.default.number.isRequired,
52
-
44
+ height: function height() {
45
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
46
+ args[_key] = arguments[_key];
47
+ }
48
+ var props = args[0];
49
+ // Required if resizing height or both
50
+ if (props.axis === 'both' || props.axis === 'y') {
51
+ var _PropTypes$number;
52
+ return (_PropTypes$number = _propTypes.default.number).isRequired.apply(_PropTypes$number, args);
53
+ }
54
+ return _propTypes.default.number.apply(_propTypes.default, args);
55
+ },
53
56
  /*
54
57
  * Customize cursor resize handle
55
58
  * */
56
59
  handle: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
57
-
58
60
  /*
59
61
  * If you change this, be sure to update your css
60
62
  * */
61
63
  handleSize: _propTypes.default.arrayOf(_propTypes.default.number),
62
64
  lockAspectRatio: _propTypes.default.bool,
63
-
64
65
  /*
65
66
  * Max X & Y measure
66
67
  * */
67
68
  maxConstraints: _propTypes.default.arrayOf(_propTypes.default.number),
68
-
69
69
  /*
70
70
  * Min X & Y measure
71
71
  * */
72
72
  minConstraints: _propTypes.default.arrayOf(_propTypes.default.number),
73
-
74
73
  /*
75
74
  * Called on stop resize event
76
75
  * */
77
76
  onResizeStop: _propTypes.default.func,
78
-
79
77
  /*
80
78
  * Called on start resize event
81
79
  * */
82
80
  onResizeStart: _propTypes.default.func,
83
-
84
81
  /*
85
82
  * Called on resize event
86
83
  * */
87
84
  onResize: _propTypes.default.func,
88
-
89
85
  /*
90
86
  * Defines which resize handles should be rendered (default: 'se')
91
87
  * 's' - South handle (bottom-center)
@@ -98,15 +94,24 @@ var resizableProps = {
98
94
  * 'ne' - Northeast handle (top-center)
99
95
  * */
100
96
  resizeHandles: _propTypes.default.arrayOf(_propTypes.default.oneOf(['s', 'w', 'e', 'n', 'sw', 'nw', 'se', 'ne'])),
101
-
102
97
  /*
103
98
  * If `transform: scale(n)` is set on the parent, this should be set to `n`.
104
99
  * */
105
100
  transformScale: _propTypes.default.number,
106
-
107
101
  /*
108
102
  * Initial width
109
103
  */
110
- width: _propTypes.default.number.isRequired
104
+ width: function width() {
105
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
106
+ args[_key2] = arguments[_key2];
107
+ }
108
+ var props = args[0];
109
+ // Required if resizing width or both
110
+ if (props.axis === 'both' || props.axis === 'x') {
111
+ var _PropTypes$number2;
112
+ return (_PropTypes$number2 = _propTypes.default.number).isRequired.apply(_PropTypes$number2, args);
113
+ }
114
+ return _propTypes.default.number.apply(_propTypes.default, args);
115
+ }
111
116
  };
112
117
  exports.resizableProps = resizableProps;
@@ -88,7 +88,14 @@ export const resizableProps: Object = {
88
88
  /*
89
89
  * Initial height
90
90
  * */
91
- height: PropTypes.number.isRequired,
91
+ height: (...args) => {
92
+ const [props] = args;
93
+ // Required if resizing height or both
94
+ if (props.axis === 'both' || props.axis === 'y') {
95
+ return PropTypes.number.isRequired(...args);
96
+ }
97
+ return PropTypes.number(...args);
98
+ },
92
99
  /*
93
100
  * Customize cursor resize handle
94
101
  * */
@@ -141,5 +148,12 @@ export const resizableProps: Object = {
141
148
  /*
142
149
  * Initial width
143
150
  */
144
- width: PropTypes.number.isRequired,
151
+ width: (...args) => {
152
+ const [props] = args;
153
+ // Required if resizing width or both
154
+ if (props.axis === 'both' || props.axis === 'x') {
155
+ return PropTypes.number.isRequired(...args);
156
+ }
157
+ return PropTypes.number(...args);
158
+ },
145
159
  };
package/build/utils.js CHANGED
@@ -2,26 +2,20 @@
2
2
 
3
3
  exports.__esModule = true;
4
4
  exports.cloneElement = cloneElement;
5
-
6
5
  var _react = _interopRequireDefault(require("react"));
7
-
8
6
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
-
10
- 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; }
11
-
12
- 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; }
13
-
14
- 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; }
15
-
7
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
8
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
9
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
10
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
11
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
16
12
  // React.addons.cloneWithProps look-alike that merges style & className.
17
13
  function cloneElement(element, props) {
18
14
  if (props.style && element.props.style) {
19
15
  props.style = _objectSpread(_objectSpread({}, element.props.style), props.style);
20
16
  }
21
-
22
17
  if (props.className && element.props.className) {
23
18
  props.className = element.props.className + " " + props.className;
24
19
  }
25
-
26
20
  return /*#__PURE__*/_react.default.cloneElement(element, props);
27
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-resizable",
3
- "version": "3.0.3",
3
+ "version": "3.0.5",
4
4
  "description": "A component that is resizable with handles.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -9,8 +9,7 @@
9
9
  "unit": "jest --watch --verbose",
10
10
  "build": "bash build.sh",
11
11
  "build-example": "webpack",
12
- "dev": "webpack-dev-server --open --open-page=examples/1.html",
13
- "watch": "webpack --progress --watch",
12
+ "dev": "webpack serve --open",
14
13
  "prepublishOnly": "npm run build",
15
14
  "validate": "yarn check",
16
15
  "preversion": "npm run lint",
@@ -34,33 +33,34 @@
34
33
  },
35
34
  "homepage": "https://github.com/react-grid-layout/react-resizable",
36
35
  "devDependencies": {
37
- "@babel/cli": "^7.14.3",
38
- "@babel/core": "^7.14.3",
39
- "@babel/eslint-parser": "^7.14.4",
40
- "@babel/plugin-proposal-class-properties": "^7.10.4",
41
- "@babel/plugin-proposal-object-rest-spread": "^7.14.4",
42
- "@babel/preset-env": "^7.14.4",
43
- "@babel/preset-flow": "^7.10.4",
44
- "@babel/preset-react": "^7.10.4",
45
- "babel-loader": "^8.0.6",
36
+ "@babel/cli": "^7.21.0",
37
+ "@babel/core": "^7.21.3",
38
+ "@babel/eslint-parser": "^7.21.3",
39
+ "@babel/plugin-proposal-class-properties": "^7.18.6",
40
+ "@babel/plugin-proposal-object-rest-spread": "^7.20.7",
41
+ "@babel/preset-env": "^7.20.2",
42
+ "@babel/preset-flow": "^7.18.6",
43
+ "@babel/preset-react": "^7.18.6",
44
+ "babel-loader": "^9.1.2",
46
45
  "cross-env": "^7.0.2",
47
- "css-loader": "^4.2.2",
46
+ "css-loader": "^6.7.3",
48
47
  "enzyme": "^3.11.0",
49
- "enzyme-adapter-react-16": "^1.15.4",
50
- "eslint": "^7.28.0",
51
- "eslint-plugin-jest": "^24.3.6",
52
- "eslint-plugin-react": "^7.24.0",
53
- "flow-bin": "^0.150.1",
54
- "jest": "^27.0.4",
48
+ "enzyme-adapter-react-16": "^1.15.7",
49
+ "eslint": "^8.36.0",
50
+ "eslint-plugin-jest": "^27.2.1",
51
+ "eslint-plugin-react": "^7.32.2",
52
+ "flow-bin": "^0.153.0",
53
+ "jest": "^29.5.0",
54
+ "jest-environment-jsdom": "^29.5.0",
55
55
  "lodash": "^4.17.20",
56
56
  "pre-commit": "^1.1.2",
57
57
  "react": "^16.10.2",
58
58
  "react-dom": "^16.10.2",
59
59
  "react-test-renderer": "^16.11.0",
60
- "style-loader": "^1.0.0",
61
- "webpack": "^4.44.1",
62
- "webpack-cli": "^3.3.12",
63
- "webpack-dev-server": "^3.8.2"
60
+ "style-loader": "^3.3.2",
61
+ "webpack": "^5.76.2",
62
+ "webpack-cli": "^5.0.1",
63
+ "webpack-dev-server": "^4.13.1"
64
64
  },
65
65
  "dependencies": {
66
66
  "prop-types": "15.x",