react-grid-layout 1.4.4 → 1.5.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/CHANGELOG.md +1 -1
- package/README.md +14 -16
- package/build/GridItem.js +26 -14
- package/build/ResponsiveReactGridLayout.js +1 -1
- package/build/calculateUtils.js +6 -9
- package/build/utils.js +7 -2
- 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 +30 -26
- package/lib/ResponsiveReactGridLayout.jsx +1 -1
- package/lib/calculateUtils.js +6 -10
- package/lib/utils.js +11 -8
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
### Bugfixes
|
|
6
6
|
|
|
7
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
|
|
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
9
|
- Various lint/dependency fixes.
|
|
10
10
|
|
|
11
11
|
## 1.4.3 (Nov 8, 2023)
|
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,7 +54,7 @@ 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)
|
|
@@ -301,13 +301,11 @@ draggableHandle: ?string = '',
|
|
|
301
301
|
// Compaction type.
|
|
302
302
|
compactType: ?('vertical' | 'horizontal' | null) = 'vertical';
|
|
303
303
|
|
|
304
|
-
// Layout is an array of
|
|
305
|
-
// {x: number, y: number, w: number, h: number}
|
|
304
|
+
// Layout is an array of objects with the format:
|
|
306
305
|
// The index into the layout must match the key used on each item component.
|
|
307
306
|
// If you choose to use custom keys, you can specify that key in the layout
|
|
308
|
-
// array objects
|
|
309
|
-
|
|
310
|
-
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
|
|
311
309
|
|
|
312
310
|
// Margin between items [x, y] in px.
|
|
313
311
|
margin: ?[number, number] = [10, 10],
|
package/build/GridItem.js
CHANGED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _reactDom = require("react-dom");
|
|
8
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
10
|
var _reactDraggable = require("react-draggable");
|
|
10
11
|
var _reactResizable = require("react-resizable");
|
|
@@ -166,8 +167,9 @@ class GridItem extends _react.default.Component /*:: <Props, State>*/{
|
|
|
166
167
|
* onDrag event handler
|
|
167
168
|
* @param {Event} e event data
|
|
168
169
|
* @param {Object} callbackData an object with node, delta and position information
|
|
170
|
+
* @param {boolean} dontFlush if true, will not call flushSync
|
|
169
171
|
*/
|
|
170
|
-
_defineProperty(this, "onDrag", (e, _ref2) => {
|
|
172
|
+
_defineProperty(this, "onDrag", (e, _ref2, dontFlush) => {
|
|
171
173
|
let {
|
|
172
174
|
node,
|
|
173
175
|
deltaX,
|
|
@@ -213,18 +215,25 @@ class GridItem extends _react.default.Component /*:: <Props, State>*/{
|
|
|
213
215
|
top,
|
|
214
216
|
left
|
|
215
217
|
};
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
218
|
+
|
|
219
|
+
// dontFlush is set if we're calling from inside
|
|
220
|
+
if (dontFlush) {
|
|
221
|
+
this.setState({
|
|
222
|
+
dragging: newPosition
|
|
223
|
+
});
|
|
224
|
+
} else {
|
|
225
|
+
(0, _reactDom.flushSync)(() => {
|
|
226
|
+
this.setState({
|
|
227
|
+
dragging: newPosition
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
}
|
|
219
231
|
|
|
220
232
|
// Call callback with this data
|
|
221
|
-
const {
|
|
222
|
-
containerPadding
|
|
223
|
-
} = this.props;
|
|
224
233
|
const {
|
|
225
234
|
x,
|
|
226
235
|
y
|
|
227
|
-
} = (0, _calculateUtils.calcXY)(positionParams, top
|
|
236
|
+
} = (0, _calculateUtils.calcXY)(positionParams, top, left, w, h);
|
|
228
237
|
return onDrag.call(this, i, x, y, {
|
|
229
238
|
e,
|
|
230
239
|
node,
|
|
@@ -250,8 +259,7 @@ class GridItem extends _react.default.Component /*:: <Props, State>*/{
|
|
|
250
259
|
const {
|
|
251
260
|
w,
|
|
252
261
|
h,
|
|
253
|
-
i
|
|
254
|
-
containerPadding
|
|
262
|
+
i
|
|
255
263
|
} = this.props;
|
|
256
264
|
const {
|
|
257
265
|
left,
|
|
@@ -267,7 +275,7 @@ class GridItem extends _react.default.Component /*:: <Props, State>*/{
|
|
|
267
275
|
const {
|
|
268
276
|
x,
|
|
269
277
|
y
|
|
270
|
-
} = (0, _calculateUtils.calcXY)(this.getPositionParams(), top
|
|
278
|
+
} = (0, _calculateUtils.calcXY)(this.getPositionParams(), top, left, w, h);
|
|
271
279
|
return onDragStop.call(this, i, x, y, {
|
|
272
280
|
e,
|
|
273
281
|
node,
|
|
@@ -333,9 +341,11 @@ class GridItem extends _react.default.Component /*:: <Props, State>*/{
|
|
|
333
341
|
node,
|
|
334
342
|
deltaX,
|
|
335
343
|
deltaY
|
|
336
|
-
}
|
|
344
|
+
}, true // dontFLush: avoid flushSync to temper warnings
|
|
345
|
+
);
|
|
337
346
|
}
|
|
338
347
|
}
|
|
348
|
+
|
|
339
349
|
getPositionParams() /*: PositionParams*/{
|
|
340
350
|
let props /*: Props*/ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.props;
|
|
341
351
|
return {
|
|
@@ -485,8 +495,10 @@ class GridItem extends _react.default.Component /*:: <Props, State>*/{
|
|
|
485
495
|
let updatedSize = size;
|
|
486
496
|
if (node) {
|
|
487
497
|
updatedSize = (0, _utils.resizeItemInDirection)(handle, position, size, containerWidth);
|
|
488
|
-
|
|
489
|
-
|
|
498
|
+
(0, _reactDom.flushSync)(() => {
|
|
499
|
+
this.setState({
|
|
500
|
+
resizing: handlerName === "onResizeStop" ? null : updatedSize
|
|
501
|
+
});
|
|
490
502
|
});
|
|
491
503
|
}
|
|
492
504
|
|
|
@@ -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);
|
package/build/utils.js
CHANGED
|
@@ -805,10 +805,15 @@ function validateLayout(layout /*: Layout*/) /*: void*/{
|
|
|
805
805
|
for (let i = 0, len = layout.length; i < len; i++) {
|
|
806
806
|
const item = layout[i];
|
|
807
807
|
for (let j = 0; j < subProps.length; j++) {
|
|
808
|
-
|
|
809
|
-
|
|
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})`);
|
|
810
812
|
}
|
|
811
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
|
+
}
|
|
812
817
|
}
|
|
813
818
|
}
|
|
814
819
|
|