react-grid-layout 2.1.0 → 2.2.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 (38) hide show
  1. package/README.md +20 -3
  2. package/dist/{chunk-FN6MIZ24.js → chunk-2TEFHZC4.js} +118 -111
  3. package/dist/chunk-2TEFHZC4.js.map +1 -0
  4. package/dist/{chunk-GPZBANOK.js → chunk-43GDBEG4.js} +21 -20
  5. package/dist/chunk-43GDBEG4.js.map +1 -0
  6. package/dist/{chunk-LWF5EYMO.mjs → chunk-MUNIXYTV.mjs} +6 -5
  7. package/dist/chunk-MUNIXYTV.mjs.map +1 -0
  8. package/dist/{chunk-QRW3ND4U.js → chunk-NQUM7RXX.js} +195 -105
  9. package/dist/chunk-NQUM7RXX.js.map +1 -0
  10. package/dist/{chunk-2O3ZME4Q.mjs → chunk-OH26KG7Y.mjs} +118 -112
  11. package/dist/chunk-OH26KG7Y.mjs.map +1 -0
  12. package/dist/{chunk-MXXN7GUE.mjs → chunk-OWK47QTG.mjs} +164 -74
  13. package/dist/chunk-OWK47QTG.mjs.map +1 -0
  14. package/dist/core.d.mts +1 -1
  15. package/dist/core.d.ts +1 -1
  16. package/dist/core.js +45 -41
  17. package/dist/core.mjs +1 -1
  18. package/dist/index.d.mts +1 -1
  19. package/dist/index.d.ts +1 -1
  20. package/dist/index.js +23 -23
  21. package/dist/index.mjs +3 -3
  22. package/dist/legacy.js +17 -14
  23. package/dist/legacy.js.map +1 -1
  24. package/dist/legacy.mjs +6 -3
  25. package/dist/legacy.mjs.map +1 -1
  26. package/dist/{position-C8a5g6bb.d.mts → position-CXNzFxI0.d.mts} +7 -1
  27. package/dist/{position-H8tBL91b.d.ts → position-Dk0FRWA9.d.ts} +7 -1
  28. package/dist/react.d.mts +6 -2
  29. package/dist/react.d.ts +6 -2
  30. package/dist/react.js +17 -17
  31. package/dist/react.mjs +3 -3
  32. package/package.json +4 -3
  33. package/dist/chunk-2O3ZME4Q.mjs.map +0 -1
  34. package/dist/chunk-FN6MIZ24.js.map +0 -1
  35. package/dist/chunk-GPZBANOK.js.map +0 -1
  36. package/dist/chunk-LWF5EYMO.mjs.map +0 -1
  37. package/dist/chunk-MXXN7GUE.mjs.map +0 -1
  38. package/dist/chunk-QRW3ND4U.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkFN6MIZ24_js = require('./chunk-FN6MIZ24.js');
3
+ var chunk2TEFHZC4_js = require('./chunk-2TEFHZC4.js');
4
4
  var chunkBJFPTW5Q_js = require('./chunk-BJFPTW5Q.js');
5
5
  var React2 = require('react');
6
6
  var reactDraggable = require('react-draggable');
