react-grid-layout 2.1.1 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/README.md +14 -55
  2. package/dist/{ResponsiveGridLayout-BkHF9YHa.d.mts → ResponsiveGridLayout-DqK__izz.d.mts} +1 -1
  3. package/dist/{ResponsiveGridLayout-CLn16-X3.d.ts → ResponsiveGridLayout-MbDNfJ8M.d.ts} +1 -1
  4. package/dist/{calculate-DsVTldEE.d.ts → calculate-9RxGrt-U.d.ts} +1 -1
  5. package/dist/{calculate-DwbL1D06.d.mts → calculate-FbCWy8x1.d.mts} +1 -1
  6. package/dist/{chunk-WWS3M5Y3.js → chunk-2DDROKB2.js} +15 -158
  7. package/dist/chunk-2DDROKB2.js.map +1 -0
  8. package/dist/{chunk-RB2IKK5B.js → chunk-3CEWSUXL.js} +179 -93
  9. package/dist/chunk-3CEWSUXL.js.map +1 -0
  10. package/dist/{chunk-PLWMASMX.mjs → chunk-AZ6K3JIJ.mjs} +150 -64
  11. package/dist/chunk-AZ6K3JIJ.mjs.map +1 -0
  12. package/dist/chunk-PBQSHIID.js +4 -0
  13. package/dist/{chunk-7ELO5FRW.js.map → chunk-PBQSHIID.js.map} +1 -1
  14. package/dist/{chunk-YQQYHEEG.js → chunk-QGXQSZII.js} +34 -39
  15. package/dist/chunk-QGXQSZII.js.map +1 -0
  16. package/dist/{chunk-FLITZMQC.mjs → chunk-XYPIYYYQ.mjs} +16 -157
  17. package/dist/chunk-XYPIYYYQ.mjs.map +1 -0
  18. package/dist/{chunk-LIKX67MZ.mjs → chunk-YFVX5RDK.mjs} +27 -32
  19. package/dist/chunk-YFVX5RDK.mjs.map +1 -0
  20. package/dist/chunk-ZWN22PS2.mjs +3 -0
  21. package/dist/{chunk-526JND3R.mjs.map → chunk-ZWN22PS2.mjs.map} +1 -1
  22. package/dist/core.d.mts +6 -32
  23. package/dist/core.d.ts +6 -32
  24. package/dist/core.js +41 -49
  25. package/dist/core.mjs +2 -2
  26. package/dist/extras.d.mts +2 -2
  27. package/dist/extras.d.ts +2 -2
  28. package/dist/extras.js +0 -72
  29. package/dist/extras.js.map +1 -1
  30. package/dist/extras.mjs +0 -72
  31. package/dist/extras.mjs.map +1 -1
  32. package/dist/index.d.mts +5 -5
  33. package/dist/index.d.ts +5 -5
  34. package/dist/index.js +24 -24
  35. package/dist/index.mjs +4 -4
  36. package/dist/legacy.d.mts +2 -2
  37. package/dist/legacy.d.ts +2 -2
  38. package/dist/legacy.js +17 -14
  39. package/dist/legacy.js.map +1 -1
  40. package/dist/legacy.mjs +6 -3
  41. package/dist/legacy.mjs.map +1 -1
  42. package/dist/{position-CXNzFxI0.d.mts → position-CetgOHhD.d.mts} +1 -1
  43. package/dist/{position-Dk0FRWA9.d.ts → position-DhZqWO1-.d.ts} +1 -1
  44. package/dist/react.d.mts +15 -14
  45. package/dist/react.d.ts +15 -14
  46. package/dist/react.js +18 -18
  47. package/dist/react.mjs +4 -4
  48. package/dist/{responsive-BB5d98xz.d.mts → responsive-DLRtE8v8.d.ts} +3 -3
  49. package/dist/{responsive-BXI-GCXG.d.ts → responsive-T0N0GmBB.d.mts} +3 -3
  50. package/dist/{types-CokovIMH.d.ts → types-BiXsdXr7.d.mts} +5 -16
  51. package/dist/{types-CokovIMH.d.mts → types-BiXsdXr7.d.ts} +5 -16
  52. package/index-dev.js +2 -3
  53. package/package.json +1 -1
  54. package/dist/chunk-526JND3R.mjs +0 -3
  55. package/dist/chunk-7ELO5FRW.js +0 -4
  56. package/dist/chunk-FLITZMQC.mjs.map +0 -1
  57. package/dist/chunk-LIKX67MZ.mjs.map +0 -1
  58. package/dist/chunk-PLWMASMX.mjs.map +0 -1
  59. package/dist/chunk-RB2IKK5B.js.map +0 -1
  60. package/dist/chunk-WWS3M5Y3.js.map +0 -1
  61. package/dist/chunk-YQQYHEEG.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkWWS3M5Y3_js = require('./chunk-WWS3M5Y3.js');
