react-grid-layout 1.5.2 → 1.5.3
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/CHANGELOG.md +8 -8
- package/README.md +1 -0
- package/build/GridItem.js +3 -5
- package/build/ReactGridLayout.js +14 -17
- package/build/ReactGridLayoutPropTypes.js +1 -1
- package/build/ResponsiveReactGridLayout.js +21 -18
- package/build/components/WidthProvider.js +8 -4
- package/build/utils.js +34 -26
- package/dist/react-grid-layout.min.js +1 -1
- package/dist/react-grid-layout.min.js.map +1 -1
- package/lib/utils.js +20 -4
- package/package.json +3 -2
- package/yarn-error.log +7780 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.5.3 (Dec 5, 2025)
|
|
4
|
+
|
|
5
|
+
- Fix collision detection y-coordinate offset. [#2173](https://github.com/react-grid-layout/react-grid-layout/pull/2173)
|
|
6
|
+
- Memoize bottom computation in compact for performance. [#2115](https://github.com/react-grid-layout/react-grid-layout/pull/2115)
|
|
7
|
+
- Make `b` param in `compactItem` optional. [#2165](https://github.com/react-grid-layout/react-grid-layout/pull/2165)
|
|
8
|
+
- Fix example animations and rework example styles.
|
|
9
|
+
- Various devDependency updates and security fixes. [#2179](https://github.com/react-grid-layout/react-grid-layout/pull/2179)
|
|
10
|
+
|
|
3
11
|
## 1.5.2 (Jun 25, 2025)
|
|
4
12
|
|
|
5
13
|
- Fix `calcXY` when `isBounded=true` moving items incorrectly. Likely related to #2059. Thanks @wanpan11. [#2102](https://github.com/react-grid-layout/react-grid-layout/pull/2102)
|
|
@@ -440,7 +448,6 @@ Thanks to @daynin and @n1ghtmare for taking an active role in maintaining RGL, a
|
|
|
440
448
|
---
|
|
441
449
|
|
|
442
450
|
- Fix React PropTypes & createClass warnings
|
|
443
|
-
|
|
444
451
|
- See https://github.com/facebook/react/issues/10583
|
|
445
452
|
|
|
446
453
|
0.15.0 (Aug 21, 2017)
|
|
@@ -456,7 +463,6 @@ Thanks to @daynin and @n1ghtmare for taking an active role in maintaining RGL, a
|
|
|
456
463
|
---
|
|
457
464
|
|
|
458
465
|
- Fixed a dragging bug when the grid container is scrollable. Thanks @chultquist.
|
|
459
|
-
|
|
460
466
|
- Ref: https://github.com/STRML/react-grid-layout/pull/555
|
|
461
467
|
|
|
462
468
|
0.14.6 (Apr 19, 2017)
|
|
@@ -531,7 +537,6 @@ Thanks to @daynin and @n1ghtmare for taking an active role in maintaining RGL, a
|
|
|
531
537
|
#### Fixes:
|
|
532
538
|
|
|
533
539
|
- Fixed sorting of layout items, which could be different in IE if two items have the same x & y coordinate.
|
|
534
|
-
|
|
535
540
|
- See [#369](https://github.com/STRML/react-grid-layout/issues/369).
|
|
536
541
|
|
|
537
542
|
0.13.8 (Oct 13, 2016)
|
|
@@ -541,7 +546,6 @@ Thanks to @daynin and @n1ghtmare for taking an active role in maintaining RGL, a
|
|
|
541
546
|
#### Fixes:
|
|
542
547
|
|
|
543
548
|
- Fixed breakage introduced in `0.13.7` when items are added without a layout or `data-grid` property.
|
|
544
|
-
|
|
545
549
|
- See [#368](https://github.com/STRML/react-grid-layout/issues/368).
|
|
546
550
|
|
|
547
551
|
0.13.7 (Oct 3, 2016)
|
|
@@ -579,7 +583,6 @@ Thanks to @daynin and @n1ghtmare for taking an active role in maintaining RGL, a
|
|
|
579
583
|
|
|
580
584
|
- Fixed potential call to `ReactDOM.findDOMNode(this)` after unmount of `WidthProvider`.
|
|
581
585
|
- Fixed an issue where layout items using `data-grid` could rearrange on mount depending on how they were ordered.
|
|
582
|
-
|
|
583
586
|
- See [#342](https://github.com/STRML/react-grid-layout/pull/342) for reference.
|
|
584
587
|
|
|
585
588
|
0.13.3 (Aug 31, 2016)
|
|
@@ -602,7 +605,6 @@ Thanks to @daynin and @n1ghtmare for taking an active role in maintaining RGL, a
|
|
|
602
605
|
- I'm aware this could be a breaking change if you were relying on this bad behavior. If so, please
|
|
603
606
|
use your own `WidthProvider`-style HOC.
|
|
604
607
|
- `babel-plugin-transform-flow-comments` had limited support for defining types like transpiled classes.
|
|
605
|
-
|
|
606
608
|
- This has been updated to instead copy source to `.js.flow` files, which preserves all type information.
|
|
607
609
|
|
|
608
610
|
0.13.1 (Aug 16, 2016)
|
|
@@ -650,7 +652,6 @@ Thanks to @daynin and @n1ghtmare for taking an active role in maintaining RGL, a
|
|
|
650
652
|
---
|
|
651
653
|
|
|
652
654
|
- Update to React-Draggable v2. Fixes: #241, #239, #24
|
|
653
|
-
|
|
654
655
|
- v2 contains a number of bugfixes & enhancements for touchscreens, multitouch, and scrolling containers.
|
|
655
656
|
|
|
656
657
|
0.12.3 (May 3, 2016)
|
|
@@ -828,7 +829,6 @@ Other changes:
|
|
|
828
829
|
- Upgraded to Babel 6.
|
|
829
830
|
- Full typechecking via Flow.
|
|
830
831
|
- Lots of misc bugfixes.
|
|
831
|
-
|
|
832
832
|
- See beta releases below for more details.
|
|
833
833
|
|
|
834
834
|
0.10.0-beta1
|
package/README.md
CHANGED
|
@@ -62,6 +62,7 @@ RGL is React-only and does not require jQuery.
|
|
|
62
62
|
|
|
63
63
|
#### Projects Using React-Grid-Layout
|
|
64
64
|
|
|
65
|
+
- [Basedash](https://www.basedash.com)
|
|
65
66
|
- [BitMEX](https://www.bitmex.com/)
|
|
66
67
|
- [AWS CloudFront Dashboards](https://aws.amazon.com/blogs/aws/cloudwatch-dashboards-create-use-customized-metrics-views/)
|
|
67
68
|
- [Grafana](https://grafana.com/)
|
package/build/GridItem.js
CHANGED
|
@@ -14,6 +14,8 @@ var _calculateUtils = require("./calculateUtils");
|
|
|
14
14
|
var _ReactGridLayoutPropTypes = require("./ReactGridLayoutPropTypes");
|
|
15
15
|
var _clsx = _interopRequireDefault(require("clsx"));
|
|
16
16
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
|
+
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; }
|
|
18
|
+
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; }
|
|
17
19
|
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; }
|
|
18
20
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
19
21
|
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); }
|
|
@@ -543,11 +545,7 @@ class GridItem extends _react.default.Component /*:: <Props, State>*/{
|
|
|
543
545
|
cssTransforms: useCSSTransforms
|
|
544
546
|
}),
|
|
545
547
|
// We can set the width and height on the child, but unfortunately we can't set the position.
|
|
546
|
-
style: {
|
|
547
|
-
...this.props.style,
|
|
548
|
-
...child.props.style,
|
|
549
|
-
...this.createStyle(pos)
|
|
550
|
-
}
|
|
548
|
+
style: _objectSpread(_objectSpread(_objectSpread({}, this.props.style), child.props.style), this.createStyle(pos))
|
|
551
549
|
});
|
|
552
550
|
|
|
553
551
|
// Resizable support. This is usually on but the user can toggle it off.
|
package/build/ReactGridLayout.js
CHANGED
|
@@ -13,6 +13,8 @@ var _GridItem = _interopRequireDefault(require("./GridItem"));
|
|
|
13
13
|
var _ReactGridLayoutPropTypes = _interopRequireDefault(require("./ReactGridLayoutPropTypes"));
|
|
14
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
15
|
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); }
|
|
16
|
+
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; }
|
|
17
|
+
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; }
|
|
16
18
|
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; }
|
|
17
19
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
18
20
|
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); }
|
|
@@ -265,13 +267,12 @@ class ReactGridLayout extends React.Component /*:: <Props, State>*/{
|
|
|
265
267
|
// Something like quad tree should be used
|
|
266
268
|
// to find collisions faster
|
|
267
269
|
if (preventCollision && !allowOverlap) {
|
|
268
|
-
const collisions = (0, _utils.getAllCollisions)(layout, {
|
|
269
|
-
...l,
|
|
270
|
+
const collisions = (0, _utils.getAllCollisions)(layout, _objectSpread(_objectSpread({}, l), {}, {
|
|
270
271
|
w,
|
|
271
272
|
h,
|
|
272
273
|
x,
|
|
273
274
|
y
|
|
274
|
-
}).filter(layoutItem => layoutItem.i !== l.i);
|
|
275
|
+
})).filter(layoutItem => layoutItem.i !== l.i);
|
|
275
276
|
hasCollisions = collisions.length > 0;
|
|
276
277
|
|
|
277
278
|
// If we're colliding, we need adjust the placeholder.
|
|
@@ -348,6 +349,7 @@ class ReactGridLayout extends React.Component /*:: <Props, State>*/{
|
|
|
348
349
|
// Called while dragging an element. Part of browser native drag/drop API.
|
|
349
350
|
// Native event target might be the layout itself, or an element within the layout.
|
|
350
351
|
_defineProperty(this, "onDragOver", e => {
|
|
352
|
+
var _e$nativeEvent$target;
|
|
351
353
|
e.preventDefault(); // Prevent any browser native action
|
|
352
354
|
e.stopPropagation();
|
|
353
355
|
|
|
@@ -356,7 +358,7 @@ class ReactGridLayout extends React.Component /*:: <Props, State>*/{
|
|
|
356
358
|
// FIXME remove this hack
|
|
357
359
|
if (isFirefox &&
|
|
358
360
|
// $FlowIgnore can't figure this out
|
|
359
|
-
!e.nativeEvent.target
|
|
361
|
+
!((_e$nativeEvent$target = e.nativeEvent.target) !== null && _e$nativeEvent$target !== void 0 && _e$nativeEvent$target.classList.contains(layoutClassName))) {
|
|
360
362
|
return false;
|
|
361
363
|
}
|
|
362
364
|
const {
|
|
@@ -372,17 +374,14 @@ class ReactGridLayout extends React.Component /*:: <Props, State>*/{
|
|
|
372
374
|
} = this.props;
|
|
373
375
|
// Allow user to customize the dropping item or short-circuit the drop based on the results
|
|
374
376
|
// of the `onDragOver(e: Event)` callback.
|
|
375
|
-
const onDragOverResult = onDropDragOver
|
|
377
|
+
const onDragOverResult = onDropDragOver === null || onDropDragOver === void 0 ? void 0 : onDropDragOver(e);
|
|
376
378
|
if (onDragOverResult === false) {
|
|
377
379
|
if (this.state.droppingDOMNode) {
|
|
378
380
|
this.removeDroppingPlaceholder();
|
|
379
381
|
}
|
|
380
382
|
return false;
|
|
381
383
|
}
|
|
382
|
-
const finalDroppingItem = {
|
|
383
|
-
...droppingItem,
|
|
384
|
-
...onDragOverResult
|
|
385
|
-
};
|
|
384
|
+
const finalDroppingItem = _objectSpread(_objectSpread({}, droppingItem), onDragOverResult);
|
|
386
385
|
const {
|
|
387
386
|
layout
|
|
388
387
|
} = this.state;
|
|
@@ -413,13 +412,12 @@ class ReactGridLayout extends React.Component /*:: <Props, State>*/{
|
|
|
413
412
|
key: finalDroppingItem.i
|
|
414
413
|
}),
|
|
415
414
|
droppingPosition,
|
|
416
|
-
layout: [...layout, {
|
|
417
|
-
...finalDroppingItem,
|
|
415
|
+
layout: [...layout, _objectSpread(_objectSpread({}, finalDroppingItem), {}, {
|
|
418
416
|
x: calculatedPosition.x,
|
|
419
417
|
y: calculatedPosition.y,
|
|
420
418
|
static: false,
|
|
421
419
|
isDraggable: true
|
|
422
|
-
}]
|
|
420
|
+
})]
|
|
423
421
|
});
|
|
424
422
|
} else if (this.state.droppingPosition) {
|
|
425
423
|
const {
|
|
@@ -584,7 +582,7 @@ class ReactGridLayout extends React.Component /*:: <Props, State>*/{
|
|
|
584
582
|
x: activeDrag.x,
|
|
585
583
|
y: activeDrag.y,
|
|
586
584
|
i: activeDrag.i,
|
|
587
|
-
className:
|
|
585
|
+
className: "react-grid-placeholder ".concat(this.state.resizing ? "placeholder-resizing" : ""),
|
|
588
586
|
containerWidth: width,
|
|
589
587
|
cols: cols,
|
|
590
588
|
margin: margin,
|
|
@@ -683,10 +681,9 @@ class ReactGridLayout extends React.Component /*:: <Props, State>*/{
|
|
|
683
681
|
innerRef
|
|
684
682
|
} = this.props;
|
|
685
683
|
const mergedClassName = (0, _clsx.default)(layoutClassName, className);
|
|
686
|
-
const mergedStyle = {
|
|
687
|
-
height: this.containerHeight()
|
|
688
|
-
|
|
689
|
-
};
|
|
684
|
+
const mergedStyle = _objectSpread({
|
|
685
|
+
height: this.containerHeight()
|
|
686
|
+
}, style);
|
|
690
687
|
return /*#__PURE__*/React.createElement("div", {
|
|
691
688
|
ref: innerRef,
|
|
692
689
|
className: mergedClassName,
|
|
@@ -198,7 +198,7 @@ var _default = exports.default = {
|
|
|
198
198
|
// Check children keys for duplicates. Throw if found.
|
|
199
199
|
const keys = {};
|
|
200
200
|
_react.default.Children.forEach(children, function (child) {
|
|
201
|
-
if (child
|
|
201
|
+
if ((child === null || child === void 0 ? void 0 : child.key) == null) return;
|
|
202
202
|
if (keys[child.key]) {
|
|
203
203
|
throw new Error('Duplicate child key "' + child.key + '" found! This will cause problems in ReactGridLayout.');
|
|
204
204
|
}
|
|
@@ -10,9 +10,14 @@ var _fastEquals = require("fast-equals");
|
|
|
10
10
|
var _utils = require("./utils");
|
|
11
11
|
var _responsiveUtils = require("./responsiveUtils");
|
|
12
12
|
var _ReactGridLayout = _interopRequireDefault(require("./ReactGridLayout"));
|
|
13
|
+
const _excluded = ["breakpoint", "breakpoints", "cols", "layouts", "margin", "containerPadding", "onBreakpointChange", "onLayoutChange", "onWidthChange"];
|
|
13
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
15
|
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); }
|
|
15
16
|
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); }
|
|
17
|
+
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; }
|
|
18
|
+
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; }
|
|
19
|
+
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; }
|
|
20
|
+
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; }
|
|
16
21
|
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; }
|
|
17
22
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
18
23
|
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); } /*:: import { type Layout, type Pick } from "./utils";*/ /*:: import { type ResponsiveLayout, type OnLayoutChangeCallback, type Breakpoints } from "./responsiveUtils";*/
|
|
@@ -86,10 +91,9 @@ class ResponsiveReactGridLayout extends React.Component
|
|
|
86
91
|
_defineProperty(this, "state", this.generateInitialState());
|
|
87
92
|
// wrap layouts so we do not need to pass layouts to child
|
|
88
93
|
_defineProperty(this, "onLayoutChange", (layout /*: Layout*/) => {
|
|
89
|
-
this.props.onLayoutChange(layout, {
|
|
90
|
-
...this.props.layouts,
|
|
94
|
+
this.props.onLayoutChange(layout, _objectSpread(_objectSpread({}, this.props.layouts), {}, {
|
|
91
95
|
[this.state.breakpoint]: layout
|
|
92
|
-
});
|
|
96
|
+
}));
|
|
93
97
|
});
|
|
94
98
|
}
|
|
95
99
|
generateInitialState() /*: State*/{
|
|
@@ -150,9 +154,7 @@ class ResponsiveReactGridLayout extends React.Component
|
|
|
150
154
|
const newBreakpoint = this.props.breakpoint || (0, _responsiveUtils.getBreakpointFromWidth)(this.props.breakpoints, this.props.width);
|
|
151
155
|
const lastBreakpoint = this.state.breakpoint;
|
|
152
156
|
const newCols /*: number*/ = (0, _responsiveUtils.getColsFromBreakpoint)(newBreakpoint, cols);
|
|
153
|
-
const newLayouts = {
|
|
154
|
-
...layouts
|
|
155
|
-
};
|
|
157
|
+
const newLayouts = _objectSpread({}, layouts);
|
|
156
158
|
|
|
157
159
|
// Breakpoint change
|
|
158
160
|
if (lastBreakpoint !== newBreakpoint || prevProps.breakpoints !== breakpoints || prevProps.cols !== cols) {
|
|
@@ -185,18 +187,19 @@ class ResponsiveReactGridLayout extends React.Component
|
|
|
185
187
|
}
|
|
186
188
|
render() /*: React.Element<typeof ReactGridLayout>*/{
|
|
187
189
|
/* eslint-disable no-unused-vars */
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
190
|
+
const _this$props = this.props,
|
|
191
|
+
{
|
|
192
|
+
breakpoint,
|
|
193
|
+
breakpoints,
|
|
194
|
+
cols,
|
|
195
|
+
layouts,
|
|
196
|
+
margin,
|
|
197
|
+
containerPadding,
|
|
198
|
+
onBreakpointChange,
|
|
199
|
+
onLayoutChange,
|
|
200
|
+
onWidthChange
|
|
201
|
+
} = _this$props,
|
|
202
|
+
other = _objectWithoutProperties(_this$props, _excluded);
|
|
200
203
|
/* eslint-enable no-unused-vars */
|
|
201
204
|
|
|
202
205
|
return /*#__PURE__*/React.createElement(_ReactGridLayout.default, _extends({}, other, {
|
|
@@ -8,9 +8,12 @@ var React = _interopRequireWildcard(require("react"));
|
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
var _resizeObserverPolyfill = _interopRequireDefault(require("resize-observer-polyfill"));
|
|
10
10
|
var _clsx = _interopRequireDefault(require("clsx"));
|
|
11
|
+
const _excluded = ["measureBeforeMount"];
|
|
11
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
13
|
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); }
|
|
13
14
|
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); }
|
|
15
|
+
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; }
|
|
16
|
+
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; }
|
|
14
17
|
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; }
|
|
15
18
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
16
19
|
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); }
|
|
@@ -84,10 +87,11 @@ function WidthProvideRGL /*:: <Config>*/(ComposedComponent /*: React.AbstractCom
|
|
|
84
87
|
this.resizeObserver.disconnect();
|
|
85
88
|
}
|
|
86
89
|
render() {
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
90
|
+
const _this$props = this.props,
|
|
91
|
+
{
|
|
92
|
+
measureBeforeMount
|
|
93
|
+
} = _this$props,
|
|
94
|
+
rest = _objectWithoutProperties(_this$props, _excluded);
|
|
91
95
|
if (measureBeforeMount && !this.mounted) {
|
|
92
96
|
return /*#__PURE__*/React.createElement("div", {
|
|
93
97
|
className: (0, _clsx.default)(this.props.className, layoutClassName),
|
package/build/utils.js
CHANGED
|
@@ -35,6 +35,11 @@ exports.withLayoutItem = withLayoutItem;
|
|
|
35
35
|
var _fastEquals = require("fast-equals");
|
|
36
36
|
var _react = _interopRequireDefault(require("react"));
|
|
37
37
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
38
|
+
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; }
|
|
39
|
+
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; }
|
|
40
|
+
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; }
|
|
41
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
42
|
+
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); }
|
|
38
43
|
/*:: import type {
|
|
39
44
|
ChildrenArray as ReactChildrenArray,
|
|
40
45
|
Element as ReactElement
|
|
@@ -196,7 +201,7 @@ function cloneLayoutItem(layoutItem /*: LayoutItem*/) /*: LayoutItem*/{
|
|
|
196
201
|
* This will catch differences in keys, order, and length.
|
|
197
202
|
*/
|
|
198
203
|
function childrenEqual(a /*: ReactChildren*/, b /*: ReactChildren*/) /*: boolean*/{
|
|
199
|
-
return (0, _fastEquals.deepEqual)(_react.default.Children.map(a, c => c
|
|
204
|
+
return (0, _fastEquals.deepEqual)(_react.default.Children.map(a, c => c === null || c === void 0 ? void 0 : c.key), _react.default.Children.map(b, c => c === null || c === void 0 ? void 0 : c.key)) && (0, _fastEquals.deepEqual)(_react.default.Children.map(a, c => c === null || c === void 0 ? void 0 : c.props["data-grid"]), _react.default.Children.map(b, c => c === null || c === void 0 ? void 0 : c.props["data-grid"]));
|
|
200
205
|
}
|
|
201
206
|
|
|
202
207
|
/**
|
|
@@ -242,6 +247,8 @@ function collides(l1 /*: LayoutItem*/, l2 /*: LayoutItem*/) /*: boolean*/{
|
|
|
242
247
|
function compact(layout /*: Layout*/, compactType /*: CompactType*/, cols /*: number*/, allowOverlap /*: ?boolean*/) /*: Layout*/{
|
|
243
248
|
// Statics go in the compareWith array right away so items flow around them.
|
|
244
249
|
const compareWith = getStatics(layout);
|
|
250
|
+
// We keep track of the bottom position.
|
|
251
|
+
let b = bottom(compareWith);
|
|
245
252
|
// We go through the items by row and column.
|
|
246
253
|
const sorted = sortLayoutItems(layout, compactType);
|
|
247
254
|
// Holding for new items.
|
|
@@ -251,7 +258,8 @@ function compact(layout /*: Layout*/, compactType /*: CompactType*/, cols /*: nu
|
|
|
251
258
|
|
|
252
259
|
// Don't move static elements
|
|
253
260
|
if (!l.static) {
|
|
254
|
-
l = compactItem(compareWith, l, compactType, cols, sorted, allowOverlap);
|
|
261
|
+
l = compactItem(compareWith, l, compactType, cols, sorted, allowOverlap, b);
|
|
262
|
+
b = Math.max(b, l.y + l.h);
|
|
255
263
|
|
|
256
264
|
// Add to comparison array. We only collide with items before this one.
|
|
257
265
|
// Statics are already in this array.
|
|
@@ -302,14 +310,18 @@ function resolveCompactionCollision(layout /*: Layout*/, item /*: LayoutItem*/,
|
|
|
302
310
|
* Modifies item.
|
|
303
311
|
*
|
|
304
312
|
*/
|
|
305
|
-
function compactItem(compareWith /*: Layout*/, l /*: LayoutItem*/, compactType /*: CompactType*/, cols /*: number*/, fullLayout /*: Layout*/, allowOverlap /*: ?boolean*/) /*: LayoutItem*/{
|
|
313
|
+
function compactItem(compareWith /*: Layout*/, l /*: LayoutItem*/, compactType /*: CompactType*/, cols /*: number*/, fullLayout /*: Layout*/, allowOverlap /*: ?boolean*/, b /*: ?number*/) /*: LayoutItem*/{
|
|
306
314
|
const compactV = compactType === "vertical";
|
|
307
315
|
const compactH = compactType === "horizontal";
|
|
308
316
|
if (compactV) {
|
|
309
317
|
// Bottom 'y' possible is the bottom of the layout.
|
|
310
318
|
// This allows you to do nice stuff like specify {y: Infinity}
|
|
311
319
|
// This is here because the layout must be sorted in order to get the correct bottom `y`.
|
|
312
|
-
|
|
320
|
+
if (typeof b === "number") {
|
|
321
|
+
l.y = Math.min(b, l.y);
|
|
322
|
+
} else {
|
|
323
|
+
l.y = Math.min(bottom(compareWith), l.y);
|
|
324
|
+
}
|
|
313
325
|
// Move the element up as far as it can go without colliding.
|
|
314
326
|
while (l.y > 0 && !getFirstCollision(compareWith, l)) {
|
|
315
327
|
l.y--;
|
|
@@ -433,7 +445,7 @@ function moveElement(layout /*: Layout*/, l /*: LayoutItem*/, x /*: ?number*/, y
|
|
|
433
445
|
|
|
434
446
|
// Short-circuit if nothing to do.
|
|
435
447
|
if (l.y === y && l.x === x) return layout;
|
|
436
|
-
log(
|
|
448
|
+
log("Moving element ".concat(l.i, " to [").concat(String(x), ",").concat(String(y), "] from [").concat(l.x, ",").concat(l.y, "]"));
|
|
437
449
|
const oldX = l.x;
|
|
438
450
|
const oldY = l.y;
|
|
439
451
|
|
|
@@ -463,7 +475,7 @@ function moveElement(layout /*: Layout*/, l /*: LayoutItem*/, x /*: ?number*/, y
|
|
|
463
475
|
// If we are preventing collision but not allowing overlap, we need to
|
|
464
476
|
// revert the position of this element so it goes to where it came from, rather
|
|
465
477
|
// than the user's desired location.
|
|
466
|
-
log(
|
|
478
|
+
log("Collision prevented on ".concat(l.i, ", reverting."));
|
|
467
479
|
l.x = oldX;
|
|
468
480
|
l.y = oldY;
|
|
469
481
|
l.moved = false;
|
|
@@ -473,7 +485,7 @@ function moveElement(layout /*: Layout*/, l /*: LayoutItem*/, x /*: ?number*/, y
|
|
|
473
485
|
// Move each item that collides away from this element.
|
|
474
486
|
for (let i = 0, len = collisions.length; i < len; i++) {
|
|
475
487
|
const collision = collisions[i];
|
|
476
|
-
log(
|
|
488
|
+
log("Resolving collision between ".concat(l.i, " at [").concat(l.x, ",").concat(l.y, "] and ").concat(collision.i, " at [").concat(collision.x, ",").concat(collision.y, "]"));
|
|
477
489
|
|
|
478
490
|
// Short circuit so we can't infinite loop
|
|
479
491
|
if (collision.moved) continue;
|
|
@@ -523,10 +535,10 @@ function moveElementAwayFromCollision(layout /*: Layout*/, collidesWith /*: Layo
|
|
|
523
535
|
|
|
524
536
|
// No collision? If so, we can go up there; otherwise, we'll end up moving down as normal
|
|
525
537
|
if (!firstCollision) {
|
|
526
|
-
log(
|
|
538
|
+
log("Doing reverse collision on ".concat(itemToMove.i, " up to [").concat(fakeItem.x, ",").concat(fakeItem.y, "]."));
|
|
527
539
|
return moveElement(layout, itemToMove, compactH ? fakeItem.x : undefined, compactV ? fakeItem.y : undefined, isUserAction, preventCollision, compactType, cols);
|
|
528
540
|
} else if (collisionNorth && compactV) {
|
|
529
|
-
return moveElement(layout, itemToMove, undefined,
|
|
541
|
+
return moveElement(layout, itemToMove, undefined, itemToMove.y + 1, isUserAction, preventCollision, compactType, cols);
|
|
530
542
|
} else if (collisionNorth && compactType == null) {
|
|
531
543
|
collidesWith.y = itemToMove.y;
|
|
532
544
|
itemToMove.y = itemToMove.y + itemToMove.h;
|
|
@@ -650,10 +662,7 @@ function resizeItemInDirection(direction /*: ResizeHandleAxis*/, currentSize /*:
|
|
|
650
662
|
const ordinalHandler = ordinalResizeHandlerMap[direction];
|
|
651
663
|
// Shouldn't be possible given types; that said, don't fail hard
|
|
652
664
|
if (!ordinalHandler) return newSize;
|
|
653
|
-
return ordinalHandler(currentSize, {
|
|
654
|
-
...currentSize,
|
|
655
|
-
...newSize
|
|
656
|
-
}, containerWidth);
|
|
665
|
+
return ordinalHandler(currentSize, _objectSpread(_objectSpread({}, currentSize), newSize), containerWidth);
|
|
657
666
|
}
|
|
658
667
|
function setTransform(_ref5 /*:: */) /*: Object*/{
|
|
659
668
|
let {
|
|
@@ -663,15 +672,15 @@ function setTransform(_ref5 /*:: */) /*: Object*/{
|
|
|
663
672
|
height
|
|
664
673
|
} /*: Position*/ = _ref5 /*: Position*/;
|
|
665
674
|
// Replace unitless items with px
|
|
666
|
-
const translate =
|
|
675
|
+
const translate = "translate(".concat(left, "px,").concat(top, "px)");
|
|
667
676
|
return {
|
|
668
677
|
transform: translate,
|
|
669
678
|
WebkitTransform: translate,
|
|
670
679
|
MozTransform: translate,
|
|
671
680
|
msTransform: translate,
|
|
672
681
|
OTransform: translate,
|
|
673
|
-
width:
|
|
674
|
-
height:
|
|
682
|
+
width: "".concat(width, "px"),
|
|
683
|
+
height: "".concat(height, "px"),
|
|
675
684
|
position: "absolute"
|
|
676
685
|
};
|
|
677
686
|
}
|
|
@@ -683,10 +692,10 @@ function setTopLeft(_ref6 /*:: */) /*: Object*/{
|
|
|
683
692
|
height
|
|
684
693
|
} /*: Position*/ = _ref6 /*: Position*/;
|
|
685
694
|
return {
|
|
686
|
-
top:
|
|
687
|
-
left:
|
|
688
|
-
width:
|
|
689
|
-
height:
|
|
695
|
+
top: "".concat(top, "px"),
|
|
696
|
+
left: "".concat(left, "px"),
|
|
697
|
+
width: "".concat(width, "px"),
|
|
698
|
+
height: "".concat(height, "px"),
|
|
690
699
|
position: "absolute"
|
|
691
700
|
};
|
|
692
701
|
}
|
|
@@ -752,7 +761,7 @@ function synchronizeLayoutWithChildren(initialLayout /*: Layout*/, children /*:
|
|
|
752
761
|
const layout /*: LayoutItem[]*/ = [];
|
|
753
762
|
_react.default.Children.forEach(children, (child /*: ReactElement<any>*/) => {
|
|
754
763
|
// Child may not exist
|
|
755
|
-
if (child
|
|
764
|
+
if ((child === null || child === void 0 ? void 0 : child.key) == null) return;
|
|
756
765
|
const exists = getLayoutItem(initialLayout, String(child.key));
|
|
757
766
|
const g = child.props["data-grid"];
|
|
758
767
|
// Don't overwrite the layout item if it's already in the initial layout.
|
|
@@ -766,10 +775,9 @@ function synchronizeLayoutWithChildren(initialLayout /*: Layout*/, children /*:
|
|
|
766
775
|
validateLayout([g], "ReactGridLayout.children");
|
|
767
776
|
}
|
|
768
777
|
// FIXME clone not really necessary here
|
|
769
|
-
layout.push(cloneLayoutItem({
|
|
770
|
-
...g,
|
|
778
|
+
layout.push(cloneLayoutItem(_objectSpread(_objectSpread({}, g), {}, {
|
|
771
779
|
i: child.key
|
|
772
|
-
}));
|
|
780
|
+
})));
|
|
773
781
|
} else {
|
|
774
782
|
// Nothing provided: ensure this is added to the bottom
|
|
775
783
|
// FIXME clone not really necessary here
|
|
@@ -808,11 +816,11 @@ function validateLayout(layout /*: Layout*/) /*: void*/{
|
|
|
808
816
|
const key = subProps[j];
|
|
809
817
|
const value = item[key];
|
|
810
818
|
if (typeof value !== "number" || Number.isNaN(value)) {
|
|
811
|
-
throw new Error(
|
|
819
|
+
throw new Error("ReactGridLayout: ".concat(contextName, "[").concat(i, "].").concat(key, " must be a number! Received: ").concat(value, " (").concat(typeof value, ")"));
|
|
812
820
|
}
|
|
813
821
|
}
|
|
814
822
|
if (typeof item.i !== "undefined" && typeof item.i !== "string") {
|
|
815
|
-
throw new Error(
|
|
823
|
+
throw new Error("ReactGridLayout: ".concat(contextName, "[").concat(i, "].i must be a string! Received: ").concat(item.i, " (").concat(typeof item.i, ")"));
|
|
816
824
|
}
|
|
817
825
|
}
|
|
818
826
|
}
|