react-grid-layout 2.0.0 → 2.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/README.md +117 -28
- package/css/styles.css +0 -1
- package/dist/{ResponsiveGridLayout-D6lFRE3f.d.mts → ResponsiveGridLayout-BkHF9YHa.d.mts} +10 -1
- package/dist/{ResponsiveGridLayout-CH4s0tKj.d.ts → ResponsiveGridLayout-CLn16-X3.d.ts} +10 -1
- package/dist/{calculate-CwYDW8na.d.mts → calculate-DsVTldEE.d.ts} +30 -2
- package/dist/{calculate-mgLpNJ5O.d.ts → calculate-DwbL1D06.d.mts} +30 -2
- package/dist/chunk-526JND3R.mjs +3 -0
- package/dist/{chunk-ZWN22PS2.mjs.map → chunk-526JND3R.mjs.map} +1 -1
- package/dist/chunk-7ELO5FRW.js +4 -0
- package/dist/{chunk-PBQSHIID.js.map → chunk-7ELO5FRW.js.map} +1 -1
- package/dist/chunk-AWM66AWF.mjs +422 -0
- package/dist/chunk-AWM66AWF.mjs.map +1 -0
- package/dist/chunk-BJFPTW5Q.js +449 -0
- package/dist/chunk-BJFPTW5Q.js.map +1 -0
- package/dist/{chunk-4HNUMWQK.mjs → chunk-FLITZMQC.mjs} +198 -311
- package/dist/chunk-FLITZMQC.mjs.map +1 -0
- package/dist/{chunk-ZCXE6SR5.mjs → chunk-LIKX67MZ.mjs} +7 -5
- package/dist/chunk-LIKX67MZ.mjs.map +1 -0
- package/dist/{chunk-R35HZZTA.mjs → chunk-PLWMASMX.mjs} +208 -90
- package/dist/chunk-PLWMASMX.mjs.map +1 -0
- package/dist/{chunk-BFTKGAP3.js → chunk-RB2IKK5B.js} +260 -142
- package/dist/chunk-RB2IKK5B.js.map +1 -0
- package/dist/{chunk-3WO4SAYB.js → chunk-WWS3M5Y3.js} +238 -355
- package/dist/chunk-WWS3M5Y3.js.map +1 -0
- package/dist/{chunk-H5KMDLY3.js → chunk-YQQYHEEG.js} +43 -41
- package/dist/chunk-YQQYHEEG.js.map +1 -0
- package/dist/core.d.mts +159 -6
- package/dist/core.d.ts +159 -6
- package/dist/core.js +145 -85
- package/dist/core.mjs +3 -3
- package/dist/extras.d.mts +133 -3
- package/dist/extras.d.ts +133 -3
- package/dist/extras.js +373 -2
- package/dist/extras.js.map +1 -1
- package/dist/extras.mjs +367 -2
- package/dist/extras.mjs.map +1 -1
- package/dist/index.d.mts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +64 -64
- package/dist/index.mjs +5 -5
- package/dist/legacy.d.mts +2 -2
- package/dist/legacy.d.ts +2 -2
- package/dist/legacy.js +26 -25
- package/dist/legacy.js.map +1 -1
- package/dist/legacy.mjs +16 -15
- package/dist/legacy.mjs.map +1 -1
- package/dist/{position-Dk2b4ZMS.d.ts → position-CXNzFxI0.d.mts} +18 -7
- package/dist/{position-BmN1z36J.d.mts → position-Dk0FRWA9.d.ts} +18 -7
- package/dist/react.d.mts +11 -5
- package/dist/react.d.ts +11 -5
- package/dist/react.js +38 -38
- package/dist/react.mjs +5 -5
- package/dist/{responsive-CJxefsYw.d.mts → responsive-BB5d98xz.d.mts} +1 -1
- package/dist/{responsive-C4L1ESlm.d.ts → responsive-BXI-GCXG.d.ts} +1 -1
- package/dist/{types-Cxf4nHNr.d.mts → types-CokovIMH.d.mts} +98 -4
- package/dist/{types-Cxf4nHNr.d.ts → types-CokovIMH.d.ts} +98 -4
- package/index-dev.js +16 -0
- package/package.json +5 -3
- package/dist/chunk-2KUHNJXF.mjs +0 -90
- package/dist/chunk-2KUHNJXF.mjs.map +0 -1
- package/dist/chunk-3WO4SAYB.js.map +0 -1
- package/dist/chunk-4HNUMWQK.mjs.map +0 -1
- package/dist/chunk-BFTKGAP3.js.map +0 -1
- package/dist/chunk-F6NQPYKT.js +0 -98
- package/dist/chunk-F6NQPYKT.js.map +0 -1
- package/dist/chunk-H5KMDLY3.js.map +0 -1
- package/dist/chunk-PBQSHIID.js +0 -4
- package/dist/chunk-R35HZZTA.mjs.map +0 -1
- package/dist/chunk-ZCXE6SR5.mjs.map +0 -1
- package/dist/chunk-ZWN22PS2.mjs +0 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkWWS3M5Y3_js = require('./chunk-WWS3M5Y3.js');
|
|
4
|
+
var chunkBJFPTW5Q_js = require('./chunk-BJFPTW5Q.js');
|
|
5
5
|
var React2 = require('react');
|
|
6
6
|
var reactDraggable = require('react-draggable');
|
|
7
7
|
var reactResizable = require('react-resizable');
|
|
@@ -46,6 +46,9 @@ function GridItem(props) {
|
|
|
46
46
|
i,
|
|
47
47
|
resizeHandles,
|
|
48
48
|
resizeHandle,
|
|
49
|
+
constraints = chunkWWS3M5Y3_js.defaultConstraints,
|
|
50
|
+
layoutItem,
|
|
51
|
+
layout = [],
|
|
49
52
|
onDragStart: onDragStartProp,
|
|
50
53
|
onDrag: onDragProp,
|
|
51
54
|
onDragStop: onDragStopProp,
|
|
@@ -77,17 +80,44 @@ function GridItem(props) {
|
|
|
77
80
|
}),
|
|
78
81
|
[cols, containerPadding, containerWidth, margin, maxRows, rowHeight]
|
|
79
82
|
);
|
|
83
|
+
const constraintContext = React2.useMemo(
|
|
84
|
+
() => ({
|
|
85
|
+
cols,
|
|
86
|
+
maxRows,
|
|
87
|
+
containerWidth,
|
|
88
|
+
containerHeight: 0,
|
|
89
|
+
// Auto-height grids don't have a fixed container height
|
|
90
|
+
rowHeight,
|
|
91
|
+
margin,
|
|
92
|
+
layout
|
|
93
|
+
}),
|
|
94
|
+
[cols, maxRows, containerWidth, rowHeight, margin, layout]
|
|
95
|
+
);
|
|
96
|
+
const effectiveLayoutItem = React2.useMemo(
|
|
97
|
+
() => layoutItem ?? {
|
|
98
|
+
i,
|
|
99
|
+
x,
|
|
100
|
+
y,
|
|
101
|
+
w,
|
|
102
|
+
h,
|
|
103
|
+
minW,
|
|
104
|
+
maxW,
|
|
105
|
+
minH,
|
|
106
|
+
maxH
|
|
107
|
+
},
|
|
108
|
+
[layoutItem, i, x, y, w, h, minW, maxW, minH, maxH]
|
|
109
|
+
);
|
|
80
110
|
const createStyle = React2.useCallback(
|
|
81
111
|
(pos2) => {
|
|
82
112
|
if (useCSSTransforms) {
|
|
83
|
-
return
|
|
113
|
+
return chunkWWS3M5Y3_js.setTransform(pos2);
|
|
84
114
|
}
|
|
85
|
-
const styleObj =
|
|
115
|
+
const styleObj = chunkWWS3M5Y3_js.setTopLeft(pos2);
|
|
86
116
|
if (usePercentages) {
|
|
87
117
|
return {
|
|
88
118
|
...styleObj,
|
|
89
|
-
left:
|
|
90
|
-
width:
|
|
119
|
+
left: chunkWWS3M5Y3_js.perc(pos2.left / containerWidth),
|
|
120
|
+
width: chunkWWS3M5Y3_js.perc(pos2.width / containerWidth)
|
|
91
121
|
};
|
|
92
122
|
}
|
|
93
123
|
return styleObj;
|
|
@@ -111,12 +141,17 @@ function GridItem(props) {
|
|
|
111
141
|
};
|
|
112
142
|
dragPositionRef.current = newPosition;
|
|
113
143
|
setDragging(true);
|
|
114
|
-
const
|
|
144
|
+
const rawPos = chunkBJFPTW5Q_js.calcXYRaw(
|
|
115
145
|
positionParams,
|
|
116
146
|
newPosition.top,
|
|
117
|
-
newPosition.left
|
|
118
|
-
|
|
119
|
-
|
|
147
|
+
newPosition.left
|
|
148
|
+
);
|
|
149
|
+
const { x: newX, y: newY } = chunkWWS3M5Y3_js.applyPositionConstraints(
|
|
150
|
+
constraints,
|
|
151
|
+
effectiveLayoutItem,
|
|
152
|
+
rawPos.x,
|
|
153
|
+
rawPos.y,
|
|
154
|
+
constraintContext
|
|
120
155
|
);
|
|
121
156
|
onDragStartProp(i, newX, newY, {
|
|
122
157
|
e,
|
|
@@ -124,7 +159,15 @@ function GridItem(props) {
|
|
|
124
159
|
newPosition
|
|
125
160
|
});
|
|
126
161
|
},
|
|
127
|
-
[
|
|
162
|
+
[
|
|
163
|
+
onDragStartProp,
|
|
164
|
+
transformScale,
|
|
165
|
+
positionParams,
|
|
166
|
+
constraints,
|
|
167
|
+
effectiveLayoutItem,
|
|
168
|
+
constraintContext,
|
|
169
|
+
i
|
|
170
|
+
]
|
|
128
171
|
);
|
|
129
172
|
const onDrag = React2.useCallback(
|
|
130
173
|
(e, { node, deltaX, deltaY }) => {
|
|
@@ -134,16 +177,23 @@ function GridItem(props) {
|
|
|
134
177
|
if (isBounded) {
|
|
135
178
|
const { offsetParent } = node;
|
|
136
179
|
if (offsetParent) {
|
|
137
|
-
const bottomBoundary = offsetParent.clientHeight -
|
|
138
|
-
top =
|
|
139
|
-
const colWidth =
|
|
140
|
-
const rightBoundary = containerWidth -
|
|
141
|
-
left =
|
|
180
|
+
const bottomBoundary = offsetParent.clientHeight - chunkBJFPTW5Q_js.calcGridItemWHPx(h, rowHeight, margin[1]);
|
|
181
|
+
top = chunkBJFPTW5Q_js.clamp(top, 0, bottomBoundary);
|
|
182
|
+
const colWidth = chunkBJFPTW5Q_js.calcGridColWidth(positionParams);
|
|
183
|
+
const rightBoundary = containerWidth - chunkBJFPTW5Q_js.calcGridItemWHPx(w, colWidth, margin[0]);
|
|
184
|
+
left = chunkBJFPTW5Q_js.clamp(left, 0, rightBoundary);
|
|
142
185
|
}
|
|
143
186
|
}
|
|
144
187
|
const newPosition = { top, left };
|
|
145
188
|
dragPositionRef.current = newPosition;
|
|
146
|
-
const
|
|
189
|
+
const rawPos = chunkBJFPTW5Q_js.calcXYRaw(positionParams, top, left);
|
|
190
|
+
const { x: newX, y: newY } = chunkWWS3M5Y3_js.applyPositionConstraints(
|
|
191
|
+
constraints,
|
|
192
|
+
effectiveLayoutItem,
|
|
193
|
+
rawPos.x,
|
|
194
|
+
rawPos.y,
|
|
195
|
+
constraintContext
|
|
196
|
+
);
|
|
147
197
|
onDragProp(i, newX, newY, {
|
|
148
198
|
e,
|
|
149
199
|
node,
|
|
@@ -160,7 +210,10 @@ function GridItem(props) {
|
|
|
160
210
|
positionParams,
|
|
161
211
|
containerWidth,
|
|
162
212
|
w,
|
|
163
|
-
i
|
|
213
|
+
i,
|
|
214
|
+
constraints,
|
|
215
|
+
effectiveLayoutItem,
|
|
216
|
+
constraintContext
|
|
164
217
|
]
|
|
165
218
|
);
|
|
166
219
|
const onDragStop = React2.useCallback(
|
|
@@ -170,14 +223,29 @@ function GridItem(props) {
|
|
|
170
223
|
const newPosition = { top, left };
|
|
171
224
|
setDragging(false);
|
|
172
225
|
dragPositionRef.current = { left: 0, top: 0 };
|
|
173
|
-
const
|
|
226
|
+
const rawPos = chunkBJFPTW5Q_js.calcXYRaw(positionParams, top, left);
|
|
227
|
+
const { x: newX, y: newY } = chunkWWS3M5Y3_js.applyPositionConstraints(
|
|
228
|
+
constraints,
|
|
229
|
+
effectiveLayoutItem,
|
|
230
|
+
rawPos.x,
|
|
231
|
+
rawPos.y,
|
|
232
|
+
constraintContext
|
|
233
|
+
);
|
|
174
234
|
onDragStopProp(i, newX, newY, {
|
|
175
235
|
e,
|
|
176
236
|
node,
|
|
177
237
|
newPosition
|
|
178
238
|
});
|
|
179
239
|
},
|
|
180
|
-
[
|
|
240
|
+
[
|
|
241
|
+
onDragStopProp,
|
|
242
|
+
dragging,
|
|
243
|
+
positionParams,
|
|
244
|
+
constraints,
|
|
245
|
+
effectiveLayoutItem,
|
|
246
|
+
constraintContext,
|
|
247
|
+
i
|
|
248
|
+
]
|
|
181
249
|
);
|
|
182
250
|
const onResizeHandler = React2.useCallback(
|
|
183
251
|
(e, { node, size, handle: resizeHandle2 }, position, handlerName) => {
|
|
@@ -185,7 +253,7 @@ function GridItem(props) {
|
|
|
185
253
|
if (!handler) return;
|
|
186
254
|
let updatedSize;
|
|
187
255
|
if (node) {
|
|
188
|
-
updatedSize =
|
|
256
|
+
updatedSize = chunkWWS3M5Y3_js.resizeItemInDirection(
|
|
189
257
|
resizeHandle2,
|
|
190
258
|
position,
|
|
191
259
|
size,
|
|
@@ -199,16 +267,19 @@ function GridItem(props) {
|
|
|
199
267
|
};
|
|
200
268
|
}
|
|
201
269
|
resizePositionRef.current = updatedSize;
|
|
202
|
-
|
|
270
|
+
const rawSize = chunkBJFPTW5Q_js.calcWHRaw(
|
|
203
271
|
positionParams,
|
|
204
272
|
updatedSize.width,
|
|
205
|
-
updatedSize.height
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
273
|
+
updatedSize.height
|
|
274
|
+
);
|
|
275
|
+
const { w: newW, h: newH } = chunkWWS3M5Y3_js.applySizeConstraints(
|
|
276
|
+
constraints,
|
|
277
|
+
effectiveLayoutItem,
|
|
278
|
+
rawSize.w,
|
|
279
|
+
rawSize.h,
|
|
280
|
+
resizeHandle2,
|
|
281
|
+
constraintContext
|
|
209
282
|
);
|
|
210
|
-
newW = chunkF6NQPYKT_js.clamp(newW, Math.max(minW, 1), maxW);
|
|
211
|
-
newH = chunkF6NQPYKT_js.clamp(newH, minH, maxH);
|
|
212
283
|
handler(i, newW, newH, {
|
|
213
284
|
e: e.nativeEvent,
|
|
214
285
|
node,
|
|
@@ -224,17 +295,16 @@ function GridItem(props) {
|
|
|
224
295
|
positionParams,
|
|
225
296
|
x,
|
|
226
297
|
y,
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
i
|
|
298
|
+
i,
|
|
299
|
+
constraints,
|
|
300
|
+
effectiveLayoutItem,
|
|
301
|
+
constraintContext
|
|
232
302
|
]
|
|
233
303
|
);
|
|
234
304
|
const handleResizeStart = React2.useCallback(
|
|
235
305
|
(e, data) => {
|
|
236
306
|
setResizing(true);
|
|
237
|
-
const pos2 =
|
|
307
|
+
const pos2 = chunkBJFPTW5Q_js.calcGridItemPosition(positionParams, x, y, w, h);
|
|
238
308
|
const typedData = {
|
|
239
309
|
...data,
|
|
240
310
|
handle: data.handle
|
|
@@ -245,7 +315,7 @@ function GridItem(props) {
|
|
|
245
315
|
);
|
|
246
316
|
const handleResize = React2.useCallback(
|
|
247
317
|
(e, data) => {
|
|
248
|
-
const pos2 =
|
|
318
|
+
const pos2 = chunkBJFPTW5Q_js.calcGridItemPosition(positionParams, x, y, w, h);
|
|
249
319
|
const typedData = {
|
|
250
320
|
...data,
|
|
251
321
|
handle: data.handle
|
|
@@ -258,7 +328,7 @@ function GridItem(props) {
|
|
|
258
328
|
(e, data) => {
|
|
259
329
|
setResizing(false);
|
|
260
330
|
resizePositionRef.current = { top: 0, left: 0, width: 0, height: 0 };
|
|
261
|
-
const pos2 =
|
|
331
|
+
const pos2 = chunkBJFPTW5Q_js.calcGridItemPosition(positionParams, x, y, w, h);
|
|
262
332
|
const typedData = {
|
|
263
333
|
...data,
|
|
264
334
|
handle: data.handle
|
|
@@ -303,7 +373,7 @@ function GridItem(props) {
|
|
|
303
373
|
}
|
|
304
374
|
prevDroppingPositionRef.current = droppingPosition;
|
|
305
375
|
}, [droppingPosition, dragging, onDragStart, onDrag]);
|
|
306
|
-
const pos =
|
|
376
|
+
const pos = chunkBJFPTW5Q_js.calcGridItemPosition(
|
|
307
377
|
positionParams,
|
|
308
378
|
x,
|
|
309
379
|
y,
|
|
@@ -313,14 +383,12 @@ function GridItem(props) {
|
|
|
313
383
|
resizing ? resizePositionRef.current : null
|
|
314
384
|
);
|
|
315
385
|
const child = React2__default.default.Children.only(children);
|
|
316
|
-
const
|
|
317
|
-
const
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
const maxConstraints = [
|
|
321
|
-
Math.min(maxes.width, maxWidth),
|
|
322
|
-
Math.min(maxes.height, Infinity)
|
|
386
|
+
const minGridUnit = chunkBJFPTW5Q_js.calcGridItemPosition(positionParams, 0, 0, 1, 1);
|
|
387
|
+
const minConstraints = [
|
|
388
|
+
minGridUnit.width,
|
|
389
|
+
minGridUnit.height
|
|
323
390
|
];
|
|
391
|
+
const maxConstraints = [Infinity, Infinity];
|
|
324
392
|
const childProps = child.props;
|
|
325
393
|
const childClassName = childProps["className"];
|
|
326
394
|
const childStyle = childProps["style"];
|
|
@@ -403,7 +471,7 @@ function synchronizeLayoutWithChildren(initialLayout, children, cols, compactTyp
|
|
|
403
471
|
childKeys.add(key);
|
|
404
472
|
const existingItem = initialLayout.find((l) => l.i === key);
|
|
405
473
|
if (existingItem) {
|
|
406
|
-
layout.push(
|
|
474
|
+
layout.push(chunkBJFPTW5Q_js.cloneLayoutItem(existingItem));
|
|
407
475
|
} else {
|
|
408
476
|
const childProps = child.props;
|
|
409
477
|
const dataGrid = childProps["data-grid"];
|
|
@@ -428,15 +496,15 @@ function synchronizeLayoutWithChildren(initialLayout, children, cols, compactTyp
|
|
|
428
496
|
layout.push({
|
|
429
497
|
i: key,
|
|
430
498
|
x: 0,
|
|
431
|
-
y:
|
|
499
|
+
y: chunkBJFPTW5Q_js.bottom(layout),
|
|
432
500
|
w: 1,
|
|
433
501
|
h: 1
|
|
434
502
|
});
|
|
435
503
|
}
|
|
436
504
|
}
|
|
437
505
|
});
|
|
438
|
-
const corrected =
|
|
439
|
-
return
|
|
506
|
+
const corrected = chunkBJFPTW5Q_js.correctBounds(layout, { cols });
|
|
507
|
+
return chunkWWS3M5Y3_js.compact(corrected, compactType, cols, allowOverlap);
|
|
440
508
|
}
|
|
441
509
|
function GridLayout(props) {
|
|
442
510
|
const {
|
|
@@ -448,8 +516,9 @@ function GridLayout(props) {
|
|
|
448
516
|
dragConfig: dragConfigProp,
|
|
449
517
|
resizeConfig: resizeConfigProp,
|
|
450
518
|
dropConfig: dropConfigProp,
|
|
451
|
-
positionStrategy =
|
|
519
|
+
positionStrategy = chunkWWS3M5Y3_js.defaultPositionStrategy,
|
|
452
520
|
compactor: compactorProp,
|
|
521
|
+
constraints = chunkWWS3M5Y3_js.defaultConstraints,
|
|
453
522
|
// Layout data
|
|
454
523
|
layout: propsLayout = [],
|
|
455
524
|
droppingItem: droppingItemProp,
|
|
@@ -470,19 +539,19 @@ function GridLayout(props) {
|
|
|
470
539
|
onDropDragOver: onDropDragOverProp = noop
|
|
471
540
|
} = props;
|
|
472
541
|
const gridConfig = React2.useMemo(
|
|
473
|
-
() => ({ ...
|
|
542
|
+
() => ({ ...chunkWWS3M5Y3_js.defaultGridConfig, ...gridConfigProp }),
|
|
474
543
|
[gridConfigProp]
|
|
475
544
|
);
|
|
476
545
|
const dragConfig = React2.useMemo(
|
|
477
|
-
() => ({ ...
|
|
546
|
+
() => ({ ...chunkWWS3M5Y3_js.defaultDragConfig, ...dragConfigProp }),
|
|
478
547
|
[dragConfigProp]
|
|
479
548
|
);
|
|
480
549
|
const resizeConfig = React2.useMemo(
|
|
481
|
-
() => ({ ...
|
|
550
|
+
() => ({ ...chunkWWS3M5Y3_js.defaultResizeConfig, ...resizeConfigProp }),
|
|
482
551
|
[resizeConfigProp]
|
|
483
552
|
);
|
|
484
553
|
const dropConfig = React2.useMemo(
|
|
485
|
-
() => ({ ...
|
|
554
|
+
() => ({ ...chunkWWS3M5Y3_js.defaultDropConfig, ...dropConfigProp }),
|
|
486
555
|
[dropConfigProp]
|
|
487
556
|
);
|
|
488
557
|
const { cols, rowHeight, maxRows, margin, containerPadding } = gridConfig;
|
|
@@ -498,7 +567,7 @@ function GridLayout(props) {
|
|
|
498
567
|
handleComponent: resizeHandle
|
|
499
568
|
} = resizeConfig;
|
|
500
569
|
const { enabled: isDroppable, defaultItem: defaultDropItem } = dropConfig;
|
|
501
|
-
const compactor = compactorProp ??
|
|
570
|
+
const compactor = compactorProp ?? chunkWWS3M5Y3_js.getCompactor("vertical");
|
|
502
571
|
const compactType = compactor.type;
|
|
503
572
|
const allowOverlap = compactor.allowOverlap;
|
|
504
573
|
const preventCollision = compactor.preventCollision ?? false;
|
|
@@ -536,6 +605,8 @@ function GridLayout(props) {
|
|
|
536
605
|
const prevPropsLayoutRef = React2.useRef(propsLayout);
|
|
537
606
|
const prevChildrenRef = React2.useRef(children);
|
|
538
607
|
const prevCompactTypeRef = React2.useRef(compactType);
|
|
608
|
+
const layoutRef = React2.useRef(layout);
|
|
609
|
+
layoutRef.current = layout;
|
|
539
610
|
React2.useEffect(() => {
|
|
540
611
|
setMounted(true);
|
|
541
612
|
if (!fastEquals.deepEqual(layout, propsLayout)) {
|
|
@@ -544,6 +615,7 @@ function GridLayout(props) {
|
|
|
544
615
|
}, []);
|
|
545
616
|
React2.useEffect(() => {
|
|
546
617
|
if (activeDrag) return;
|
|
618
|
+
if (droppingDOMNode) return;
|
|
547
619
|
const layoutChanged = !fastEquals.deepEqual(propsLayout, prevPropsLayoutRef.current);
|
|
548
620
|
const childrenChanged = !childrenEqual(children, prevChildrenRef.current);
|
|
549
621
|
const compactTypeChanged = compactType !== prevCompactTypeRef.current;
|
|
@@ -568,6 +640,7 @@ function GridLayout(props) {
|
|
|
568
640
|
compactType,
|
|
569
641
|
allowOverlap,
|
|
570
642
|
activeDrag,
|
|
643
|
+
droppingDOMNode,
|
|
571
644
|
layout
|
|
572
645
|
]);
|
|
573
646
|
React2.useEffect(() => {
|
|
@@ -578,13 +651,14 @@ function GridLayout(props) {
|
|
|
578
651
|
}, [layout, activeDrag, onLayoutChange]);
|
|
579
652
|
const containerHeight = React2.useMemo(() => {
|
|
580
653
|
if (!autoSize) return void 0;
|
|
581
|
-
const nbRow =
|
|
654
|
+
const nbRow = chunkBJFPTW5Q_js.bottom(layout);
|
|
582
655
|
const containerPaddingY = effectiveContainerPadding[1];
|
|
583
656
|
return nbRow * rowHeight + (nbRow - 1) * margin[1] + containerPaddingY * 2 + "px";
|
|
584
657
|
}, [autoSize, layout, rowHeight, margin, effectiveContainerPadding]);
|
|
585
658
|
const onDragStart = React2.useCallback(
|
|
586
659
|
(i, _x, _y, data) => {
|
|
587
|
-
const
|
|
660
|
+
const currentLayout = layoutRef.current;
|
|
661
|
+
const l = chunkBJFPTW5Q_js.getLayoutItem(currentLayout, i);
|
|
588
662
|
if (!l) return;
|
|
589
663
|
const placeholder = {
|
|
590
664
|
w: l.w,
|
|
@@ -593,17 +667,18 @@ function GridLayout(props) {
|
|
|
593
667
|
y: l.y,
|
|
594
668
|
i
|
|
595
669
|
};
|
|
596
|
-
oldDragItemRef.current =
|
|
597
|
-
oldLayoutRef.current =
|
|
670
|
+
oldDragItemRef.current = chunkBJFPTW5Q_js.cloneLayoutItem(l);
|
|
671
|
+
oldLayoutRef.current = currentLayout;
|
|
598
672
|
setActiveDrag(placeholder);
|
|
599
|
-
onDragStartProp(
|
|
673
|
+
onDragStartProp(currentLayout, l, l, null, data.e, data.node);
|
|
600
674
|
},
|
|
601
|
-
[
|
|
675
|
+
[onDragStartProp]
|
|
602
676
|
);
|
|
603
677
|
const onDrag = React2.useCallback(
|
|
604
678
|
(i, x, y, data) => {
|
|
679
|
+
const currentLayout = layoutRef.current;
|
|
605
680
|
const oldDragItem = oldDragItemRef.current;
|
|
606
|
-
const l =
|
|
681
|
+
const l = chunkBJFPTW5Q_js.getLayoutItem(currentLayout, i);
|
|
607
682
|
if (!l) return;
|
|
608
683
|
const placeholder = {
|
|
609
684
|
w: l.w,
|
|
@@ -612,8 +687,8 @@ function GridLayout(props) {
|
|
|
612
687
|
y: l.y,
|
|
613
688
|
i
|
|
614
689
|
};
|
|
615
|
-
const newLayout =
|
|
616
|
-
|
|
690
|
+
const newLayout = chunkBJFPTW5Q_js.moveElement(
|
|
691
|
+
currentLayout,
|
|
617
692
|
l,
|
|
618
693
|
x,
|
|
619
694
|
y,
|
|
@@ -625,20 +700,21 @@ function GridLayout(props) {
|
|
|
625
700
|
);
|
|
626
701
|
onDragProp(newLayout, oldDragItem, l, placeholder, data.e, data.node);
|
|
627
702
|
setLayout(
|
|
628
|
-
allowOverlap ? newLayout :
|
|
703
|
+
allowOverlap ? newLayout : chunkWWS3M5Y3_js.compact(newLayout, compactType, cols)
|
|
629
704
|
);
|
|
630
705
|
setActiveDrag(placeholder);
|
|
631
706
|
},
|
|
632
|
-
[
|
|
707
|
+
[preventCollision, compactType, cols, allowOverlap, onDragProp]
|
|
633
708
|
);
|
|
634
709
|
const onDragStop = React2.useCallback(
|
|
635
710
|
(i, x, y, data) => {
|
|
636
711
|
if (!activeDrag) return;
|
|
712
|
+
const currentLayout = layoutRef.current;
|
|
637
713
|
const oldDragItem = oldDragItemRef.current;
|
|
638
|
-
const l =
|
|
714
|
+
const l = chunkBJFPTW5Q_js.getLayoutItem(currentLayout, i);
|
|
639
715
|
if (!l) return;
|
|
640
|
-
const newLayout =
|
|
641
|
-
|
|
716
|
+
const newLayout = chunkBJFPTW5Q_js.moveElement(
|
|
717
|
+
currentLayout,
|
|
642
718
|
l,
|
|
643
719
|
x,
|
|
644
720
|
y,
|
|
@@ -648,7 +724,7 @@ function GridLayout(props) {
|
|
|
648
724
|
cols,
|
|
649
725
|
allowOverlap
|
|
650
726
|
);
|
|
651
|
-
const finalLayout = allowOverlap ? newLayout :
|
|
727
|
+
const finalLayout = allowOverlap ? newLayout : chunkWWS3M5Y3_js.compact(newLayout, compactType, cols);
|
|
652
728
|
onDragStopProp(finalLayout, oldDragItem, l, null, data.e, data.node);
|
|
653
729
|
const oldLayout = oldLayoutRef.current;
|
|
654
730
|
oldDragItemRef.current = null;
|
|
@@ -661,7 +737,6 @@ function GridLayout(props) {
|
|
|
661
737
|
},
|
|
662
738
|
[
|
|
663
739
|
activeDrag,
|
|
664
|
-
layout,
|
|
665
740
|
preventCollision,
|
|
666
741
|
compactType,
|
|
667
742
|
cols,
|
|
@@ -672,23 +747,25 @@ function GridLayout(props) {
|
|
|
672
747
|
);
|
|
673
748
|
const onResizeStart = React2.useCallback(
|
|
674
749
|
(i, _w, _h, data) => {
|
|
675
|
-
const
|
|
750
|
+
const currentLayout = layoutRef.current;
|
|
751
|
+
const l = chunkBJFPTW5Q_js.getLayoutItem(currentLayout, i);
|
|
676
752
|
if (!l) return;
|
|
677
|
-
oldResizeItemRef.current =
|
|
678
|
-
oldLayoutRef.current =
|
|
753
|
+
oldResizeItemRef.current = chunkBJFPTW5Q_js.cloneLayoutItem(l);
|
|
754
|
+
oldLayoutRef.current = currentLayout;
|
|
679
755
|
setResizing(true);
|
|
680
|
-
onResizeStartProp(
|
|
756
|
+
onResizeStartProp(currentLayout, l, l, null, data.e, data.node);
|
|
681
757
|
},
|
|
682
|
-
[
|
|
758
|
+
[onResizeStartProp]
|
|
683
759
|
);
|
|
684
760
|
const onResize = React2.useCallback(
|
|
685
761
|
(i, w, h, data) => {
|
|
762
|
+
const currentLayout = layoutRef.current;
|
|
686
763
|
const oldResizeItem = oldResizeItemRef.current;
|
|
687
764
|
const { handle } = data;
|
|
688
765
|
let shouldMoveItem = false;
|
|
689
766
|
let newX;
|
|
690
767
|
let newY;
|
|
691
|
-
const [newLayout, l] =
|
|
768
|
+
const [newLayout, l] = chunkBJFPTW5Q_js.withLayoutItem(currentLayout, i, (item) => {
|
|
692
769
|
newX = item.x;
|
|
693
770
|
newY = item.y;
|
|
694
771
|
if (["sw", "w", "nw", "n", "ne"].includes(handle)) {
|
|
@@ -705,7 +782,7 @@ function GridLayout(props) {
|
|
|
705
782
|
shouldMoveItem = true;
|
|
706
783
|
}
|
|
707
784
|
if (preventCollision && !allowOverlap) {
|
|
708
|
-
const collisions =
|
|
785
|
+
const collisions = chunkBJFPTW5Q_js.getAllCollisions(currentLayout, {
|
|
709
786
|
...item,
|
|
710
787
|
w,
|
|
711
788
|
h,
|
|
@@ -727,7 +804,7 @@ function GridLayout(props) {
|
|
|
727
804
|
if (!l) return;
|
|
728
805
|
let finalLayout = newLayout;
|
|
729
806
|
if (shouldMoveItem && newX !== void 0 && newY !== void 0) {
|
|
730
|
-
finalLayout =
|
|
807
|
+
finalLayout = chunkBJFPTW5Q_js.moveElement(
|
|
731
808
|
newLayout,
|
|
732
809
|
l,
|
|
733
810
|
newX,
|
|
@@ -756,17 +833,18 @@ function GridLayout(props) {
|
|
|
756
833
|
data.node
|
|
757
834
|
);
|
|
758
835
|
setLayout(
|
|
759
|
-
allowOverlap ? finalLayout :
|
|
836
|
+
allowOverlap ? finalLayout : chunkWWS3M5Y3_js.compact(finalLayout, compactType, cols)
|
|
760
837
|
);
|
|
761
838
|
setActiveDrag(placeholder);
|
|
762
839
|
},
|
|
763
|
-
[
|
|
840
|
+
[preventCollision, allowOverlap, compactType, cols, onResizeProp]
|
|
764
841
|
);
|
|
765
842
|
const onResizeStop = React2.useCallback(
|
|
766
843
|
(i, _w, _h, data) => {
|
|
844
|
+
const currentLayout = layoutRef.current;
|
|
767
845
|
const oldResizeItem = oldResizeItemRef.current;
|
|
768
|
-
const l =
|
|
769
|
-
const finalLayout = allowOverlap ?
|
|
846
|
+
const l = chunkBJFPTW5Q_js.getLayoutItem(currentLayout, i);
|
|
847
|
+
const finalLayout = allowOverlap ? currentLayout : chunkWWS3M5Y3_js.compact(currentLayout, compactType, cols);
|
|
770
848
|
onResizeStopProp(
|
|
771
849
|
finalLayout,
|
|
772
850
|
oldResizeItem,
|
|
@@ -785,11 +863,12 @@ function GridLayout(props) {
|
|
|
785
863
|
onLayoutChange(finalLayout);
|
|
786
864
|
}
|
|
787
865
|
},
|
|
788
|
-
[
|
|
866
|
+
[allowOverlap, compactType, cols, onResizeStopProp, onLayoutChange]
|
|
789
867
|
);
|
|
790
868
|
const removeDroppingPlaceholder = React2.useCallback(() => {
|
|
791
|
-
const
|
|
792
|
-
|
|
869
|
+
const currentLayout = layoutRef.current;
|
|
870
|
+
const newLayout = chunkWWS3M5Y3_js.compact(
|
|
871
|
+
currentLayout.filter((l) => l.i !== droppingItem.i),
|
|
793
872
|
compactType,
|
|
794
873
|
cols,
|
|
795
874
|
allowOverlap
|
|
@@ -798,7 +877,7 @@ function GridLayout(props) {
|
|
|
798
877
|
setDroppingDOMNode(null);
|
|
799
878
|
setActiveDrag(null);
|
|
800
879
|
setDroppingPosition(void 0);
|
|
801
|
-
}, [
|
|
880
|
+
}, [droppingItem.i, compactType, cols, allowOverlap]);
|
|
802
881
|
const handleDragOver = React2.useCallback(
|
|
803
882
|
(e) => {
|
|
804
883
|
e.preventDefault();
|
|
@@ -808,42 +887,62 @@ function GridLayout(props) {
|
|
|
808
887
|
)) {
|
|
809
888
|
return false;
|
|
810
889
|
}
|
|
811
|
-
const
|
|
812
|
-
if (
|
|
890
|
+
const rawResult = onDropDragOverProp(e);
|
|
891
|
+
if (rawResult === false) {
|
|
813
892
|
if (droppingDOMNode) {
|
|
814
893
|
removeDroppingPlaceholder();
|
|
815
894
|
}
|
|
816
895
|
return false;
|
|
817
896
|
}
|
|
897
|
+
const {
|
|
898
|
+
dragOffsetX = 0,
|
|
899
|
+
dragOffsetY = 0,
|
|
900
|
+
...onDragOverResult
|
|
901
|
+
} = rawResult ?? {};
|
|
818
902
|
const finalDroppingItem = { ...droppingItem, ...onDragOverResult };
|
|
819
903
|
const gridRect = e.currentTarget.getBoundingClientRect();
|
|
820
|
-
const
|
|
821
|
-
|
|
904
|
+
const positionParams = {
|
|
905
|
+
cols,
|
|
906
|
+
margin,
|
|
907
|
+
maxRows,
|
|
908
|
+
rowHeight,
|
|
909
|
+
containerWidth: width,
|
|
910
|
+
containerPadding: effectiveContainerPadding
|
|
911
|
+
};
|
|
912
|
+
const actualColWidth = chunkBJFPTW5Q_js.calcGridColWidth(positionParams);
|
|
913
|
+
const itemPixelWidth = chunkBJFPTW5Q_js.calcGridItemWHPx(
|
|
914
|
+
finalDroppingItem.w,
|
|
915
|
+
actualColWidth,
|
|
916
|
+
margin[0]
|
|
917
|
+
);
|
|
918
|
+
const itemPixelHeight = chunkBJFPTW5Q_js.calcGridItemWHPx(
|
|
919
|
+
finalDroppingItem.h,
|
|
920
|
+
rowHeight,
|
|
921
|
+
margin[1]
|
|
922
|
+
);
|
|
923
|
+
const itemCenterOffsetX = itemPixelWidth / 2;
|
|
924
|
+
const itemCenterOffsetY = itemPixelHeight / 2;
|
|
925
|
+
const rawGridX = e.clientX - gridRect.left + dragOffsetX - itemCenterOffsetX;
|
|
926
|
+
const rawGridY = e.clientY - gridRect.top + dragOffsetY - itemCenterOffsetY;
|
|
927
|
+
const clampedGridX = Math.max(0, rawGridX);
|
|
928
|
+
const clampedGridY = Math.max(0, rawGridY);
|
|
822
929
|
const newDroppingPosition = {
|
|
823
|
-
left:
|
|
824
|
-
top:
|
|
930
|
+
left: clampedGridX / transformScale,
|
|
931
|
+
top: clampedGridY / transformScale,
|
|
825
932
|
e: e.nativeEvent
|
|
826
933
|
};
|
|
827
934
|
if (!droppingDOMNode) {
|
|
828
|
-
const
|
|
829
|
-
cols,
|
|
830
|
-
margin,
|
|
831
|
-
maxRows,
|
|
832
|
-
rowHeight,
|
|
833
|
-
containerWidth: width,
|
|
834
|
-
containerPadding: effectiveContainerPadding
|
|
835
|
-
};
|
|
836
|
-
const calculatedPosition = chunkF6NQPYKT_js.calcXY(
|
|
935
|
+
const calculatedPosition = chunkBJFPTW5Q_js.calcXY(
|
|
837
936
|
positionParams,
|
|
838
|
-
|
|
839
|
-
|
|
937
|
+
clampedGridY,
|
|
938
|
+
clampedGridX,
|
|
840
939
|
finalDroppingItem.w,
|
|
841
940
|
finalDroppingItem.h
|
|
842
941
|
);
|
|
843
942
|
setDroppingDOMNode(/* @__PURE__ */ jsxRuntime.jsx("div", {}, finalDroppingItem.i));
|
|
844
943
|
setDroppingPosition(newDroppingPosition);
|
|
845
944
|
setLayout([
|
|
846
|
-
...
|
|
945
|
+
...layoutRef.current,
|
|
847
946
|
{
|
|
848
947
|
...finalDroppingItem,
|
|
849
948
|
x: calculatedPosition.x,
|
|
@@ -853,7 +952,7 @@ function GridLayout(props) {
|
|
|
853
952
|
}
|
|
854
953
|
]);
|
|
855
954
|
} else if (droppingPosition) {
|
|
856
|
-
const shouldUpdate = droppingPosition.left !==
|
|
955
|
+
const shouldUpdate = droppingPosition.left !== newDroppingPosition.left || droppingPosition.top !== newDroppingPosition.top;
|
|
857
956
|
if (shouldUpdate) {
|
|
858
957
|
setDroppingPosition(newDroppingPosition);
|
|
859
958
|
}
|
|
@@ -871,8 +970,7 @@ function GridLayout(props) {
|
|
|
871
970
|
maxRows,
|
|
872
971
|
rowHeight,
|
|
873
972
|
width,
|
|
874
|
-
effectiveContainerPadding
|
|
875
|
-
layout
|
|
973
|
+
effectiveContainerPadding
|
|
876
974
|
]
|
|
877
975
|
);
|
|
878
976
|
const handleDragLeave = React2.useCallback(
|
|
@@ -895,17 +993,18 @@ function GridLayout(props) {
|
|
|
895
993
|
(e) => {
|
|
896
994
|
e.preventDefault();
|
|
897
995
|
e.stopPropagation();
|
|
898
|
-
const
|
|
996
|
+
const currentLayout = layoutRef.current;
|
|
997
|
+
const item = currentLayout.find((l) => l.i === droppingItem.i);
|
|
899
998
|
dragEnterCounterRef.current = 0;
|
|
900
999
|
removeDroppingPlaceholder();
|
|
901
|
-
onDropProp(
|
|
1000
|
+
onDropProp(currentLayout, item, e.nativeEvent);
|
|
902
1001
|
},
|
|
903
|
-
[
|
|
1002
|
+
[droppingItem.i, removeDroppingPlaceholder, onDropProp]
|
|
904
1003
|
);
|
|
905
1004
|
const processGridItem = React2.useCallback(
|
|
906
1005
|
(child, isDroppingItem) => {
|
|
907
1006
|
if (!child || !child.key) return null;
|
|
908
|
-
const l =
|
|
1007
|
+
const l = chunkBJFPTW5Q_js.getLayoutItem(layout, String(child.key));
|
|
909
1008
|
if (!l) return null;
|
|
910
1009
|
const draggable = typeof l.isDraggable === "boolean" ? l.isDraggable : !l.static && isDraggable;
|
|
911
1010
|
const resizable = typeof l.isResizable === "boolean" ? l.isResizable : !l.static && isResizable;
|
|
@@ -948,6 +1047,9 @@ function GridLayout(props) {
|
|
|
948
1047
|
droppingPosition: isDroppingItem ? droppingPosition : void 0,
|
|
949
1048
|
resizeHandles: resizeHandlesOptions,
|
|
950
1049
|
resizeHandle: resizeHandleElement,
|
|
1050
|
+
constraints,
|
|
1051
|
+
layoutItem: l,
|
|
1052
|
+
layout,
|
|
951
1053
|
children: child
|
|
952
1054
|
},
|
|
953
1055
|
l.i
|
|
@@ -977,7 +1079,8 @@ function GridLayout(props) {
|
|
|
977
1079
|
transformScale,
|
|
978
1080
|
droppingPosition,
|
|
979
1081
|
resizeHandles,
|
|
980
|
-
resizeHandle
|
|
1082
|
+
resizeHandle,
|
|
1083
|
+
constraints
|
|
981
1084
|
]
|
|
982
1085
|
);
|
|
983
1086
|
const renderPlaceholder = () => {
|
|
@@ -1002,6 +1105,8 @@ function GridLayout(props) {
|
|
|
1002
1105
|
isBounded: false,
|
|
1003
1106
|
useCSSTransforms,
|
|
1004
1107
|
transformScale,
|
|
1108
|
+
constraints,
|
|
1109
|
+
layout,
|
|
1005
1110
|
children: /* @__PURE__ */ jsxRuntime.jsx("div", {})
|
|
1006
1111
|
}
|
|
1007
1112
|
);
|
|
@@ -1083,15 +1188,15 @@ function synchronizeLayoutWithChildren2(initialLayout, children, cols, compactTy
|
|
|
1083
1188
|
layout.push({
|
|
1084
1189
|
i: key,
|
|
1085
1190
|
x: 0,
|
|
1086
|
-
y:
|
|
1191
|
+
y: chunkBJFPTW5Q_js.bottom(layout),
|
|
1087
1192
|
w: 1,
|
|
1088
1193
|
h: 1
|
|
1089
1194
|
});
|
|
1090
1195
|
}
|
|
1091
1196
|
}
|
|
1092
1197
|
});
|
|
1093
|
-
const corrected =
|
|
1094
|
-
return
|
|
1198
|
+
const corrected = chunkBJFPTW5Q_js.correctBounds(layout, { cols });
|
|
1199
|
+
return chunkWWS3M5Y3_js.compact(corrected, compactType, cols, allowOverlap);
|
|
1095
1200
|
}
|
|
1096
1201
|
function ResponsiveGridLayout(props) {
|
|
1097
1202
|
const {
|
|
@@ -1111,17 +1216,17 @@ function ResponsiveGridLayout(props) {
|
|
|
1111
1216
|
onWidthChange = noop2,
|
|
1112
1217
|
...restProps
|
|
1113
1218
|
} = props;
|
|
1114
|
-
const compactor = compactorProp ??
|
|
1219
|
+
const compactor = compactorProp ?? chunkWWS3M5Y3_js.getCompactor("vertical");
|
|
1115
1220
|
const compactType = compactor.type;
|
|
1116
1221
|
const allowOverlap = compactor.allowOverlap;
|
|
1117
1222
|
const initialBreakpoint = React2.useMemo(() => {
|
|
1118
|
-
return propBreakpoint ??
|
|
1223
|
+
return propBreakpoint ?? chunkWWS3M5Y3_js.getBreakpointFromWidth(breakpoints, width);
|
|
1119
1224
|
}, []);
|
|
1120
1225
|
const initialCols = React2.useMemo(() => {
|
|
1121
|
-
return
|
|
1226
|
+
return chunkWWS3M5Y3_js.getColsFromBreakpoint(initialBreakpoint, colsConfig);
|
|
1122
1227
|
}, [initialBreakpoint, colsConfig]);
|
|
1123
1228
|
const initialLayout = React2.useMemo(() => {
|
|
1124
|
-
return
|
|
1229
|
+
return chunkWWS3M5Y3_js.findOrGenerateResponsiveLayout(
|
|
1125
1230
|
propsLayouts,
|
|
1126
1231
|
breakpoints,
|
|
1127
1232
|
initialBreakpoint,
|
|
@@ -1140,9 +1245,13 @@ function ResponsiveGridLayout(props) {
|
|
|
1140
1245
|
const prevColsRef = React2.useRef(colsConfig);
|
|
1141
1246
|
const prevLayoutsRef = React2.useRef(propsLayouts);
|
|
1142
1247
|
const prevCompactTypeRef = React2.useRef(compactType);
|
|
1248
|
+
const layoutsRef = React2.useRef(layouts);
|
|
1143
1249
|
React2.useEffect(() => {
|
|
1250
|
+
layoutsRef.current = layouts;
|
|
1251
|
+
}, [layouts]);
|
|
1252
|
+
const derivedLayout = React2.useMemo(() => {
|
|
1144
1253
|
if (!fastEquals.deepEqual(propsLayouts, prevLayoutsRef.current)) {
|
|
1145
|
-
|
|
1254
|
+
return chunkWWS3M5Y3_js.findOrGenerateResponsiveLayout(
|
|
1146
1255
|
propsLayouts,
|
|
1147
1256
|
breakpoints,
|
|
1148
1257
|
breakpoint,
|
|
@@ -1150,34 +1259,41 @@ function ResponsiveGridLayout(props) {
|
|
|
1150
1259
|
cols,
|
|
1151
1260
|
compactType
|
|
1152
1261
|
);
|
|
1153
|
-
|
|
1262
|
+
}
|
|
1263
|
+
return null;
|
|
1264
|
+
}, [propsLayouts, breakpoints, breakpoint, cols, compactType]);
|
|
1265
|
+
const effectiveLayout = derivedLayout ?? layout;
|
|
1266
|
+
React2.useEffect(() => {
|
|
1267
|
+
if (derivedLayout !== null) {
|
|
1268
|
+
setLayout(derivedLayout);
|
|
1154
1269
|
setLayouts(propsLayouts);
|
|
1270
|
+
layoutsRef.current = propsLayouts;
|
|
1155
1271
|
prevLayoutsRef.current = propsLayouts;
|
|
1156
1272
|
}
|
|
1157
|
-
}, [
|
|
1273
|
+
}, [derivedLayout, propsLayouts]);
|
|
1158
1274
|
React2.useEffect(() => {
|
|
1159
1275
|
if (compactType !== prevCompactTypeRef.current) {
|
|
1160
|
-
const newLayout =
|
|
1161
|
-
|
|
1276
|
+
const newLayout = chunkWWS3M5Y3_js.compact(
|
|
1277
|
+
chunkBJFPTW5Q_js.cloneLayout(effectiveLayout),
|
|
1162
1278
|
compactType,
|
|
1163
1279
|
cols,
|
|
1164
1280
|
allowOverlap
|
|
1165
1281
|
);
|
|
1166
1282
|
const newLayouts = {
|
|
1167
|
-
...
|
|
1283
|
+
...layoutsRef.current,
|
|
1168
1284
|
[breakpoint]: newLayout
|
|
1169
1285
|
};
|
|
1170
1286
|
setLayout(newLayout);
|
|
1171
1287
|
setLayouts(newLayouts);
|
|
1288
|
+
layoutsRef.current = newLayouts;
|
|
1172
1289
|
onLayoutChange(newLayout, newLayouts);
|
|
1173
1290
|
prevCompactTypeRef.current = compactType;
|
|
1174
1291
|
}
|
|
1175
1292
|
}, [
|
|
1176
1293
|
compactType,
|
|
1177
|
-
|
|
1294
|
+
effectiveLayout,
|
|
1178
1295
|
cols,
|
|
1179
1296
|
allowOverlap,
|
|
1180
|
-
layouts,
|
|
1181
1297
|
breakpoint,
|
|
1182
1298
|
onLayoutChange
|
|
1183
1299
|
]);
|
|
@@ -1190,15 +1306,15 @@ function ResponsiveGridLayout(props) {
|
|
|
1190
1306
|
);
|
|
1191
1307
|
const colsChanged = !fastEquals.deepEqual(colsConfig, prevColsRef.current);
|
|
1192
1308
|
if (widthChanged || breakpointPropChanged || breakpointsChanged || colsChanged) {
|
|
1193
|
-
const newBreakpoint = propBreakpoint ??
|
|
1194
|
-
const newCols =
|
|
1309
|
+
const newBreakpoint = propBreakpoint ?? chunkWWS3M5Y3_js.getBreakpointFromWidth(breakpoints, width);
|
|
1310
|
+
const newCols = chunkWWS3M5Y3_js.getColsFromBreakpoint(newBreakpoint, colsConfig);
|
|
1195
1311
|
const lastBreakpoint = breakpoint;
|
|
1196
1312
|
if (lastBreakpoint !== newBreakpoint || breakpointsChanged || colsChanged) {
|
|
1197
|
-
const newLayouts = { ...
|
|
1313
|
+
const newLayouts = { ...layoutsRef.current };
|
|
1198
1314
|
if (!newLayouts[lastBreakpoint]) {
|
|
1199
|
-
newLayouts[lastBreakpoint] =
|
|
1315
|
+
newLayouts[lastBreakpoint] = chunkBJFPTW5Q_js.cloneLayout(layout);
|
|
1200
1316
|
}
|
|
1201
|
-
let newLayout =
|
|
1317
|
+
let newLayout = chunkWWS3M5Y3_js.findOrGenerateResponsiveLayout(
|
|
1202
1318
|
newLayouts,
|
|
1203
1319
|
breakpoints,
|
|
1204
1320
|
newBreakpoint,
|
|
@@ -1218,14 +1334,15 @@ function ResponsiveGridLayout(props) {
|
|
|
1218
1334
|
setCols(newCols);
|
|
1219
1335
|
setLayout(newLayout);
|
|
1220
1336
|
setLayouts(newLayouts);
|
|
1337
|
+
layoutsRef.current = newLayouts;
|
|
1221
1338
|
onBreakpointChange(newBreakpoint, newCols);
|
|
1222
1339
|
onLayoutChange(newLayout, newLayouts);
|
|
1223
1340
|
}
|
|
1224
|
-
const currentMargin2 =
|
|
1341
|
+
const currentMargin2 = chunkWWS3M5Y3_js.getIndentationValue(
|
|
1225
1342
|
propMargin,
|
|
1226
1343
|
newBreakpoint
|
|
1227
1344
|
);
|
|
1228
|
-
const currentPadding = propContainerPadding ?
|
|
1345
|
+
const currentPadding = propContainerPadding ? chunkWWS3M5Y3_js.getIndentationValue(
|
|
1229
1346
|
propContainerPadding,
|
|
1230
1347
|
newBreakpoint
|
|
1231
1348
|
) : null;
|
|
@@ -1243,7 +1360,6 @@ function ResponsiveGridLayout(props) {
|
|
|
1243
1360
|
breakpoint,
|
|
1244
1361
|
cols,
|
|
1245
1362
|
layout,
|
|
1246
|
-
layouts,
|
|
1247
1363
|
children,
|
|
1248
1364
|
compactType,
|
|
1249
1365
|
allowOverlap,
|
|
@@ -1255,25 +1371,27 @@ function ResponsiveGridLayout(props) {
|
|
|
1255
1371
|
]);
|
|
1256
1372
|
const handleLayoutChange = React2.useCallback(
|
|
1257
1373
|
(newLayout) => {
|
|
1374
|
+
const currentLayouts = layoutsRef.current;
|
|
1258
1375
|
const newLayouts = {
|
|
1259
|
-
...
|
|
1376
|
+
...currentLayouts,
|
|
1260
1377
|
[breakpoint]: newLayout
|
|
1261
1378
|
};
|
|
1262
1379
|
setLayout(newLayout);
|
|
1263
1380
|
setLayouts(newLayouts);
|
|
1381
|
+
layoutsRef.current = newLayouts;
|
|
1264
1382
|
onLayoutChange(newLayout, newLayouts);
|
|
1265
1383
|
},
|
|
1266
|
-
[
|
|
1384
|
+
[breakpoint, onLayoutChange]
|
|
1267
1385
|
);
|
|
1268
1386
|
const currentMargin = React2.useMemo(() => {
|
|
1269
|
-
return
|
|
1387
|
+
return chunkWWS3M5Y3_js.getIndentationValue(
|
|
1270
1388
|
propMargin,
|
|
1271
1389
|
breakpoint
|
|
1272
1390
|
);
|
|
1273
1391
|
}, [propMargin, breakpoint]);
|
|
1274
1392
|
const currentContainerPadding = React2.useMemo(() => {
|
|
1275
1393
|
if (propContainerPadding === null) return null;
|
|
1276
|
-
return
|
|
1394
|
+
return chunkWWS3M5Y3_js.getIndentationValue(
|
|
1277
1395
|
propContainerPadding,
|
|
1278
1396
|
breakpoint
|
|
1279
1397
|
);
|
|
@@ -1296,7 +1414,7 @@ function ResponsiveGridLayout(props) {
|
|
|
1296
1414
|
gridConfig,
|
|
1297
1415
|
compactor,
|
|
1298
1416
|
onLayoutChange: handleLayoutChange,
|
|
1299
|
-
layout,
|
|
1417
|
+
layout: effectiveLayout,
|
|
1300
1418
|
children
|
|
1301
1419
|
}
|
|
1302
1420
|
);
|
|
@@ -1305,5 +1423,5 @@ function ResponsiveGridLayout(props) {
|
|
|
1305
1423
|
exports.GridItem = GridItem;
|
|
1306
1424
|
exports.GridLayout = GridLayout;
|
|
1307
1425
|
exports.ResponsiveGridLayout = ResponsiveGridLayout;
|
|
1308
|
-
//# sourceMappingURL=chunk-
|
|
1309
|
-
//# sourceMappingURL=chunk-
|
|
1426
|
+
//# sourceMappingURL=chunk-RB2IKK5B.js.map
|
|
1427
|
+
//# sourceMappingURL=chunk-RB2IKK5B.js.map
|