3
+ var chunk2DDROKB2_js = require('./chunk-2DDROKB2.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 = chunkWWS3M5Y3_js.defaultConstraints,
51
+ constraints = chunk2DDROKB2_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: []
102
+ }),
103
+ [cols, maxRows, containerWidth, rowHeight, margin]
104
+ );
105
+ const getConstraintContext = React2.useCallback(
106
+ () => ({
107
+ ...constraintContext,
108
+ layout: layoutRef.current
93
109
  }),
94
- [cols, maxRows, containerWidth, rowHeight, margin, layout]
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 chunkWWS3M5Y3_js.setTransform(pos2);
132
+ return chunk2DDROKB2_js.setTransform(pos2);
114
133
  }
115
- const styleObj = chunkWWS3M5Y3_js.setTopLeft(pos2);
134
+ const styleObj = chunk2DDROKB2_js.setTopLeft(pos2);
116
135
  if (usePercentages) {
117
136
  return {
118
137
  ...styleObj,
119
- left: chunkWWS3M5Y3_js.perc(pos2.left / containerWidth),
120
- width: chunkWWS3M5Y3_js.perc(pos2.width / containerWidth)
138
+ left: chunk2DDROKB2_js.perc(pos2.left / containerWidth),
139
+ width: chunk2DDROKB2_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 } = chunkWWS3M5Y3_js.applyPositionConstraints(
190
+ const { x: newX, y: newY } = chunk2DDROKB2_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 } = chunk2DDROKB2_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 } = chunkWWS3M5Y3_js.applyPositionConstraints(
263
+ const { x: newX, y: newY } = chunk2DDROKB2_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 } = chunkWWS3M5Y3_js.applyPositionConstraints(
311
+ const { x: newX, y: newY } = chunk2DDROKB2_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 = chunkWWS3M5Y3_js.resizeItemInDirection(
340
+ updatedSize = chunk2DDROKB2_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 } = chunkWWS3M5Y3_js.applySizeConstraints(
359
+ const { w: newW, h: newH } = chunk2DDROKB2_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 chunkWWS3M5Y3_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 = chunkWWS3M5Y3_js.defaultPositionStrategy,
601
+ positionStrategy = chunk2DDROKB2_js.defaultPositionStrategy,
520
602
  compactor: compactorProp,
521
- constraints = chunkWWS3M5Y3_js.defaultConstraints,
603
+ constraints = chunk2DDROKB2_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
- () => ({ ...chunkWWS3M5Y3_js.defaultGridConfig, ...gridConfigProp }),
624
+ () => ({ ...chunk2DDROKB2_js.defaultGridConfig, ...gridConfigProp }),
543
625
  [gridConfigProp]
544
626
  );
545
627
  const dragConfig = React2.useMemo(
546
- () => ({ ...chunkWWS3M5Y3_js.defaultDragConfig, ...dragConfigProp }),
628
+ () => ({ ...chunk2DDROKB2_js.defaultDragConfig, ...dragConfigProp }),
547
629
  [dragConfigProp]
548
630
  );
549
631
  const resizeConfig = React2.useMemo(
550
- () => ({ ...chunkWWS3M5Y3_js.defaultResizeConfig, ...resizeConfigProp }),
632
+ () => ({ ...chunk2DDROKB2_js.defaultResizeConfig, ...resizeConfigProp }),
551
633
  [resizeConfigProp]
552
634
  );
553
635
  const dropConfig = React2.useMemo(
554
- () => ({ ...chunkWWS3M5Y3_js.defaultDropConfig, ...dropConfigProp }),
636
+ () => ({ ...chunk2DDROKB2_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 ?? chunkWWS3M5Y3_js.getCompactor("vertical");
652
+ const {
653
+ enabled: isDroppable,
654
+ defaultItem: defaultDropItem,
655
+ onDragOver: dropConfigOnDragOver
656
+ } = dropConfig;
657
+ const compactor = compactorProp ?? chunk2DDROKB2_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);
@@ -625,8 +706,7 @@ function GridLayout(props) {
625
706
  baseLayout,
626
707
  children,
627
708
  cols,
628
- compactType,
629
- allowOverlap
709
+ compactor
630
710
  );
631
711
  setLayout(newLayout);
632
712
  }
@@ -638,7 +718,7 @@ function GridLayout(props) {
638
718
  children,
639
719
  cols,
640
720
  compactType,
641
- allowOverlap,
721
+ compactor,
642
722
  activeDrag,
643
723
  droppingDOMNode,
644
724
  layout
@@ -699,12 +779,10 @@ function GridLayout(props) {
699
779
  allowOverlap
700
780
  );
701
781
  onDragProp(newLayout, oldDragItem, l, placeholder, data.e, data.node);
702
- setLayout(
703
- allowOverlap ? newLayout : chunkWWS3M5Y3_js.compact(newLayout, compactType, cols)
704
- );
782
+ setLayout(compactor.compact(newLayout, cols));
705
783
  setActiveDrag(placeholder);
706
784
  },
707
- [preventCollision, compactType, cols, allowOverlap, onDragProp]
785
+ [preventCollision, compactType, cols, allowOverlap, compactor, onDragProp]
708
786
  );
709
787
  const onDragStop = React2.useCallback(
710
788
  (i, x, y, data) => {
@@ -724,7 +802,7 @@ function GridLayout(props) {
724
802
  cols,
725
803
  allowOverlap
726
804
  );
727
- const finalLayout = allowOverlap ? newLayout : chunkWWS3M5Y3_js.compact(newLayout, compactType, cols);
805
+ const finalLayout = compactor.compact(newLayout, cols);
728
806
  onDragStopProp(finalLayout, oldDragItem, l, null, data.e, data.node);
729
807
  const oldLayout = oldLayoutRef.current;
730
808
  oldDragItemRef.current = null;
@@ -741,6 +819,7 @@ function GridLayout(props) {
741
819
  compactType,
742
820
  cols,
743
821
  allowOverlap,
822
+ compactor,
744
823
  onDragStopProp,
745
824
  onLayoutChange
746
825
  ]
@@ -832,19 +911,17 @@ function GridLayout(props) {
832
911
  data.e,
833
912
  data.node
834
913
  );
835
- setLayout(
836
- allowOverlap ? finalLayout : chunkWWS3M5Y3_js.compact(finalLayout, compactType, cols)
837
- );
914
+ setLayout(compactor.compact(finalLayout, cols));
838
915
  setActiveDrag(placeholder);
839
916
  },
840
- [preventCollision, allowOverlap, compactType, cols, onResizeProp]
917
+ [preventCollision, compactType, cols, allowOverlap, compactor, onResizeProp]
841
918
  );
842
919
  const onResizeStop = React2.useCallback(
843
920
  (i, _w, _h, data) => {
844
921
  const currentLayout = layoutRef.current;
845
922
  const oldResizeItem = oldResizeItemRef.current;
846
923
  const l = chunkBJFPTW5Q_js.getLayoutItem(currentLayout, i);
847
- const finalLayout = allowOverlap ? currentLayout : chunkWWS3M5Y3_js.compact(currentLayout, compactType, cols);
924
+ const finalLayout = compactor.compact(currentLayout, cols);
848
925
  onResizeStopProp(
849
926
  finalLayout,
850
927
  oldResizeItem,
@@ -863,21 +940,26 @@ function GridLayout(props) {
863
940
  onLayoutChange(finalLayout);
864
941
  }
865
942
  },
866
- [allowOverlap, compactType, cols, onResizeStopProp, onLayoutChange]
943
+ [cols, compactor, onResizeStopProp, onLayoutChange]
867
944
  );
868
945
  const removeDroppingPlaceholder = React2.useCallback(() => {
869
946
  const currentLayout = layoutRef.current;
870
- const newLayout = chunkWWS3M5Y3_js.compact(
947
+ const hasDroppingItem = currentLayout.some((l) => l.i === droppingItem.i);
948
+ if (!hasDroppingItem) {
949
+ setDroppingDOMNode(null);
950
+ setActiveDrag(null);
951
+ setDroppingPosition(void 0);
952
+ return;
953
+ }
954
+ const newLayout = compactor.compact(
871
955
  currentLayout.filter((l) => l.i !== droppingItem.i),
872
- compactType,
873
- cols,
874
- allowOverlap
956
+ cols
875
957
  );
876
958
  setLayout(newLayout);
877
959
  setDroppingDOMNode(null);
878
960
  setActiveDrag(null);
879
961
  setDroppingPosition(void 0);
880
- }, [droppingItem.i, compactType, cols, allowOverlap]);
962
+ }, [droppingItem.i, cols, compactor]);
881
963
  const handleDragOver = React2.useCallback(
882
964
  (e) => {
883
965
  e.preventDefault();
@@ -887,7 +969,7 @@ function GridLayout(props) {
887
969
  )) {
888
970
  return false;
889
971
  }
890
- const rawResult = onDropDragOverProp(e);
972
+ const rawResult = dropConfigOnDragOver ? dropConfigOnDragOver(e.nativeEvent) : onDropDragOverProp(e);
891
973
  if (rawResult === false) {
892
974
  if (droppingDOMNode) {
893
975
  removeDroppingPlaceholder();
@@ -962,6 +1044,7 @@ function GridLayout(props) {
962
1044
  droppingDOMNode,
963
1045
  droppingPosition,
964
1046
  droppingItem,
1047
+ dropConfigOnDragOver,
965
1048
  onDropDragOverProp,
966
1049
  removeDroppingPlaceholder,
967
1050
  transformScale,
@@ -978,6 +1061,9 @@ function GridLayout(props) {
978
1061
  e.preventDefault();
979
1062
  e.stopPropagation();
980
1063
  dragEnterCounterRef.current--;
1064
+ if (dragEnterCounterRef.current < 0) {
1065
+ dragEnterCounterRef.current = 0;
1066
+ }
981
1067
  if (dragEnterCounterRef.current === 0) {
982
1068
  removeDroppingPlaceholder();
983
1069
  }
@@ -1034,6 +1120,8 @@ function GridLayout(props) {
1034
1120
  useCSSTransforms: useCSSTransforms && mounted,
1035
1121
  usePercentages: !mounted,
1036
1122
  transformScale,
1123
+ positionStrategy,
1124
+ dragThreshold,
1037
1125
  w: l.w,
1038
1126
  h: l.h,
1039
1127
  x: l.x,
@@ -1077,6 +1165,8 @@ function GridLayout(props) {
1077
1165
  useCSSTransforms,
1078
1166
  mounted,
1079
1167
  transformScale,
1168
+ positionStrategy,
1169
+ dragThreshold,
1080
1170
  droppingPosition,
1081
1171
  resizeHandles,
1082
1172
  resizeHandle,
@@ -1153,7 +1243,7 @@ var DEFAULT_COLS = {
1153
1243
  };
1154
1244
  var noop2 = () => {
1155
1245
  };
1156
- function synchronizeLayoutWithChildren2(initialLayout, children, cols, compactType, allowOverlap) {
1246
+ function synchronizeLayoutWithChildren2(initialLayout, children, cols, compactor) {
1157
1247
  const layout = [];
1158
1248
  React2__default.default.Children.forEach(children, (child) => {
1159
1249
  if (!React2__default.default.isValidElement(child) || child.key === null) return;
@@ -1196,7 +1286,7 @@ function synchronizeLayoutWithChildren2(initialLayout, children, cols, compactTy
1196
1286
  }
1197
1287
  });
1198
1288
  const corrected = chunkBJFPTW5Q_js.correctBounds(layout, { cols });
1199
- return chunkWWS3M5Y3_js.compact(corrected, compactType, cols, allowOverlap);
1289
+ return compactor.compact(corrected, cols);
1200
1290
  }
1201
1291
  function ResponsiveGridLayout(props) {
1202
1292
  const {
@@ -1216,17 +1306,17 @@ function ResponsiveGridLayout(props) {
1216
1306
  onWidthChange = noop2,
1217
1307
  ...restProps
1218
1308
  } = props;
1219
- const compactor = compactorProp ?? chunkWWS3M5Y3_js.getCompactor("vertical");
1309
+ const compactor = compactorProp ?? chunk2DDROKB2_js.getCompactor("vertical");
1220
1310
  const compactType = compactor.type;
1221
1311
  const allowOverlap = compactor.allowOverlap;
1222
1312
  const initialBreakpoint = React2.useMemo(() => {
1223
- return propBreakpoint ?? chunkWWS3M5Y3_js.getBreakpointFromWidth(breakpoints, width);
1313
+ return propBreakpoint ?? chunk2DDROKB2_js.getBreakpointFromWidth(breakpoints, width);
1224
1314
  }, []);
1225
1315
  const initialCols = React2.useMemo(() => {
1226
- return chunkWWS3M5Y3_js.getColsFromBreakpoint(initialBreakpoint, colsConfig);
1316
+ return chunk2DDROKB2_js.getColsFromBreakpoint(initialBreakpoint, colsConfig);
1227
1317
  }, [initialBreakpoint, colsConfig]);
1228
1318
  const initialLayout = React2.useMemo(() => {
1229
- return chunkWWS3M5Y3_js.findOrGenerateResponsiveLayout(
1319
+ return chunk2DDROKB2_js.findOrGenerateResponsiveLayout(
1230
1320
  propsLayouts,
1231
1321
  breakpoints,
1232
1322
  initialBreakpoint,
@@ -1251,17 +1341,17 @@ function ResponsiveGridLayout(props) {
1251
1341
  }, [layouts]);
1252
1342
  const derivedLayout = React2.useMemo(() => {
1253
1343
  if (!fastEquals.deepEqual(propsLayouts, prevLayoutsRef.current)) {
1254
- return chunkWWS3M5Y3_js.findOrGenerateResponsiveLayout(
1344
+ return chunk2DDROKB2_js.findOrGenerateResponsiveLayout(
1255
1345
  propsLayouts,
1256
1346
  breakpoints,
1257
1347
  breakpoint,
1258
1348
  breakpoint,
1259
1349
  cols,
1260
- compactType
1350
+ compactor
1261
1351
  );
1262
1352
  }
1263
1353
  return null;
1264
- }, [propsLayouts, breakpoints, breakpoint, cols, compactType]);
1354
+ }, [propsLayouts, breakpoints, breakpoint, cols, compactor]);
1265
1355
  const effectiveLayout = derivedLayout ?? layout;
1266
1356
  React2.useEffect(() => {
1267
1357
  if (derivedLayout !== null) {
@@ -1273,12 +1363,7 @@ function ResponsiveGridLayout(props) {
1273
1363
  }, [derivedLayout, propsLayouts]);
1274
1364
  React2.useEffect(() => {
1275
1365
  if (compactType !== prevCompactTypeRef.current) {
1276
- const newLayout = chunkWWS3M5Y3_js.compact(
1277
- chunkBJFPTW5Q_js.cloneLayout(effectiveLayout),
1278
- compactType,
1279
- cols,
1280
- allowOverlap
1281
- );
1366
+ const newLayout = compactor.compact(chunkBJFPTW5Q_js.cloneLayout(effectiveLayout), cols);
1282
1367
  const newLayouts = {
1283
1368
  ...layoutsRef.current,
1284
1369
  [breakpoint]: newLayout
@@ -1291,6 +1376,7 @@ function ResponsiveGridLayout(props) {
1291
1376
  }
1292
1377
  }, [
1293
1378
  compactType,
1379
+ compactor,
1294
1380
  effectiveLayout,
1295
1381
  cols,
1296
1382
  allowOverlap,
@@ -1306,28 +1392,27 @@ function ResponsiveGridLayout(props) {
1306
1392
  );
1307
1393
  const colsChanged = !fastEquals.deepEqual(colsConfig, prevColsRef.current);
1308
1394
  if (widthChanged || breakpointPropChanged || breakpointsChanged || colsChanged) {
1309
- const newBreakpoint = propBreakpoint ?? chunkWWS3M5Y3_js.getBreakpointFromWidth(breakpoints, width);
1310
- const newCols = chunkWWS3M5Y3_js.getColsFromBreakpoint(newBreakpoint, colsConfig);
1395
+ const newBreakpoint = propBreakpoint ?? chunk2DDROKB2_js.getBreakpointFromWidth(breakpoints, width);
1396
+ const newCols = chunk2DDROKB2_js.getColsFromBreakpoint(newBreakpoint, colsConfig);
1311
1397
  const lastBreakpoint = breakpoint;
1312
1398
  if (lastBreakpoint !== newBreakpoint || breakpointsChanged || colsChanged) {
1313
1399
  const newLayouts = { ...layoutsRef.current };
1314
1400
  if (!newLayouts[lastBreakpoint]) {
1315
1401
  newLayouts[lastBreakpoint] = chunkBJFPTW5Q_js.cloneLayout(layout);
1316
1402
  }
1317
- let newLayout = chunkWWS3M5Y3_js.findOrGenerateResponsiveLayout(
1403
+ let newLayout = chunk2DDROKB2_js.findOrGenerateResponsiveLayout(
1318
1404
  newLayouts,
1319
1405
  breakpoints,
1320
1406
  newBreakpoint,
1321
1407
  lastBreakpoint,
1322
1408
  newCols,
1323
- compactType
1409
+ compactor
1324
1410
  );
1325
1411
  newLayout = synchronizeLayoutWithChildren2(
1326
1412
  newLayout,
1327
1413
  children,
1328
1414
  newCols,
1329
- compactType,
1330
- allowOverlap
1415
+ compactor
1331
1416
  );
1332
1417
  newLayouts[newBreakpoint] = newLayout;
1333
1418
  setBreakpoint(newBreakpoint);
@@ -1338,11 +1423,11 @@ function ResponsiveGridLayout(props) {
1338
1423
  onBreakpointChange(newBreakpoint, newCols);
1339
1424
  onLayoutChange(newLayout, newLayouts);
1340
1425
  }
1341
- const currentMargin2 = chunkWWS3M5Y3_js.getIndentationValue(
1426
+ const currentMargin2 = chunk2DDROKB2_js.getIndentationValue(
1342
1427
  propMargin,
1343
1428
  newBreakpoint
1344
1429
  );
1345
- const currentPadding = propContainerPadding ? chunkWWS3M5Y3_js.getIndentationValue(
1430
+ const currentPadding = propContainerPadding ? chunk2DDROKB2_js.getIndentationValue(
1346
1431
  propContainerPadding,
1347
1432
  newBreakpoint
1348
1433
  ) : null;
@@ -1361,6 +1446,7 @@ function ResponsiveGridLayout(props) {
1361
1446
  cols,
1362
1447
  layout,
1363
1448
  children,
1449
+ compactor,
1364
1450
  compactType,
1365
1451
  allowOverlap,
1366
1452
  propMargin,
@@ -1384,14 +1470,14 @@ function ResponsiveGridLayout(props) {
1384
1470
  [breakpoint, onLayoutChange]
1385
1471
  );
1386
1472
  const currentMargin = React2.useMemo(() => {
1387
- return chunkWWS3M5Y3_js.getIndentationValue(
1473
+ return chunk2DDROKB2_js.getIndentationValue(
1388
1474
  propMargin,
1389
1475
  breakpoint
1390
1476
  );
1391
1477
  }, [propMargin, breakpoint]);
1392
1478
  const currentContainerPadding = React2.useMemo(() => {
1393
1479
  if (propContainerPadding === null) return null;
1394
- return chunkWWS3M5Y3_js.getIndentationValue(
1480
+ return chunk2DDROKB2_js.getIndentationValue(
1395
1481
  propContainerPadding,
1396
1482
  breakpoint
1397
1483
  );
@@ -1423,5 +1509,5 @@ function ResponsiveGridLayout(props) {
1423
1509
  exports.GridItem = GridItem;
1424
1510
  exports.GridLayout = GridLayout;
1425
1511
  exports.ResponsiveGridLayout = ResponsiveGridLayout;
1426
- //# sourceMappingURL=chunk-RB2IKK5B.js.map
1427
- //# sourceMappingURL=chunk-RB2IKK5B.js.map
1512
+ //# sourceMappingURL=chunk-3CEWSUXL.js.map
1513
+ //# sourceMappingURL=chunk-3CEWSUXL.js.map