@@ -30,6 +30,8 @@ function GridItem(props) {
30
30
  useCSSTransforms = true,
31
31
  usePercentages = false,
32
32
  transformScale = 1,
33
+ positionStrategy,
34
+ dragThreshold = 0,
33
35
  droppingPosition,
34
36
  className = "",
35
37
  style,
@@ -46,7 +48,7 @@ function GridItem(props) {
46
48
  i,
47
49
  resizeHandles,
48
50
  resizeHandle,
49
- constraints = chunkFN6MIZ24_js.defaultConstraints,
51
+ constraints = chunk2TEFHZC4_js.defaultConstraints,
50
52
  layoutItem,
51
53
  layout = [],
52
54
  onDragStart: onDragStartProp,
@@ -69,6 +71,11 @@ function GridItem(props) {
69
71
  const prevDroppingPositionRef = React2.useRef(
70
72
  void 0
71
73
  );
74
+ const layoutRef = React2.useRef(layout);
75
+ layoutRef.current = layout;
76
+ const dragPendingRef = React2.useRef(false);
77
+ const initialDragClientRef = React2.useRef({ x: 0, y: 0 });
78
+ const thresholdExceededRef = React2.useRef(false);
72
79
  const positionParams = React2.useMemo(
73
80
  () => ({
74
81
  cols,
@@ -89,9 +96,18 @@ function GridItem(props) {
89
96
  // Auto-height grids don't have a fixed container height
90
97
  rowHeight,
91
98
  margin,
92
- layout
99
+ // Use empty layout here - the actual layout will be accessed via layoutRef when needed
100
+ // This prevents the context from changing when layout changes, avoiding callback recreation
101
+ layout: []
93
102
  }),
94
- [cols, maxRows, containerWidth, rowHeight, margin, layout]
103
+ [cols, maxRows, containerWidth, rowHeight, margin]
104
+ );
105
+ const getConstraintContext = React2.useCallback(
106
+ () => ({
107
+ ...constraintContext,
108
+ layout: layoutRef.current
109
+ }),
110
+ [constraintContext]
95
111
  );
96
112
  const effectiveLayoutItem = React2.useMemo(
97
113
  () => layoutItem ?? {
@@ -109,20 +125,23 @@ function GridItem(props) {
109
125
  );
110
126
  const createStyle = React2.useCallback(
111
127
  (pos2) => {
128
+ if (positionStrategy?.calcStyle) {
129
+ return positionStrategy.calcStyle(pos2);
130
+ }
112
131
  if (useCSSTransforms) {
113
- return chunkFN6MIZ24_js.setTransform(pos2);
132
+ return chunk2TEFHZC4_js.setTransform(pos2);
114
133
  }
115
- const styleObj = chunkFN6MIZ24_js.setTopLeft(pos2);
134
+ const styleObj = chunk2TEFHZC4_js.setTopLeft(pos2);
116
135
  if (usePercentages) {
117
136
  return {
118
137
  ...styleObj,
119
- left: chunkFN6MIZ24_js.perc(pos2.left / containerWidth),
120
- width: chunkFN6MIZ24_js.perc(pos2.width / containerWidth)
138
+ left: chunk2TEFHZC4_js.perc(pos2.left / containerWidth),
139
+ width: chunk2TEFHZC4_js.perc(pos2.width / containerWidth)
121
140
  };
122
141
  }
123
142
  return styleObj;
124
143
  },
125
- [useCSSTransforms, usePercentages, containerWidth]
144
+ [positionStrategy, useCSSTransforms, usePercentages, containerWidth]
126
145
  );
127
146
  const onDragStart = React2.useCallback(
128
147
  (e, { node }) => {
@@ -135,23 +154,45 @@ function GridItem(props) {
135
154
  const pLeft = parentRect.left / transformScale;
136
155
  const cTop = clientRect.top / transformScale;
137
156
  const pTop = parentRect.top / transformScale;
138
- const newPosition = {
139
- left: cLeft - pLeft + offsetParent.scrollLeft,
140
- top: cTop - pTop + offsetParent.scrollTop
141
- };
157
+ let newPosition;
158
+ if (positionStrategy?.calcDragPosition) {
159
+ const mouseEvent = e;
160
+ newPosition = positionStrategy.calcDragPosition(
161
+ mouseEvent.clientX,
162
+ mouseEvent.clientY,
163
+ mouseEvent.clientX - clientRect.left,
164
+ mouseEvent.clientY - clientRect.top
165
+ );
166
+ } else {
167
+ newPosition = {
168
+ left: cLeft - pLeft + offsetParent.scrollLeft,
169
+ top: cTop - pTop + offsetParent.scrollTop
170
+ };
171
+ }
142
172
  dragPositionRef.current = newPosition;
173
+ if (dragThreshold > 0) {
174
+ const mouseEvent = e;
175
+ initialDragClientRef.current = {
176
+ x: mouseEvent.clientX,
177
+ y: mouseEvent.clientY
178
+ };
179
+ dragPendingRef.current = true;
180
+ thresholdExceededRef.current = false;
181
+ setDragging(true);
182
+ return;
183
+ }
143
184
  setDragging(true);
144
185
  const rawPos = chunkBJFPTW5Q_js.calcXYRaw(
145
186
  positionParams,
146
187
  newPosition.top,
147
188
  newPosition.left
148
189
  );
149
- const { x: newX, y: newY } = chunkFN6MIZ24_js.applyPositionConstraints(
190
+ const { x: newX, y: newY } = chunk2TEFHZC4_js.applyPositionConstraints(
150
191
  constraints,
151
192
  effectiveLayoutItem,
152
193
  rawPos.x,
153
194
  rawPos.y,
154
- constraintContext
195
+ getConstraintContext()
155
196
  );
156
197
  onDragStartProp(i, newX, newY, {
157
198
  e,
@@ -163,15 +204,47 @@ function GridItem(props) {
163
204
  onDragStartProp,
164
205
  transformScale,
165
206
  positionParams,
207
+ positionStrategy,
208
+ dragThreshold,
166
209
  constraints,
167
210
  effectiveLayoutItem,
168
- constraintContext,
211
+ getConstraintContext,
169
212
  i
170
213
  ]
171
214
  );
172
215
  const onDrag = React2.useCallback(
173
216
  (e, { node, deltaX, deltaY }) => {
174
217
  if (!onDragProp || !dragging) return;
218
+ const mouseEvent = e;
219
+ if (dragPendingRef.current && !thresholdExceededRef.current) {
220
+ const dx = mouseEvent.clientX - initialDragClientRef.current.x;
221
+ const dy = mouseEvent.clientY - initialDragClientRef.current.y;
222
+ const distance = Math.hypot(dx, dy);
223
+ if (distance < dragThreshold) {
224
+ return;
225
+ }
226
+ thresholdExceededRef.current = true;
227
+ dragPendingRef.current = false;
228
+ if (onDragStartProp) {
229
+ const rawPos2 = chunkBJFPTW5Q_js.calcXYRaw(
230
+ positionParams,
231
+ dragPositionRef.current.top,
232
+ dragPositionRef.current.left
233
+ );
234
+ const { x: startX, y: startY } = chunk2TEFHZC4_js.applyPositionConstraints(
235
+ constraints,
236
+ effectiveLayoutItem,
237
+ rawPos2.x,
238
+ rawPos2.y,
239
+ getConstraintContext()
240
+ );
241
+ onDragStartProp(i, startX, startY, {
242
+ e,
243
+ node,
244
+ newPosition: dragPositionRef.current
245
+ });
246
+ }
247
+ }
175
248
  let top = dragPositionRef.current.top + deltaY;
176
249
  let left = dragPositionRef.current.left + deltaX;
177
250
  if (isBounded) {
@@ -187,12 +260,12 @@ function GridItem(props) {
187
260
  const newPosition = { top, left };
188
261
  dragPositionRef.current = newPosition;
189
262
  const rawPos = chunkBJFPTW5Q_js.calcXYRaw(positionParams, top, left);
190
- const { x: newX, y: newY } = chunkFN6MIZ24_js.applyPositionConstraints(
263
+ const { x: newX, y: newY } = chunk2TEFHZC4_js.applyPositionConstraints(
191
264
  constraints,
192
265
  effectiveLayoutItem,
193
266
  rawPos.x,
194
267
  rawPos.y,
195
- constraintContext
268
+ getConstraintContext()
196
269
  );
197
270
  onDragProp(i, newX, newY, {
198
271
  e,
@@ -202,7 +275,9 @@ function GridItem(props) {
202
275
  },
203
276
  [
204
277
  onDragProp,
278
+ onDragStartProp,
205
279
  dragging,
280
+ dragThreshold,
206
281
  isBounded,
207
282
  h,
208
283
  rowHeight,
@@ -213,23 +288,32 @@ function GridItem(props) {
213
288
  i,
214
289
  constraints,
215
290
  effectiveLayoutItem,
216
- constraintContext
291
+ getConstraintContext
217
292
  ]
218
293
  );
219
294
  const onDragStop = React2.useCallback(
220
295
  (e, { node }) => {
221
296
  if (!onDragStopProp || !dragging) return;
297
+ const wasPending = dragPendingRef.current;
298
+ dragPendingRef.current = false;
299
+ thresholdExceededRef.current = false;
300
+ initialDragClientRef.current = { x: 0, y: 0 };
301
+ if (wasPending) {
302
+ setDragging(false);
303
+ dragPositionRef.current = { left: 0, top: 0 };
304
+ return;
305
+ }
222
306
  const { left, top } = dragPositionRef.current;
223
307
  const newPosition = { top, left };
224
308
  setDragging(false);
225
309
  dragPositionRef.current = { left: 0, top: 0 };
226
310
  const rawPos = chunkBJFPTW5Q_js.calcXYRaw(positionParams, top, left);
227
- const { x: newX, y: newY } = chunkFN6MIZ24_js.applyPositionConstraints(
311
+ const { x: newX, y: newY } = chunk2TEFHZC4_js.applyPositionConstraints(
228
312
  constraints,
229
313
  effectiveLayoutItem,
230
314
  rawPos.x,
231
315
  rawPos.y,
232
- constraintContext
316
+ getConstraintContext()
233
317
  );
234
318
  onDragStopProp(i, newX, newY, {
235
319
  e,
@@ -243,7 +327,7 @@ function GridItem(props) {
243
327
  positionParams,
244
328
  constraints,
245
329
  effectiveLayoutItem,
246
- constraintContext,
330
+ getConstraintContext,
247
331
  i
248
332
  ]
249
333
  );
@@ -253,7 +337,7 @@ function GridItem(props) {
253
337
  if (!handler) return;
254
338
  let updatedSize;
255
339
  if (node) {
256
- updatedSize = chunkFN6MIZ24_js.resizeItemInDirection(
340
+ updatedSize = chunk2TEFHZC4_js.resizeItemInDirection(
257
341
  resizeHandle2,
258
342
  position,
259
343
  size,
@@ -272,13 +356,13 @@ function GridItem(props) {
272
356
  updatedSize.width,
273
357
  updatedSize.height
274
358
  );
275
- const { w: newW, h: newH } = chunkFN6MIZ24_js.applySizeConstraints(
359
+ const { w: newW, h: newH } = chunk2TEFHZC4_js.applySizeConstraints(
276
360
  constraints,
277
361
  effectiveLayoutItem,
278
362
  rawSize.w,
279
363
  rawSize.h,
280
364
  resizeHandle2,
281
- constraintContext
365
+ getConstraintContext()
282
366
  );
283
367
  handler(i, newW, newH, {
284
368
  e: e.nativeEvent,
@@ -293,12 +377,10 @@ function GridItem(props) {
293
377
  onResizeStopProp,
294
378
  containerWidth,
295
379
  positionParams,
296
- x,
297
- y,
298
380
  i,
299
381
  constraints,
300
382
  effectiveLayoutItem,
301
- constraintContext
383
+ getConstraintContext
302
384
  ]
303
385
  );
304
386
  const handleResizeStart = React2.useCallback(
@@ -462,7 +544,7 @@ function childrenEqual(a, b) {
462
544
  }
463
545
  return true;
464
546
  }
465
- function synchronizeLayoutWithChildren(initialLayout, children, cols, compactType, allowOverlap) {
547
+ function synchronizeLayoutWithChildren(initialLayout, children, cols, compactor) {
466
548
  const layout = [];
467
549
  const childKeys = /* @__PURE__ */ new Set();
468
550
  React2__default.default.Children.forEach(children, (child) => {
@@ -504,7 +586,7 @@ function synchronizeLayoutWithChildren(initialLayout, children, cols, compactTyp
504
586
  }
505
587
  });
506
588
  const corrected = chunkBJFPTW5Q_js.correctBounds(layout, { cols });
507
- return chunkFN6MIZ24_js.compact(corrected, compactType, cols, allowOverlap);
589
+ return compactor.compact(corrected, cols);
508
590
  }
509
591
  function GridLayout(props) {
510
592
  const {
@@ -516,9 +598,9 @@ function GridLayout(props) {
516
598
  dragConfig: dragConfigProp,
517
599
  resizeConfig: resizeConfigProp,
518
600
  dropConfig: dropConfigProp,
519
- positionStrategy = chunkFN6MIZ24_js.defaultPositionStrategy,
601
+ positionStrategy = chunk2TEFHZC4_js.defaultPositionStrategy,
520
602
  compactor: compactorProp,
521
- constraints = chunkFN6MIZ24_js.defaultConstraints,
603
+ constraints = chunk2TEFHZC4_js.defaultConstraints,
522
604
  // Layout data
523
605
  layout: propsLayout = [],
524
606
  droppingItem: droppingItemProp,
@@ -539,19 +621,19 @@ function GridLayout(props) {
539
621
  onDropDragOver: onDropDragOverProp = noop
540
622
  } = props;
541
623
  const gridConfig = React2.useMemo(
542
- () => ({ ...chunkFN6MIZ24_js.defaultGridConfig, ...gridConfigProp }),
624
+ () => ({ ...chunk2TEFHZC4_js.defaultGridConfig, ...gridConfigProp }),
543
625
  [gridConfigProp]
544
626
  );
545
627
  const dragConfig = React2.useMemo(
546
- () => ({ ...chunkFN6MIZ24_js.defaultDragConfig, ...dragConfigProp }),
628
+ () => ({ ...chunk2TEFHZC4_js.defaultDragConfig, ...dragConfigProp }),
547
629
  [dragConfigProp]
548
630
  );
549
631
  const resizeConfig = React2.useMemo(
550
- () => ({ ...chunkFN6MIZ24_js.defaultResizeConfig, ...resizeConfigProp }),
632
+ () => ({ ...chunk2TEFHZC4_js.defaultResizeConfig, ...resizeConfigProp }),
551
633
  [resizeConfigProp]
552
634
  );
553
635
  const dropConfig = React2.useMemo(
554
- () => ({ ...chunkFN6MIZ24_js.defaultDropConfig, ...dropConfigProp }),
636
+ () => ({ ...chunk2TEFHZC4_js.defaultDropConfig, ...dropConfigProp }),
555
637
  [dropConfigProp]
556
638
  );
557
639
  const { cols, rowHeight, maxRows, margin, containerPadding } = gridConfig;
@@ -559,15 +641,20 @@ function GridLayout(props) {
559
641
  enabled: isDraggable,
560
642
  bounded: isBounded,
561
643
  handle: draggableHandle,
562
- cancel: draggableCancel
644
+ cancel: draggableCancel,
645
+ threshold: dragThreshold
563
646
  } = dragConfig;
564
647
  const {
565
648
  enabled: isResizable,
566
649
  handles: resizeHandles,
567
650
  handleComponent: resizeHandle
568
651
  } = resizeConfig;
569
- const { enabled: isDroppable, defaultItem: defaultDropItem } = dropConfig;
570
- const compactor = compactorProp ?? chunkFN6MIZ24_js.getCompactor("vertical");
652
+ const {
653
+ enabled: isDroppable,
654
+ defaultItem: defaultDropItem,
655
+ onDragOver: dropConfigOnDragOver
656
+ } = dropConfig;
657
+ const compactor = compactorProp ?? chunk2TEFHZC4_js.getCompactor("vertical");
571
658
  const compactType = compactor.type;
572
659
  const allowOverlap = compactor.allowOverlap;
573
660
  const preventCollision = compactor.preventCollision ?? false;
@@ -583,13 +670,7 @@ function GridLayout(props) {
583
670
  const effectiveContainerPadding = containerPadding ?? margin;
584
671
  const [mounted, setMounted] = React2.useState(false);
585
672
  const [layout, setLayout] = React2.useState(
586
- () => synchronizeLayoutWithChildren(
587
- propsLayout,
588
- children,
589
- cols,
590
- compactType,
591
- allowOverlap
592
- )
673
+ () => synchronizeLayoutWithChildren(propsLayout, children, cols, compactor)
593
674
  );
594
675
  const [activeDrag, setActiveDrag] = React2.useState(null);
595
676
  const [resizing, setResizing] = React2.useState(false);
@@ -605,6 +686,8 @@ function GridLayout(props) {
605
686
  const prevPropsLayoutRef = React2.useRef(propsLayout);
606
687
  const prevChildrenRef = React2.useRef(children);
607
688
  const prevCompactTypeRef = React2.useRef(compactType);
689
+ const layoutRef = React2.useRef(layout);
690
+ layoutRef.current = layout;
608
691
  React2.useEffect(() => {
609
692
  setMounted(true);
610
693
  if (!fastEquals.deepEqual(layout, propsLayout)) {
@@ -613,6 +696,7 @@ function GridLayout(props) {
613
696
  }, []);
614
697
  React2.useEffect(() => {
615
698
  if (activeDrag) return;
699
+ if (droppingDOMNode) return;
616
700
  const layoutChanged = !fastEquals.deepEqual(propsLayout, prevPropsLayoutRef.current);
617
701
  const childrenChanged = !childrenEqual(children, prevChildrenRef.current);
618
702
  const compactTypeChanged = compactType !== prevCompactTypeRef.current;
@@ -622,8 +706,7 @@ function GridLayout(props) {
622
706
  baseLayout,
623
707
  children,
624
708
  cols,
625
- compactType,
626
- allowOverlap
709
+ compactor
627
710
  );
628
711
  setLayout(newLayout);
629
712
  }
@@ -635,8 +718,9 @@ function GridLayout(props) {
635
718
  children,
636
719
  cols,
637
720
  compactType,
638
- allowOverlap,
721
+ compactor,
639
722
  activeDrag,
723
+ droppingDOMNode,
640
724
  layout
641
725
  ]);
642
726
  React2.useEffect(() => {
@@ -653,7 +737,8 @@ function GridLayout(props) {
653
737
  }, [autoSize, layout, rowHeight, margin, effectiveContainerPadding]);
654
738
  const onDragStart = React2.useCallback(
655
739
  (i, _x, _y, data) => {
656
- const l = chunkBJFPTW5Q_js.getLayoutItem(layout, i);
740
+ const currentLayout = layoutRef.current;
741
+ const l = chunkBJFPTW5Q_js.getLayoutItem(currentLayout, i);
657
742
  if (!l) return;
658
743
  const placeholder = {
659
744
  w: l.w,
@@ -663,16 +748,17 @@ function GridLayout(props) {
663
748
  i
664
749
  };
665
750
  oldDragItemRef.current = chunkBJFPTW5Q_js.cloneLayoutItem(l);
666
- oldLayoutRef.current = layout;
751
+ oldLayoutRef.current = currentLayout;
667
752
  setActiveDrag(placeholder);
668
- onDragStartProp(layout, l, l, null, data.e, data.node);
753
+ onDragStartProp(currentLayout, l, l, null, data.e, data.node);
669
754
  },
670
- [layout, onDragStartProp]
755
+ [onDragStartProp]
671
756
  );
672
757
  const onDrag = React2.useCallback(
673
758
  (i, x, y, data) => {
759
+ const currentLayout = layoutRef.current;
674
760
  const oldDragItem = oldDragItemRef.current;
675
- const l = chunkBJFPTW5Q_js.getLayoutItem(layout, i);
761
+ const l = chunkBJFPTW5Q_js.getLayoutItem(currentLayout, i);
676
762
  if (!l) return;
677
763
  const placeholder = {
678
764
  w: l.w,
@@ -682,7 +768,7 @@ function GridLayout(props) {
682
768
  i
683
769
  };
684
770
  const newLayout = chunkBJFPTW5Q_js.moveElement(
685
- layout,
771
+ currentLayout,
686
772
  l,
687
773
  x,
688
774
  y,
@@ -693,21 +779,20 @@ function GridLayout(props) {
693
779
  allowOverlap
694
780
  );
695
781
  onDragProp(newLayout, oldDragItem, l, placeholder, data.e, data.node);
696
- setLayout(
697
- allowOverlap ? newLayout : chunkFN6MIZ24_js.compact(newLayout, compactType, cols)
698
- );
782
+ setLayout(compactor.compact(newLayout, cols));
699
783
  setActiveDrag(placeholder);
700
784
  },
701
- [layout, preventCollision, compactType, cols, allowOverlap, onDragProp]
785
+ [preventCollision, compactType, cols, allowOverlap, compactor, onDragProp]
702
786
  );
703
787
  const onDragStop = React2.useCallback(
704
788
  (i, x, y, data) => {
705
789
  if (!activeDrag) return;
790
+ const currentLayout = layoutRef.current;
706
791
  const oldDragItem = oldDragItemRef.current;
707
- const l = chunkBJFPTW5Q_js.getLayoutItem(layout, i);
792
+ const l = chunkBJFPTW5Q_js.getLayoutItem(currentLayout, i);
708
793
  if (!l) return;
709
794
  const newLayout = chunkBJFPTW5Q_js.moveElement(
710
- layout,
795
+ currentLayout,
711
796
  l,
712
797
  x,
713
798
  y,
@@ -717,7 +802,7 @@ function GridLayout(props) {
717
802
  cols,
718
803
  allowOverlap
719
804
  );
720
- const finalLayout = allowOverlap ? newLayout : chunkFN6MIZ24_js.compact(newLayout, compactType, cols);
805
+ const finalLayout = compactor.compact(newLayout, cols);
721
806
  onDragStopProp(finalLayout, oldDragItem, l, null, data.e, data.node);
722
807
  const oldLayout = oldLayoutRef.current;
723
808
  oldDragItemRef.current = null;
@@ -730,34 +815,36 @@ function GridLayout(props) {
730
815
  },
731
816
  [
732
817
  activeDrag,
733
- layout,
734
818
  preventCollision,
735
819
  compactType,
736
820
  cols,
737
821
  allowOverlap,
822
+ compactor,
738
823
  onDragStopProp,
739
824
  onLayoutChange
740
825
  ]
741
826
  );
742
827
  const onResizeStart = React2.useCallback(
743
828
  (i, _w, _h, data) => {
744
- const l = chunkBJFPTW5Q_js.getLayoutItem(layout, i);
829
+ const currentLayout = layoutRef.current;
830
+ const l = chunkBJFPTW5Q_js.getLayoutItem(currentLayout, i);
745
831
  if (!l) return;
746
832
  oldResizeItemRef.current = chunkBJFPTW5Q_js.cloneLayoutItem(l);
747
- oldLayoutRef.current = layout;
833
+ oldLayoutRef.current = currentLayout;
748
834
  setResizing(true);
749
- onResizeStartProp(layout, l, l, null, data.e, data.node);
835
+ onResizeStartProp(currentLayout, l, l, null, data.e, data.node);
750
836
  },
751
- [layout, onResizeStartProp]
837
+ [onResizeStartProp]
752
838
  );
753
839
  const onResize = React2.useCallback(
754
840
  (i, w, h, data) => {
841
+ const currentLayout = layoutRef.current;
755
842
  const oldResizeItem = oldResizeItemRef.current;
756
843
  const { handle } = data;
757
844
  let shouldMoveItem = false;
758
845
  let newX;
759
846
  let newY;
760
- const [newLayout, l] = chunkBJFPTW5Q_js.withLayoutItem(layout, i, (item) => {
847
+ const [newLayout, l] = chunkBJFPTW5Q_js.withLayoutItem(currentLayout, i, (item) => {
761
848
  newX = item.x;
762
849
  newY = item.y;
763
850
  if (["sw", "w", "nw", "n", "ne"].includes(handle)) {
@@ -774,7 +861,7 @@ function GridLayout(props) {
774
861
  shouldMoveItem = true;
775
862
  }
776
863
  if (preventCollision && !allowOverlap) {
777
- const collisions = chunkBJFPTW5Q_js.getAllCollisions(layout, {
864
+ const collisions = chunkBJFPTW5Q_js.getAllCollisions(currentLayout, {
778
865
  ...item,
779
866
  w,
780
867
  h,
@@ -824,18 +911,17 @@ function GridLayout(props) {
824
911
  data.e,
825
912
  data.node
826
913
  );
827
- setLayout(
828
- allowOverlap ? finalLayout : chunkFN6MIZ24_js.compact(finalLayout, compactType, cols)
829
- );
914
+ setLayout(compactor.compact(finalLayout, cols));
830
915
  setActiveDrag(placeholder);
831
916
  },
832
- [layout, preventCollision, allowOverlap, compactType, cols, onResizeProp]
917
+ [preventCollision, compactType, cols, allowOverlap, compactor, onResizeProp]
833
918
  );
834
919
  const onResizeStop = React2.useCallback(
835
920
  (i, _w, _h, data) => {
921
+ const currentLayout = layoutRef.current;
836
922
  const oldResizeItem = oldResizeItemRef.current;
837
- const l = chunkBJFPTW5Q_js.getLayoutItem(layout, i);
838
- const finalLayout = allowOverlap ? layout : chunkFN6MIZ24_js.compact(layout, compactType, cols);
923
+ const l = chunkBJFPTW5Q_js.getLayoutItem(currentLayout, i);
924
+ const finalLayout = compactor.compact(currentLayout, cols);
839
925
  onResizeStopProp(
840
926
  finalLayout,
841
927
  oldResizeItem,
@@ -854,20 +940,19 @@ function GridLayout(props) {
854
940
  onLayoutChange(finalLayout);
855
941
  }
856
942
  },
857
- [layout, allowOverlap, compactType, cols, onResizeStopProp, onLayoutChange]
943
+ [cols, compactor, onResizeStopProp, onLayoutChange]
858
944
  );
859
945
  const removeDroppingPlaceholder = React2.useCallback(() => {
860
- const newLayout = chunkFN6MIZ24_js.compact(
861
- layout.filter((l) => l.i !== droppingItem.i),
862
- compactType,
863
- cols,
864
- allowOverlap
946
+ const currentLayout = layoutRef.current;
947
+ const newLayout = compactor.compact(
948
+ currentLayout.filter((l) => l.i !== droppingItem.i),
949
+ cols
865
950
  );
866
951
  setLayout(newLayout);
867
952
  setDroppingDOMNode(null);
868
953
  setActiveDrag(null);
869
954
  setDroppingPosition(void 0);
870
- }, [layout, droppingItem.i, compactType, cols, allowOverlap]);
955
+ }, [droppingItem.i, cols, compactor]);
871
956
  const handleDragOver = React2.useCallback(
872
957
  (e) => {
873
958
  e.preventDefault();
@@ -877,7 +962,7 @@ function GridLayout(props) {
877
962
  )) {
878
963
  return false;
879
964
  }
880
- const rawResult = onDropDragOverProp(e);
965
+ const rawResult = dropConfigOnDragOver ? dropConfigOnDragOver(e.nativeEvent) : onDropDragOverProp(e);
881
966
  if (rawResult === false) {
882
967
  if (droppingDOMNode) {
883
968
  removeDroppingPlaceholder();
@@ -932,7 +1017,7 @@ function GridLayout(props) {
932
1017
  setDroppingDOMNode(/* @__PURE__ */ jsxRuntime.jsx("div", {}, finalDroppingItem.i));
933
1018
  setDroppingPosition(newDroppingPosition);
934
1019
  setLayout([
935
- ...layout,
1020
+ ...layoutRef.current,
936
1021
  {
937
1022
  ...finalDroppingItem,
938
1023
  x: calculatedPosition.x,
@@ -952,6 +1037,7 @@ function GridLayout(props) {
952
1037
  droppingDOMNode,
953
1038
  droppingPosition,
954
1039
  droppingItem,
1040
+ dropConfigOnDragOver,
955
1041
  onDropDragOverProp,
956
1042
  removeDroppingPlaceholder,
957
1043
  transformScale,
@@ -960,8 +1046,7 @@ function GridLayout(props) {
960
1046
  maxRows,
961
1047
  rowHeight,
962
1048
  width,
963
- effectiveContainerPadding,
964
- layout
1049
+ effectiveContainerPadding
965
1050
  ]
966
1051
  );
967
1052
  const handleDragLeave = React2.useCallback(
@@ -984,12 +1069,13 @@ function GridLayout(props) {
984
1069
  (e) => {
985
1070
  e.preventDefault();
986
1071
  e.stopPropagation();
987
- const item = layout.find((l) => l.i === droppingItem.i);
1072
+ const currentLayout = layoutRef.current;
1073
+ const item = currentLayout.find((l) => l.i === droppingItem.i);
988
1074
  dragEnterCounterRef.current = 0;
989
1075
  removeDroppingPlaceholder();
990
- onDropProp(layout, item, e.nativeEvent);
1076
+ onDropProp(currentLayout, item, e.nativeEvent);
991
1077
  },
992
- [layout, droppingItem.i, removeDroppingPlaceholder, onDropProp]
1078
+ [droppingItem.i, removeDroppingPlaceholder, onDropProp]
993
1079
  );
994
1080
  const processGridItem = React2.useCallback(
995
1081
  (child, isDroppingItem) => {
@@ -1024,6 +1110,8 @@ function GridLayout(props) {
1024
1110
  useCSSTransforms: useCSSTransforms && mounted,
1025
1111
  usePercentages: !mounted,
1026
1112
  transformScale,
1113
+ positionStrategy,
1114
+ dragThreshold,
1027
1115
  w: l.w,
1028
1116
  h: l.h,
1029
1117
  x: l.x,
@@ -1067,6 +1155,8 @@ function GridLayout(props) {
1067
1155
  useCSSTransforms,
1068
1156
  mounted,
1069
1157
  transformScale,
1158
+ positionStrategy,
1159
+ dragThreshold,
1070
1160
  droppingPosition,
1071
1161
  resizeHandles,
1072
1162
  resizeHandle,
@@ -1186,7 +1276,7 @@ function synchronizeLayoutWithChildren2(initialLayout, children, cols, compactTy
1186
1276
  }
1187
1277
  });
1188
1278
  const corrected = chunkBJFPTW5Q_js.correctBounds(layout, { cols });
1189
- return chunkFN6MIZ24_js.compact(corrected, compactType, cols, allowOverlap);
1279
+ return chunk2TEFHZC4_js.compact(corrected, compactType, cols, allowOverlap);
1190
1280
  }
1191
1281
  function ResponsiveGridLayout(props) {
1192
1282
  const {
@@ -1206,17 +1296,17 @@ function ResponsiveGridLayout(props) {
1206
1296
  onWidthChange = noop2,
1207
1297
  ...restProps
1208
1298
  } = props;
1209
- const compactor = compactorProp ?? chunkFN6MIZ24_js.getCompactor("vertical");
1299
+ const compactor = compactorProp ?? chunk2TEFHZC4_js.getCompactor("vertical");
1210
1300
  const compactType = compactor.type;
1211
1301
  const allowOverlap = compactor.allowOverlap;
1212
1302
  const initialBreakpoint = React2.useMemo(() => {
1213
- return propBreakpoint ?? chunkFN6MIZ24_js.getBreakpointFromWidth(breakpoints, width);
1303
+ return propBreakpoint ?? chunk2TEFHZC4_js.getBreakpointFromWidth(breakpoints, width);
1214
1304
  }, []);
1215
1305
  const initialCols = React2.useMemo(() => {
1216
- return chunkFN6MIZ24_js.getColsFromBreakpoint(initialBreakpoint, colsConfig);
1306
+ return chunk2TEFHZC4_js.getColsFromBreakpoint(initialBreakpoint, colsConfig);
1217
1307
  }, [initialBreakpoint, colsConfig]);
1218
1308
  const initialLayout = React2.useMemo(() => {
1219
- return chunkFN6MIZ24_js.findOrGenerateResponsiveLayout(
1309
+ return chunk2TEFHZC4_js.findOrGenerateResponsiveLayout(
1220
1310
  propsLayouts,
1221
1311
  breakpoints,
1222
1312
  initialBreakpoint,
@@ -1241,7 +1331,7 @@ function ResponsiveGridLayout(props) {
1241
1331
  }, [layouts]);
1242
1332
  const derivedLayout = React2.useMemo(() => {
1243
1333
  if (!fastEquals.deepEqual(propsLayouts, prevLayoutsRef.current)) {
1244
- return chunkFN6MIZ24_js.findOrGenerateResponsiveLayout(
1334
+ return chunk2TEFHZC4_js.findOrGenerateResponsiveLayout(
1245
1335
  propsLayouts,
1246
1336
  breakpoints,
1247
1337
  breakpoint,
@@ -1263,7 +1353,7 @@ function ResponsiveGridLayout(props) {
1263
1353
  }, [derivedLayout, propsLayouts]);
1264
1354
  React2.useEffect(() => {
1265
1355
  if (compactType !== prevCompactTypeRef.current) {
1266
- const newLayout = chunkFN6MIZ24_js.compact(
1356
+ const newLayout = chunk2TEFHZC4_js.compact(
1267
1357
  chunkBJFPTW5Q_js.cloneLayout(effectiveLayout),
1268
1358
  compactType,
1269
1359
  cols,
@@ -1296,15 +1386,15 @@ function ResponsiveGridLayout(props) {
1296
1386
  );
1297
1387
  const colsChanged = !fastEquals.deepEqual(colsConfig, prevColsRef.current);
1298
1388
  if (widthChanged || breakpointPropChanged || breakpointsChanged || colsChanged) {
1299
- const newBreakpoint = propBreakpoint ?? chunkFN6MIZ24_js.getBreakpointFromWidth(breakpoints, width);
1300
- const newCols = chunkFN6MIZ24_js.getColsFromBreakpoint(newBreakpoint, colsConfig);
1389
+ const newBreakpoint = propBreakpoint ?? chunk2TEFHZC4_js.getBreakpointFromWidth(breakpoints, width);
1390
+ const newCols = chunk2TEFHZC4_js.getColsFromBreakpoint(newBreakpoint, colsConfig);
1301
1391
  const lastBreakpoint = breakpoint;
1302
1392
  if (lastBreakpoint !== newBreakpoint || breakpointsChanged || colsChanged) {
1303
1393
  const newLayouts = { ...layoutsRef.current };
1304
1394
  if (!newLayouts[lastBreakpoint]) {
1305
1395
  newLayouts[lastBreakpoint] = chunkBJFPTW5Q_js.cloneLayout(layout);
1306
1396
  }
1307
- let newLayout = chunkFN6MIZ24_js.findOrGenerateResponsiveLayout(
1397
+ let newLayout = chunk2TEFHZC4_js.findOrGenerateResponsiveLayout(
1308
1398
  newLayouts,
1309
1399
  breakpoints,
1310
1400
  newBreakpoint,
@@ -1328,11 +1418,11 @@ function ResponsiveGridLayout(props) {
1328
1418
  onBreakpointChange(newBreakpoint, newCols);
1329
1419
  onLayoutChange(newLayout, newLayouts);
1330
1420
  }
1331
- const currentMargin2 = chunkFN6MIZ24_js.getIndentationValue(
1421
+ const currentMargin2 = chunk2TEFHZC4_js.getIndentationValue(
1332
1422
  propMargin,
1333
1423
  newBreakpoint
1334
1424
  );
1335
- const currentPadding = propContainerPadding ? chunkFN6MIZ24_js.getIndentationValue(
1425
+ const currentPadding = propContainerPadding ? chunk2TEFHZC4_js.getIndentationValue(
1336
1426
  propContainerPadding,
1337
1427
  newBreakpoint
1338
1428
  ) : null;
@@ -1374,14 +1464,14 @@ function ResponsiveGridLayout(props) {
1374
1464
  [breakpoint, onLayoutChange]
1375
1465
  );
1376
1466
  const currentMargin = React2.useMemo(() => {
1377
- return chunkFN6MIZ24_js.getIndentationValue(
1467
+ return chunk2TEFHZC4_js.getIndentationValue(
1378
1468
  propMargin,
1379
1469
  breakpoint
1380
1470
  );
1381
1471
  }, [propMargin, breakpoint]);
1382
1472
  const currentContainerPadding = React2.useMemo(() => {
1383
1473
  if (propContainerPadding === null) return null;
1384
- return chunkFN6MIZ24_js.getIndentationValue(
1474
+ return chunk2TEFHZC4_js.getIndentationValue(
1385
1475
  propContainerPadding,
1386
1476
  breakpoint
1387
1477
  );
@@ -1413,5 +1503,5 @@ function ResponsiveGridLayout(props) {
1413
1503
  exports.GridItem = GridItem;
1414
1504
  exports.GridLayout = GridLayout;
1415
1505
  exports.ResponsiveGridLayout = ResponsiveGridLayout;
1416
- //# sourceMappingURL=chunk-QRW3ND4U.js.map
1417
- //# sourceMappingURL=chunk-QRW3ND4U.js.map
1506
+ //# sourceMappingURL=chunk-NQUM7RXX.js.map
1507
+ //# sourceMappingURL=chunk-NQUM7RXX.js.map