react-grid-layout 1.5.3 → 2.1.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/README.md +1156 -442
- package/css/styles.css +5 -4
- package/dist/ResponsiveGridLayout-BkHF9YHa.d.mts +133 -0
- package/dist/ResponsiveGridLayout-CLn16-X3.d.ts +133 -0
- package/dist/calculate-DsVTldEE.d.ts +196 -0
- package/dist/calculate-DwbL1D06.d.mts +196 -0
- package/dist/chunk-2O3ZME4Q.mjs +703 -0
- package/dist/chunk-2O3ZME4Q.mjs.map +1 -0
- package/dist/chunk-526JND3R.mjs +3 -0
- package/dist/chunk-526JND3R.mjs.map +1 -0
- package/dist/chunk-7ELO5FRW.js +4 -0
- package/dist/chunk-7ELO5FRW.js.map +1 -0
- 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-FN6MIZ24.js +744 -0
- package/dist/chunk-FN6MIZ24.js.map +1 -0
- package/dist/chunk-GPZBANOK.js +435 -0
- package/dist/chunk-GPZBANOK.js.map +1 -0
- package/dist/chunk-LWF5EYMO.mjs +429 -0
- package/dist/chunk-LWF5EYMO.mjs.map +1 -0
- package/dist/chunk-MXXN7GUE.mjs +1408 -0
- package/dist/chunk-MXXN7GUE.mjs.map +1 -0
- package/dist/chunk-QRW3ND4U.js +1417 -0
- package/dist/chunk-QRW3ND4U.js.map +1 -0
- package/dist/core.d.mts +186 -0
- package/dist/core.d.ts +186 -0
- package/dist/core.js +274 -0
- package/dist/core.js.map +1 -0
- package/dist/core.mjs +5 -0
- package/dist/core.mjs.map +1 -0
- package/dist/extras.d.mts +208 -0
- package/dist/extras.d.ts +208 -0
- package/dist/extras.js +462 -0
- package/dist/extras.js.map +1 -0
- package/dist/extras.mjs +454 -0
- package/dist/extras.mjs.map +1 -0
- package/dist/index.d.mts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +154 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +7 -0
- package/dist/index.mjs.map +1 -0
- package/dist/legacy.d.mts +163 -0
- package/dist/legacy.d.ts +163 -0
- package/dist/legacy.js +320 -0
- package/dist/legacy.js.map +1 -0
- package/dist/legacy.mjs +308 -0
- package/dist/legacy.mjs.map +1 -0
- package/dist/position-C8a5g6bb.d.mts +324 -0
- package/dist/position-H8tBL91b.d.ts +324 -0
- package/dist/react.d.mts +357 -0
- package/dist/react.d.ts +357 -0
- package/dist/react.js +96 -0
- package/dist/react.js.map +1 -0
- package/dist/react.mjs +7 -0
- package/dist/react.mjs.map +1 -0
- package/dist/responsive-BB5d98xz.d.mts +145 -0
- package/dist/responsive-BXI-GCXG.d.ts +145 -0
- package/dist/types-CokovIMH.d.mts +469 -0
- package/dist/types-CokovIMH.d.ts +469 -0
- package/index-dev.js +24 -0
- package/package.json +133 -40
- package/.babelrc.js +0 -22
- package/.browserslistrc +0 -3
- package/.eslintignore +0 -4
- package/.flowconfig +0 -20
- package/.prettierignore +0 -4
- package/.prettierrc +0 -17
- package/CHANGELOG.md +0 -985
- package/build/GridItem.js +0 -638
- package/build/ReactGridLayout.js +0 -741
- package/build/ReactGridLayoutPropTypes.js +0 -210
- package/build/ResponsiveReactGridLayout.js +0 -297
- package/build/calculateUtils.js +0 -165
- package/build/components/WidthProvider.js +0 -115
- package/build/fastRGLPropsEqual.js +0 -5
- package/build/responsiveUtils.js +0 -101
- package/build/utils.js +0 -842
- package/dist/react-grid-layout.min.js +0 -2
- package/dist/react-grid-layout.min.js.map +0 -1
- package/index.js.flow +0 -8
- package/ip_fetcher +0 -0
- package/ip_fetcher.c +0 -47
- package/lib/GridItem.jsx +0 -689
- package/lib/ReactGridLayout.jsx +0 -855
- package/lib/ReactGridLayoutPropTypes.js +0 -241
- package/lib/ResponsiveReactGridLayout.jsx +0 -349
- package/lib/calculateUtils.js +0 -169
- package/lib/components/WidthProvider.jsx +0 -110
- package/lib/fastRGLPropsEqual.js +0 -46
- package/lib/responsiveUtils.js +0 -118
- package/lib/utils.js +0 -995
- package/yarn-error.log +0 -7780
|
@@ -0,0 +1,1417 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkFN6MIZ24_js = require('./chunk-FN6MIZ24.js');
|
|
4
|
+
var chunkBJFPTW5Q_js = require('./chunk-BJFPTW5Q.js');
|
|
5
|
+
var React2 = require('react');
|
|
6
|
+
var reactDraggable = require('react-draggable');
|
|
7
|
+
var reactResizable = require('react-resizable');
|
|
8
|
+
var clsx = require('clsx');
|
|
9
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
10
|
+
var fastEquals = require('fast-equals');
|
|
11
|
+
|
|
12
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
|
|
14
|
+
var React2__default = /*#__PURE__*/_interopDefault(React2);
|
|
15
|
+
var clsx__default = /*#__PURE__*/_interopDefault(clsx);
|
|
16
|
+
|
|
17
|
+
function GridItem(props) {
|
|
18
|
+
const {
|
|
19
|
+
children,
|
|
20
|
+
cols,
|
|
21
|
+
containerWidth,
|
|
22
|
+
margin,
|
|
23
|
+
containerPadding,
|
|
24
|
+
rowHeight,
|
|
25
|
+
maxRows,
|
|
26
|
+
isDraggable,
|
|
27
|
+
isResizable,
|
|
28
|
+
isBounded,
|
|
29
|
+
static: isStatic,
|
|
30
|
+
useCSSTransforms = true,
|
|
31
|
+
usePercentages = false,
|
|
32
|
+
transformScale = 1,
|
|
33
|
+
droppingPosition,
|
|
34
|
+
className = "",
|
|
35
|
+
style,
|
|
36
|
+
handle = "",
|
|
37
|
+
cancel = "",
|
|
38
|
+
x,
|
|
39
|
+
y,
|
|
40
|
+
w,
|
|
41
|
+
h,
|
|
42
|
+
minW = 1,
|
|
43
|
+
maxW = Infinity,
|
|
44
|
+
minH = 1,
|
|
45
|
+
maxH = Infinity,
|
|
46
|
+
i,
|
|
47
|
+
resizeHandles,
|
|
48
|
+
resizeHandle,
|
|
49
|
+
constraints = chunkFN6MIZ24_js.defaultConstraints,
|
|
50
|
+
layoutItem,
|
|
51
|
+
layout = [],
|
|
52
|
+
onDragStart: onDragStartProp,
|
|
53
|
+
onDrag: onDragProp,
|
|
54
|
+
onDragStop: onDragStopProp,
|
|
55
|
+
onResizeStart: onResizeStartProp,
|
|
56
|
+
onResize: onResizeProp,
|
|
57
|
+
onResizeStop: onResizeStopProp
|
|
58
|
+
} = props;
|
|
59
|
+
const [dragging, setDragging] = React2.useState(false);
|
|
60
|
+
const [resizing, setResizing] = React2.useState(false);
|
|
61
|
+
const elementRef = React2.useRef(null);
|
|
62
|
+
const dragPositionRef = React2.useRef({ left: 0, top: 0 });
|
|
63
|
+
const resizePositionRef = React2.useRef({
|
|
64
|
+
top: 0,
|
|
65
|
+
left: 0,
|
|
66
|
+
width: 0,
|
|
67
|
+
height: 0
|
|
68
|
+
});
|
|
69
|
+
const prevDroppingPositionRef = React2.useRef(
|
|
70
|
+
void 0
|
|
71
|
+
);
|
|
72
|
+
const positionParams = React2.useMemo(
|
|
73
|
+
() => ({
|
|
74
|
+
cols,
|
|
75
|
+
containerPadding,
|
|
76
|
+
containerWidth,
|
|
77
|
+
margin,
|
|
78
|
+
maxRows,
|
|
79
|
+
rowHeight
|
|
80
|
+
}),
|
|
81
|
+
[cols, containerPadding, containerWidth, margin, maxRows, rowHeight]
|
|
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
|
+
);
|
|
110
|
+
const createStyle = React2.useCallback(
|
|
111
|
+
(pos2) => {
|
|
112
|
+
if (useCSSTransforms) {
|
|
113
|
+
return chunkFN6MIZ24_js.setTransform(pos2);
|
|
114
|
+
}
|
|
115
|
+
const styleObj = chunkFN6MIZ24_js.setTopLeft(pos2);
|
|
116
|
+
if (usePercentages) {
|
|
117
|
+
return {
|
|
118
|
+
...styleObj,
|
|
119
|
+
left: chunkFN6MIZ24_js.perc(pos2.left / containerWidth),
|
|
120
|
+
width: chunkFN6MIZ24_js.perc(pos2.width / containerWidth)
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
return styleObj;
|
|
124
|
+
},
|
|
125
|
+
[useCSSTransforms, usePercentages, containerWidth]
|
|
126
|
+
);
|
|
127
|
+
const onDragStart = React2.useCallback(
|
|
128
|
+
(e, { node }) => {
|
|
129
|
+
if (!onDragStartProp) return;
|
|
130
|
+
const { offsetParent } = node;
|
|
131
|
+
if (!offsetParent) return;
|
|
132
|
+
const parentRect = offsetParent.getBoundingClientRect();
|
|
133
|
+
const clientRect = node.getBoundingClientRect();
|
|
134
|
+
const cLeft = clientRect.left / transformScale;
|
|
135
|
+
const pLeft = parentRect.left / transformScale;
|
|
136
|
+
const cTop = clientRect.top / transformScale;
|
|
137
|
+
const pTop = parentRect.top / transformScale;
|
|
138
|
+
const newPosition = {
|
|
139
|
+
left: cLeft - pLeft + offsetParent.scrollLeft,
|
|
140
|
+
top: cTop - pTop + offsetParent.scrollTop
|
|
141
|
+
};
|
|
142
|
+
dragPositionRef.current = newPosition;
|
|
143
|
+
setDragging(true);
|
|
144
|
+
const rawPos = chunkBJFPTW5Q_js.calcXYRaw(
|
|
145
|
+
positionParams,
|
|
146
|
+
newPosition.top,
|
|
147
|
+
newPosition.left
|
|
148
|
+
);
|
|
149
|
+
const { x: newX, y: newY } = chunkFN6MIZ24_js.applyPositionConstraints(
|
|
150
|
+
constraints,
|
|
151
|
+
effectiveLayoutItem,
|
|
152
|
+
rawPos.x,
|
|
153
|
+
rawPos.y,
|
|
154
|
+
constraintContext
|
|
155
|
+
);
|
|
156
|
+
onDragStartProp(i, newX, newY, {
|
|
157
|
+
e,
|
|
158
|
+
node,
|
|
159
|
+
newPosition
|
|
160
|
+
});
|
|
161
|
+
},
|
|
162
|
+
[
|
|
163
|
+
onDragStartProp,
|
|
164
|
+
transformScale,
|
|
165
|
+
positionParams,
|
|
166
|
+
constraints,
|
|
167
|
+
effectiveLayoutItem,
|
|
168
|
+
constraintContext,
|
|
169
|
+
i
|
|
170
|
+
]
|
|
171
|
+
);
|
|
172
|
+
const onDrag = React2.useCallback(
|
|
173
|
+
(e, { node, deltaX, deltaY }) => {
|
|
174
|
+
if (!onDragProp || !dragging) return;
|
|
175
|
+
let top = dragPositionRef.current.top + deltaY;
|
|
176
|
+
let left = dragPositionRef.current.left + deltaX;
|
|
177
|
+
if (isBounded) {
|
|
178
|
+
const { offsetParent } = node;
|
|
179
|
+
if (offsetParent) {
|
|
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);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
const newPosition = { top, left };
|
|
188
|
+
dragPositionRef.current = newPosition;
|
|
189
|
+
const rawPos = chunkBJFPTW5Q_js.calcXYRaw(positionParams, top, left);
|
|
190
|
+
const { x: newX, y: newY } = chunkFN6MIZ24_js.applyPositionConstraints(
|
|
191
|
+
constraints,
|
|
192
|
+
effectiveLayoutItem,
|
|
193
|
+
rawPos.x,
|
|
194
|
+
rawPos.y,
|
|
195
|
+
constraintContext
|
|
196
|
+
);
|
|
197
|
+
onDragProp(i, newX, newY, {
|
|
198
|
+
e,
|
|
199
|
+
node,
|
|
200
|
+
newPosition
|
|
201
|
+
});
|
|
202
|
+
},
|
|
203
|
+
[
|
|
204
|
+
onDragProp,
|
|
205
|
+
dragging,
|
|
206
|
+
isBounded,
|
|
207
|
+
h,
|
|
208
|
+
rowHeight,
|
|
209
|
+
margin,
|
|
210
|
+
positionParams,
|
|
211
|
+
containerWidth,
|
|
212
|
+
w,
|
|
213
|
+
i,
|
|
214
|
+
constraints,
|
|
215
|
+
effectiveLayoutItem,
|
|
216
|
+
constraintContext
|
|
217
|
+
]
|
|
218
|
+
);
|
|
219
|
+
const onDragStop = React2.useCallback(
|
|
220
|
+
(e, { node }) => {
|
|
221
|
+
if (!onDragStopProp || !dragging) return;
|
|
222
|
+
const { left, top } = dragPositionRef.current;
|
|
223
|
+
const newPosition = { top, left };
|
|
224
|
+
setDragging(false);
|
|
225
|
+
dragPositionRef.current = { left: 0, top: 0 };
|
|
226
|
+
const rawPos = chunkBJFPTW5Q_js.calcXYRaw(positionParams, top, left);
|
|
227
|
+
const { x: newX, y: newY } = chunkFN6MIZ24_js.applyPositionConstraints(
|
|
228
|
+
constraints,
|
|
229
|
+
effectiveLayoutItem,
|
|
230
|
+
rawPos.x,
|
|
231
|
+
rawPos.y,
|
|
232
|
+
constraintContext
|
|
233
|
+
);
|
|
234
|
+
onDragStopProp(i, newX, newY, {
|
|
235
|
+
e,
|
|
236
|
+
node,
|
|
237
|
+
newPosition
|
|
238
|
+
});
|
|
239
|
+
},
|
|
240
|
+
[
|
|
241
|
+
onDragStopProp,
|
|
242
|
+
dragging,
|
|
243
|
+
positionParams,
|
|
244
|
+
constraints,
|
|
245
|
+
effectiveLayoutItem,
|
|
246
|
+
constraintContext,
|
|
247
|
+
i
|
|
248
|
+
]
|
|
249
|
+
);
|
|
250
|
+
const onResizeHandler = React2.useCallback(
|
|
251
|
+
(e, { node, size, handle: resizeHandle2 }, position, handlerName) => {
|
|
252
|
+
const handler = handlerName === "onResizeStart" ? onResizeStartProp : handlerName === "onResize" ? onResizeProp : onResizeStopProp;
|
|
253
|
+
if (!handler) return;
|
|
254
|
+
let updatedSize;
|
|
255
|
+
if (node) {
|
|
256
|
+
updatedSize = chunkFN6MIZ24_js.resizeItemInDirection(
|
|
257
|
+
resizeHandle2,
|
|
258
|
+
position,
|
|
259
|
+
size,
|
|
260
|
+
containerWidth
|
|
261
|
+
);
|
|
262
|
+
} else {
|
|
263
|
+
updatedSize = {
|
|
264
|
+
...size,
|
|
265
|
+
top: position.top,
|
|
266
|
+
left: position.left
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
resizePositionRef.current = updatedSize;
|
|
270
|
+
const rawSize = chunkBJFPTW5Q_js.calcWHRaw(
|
|
271
|
+
positionParams,
|
|
272
|
+
updatedSize.width,
|
|
273
|
+
updatedSize.height
|
|
274
|
+
);
|
|
275
|
+
const { w: newW, h: newH } = chunkFN6MIZ24_js.applySizeConstraints(
|
|
276
|
+
constraints,
|
|
277
|
+
effectiveLayoutItem,
|
|
278
|
+
rawSize.w,
|
|
279
|
+
rawSize.h,
|
|
280
|
+
resizeHandle2,
|
|
281
|
+
constraintContext
|
|
282
|
+
);
|
|
283
|
+
handler(i, newW, newH, {
|
|
284
|
+
e: e.nativeEvent,
|
|
285
|
+
node,
|
|
286
|
+
size: updatedSize,
|
|
287
|
+
handle: resizeHandle2
|
|
288
|
+
});
|
|
289
|
+
},
|
|
290
|
+
[
|
|
291
|
+
onResizeStartProp,
|
|
292
|
+
onResizeProp,
|
|
293
|
+
onResizeStopProp,
|
|
294
|
+
containerWidth,
|
|
295
|
+
positionParams,
|
|
296
|
+
x,
|
|
297
|
+
y,
|
|
298
|
+
i,
|
|
299
|
+
constraints,
|
|
300
|
+
effectiveLayoutItem,
|
|
301
|
+
constraintContext
|
|
302
|
+
]
|
|
303
|
+
);
|
|
304
|
+
const handleResizeStart = React2.useCallback(
|
|
305
|
+
(e, data) => {
|
|
306
|
+
setResizing(true);
|
|
307
|
+
const pos2 = chunkBJFPTW5Q_js.calcGridItemPosition(positionParams, x, y, w, h);
|
|
308
|
+
const typedData = {
|
|
309
|
+
...data,
|
|
310
|
+
handle: data.handle
|
|
311
|
+
};
|
|
312
|
+
onResizeHandler(e, typedData, pos2, "onResizeStart");
|
|
313
|
+
},
|
|
314
|
+
[onResizeHandler, positionParams, x, y, w, h]
|
|
315
|
+
);
|
|
316
|
+
const handleResize = React2.useCallback(
|
|
317
|
+
(e, data) => {
|
|
318
|
+
const pos2 = chunkBJFPTW5Q_js.calcGridItemPosition(positionParams, x, y, w, h);
|
|
319
|
+
const typedData = {
|
|
320
|
+
...data,
|
|
321
|
+
handle: data.handle
|
|
322
|
+
};
|
|
323
|
+
onResizeHandler(e, typedData, pos2, "onResize");
|
|
324
|
+
},
|
|
325
|
+
[onResizeHandler, positionParams, x, y, w, h]
|
|
326
|
+
);
|
|
327
|
+
const handleResizeStop = React2.useCallback(
|
|
328
|
+
(e, data) => {
|
|
329
|
+
setResizing(false);
|
|
330
|
+
resizePositionRef.current = { top: 0, left: 0, width: 0, height: 0 };
|
|
331
|
+
const pos2 = chunkBJFPTW5Q_js.calcGridItemPosition(positionParams, x, y, w, h);
|
|
332
|
+
const typedData = {
|
|
333
|
+
...data,
|
|
334
|
+
handle: data.handle
|
|
335
|
+
};
|
|
336
|
+
onResizeHandler(e, typedData, pos2, "onResizeStop");
|
|
337
|
+
},
|
|
338
|
+
[onResizeHandler, positionParams, x, y, w, h]
|
|
339
|
+
);
|
|
340
|
+
React2.useEffect(() => {
|
|
341
|
+
if (!droppingPosition) return;
|
|
342
|
+
const node = elementRef.current;
|
|
343
|
+
if (!node) return;
|
|
344
|
+
const prevDroppingPosition = prevDroppingPositionRef.current || {
|
|
345
|
+
left: 0,
|
|
346
|
+
top: 0
|
|
347
|
+
};
|
|
348
|
+
const shouldDrag = dragging && (droppingPosition.left !== prevDroppingPosition.left || droppingPosition.top !== prevDroppingPosition.top);
|
|
349
|
+
if (!dragging) {
|
|
350
|
+
const fakeData = {
|
|
351
|
+
node,
|
|
352
|
+
deltaX: droppingPosition.left,
|
|
353
|
+
deltaY: droppingPosition.top,
|
|
354
|
+
lastX: 0,
|
|
355
|
+
lastY: 0,
|
|
356
|
+
x: droppingPosition.left,
|
|
357
|
+
y: droppingPosition.top
|
|
358
|
+
};
|
|
359
|
+
onDragStart(droppingPosition.e, fakeData);
|
|
360
|
+
} else if (shouldDrag) {
|
|
361
|
+
const deltaX = droppingPosition.left - dragPositionRef.current.left;
|
|
362
|
+
const deltaY = droppingPosition.top - dragPositionRef.current.top;
|
|
363
|
+
const fakeData = {
|
|
364
|
+
node,
|
|
365
|
+
deltaX,
|
|
366
|
+
deltaY,
|
|
367
|
+
lastX: dragPositionRef.current.left,
|
|
368
|
+
lastY: dragPositionRef.current.top,
|
|
369
|
+
x: droppingPosition.left,
|
|
370
|
+
y: droppingPosition.top
|
|
371
|
+
};
|
|
372
|
+
onDrag(droppingPosition.e, fakeData);
|
|
373
|
+
}
|
|
374
|
+
prevDroppingPositionRef.current = droppingPosition;
|
|
375
|
+
}, [droppingPosition, dragging, onDragStart, onDrag]);
|
|
376
|
+
const pos = chunkBJFPTW5Q_js.calcGridItemPosition(
|
|
377
|
+
positionParams,
|
|
378
|
+
x,
|
|
379
|
+
y,
|
|
380
|
+
w,
|
|
381
|
+
h,
|
|
382
|
+
dragging ? dragPositionRef.current : null,
|
|
383
|
+
resizing ? resizePositionRef.current : null
|
|
384
|
+
);
|
|
385
|
+
const child = React2__default.default.Children.only(children);
|
|
386
|
+
const minGridUnit = chunkBJFPTW5Q_js.calcGridItemPosition(positionParams, 0, 0, 1, 1);
|
|
387
|
+
const minConstraints = [
|
|
388
|
+
minGridUnit.width,
|
|
389
|
+
minGridUnit.height
|
|
390
|
+
];
|
|
391
|
+
const maxConstraints = [Infinity, Infinity];
|
|
392
|
+
const childProps = child.props;
|
|
393
|
+
const childClassName = childProps["className"];
|
|
394
|
+
const childStyle = childProps["style"];
|
|
395
|
+
let newChild = React2__default.default.cloneElement(child, {
|
|
396
|
+
ref: elementRef,
|
|
397
|
+
className: clsx__default.default("react-grid-item", childClassName, className, {
|
|
398
|
+
static: isStatic,
|
|
399
|
+
resizing,
|
|
400
|
+
"react-draggable": isDraggable,
|
|
401
|
+
"react-draggable-dragging": dragging,
|
|
402
|
+
dropping: Boolean(droppingPosition),
|
|
403
|
+
cssTransforms: useCSSTransforms
|
|
404
|
+
}),
|
|
405
|
+
style: {
|
|
406
|
+
...style,
|
|
407
|
+
...childStyle,
|
|
408
|
+
...createStyle(pos)
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
const resizableHandle = resizeHandle;
|
|
412
|
+
newChild = /* @__PURE__ */ jsxRuntime.jsx(
|
|
413
|
+
reactResizable.Resizable,
|
|
414
|
+
{
|
|
415
|
+
draggableOpts: { disabled: !isResizable },
|
|
416
|
+
className: isResizable ? void 0 : "react-resizable-hide",
|
|
417
|
+
width: pos.width,
|
|
418
|
+
height: pos.height,
|
|
419
|
+
minConstraints,
|
|
420
|
+
maxConstraints,
|
|
421
|
+
onResizeStart: handleResizeStart,
|
|
422
|
+
onResize: handleResize,
|
|
423
|
+
onResizeStop: handleResizeStop,
|
|
424
|
+
transformScale,
|
|
425
|
+
resizeHandles,
|
|
426
|
+
handle: resizableHandle,
|
|
427
|
+
children: newChild
|
|
428
|
+
}
|
|
429
|
+
);
|
|
430
|
+
newChild = /* @__PURE__ */ jsxRuntime.jsx(
|
|
431
|
+
reactDraggable.DraggableCore,
|
|
432
|
+
{
|
|
433
|
+
disabled: !isDraggable,
|
|
434
|
+
onStart: onDragStart,
|
|
435
|
+
onDrag,
|
|
436
|
+
onStop: onDragStop,
|
|
437
|
+
handle,
|
|
438
|
+
cancel: ".react-resizable-handle" + (cancel ? "," + cancel : ""),
|
|
439
|
+
scale: transformScale,
|
|
440
|
+
nodeRef: elementRef,
|
|
441
|
+
children: newChild
|
|
442
|
+
}
|
|
443
|
+
);
|
|
444
|
+
return newChild;
|
|
445
|
+
}
|
|
446
|
+
var noop = () => {
|
|
447
|
+
};
|
|
448
|
+
var layoutClassName = "react-grid-layout";
|
|
449
|
+
var isFirefox = false;
|
|
450
|
+
try {
|
|
451
|
+
isFirefox = /firefox/i.test(navigator.userAgent);
|
|
452
|
+
} catch {
|
|
453
|
+
}
|
|
454
|
+
function childrenEqual(a, b) {
|
|
455
|
+
const aArr = React2__default.default.Children.toArray(a);
|
|
456
|
+
const bArr = React2__default.default.Children.toArray(b);
|
|
457
|
+
if (aArr.length !== bArr.length) return false;
|
|
458
|
+
for (let i = 0; i < aArr.length; i++) {
|
|
459
|
+
const aChild = aArr[i];
|
|
460
|
+
const bChild = bArr[i];
|
|
461
|
+
if (aChild?.key !== bChild?.key) return false;
|
|
462
|
+
}
|
|
463
|
+
return true;
|
|
464
|
+
}
|
|
465
|
+
function synchronizeLayoutWithChildren(initialLayout, children, cols, compactType, allowOverlap) {
|
|
466
|
+
const layout = [];
|
|
467
|
+
const childKeys = /* @__PURE__ */ new Set();
|
|
468
|
+
React2__default.default.Children.forEach(children, (child) => {
|
|
469
|
+
if (!React2__default.default.isValidElement(child) || child.key === null) return;
|
|
470
|
+
const key = String(child.key);
|
|
471
|
+
childKeys.add(key);
|
|
472
|
+
const existingItem = initialLayout.find((l) => l.i === key);
|
|
473
|
+
if (existingItem) {
|
|
474
|
+
layout.push(chunkBJFPTW5Q_js.cloneLayoutItem(existingItem));
|
|
475
|
+
} else {
|
|
476
|
+
const childProps = child.props;
|
|
477
|
+
const dataGrid = childProps["data-grid"];
|
|
478
|
+
if (dataGrid) {
|
|
479
|
+
layout.push({
|
|
480
|
+
i: key,
|
|
481
|
+
x: dataGrid.x ?? 0,
|
|
482
|
+
y: dataGrid.y ?? 0,
|
|
483
|
+
w: dataGrid.w ?? 1,
|
|
484
|
+
h: dataGrid.h ?? 1,
|
|
485
|
+
minW: dataGrid.minW,
|
|
486
|
+
maxW: dataGrid.maxW,
|
|
487
|
+
minH: dataGrid.minH,
|
|
488
|
+
maxH: dataGrid.maxH,
|
|
489
|
+
static: dataGrid.static,
|
|
490
|
+
isDraggable: dataGrid.isDraggable,
|
|
491
|
+
isResizable: dataGrid.isResizable,
|
|
492
|
+
resizeHandles: dataGrid.resizeHandles,
|
|
493
|
+
isBounded: dataGrid.isBounded
|
|
494
|
+
});
|
|
495
|
+
} else {
|
|
496
|
+
layout.push({
|
|
497
|
+
i: key,
|
|
498
|
+
x: 0,
|
|
499
|
+
y: chunkBJFPTW5Q_js.bottom(layout),
|
|
500
|
+
w: 1,
|
|
501
|
+
h: 1
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
});
|
|
506
|
+
const corrected = chunkBJFPTW5Q_js.correctBounds(layout, { cols });
|
|
507
|
+
return chunkFN6MIZ24_js.compact(corrected, compactType, cols, allowOverlap);
|
|
508
|
+
}
|
|
509
|
+
function GridLayout(props) {
|
|
510
|
+
const {
|
|
511
|
+
// Required
|
|
512
|
+
children,
|
|
513
|
+
width,
|
|
514
|
+
// Composable config interfaces
|
|
515
|
+
gridConfig: gridConfigProp,
|
|
516
|
+
dragConfig: dragConfigProp,
|
|
517
|
+
resizeConfig: resizeConfigProp,
|
|
518
|
+
dropConfig: dropConfigProp,
|
|
519
|
+
positionStrategy = chunkFN6MIZ24_js.defaultPositionStrategy,
|
|
520
|
+
compactor: compactorProp,
|
|
521
|
+
constraints = chunkFN6MIZ24_js.defaultConstraints,
|
|
522
|
+
// Layout data
|
|
523
|
+
layout: propsLayout = [],
|
|
524
|
+
droppingItem: droppingItemProp,
|
|
525
|
+
// Container props
|
|
526
|
+
autoSize = true,
|
|
527
|
+
className = "",
|
|
528
|
+
style = {},
|
|
529
|
+
innerRef,
|
|
530
|
+
// Callbacks
|
|
531
|
+
onLayoutChange = noop,
|
|
532
|
+
onDragStart: onDragStartProp = noop,
|
|
533
|
+
onDrag: onDragProp = noop,
|
|
534
|
+
onDragStop: onDragStopProp = noop,
|
|
535
|
+
onResizeStart: onResizeStartProp = noop,
|
|
536
|
+
onResize: onResizeProp = noop,
|
|
537
|
+
onResizeStop: onResizeStopProp = noop,
|
|
538
|
+
onDrop: onDropProp = noop,
|
|
539
|
+
onDropDragOver: onDropDragOverProp = noop
|
|
540
|
+
} = props;
|
|
541
|
+
const gridConfig = React2.useMemo(
|
|
542
|
+
() => ({ ...chunkFN6MIZ24_js.defaultGridConfig, ...gridConfigProp }),
|
|
543
|
+
[gridConfigProp]
|
|
544
|
+
);
|
|
545
|
+
const dragConfig = React2.useMemo(
|
|
546
|
+
() => ({ ...chunkFN6MIZ24_js.defaultDragConfig, ...dragConfigProp }),
|
|
547
|
+
[dragConfigProp]
|
|
548
|
+
);
|
|
549
|
+
const resizeConfig = React2.useMemo(
|
|
550
|
+
() => ({ ...chunkFN6MIZ24_js.defaultResizeConfig, ...resizeConfigProp }),
|
|
551
|
+
[resizeConfigProp]
|
|
552
|
+
);
|
|
553
|
+
const dropConfig = React2.useMemo(
|
|
554
|
+
() => ({ ...chunkFN6MIZ24_js.defaultDropConfig, ...dropConfigProp }),
|
|
555
|
+
[dropConfigProp]
|
|
556
|
+
);
|
|
557
|
+
const { cols, rowHeight, maxRows, margin, containerPadding } = gridConfig;
|
|
558
|
+
const {
|
|
559
|
+
enabled: isDraggable,
|
|
560
|
+
bounded: isBounded,
|
|
561
|
+
handle: draggableHandle,
|
|
562
|
+
cancel: draggableCancel
|
|
563
|
+
} = dragConfig;
|
|
564
|
+
const {
|
|
565
|
+
enabled: isResizable,
|
|
566
|
+
handles: resizeHandles,
|
|
567
|
+
handleComponent: resizeHandle
|
|
568
|
+
} = resizeConfig;
|
|
569
|
+
const { enabled: isDroppable, defaultItem: defaultDropItem } = dropConfig;
|
|
570
|
+
const compactor = compactorProp ?? chunkFN6MIZ24_js.getCompactor("vertical");
|
|
571
|
+
const compactType = compactor.type;
|
|
572
|
+
const allowOverlap = compactor.allowOverlap;
|
|
573
|
+
const preventCollision = compactor.preventCollision ?? false;
|
|
574
|
+
const droppingItem = React2.useMemo(
|
|
575
|
+
() => droppingItemProp ?? {
|
|
576
|
+
i: "__dropping-elem__",
|
|
577
|
+
...defaultDropItem
|
|
578
|
+
},
|
|
579
|
+
[droppingItemProp, defaultDropItem]
|
|
580
|
+
);
|
|
581
|
+
const useCSSTransforms = positionStrategy.type === "transform";
|
|
582
|
+
const transformScale = positionStrategy.scale;
|
|
583
|
+
const effectiveContainerPadding = containerPadding ?? margin;
|
|
584
|
+
const [mounted, setMounted] = React2.useState(false);
|
|
585
|
+
const [layout, setLayout] = React2.useState(
|
|
586
|
+
() => synchronizeLayoutWithChildren(
|
|
587
|
+
propsLayout,
|
|
588
|
+
children,
|
|
589
|
+
cols,
|
|
590
|
+
compactType,
|
|
591
|
+
allowOverlap
|
|
592
|
+
)
|
|
593
|
+
);
|
|
594
|
+
const [activeDrag, setActiveDrag] = React2.useState(null);
|
|
595
|
+
const [resizing, setResizing] = React2.useState(false);
|
|
596
|
+
const [droppingDOMNode, setDroppingDOMNode] = React2.useState(
|
|
597
|
+
null
|
|
598
|
+
);
|
|
599
|
+
const [droppingPosition, setDroppingPosition] = React2.useState();
|
|
600
|
+
const oldDragItemRef = React2.useRef(null);
|
|
601
|
+
const oldResizeItemRef = React2.useRef(null);
|
|
602
|
+
const oldLayoutRef = React2.useRef(null);
|
|
603
|
+
const dragEnterCounterRef = React2.useRef(0);
|
|
604
|
+
const prevLayoutRef = React2.useRef(layout);
|
|
605
|
+
const prevPropsLayoutRef = React2.useRef(propsLayout);
|
|
606
|
+
const prevChildrenRef = React2.useRef(children);
|
|
607
|
+
const prevCompactTypeRef = React2.useRef(compactType);
|
|
608
|
+
React2.useEffect(() => {
|
|
609
|
+
setMounted(true);
|
|
610
|
+
if (!fastEquals.deepEqual(layout, propsLayout)) {
|
|
611
|
+
onLayoutChange(layout);
|
|
612
|
+
}
|
|
613
|
+
}, []);
|
|
614
|
+
React2.useEffect(() => {
|
|
615
|
+
if (activeDrag) return;
|
|
616
|
+
const layoutChanged = !fastEquals.deepEqual(propsLayout, prevPropsLayoutRef.current);
|
|
617
|
+
const childrenChanged = !childrenEqual(children, prevChildrenRef.current);
|
|
618
|
+
const compactTypeChanged = compactType !== prevCompactTypeRef.current;
|
|
619
|
+
if (layoutChanged || childrenChanged || compactTypeChanged) {
|
|
620
|
+
const baseLayout = layoutChanged ? propsLayout : layout;
|
|
621
|
+
const newLayout = synchronizeLayoutWithChildren(
|
|
622
|
+
baseLayout,
|
|
623
|
+
children,
|
|
624
|
+
cols,
|
|
625
|
+
compactType,
|
|
626
|
+
allowOverlap
|
|
627
|
+
);
|
|
628
|
+
setLayout(newLayout);
|
|
629
|
+
}
|
|
630
|
+
prevPropsLayoutRef.current = propsLayout;
|
|
631
|
+
prevChildrenRef.current = children;
|
|
632
|
+
prevCompactTypeRef.current = compactType;
|
|
633
|
+
}, [
|
|
634
|
+
propsLayout,
|
|
635
|
+
children,
|
|
636
|
+
cols,
|
|
637
|
+
compactType,
|
|
638
|
+
allowOverlap,
|
|
639
|
+
activeDrag,
|
|
640
|
+
layout
|
|
641
|
+
]);
|
|
642
|
+
React2.useEffect(() => {
|
|
643
|
+
if (!activeDrag && !fastEquals.deepEqual(layout, prevLayoutRef.current)) {
|
|
644
|
+
prevLayoutRef.current = layout;
|
|
645
|
+
onLayoutChange(layout);
|
|
646
|
+
}
|
|
647
|
+
}, [layout, activeDrag, onLayoutChange]);
|
|
648
|
+
const containerHeight = React2.useMemo(() => {
|
|
649
|
+
if (!autoSize) return void 0;
|
|
650
|
+
const nbRow = chunkBJFPTW5Q_js.bottom(layout);
|
|
651
|
+
const containerPaddingY = effectiveContainerPadding[1];
|
|
652
|
+
return nbRow * rowHeight + (nbRow - 1) * margin[1] + containerPaddingY * 2 + "px";
|
|
653
|
+
}, [autoSize, layout, rowHeight, margin, effectiveContainerPadding]);
|
|
654
|
+
const onDragStart = React2.useCallback(
|
|
655
|
+
(i, _x, _y, data) => {
|
|
656
|
+
const l = chunkBJFPTW5Q_js.getLayoutItem(layout, i);
|
|
657
|
+
if (!l) return;
|
|
658
|
+
const placeholder = {
|
|
659
|
+
w: l.w,
|
|
660
|
+
h: l.h,
|
|
661
|
+
x: l.x,
|
|
662
|
+
y: l.y,
|
|
663
|
+
i
|
|
664
|
+
};
|
|
665
|
+
oldDragItemRef.current = chunkBJFPTW5Q_js.cloneLayoutItem(l);
|
|
666
|
+
oldLayoutRef.current = layout;
|
|
667
|
+
setActiveDrag(placeholder);
|
|
668
|
+
onDragStartProp(layout, l, l, null, data.e, data.node);
|
|
669
|
+
},
|
|
670
|
+
[layout, onDragStartProp]
|
|
671
|
+
);
|
|
672
|
+
const onDrag = React2.useCallback(
|
|
673
|
+
(i, x, y, data) => {
|
|
674
|
+
const oldDragItem = oldDragItemRef.current;
|
|
675
|
+
const l = chunkBJFPTW5Q_js.getLayoutItem(layout, i);
|
|
676
|
+
if (!l) return;
|
|
677
|
+
const placeholder = {
|
|
678
|
+
w: l.w,
|
|
679
|
+
h: l.h,
|
|
680
|
+
x: l.x,
|
|
681
|
+
y: l.y,
|
|
682
|
+
i
|
|
683
|
+
};
|
|
684
|
+
const newLayout = chunkBJFPTW5Q_js.moveElement(
|
|
685
|
+
layout,
|
|
686
|
+
l,
|
|
687
|
+
x,
|
|
688
|
+
y,
|
|
689
|
+
true,
|
|
690
|
+
preventCollision,
|
|
691
|
+
compactType,
|
|
692
|
+
cols,
|
|
693
|
+
allowOverlap
|
|
694
|
+
);
|
|
695
|
+
onDragProp(newLayout, oldDragItem, l, placeholder, data.e, data.node);
|
|
696
|
+
setLayout(
|
|
697
|
+
allowOverlap ? newLayout : chunkFN6MIZ24_js.compact(newLayout, compactType, cols)
|
|
698
|
+
);
|
|
699
|
+
setActiveDrag(placeholder);
|
|
700
|
+
},
|
|
701
|
+
[layout, preventCollision, compactType, cols, allowOverlap, onDragProp]
|
|
702
|
+
);
|
|
703
|
+
const onDragStop = React2.useCallback(
|
|
704
|
+
(i, x, y, data) => {
|
|
705
|
+
if (!activeDrag) return;
|
|
706
|
+
const oldDragItem = oldDragItemRef.current;
|
|
707
|
+
const l = chunkBJFPTW5Q_js.getLayoutItem(layout, i);
|
|
708
|
+
if (!l) return;
|
|
709
|
+
const newLayout = chunkBJFPTW5Q_js.moveElement(
|
|
710
|
+
layout,
|
|
711
|
+
l,
|
|
712
|
+
x,
|
|
713
|
+
y,
|
|
714
|
+
true,
|
|
715
|
+
preventCollision,
|
|
716
|
+
compactType,
|
|
717
|
+
cols,
|
|
718
|
+
allowOverlap
|
|
719
|
+
);
|
|
720
|
+
const finalLayout = allowOverlap ? newLayout : chunkFN6MIZ24_js.compact(newLayout, compactType, cols);
|
|
721
|
+
onDragStopProp(finalLayout, oldDragItem, l, null, data.e, data.node);
|
|
722
|
+
const oldLayout = oldLayoutRef.current;
|
|
723
|
+
oldDragItemRef.current = null;
|
|
724
|
+
oldLayoutRef.current = null;
|
|
725
|
+
setActiveDrag(null);
|
|
726
|
+
setLayout(finalLayout);
|
|
727
|
+
if (oldLayout && !fastEquals.deepEqual(oldLayout, finalLayout)) {
|
|
728
|
+
onLayoutChange(finalLayout);
|
|
729
|
+
}
|
|
730
|
+
},
|
|
731
|
+
[
|
|
732
|
+
activeDrag,
|
|
733
|
+
layout,
|
|
734
|
+
preventCollision,
|
|
735
|
+
compactType,
|
|
736
|
+
cols,
|
|
737
|
+
allowOverlap,
|
|
738
|
+
onDragStopProp,
|
|
739
|
+
onLayoutChange
|
|
740
|
+
]
|
|
741
|
+
);
|
|
742
|
+
const onResizeStart = React2.useCallback(
|
|
743
|
+
(i, _w, _h, data) => {
|
|
744
|
+
const l = chunkBJFPTW5Q_js.getLayoutItem(layout, i);
|
|
745
|
+
if (!l) return;
|
|
746
|
+
oldResizeItemRef.current = chunkBJFPTW5Q_js.cloneLayoutItem(l);
|
|
747
|
+
oldLayoutRef.current = layout;
|
|
748
|
+
setResizing(true);
|
|
749
|
+
onResizeStartProp(layout, l, l, null, data.e, data.node);
|
|
750
|
+
},
|
|
751
|
+
[layout, onResizeStartProp]
|
|
752
|
+
);
|
|
753
|
+
const onResize = React2.useCallback(
|
|
754
|
+
(i, w, h, data) => {
|
|
755
|
+
const oldResizeItem = oldResizeItemRef.current;
|
|
756
|
+
const { handle } = data;
|
|
757
|
+
let shouldMoveItem = false;
|
|
758
|
+
let newX;
|
|
759
|
+
let newY;
|
|
760
|
+
const [newLayout, l] = chunkBJFPTW5Q_js.withLayoutItem(layout, i, (item) => {
|
|
761
|
+
newX = item.x;
|
|
762
|
+
newY = item.y;
|
|
763
|
+
if (["sw", "w", "nw", "n", "ne"].includes(handle)) {
|
|
764
|
+
if (["sw", "nw", "w"].includes(handle)) {
|
|
765
|
+
newX = item.x + (item.w - w);
|
|
766
|
+
w = item.x !== newX && newX < 0 ? item.w : w;
|
|
767
|
+
newX = newX < 0 ? 0 : newX;
|
|
768
|
+
}
|
|
769
|
+
if (["ne", "n", "nw"].includes(handle)) {
|
|
770
|
+
newY = item.y + (item.h - h);
|
|
771
|
+
h = item.y !== newY && newY < 0 ? item.h : h;
|
|
772
|
+
newY = newY < 0 ? 0 : newY;
|
|
773
|
+
}
|
|
774
|
+
shouldMoveItem = true;
|
|
775
|
+
}
|
|
776
|
+
if (preventCollision && !allowOverlap) {
|
|
777
|
+
const collisions = chunkBJFPTW5Q_js.getAllCollisions(layout, {
|
|
778
|
+
...item,
|
|
779
|
+
w,
|
|
780
|
+
h,
|
|
781
|
+
x: newX ?? item.x,
|
|
782
|
+
y: newY ?? item.y
|
|
783
|
+
}).filter((layoutItem) => layoutItem.i !== item.i);
|
|
784
|
+
if (collisions.length > 0) {
|
|
785
|
+
newY = item.y;
|
|
786
|
+
h = item.h;
|
|
787
|
+
newX = item.x;
|
|
788
|
+
w = item.w;
|
|
789
|
+
shouldMoveItem = false;
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
item.w = w;
|
|
793
|
+
item.h = h;
|
|
794
|
+
return item;
|
|
795
|
+
});
|
|
796
|
+
if (!l) return;
|
|
797
|
+
let finalLayout = newLayout;
|
|
798
|
+
if (shouldMoveItem && newX !== void 0 && newY !== void 0) {
|
|
799
|
+
finalLayout = chunkBJFPTW5Q_js.moveElement(
|
|
800
|
+
newLayout,
|
|
801
|
+
l,
|
|
802
|
+
newX,
|
|
803
|
+
newY,
|
|
804
|
+
true,
|
|
805
|
+
preventCollision,
|
|
806
|
+
compactType,
|
|
807
|
+
cols,
|
|
808
|
+
allowOverlap
|
|
809
|
+
);
|
|
810
|
+
}
|
|
811
|
+
const placeholder = {
|
|
812
|
+
w: l.w,
|
|
813
|
+
h: l.h,
|
|
814
|
+
x: l.x,
|
|
815
|
+
y: l.y,
|
|
816
|
+
i,
|
|
817
|
+
static: true
|
|
818
|
+
};
|
|
819
|
+
onResizeProp(
|
|
820
|
+
finalLayout,
|
|
821
|
+
oldResizeItem,
|
|
822
|
+
l,
|
|
823
|
+
placeholder,
|
|
824
|
+
data.e,
|
|
825
|
+
data.node
|
|
826
|
+
);
|
|
827
|
+
setLayout(
|
|
828
|
+
allowOverlap ? finalLayout : chunkFN6MIZ24_js.compact(finalLayout, compactType, cols)
|
|
829
|
+
);
|
|
830
|
+
setActiveDrag(placeholder);
|
|
831
|
+
},
|
|
832
|
+
[layout, preventCollision, allowOverlap, compactType, cols, onResizeProp]
|
|
833
|
+
);
|
|
834
|
+
const onResizeStop = React2.useCallback(
|
|
835
|
+
(i, _w, _h, data) => {
|
|
836
|
+
const oldResizeItem = oldResizeItemRef.current;
|
|
837
|
+
const l = chunkBJFPTW5Q_js.getLayoutItem(layout, i);
|
|
838
|
+
const finalLayout = allowOverlap ? layout : chunkFN6MIZ24_js.compact(layout, compactType, cols);
|
|
839
|
+
onResizeStopProp(
|
|
840
|
+
finalLayout,
|
|
841
|
+
oldResizeItem,
|
|
842
|
+
l ?? null,
|
|
843
|
+
null,
|
|
844
|
+
data.e,
|
|
845
|
+
data.node
|
|
846
|
+
);
|
|
847
|
+
const oldLayout = oldLayoutRef.current;
|
|
848
|
+
oldResizeItemRef.current = null;
|
|
849
|
+
oldLayoutRef.current = null;
|
|
850
|
+
setActiveDrag(null);
|
|
851
|
+
setResizing(false);
|
|
852
|
+
setLayout(finalLayout);
|
|
853
|
+
if (oldLayout && !fastEquals.deepEqual(oldLayout, finalLayout)) {
|
|
854
|
+
onLayoutChange(finalLayout);
|
|
855
|
+
}
|
|
856
|
+
},
|
|
857
|
+
[layout, allowOverlap, compactType, cols, onResizeStopProp, onLayoutChange]
|
|
858
|
+
);
|
|
859
|
+
const removeDroppingPlaceholder = React2.useCallback(() => {
|
|
860
|
+
const newLayout = chunkFN6MIZ24_js.compact(
|
|
861
|
+
layout.filter((l) => l.i !== droppingItem.i),
|
|
862
|
+
compactType,
|
|
863
|
+
cols,
|
|
864
|
+
allowOverlap
|
|
865
|
+
);
|
|
866
|
+
setLayout(newLayout);
|
|
867
|
+
setDroppingDOMNode(null);
|
|
868
|
+
setActiveDrag(null);
|
|
869
|
+
setDroppingPosition(void 0);
|
|
870
|
+
}, [layout, droppingItem.i, compactType, cols, allowOverlap]);
|
|
871
|
+
const handleDragOver = React2.useCallback(
|
|
872
|
+
(e) => {
|
|
873
|
+
e.preventDefault();
|
|
874
|
+
e.stopPropagation();
|
|
875
|
+
if (isFirefox && !e.nativeEvent.target?.classList.contains(
|
|
876
|
+
layoutClassName
|
|
877
|
+
)) {
|
|
878
|
+
return false;
|
|
879
|
+
}
|
|
880
|
+
const rawResult = onDropDragOverProp(e);
|
|
881
|
+
if (rawResult === false) {
|
|
882
|
+
if (droppingDOMNode) {
|
|
883
|
+
removeDroppingPlaceholder();
|
|
884
|
+
}
|
|
885
|
+
return false;
|
|
886
|
+
}
|
|
887
|
+
const {
|
|
888
|
+
dragOffsetX = 0,
|
|
889
|
+
dragOffsetY = 0,
|
|
890
|
+
...onDragOverResult
|
|
891
|
+
} = rawResult ?? {};
|
|
892
|
+
const finalDroppingItem = { ...droppingItem, ...onDragOverResult };
|
|
893
|
+
const gridRect = e.currentTarget.getBoundingClientRect();
|
|
894
|
+
const positionParams = {
|
|
895
|
+
cols,
|
|
896
|
+
margin,
|
|
897
|
+
maxRows,
|
|
898
|
+
rowHeight,
|
|
899
|
+
containerWidth: width,
|
|
900
|
+
containerPadding: effectiveContainerPadding
|
|
901
|
+
};
|
|
902
|
+
const actualColWidth = chunkBJFPTW5Q_js.calcGridColWidth(positionParams);
|
|
903
|
+
const itemPixelWidth = chunkBJFPTW5Q_js.calcGridItemWHPx(
|
|
904
|
+
finalDroppingItem.w,
|
|
905
|
+
actualColWidth,
|
|
906
|
+
margin[0]
|
|
907
|
+
);
|
|
908
|
+
const itemPixelHeight = chunkBJFPTW5Q_js.calcGridItemWHPx(
|
|
909
|
+
finalDroppingItem.h,
|
|
910
|
+
rowHeight,
|
|
911
|
+
margin[1]
|
|
912
|
+
);
|
|
913
|
+
const itemCenterOffsetX = itemPixelWidth / 2;
|
|
914
|
+
const itemCenterOffsetY = itemPixelHeight / 2;
|
|
915
|
+
const rawGridX = e.clientX - gridRect.left + dragOffsetX - itemCenterOffsetX;
|
|
916
|
+
const rawGridY = e.clientY - gridRect.top + dragOffsetY - itemCenterOffsetY;
|
|
917
|
+
const clampedGridX = Math.max(0, rawGridX);
|
|
918
|
+
const clampedGridY = Math.max(0, rawGridY);
|
|
919
|
+
const newDroppingPosition = {
|
|
920
|
+
left: clampedGridX / transformScale,
|
|
921
|
+
top: clampedGridY / transformScale,
|
|
922
|
+
e: e.nativeEvent
|
|
923
|
+
};
|
|
924
|
+
if (!droppingDOMNode) {
|
|
925
|
+
const calculatedPosition = chunkBJFPTW5Q_js.calcXY(
|
|
926
|
+
positionParams,
|
|
927
|
+
clampedGridY,
|
|
928
|
+
clampedGridX,
|
|
929
|
+
finalDroppingItem.w,
|
|
930
|
+
finalDroppingItem.h
|
|
931
|
+
);
|
|
932
|
+
setDroppingDOMNode(/* @__PURE__ */ jsxRuntime.jsx("div", {}, finalDroppingItem.i));
|
|
933
|
+
setDroppingPosition(newDroppingPosition);
|
|
934
|
+
setLayout([
|
|
935
|
+
...layout,
|
|
936
|
+
{
|
|
937
|
+
...finalDroppingItem,
|
|
938
|
+
x: calculatedPosition.x,
|
|
939
|
+
y: calculatedPosition.y,
|
|
940
|
+
static: false,
|
|
941
|
+
isDraggable: true
|
|
942
|
+
}
|
|
943
|
+
]);
|
|
944
|
+
} else if (droppingPosition) {
|
|
945
|
+
const shouldUpdate = droppingPosition.left !== newDroppingPosition.left || droppingPosition.top !== newDroppingPosition.top;
|
|
946
|
+
if (shouldUpdate) {
|
|
947
|
+
setDroppingPosition(newDroppingPosition);
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
},
|
|
951
|
+
[
|
|
952
|
+
droppingDOMNode,
|
|
953
|
+
droppingPosition,
|
|
954
|
+
droppingItem,
|
|
955
|
+
onDropDragOverProp,
|
|
956
|
+
removeDroppingPlaceholder,
|
|
957
|
+
transformScale,
|
|
958
|
+
cols,
|
|
959
|
+
margin,
|
|
960
|
+
maxRows,
|
|
961
|
+
rowHeight,
|
|
962
|
+
width,
|
|
963
|
+
effectiveContainerPadding,
|
|
964
|
+
layout
|
|
965
|
+
]
|
|
966
|
+
);
|
|
967
|
+
const handleDragLeave = React2.useCallback(
|
|
968
|
+
(e) => {
|
|
969
|
+
e.preventDefault();
|
|
970
|
+
e.stopPropagation();
|
|
971
|
+
dragEnterCounterRef.current--;
|
|
972
|
+
if (dragEnterCounterRef.current === 0) {
|
|
973
|
+
removeDroppingPlaceholder();
|
|
974
|
+
}
|
|
975
|
+
},
|
|
976
|
+
[removeDroppingPlaceholder]
|
|
977
|
+
);
|
|
978
|
+
const handleDragEnter = React2.useCallback((e) => {
|
|
979
|
+
e.preventDefault();
|
|
980
|
+
e.stopPropagation();
|
|
981
|
+
dragEnterCounterRef.current++;
|
|
982
|
+
}, []);
|
|
983
|
+
const handleDrop = React2.useCallback(
|
|
984
|
+
(e) => {
|
|
985
|
+
e.preventDefault();
|
|
986
|
+
e.stopPropagation();
|
|
987
|
+
const item = layout.find((l) => l.i === droppingItem.i);
|
|
988
|
+
dragEnterCounterRef.current = 0;
|
|
989
|
+
removeDroppingPlaceholder();
|
|
990
|
+
onDropProp(layout, item, e.nativeEvent);
|
|
991
|
+
},
|
|
992
|
+
[layout, droppingItem.i, removeDroppingPlaceholder, onDropProp]
|
|
993
|
+
);
|
|
994
|
+
const processGridItem = React2.useCallback(
|
|
995
|
+
(child, isDroppingItem) => {
|
|
996
|
+
if (!child || !child.key) return null;
|
|
997
|
+
const l = chunkBJFPTW5Q_js.getLayoutItem(layout, String(child.key));
|
|
998
|
+
if (!l) return null;
|
|
999
|
+
const draggable = typeof l.isDraggable === "boolean" ? l.isDraggable : !l.static && isDraggable;
|
|
1000
|
+
const resizable = typeof l.isResizable === "boolean" ? l.isResizable : !l.static && isResizable;
|
|
1001
|
+
const resizeHandlesOptions = l.resizeHandles || [...resizeHandles];
|
|
1002
|
+
const bounded = draggable && isBounded && l.isBounded !== false;
|
|
1003
|
+
const resizeHandleElement = resizeHandle;
|
|
1004
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1005
|
+
GridItem,
|
|
1006
|
+
{
|
|
1007
|
+
containerWidth: width,
|
|
1008
|
+
cols,
|
|
1009
|
+
margin,
|
|
1010
|
+
containerPadding: effectiveContainerPadding,
|
|
1011
|
+
maxRows,
|
|
1012
|
+
rowHeight,
|
|
1013
|
+
cancel: draggableCancel,
|
|
1014
|
+
handle: draggableHandle,
|
|
1015
|
+
onDragStart,
|
|
1016
|
+
onDrag,
|
|
1017
|
+
onDragStop,
|
|
1018
|
+
onResizeStart,
|
|
1019
|
+
onResize,
|
|
1020
|
+
onResizeStop,
|
|
1021
|
+
isDraggable: draggable,
|
|
1022
|
+
isResizable: resizable,
|
|
1023
|
+
isBounded: bounded,
|
|
1024
|
+
useCSSTransforms: useCSSTransforms && mounted,
|
|
1025
|
+
usePercentages: !mounted,
|
|
1026
|
+
transformScale,
|
|
1027
|
+
w: l.w,
|
|
1028
|
+
h: l.h,
|
|
1029
|
+
x: l.x,
|
|
1030
|
+
y: l.y,
|
|
1031
|
+
i: l.i,
|
|
1032
|
+
minH: l.minH,
|
|
1033
|
+
minW: l.minW,
|
|
1034
|
+
maxH: l.maxH,
|
|
1035
|
+
maxW: l.maxW,
|
|
1036
|
+
static: l.static,
|
|
1037
|
+
droppingPosition: isDroppingItem ? droppingPosition : void 0,
|
|
1038
|
+
resizeHandles: resizeHandlesOptions,
|
|
1039
|
+
resizeHandle: resizeHandleElement,
|
|
1040
|
+
constraints,
|
|
1041
|
+
layoutItem: l,
|
|
1042
|
+
layout,
|
|
1043
|
+
children: child
|
|
1044
|
+
},
|
|
1045
|
+
l.i
|
|
1046
|
+
);
|
|
1047
|
+
},
|
|
1048
|
+
[
|
|
1049
|
+
layout,
|
|
1050
|
+
width,
|
|
1051
|
+
cols,
|
|
1052
|
+
margin,
|
|
1053
|
+
effectiveContainerPadding,
|
|
1054
|
+
maxRows,
|
|
1055
|
+
rowHeight,
|
|
1056
|
+
draggableCancel,
|
|
1057
|
+
draggableHandle,
|
|
1058
|
+
onDragStart,
|
|
1059
|
+
onDrag,
|
|
1060
|
+
onDragStop,
|
|
1061
|
+
onResizeStart,
|
|
1062
|
+
onResize,
|
|
1063
|
+
onResizeStop,
|
|
1064
|
+
isDraggable,
|
|
1065
|
+
isResizable,
|
|
1066
|
+
isBounded,
|
|
1067
|
+
useCSSTransforms,
|
|
1068
|
+
mounted,
|
|
1069
|
+
transformScale,
|
|
1070
|
+
droppingPosition,
|
|
1071
|
+
resizeHandles,
|
|
1072
|
+
resizeHandle,
|
|
1073
|
+
constraints
|
|
1074
|
+
]
|
|
1075
|
+
);
|
|
1076
|
+
const renderPlaceholder = () => {
|
|
1077
|
+
if (!activeDrag) return null;
|
|
1078
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1079
|
+
GridItem,
|
|
1080
|
+
{
|
|
1081
|
+
w: activeDrag.w,
|
|
1082
|
+
h: activeDrag.h,
|
|
1083
|
+
x: activeDrag.x,
|
|
1084
|
+
y: activeDrag.y,
|
|
1085
|
+
i: activeDrag.i,
|
|
1086
|
+
className: `react-grid-placeholder ${resizing ? "placeholder-resizing" : ""}`,
|
|
1087
|
+
containerWidth: width,
|
|
1088
|
+
cols,
|
|
1089
|
+
margin,
|
|
1090
|
+
containerPadding: effectiveContainerPadding,
|
|
1091
|
+
maxRows,
|
|
1092
|
+
rowHeight,
|
|
1093
|
+
isDraggable: false,
|
|
1094
|
+
isResizable: false,
|
|
1095
|
+
isBounded: false,
|
|
1096
|
+
useCSSTransforms,
|
|
1097
|
+
transformScale,
|
|
1098
|
+
constraints,
|
|
1099
|
+
layout,
|
|
1100
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", {})
|
|
1101
|
+
}
|
|
1102
|
+
);
|
|
1103
|
+
};
|
|
1104
|
+
const mergedClassName = clsx__default.default(layoutClassName, className);
|
|
1105
|
+
const mergedStyle = {
|
|
1106
|
+
height: containerHeight,
|
|
1107
|
+
...style
|
|
1108
|
+
};
|
|
1109
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1110
|
+
"div",
|
|
1111
|
+
{
|
|
1112
|
+
ref: innerRef,
|
|
1113
|
+
className: mergedClassName,
|
|
1114
|
+
style: mergedStyle,
|
|
1115
|
+
onDrop: isDroppable ? handleDrop : void 0,
|
|
1116
|
+
onDragLeave: isDroppable ? handleDragLeave : void 0,
|
|
1117
|
+
onDragEnter: isDroppable ? handleDragEnter : void 0,
|
|
1118
|
+
onDragOver: isDroppable ? handleDragOver : void 0,
|
|
1119
|
+
children: [
|
|
1120
|
+
React2__default.default.Children.map(children, (child) => {
|
|
1121
|
+
if (!React2__default.default.isValidElement(child)) return null;
|
|
1122
|
+
return processGridItem(child);
|
|
1123
|
+
}),
|
|
1124
|
+
isDroppable && droppingDOMNode && processGridItem(droppingDOMNode, true),
|
|
1125
|
+
renderPlaceholder()
|
|
1126
|
+
]
|
|
1127
|
+
}
|
|
1128
|
+
);
|
|
1129
|
+
}
|
|
1130
|
+
var DEFAULT_BREAKPOINTS = {
|
|
1131
|
+
lg: 1200,
|
|
1132
|
+
md: 996,
|
|
1133
|
+
sm: 768,
|
|
1134
|
+
xs: 480,
|
|
1135
|
+
xxs: 0
|
|
1136
|
+
};
|
|
1137
|
+
var DEFAULT_COLS = {
|
|
1138
|
+
lg: 12,
|
|
1139
|
+
md: 10,
|
|
1140
|
+
sm: 6,
|
|
1141
|
+
xs: 4,
|
|
1142
|
+
xxs: 2
|
|
1143
|
+
};
|
|
1144
|
+
var noop2 = () => {
|
|
1145
|
+
};
|
|
1146
|
+
function synchronizeLayoutWithChildren2(initialLayout, children, cols, compactType, allowOverlap) {
|
|
1147
|
+
const layout = [];
|
|
1148
|
+
React2__default.default.Children.forEach(children, (child) => {
|
|
1149
|
+
if (!React2__default.default.isValidElement(child) || child.key === null) return;
|
|
1150
|
+
const key = String(child.key);
|
|
1151
|
+
const existingItem = initialLayout.find((l) => l.i === key);
|
|
1152
|
+
if (existingItem) {
|
|
1153
|
+
layout.push({
|
|
1154
|
+
...existingItem,
|
|
1155
|
+
i: key
|
|
1156
|
+
});
|
|
1157
|
+
} else {
|
|
1158
|
+
const childProps = child.props;
|
|
1159
|
+
const dataGrid = childProps["data-grid"];
|
|
1160
|
+
if (dataGrid) {
|
|
1161
|
+
layout.push({
|
|
1162
|
+
i: key,
|
|
1163
|
+
x: dataGrid.x ?? 0,
|
|
1164
|
+
y: dataGrid.y ?? 0,
|
|
1165
|
+
w: dataGrid.w ?? 1,
|
|
1166
|
+
h: dataGrid.h ?? 1,
|
|
1167
|
+
minW: dataGrid.minW,
|
|
1168
|
+
maxW: dataGrid.maxW,
|
|
1169
|
+
minH: dataGrid.minH,
|
|
1170
|
+
maxH: dataGrid.maxH,
|
|
1171
|
+
static: dataGrid.static,
|
|
1172
|
+
isDraggable: dataGrid.isDraggable,
|
|
1173
|
+
isResizable: dataGrid.isResizable,
|
|
1174
|
+
resizeHandles: dataGrid.resizeHandles,
|
|
1175
|
+
isBounded: dataGrid.isBounded
|
|
1176
|
+
});
|
|
1177
|
+
} else {
|
|
1178
|
+
layout.push({
|
|
1179
|
+
i: key,
|
|
1180
|
+
x: 0,
|
|
1181
|
+
y: chunkBJFPTW5Q_js.bottom(layout),
|
|
1182
|
+
w: 1,
|
|
1183
|
+
h: 1
|
|
1184
|
+
});
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
});
|
|
1188
|
+
const corrected = chunkBJFPTW5Q_js.correctBounds(layout, { cols });
|
|
1189
|
+
return chunkFN6MIZ24_js.compact(corrected, compactType, cols, allowOverlap);
|
|
1190
|
+
}
|
|
1191
|
+
function ResponsiveGridLayout(props) {
|
|
1192
|
+
const {
|
|
1193
|
+
children,
|
|
1194
|
+
width,
|
|
1195
|
+
breakpoint: propBreakpoint,
|
|
1196
|
+
breakpoints = DEFAULT_BREAKPOINTS,
|
|
1197
|
+
cols: colsConfig = DEFAULT_COLS,
|
|
1198
|
+
layouts: propsLayouts = {},
|
|
1199
|
+
rowHeight = 150,
|
|
1200
|
+
maxRows = Infinity,
|
|
1201
|
+
margin: propMargin = [10, 10],
|
|
1202
|
+
containerPadding: propContainerPadding = null,
|
|
1203
|
+
compactor: compactorProp,
|
|
1204
|
+
onBreakpointChange = noop2,
|
|
1205
|
+
onLayoutChange = noop2,
|
|
1206
|
+
onWidthChange = noop2,
|
|
1207
|
+
...restProps
|
|
1208
|
+
} = props;
|
|
1209
|
+
const compactor = compactorProp ?? chunkFN6MIZ24_js.getCompactor("vertical");
|
|
1210
|
+
const compactType = compactor.type;
|
|
1211
|
+
const allowOverlap = compactor.allowOverlap;
|
|
1212
|
+
const initialBreakpoint = React2.useMemo(() => {
|
|
1213
|
+
return propBreakpoint ?? chunkFN6MIZ24_js.getBreakpointFromWidth(breakpoints, width);
|
|
1214
|
+
}, []);
|
|
1215
|
+
const initialCols = React2.useMemo(() => {
|
|
1216
|
+
return chunkFN6MIZ24_js.getColsFromBreakpoint(initialBreakpoint, colsConfig);
|
|
1217
|
+
}, [initialBreakpoint, colsConfig]);
|
|
1218
|
+
const initialLayout = React2.useMemo(() => {
|
|
1219
|
+
return chunkFN6MIZ24_js.findOrGenerateResponsiveLayout(
|
|
1220
|
+
propsLayouts,
|
|
1221
|
+
breakpoints,
|
|
1222
|
+
initialBreakpoint,
|
|
1223
|
+
initialBreakpoint,
|
|
1224
|
+
initialCols,
|
|
1225
|
+
compactType
|
|
1226
|
+
);
|
|
1227
|
+
}, []);
|
|
1228
|
+
const [breakpoint, setBreakpoint] = React2.useState(initialBreakpoint);
|
|
1229
|
+
const [cols, setCols] = React2.useState(initialCols);
|
|
1230
|
+
const [layout, setLayout] = React2.useState(initialLayout);
|
|
1231
|
+
const [layouts, setLayouts] = React2.useState(propsLayouts);
|
|
1232
|
+
const prevWidthRef = React2.useRef(width);
|
|
1233
|
+
const prevBreakpointRef = React2.useRef(propBreakpoint);
|
|
1234
|
+
const prevBreakpointsRef = React2.useRef(breakpoints);
|
|
1235
|
+
const prevColsRef = React2.useRef(colsConfig);
|
|
1236
|
+
const prevLayoutsRef = React2.useRef(propsLayouts);
|
|
1237
|
+
const prevCompactTypeRef = React2.useRef(compactType);
|
|
1238
|
+
const layoutsRef = React2.useRef(layouts);
|
|
1239
|
+
React2.useEffect(() => {
|
|
1240
|
+
layoutsRef.current = layouts;
|
|
1241
|
+
}, [layouts]);
|
|
1242
|
+
const derivedLayout = React2.useMemo(() => {
|
|
1243
|
+
if (!fastEquals.deepEqual(propsLayouts, prevLayoutsRef.current)) {
|
|
1244
|
+
return chunkFN6MIZ24_js.findOrGenerateResponsiveLayout(
|
|
1245
|
+
propsLayouts,
|
|
1246
|
+
breakpoints,
|
|
1247
|
+
breakpoint,
|
|
1248
|
+
breakpoint,
|
|
1249
|
+
cols,
|
|
1250
|
+
compactType
|
|
1251
|
+
);
|
|
1252
|
+
}
|
|
1253
|
+
return null;
|
|
1254
|
+
}, [propsLayouts, breakpoints, breakpoint, cols, compactType]);
|
|
1255
|
+
const effectiveLayout = derivedLayout ?? layout;
|
|
1256
|
+
React2.useEffect(() => {
|
|
1257
|
+
if (derivedLayout !== null) {
|
|
1258
|
+
setLayout(derivedLayout);
|
|
1259
|
+
setLayouts(propsLayouts);
|
|
1260
|
+
layoutsRef.current = propsLayouts;
|
|
1261
|
+
prevLayoutsRef.current = propsLayouts;
|
|
1262
|
+
}
|
|
1263
|
+
}, [derivedLayout, propsLayouts]);
|
|
1264
|
+
React2.useEffect(() => {
|
|
1265
|
+
if (compactType !== prevCompactTypeRef.current) {
|
|
1266
|
+
const newLayout = chunkFN6MIZ24_js.compact(
|
|
1267
|
+
chunkBJFPTW5Q_js.cloneLayout(effectiveLayout),
|
|
1268
|
+
compactType,
|
|
1269
|
+
cols,
|
|
1270
|
+
allowOverlap
|
|
1271
|
+
);
|
|
1272
|
+
const newLayouts = {
|
|
1273
|
+
...layoutsRef.current,
|
|
1274
|
+
[breakpoint]: newLayout
|
|
1275
|
+
};
|
|
1276
|
+
setLayout(newLayout);
|
|
1277
|
+
setLayouts(newLayouts);
|
|
1278
|
+
layoutsRef.current = newLayouts;
|
|
1279
|
+
onLayoutChange(newLayout, newLayouts);
|
|
1280
|
+
prevCompactTypeRef.current = compactType;
|
|
1281
|
+
}
|
|
1282
|
+
}, [
|
|
1283
|
+
compactType,
|
|
1284
|
+
effectiveLayout,
|
|
1285
|
+
cols,
|
|
1286
|
+
allowOverlap,
|
|
1287
|
+
breakpoint,
|
|
1288
|
+
onLayoutChange
|
|
1289
|
+
]);
|
|
1290
|
+
React2.useEffect(() => {
|
|
1291
|
+
const widthChanged = width !== prevWidthRef.current;
|
|
1292
|
+
const breakpointPropChanged = propBreakpoint !== prevBreakpointRef.current;
|
|
1293
|
+
const breakpointsChanged = !fastEquals.deepEqual(
|
|
1294
|
+
breakpoints,
|
|
1295
|
+
prevBreakpointsRef.current
|
|
1296
|
+
);
|
|
1297
|
+
const colsChanged = !fastEquals.deepEqual(colsConfig, prevColsRef.current);
|
|
1298
|
+
if (widthChanged || breakpointPropChanged || breakpointsChanged || colsChanged) {
|
|
1299
|
+
const newBreakpoint = propBreakpoint ?? chunkFN6MIZ24_js.getBreakpointFromWidth(breakpoints, width);
|
|
1300
|
+
const newCols = chunkFN6MIZ24_js.getColsFromBreakpoint(newBreakpoint, colsConfig);
|
|
1301
|
+
const lastBreakpoint = breakpoint;
|
|
1302
|
+
if (lastBreakpoint !== newBreakpoint || breakpointsChanged || colsChanged) {
|
|
1303
|
+
const newLayouts = { ...layoutsRef.current };
|
|
1304
|
+
if (!newLayouts[lastBreakpoint]) {
|
|
1305
|
+
newLayouts[lastBreakpoint] = chunkBJFPTW5Q_js.cloneLayout(layout);
|
|
1306
|
+
}
|
|
1307
|
+
let newLayout = chunkFN6MIZ24_js.findOrGenerateResponsiveLayout(
|
|
1308
|
+
newLayouts,
|
|
1309
|
+
breakpoints,
|
|
1310
|
+
newBreakpoint,
|
|
1311
|
+
lastBreakpoint,
|
|
1312
|
+
newCols,
|
|
1313
|
+
compactType
|
|
1314
|
+
);
|
|
1315
|
+
newLayout = synchronizeLayoutWithChildren2(
|
|
1316
|
+
newLayout,
|
|
1317
|
+
children,
|
|
1318
|
+
newCols,
|
|
1319
|
+
compactType,
|
|
1320
|
+
allowOverlap
|
|
1321
|
+
);
|
|
1322
|
+
newLayouts[newBreakpoint] = newLayout;
|
|
1323
|
+
setBreakpoint(newBreakpoint);
|
|
1324
|
+
setCols(newCols);
|
|
1325
|
+
setLayout(newLayout);
|
|
1326
|
+
setLayouts(newLayouts);
|
|
1327
|
+
layoutsRef.current = newLayouts;
|
|
1328
|
+
onBreakpointChange(newBreakpoint, newCols);
|
|
1329
|
+
onLayoutChange(newLayout, newLayouts);
|
|
1330
|
+
}
|
|
1331
|
+
const currentMargin2 = chunkFN6MIZ24_js.getIndentationValue(
|
|
1332
|
+
propMargin,
|
|
1333
|
+
newBreakpoint
|
|
1334
|
+
);
|
|
1335
|
+
const currentPadding = propContainerPadding ? chunkFN6MIZ24_js.getIndentationValue(
|
|
1336
|
+
propContainerPadding,
|
|
1337
|
+
newBreakpoint
|
|
1338
|
+
) : null;
|
|
1339
|
+
onWidthChange(width, currentMargin2, newCols, currentPadding);
|
|
1340
|
+
prevWidthRef.current = width;
|
|
1341
|
+
prevBreakpointRef.current = propBreakpoint;
|
|
1342
|
+
prevBreakpointsRef.current = breakpoints;
|
|
1343
|
+
prevColsRef.current = colsConfig;
|
|
1344
|
+
}
|
|
1345
|
+
}, [
|
|
1346
|
+
width,
|
|
1347
|
+
propBreakpoint,
|
|
1348
|
+
breakpoints,
|
|
1349
|
+
colsConfig,
|
|
1350
|
+
breakpoint,
|
|
1351
|
+
cols,
|
|
1352
|
+
layout,
|
|
1353
|
+
children,
|
|
1354
|
+
compactType,
|
|
1355
|
+
allowOverlap,
|
|
1356
|
+
propMargin,
|
|
1357
|
+
propContainerPadding,
|
|
1358
|
+
onBreakpointChange,
|
|
1359
|
+
onLayoutChange,
|
|
1360
|
+
onWidthChange
|
|
1361
|
+
]);
|
|
1362
|
+
const handleLayoutChange = React2.useCallback(
|
|
1363
|
+
(newLayout) => {
|
|
1364
|
+
const currentLayouts = layoutsRef.current;
|
|
1365
|
+
const newLayouts = {
|
|
1366
|
+
...currentLayouts,
|
|
1367
|
+
[breakpoint]: newLayout
|
|
1368
|
+
};
|
|
1369
|
+
setLayout(newLayout);
|
|
1370
|
+
setLayouts(newLayouts);
|
|
1371
|
+
layoutsRef.current = newLayouts;
|
|
1372
|
+
onLayoutChange(newLayout, newLayouts);
|
|
1373
|
+
},
|
|
1374
|
+
[breakpoint, onLayoutChange]
|
|
1375
|
+
);
|
|
1376
|
+
const currentMargin = React2.useMemo(() => {
|
|
1377
|
+
return chunkFN6MIZ24_js.getIndentationValue(
|
|
1378
|
+
propMargin,
|
|
1379
|
+
breakpoint
|
|
1380
|
+
);
|
|
1381
|
+
}, [propMargin, breakpoint]);
|
|
1382
|
+
const currentContainerPadding = React2.useMemo(() => {
|
|
1383
|
+
if (propContainerPadding === null) return null;
|
|
1384
|
+
return chunkFN6MIZ24_js.getIndentationValue(
|
|
1385
|
+
propContainerPadding,
|
|
1386
|
+
breakpoint
|
|
1387
|
+
);
|
|
1388
|
+
}, [propContainerPadding, breakpoint]);
|
|
1389
|
+
const gridConfig = React2.useMemo(
|
|
1390
|
+
() => ({
|
|
1391
|
+
cols,
|
|
1392
|
+
rowHeight,
|
|
1393
|
+
maxRows,
|
|
1394
|
+
margin: currentMargin,
|
|
1395
|
+
containerPadding: currentContainerPadding
|
|
1396
|
+
}),
|
|
1397
|
+
[cols, rowHeight, maxRows, currentMargin, currentContainerPadding]
|
|
1398
|
+
);
|
|
1399
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1400
|
+
GridLayout,
|
|
1401
|
+
{
|
|
1402
|
+
...restProps,
|
|
1403
|
+
width,
|
|
1404
|
+
gridConfig,
|
|
1405
|
+
compactor,
|
|
1406
|
+
onLayoutChange: handleLayoutChange,
|
|
1407
|
+
layout: effectiveLayout,
|
|
1408
|
+
children
|
|
1409
|
+
}
|
|
1410
|
+
);
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1413
|
+
exports.GridItem = GridItem;
|
|
1414
|
+
exports.GridLayout = GridLayout;
|
|
1415
|
+
exports.ResponsiveGridLayout = ResponsiveGridLayout;
|
|
1416
|
+
//# sourceMappingURL=chunk-QRW3ND4U.js.map
|
|
1417
|
+
//# sourceMappingURL=chunk-QRW3ND4U.js.map
|