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,4 +1,4 @@
1
- import { defaultConstraints, setTransform, setTopLeft, perc, applyPositionConstraints, resizeItemInDirection, applySizeConstraints, defaultPositionStrategy, defaultGridConfig, defaultDragConfig, defaultResizeConfig, defaultDropConfig, getCompactor, compact, getBreakpointFromWidth, getColsFromBreakpoint, findOrGenerateResponsiveLayout, getIndentationValue } from './chunk-2O3ZME4Q.mjs';
1
+ import { defaultConstraints, setTransform, setTopLeft, perc, applyPositionConstraints, resizeItemInDirection, applySizeConstraints, defaultPositionStrategy, defaultGridConfig, defaultDragConfig, defaultResizeConfig, defaultDropConfig, getCompactor, getBreakpointFromWidth, getColsFromBreakpoint, findOrGenerateResponsiveLayout, compact, getIndentationValue } from './chunk-OH26KG7Y.mjs';
2
2
  import { calcXYRaw, calcGridItemWHPx, clamp, calcGridColWidth, calcWHRaw, calcGridItemPosition, bottom, getLayoutItem, cloneLayoutItem, moveElement, withLayoutItem, getAllCollisions, calcXY, cloneLayout, correctBounds } from './chunk-AWM66AWF.mjs';
3
3
  import React2, { useState, useRef, useMemo, useCallback, useEffect } from 'react';
4
4
  import { DraggableCore } from 'react-draggable';
