react-grid-layout 2.2.1 → 2.2.3

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 (63) hide show
  1. package/dist/{ResponsiveGridLayout-MbDNfJ8M.d.ts → ResponsiveGridLayout-BjVraYMQ.d.mts} +2 -3
  2. package/dist/{ResponsiveGridLayout-DqK__izz.d.mts → ResponsiveGridLayout-BrhkSyZk.d.ts} +2 -3
  3. package/dist/{calculate-FbCWy8x1.d.mts → calculate-DH4EVtn1.d.mts} +2 -2
  4. package/dist/{calculate-9RxGrt-U.d.ts → calculate-rP3DHexe.d.ts} +2 -2
  5. package/dist/{chunk-2DDROKB2.js → chunk-55DQUWLA.js} +21 -23
  6. package/dist/{chunk-AWM66AWF.mjs → chunk-76RTO6EO.mjs} +0 -2
  7. package/dist/{chunk-QGXQSZII.js → chunk-7MZZ6T4J.js} +49 -35
  8. package/dist/{chunk-BJFPTW5Q.js → chunk-A5WIFECI.js} +0 -2
  9. package/dist/{chunk-3CEWSUXL.js → chunk-BPZQUJ7Y.js} +101 -84
  10. package/dist/{chunk-XYPIYYYQ.mjs → chunk-KDANGDDL.mjs} +1 -3
  11. package/dist/chunk-O3KX3VYW.mjs +1 -0
  12. package/dist/{chunk-YFVX5RDK.mjs → chunk-PZLKKWSX.mjs} +19 -5
  13. package/dist/{chunk-AZ6K3JIJ.mjs → chunk-WGL5FSZH.mjs} +34 -17
  14. package/dist/chunk-ZJHF4QM5.js +2 -0
  15. package/dist/core.d.mts +5 -5
  16. package/dist/core.d.ts +5 -5
  17. package/dist/core.js +68 -70
  18. package/dist/core.mjs +3 -5
  19. package/dist/extras.d.mts +2 -2
  20. package/dist/extras.d.ts +2 -2
  21. package/dist/extras.js +8 -10
  22. package/dist/extras.mjs +1 -3
  23. package/dist/index.d.mts +5 -5
  24. package/dist/index.d.ts +5 -5
  25. package/dist/index.js +40 -42
  26. package/dist/index.mjs +5 -7
  27. package/dist/legacy.d.mts +2 -2
  28. package/dist/legacy.d.ts +2 -2
  29. package/dist/legacy.js +25 -17
  30. package/dist/legacy.mjs +14 -6
  31. package/dist/{position-CetgOHhD.d.mts → position-BV-g3Ezg.d.mts} +2 -2
  32. package/dist/{position-DhZqWO1-.d.ts → position-CSgQSjwQ.d.ts} +2 -2
  33. package/dist/react.d.mts +5 -5
  34. package/dist/react.d.ts +5 -5
  35. package/dist/react.js +26 -28
  36. package/dist/react.mjs +5 -7
  37. package/dist/{responsive-T0N0GmBB.d.mts → responsive-BrTV_0tK.d.mts} +2 -2
  38. package/dist/{responsive-DLRtE8v8.d.ts → responsive-C_YtBQYq.d.ts} +2 -2
  39. package/dist/{types-BiXsdXr7.d.mts → types-jd8MiKM1.d.mts} +1 -1
  40. package/dist/{types-BiXsdXr7.d.ts → types-jd8MiKM1.d.ts} +1 -1
  41. package/package.json +22 -22
  42. package/dist/chunk-2DDROKB2.js.map +0 -1
  43. package/dist/chunk-3CEWSUXL.js.map +0 -1
  44. package/dist/chunk-AWM66AWF.mjs.map +0 -1
  45. package/dist/chunk-AZ6K3JIJ.mjs.map +0 -1
  46. package/dist/chunk-BJFPTW5Q.js.map +0 -1
  47. package/dist/chunk-PBQSHIID.js +0 -4
  48. package/dist/chunk-PBQSHIID.js.map +0 -1
  49. package/dist/chunk-QGXQSZII.js.map +0 -1
  50. package/dist/chunk-XYPIYYYQ.mjs.map +0 -1
  51. package/dist/chunk-YFVX5RDK.mjs.map +0 -1
  52. package/dist/chunk-ZWN22PS2.mjs +0 -3
  53. package/dist/chunk-ZWN22PS2.mjs.map +0 -1
  54. package/dist/core.js.map +0 -1
  55. package/dist/core.mjs.map +0 -1
  56. package/dist/extras.js.map +0 -1
  57. package/dist/extras.mjs.map +0 -1
  58. package/dist/index.js.map +0 -1
  59. package/dist/index.mjs.map +0 -1
  60. package/dist/legacy.js.map +0 -1
  61. package/dist/legacy.mjs.map +0 -1
  62. package/dist/react.js.map +0 -1
  63. package/dist/react.mjs.map +0 -1
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunk2DDROKB2_js = require('./chunk-2DDROKB2.js');
4
- var chunkBJFPTW5Q_js = require('./chunk-BJFPTW5Q.js');
3
+ var chunk55DQUWLA_js = require('./chunk-55DQUWLA.js');
4
+ var chunkA5WIFECI_js = require('./chunk-A5WIFECI.js');
5
5
  var React2 = require('react');
6
6
  var reactDraggable = require('react-draggable');
