react-grid-layout 0.18.2 → 1.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/.babelrc.js CHANGED
@@ -1,12 +1,14 @@
1
- "use strict";
1
+ // @flow
2
+
3
+ const es6Compat = process.env.BABEL_ES_COMPAT === "6" || process.env.NODE_ENV === "test";
2
4
 
3
5
  module.exports = {
4
6
  presets: [
5
7
  [
6
8
  "@babel/preset-env",
7
9
  {
8
- targets: "> 0.25%, not dead"
9
- }
10
+ targets: es6Compat ? "maintained node versions" : "> 0.25%, not dead"
11
+ },
10
12
  ],
11
13
  "@babel/react",
12
14
  "@babel/preset-flow"
package/.flowconfig CHANGED
@@ -1,5 +1,5 @@
1
1
  [version]
2
- ^0.119.0
2
+ ^0.133.0
3
3
 
4
4
  [ignore]
5
5
  <PROJECT_ROOT>/build/.*
@@ -12,11 +12,8 @@
12
12
 
13
13
  [libs]
14
14
  interfaces/
15
+ flow-typed/
15
16
 
16
17
  [options]
17
18
  emoji=true
18
19
  module.use_strict=true
19
- suppress_comment=\\(.\\|\n\\)*\\s*\\$FlowFixMe.*
20
- suppress_comment=\\(.\\|\n\\)*\\s*\\$FlowBug.*
21
- suppress_comment=\\(.\\|\n\\)*\\s*\\$FlowIgnore.*
22
- suppress_comment=\\(.\\|\n\\)*\\s*\\$FlowNative.*
package/.travis.yml CHANGED
@@ -1,6 +1,7 @@
1
1
  language: node_js
2
2
  node_js:
3
- - "node"
3
+ - 10
4
+ - 12
4
5
  - "lts/*"
5
6
  script:
6
7
  - make build test
package/CHANGELOG.md CHANGED
@@ -1,5 +1,58 @@
1
1
  # Changelog
2
2
 
3
+ 1.1.1 (Sep 10, 2020)
4
+ ---
5
+
6
+ Republish to add `dist/` folder for unpkg use.
7
+
8
+ 1.1.0 (Sep 3, 2020)
9
+ ---
10
+
11
+ ### New Features
12
+ - You can now place resizable handles on all corners. Use the `resizeHandles` prop, which is default `['se']` (for 'southeast').
13
+ - Allowable values are:
14
+ * 's' - South handle (bottom-center)
15
+ * 'w' - West handle (left-center)
16
+ * 'e' - East handle (right-center)
17
+ * 'n' - North handle (top-center)
18
+ * 'sw' - Southwest handle (bottom-left)
19
+ * 'nw' - Northwest handle (top-left)
20
+ * 'se' - Southeast handle (bottom-right)
21
+ * 'ne' - Northeast handle (top-right)
22
+ - These values may be combined, e.g. `['s', 'se', 'e']`, to place three handles on the bottom side, bottom-right corner, and right side.
23
+
24
+ ### Bugfixes
25
+ - Revert `containerPadding` change in #1138. This change was meant to be types-only, but it caused a behavioral change where the default value of `containerPadding` became `[0, 0]`, not `margin`, which is default `[10, 10]`.
26
+ - Add a few more files to `npmignore` to improve package size.
27
+
28
+ 1.0.0 (July 20, 2020)
29
+ ---
30
+
31
+ React-Grid-Layout has been in `0.x` status for far too long. With the addition of some new features in this version and a breaking change, I thought it was time to move to a stable semver.
32
+
33
+ ### Breaking Changes
34
+ - `onDrop` callback now has a form more consistent with other callbacks.
35
+ - Previous type: `(elemParams: { x: number, y: number, w: number, h: number, e: Event }) => void`
36
+ - New type: `(layout: Layout, item: ?LayoutItem, e: Event) => void`
37
+ - Thanks @ceberhar [#1169](https://github.com/STRML/react-grid-layout/pull/1169)
38
+ - Dropping Node 8 compatibility and testing due to devDep incompatibilities
39
+
40
+ ### New Features
41
+ - Add `innerRef: React.Ref<'div'>` prop to expose a ref for the grid layout's outer div. Thanks @paul-sachs [#1176](https://github.com/STRML/react-grid-layout/pull/1176)
42
+ - Add `isBounded` property to prevent dragging items outside of the grid. Thanks @artembykov [#1248](https://github.com/STRML/react-grid-layout/pull/1248)
43
+
44
+ ### Bugfixes
45
+ - Fix grid items stuck using percentages on first render. Thanks @rhbg [#1246](https://github.com/STRML/react-grid-layout/pull/1246)
46
+
47
+ 0.18.3 (Mar 16, 2020)
48
+ ----
49
+
50
+ ### Bugfixes
51
+ - Fix `shouldComponentUpdate` interfering with droppability ([#1152](https://github.com/STRML/react-grid-layout/issues/1152))
52
+
53
+ ### Internal Changes
54
+ - New Enzyme test suite added to prevent regression. If you have time, we could really use more test cases that reflect your use cases!
55
+
3
56
  0.18.2 (Feb 26, 2020)
4
57
  ----
5
58
 
package/README.md CHANGED
@@ -52,6 +52,8 @@ RGL is React-only and does not require jQuery.
52
52
  1. [Error Case](https://strml.github.io/react-grid-layout/examples/13-error-case.html)
53
53
  1. [Toolbox](https://strml.github.io/react-grid-layout/examples/14-toolbox.html)
54
54
  1. [Drag From Outside](https://strml.github.io/react-grid-layout/examples/15-drag-from-outside.html)
55
+ 1. [Bounded Layout](https://strml.github.io/react-grid-layout/examples/16-bounded.html)
56
+ 1. [Resizable Handles](https://strml.github.io/react-grid-layout/examples/17-resizable-handles.html)
55
57
 
56
58
  #### Projects Using React-Grid-Layout
57
59
 
@@ -69,6 +71,7 @@ RGL is React-only and does not require jQuery.
69
71
  - [Monday](https://support.monday.com/hc/en-us/articles/360002187819-What-are-the-Dashboards-)
70
72
  - [Quadency](https://quadency.com/)
71
73
  - [Hakkiri](https://www.hakkiri.io)
74
+ - [Ubidots](https://help.ubidots.com/en/articles/2400308-create-dashboards-and-widgets)
72
75
 
73
76
  *Know of others? Create a PR to let me know!*
74
77
 
@@ -86,7 +89,7 @@ RGL is React-only and does not require jQuery.
86
89
  * Responsive breakpoints
87
90
  * Separate layouts per responsive breakpoint
88
91
  * Grid Items placed using CSS Transforms
89
- * Performance: [on](http://i.imgur.com/FTogpLp.jpg) / [off](http://i.imgur.com/gOveMm8.jpg), note paint (green) as % of time
92
+ * Performance with CSS Transforms: [on](http://i.imgur.com/FTogpLp.jpg) / [off](http://i.imgur.com/gOveMm8.jpg), note paint (green) as % of time
90
93
 
91
94
  |Version | Compatibility |
92
95
  |----------------|------------------|
@@ -197,8 +200,8 @@ If the largest is provided, RGL will attempt to interpolate the rest.
197
200
  You will also need to provide a `width`, when using `<ResponsiveReactGridLayout>` it is suggested you use the HOC
198
201
  `WidthProvider` as per the instructions below.
199
202
 
200
- For the time being, it is not possible to supply responsive mappings via the `data-grid` property on individual
201
- items, but that is coming soon.
203
+ It is possible to supply default mappings via the `data-grid` property on individual
204
+ items, so that they would be taken into account within layout interpolation.
202
205
 
203
206
  ### Providing Grid Width
204
207
 
@@ -304,6 +307,7 @@ droppingItem?: { i: string, w: number, h: number }
304
307
  //
305
308
  isDraggable: ?boolean = true,
306
309
  isResizable: ?boolean = true,
310
+ isBounded: ?boolean = false,
307
311
  // Uses CSS3 translate() instead of position top/left.
308
312
  // This makes about 6x faster paint performance
309
313
  useCSSTransforms: ?boolean = true,
@@ -326,6 +330,17 @@ preventCollision: ?boolean = false;
326
330
  // onDragStart attribute is required for Firefox for a dragging initialization
327
331
  // @see https://bugzilla.mozilla.org/show_bug.cgi?id=568313
328
332
  isDroppable: ?boolean = false
333
+ // Defines which resize handles should be rendered
334
+ // Allows for any combination of:
335
+ // 's' - South handle (bottom-center)
336
+ // 'w' - West handle (left-center)
337
+ // 'e' - East handle (right-center)
338
+ // 'n' - North handle (top-center)
339
+ // 'sw' - Southwest handle (bottom-left)
340
+ // 'nw' - Northwest handle (top-left)
341
+ // 'se' - Southeast handle (bottom-right)
342
+ // 'ne' - Northeast handle (top-right)
343
+ resizeHandles: ?Array<'s' | 'w' | 'e' | 'n' | 'sw' | 'nw' | 'se' | 'ne'> = ['se']
329
344
 
330
345
  //
331
346
  // Callbacks
@@ -354,8 +369,12 @@ onResizeStart: ItemCallback,
354
369
  onResize: ItemCallback,
355
370
  // Calls when resize is complete.
356
371
  onResizeStop: ItemCallback,
357
- // Calls when some element has been dropped
358
- onDrop: (elemParams: { x: number, y: number, w: number, h: number, e: Event }) => void
372
+ // Calls when an element has been dropped into the grid from outside.
373
+ onDrop: (layout: Layout, item: ?LayoutItem, e: Event) => void
374
+
375
+ // Ref for getting a reference for the grid's wrapping div.
376
+ // You can use this instead of a regular ref and the deprecated `ReactDOM.findDOMNode()`` function.
377
+ innerRef: ?React.Ref<"div">
359
378
  ```
360
379
 
361
380
  ### Responsive Grid Layout Props
@@ -440,7 +459,12 @@ will be draggable, even if the item is marked `static: true`.
440
459
  // If false, will not be draggable. Overrides `static`.
441
460
  isDraggable: ?boolean = true,
442
461
  // If false, will not be resizable. Overrides `static`.
443
- isResizable: ?boolean = true
462
+ isResizable: ?boolean = true,
463
+ // By default, a handle is only shown on the bottom-right (southeast) corner.
464
+ // Note that resizing from the top or left is generally not intuitive.
465
+ resizeHandles?: ?Array<'s' | 'w' | 'e' | 'n' | 'sw' | 'nw' | 'se' | 'ne'> = ['se']
466
+ // If true and draggable, item will be moved only within grid.
467
+ isBounded: ?boolean = false
444
468
  }
445
469
  ```
446
470
 
@@ -468,9 +492,9 @@ shouldComponentUpdate(nextProps: Props, nextState: State) {
468
492
  If you memoize your children, you can take advantage of this, and reap faster rerenders. For example:
469
493
 
470
494
  ```js
471
- function MyGrid() {
472
- const children = React.useMemo((count) => {
473
- return new Array(count).fill(undefined).map((val, idx) => {
495
+ function MyGrid(props) {
496
+ const children = React.useMemo(() => {
497
+ return new Array(props.count).fill(undefined).map((val, idx) => {
474
498
  return <div key={idx} data-grid={{x: idx, y: 1, w: 1, h: 1}} />;
475
499
  });
476
500
  }, [props.count]);
package/build/GridItem.js CHANGED
@@ -35,29 +35,31 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
35
35
 
36
36
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
37
37
 
38
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
38
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
39
39
 
40
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
40
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
41
+
42
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
43
+
44
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
41
45
 
42
46
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
43
47
 
44
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
48
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
45
49
 
46
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
50
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
47
51
 
48
52
  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; }
49
53
 
50
54
  /**
51
55
  * An individual item within a ReactGridLayout.
52
56
  */
53
- var GridItem =
54
- /*#__PURE__*/
55
- function (_React$Component) {
57
+ var GridItem = /*#__PURE__*/function (_React$Component) {
56
58
  _inherits(GridItem, _React$Component);
57
59
 
58
- function GridItem() {
59
- var _getPrototypeOf2;
60
+ var _super = _createSuper(GridItem);
60
61
 
62
+ function GridItem() {
61
63
  var _this;
62
64
 
63
65
  _classCallCheck(this, GridItem);
@@ -66,7 +68,7 @@ function (_React$Component) {
66
68
  args[_key] = arguments[_key];
67
69
  }
68
70
 
69
- _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(GridItem)).call.apply(_getPrototypeOf2, [this].concat(args)));
71
+ _this = _super.call.apply(_super, [this].concat(args));
70
72
 
71
73
  _defineProperty(_assertThisInitialized(_this), "state", {
72
74
  resizing: null,
@@ -80,7 +82,8 @@ function (_React$Component) {
80
82
  /*: Event*/
81
83
  , _ref) {
82
84
  var node = _ref.node;
83
- if (!_this.props.onDragStart) return;
85
+ var onDragStart = _this.props.onDragStart;
86
+ if (!onDragStart) return;
84
87
  var newPosition
85
88
  /*: PartialPosition*/
86
89
  = {
@@ -101,13 +104,14 @@ function (_React$Component) {
101
104
 
102
105
  _this.setState({
103
106
  dragging: newPosition
104
- });
107
+ }); // Call callback with this data
108
+
105
109
 
106
110
  var _calcXY = (0, _calculateUtils.calcXY)(_this.getPositionParams(), newPosition.top, newPosition.left, _this.props.w, _this.props.h),
107
111
  x = _calcXY.x,
108
112
  y = _calcXY.y;
109
113
 
110
- return _this.props.onDragStart && _this.props.onDragStart.call(_assertThisInitialized(_this), _this.props.i, x, y, {
114
+ return onDragStart.call(_assertThisInitialized(_this), _this.props.i, x, y, {
111
115
  e: e,
112
116
  node: node,
113
117
  newPosition: newPosition
@@ -126,25 +130,55 @@ function (_React$Component) {
126
130
  if (!onDrag) return;
127
131
  deltaX /= transformScale;
128
132
  deltaY /= transformScale;
133
+
134
+ if (!_this.state.dragging) {
135
+ throw new Error("onDrag called before onDragStart.");
136
+ }
137
+
138
+ var top = _this.state.dragging.top + deltaY;
139
+ var left = _this.state.dragging.left + deltaX;
140
+ var _this$props2 = _this.props,
141
+ isBounded = _this$props2.isBounded,
142
+ i = _this$props2.i,
143
+ w = _this$props2.w,
144
+ h = _this$props2.h,
145
+ containerWidth = _this$props2.containerWidth;
146
+
147
+ var positionParams = _this.getPositionParams(); // Boundary calculations; keeps items within the grid
148
+
149
+
150
+ if (isBounded) {
151
+ var offsetParent = node.offsetParent;
152
+
153
+ if (offsetParent) {
154
+ var _this$props3 = _this.props,
155
+ margin = _this$props3.margin,
156
+ rowHeight = _this$props3.rowHeight;
157
+ var bottomBoundary = offsetParent.clientHeight - (0, _calculateUtils.calcGridItemWHPx)(h, rowHeight, margin[1]);
158
+ top = (0, _calculateUtils.clamp)(top, 0, bottomBoundary);
159
+ var colWidth = (0, _calculateUtils.calcGridColWidth)(positionParams);
160
+ var rightBoundary = containerWidth - (0, _calculateUtils.calcGridItemWHPx)(w, colWidth, margin[0]);
161
+ left = (0, _calculateUtils.clamp)(left, 0, rightBoundary);
162
+ }
163
+ }
164
+
129
165
  var newPosition
130
166
  /*: PartialPosition*/
131
167
  = {
132
- top: 0,
133
- left: 0
168
+ top: top,
169
+ left: left
134
170
  };
135
- if (!_this.state.dragging) throw new Error("onDrag called before onDragStart.");
136
- newPosition.left = _this.state.dragging.left + deltaX;
137
- newPosition.top = _this.state.dragging.top + deltaY;
138
171
 
139
172
  _this.setState({
140
173
  dragging: newPosition
141
- });
174
+ }); // Call callback with this data
175
+
142
176
 
143
- var _calcXY2 = (0, _calculateUtils.calcXY)(_this.getPositionParams(), newPosition.top, newPosition.left, _this.props.w, _this.props.h),
177
+ var _calcXY2 = (0, _calculateUtils.calcXY)(positionParams, top, left, w, h),
144
178
  x = _calcXY2.x,
145
179
  y = _calcXY2.y;
146
180
 
147
- return onDrag && onDrag.call(_assertThisInitialized(_this), _this.props.i, x, y, {
181
+ return onDrag.call(_assertThisInitialized(_this), i, x, y, {
148
182
  e: e,
149
183
  node: node,
150
184
  newPosition: newPosition
@@ -155,26 +189,36 @@ function (_React$Component) {
155
189
  /*: Event*/
156
190
  , _ref3) {
157
191
  var node = _ref3.node;
158
- if (!_this.props.onDragStop) return;
192
+ var onDragStop = _this.props.onDragStop;
193
+ if (!onDragStop) return;
194
+
195
+ if (!_this.state.dragging) {
196
+ throw new Error("onDragEnd called before onDragStart.");
197
+ }
198
+
199
+ var _this$props4 = _this.props,
200
+ w = _this$props4.w,
201
+ h = _this$props4.h,
202
+ i = _this$props4.i;
203
+ var _this$state$dragging = _this.state.dragging,
204
+ left = _this$state$dragging.left,
205
+ top = _this$state$dragging.top;
159
206
  var newPosition
160
207
  /*: PartialPosition*/
161
208
  = {
162
- top: 0,
163
- left: 0
209
+ top: top,
210
+ left: left
164
211
  };
165
- if (!_this.state.dragging) throw new Error("onDragEnd called before onDragStart.");
166
- newPosition.left = _this.state.dragging.left;
167
- newPosition.top = _this.state.dragging.top;
168
212
 
169
213
  _this.setState({
170
214
  dragging: null
171
215
  });
172
216
 
173
- var _calcXY3 = (0, _calculateUtils.calcXY)(_this.getPositionParams(), newPosition.top, newPosition.left, _this.props.w, _this.props.h),
217
+ var _calcXY3 = (0, _calculateUtils.calcXY)(_this.getPositionParams(), top, left, w, h),
174
218
  x = _calcXY3.x,
175
219
  y = _calcXY3.y;
176
220
 
177
- return _this.props.onDragStop && _this.props.onDragStop.call(_assertThisInitialized(_this), _this.props.i, x, y, {
221
+ return onDragStop.call(_assertThisInitialized(_this), i, x, y, {
178
222
  e: e,
179
223
  node: node,
180
224
  newPosition: newPosition
@@ -217,12 +261,18 @@ function (_React$Component) {
217
261
  ) {
218
262
  // We can't deeply compare children. If the developer memoizes them, we can
219
263
  // use this optimization.
220
- if (this.props.children !== nextProps.children) return true; // TODO memoize these calculations so they don't take so long?
264
+ if (this.props.children !== nextProps.children) return true;
265
+ if (this.props.droppingPosition !== nextProps.droppingPosition) return true; // TODO memoize these calculations so they don't take so long?
221
266
 
222
267
  var oldPosition = (0, _calculateUtils.calcGridItemPosition)(this.getPositionParams(this.props), this.props.x, this.props.y, this.props.w, this.props.h, this.state);
223
268
  var newPosition = (0, _calculateUtils.calcGridItemPosition)(this.getPositionParams(nextProps), nextProps.x, nextProps.y, nextProps.w, nextProps.h, nextState);
224
269
  return !(0, _utils.fastPositionEqual)(oldPosition, newPosition) || this.props.useCSSTransforms !== nextProps.useCSSTransforms;
225
270
  }
271
+ }, {
272
+ key: "componentDidMount",
273
+ value: function componentDidMount() {
274
+ this.moveDroppingItem({});
275
+ }
226
276
  }, {
227
277
  key: "componentDidUpdate",
228
278
  value: function componentDidUpdate(prevProps
@@ -238,13 +288,13 @@ function (_React$Component) {
238
288
  /*: Props*/
239
289
  ) {
240
290
  var droppingPosition = this.props.droppingPosition;
241
- var prevDroppingPosition = prevProps.droppingPosition;
291
+ if (!droppingPosition) return;
292
+ var prevDroppingPosition = prevProps.droppingPosition || {
293
+ left: 0,
294
+ top: 0
295
+ };
242
296
  var dragging = this.state.dragging;
243
297
 
244
- if (!droppingPosition || !prevDroppingPosition) {
245
- return;
246
- }
247
-
248
298
  if (!this.currentNode) {
249
299
  // eslint-disable-next-line react/no-find-dom-node
250
300
  this.currentNode = ((_reactDom.default.findDOMNode(this)
@@ -307,10 +357,10 @@ function (_React$Component) {
307
357
  )
308
358
  /*: { [key: string]: ?string }*/
309
359
  {
310
- var _this$props2 = this.props,
311
- usePercentages = _this$props2.usePercentages,
312
- containerWidth = _this$props2.containerWidth,
313
- useCSSTransforms = _this$props2.useCSSTransforms;
360
+ var _this$props5 = this.props,
361
+ usePercentages = _this$props5.usePercentages,
362
+ containerWidth = _this$props5.containerWidth,
363
+ useCSSTransforms = _this$props5.useCSSTransforms;
314
364
  var style; // CSS Transforms support (default)
315
365
 
316
366
  if (useCSSTransforms) {
@@ -342,7 +392,7 @@ function (_React$Component) {
342
392
  )
343
393
  /*: ReactElement<any>*/
344
394
  {
345
- return _react.default.createElement(_reactDraggable.DraggableCore, {
395
+ return /*#__PURE__*/_react.default.createElement(_reactDraggable.DraggableCore, {
346
396
  disabled: !isDraggable,
347
397
  onStart: this.onDragStart,
348
398
  onDrag: this.onDrag,
@@ -370,14 +420,15 @@ function (_React$Component) {
370
420
  )
371
421
  /*: ReactElement<any>*/
372
422
  {
373
- var _this$props3 = this.props,
374
- cols = _this$props3.cols,
375
- x = _this$props3.x,
376
- minW = _this$props3.minW,
377
- minH = _this$props3.minH,
378
- maxW = _this$props3.maxW,
379
- maxH = _this$props3.maxH,
380
- transformScale = _this$props3.transformScale;
423
+ var _this$props6 = this.props,
424
+ cols = _this$props6.cols,
425
+ x = _this$props6.x,
426
+ minW = _this$props6.minW,
427
+ minH = _this$props6.minH,
428
+ maxW = _this$props6.maxW,
429
+ maxH = _this$props6.maxH,
430
+ transformScale = _this$props6.transformScale,
431
+ resizeHandles = _this$props6.resizeHandles;
381
432
  var positionParams = this.getPositionParams(); // This is the max possible width - doesn't go to infinity because of the width of the window
382
433
 
383
434
  var maxWidth = (0, _calculateUtils.calcGridItemPosition)(positionParams, 0, 0, cols - x, 0).width; // Calculate min/max constraints using our min & maxes
@@ -386,7 +437,7 @@ function (_React$Component) {
386
437
  var maxes = (0, _calculateUtils.calcGridItemPosition)(positionParams, 0, 0, maxW, maxH);
387
438
  var minConstraints = [mins.width, mins.height];
388
439
  var maxConstraints = [Math.min(maxes.width, maxWidth), Math.min(maxes.height, Infinity)];
389
- return _react.default.createElement(_reactResizable.Resizable, {
440
+ return /*#__PURE__*/_react.default.createElement(_reactResizable.Resizable, {
390
441
  draggableOpts: {
391
442
  disabled: !isResizable
392
443
  },
@@ -398,7 +449,8 @@ function (_React$Component) {
398
449
  onResizeStop: this.onResizeStop,
399
450
  onResizeStart: this.onResizeStart,
400
451
  onResize: this.onResize,
401
- transformScale: transformScale
452
+ transformScale: transformScale,
453
+ resizeHandles: resizeHandles
402
454
  }, child);
403
455
  }
404
456
  /**
@@ -427,27 +479,28 @@ function (_React$Component) {
427
479
  size = _ref4.size;
428
480
  var handler = this.props[handlerName];
429
481
  if (!handler) return;
430
- var _this$props4 = this.props,
431
- cols = _this$props4.cols,
432
- x = _this$props4.x,
433
- y = _this$props4.y,
434
- i = _this$props4.i,
435
- maxW = _this$props4.maxW,
436
- minW = _this$props4.minW,
437
- maxH = _this$props4.maxH,
438
- minH = _this$props4.minH; // Get new XY
482
+ var _this$props7 = this.props,
483
+ cols = _this$props7.cols,
484
+ x = _this$props7.x,
485
+ y = _this$props7.y,
486
+ i = _this$props7.i,
487
+ maxH = _this$props7.maxH,
488
+ minH = _this$props7.minH;
489
+ var _this$props8 = this.props,
490
+ minW = _this$props8.minW,
491
+ maxW = _this$props8.maxW; // Get new XY
439
492
 
440
493
  var _calcWH = (0, _calculateUtils.calcWH)(this.getPositionParams(), size.width, size.height, x, y),
441
494
  w = _calcWH.w,
442
- h = _calcWH.h; // Cap w at numCols
495
+ h = _calcWH.h; // minW should be at least 1 (TODO propTypes validation?)
443
496
 
444
497
 
445
- w = Math.min(w, cols - x); // Ensure w is at least 1
498
+ minW = Math.max(minW, 1); // maxW should be at most (cols - x)
446
499
 
447
- w = Math.max(w, 1); // Min/max capping
500
+ maxW = Math.min(maxW, cols - x); // Min/max capping
448
501
 
449
- w = Math.max(Math.min(w, maxW), minW);
450
- h = Math.max(Math.min(h, maxH), minH);
502
+ w = (0, _calculateUtils.clamp)(w, minW, maxW);
503
+ h = (0, _calculateUtils.clamp)(h, minH, maxH);
451
504
  this.setState({
452
505
  resizing: handlerName === "onResizeStop" ? null : size
453
506
  });
@@ -462,21 +515,21 @@ function (_React$Component) {
462
515
  value: function render()
463
516
  /*: ReactNode*/
464
517
  {
465
- var _this$props5 = this.props,
466
- x = _this$props5.x,
467
- y = _this$props5.y,
468
- w = _this$props5.w,
469
- h = _this$props5.h,
470
- isDraggable = _this$props5.isDraggable,
471
- isResizable = _this$props5.isResizable,
472
- droppingPosition = _this$props5.droppingPosition,
473
- useCSSTransforms = _this$props5.useCSSTransforms;
518
+ var _this$props9 = this.props,
519
+ x = _this$props9.x,
520
+ y = _this$props9.y,
521
+ w = _this$props9.w,
522
+ h = _this$props9.h,
523
+ isDraggable = _this$props9.isDraggable,
524
+ isResizable = _this$props9.isResizable,
525
+ droppingPosition = _this$props9.droppingPosition,
526
+ useCSSTransforms = _this$props9.useCSSTransforms;
474
527
  var pos = (0, _calculateUtils.calcGridItemPosition)(this.getPositionParams(), x, y, w, h, this.state);
475
528
 
476
529
  var child = _react.default.Children.only(this.props.children); // Create the child element. We clone the existing element but modify its className and style.
477
530
 
478
531
 
479
- var newChild = _react.default.cloneElement(child, {
532
+ var newChild = /*#__PURE__*/_react.default.cloneElement(child, {
480
533
  className: (0, _classnames.default)("react-grid-item", child.props.className, this.props.className, {
481
534
  static: this.props.static,
482
535
  resizing: Boolean(this.state.resizing),
@@ -486,7 +539,7 @@ function (_React$Component) {
486
539
  cssTransforms: useCSSTransforms
487
540
  }),
488
541
  // We can set the width and height on the child, but unfortunately we can't set the position.
489
- style: _objectSpread({}, this.props.style, {}, child.props.style, {}, this.createStyle(pos))
542
+ style: _objectSpread(_objectSpread(_objectSpread({}, this.props.style), child.props.style), this.createStyle(pos))
490
543
  }); // Resizable support. This is usually on but the user can toggle it off.
491
544
 
492
545
 
@@ -566,6 +619,7 @@ _defineProperty(GridItem, "propTypes", {
566
619
  // Flags
567
620
  isDraggable: _propTypes.default.bool.isRequired,
568
621
  isResizable: _propTypes.default.bool.isRequired,
622
+ isBounded: _propTypes.default.bool.isRequired,
569
623
  static: _propTypes.default.bool,
570
624
  // Use CSS transforms instead of top/left
571
625
  useCSSTransforms: _propTypes.default.bool.isRequired,