@@ -23,6 +23,8 @@ function GridItem(props) {
23
23
  useCSSTransforms = true,
24
24
  usePercentages = false,
25
25
  transformScale = 1,
26
+ positionStrategy,
27
+ dragThreshold = 0,
26
28
  droppingPosition,
27
29
  className = "",
28
30
  style,
@@ -62,6 +64,11 @@ function GridItem(props) {
62
64
  const prevDroppingPositionRef = useRef(
63
65
  void 0
64
66
  );
67
+ const layoutRef = useRef(layout);
68
+ layoutRef.current = layout;
69
+ const dragPendingRef = useRef(false);
70
+ const initialDragClientRef = useRef({ x: 0, y: 0 });
71
+ const thresholdExceededRef = useRef(false);
65
72
  const positionParams = useMemo(
66
73
  () => ({
67
74
  cols,
@@ -82,9 +89,18 @@ function GridItem(props) {
82
89
  // Auto-height grids don't have a fixed container height
83
90
  rowHeight,
84
91
  margin,
85
- layout
92
+ // Use empty layout here - the actual layout will be accessed via layoutRef when needed
93
+ // This prevents the context from changing when layout changes, avoiding callback recreation
94
+ layout: []
86
95
  }),
87
- [cols, maxRows, containerWidth, rowHeight, margin, layout]
96
+ [cols, maxRows, containerWidth, rowHeight, margin]
97
+ );
98
+ const getConstraintContext = useCallback(
99
+ () => ({
100
+ ...constraintContext,
101
+ layout: layoutRef.current
102
+ }),
103
+ [constraintContext]
88
104
  );
89
105
  const effectiveLayoutItem = useMemo(
90
106
  () => layoutItem ?? {
@@ -102,6 +118,9 @@ function GridItem(props) {
102
118
  );
103
119
  const createStyle = useCallback(
104
120
  (pos2) => {
121
+ if (positionStrategy?.calcStyle) {
122
+ return positionStrategy.calcStyle(pos2);
123
+ }
105
124
  if (useCSSTransforms) {
106
125
  return setTransform(pos2);
107
126
  }
@@ -115,7 +134,7 @@ function GridItem(props) {
115
134
  }
116
135
  return styleObj;
117
136
  },
118
- [useCSSTransforms, usePercentages, containerWidth]
137
+ [positionStrategy, useCSSTransforms, usePercentages, containerWidth]
119
138
  );
120
139
  const onDragStart = useCallback(
121
140
  (e, { node }) => {
@@ -128,11 +147,33 @@ function GridItem(props) {
128
147
  const pLeft = parentRect.left / transformScale;
129
148
  const cTop = clientRect.top / transformScale;
130
149
  const pTop = parentRect.top / transformScale;
131
- const newPosition = {
132
- left: cLeft - pLeft + offsetParent.scrollLeft,
133
- top: cTop - pTop + offsetParent.scrollTop
134
- };
150
+ let newPosition;
151
+ if (positionStrategy?.calcDragPosition) {
152
+ const mouseEvent = e;
153
+ newPosition = positionStrategy.calcDragPosition(
154
+ mouseEvent.clientX,
155
+ mouseEvent.clientY,
156
+ mouseEvent.clientX - clientRect.left,
157
+ mouseEvent.clientY - clientRect.top
158
+ );
159
+ } else {
160
+ newPosition = {
161
+ left: cLeft - pLeft + offsetParent.scrollLeft,
162
+ top: cTop - pTop + offsetParent.scrollTop
163
+ };
164
+ }
135
165
  dragPositionRef.current = newPosition;
166
+ if (dragThreshold > 0) {
167
+ const mouseEvent = e;
168
+ initialDragClientRef.current = {
169
+ x: mouseEvent.clientX,
170
+ y: mouseEvent.clientY
171
+ };
172
+ dragPendingRef.current = true;
173
+ thresholdExceededRef.current = false;
174
+ setDragging(true);
175
+ return;
176
+ }
136
177
  setDragging(true);
137
178
  const rawPos = calcXYRaw(
138
179
  positionParams,
@@ -144,7 +185,7 @@ function GridItem(props) {
144
185
  effectiveLayoutItem,
145
186
  rawPos.x,
146
187
  rawPos.y,
147
- constraintContext
188
+ getConstraintContext()
148
189
  );
149
190
  onDragStartProp(i, newX, newY, {
150
191
  e,
@@ -156,15 +197,47 @@ function GridItem(props) {
156
197
  onDragStartProp,
157
198
  transformScale,
158
199
  positionParams,
200
+ positionStrategy,
201
+ dragThreshold,
159
202
  constraints,
160
203
  effectiveLayoutItem,
161
- constraintContext,
204
+ getConstraintContext,
162
205
  i
163
206
  ]
164
207
  );
165
208
  const onDrag = useCallback(
166
209
  (e, { node, deltaX, deltaY }) => {
167
210
  if (!onDragProp || !dragging) return;
211
+ const mouseEvent = e;
212
+ if (dragPendingRef.current && !thresholdExceededRef.current) {
213
+ const dx = mouseEvent.clientX - initialDragClientRef.current.x;
214
+ const dy = mouseEvent.clientY - initialDragClientRef.current.y;
215
+ const distance = Math.hypot(dx, dy);
216
+ if (distance < dragThreshold) {
217
+ return;
218
+ }
219
+ thresholdExceededRef.current = true;
220
+ dragPendingRef.current = false;
221
+ if (onDragStartProp) {
222
+ const rawPos2 = calcXYRaw(
223
+ positionParams,
224
+ dragPositionRef.current.top,
225
+ dragPositionRef.current.left
226
+ );
227
+ const { x: startX, y: startY } = applyPositionConstraints(
228
+ constraints,
229
+ effectiveLayoutItem,
230
+ rawPos2.x,
231
+ rawPos2.y,
232
+ getConstraintContext()
233
+ );
234
+ onDragStartProp(i, startX, startY, {
235
+ e,
236
+ node,
237
+ newPosition: dragPositionRef.current
238
+ });
239
+ }
240
+ }
168
241
  let top = dragPositionRef.current.top + deltaY;
169
242
  let left = dragPositionRef.current.left + deltaX;
170
243
  if (isBounded) {
@@ -185,7 +258,7 @@ function GridItem(props) {
185
258
  effectiveLayoutItem,
186
259
  rawPos.x,
187
260
  rawPos.y,
188
- constraintContext
261
+ getConstraintContext()
189
262
  );
190
263
  onDragProp(i, newX, newY, {
191
264
  e,
@@ -195,7 +268,9 @@ function GridItem(props) {
195
268
  },
196
269
  [
197
270
  onDragProp,
271
+ onDragStartProp,
198
272
  dragging,
273
+ dragThreshold,
199
274
  isBounded,
200
275
  h,
201
276
  rowHeight,
@@ -206,12 +281,21 @@ function GridItem(props) {
206
281
  i,
207
282
  constraints,
208
283
  effectiveLayoutItem,
209
- constraintContext
284
+ getConstraintContext
210
285
  ]
211
286
  );
212
287
  const onDragStop = useCallback(
213
288
  (e, { node }) => {
214
289
  if (!onDragStopProp || !dragging) return;
290
+ const wasPending = dragPendingRef.current;
291
+ dragPendingRef.current = false;
292
+ thresholdExceededRef.current = false;
293
+ initialDragClientRef.current = { x: 0, y: 0 };
294
+ if (wasPending) {
295
+ setDragging(false);
296
+ dragPositionRef.current = { left: 0, top: 0 };
297
+ return;
298
+ }
215
299
  const { left, top } = dragPositionRef.current;
216
300
  const newPosition = { top, left };
217
301
  setDragging(false);
@@ -222,7 +306,7 @@ function GridItem(props) {
222
306
  effectiveLayoutItem,
223
307
  rawPos.x,
224
308
  rawPos.y,
225
- constraintContext
309
+ getConstraintContext()
226
310
  );
227
311
  onDragStopProp(i, newX, newY, {
228
312
  e,
@@ -236,7 +320,7 @@ function GridItem(props) {
236
320
  positionParams,
237
321
  constraints,
238
322
  effectiveLayoutItem,
239
- constraintContext,
323
+ getConstraintContext,
240
324
  i
241
325
  ]
242
326
  );
@@ -271,7 +355,7 @@ function GridItem(props) {
271
355
  rawSize.w,
272
356
  rawSize.h,
273
357
  resizeHandle2,
274
- constraintContext
358
+ getConstraintContext()
275
359
  );
276
360
  handler(i, newW, newH, {
277
361
  e: e.nativeEvent,
@@ -286,12 +370,10 @@ function GridItem(props) {
286
370
  onResizeStopProp,
287
371
  containerWidth,
288
372
  positionParams,
289
- x,
290
- y,
291
373
  i,
292
374
  constraints,
293
375
  effectiveLayoutItem,
294
- constraintContext
376
+ getConstraintContext
295
377
  ]
296
378
  );
297
379
  const handleResizeStart = useCallback(
@@ -455,7 +537,7 @@ function childrenEqual(a, b) {
455
537
  }
456
538
  return true;
457
539
  }
458
- function synchronizeLayoutWithChildren(initialLayout, children, cols, compactType, allowOverlap) {
540
+ function synchronizeLayoutWithChildren(initialLayout, children, cols, compactor) {
459
541
  const layout = [];
460
542
  const childKeys = /* @__PURE__ */ new Set();
461
543
  React2.Children.forEach(children, (child) => {
@@ -497,7 +579,7 @@ function synchronizeLayoutWithChildren(initialLayout, children, cols, compactTyp
497
579
  }
498
580
  });
499
581
  const corrected = correctBounds(layout, { cols });
500
- return compact(corrected, compactType, cols, allowOverlap);
582
+ return compactor.compact(corrected, cols);
501
583
  }
502
584
  function GridLayout(props) {
503
585
  const {
@@ -552,14 +634,19 @@ function GridLayout(props) {
552
634
  enabled: isDraggable,
553
635
  bounded: isBounded,
554
636
  handle: draggableHandle,
555
- cancel: draggableCancel
637
+ cancel: draggableCancel,
638
+ threshold: dragThreshold
556
639
  } = dragConfig;
557
640
  const {
558
641
  enabled: isResizable,
559
642
  handles: resizeHandles,
560
643
  handleComponent: resizeHandle
561
644
  } = resizeConfig;
562
- const { enabled: isDroppable, defaultItem: defaultDropItem } = dropConfig;
645
+ const {
646
+ enabled: isDroppable,
647
+ defaultItem: defaultDropItem,
648
+ onDragOver: dropConfigOnDragOver
649
+ } = dropConfig;
563
650
  const compactor = compactorProp ?? getCompactor("vertical");
564
651
  const compactType = compactor.type;
565
652
  const allowOverlap = compactor.allowOverlap;
@@ -576,13 +663,7 @@ function GridLayout(props) {
576
663
  const effectiveContainerPadding = containerPadding ?? margin;
577
664
  const [mounted, setMounted] = useState(false);
578
665
  const [layout, setLayout] = useState(
579
- () => synchronizeLayoutWithChildren(
580
- propsLayout,
581
- children,
582
- cols,
583
- compactType,
584
- allowOverlap
585
- )
666
+ () => synchronizeLayoutWithChildren(propsLayout, children, cols, compactor)
586
667
  );
587
668
  const [activeDrag, setActiveDrag] = useState(null);
588
669
  const [resizing, setResizing] = useState(false);
@@ -598,6 +679,8 @@ function GridLayout(props) {
598
679
  const prevPropsLayoutRef = useRef(propsLayout);
599
680
  const prevChildrenRef = useRef(children);
600
681
  const prevCompactTypeRef = useRef(compactType);
682
+ const layoutRef = useRef(layout);
683
+ layoutRef.current = layout;
601
684
  useEffect(() => {
602
685
  setMounted(true);
603
686
  if (!deepEqual(layout, propsLayout)) {
@@ -606,6 +689,7 @@ function GridLayout(props) {
606
689
  }, []);
607
690
  useEffect(() => {
608
691
  if (activeDrag) return;
692
+ if (droppingDOMNode) return;
609
693
  const layoutChanged = !deepEqual(propsLayout, prevPropsLayoutRef.current);
610
694
  const childrenChanged = !childrenEqual(children, prevChildrenRef.current);
611
695
  const compactTypeChanged = compactType !== prevCompactTypeRef.current;
@@ -615,8 +699,7 @@ function GridLayout(props) {
615
699
  baseLayout,
616
700
  children,
617
701
  cols,
618
- compactType,
619
- allowOverlap
702
+ compactor
620
703
  );
621
704
  setLayout(newLayout);
622
705
  }
@@ -628,8 +711,9 @@ function GridLayout(props) {
628
711
  children,
629
712
  cols,
630
713
  compactType,
631
- allowOverlap,
714
+ compactor,
632
715
  activeDrag,
716
+ droppingDOMNode,
633
717
  layout
634
718
  ]);
635
719
  useEffect(() => {
@@ -646,7 +730,8 @@ function GridLayout(props) {
646
730
  }, [autoSize, layout, rowHeight, margin, effectiveContainerPadding]);
647
731
  const onDragStart = useCallback(
648
732
  (i, _x, _y, data) => {
649
- const l = getLayoutItem(layout, i);
733
+ const currentLayout = layoutRef.current;
734
+ const l = getLayoutItem(currentLayout, i);
650
735
  if (!l) return;
651
736
  const placeholder = {
652
737
  w: l.w,
@@ -656,16 +741,17 @@ function GridLayout(props) {
656
741
  i
657
742
  };
658
743
  oldDragItemRef.current = cloneLayoutItem(l);
659
- oldLayoutRef.current = layout;
744
+ oldLayoutRef.current = currentLayout;
660
745
  setActiveDrag(placeholder);
661
- onDragStartProp(layout, l, l, null, data.e, data.node);
746
+ onDragStartProp(currentLayout, l, l, null, data.e, data.node);
662
747
  },
663
- [layout, onDragStartProp]
748
+ [onDragStartProp]
664
749
  );
665
750
  const onDrag = useCallback(
666
751
  (i, x, y, data) => {
752
+ const currentLayout = layoutRef.current;
667
753
  const oldDragItem = oldDragItemRef.current;
668
- const l = getLayoutItem(layout, i);
754
+ const l = getLayoutItem(currentLayout, i);
669
755
  if (!l) return;
670
756
  const placeholder = {
671
757
  w: l.w,
@@ -675,7 +761,7 @@ function GridLayout(props) {
675
761
  i
676
762
  };
677
763
  const newLayout = moveElement(
678
- layout,
764
+ currentLayout,
679
765
  l,
680
766
  x,
681
767
  y,
@@ -686,21 +772,20 @@ function GridLayout(props) {
686
772
  allowOverlap
687
773
  );
688
774
  onDragProp(newLayout, oldDragItem, l, placeholder, data.e, data.node);
689
- setLayout(
690
- allowOverlap ? newLayout : compact(newLayout, compactType, cols)
691
- );
775
+ setLayout(compactor.compact(newLayout, cols));
692
776
  setActiveDrag(placeholder);
693
777
  },
694
- [layout, preventCollision, compactType, cols, allowOverlap, onDragProp]
778
+ [preventCollision, compactType, cols, allowOverlap, compactor, onDragProp]
695
779
  );
696
780
  const onDragStop = useCallback(
697
781
  (i, x, y, data) => {
698
782
  if (!activeDrag) return;
783
+ const currentLayout = layoutRef.current;
699
784
  const oldDragItem = oldDragItemRef.current;
700
- const l = getLayoutItem(layout, i);
785
+ const l = getLayoutItem(currentLayout, i);
701
786
  if (!l) return;
702
787
  const newLayout = moveElement(
703
- layout,
788
+ currentLayout,
704
789
  l,
705
790
  x,
706
791
  y,
@@ -710,7 +795,7 @@ function GridLayout(props) {
710
795
  cols,
711
796
  allowOverlap
712
797
  );
713
- const finalLayout = allowOverlap ? newLayout : compact(newLayout, compactType, cols);
798
+ const finalLayout = compactor.compact(newLayout, cols);
714
799
  onDragStopProp(finalLayout, oldDragItem, l, null, data.e, data.node);
715
800
  const oldLayout = oldLayoutRef.current;
716
801
  oldDragItemRef.current = null;
@@ -723,34 +808,36 @@ function GridLayout(props) {
723
808
  },
724
809
  [
725
810
  activeDrag,
726
- layout,
727
811
  preventCollision,
728
812
  compactType,
729
813
  cols,
730
814
  allowOverlap,
815
+ compactor,
731
816
  onDragStopProp,
732
817
  onLayoutChange
733
818
  ]
734
819
  );
735
820
  const onResizeStart = useCallback(
736
821
  (i, _w, _h, data) => {
737
- const l = getLayoutItem(layout, i);
822
+ const currentLayout = layoutRef.current;
823
+ const l = getLayoutItem(currentLayout, i);
738
824
  if (!l) return;
739
825
  oldResizeItemRef.current = cloneLayoutItem(l);
740
- oldLayoutRef.current = layout;
826
+ oldLayoutRef.current = currentLayout;
741
827
  setResizing(true);
742
- onResizeStartProp(layout, l, l, null, data.e, data.node);
828
+ onResizeStartProp(currentLayout, l, l, null, data.e, data.node);
743
829
  },
744
- [layout, onResizeStartProp]
830
+ [onResizeStartProp]
745
831
  );
746
832
  const onResize = useCallback(
747
833
  (i, w, h, data) => {
834
+ const currentLayout = layoutRef.current;
748
835
  const oldResizeItem = oldResizeItemRef.current;
749
836
  const { handle } = data;
750
837
  let shouldMoveItem = false;
751
838
  let newX;
752
839
  let newY;
753
- const [newLayout, l] = withLayoutItem(layout, i, (item) => {
840
+ const [newLayout, l] = withLayoutItem(currentLayout, i, (item) => {
754
841
  newX = item.x;
755
842
  newY = item.y;
756
843
  if (["sw", "w", "nw", "n", "ne"].includes(handle)) {
@@ -767,7 +854,7 @@ function GridLayout(props) {
767
854
  shouldMoveItem = true;
768
855
  }
769
856
  if (preventCollision && !allowOverlap) {
770
- const collisions = getAllCollisions(layout, {
857
+ const collisions = getAllCollisions(currentLayout, {
771
858
  ...item,
772
859
  w,
773
860
  h,
@@ -817,18 +904,17 @@ function GridLayout(props) {
817
904
  data.e,
818
905
  data.node
819
906
  );
820
- setLayout(
821
- allowOverlap ? finalLayout : compact(finalLayout, compactType, cols)
822
- );
907
+ setLayout(compactor.compact(finalLayout, cols));
823
908
  setActiveDrag(placeholder);
824
909
  },
825
- [layout, preventCollision, allowOverlap, compactType, cols, onResizeProp]
910
+ [preventCollision, compactType, cols, allowOverlap, compactor, onResizeProp]
826
911
  );
827
912
  const onResizeStop = useCallback(
828
913
  (i, _w, _h, data) => {
914
+ const currentLayout = layoutRef.current;
829
915
  const oldResizeItem = oldResizeItemRef.current;
830
- const l = getLayoutItem(layout, i);
831
- const finalLayout = allowOverlap ? layout : compact(layout, compactType, cols);
916
+ const l = getLayoutItem(currentLayout, i);
917
+ const finalLayout = compactor.compact(currentLayout, cols);
832
918
  onResizeStopProp(
833
919
  finalLayout,
834
920
  oldResizeItem,
@@ -847,20 +933,19 @@ function GridLayout(props) {
847
933
  onLayoutChange(finalLayout);
848
934
  }
849
935
  },
850
- [layout, allowOverlap, compactType, cols, onResizeStopProp, onLayoutChange]
936
+ [cols, compactor, onResizeStopProp, onLayoutChange]
851
937
  );
852
938
  const removeDroppingPlaceholder = useCallback(() => {
853
- const newLayout = compact(
854
- layout.filter((l) => l.i !== droppingItem.i),
855
- compactType,
856
- cols,
857
- allowOverlap
939
+ const currentLayout = layoutRef.current;
940
+ const newLayout = compactor.compact(
941
+ currentLayout.filter((l) => l.i !== droppingItem.i),
942
+ cols
858
943
  );
859
944
  setLayout(newLayout);
860
945
  setDroppingDOMNode(null);
861
946
  setActiveDrag(null);
862
947
  setDroppingPosition(void 0);
863
- }, [layout, droppingItem.i, compactType, cols, allowOverlap]);
948
+ }, [droppingItem.i, cols, compactor]);
864
949
  const handleDragOver = useCallback(
865
950
  (e) => {
866
951
  e.preventDefault();
@@ -870,7 +955,7 @@ function GridLayout(props) {
870
955
  )) {
871
956
  return false;
872
957
  }
873
- const rawResult = onDropDragOverProp(e);
958
+ const rawResult = dropConfigOnDragOver ? dropConfigOnDragOver(e.nativeEvent) : onDropDragOverProp(e);
874
959
  if (rawResult === false) {
875
960
  if (droppingDOMNode) {
876
961
  removeDroppingPlaceholder();
@@ -925,7 +1010,7 @@ function GridLayout(props) {
925
1010
  setDroppingDOMNode(/* @__PURE__ */ jsx("div", {}, finalDroppingItem.i));
926
1011
  setDroppingPosition(newDroppingPosition);
927
1012
  setLayout([
928
- ...layout,
1013
+ ...layoutRef.current,
929
1014
  {
930
1015
  ...finalDroppingItem,
931
1016
  x: calculatedPosition.x,
@@ -945,6 +1030,7 @@ function GridLayout(props) {
945
1030
  droppingDOMNode,
946
1031
  droppingPosition,
947
1032
  droppingItem,
1033
+ dropConfigOnDragOver,
948
1034
  onDropDragOverProp,
949
1035
  removeDroppingPlaceholder,
950
1036
  transformScale,
@@ -953,8 +1039,7 @@ function GridLayout(props) {
953
1039
  maxRows,
954
1040
  rowHeight,
955
1041
  width,
956
- effectiveContainerPadding,
957
- layout
1042
+ effectiveContainerPadding
958
1043
  ]
959
1044
  );
960
1045
  const handleDragLeave = useCallback(
@@ -977,12 +1062,13 @@ function GridLayout(props) {
977
1062
  (e) => {
978
1063
  e.preventDefault();
979
1064
  e.stopPropagation();
980
- const item = layout.find((l) => l.i === droppingItem.i);
1065
+ const currentLayout = layoutRef.current;
1066
+ const item = currentLayout.find((l) => l.i === droppingItem.i);
981
1067
  dragEnterCounterRef.current = 0;
982
1068
  removeDroppingPlaceholder();
983
- onDropProp(layout, item, e.nativeEvent);
1069
+ onDropProp(currentLayout, item, e.nativeEvent);
984
1070
  },
985
- [layout, droppingItem.i, removeDroppingPlaceholder, onDropProp]
1071
+ [droppingItem.i, removeDroppingPlaceholder, onDropProp]
986
1072
  );
987
1073
  const processGridItem = useCallback(
988
1074
  (child, isDroppingItem) => {
@@ -1017,6 +1103,8 @@ function GridLayout(props) {
1017
1103
  useCSSTransforms: useCSSTransforms && mounted,
1018
1104
  usePercentages: !mounted,
1019
1105
  transformScale,
1106
+ positionStrategy,
1107
+ dragThreshold,
1020
1108
  w: l.w,
1021
1109
  h: l.h,
1022
1110
  x: l.x,
@@ -1060,6 +1148,8 @@ function GridLayout(props) {
1060
1148
  useCSSTransforms,
1061
1149
  mounted,
1062
1150
  transformScale,
1151
+ positionStrategy,
1152
+ dragThreshold,
1063
1153
  droppingPosition,
1064
1154
  resizeHandles,
1065
1155
  resizeHandle,
@@ -1404,5 +1494,5 @@ function ResponsiveGridLayout(props) {
1404
1494
  }
1405
1495
 
1406
1496
  export { GridItem, GridLayout, ResponsiveGridLayout };
1407
- //# sourceMappingURL=chunk-MXXN7GUE.mjs.map
1408
- //# sourceMappingURL=chunk-MXXN7GUE.mjs.map
1497
+ //# sourceMappingURL=chunk-OWK47QTG.mjs.map
1498
+ //# sourceMappingURL=chunk-OWK47QTG.mjs.map