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,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-FLITZMQC.mjs';
1
+ import { defaultConstraints, setTransform, setTopLeft, perc, applyPositionConstraints, resizeItemInDirection, applySizeConstraints, defaultPositionStrategy, defaultGridConfig, defaultDragConfig, defaultResizeConfig, defaultDropConfig, getCompactor, getBreakpointFromWidth, getColsFromBreakpoint, findOrGenerateResponsiveLayout, getIndentationValue } from './chunk-XYPIYYYQ.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: []
95
+ }),
96
+ [cols, maxRows, containerWidth, rowHeight, margin]
97
+ );
98
+ const getConstraintContext = useCallback(
99
+ () => ({
100
+ ...constraintContext,
101
+ layout: layoutRef.current
86
102
  }),
87
- [cols, maxRows, containerWidth, rowHeight, margin, layout]
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);
@@ -618,8 +699,7 @@ function GridLayout(props) {
618
699
  baseLayout,
619
700
  children,
620
701
  cols,
621
- compactType,
622
- allowOverlap
702
+ compactor
623
703
  );
624
704
  setLayout(newLayout);
625
705
  }
@@ -631,7 +711,7 @@ function GridLayout(props) {
631
711
  children,
632
712
  cols,
633
713
  compactType,
634
- allowOverlap,
714
+ compactor,
635
715
  activeDrag,
636
716
  droppingDOMNode,
637
717
  layout
@@ -692,12 +772,10 @@ function GridLayout(props) {
692
772
  allowOverlap
693
773
  );
694
774
  onDragProp(newLayout, oldDragItem, l, placeholder, data.e, data.node);
695
- setLayout(
696
- allowOverlap ? newLayout : compact(newLayout, compactType, cols)
697
- );
775
+ setLayout(compactor.compact(newLayout, cols));
698
776
  setActiveDrag(placeholder);
699
777
  },
700
- [preventCollision, compactType, cols, allowOverlap, onDragProp]
778
+ [preventCollision, compactType, cols, allowOverlap, compactor, onDragProp]
701
779
  );
702
780
  const onDragStop = useCallback(
703
781
  (i, x, y, data) => {
@@ -717,7 +795,7 @@ function GridLayout(props) {
717
795
  cols,
718
796
  allowOverlap
719
797
  );
720
- const finalLayout = allowOverlap ? newLayout : compact(newLayout, compactType, cols);
798
+ const finalLayout = compactor.compact(newLayout, cols);
721
799
  onDragStopProp(finalLayout, oldDragItem, l, null, data.e, data.node);
722
800
  const oldLayout = oldLayoutRef.current;
723
801
  oldDragItemRef.current = null;
@@ -734,6 +812,7 @@ function GridLayout(props) {
734
812
  compactType,
735
813
  cols,
736
814
  allowOverlap,
815
+ compactor,
737
816
  onDragStopProp,
738
817
  onLayoutChange
739
818
  ]
@@ -825,19 +904,17 @@ function GridLayout(props) {
825
904
  data.e,
826
905
  data.node
827
906
  );
828
- setLayout(
829
- allowOverlap ? finalLayout : compact(finalLayout, compactType, cols)
830
- );
907
+ setLayout(compactor.compact(finalLayout, cols));
831
908
  setActiveDrag(placeholder);
832
909
  },
833
- [preventCollision, allowOverlap, compactType, cols, onResizeProp]
910
+ [preventCollision, compactType, cols, allowOverlap, compactor, onResizeProp]
834
911
  );
