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