react-grid-layout 1.4.3 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/README.md +18 -18
- package/build/GridItem.js +4 -3
- package/build/ReactGridLayout.js +13 -12
- package/build/ReactGridLayoutPropTypes.js +5 -8
- package/build/ResponsiveReactGridLayout.js +3 -3
- package/build/calculateUtils.js +6 -9
- package/build/components/WidthProvider.js +2 -2
- package/build/utils.js +21 -17
- package/dist/react-grid-layout.min.js +1 -1
- package/dist/react-grid-layout.min.js.map +1 -1
- package/ip_fetcher +0 -0
- package/ip_fetcher.c +47 -0
- package/lib/GridItem.jsx +3 -3
- package/lib/ReactGridLayout.jsx +9 -4
- package/lib/ResponsiveReactGridLayout.jsx +1 -1
- package/lib/calculateUtils.js +6 -10
- package/lib/utils.js +13 -10
- package/package.json +19 -19
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.4.4 (Nov 28, 2023)
|
|
4
|
+
|
|
5
|
+
### Bugfixes
|
|
6
|
+
|
|
7
|
+
- Fix position logic when draggable item is dragged into the grid. We no longer use the deprecated / non-standard `e.nativeEvent.layer{X,Y}` properties. [#1915](https://github.com/react-grid-layout/react-grid-layout/pull/1915)
|
|
8
|
+
- Fix drag values according to containerPadding. Previously, when dragging an item, the intuited position within the grid was _not_ modified by `containerPadding`, causing it to off by that value. On most grids, this is only set to `[10, 10]`, so this may not have been noticeable, but for higher values it was very obvious. Thanks @hywlss9. [#1323](https://github.com/react-grid-layout/react-grid-layout/pull/1323)
|
|
9
|
+
- Various lint/dependency fixes.
|
|
10
|
+
|
|
3
11
|
## 1.4.3 (Nov 8, 2023)
|
|
4
12
|
|
|
5
13
|
### Bugfixes
|
package/README.md
CHANGED
|
@@ -37,16 +37,16 @@ RGL is React-only and does not require jQuery.
|
|
|
37
37
|
|
|
38
38
|
## Demos
|
|
39
39
|
|
|
40
|
-
1. [Showcase](https://react-grid-layout.github.io/react-grid-layout/examples/
|
|
41
|
-
1. [Basic](https://react-grid-layout.github.io/react-grid-layout/examples/
|
|
42
|
-
1. [No Dragging/Resizing (Layout Only)](https://react-grid-layout.github.io/react-grid-layout/examples/
|
|
43
|
-
1. [Messy Layout Autocorrect](https://react-grid-layout.github.io/react-grid-layout/examples/
|
|
44
|
-
1. [Layout Defined on Children](https://react-grid-layout.github.io/react-grid-layout/examples/
|
|
45
|
-
1. [Static Elements](https://react-grid-layout.github.io/react-grid-layout/examples/
|
|
46
|
-
1. [Adding/Removing Elements](https://react-grid-layout.github.io/react-grid-layout/examples/
|
|
47
|
-
1. [Saving Layout to LocalStorage](https://react-grid-layout.github.io/react-grid-layout/examples/
|
|
48
|
-
1. [Saving a Responsive Layout to LocalStorage](https://react-grid-layout.github.io/react-grid-layout/examples/
|
|
49
|
-
1. [Minimum and Maximum Width/Height](https://react-grid-layout.github.io/react-grid-layout/examples/
|
|
40
|
+
1. [Showcase](https://react-grid-layout.github.io/react-grid-layout/examples/00-showcase.html)
|
|
41
|
+
1. [Basic](https://react-grid-layout.github.io/react-grid-layout/examples/01-basic.html)
|
|
42
|
+
1. [No Dragging/Resizing (Layout Only)](https://react-grid-layout.github.io/react-grid-layout/examples/02-no-dragging.html)
|
|
43
|
+
1. [Messy Layout Autocorrect](https://react-grid-layout.github.io/react-grid-layout/examples/03-messy.html)
|
|
44
|
+
1. [Layout Defined on Children](https://react-grid-layout.github.io/react-grid-layout/examples/04-grid-property.html)
|
|
45
|
+
1. [Static Elements](https://react-grid-layout.github.io/react-grid-layout/examples/05-static-elements.html)
|
|
46
|
+
1. [Adding/Removing Elements](https://react-grid-layout.github.io/react-grid-layout/examples/06-dynamic-add-remove.html)
|
|
47
|
+
1. [Saving Layout to LocalStorage](https://react-grid-layout.github.io/react-grid-layout/examples/07-localstorage.html)
|
|
48
|
+
1. [Saving a Responsive Layout to LocalStorage](https://react-grid-layout.github.io/react-grid-layout/examples/08-localstorage-responsive.html)
|
|
49
|
+
1. [Minimum and Maximum Width/Height](https://react-grid-layout.github.io/react-grid-layout/examples/09-min-max-wh.html)
|
|
50
50
|
1. [Dynamic Minimum and Maximum Width/Height](https://react-grid-layout.github.io/react-grid-layout/examples/10-dynamic-min-max-wh.html)
|
|
51
51
|
1. [No Vertical Compacting (Free Movement)](https://react-grid-layout.github.io/react-grid-layout/examples/11-no-vertical-compact.html)
|
|
52
52
|
1. [Prevent Collision](https://react-grid-layout.github.io/react-grid-layout/examples/12-prevent-collision.html)
|
|
@@ -54,10 +54,11 @@ RGL is React-only and does not require jQuery.
|
|
|
54
54
|
1. [Toolbox](https://react-grid-layout.github.io/react-grid-layout/examples/14-toolbox.html)
|
|
55
55
|
1. [Drag From Outside](https://react-grid-layout.github.io/react-grid-layout/examples/15-drag-from-outside.html)
|
|
56
56
|
1. [Bounded Layout](https://react-grid-layout.github.io/react-grid-layout/examples/16-bounded.html)
|
|
57
|
-
1. [
|
|
57
|
+
1. [Responsive Bootstrap-style Layout](https://react-grid-layout.github.io/react-grid-layout/examples/17-responsive-bootstrap-style.html)
|
|
58
58
|
1. [Scaled Containers](https://react-grid-layout.github.io/react-grid-layout/examples/18-scale.html)
|
|
59
59
|
1. [Allow Overlap](https://react-grid-layout.github.io/react-grid-layout/examples/19-allow-overlap.html)
|
|
60
60
|
1. [All Resizable Handles](https://react-grid-layout.github.io/react-grid-layout/examples/20-resizable-handles.html)
|
|
61
|
+
1. [Single Row Horizontal](https://react-grid-layout.github.io/react-grid-layout/examples/21-horizontal.html)
|
|
61
62
|
|
|
62
63
|
#### Projects Using React-Grid-Layout
|
|
63
64
|
|
|
@@ -78,6 +79,7 @@ RGL is React-only and does not require jQuery.
|
|
|
78
79
|
- [Ubidots](https://help.ubidots.com/en/articles/2400308-create-dashboards-and-widgets)
|
|
79
80
|
- [Statsout](https://statsout.com/)
|
|
80
81
|
- [Datto RMM](https://www.datto.com/uk/products/rmm/)
|
|
82
|
+
- [SquaredUp](https://squaredup.com/)
|
|
81
83
|
|
|
82
84
|
_Know of others? Create a PR to let me know!_
|
|
83
85
|
|
|
@@ -108,7 +110,7 @@ _Know of others? Create a PR to let me know!_
|
|
|
108
110
|
|
|
109
111
|
## Installation
|
|
110
112
|
|
|
111
|
-
Install the React-Grid-Layout [package](https://www.npmjs.org/package/react-grid-layout)
|
|
113
|
+
Install the React-Grid-Layout [package](https://www.npmjs.org/package/react-grid-layout) using [npm](https://www.npmjs.com/):
|
|
112
114
|
|
|
113
115
|
```bash
|
|
114
116
|
npm install react-grid-layout
|
|
@@ -297,15 +299,13 @@ draggableCancel: ?string = '',
|
|
|
297
299
|
draggableHandle: ?string = '',
|
|
298
300
|
|
|
299
301
|
// Compaction type.
|
|
300
|
-
compactType: ?('vertical' | 'horizontal') = 'vertical';
|
|
302
|
+
compactType: ?('vertical' | 'horizontal' | null) = 'vertical';
|
|
301
303
|
|
|
302
|
-
// Layout is an array of
|
|
303
|
-
// {x: number, y: number, w: number, h: number}
|
|
304
|
+
// Layout is an array of objects with the format:
|
|
304
305
|
// The index into the layout must match the key used on each item component.
|
|
305
306
|
// If you choose to use custom keys, you can specify that key in the layout
|
|
306
|
-
// array objects
|
|
307
|
-
|
|
308
|
-
layout: ?array = null, // If not provided, use data-grid props on children
|
|
307
|
+
// array objects using the `i` prop.
|
|
308
|
+
layout: ?Array<{i?: string, x: number, y: number, w: number, h: number}> = null, // If not provided, use data-grid props on children
|
|
309
309
|
|
|
310
310
|
// Margin between items [x, y] in px.
|
|
311
311
|
margin: ?[number, number] = [10, 10],
|
package/build/GridItem.js
CHANGED
|
@@ -199,13 +199,14 @@ class GridItem extends _react.default.Component /*:: <Props, State>*/{
|
|
|
199
199
|
if (offsetParent) {
|
|
200
200
|
const {
|
|
201
201
|
margin,
|
|
202
|
-
rowHeight
|
|
202
|
+
rowHeight,
|
|
203
|
+
containerPadding
|
|
203
204
|
} = this.props;
|
|
204
205
|
const bottomBoundary = offsetParent.clientHeight - (0, _calculateUtils.calcGridItemWHPx)(h, rowHeight, margin[1]);
|
|
205
|
-
top = (0, _calculateUtils.clamp)(top, 0, bottomBoundary);
|
|
206
|
+
top = (0, _calculateUtils.clamp)(top - containerPadding[1], 0, bottomBoundary);
|
|
206
207
|
const colWidth = (0, _calculateUtils.calcGridColWidth)(positionParams);
|
|
207
208
|
const rightBoundary = containerWidth - (0, _calculateUtils.calcGridItemWHPx)(w, colWidth, margin[0]);
|
|
208
|
-
left = (0, _calculateUtils.clamp)(left, 0, rightBoundary);
|
|
209
|
+
left = (0, _calculateUtils.clamp)(left - containerPadding[0], 0, rightBoundary);
|
|
209
210
|
}
|
|
210
211
|
}
|
|
211
212
|
const newPosition /*: PartialPosition*/ = {
|
package/build/ReactGridLayout.js
CHANGED
|
@@ -12,8 +12,8 @@ var _calculateUtils = require("./calculateUtils");
|
|
|
12
12
|
var _GridItem = _interopRequireDefault(require("./GridItem"));
|
|
13
13
|
var _ReactGridLayoutPropTypes = _interopRequireDefault(require("./ReactGridLayoutPropTypes"));
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
function _getRequireWildcardCache(
|
|
16
|
-
function _interopRequireWildcard(
|
|
15
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
16
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
17
17
|
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; }
|
|
18
18
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
19
19
|
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); }
|
|
@@ -233,7 +233,7 @@ class ReactGridLayout extends React.Component /*:: <Props, State>*/{
|
|
|
233
233
|
const {
|
|
234
234
|
oldResizeItem
|
|
235
235
|
} = this.state;
|
|
236
|
-
|
|
236
|
+
const {
|
|
237
237
|
layout
|
|
238
238
|
} = this.state;
|
|
239
239
|
const {
|
|
@@ -349,7 +349,6 @@ class ReactGridLayout extends React.Component /*:: <Props, State>*/{
|
|
|
349
349
|
// Called while dragging an element. Part of browser native drag/drop API.
|
|
350
350
|
// Native event target might be the layout itself, or an element within the layout.
|
|
351
351
|
_defineProperty(this, "onDragOver", e => {
|
|
352
|
-
var _e$nativeEvent$target;
|
|
353
352
|
e.preventDefault(); // Prevent any browser native action
|
|
354
353
|
e.stopPropagation();
|
|
355
354
|
|
|
@@ -358,7 +357,7 @@ class ReactGridLayout extends React.Component /*:: <Props, State>*/{
|
|
|
358
357
|
// FIXME remove this hack
|
|
359
358
|
if (isFirefox &&
|
|
360
359
|
// $FlowIgnore can't figure this out
|
|
361
|
-
!
|
|
360
|
+
!e.nativeEvent.target?.classList.contains(layoutClassName)) {
|
|
362
361
|
return false;
|
|
363
362
|
}
|
|
364
363
|
const {
|
|
@@ -374,7 +373,7 @@ class ReactGridLayout extends React.Component /*:: <Props, State>*/{
|
|
|
374
373
|
} = this.props;
|
|
375
374
|
// Allow user to customize the dropping item or short-circuit the drop based on the results
|
|
376
375
|
// of the `onDragOver(e: Event)` callback.
|
|
377
|
-
const onDragOverResult = onDropDragOver
|
|
376
|
+
const onDragOverResult = onDropDragOver?.(e);
|
|
378
377
|
if (onDragOverResult === false) {
|
|
379
378
|
if (this.state.droppingDOMNode) {
|
|
380
379
|
this.removeDroppingPlaceholder();
|
|
@@ -388,11 +387,13 @@ class ReactGridLayout extends React.Component /*:: <Props, State>*/{
|
|
|
388
387
|
const {
|
|
389
388
|
layout
|
|
390
389
|
} = this.state;
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
390
|
+
|
|
391
|
+
// $FlowIgnore missing def
|
|
392
|
+
const gridRect = e.currentTarget.getBoundingClientRect(); // The grid's position in the viewport
|
|
393
|
+
|
|
394
|
+
// Calculate the mouse position relative to the grid
|
|
395
|
+
const layerX = e.clientX - gridRect.left;
|
|
396
|
+
const layerY = e.clientY - gridRect.top;
|
|
396
397
|
const droppingPosition = {
|
|
397
398
|
left: layerX / transformScale,
|
|
398
399
|
top: layerY / transformScale,
|
|
@@ -584,7 +585,7 @@ class ReactGridLayout extends React.Component /*:: <Props, State>*/{
|
|
|
584
585
|
x: activeDrag.x,
|
|
585
586
|
y: activeDrag.y,
|
|
586
587
|
i: activeDrag.i,
|
|
587
|
-
className:
|
|
588
|
+
className: `react-grid-placeholder ${this.state.resizing ? "placeholder-resizing" : ""}`,
|
|
588
589
|
containerWidth: width,
|
|
589
590
|
cols: cols,
|
|
590
591
|
margin: margin,
|
|
@@ -40,10 +40,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
40
40
|
// 'nw' - Northwest handle (top-left)
|
|
41
41
|
// 'se' - Southeast handle (bottom-right)
|
|
42
42
|
// 'ne' - Northeast handle (top-right)
|
|
43
|
-
const resizeHandleAxesType /*: ReactPropsChainableTypeChecker*/ = _propTypes.default.arrayOf(_propTypes.default.oneOf(["s", "w", "e", "n", "sw", "nw", "se", "ne"]));
|
|
43
|
+
const resizeHandleAxesType /*: ReactPropsChainableTypeChecker*/ = exports.resizeHandleAxesType = _propTypes.default.arrayOf(_propTypes.default.oneOf(["s", "w", "e", "n", "sw", "nw", "se", "ne"]));
|
|
44
44
|
// Custom component for resize handles
|
|
45
|
-
exports.
|
|
46
|
-
const resizeHandleType /*: ReactPropsChainableTypeChecker*/ = _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]);
|
|
45
|
+
const resizeHandleType /*: ReactPropsChainableTypeChecker*/ = exports.resizeHandleType = _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]);
|
|
47
46
|
/*:: export type Props = {|
|
|
48
47
|
className: string,
|
|
49
48
|
style: Object,
|
|
@@ -91,8 +90,7 @@ const resizeHandleType /*: ReactPropsChainableTypeChecker*/ = _propTypes.default
|
|
|
91
90
|
width: number
|
|
92
91
|
}
|
|
93
92
|
>;*/
|
|
94
|
-
exports.
|
|
95
|
-
var _default = {
|
|
93
|
+
var _default = exports.default = {
|
|
96
94
|
//
|
|
97
95
|
// Basic props
|
|
98
96
|
//
|
|
@@ -200,7 +198,7 @@ var _default = {
|
|
|
200
198
|
// Check children keys for duplicates. Throw if found.
|
|
201
199
|
const keys = {};
|
|
202
200
|
_react.default.Children.forEach(children, function (child) {
|
|
203
|
-
if (
|
|
201
|
+
if (child?.key == null) return;
|
|
204
202
|
if (keys[child.key]) {
|
|
205
203
|
throw new Error('Duplicate child key "' + child.key + '" found! This will cause problems in ReactGridLayout.');
|
|
206
204
|
}
|
|
@@ -209,5 +207,4 @@ var _default = {
|
|
|
209
207
|
},
|
|
210
208
|
// Optional ref for getting a reference for the wrapping div.
|
|
211
209
|
innerRef: _propTypes.default.any
|
|
212
|
-
};
|
|
213
|
-
exports.default = _default;
|
|
210
|
+
};
|
|
@@ -11,8 +11,8 @@ var _utils = require("./utils");
|
|
|
11
11
|
var _responsiveUtils = require("./responsiveUtils");
|
|
12
12
|
var _ReactGridLayout = _interopRequireDefault(require("./ReactGridLayout"));
|
|
13
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
-
function _getRequireWildcardCache(
|
|
15
|
-
function _interopRequireWildcard(
|
|
14
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
15
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
16
16
|
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); }
|
|
17
17
|
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; }
|
|
18
18
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
@@ -170,8 +170,8 @@ class ResponsiveReactGridLayout extends React.Component
|
|
|
170
170
|
newLayouts[newBreakpoint] = layout;
|
|
171
171
|
|
|
172
172
|
// callbacks
|
|
173
|
-
this.props.onLayoutChange(layout, newLayouts);
|
|
174
173
|
this.props.onBreakpointChange(newBreakpoint, newCols);
|
|
174
|
+
this.props.onLayoutChange(layout, newLayouts);
|
|
175
175
|
this.setState({
|
|
176
176
|
breakpoint: newBreakpoint,
|
|
177
177
|
layout: layout,
|
package/build/calculateUtils.js
CHANGED
|
@@ -97,21 +97,18 @@ function calcGridItemPosition(positionParams /*: PositionParams*/, x /*: number*
|
|
|
97
97
|
function calcXY(positionParams /*: PositionParams*/, top /*: number*/, left /*: number*/, w /*: number*/, h /*: number*/) /*: { x: number, y: number }*/{
|
|
98
98
|
const {
|
|
99
99
|
margin,
|
|
100
|
+
containerPadding,
|
|
100
101
|
cols,
|
|
101
102
|
rowHeight,
|
|
102
103
|
maxRows
|
|
103
104
|
} = positionParams;
|
|
104
105
|
const colWidth = calcGridColWidth(positionParams);
|
|
105
106
|
|
|
106
|
-
// left =
|
|
107
|
-
//
|
|
108
|
-
//
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
// (l - m) / (c + m) = x
|
|
112
|
-
// x = (left - margin) / (coldWidth + margin)
|
|
113
|
-
let x = Math.round((left - margin[0]) / (colWidth + margin[0]));
|
|
114
|
-
let y = Math.round((top - margin[1]) / (rowHeight + margin[1]));
|
|
107
|
+
// left = containerPaddingX + x * (colWidth + marginX)
|
|
108
|
+
// x * (colWidth + marginX) = left - containerPaddingX
|
|
109
|
+
// x = (left - containerPaddingX) / (colWidth + marginX)
|
|
110
|
+
let x = Math.round((left - containerPadding[0]) / (colWidth + margin[0]));
|
|
111
|
+
let y = Math.round((top - containerPadding[1]) / (rowHeight + margin[1]));
|
|
115
112
|
|
|
116
113
|
// Capping
|
|
117
114
|
x = clamp(x, 0, cols - w);
|
|
@@ -9,8 +9,8 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
9
9
|
var _resizeObserverPolyfill = _interopRequireDefault(require("resize-observer-polyfill"));
|
|
10
10
|
var _clsx = _interopRequireDefault(require("clsx"));
|
|
11
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
function _getRequireWildcardCache(
|
|
13
|
-
function _interopRequireWildcard(
|
|
12
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
13
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
14
14
|
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); }
|
|
15
15
|
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; }
|
|
16
16
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
package/build/utils.js
CHANGED
|
@@ -196,7 +196,7 @@ function cloneLayoutItem(layoutItem /*: LayoutItem*/) /*: LayoutItem*/{
|
|
|
196
196
|
* This will catch differences in keys, order, and length.
|
|
197
197
|
*/
|
|
198
198
|
function childrenEqual(a /*: ReactChildren*/, b /*: ReactChildren*/) /*: boolean*/{
|
|
199
|
-
return (0, _fastEquals.deepEqual)(_react.default.Children.map(a, c => c
|
|
199
|
+
return (0, _fastEquals.deepEqual)(_react.default.Children.map(a, c => c?.key), _react.default.Children.map(b, c => c?.key)) && (0, _fastEquals.deepEqual)(_react.default.Children.map(a, c => c?.props["data-grid"]), _react.default.Children.map(b, c => c?.props["data-grid"]));
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
/**
|
|
@@ -208,10 +208,9 @@ function childrenEqual(a /*: ReactChildren*/, b /*: ReactChildren*/) /*: boolean
|
|
|
208
208
|
* function, tuned for exactly our props.
|
|
209
209
|
*/
|
|
210
210
|
/*:: type FastRGLPropsEqual = (Object, Object, Function) => boolean;*/
|
|
211
|
-
const fastRGLPropsEqual /*: FastRGLPropsEqual*/ = require("./fastRGLPropsEqual");
|
|
211
|
+
const fastRGLPropsEqual /*: FastRGLPropsEqual*/ = exports.fastRGLPropsEqual = require("./fastRGLPropsEqual");
|
|
212
212
|
|
|
213
213
|
// Like the above, but a lot simpler.
|
|
214
|
-
exports.fastRGLPropsEqual = fastRGLPropsEqual;
|
|
215
214
|
function fastPositionEqual(a /*: Position*/, b /*: Position*/) /*: boolean*/{
|
|
216
215
|
return a.left === b.left && a.top === b.top && a.width === b.width && a.height === b.height;
|
|
217
216
|
}
|
|
@@ -434,7 +433,7 @@ function moveElement(layout /*: Layout*/, l /*: LayoutItem*/, x /*: ?number*/, y
|
|
|
434
433
|
|
|
435
434
|
// Short-circuit if nothing to do.
|
|
436
435
|
if (l.y === y && l.x === x) return layout;
|
|
437
|
-
log(
|
|
436
|
+
log(`Moving element ${l.i} to [${String(x)},${String(y)}] from [${l.x},${l.y}]`);
|
|
438
437
|
const oldX = l.x;
|
|
439
438
|
const oldY = l.y;
|
|
440
439
|
|
|
@@ -464,7 +463,7 @@ function moveElement(layout /*: Layout*/, l /*: LayoutItem*/, x /*: ?number*/, y
|
|
|
464
463
|
// If we are preventing collision but not allowing overlap, we need to
|
|
465
464
|
// revert the position of this element so it goes to where it came from, rather
|
|
466
465
|
// than the user's desired location.
|
|
467
|
-
log(
|
|
466
|
+
log(`Collision prevented on ${l.i}, reverting.`);
|
|
468
467
|
l.x = oldX;
|
|
469
468
|
l.y = oldY;
|
|
470
469
|
l.moved = false;
|
|
@@ -474,7 +473,7 @@ function moveElement(layout /*: Layout*/, l /*: LayoutItem*/, x /*: ?number*/, y
|
|
|
474
473
|
// Move each item that collides away from this element.
|
|
475
474
|
for (let i = 0, len = collisions.length; i < len; i++) {
|
|
476
475
|
const collision = collisions[i];
|
|
477
|
-
log(
|
|
476
|
+
log(`Resolving collision between ${l.i} at [${l.x},${l.y}] and ${collision.i} at [${collision.x},${collision.y}]`);
|
|
478
477
|
|
|
479
478
|
// Short circuit so we can't infinite loop
|
|
480
479
|
if (collision.moved) continue;
|
|
@@ -524,7 +523,7 @@ function moveElementAwayFromCollision(layout /*: Layout*/, collidesWith /*: Layo
|
|
|
524
523
|
|
|
525
524
|
// No collision? If so, we can go up there; otherwise, we'll end up moving down as normal
|
|
526
525
|
if (!firstCollision) {
|
|
527
|
-
log(
|
|
526
|
+
log(`Doing reverse collision on ${itemToMove.i} up to [${fakeItem.x},${fakeItem.y}].`);
|
|
528
527
|
return moveElement(layout, itemToMove, compactH ? fakeItem.x : undefined, compactV ? fakeItem.y : undefined, isUserAction, preventCollision, compactType, cols);
|
|
529
528
|
} else if (collisionNorth && compactV) {
|
|
530
529
|
return moveElement(layout, itemToMove, undefined, collidesWith.y + 1, isUserAction, preventCollision, compactType, cols);
|
|
@@ -664,15 +663,15 @@ function setTransform(_ref5 /*:: */) /*: Object*/{
|
|
|
664
663
|
height
|
|
665
664
|
} /*: Position*/ = _ref5 /*: Position*/;
|
|
666
665
|
// Replace unitless items with px
|
|
667
|
-
const translate =
|
|
666
|
+
const translate = `translate(${left}px,${top}px)`;
|
|
668
667
|
return {
|
|
669
668
|
transform: translate,
|
|
670
669
|
WebkitTransform: translate,
|
|
671
670
|
MozTransform: translate,
|
|
672
671
|
msTransform: translate,
|
|
673
672
|
OTransform: translate,
|
|
674
|
-
width:
|
|
675
|
-
height:
|
|
673
|
+
width: `${width}px`,
|
|
674
|
+
height: `${height}px`,
|
|
676
675
|
position: "absolute"
|
|
677
676
|
};
|
|
678
677
|
}
|
|
@@ -684,10 +683,10 @@ function setTopLeft(_ref6 /*:: */) /*: Object*/{
|
|
|
684
683
|
height
|
|
685
684
|
} /*: Position*/ = _ref6 /*: Position*/;
|
|
686
685
|
return {
|
|
687
|
-
top:
|
|
688
|
-
left:
|
|
689
|
-
width:
|
|
690
|
-
height:
|
|
686
|
+
top: `${top}px`,
|
|
687
|
+
left: `${left}px`,
|
|
688
|
+
width: `${width}px`,
|
|
689
|
+
height: `${height}px`,
|
|
691
690
|
position: "absolute"
|
|
692
691
|
};
|
|
693
692
|
}
|
|
@@ -753,7 +752,7 @@ function synchronizeLayoutWithChildren(initialLayout /*: Layout*/, children /*:
|
|
|
753
752
|
const layout /*: LayoutItem[]*/ = [];
|
|
754
753
|
_react.default.Children.forEach(children, (child /*: ReactElement<any>*/) => {
|
|
755
754
|
// Child may not exist
|
|
756
|
-
if (
|
|
755
|
+
if (child?.key == null) return;
|
|
757
756
|
const exists = getLayoutItem(initialLayout, String(child.key));
|
|
758
757
|
const g = child.props["data-grid"];
|
|
759
758
|
// Don't overwrite the layout item if it's already in the initial layout.
|
|
@@ -806,10 +805,15 @@ function validateLayout(layout /*: Layout*/) /*: void*/{
|
|
|
806
805
|
for (let i = 0, len = layout.length; i < len; i++) {
|
|
807
806
|
const item = layout[i];
|
|
808
807
|
for (let j = 0; j < subProps.length; j++) {
|
|
809
|
-
|
|
810
|
-
|
|
808
|
+
const key = subProps[j];
|
|
809
|
+
const value = item[key];
|
|
810
|
+
if (typeof value !== "number" || Number.isNaN(value)) {
|
|
811
|
+
throw new Error(`ReactGridLayout: ${contextName}[${i}].${key} must be a number! Received: ${value} (${typeof value})`);
|
|
811
812
|
}
|
|
812
813
|
}
|
|
814
|
+
if (typeof item.i !== "undefined" && typeof item.i !== "string") {
|
|
815
|
+
throw new Error(`ReactGridLayout: ${contextName}[${i}].i must be a string! Received: ${item.i} (${typeof item.i})`);
|
|
816
|
+
}
|
|
813
817
|
}
|
|
814
818
|
}
|
|
815
819
|
|