835
912
  const onResizeStop = useCallback(
836
913
  (i, _w, _h, data) => {
837
914
  const currentLayout = layoutRef.current;
838
915
  const oldResizeItem = oldResizeItemRef.current;
839
916
  const l = getLayoutItem(currentLayout, i);
840
- const finalLayout = allowOverlap ? currentLayout : compact(currentLayout, compactType, cols);
917
+ const finalLayout = compactor.compact(currentLayout, cols);
841
918
  onResizeStopProp(
842
919
  finalLayout,
843
920
  oldResizeItem,
@@ -856,21 +933,26 @@ function GridLayout(props) {
856
933
  onLayoutChange(finalLayout);
857
934
  }
858
935
  },
859
- [allowOverlap, compactType, cols, onResizeStopProp, onLayoutChange]
936
+ [cols, compactor, onResizeStopProp, onLayoutChange]
860
937
  );
861
938
  const removeDroppingPlaceholder = useCallback(() => {
862
939
  const currentLayout = layoutRef.current;
863
- const newLayout = compact(
940
+ const hasDroppingItem = currentLayout.some((l) => l.i === droppingItem.i);
941
+ if (!hasDroppingItem) {
942
+ setDroppingDOMNode(null);
943
+ setActiveDrag(null);
944
+ setDroppingPosition(void 0);
945
+ return;
946
+ }
947
+ const newLayout = compactor.compact(
864
948
  currentLayout.filter((l) => l.i !== droppingItem.i),
865
- compactType,
866
- cols,
867
- allowOverlap
949
+ cols
868
950
  );
869
951
  setLayout(newLayout);
870
952
  setDroppingDOMNode(null);
871
953
  setActiveDrag(null);
872
954
  setDroppingPosition(void 0);
873
- }, [droppingItem.i, compactType, cols, allowOverlap]);
955
+ }, [droppingItem.i, cols, compactor]);
874
956
  const handleDragOver = useCallback(
875
957
  (e) => {
876
958
  e.preventDefault();
@@ -880,7 +962,7 @@ function GridLayout(props) {
880
962
  )) {
881
963
  return false;
882
964
  }
883
- const rawResult = onDropDragOverProp(e);
965
+ const rawResult = dropConfigOnDragOver ? dropConfigOnDragOver(e.nativeEvent) : onDropDragOverProp(e);
884
966
  if (rawResult === false) {
885
967
  if (droppingDOMNode) {
886
968
  removeDroppingPlaceholder();
@@ -955,6 +1037,7 @@ function GridLayout(props) {
955
1037
  droppingDOMNode,
956
1038
  droppingPosition,
957
1039
  droppingItem,
1040
+ dropConfigOnDragOver,
958
1041
  onDropDragOverProp,
959
1042
  removeDroppingPlaceholder,
960
1043
  transformScale,
@@ -971,6 +1054,9 @@ function GridLayout(props) {
971
1054
  e.preventDefault();
972
1055
  e.stopPropagation();
973
1056
  dragEnterCounterRef.current--;
1057
+ if (dragEnterCounterRef.current < 0) {
1058
+ dragEnterCounterRef.current = 0;
1059
+ }
974
1060
  if (dragEnterCounterRef.current === 0) {
975
1061
  removeDroppingPlaceholder();
976
1062
  }
@@ -1027,6 +1113,8 @@ function GridLayout(props) {
1027
1113
  useCSSTransforms: useCSSTransforms && mounted,
1028
1114
  usePercentages: !mounted,
1029
1115
  transformScale,
1116
+ positionStrategy,
1117
+ dragThreshold,
1030
1118
  w: l.w,
1031
1119
  h: l.h,
1032
1120
  x: l.x,
@@ -1070,6 +1158,8 @@ function GridLayout(props) {
1070
1158
  useCSSTransforms,
1071
1159
  mounted,
1072
1160
  transformScale,
1161
+ positionStrategy,
1162
+ dragThreshold,
1073
1163
  droppingPosition,
1074
1164
  resizeHandles,
1075
1165
  resizeHandle,
@@ -1146,7 +1236,7 @@ var DEFAULT_COLS = {
1146
1236
  };
1147
1237
  var noop2 = () => {
1148
1238
  };
1149
- function synchronizeLayoutWithChildren2(initialLayout, children, cols, compactType, allowOverlap) {
1239
+ function synchronizeLayoutWithChildren2(initialLayout, children, cols, compactor) {
1150
1240
  const layout = [];
1151
1241
  React2.Children.forEach(children, (child) => {
1152
1242
  if (!React2.isValidElement(child) || child.key === null) return;
@@ -1189,7 +1279,7 @@ function synchronizeLayoutWithChildren2(initialLayout, children, cols, compactTy
1189
1279
  }
1190
1280
  });
1191
1281
  const corrected = correctBounds(layout, { cols });
1192
- return compact(corrected, compactType, cols, allowOverlap);
1282
+ return compactor.compact(corrected, cols);
1193
1283
  }
1194
1284
  function ResponsiveGridLayout(props) {
1195
1285
  const {
@@ -1250,11 +1340,11 @@ function ResponsiveGridLayout(props) {
1250
1340
  breakpoint,
1251
1341
  breakpoint,
1252
1342
  cols,
1253
- compactType
1343
+ compactor
1254
1344
  );
1255
1345
  }
1256
1346
  return null;
1257
- }, [propsLayouts, breakpoints, breakpoint, cols, compactType]);
1347
+ }, [propsLayouts, breakpoints, breakpoint, cols, compactor]);
1258
1348
  const effectiveLayout = derivedLayout ?? layout;
1259
1349
  useEffect(() => {
1260
1350
  if (derivedLayout !== null) {
@@ -1266,12 +1356,7 @@ function ResponsiveGridLayout(props) {
1266
1356
  }, [derivedLayout, propsLayouts]);
1267
1357
  useEffect(() => {
1268
1358
  if (compactType !== prevCompactTypeRef.current) {
1269
- const newLayout = compact(
1270
- cloneLayout(effectiveLayout),
1271
- compactType,
1272
- cols,
1273
- allowOverlap
1274
- );
1359
+ const newLayout = compactor.compact(cloneLayout(effectiveLayout), cols);
1275
1360
  const newLayouts = {
1276
1361
  ...layoutsRef.current,
1277
1362
  [breakpoint]: newLayout
@@ -1284,6 +1369,7 @@ function ResponsiveGridLayout(props) {
1284
1369
  }
1285
1370
  }, [
1286
1371
  compactType,
1372
+ compactor,
1287
1373
  effectiveLayout,
1288
1374
  cols,
1289
1375
  allowOverlap,
@@ -1313,14 +1399,13 @@ function ResponsiveGridLayout(props) {
1313
1399
  newBreakpoint,
1314
1400
  lastBreakpoint,
1315
1401
  newCols,
1316
- compactType
1402
+ compactor
1317
1403
  );
1318
1404
  newLayout = synchronizeLayoutWithChildren2(
1319
1405
  newLayout,
1320
1406
  children,
1321
1407
  newCols,
1322
- compactType,
1323
- allowOverlap
1408
+ compactor
1324
1409
  );
1325
1410
  newLayouts[newBreakpoint] = newLayout;
1326
1411
  setBreakpoint(newBreakpoint);
@@ -1354,6 +1439,7 @@ function ResponsiveGridLayout(props) {
1354
1439
  cols,
1355
1440
  layout,
1356
1441
  children,
1442
+ compactor,
1357
1443
  compactType,
1358
1444
  allowOverlap,
1359
1445
  propMargin,
@@ -1414,5 +1500,5 @@ function ResponsiveGridLayout(props) {
1414
1500
  }
1415
1501
 
1416
1502
  export { GridItem, GridLayout, ResponsiveGridLayout };
1417
- //# sourceMappingURL=chunk-PLWMASMX.mjs.map
1418
- //# sourceMappingURL=chunk-PLWMASMX.mjs.map
1503
+ //# sourceMappingURL=chunk-AZ6K3JIJ.mjs.map
1504
+ //# sourceMappingURL=chunk-AZ6K3JIJ.mjs.map