7
7
  var reactResizable = require('react-resizable');
@@ -48,7 +48,7 @@ function GridItem(props) {
48
48
  i,
49
49
  resizeHandles,
50
50
  resizeHandle,
51
- constraints = chunk2DDROKB2_js.defaultConstraints,
51
+ constraints = chunk55DQUWLA_js.defaultConstraints,
52
52
  layoutItem,
53
53
  layout = [],
54
54
  onDragStart: onDragStartProp,
@@ -73,6 +73,8 @@ function GridItem(props) {
73
73
  );
74
74
  const layoutRef = React2.useRef(layout);
75
75
  layoutRef.current = layout;
76
+ const onDragStartRef = React2.useRef(null);
77
+ const onDragRef = React2.useRef(null);
76
78
  const dragPendingRef = React2.useRef(false);
77
79
  const initialDragClientRef = React2.useRef({ x: 0, y: 0 });
78
80
  const thresholdExceededRef = React2.useRef(false);
@@ -129,14 +131,14 @@ function GridItem(props) {
129
131
  return positionStrategy.calcStyle(pos2);
130
132
  }
131
133
  if (useCSSTransforms) {
132
- return chunk2DDROKB2_js.setTransform(pos2);
134
+ return chunk55DQUWLA_js.setTransform(pos2);
133
135
  }
134
- const styleObj = chunk2DDROKB2_js.setTopLeft(pos2);
136
+ const styleObj = chunk55DQUWLA_js.setTopLeft(pos2);
135
137
  if (usePercentages) {
136
138
  return {
137
139
  ...styleObj,
138
- left: chunk2DDROKB2_js.perc(pos2.left / containerWidth),
139
- width: chunk2DDROKB2_js.perc(pos2.width / containerWidth)
140
+ left: chunk55DQUWLA_js.perc(pos2.left / containerWidth),
141
+ width: chunk55DQUWLA_js.perc(pos2.width / containerWidth)
140
142
  };
141
143
  }
142
144
  return styleObj;
@@ -182,12 +184,12 @@ function GridItem(props) {
182
184
  return;
183
185
  }
184
186
  setDragging(true);
185
- const rawPos = chunkBJFPTW5Q_js.calcXYRaw(
187
+ const rawPos = chunkA5WIFECI_js.calcXYRaw(
186
188
  positionParams,
187
189
  newPosition.top,
188
190
  newPosition.left
189
191
  );
190
- const { x: newX, y: newY } = chunk2DDROKB2_js.applyPositionConstraints(
192
+ const { x: newX, y: newY } = chunk55DQUWLA_js.applyPositionConstraints(
191
193
  constraints,
192
194
  effectiveLayoutItem,
193
195
  rawPos.x,
@@ -226,12 +228,12 @@ function GridItem(props) {
226
228
  thresholdExceededRef.current = true;
227
229
  dragPendingRef.current = false;
228
230
  if (onDragStartProp) {
229
- const rawPos2 = chunkBJFPTW5Q_js.calcXYRaw(
231
+ const rawPos2 = chunkA5WIFECI_js.calcXYRaw(
230
232
  positionParams,
231
233
  dragPositionRef.current.top,
232
234
  dragPositionRef.current.left
233
235
  );
234
- const { x: startX, y: startY } = chunk2DDROKB2_js.applyPositionConstraints(
236
+ const { x: startX, y: startY } = chunk55DQUWLA_js.applyPositionConstraints(
235
237
  constraints,
236
238
  effectiveLayoutItem,
237
239
  rawPos2.x,
@@ -250,17 +252,17 @@ function GridItem(props) {
250
252
  if (isBounded) {
251
253
  const { offsetParent } = node;
252
254
  if (offsetParent) {
253
- const bottomBoundary = offsetParent.clientHeight - chunkBJFPTW5Q_js.calcGridItemWHPx(h, rowHeight, margin[1]);
254
- top = chunkBJFPTW5Q_js.clamp(top, 0, bottomBoundary);
255
- const colWidth = chunkBJFPTW5Q_js.calcGridColWidth(positionParams);
256
- const rightBoundary = containerWidth - chunkBJFPTW5Q_js.calcGridItemWHPx(w, colWidth, margin[0]);
257
- left = chunkBJFPTW5Q_js.clamp(left, 0, rightBoundary);
255
+ const bottomBoundary = offsetParent.clientHeight - chunkA5WIFECI_js.calcGridItemWHPx(h, rowHeight, margin[1]);
256
+ top = chunkA5WIFECI_js.clamp(top, 0, bottomBoundary);
257
+ const colWidth2 = chunkA5WIFECI_js.calcGridColWidth(positionParams);
258
+ const rightBoundary = containerWidth - chunkA5WIFECI_js.calcGridItemWHPx(w, colWidth2, margin[0]);
259
+ left = chunkA5WIFECI_js.clamp(left, 0, rightBoundary);
258
260
  }
259
261
  }
260
262
  const newPosition = { top, left };
261
263
  dragPositionRef.current = newPosition;
262
- const rawPos = chunkBJFPTW5Q_js.calcXYRaw(positionParams, top, left);
263
- const { x: newX, y: newY } = chunk2DDROKB2_js.applyPositionConstraints(
264
+ const rawPos = chunkA5WIFECI_js.calcXYRaw(positionParams, top, left);
265
+ const { x: newX, y: newY } = chunk55DQUWLA_js.applyPositionConstraints(
264
266
  constraints,
265
267
  effectiveLayoutItem,
266
268
  rawPos.x,
@@ -307,8 +309,8 @@ function GridItem(props) {
307
309
  const newPosition = { top, left };
308
310
  setDragging(false);
309
311
  dragPositionRef.current = { left: 0, top: 0 };
310
- const rawPos = chunkBJFPTW5Q_js.calcXYRaw(positionParams, top, left);
311
- const { x: newX, y: newY } = chunk2DDROKB2_js.applyPositionConstraints(
312
+ const rawPos = chunkA5WIFECI_js.calcXYRaw(positionParams, top, left);
313
+ const { x: newX, y: newY } = chunk55DQUWLA_js.applyPositionConstraints(
312
314
  constraints,
313
315
  effectiveLayoutItem,
314
316
  rawPos.x,
@@ -331,13 +333,15 @@ function GridItem(props) {
331
333
  i
332
334
  ]
333
335
  );
336
+ onDragStartRef.current = onDragStart;
337
+ onDragRef.current = onDrag;
334
338
  const onResizeHandler = React2.useCallback(
335
339
  (e, { node, size, handle: resizeHandle2 }, position, handlerName) => {
336
340
  const handler = handlerName === "onResizeStart" ? onResizeStartProp : handlerName === "onResize" ? onResizeProp : onResizeStopProp;
337
341
  if (!handler) return;
338
342
  let updatedSize;
339
343
  if (node) {
340
- updatedSize = chunk2DDROKB2_js.resizeItemInDirection(
344
+ updatedSize = chunk55DQUWLA_js.resizeItemInDirection(
341
345
  resizeHandle2,
342
346
  position,
343
347
  size,
@@ -351,12 +355,12 @@ function GridItem(props) {
351
355
  };
352
356
  }
353
357
  resizePositionRef.current = updatedSize;
354
- const rawSize = chunkBJFPTW5Q_js.calcWHRaw(
358
+ const rawSize = chunkA5WIFECI_js.calcWHRaw(
355
359
  positionParams,
356
360
  updatedSize.width,
357
361
  updatedSize.height
358
362
  );
359
- const { w: newW, h: newH } = chunk2DDROKB2_js.applySizeConstraints(
363
+ const { w: newW, h: newH } = chunk55DQUWLA_js.applySizeConstraints(
360
364
  constraints,
361
365
  effectiveLayoutItem,
362
366
  rawSize.w,
@@ -386,7 +390,7 @@ function GridItem(props) {
386
390
  const handleResizeStart = React2.useCallback(
387
391
  (e, data) => {
388
392
  setResizing(true);
389
- const pos2 = chunkBJFPTW5Q_js.calcGridItemPosition(positionParams, x, y, w, h);
393
+ const pos2 = chunkA5WIFECI_js.calcGridItemPosition(positionParams, x, y, w, h);
390
394
  const typedData = {
391
395
  ...data,
392
396
  handle: data.handle
@@ -397,7 +401,7 @@ function GridItem(props) {
397
401
  );
398
402
  const handleResize = React2.useCallback(
399
403
  (e, data) => {
400
- const pos2 = chunkBJFPTW5Q_js.calcGridItemPosition(positionParams, x, y, w, h);
404
+ const pos2 = chunkA5WIFECI_js.calcGridItemPosition(positionParams, x, y, w, h);
401
405
  const typedData = {
402
406
  ...data,
403
407
  handle: data.handle
@@ -410,7 +414,7 @@ function GridItem(props) {
410
414
  (e, data) => {
411
415
  setResizing(false);
412
416
  resizePositionRef.current = { top: 0, left: 0, width: 0, height: 0 };
413
- const pos2 = chunkBJFPTW5Q_js.calcGridItemPosition(positionParams, x, y, w, h);
417
+ const pos2 = chunkA5WIFECI_js.calcGridItemPosition(positionParams, x, y, w, h);
414
418
  const typedData = {
415
419
  ...data,
416
420
  handle: data.handle
@@ -438,7 +442,10 @@ function GridItem(props) {
438
442
  x: droppingPosition.left,
439
443
  y: droppingPosition.top
440
444
  };
441
- onDragStart(droppingPosition.e, fakeData);
445
+ onDragStartRef.current?.(
446
+ droppingPosition.e,
447
+ fakeData
448
+ );
442
449
  } else if (shouldDrag) {
443
450
  const deltaX = droppingPosition.left - dragPositionRef.current.left;
444
451
  const deltaY = droppingPosition.top - dragPositionRef.current.top;
@@ -451,11 +458,14 @@ function GridItem(props) {
451
458
  x: droppingPosition.left,
452
459
  y: droppingPosition.top
453
460
  };
454
- onDrag(droppingPosition.e, fakeData);
461
+ onDragRef.current?.(
462
+ droppingPosition.e,
463
+ fakeData
464
+ );
455
465
  }
456
466
  prevDroppingPositionRef.current = droppingPosition;
457
- }, [droppingPosition, dragging, onDragStart, onDrag]);
458
- const pos = chunkBJFPTW5Q_js.calcGridItemPosition(
467
+ }, [droppingPosition, dragging, i]);
468
+ const pos = chunkA5WIFECI_js.calcGridItemPosition(
459
469
  positionParams,
460
470
  x,
461
471
  y,
@@ -465,12 +475,15 @@ function GridItem(props) {
465
475
  resizing ? resizePositionRef.current : null
466
476
  );
467
477
  const child = React2__default.default.Children.only(children);
468
- const minGridUnit = chunkBJFPTW5Q_js.calcGridItemPosition(positionParams, 0, 0, 1, 1);
478
+ const colWidth = chunkA5WIFECI_js.calcGridColWidth(positionParams);
469
479
  const minConstraints = [
470
- minGridUnit.width,
471
- minGridUnit.height
480
+ chunkA5WIFECI_js.calcGridItemWHPx(minW, colWidth, margin[0]),
481
+ chunkA5WIFECI_js.calcGridItemWHPx(minH, rowHeight, margin[1])
482
+ ];
483
+ const maxConstraints = [
484
+ chunkA5WIFECI_js.calcGridItemWHPx(maxW, colWidth, margin[0]),
485
+ chunkA5WIFECI_js.calcGridItemWHPx(maxH, rowHeight, margin[1])
472
486
  ];
473
- const maxConstraints = [Infinity, Infinity];
474
487
  const childProps = child.props;
475
488
  const childClassName = childProps["className"];
476
489
  const childStyle = childProps["style"];
@@ -553,7 +566,7 @@ function synchronizeLayoutWithChildren(initialLayout, children, cols, compactor)
553
566
  childKeys.add(key);
554
567
  const existingItem = initialLayout.find((l) => l.i === key);
555
568
  if (existingItem) {
556
- layout.push(chunkBJFPTW5Q_js.cloneLayoutItem(existingItem));
569
+ layout.push(chunkA5WIFECI_js.cloneLayoutItem(existingItem));
557
570
  } else {
558
571
  const childProps = child.props;
559
572
  const dataGrid = childProps["data-grid"];
@@ -578,14 +591,14 @@ function synchronizeLayoutWithChildren(initialLayout, children, cols, compactor)
578
591
  layout.push({
579
592
  i: key,
580
593
  x: 0,
581
- y: chunkBJFPTW5Q_js.bottom(layout),
594
+ y: chunkA5WIFECI_js.bottom(layout),
582
595
  w: 1,
583
596
  h: 1
584
597
  });
585
598
  }
586
599
  }
587
600
  });
588
- const corrected = chunkBJFPTW5Q_js.correctBounds(layout, { cols });
601
+ const corrected = chunkA5WIFECI_js.correctBounds(layout, { cols });
589
602
  return compactor.compact(corrected, cols);
590
603
  }
591
604
  function GridLayout(props) {
@@ -598,9 +611,9 @@ function GridLayout(props) {
598
611
  dragConfig: dragConfigProp,
599
612
  resizeConfig: resizeConfigProp,
600
613
  dropConfig: dropConfigProp,
601
- positionStrategy = chunk2DDROKB2_js.defaultPositionStrategy,
614
+ positionStrategy = chunk55DQUWLA_js.defaultPositionStrategy,
602
615
  compactor: compactorProp,
603
- constraints = chunk2DDROKB2_js.defaultConstraints,
616
+ constraints = chunk55DQUWLA_js.defaultConstraints,
604
617
  // Layout data
605
618
  layout: propsLayout = [],
606
619
  droppingItem: droppingItemProp,
@@ -621,19 +634,19 @@ function GridLayout(props) {
621
634
  onDropDragOver: onDropDragOverProp = noop
622
635
  } = props;
623
636
  const gridConfig = React2.useMemo(
624
- () => ({ ...chunk2DDROKB2_js.defaultGridConfig, ...gridConfigProp }),
637
+ () => ({ ...chunk55DQUWLA_js.defaultGridConfig, ...gridConfigProp }),
625
638
  [gridConfigProp]
626
639
  );
627
640
  const dragConfig = React2.useMemo(
628
- () => ({ ...chunk2DDROKB2_js.defaultDragConfig, ...dragConfigProp }),
641
+ () => ({ ...chunk55DQUWLA_js.defaultDragConfig, ...dragConfigProp }),
629
642
  [dragConfigProp]
630
643
  );
631
644
  const resizeConfig = React2.useMemo(
632
- () => ({ ...chunk2DDROKB2_js.defaultResizeConfig, ...resizeConfigProp }),
645
+ () => ({ ...chunk55DQUWLA_js.defaultResizeConfig, ...resizeConfigProp }),
633
646
  [resizeConfigProp]
634
647
  );
635
648
  const dropConfig = React2.useMemo(
636
- () => ({ ...chunk2DDROKB2_js.defaultDropConfig, ...dropConfigProp }),
649
+ () => ({ ...chunk55DQUWLA_js.defaultDropConfig, ...dropConfigProp }),
637
650
  [dropConfigProp]
638
651
  );
639
652
  const { cols, rowHeight, maxRows, margin, containerPadding } = gridConfig;
@@ -654,7 +667,7 @@ function GridLayout(props) {
654
667
  defaultItem: defaultDropItem,
655
668
  onDragOver: dropConfigOnDragOver
656
669
  } = dropConfig;
657
- const compactor = compactorProp ?? chunk2DDROKB2_js.getCompactor("vertical");
670
+ const compactor = compactorProp ?? chunk55DQUWLA_js.getCompactor("vertical");
658
671
  const compactType = compactor.type;
659
672
  const allowOverlap = compactor.allowOverlap;
660
673
  const preventCollision = compactor.preventCollision ?? false;
@@ -708,7 +721,9 @@ function GridLayout(props) {
708
721
  cols,
709
722
  compactor
710
723
  );
711
- setLayout(newLayout);
724
+ if (!fastEquals.deepEqual(newLayout, layout)) {
725
+ setLayout(newLayout);
726
+ }
712
727
  }
713
728
  prevPropsLayoutRef.current = propsLayout;
714
729
  prevChildrenRef.current = children;
@@ -726,19 +741,20 @@ function GridLayout(props) {
726
741
  React2.useEffect(() => {
727
742
  if (!activeDrag && !fastEquals.deepEqual(layout, prevLayoutRef.current)) {
728
743
  prevLayoutRef.current = layout;
729
- onLayoutChange(layout);
744
+ const publicLayout = layout.filter((l) => l.i !== droppingItem.i);
745
+ onLayoutChange(publicLayout);
730
746
  }
731
- }, [layout, activeDrag, onLayoutChange]);
747
+ }, [layout, activeDrag, onLayoutChange, droppingItem.i]);
732
748
  const containerHeight = React2.useMemo(() => {
733
749
  if (!autoSize) return void 0;
734
- const nbRow = chunkBJFPTW5Q_js.bottom(layout);
750
+ const nbRow = chunkA5WIFECI_js.bottom(layout);
735
751
  const containerPaddingY = effectiveContainerPadding[1];
736
752
  return nbRow * rowHeight + (nbRow - 1) * margin[1] + containerPaddingY * 2 + "px";
737
753
  }, [autoSize, layout, rowHeight, margin, effectiveContainerPadding]);
738
754
  const onDragStart = React2.useCallback(
739
755
  (i, _x, _y, data) => {
740
756
  const currentLayout = layoutRef.current;
741
- const l = chunkBJFPTW5Q_js.getLayoutItem(currentLayout, i);
757
+ const l = chunkA5WIFECI_js.getLayoutItem(currentLayout, i);
742
758
  if (!l) return;
743
759
  const placeholder = {
744
760
  w: l.w,
@@ -747,7 +763,7 @@ function GridLayout(props) {
747
763
  y: l.y,
748
764
  i
749
765
  };
750
- oldDragItemRef.current = chunkBJFPTW5Q_js.cloneLayoutItem(l);
766
+ oldDragItemRef.current = chunkA5WIFECI_js.cloneLayoutItem(l);
751
767
  oldLayoutRef.current = currentLayout;
752
768
  setActiveDrag(placeholder);
753
769
  onDragStartProp(currentLayout, l, l, null, data.e, data.node);
@@ -758,7 +774,7 @@ function GridLayout(props) {
758
774
  (i, x, y, data) => {
759
775
  const currentLayout = layoutRef.current;
760
776
  const oldDragItem = oldDragItemRef.current;
761
- const l = chunkBJFPTW5Q_js.getLayoutItem(currentLayout, i);
777
+ const l = chunkA5WIFECI_js.getLayoutItem(currentLayout, i);
762
778
  if (!l) return;
763
779
  const placeholder = {
764
780
  w: l.w,
@@ -767,7 +783,7 @@ function GridLayout(props) {
767
783
  y: l.y,
768
784
  i
769
785
  };
770
- const newLayout = chunkBJFPTW5Q_js.moveElement(
786
+ const newLayout = chunkA5WIFECI_js.moveElement(
771
787
  currentLayout,
772
788
  l,
773
789
  x,
@@ -789,9 +805,9 @@ function GridLayout(props) {
789
805
  if (!activeDrag) return;
790
806
  const currentLayout = layoutRef.current;
791
807
  const oldDragItem = oldDragItemRef.current;
792
- const l = chunkBJFPTW5Q_js.getLayoutItem(currentLayout, i);
808
+ const l = chunkA5WIFECI_js.getLayoutItem(currentLayout, i);
793
809
  if (!l) return;
794
- const newLayout = chunkBJFPTW5Q_js.moveElement(
810
+ const newLayout = chunkA5WIFECI_js.moveElement(
795
811
  currentLayout,
796
812
  l,
797
813
  x,
@@ -827,9 +843,9 @@ function GridLayout(props) {
827
843
  const onResizeStart = React2.useCallback(
828
844
  (i, _w, _h, data) => {
829
845
  const currentLayout = layoutRef.current;
830
- const l = chunkBJFPTW5Q_js.getLayoutItem(currentLayout, i);
846
+ const l = chunkA5WIFECI_js.getLayoutItem(currentLayout, i);
831
847
  if (!l) return;
832
- oldResizeItemRef.current = chunkBJFPTW5Q_js.cloneLayoutItem(l);
848
+ oldResizeItemRef.current = chunkA5WIFECI_js.cloneLayoutItem(l);
833
849
  oldLayoutRef.current = currentLayout;
834
850
  setResizing(true);
835
851
  onResizeStartProp(currentLayout, l, l, null, data.e, data.node);
@@ -844,7 +860,7 @@ function GridLayout(props) {
844
860
  let shouldMoveItem = false;
845
861
  let newX;
846
862
  let newY;
847
- const [newLayout, l] = chunkBJFPTW5Q_js.withLayoutItem(currentLayout, i, (item) => {
863
+ const [newLayout, l] = chunkA5WIFECI_js.withLayoutItem(currentLayout, i, (item) => {
848
864
  newX = item.x;
849
865
  newY = item.y;
850
866
  if (["sw", "w", "nw", "n", "ne"].includes(handle)) {
@@ -861,7 +877,7 @@ function GridLayout(props) {
861
877
  shouldMoveItem = true;
862
878
  }
863
879
  if (preventCollision && !allowOverlap) {
864
- const collisions = chunkBJFPTW5Q_js.getAllCollisions(currentLayout, {
880
+ const collisions = chunkA5WIFECI_js.getAllCollisions(currentLayout, {
865
881
  ...item,
866
882
  w,
867
883
  h,
@@ -883,7 +899,7 @@ function GridLayout(props) {
883
899
  if (!l) return;
884
900
  let finalLayout = newLayout;
885
901
  if (shouldMoveItem && newX !== void 0 && newY !== void 0) {
886
- finalLayout = chunkBJFPTW5Q_js.moveElement(
902
+ finalLayout = chunkA5WIFECI_js.moveElement(
887
903
  newLayout,
888
904
  l,
889
905
  newX,
@@ -920,7 +936,7 @@ function GridLayout(props) {
920
936
  (i, _w, _h, data) => {
921
937
  const currentLayout = layoutRef.current;
922
938
  const oldResizeItem = oldResizeItemRef.current;
923
- const l = chunkBJFPTW5Q_js.getLayoutItem(currentLayout, i);
939
+ const l = chunkA5WIFECI_js.getLayoutItem(currentLayout, i);
924
940
  const finalLayout = compactor.compact(currentLayout, cols);
925
941
  onResizeStopProp(
926
942
  finalLayout,
@@ -991,13 +1007,13 @@ function GridLayout(props) {
991
1007
  containerWidth: width,
992
1008
  containerPadding: effectiveContainerPadding
993
1009
  };
994
- const actualColWidth = chunkBJFPTW5Q_js.calcGridColWidth(positionParams);
995
- const itemPixelWidth = chunkBJFPTW5Q_js.calcGridItemWHPx(
1010
+ const actualColWidth = chunkA5WIFECI_js.calcGridColWidth(positionParams);
1011
+ const itemPixelWidth = chunkA5WIFECI_js.calcGridItemWHPx(
996
1012
  finalDroppingItem.w,
997
1013
  actualColWidth,
998
1014
  margin[0]
999
1015
  );
1000
- const itemPixelHeight = chunkBJFPTW5Q_js.calcGridItemWHPx(
1016
+ const itemPixelHeight = chunkA5WIFECI_js.calcGridItemWHPx(
1001
1017
  finalDroppingItem.h,
1002
1018
  rowHeight,
1003
1019
  margin[1]
@@ -1014,7 +1030,7 @@ function GridLayout(props) {
1014
1030
  e: e.nativeEvent
1015
1031
  };
1016
1032
  if (!droppingDOMNode) {
1017
- const calculatedPosition = chunkBJFPTW5Q_js.calcXY(
1033
+ const calculatedPosition = chunkA5WIFECI_js.calcXY(
1018
1034
  positionParams,
1019
1035
  clampedGridY,
1020
1036
  clampedGridX,
@@ -1023,8 +1039,11 @@ function GridLayout(props) {
1023
1039
  );
1024
1040
  setDroppingDOMNode(/* @__PURE__ */ jsxRuntime.jsx("div", {}, finalDroppingItem.i));
1025
1041
  setDroppingPosition(newDroppingPosition);
1042
+ const baseLayout = layoutRef.current.filter(
1043
+ (l) => l.i !== finalDroppingItem.i
1044
+ );
1026
1045
  setLayout([
1027
- ...layoutRef.current,
1046
+ ...baseLayout,
1028
1047
  {
1029
1048
  ...finalDroppingItem,
1030
1049
  x: calculatedPosition.x,
@@ -1090,7 +1109,7 @@ function GridLayout(props) {
1090
1109
  const processGridItem = React2.useCallback(
1091
1110
  (child, isDroppingItem) => {
1092
1111
  if (!child || !child.key) return null;
1093
- const l = chunkBJFPTW5Q_js.getLayoutItem(layout, String(child.key));
1112
+ const l = chunkA5WIFECI_js.getLayoutItem(layout, String(child.key));
1094
1113
  if (!l) return null;
1095
1114
  const draggable = typeof l.isDraggable === "boolean" ? l.isDraggable : !l.static && isDraggable;
1096
1115
  const resizable = typeof l.isResizable === "boolean" ? l.isResizable : !l.static && isResizable;
@@ -1278,14 +1297,14 @@ function synchronizeLayoutWithChildren2(initialLayout, children, cols, compactor
1278
1297
  layout.push({
1279
1298
  i: key,
1280
1299
  x: 0,
1281
- y: chunkBJFPTW5Q_js.bottom(layout),
1300
+ y: chunkA5WIFECI_js.bottom(layout),
1282
1301
  w: 1,
1283
1302
  h: 1
1284
1303
  });
1285
1304
  }
1286
1305
  }
1287
1306
  });
1288
- const corrected = chunkBJFPTW5Q_js.correctBounds(layout, { cols });
1307
+ const corrected = chunkA5WIFECI_js.correctBounds(layout, { cols });
1289
1308
  return compactor.compact(corrected, cols);
1290
1309
  }
1291
1310
  function ResponsiveGridLayout(props) {
@@ -1306,17 +1325,17 @@ function ResponsiveGridLayout(props) {
1306
1325
  onWidthChange = noop2,
1307
1326
  ...restProps
1308
1327
  } = props;
1309
- const compactor = compactorProp ?? chunk2DDROKB2_js.getCompactor("vertical");
1328
+ const compactor = compactorProp ?? chunk55DQUWLA_js.getCompactor("vertical");
1310
1329
  const compactType = compactor.type;
1311
1330
  const allowOverlap = compactor.allowOverlap;
1312
1331
  const initialBreakpoint = React2.useMemo(() => {
1313
- return propBreakpoint ?? chunk2DDROKB2_js.getBreakpointFromWidth(breakpoints, width);
1332
+ return propBreakpoint ?? chunk55DQUWLA_js.getBreakpointFromWidth(breakpoints, width);
1314
1333
  }, []);
1315
1334
  const initialCols = React2.useMemo(() => {
1316
- return chunk2DDROKB2_js.getColsFromBreakpoint(initialBreakpoint, colsConfig);
1335
+ return chunk55DQUWLA_js.getColsFromBreakpoint(initialBreakpoint, colsConfig);
1317
1336
  }, [initialBreakpoint, colsConfig]);
1318
1337
  const initialLayout = React2.useMemo(() => {
1319
- return chunk2DDROKB2_js.findOrGenerateResponsiveLayout(
1338
+ return chunk55DQUWLA_js.findOrGenerateResponsiveLayout(
1320
1339
  propsLayouts,
1321
1340
  breakpoints,
1322
1341
  initialBreakpoint,
@@ -1341,7 +1360,7 @@ function ResponsiveGridLayout(props) {
1341
1360
  }, [layouts]);
1342
1361
  const derivedLayout = React2.useMemo(() => {
1343
1362
  if (!fastEquals.deepEqual(propsLayouts, prevLayoutsRef.current)) {
1344
- return chunk2DDROKB2_js.findOrGenerateResponsiveLayout(
1363
+ return chunk55DQUWLA_js.findOrGenerateResponsiveLayout(
1345
1364
  propsLayouts,
1346
1365
  breakpoints,
1347
1366
  breakpoint,
@@ -1363,7 +1382,7 @@ function ResponsiveGridLayout(props) {
1363
1382
  }, [derivedLayout, propsLayouts]);
1364
1383
  React2.useEffect(() => {
1365
1384
  if (compactType !== prevCompactTypeRef.current) {
1366
- const newLayout = compactor.compact(chunkBJFPTW5Q_js.cloneLayout(effectiveLayout), cols);
1385
+ const newLayout = compactor.compact(chunkA5WIFECI_js.cloneLayout(effectiveLayout), cols);
1367
1386
  const newLayouts = {
1368
1387
  ...layoutsRef.current,
1369
1388
  [breakpoint]: newLayout
@@ -1392,15 +1411,15 @@ function ResponsiveGridLayout(props) {
1392
1411
  );
1393
1412
  const colsChanged = !fastEquals.deepEqual(colsConfig, prevColsRef.current);
1394
1413
  if (widthChanged || breakpointPropChanged || breakpointsChanged || colsChanged) {
1395
- const newBreakpoint = propBreakpoint ?? chunk2DDROKB2_js.getBreakpointFromWidth(breakpoints, width);
1396
- const newCols = chunk2DDROKB2_js.getColsFromBreakpoint(newBreakpoint, colsConfig);
1414
+ const newBreakpoint = propBreakpoint ?? chunk55DQUWLA_js.getBreakpointFromWidth(breakpoints, width);
1415
+ const newCols = chunk55DQUWLA_js.getColsFromBreakpoint(newBreakpoint, colsConfig);
1397
1416
  const lastBreakpoint = breakpoint;
1398
1417
  if (lastBreakpoint !== newBreakpoint || breakpointsChanged || colsChanged) {
1399
1418
  const newLayouts = { ...layoutsRef.current };
1400
1419
  if (!newLayouts[lastBreakpoint]) {
1401
- newLayouts[lastBreakpoint] = chunkBJFPTW5Q_js.cloneLayout(layout);
1420
+ newLayouts[lastBreakpoint] = chunkA5WIFECI_js.cloneLayout(layout);
1402
1421
  }
1403
- let newLayout = chunk2DDROKB2_js.findOrGenerateResponsiveLayout(
1422
+ let newLayout = chunk55DQUWLA_js.findOrGenerateResponsiveLayout(
1404
1423
  newLayouts,
1405
1424
  breakpoints,
1406
1425
  newBreakpoint,
@@ -1423,11 +1442,11 @@ function ResponsiveGridLayout(props) {
1423
1442
  onBreakpointChange(newBreakpoint, newCols);
1424
1443
  onLayoutChange(newLayout, newLayouts);
1425
1444
  }
1426
- const currentMargin2 = chunk2DDROKB2_js.getIndentationValue(
1445
+ const currentMargin2 = chunk55DQUWLA_js.getIndentationValue(
1427
1446
  propMargin,
1428
1447
  newBreakpoint
1429
1448
  );
1430
- const currentPadding = propContainerPadding ? chunk2DDROKB2_js.getIndentationValue(
1449
+ const currentPadding = propContainerPadding ? chunk55DQUWLA_js.getIndentationValue(
1431
1450
  propContainerPadding,
1432
1451
  newBreakpoint
1433
1452
  ) : null;
@@ -1470,14 +1489,14 @@ function ResponsiveGridLayout(props) {
1470
1489
  [breakpoint, onLayoutChange]
1471
1490
  );
1472
1491
  const currentMargin = React2.useMemo(() => {
1473
- return chunk2DDROKB2_js.getIndentationValue(
1492
+ return chunk55DQUWLA_js.getIndentationValue(
1474
1493
  propMargin,
1475
1494
  breakpoint
1476
1495
  );
1477
1496
  }, [propMargin, breakpoint]);
1478
1497
  const currentContainerPadding = React2.useMemo(() => {
1479
1498
  if (propContainerPadding === null) return null;
1480
- return chunk2DDROKB2_js.getIndentationValue(
1499
+ return chunk55DQUWLA_js.getIndentationValue(
1481
1500
  propContainerPadding,
1482
1501
  breakpoint
1483
1502
  );
@@ -1509,5 +1528,3 @@ function ResponsiveGridLayout(props) {
1509
1528
  exports.GridItem = GridItem;
1510
1529
  exports.GridLayout = GridLayout;
1511
1530
  exports.ResponsiveGridLayout = ResponsiveGridLayout;
1512
- //# sourceMappingURL=chunk-3CEWSUXL.js.map
1513
- //# sourceMappingURL=chunk-3CEWSUXL.js.map
@@ -1,4 +1,4 @@
1
- import { getStatics, collides, getFirstCollision, bottom, sortLayoutItemsByRowCol, cloneLayoutItem, sortLayoutItemsByColRow, cloneLayout, correctBounds } from './chunk-AWM66AWF.mjs';
1
+ import { getStatics, collides, getFirstCollision, bottom, sortLayoutItemsByRowCol, cloneLayoutItem, sortLayoutItemsByColRow, cloneLayout, correctBounds } from './chunk-76RTO6EO.mjs';
2
2
 
3
3
  // src/core/constraints.ts
4
4
  function clamp(value, min, max) {
@@ -564,5 +564,3 @@ function getIndentationValue(value, breakpoint) {
564
564
  }
565
565
 
566
566
  export { absoluteStrategy, applyPositionConstraints, applySizeConstraints, aspectRatio, boundedX, boundedY, compactItemHorizontal, compactItemVertical, containerBounds, createScaledStrategy, defaultConstraints, defaultDragConfig, defaultDropConfig, defaultGridConfig, defaultPositionStrategy, defaultResizeConfig, findOrGenerateResponsiveLayout, getBreakpointFromWidth, getColsFromBreakpoint, getCompactor, getIndentationValue, gridBounds, horizontalCompactor, horizontalOverlapCompactor, maxSize, minMaxSize, minSize, noCompactor, noOverlapCompactor, perc, resizeItemInDirection, resolveCompactionCollision, setTopLeft, setTransform, snapToGrid, sortBreakpoints, transformStrategy, verticalCompactor, verticalOverlapCompactor };
567
- //# sourceMappingURL=chunk-XYPIYYYQ.mjs.map
568
- //# sourceMappingURL=chunk-XYPIYYYQ.mjs.map
@@ -0,0 +1 @@
1
+
@@ -1,5 +1,5 @@
1
- import { verticalCompactor, sortBreakpoints, getBreakpointFromWidth, getColsFromBreakpoint, findOrGenerateResponsiveLayout } from './chunk-XYPIYYYQ.mjs';
2
- import { correctBounds, cloneLayout, getLayoutItem, cloneLayoutItem, moveElement, bottom } from './chunk-AWM66AWF.mjs';
1
+ import { verticalCompactor, sortBreakpoints, getBreakpointFromWidth, getColsFromBreakpoint, findOrGenerateResponsiveLayout } from './chunk-KDANGDDL.mjs';
2
+ import { correctBounds, cloneLayout, getLayoutItem, cloneLayoutItem, moveElement, bottom } from './chunk-76RTO6EO.mjs';
3
3
  import { useState, useRef, useCallback, useEffect, useMemo } from 'react';
4
4
  import { deepEqual } from 'fast-equals';
5
5
 
@@ -24,14 +24,30 @@ function useContainerWidth(options = {}) {
24
24
  if (!node) return;
25
25
  measureWidth();
26
26
  if (typeof ResizeObserver !== "undefined") {
27
+ let rafId = null;
27
28
  observerRef.current = new ResizeObserver((entries) => {
28
29
  const entry = entries[0];
29
30
  if (entry) {
30
31
  const newWidth = entry.contentRect.width;
31
- setWidth(newWidth);
32
+ if (rafId !== null) {
33
+ cancelAnimationFrame(rafId);
34
+ }
35
+ rafId = requestAnimationFrame(() => {
36
+ setWidth(newWidth);
37
+ rafId = null;
38
+ });
32
39
  }
33
40
  });
34
41
  observerRef.current.observe(node);
42
+ return () => {
43
+ if (rafId !== null) {
44
+ cancelAnimationFrame(rafId);
45
+ }
46
+ if (observerRef.current) {
47
+ observerRef.current.disconnect();
48
+ observerRef.current = null;
49
+ }
50
+ };
35
51
  }
36
52
  return () => {
37
53
  if (observerRef.current) {
@@ -421,5 +437,3 @@ function useResponsiveLayout(options) {
421
437
  }
422
438
 
423
439
  export { DEFAULT_BREAKPOINTS, DEFAULT_COLS, useContainerWidth, useGridLayout, useResponsiveLayout };
424
- //# sourceMappingURL=chunk-YFVX5RDK.mjs.map
425
- //# sourceMappingURL=chunk-YFVX5RDK.mjs.map