react-grid-layout 2.0.0 → 2.1.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 (70) hide show
  1. package/README.md +117 -28
  2. package/css/styles.css +0 -1
  3. package/dist/{ResponsiveGridLayout-D6lFRE3f.d.mts → ResponsiveGridLayout-BkHF9YHa.d.mts} +10 -1
  4. package/dist/{ResponsiveGridLayout-CH4s0tKj.d.ts → ResponsiveGridLayout-CLn16-X3.d.ts} +10 -1
  5. package/dist/{calculate-CwYDW8na.d.mts → calculate-DsVTldEE.d.ts} +30 -2
  6. package/dist/{calculate-mgLpNJ5O.d.ts → calculate-DwbL1D06.d.mts} +30 -2
  7. package/dist/chunk-526JND3R.mjs +3 -0
  8. package/dist/{chunk-ZWN22PS2.mjs.map → chunk-526JND3R.mjs.map} +1 -1
  9. package/dist/chunk-7ELO5FRW.js +4 -0
  10. package/dist/{chunk-PBQSHIID.js.map → chunk-7ELO5FRW.js.map} +1 -1
  11. package/dist/chunk-AWM66AWF.mjs +422 -0
  12. package/dist/chunk-AWM66AWF.mjs.map +1 -0
  13. package/dist/chunk-BJFPTW5Q.js +449 -0
  14. package/dist/chunk-BJFPTW5Q.js.map +1 -0
  15. package/dist/{chunk-4HNUMWQK.mjs → chunk-FLITZMQC.mjs} +198 -311
  16. package/dist/chunk-FLITZMQC.mjs.map +1 -0
  17. package/dist/{chunk-ZCXE6SR5.mjs → chunk-LIKX67MZ.mjs} +7 -5
  18. package/dist/chunk-LIKX67MZ.mjs.map +1 -0
  19. package/dist/{chunk-R35HZZTA.mjs → chunk-PLWMASMX.mjs} +208 -90
  20. package/dist/chunk-PLWMASMX.mjs.map +1 -0
  21. package/dist/{chunk-BFTKGAP3.js → chunk-RB2IKK5B.js} +260 -142
  22. package/dist/chunk-RB2IKK5B.js.map +1 -0
  23. package/dist/{chunk-3WO4SAYB.js → chunk-WWS3M5Y3.js} +238 -355
  24. package/dist/chunk-WWS3M5Y3.js.map +1 -0
  25. package/dist/{chunk-H5KMDLY3.js → chunk-YQQYHEEG.js} +43 -41
  26. package/dist/chunk-YQQYHEEG.js.map +1 -0
  27. package/dist/core.d.mts +159 -6
  28. package/dist/core.d.ts +159 -6
  29. package/dist/core.js +145 -85
  30. package/dist/core.mjs +3 -3
  31. package/dist/extras.d.mts +133 -3
  32. package/dist/extras.d.ts +133 -3
  33. package/dist/extras.js +373 -2
  34. package/dist/extras.js.map +1 -1
  35. package/dist/extras.mjs +367 -2
  36. package/dist/extras.mjs.map +1 -1
  37. package/dist/index.d.mts +5 -5
  38. package/dist/index.d.ts +5 -5
  39. package/dist/index.js +64 -64
  40. package/dist/index.mjs +5 -5
  41. package/dist/legacy.d.mts +2 -2
  42. package/dist/legacy.d.ts +2 -2
  43. package/dist/legacy.js +26 -25
  44. package/dist/legacy.js.map +1 -1
  45. package/dist/legacy.mjs +16 -15
  46. package/dist/legacy.mjs.map +1 -1
  47. package/dist/{position-Dk2b4ZMS.d.ts → position-CXNzFxI0.d.mts} +18 -7
  48. package/dist/{position-BmN1z36J.d.mts → position-Dk0FRWA9.d.ts} +18 -7
  49. package/dist/react.d.mts +11 -5
  50. package/dist/react.d.ts +11 -5
  51. package/dist/react.js +38 -38
  52. package/dist/react.mjs +5 -5
  53. package/dist/{responsive-CJxefsYw.d.mts → responsive-BB5d98xz.d.mts} +1 -1
  54. package/dist/{responsive-C4L1ESlm.d.ts → responsive-BXI-GCXG.d.ts} +1 -1
  55. package/dist/{types-Cxf4nHNr.d.mts → types-CokovIMH.d.mts} +98 -4
  56. package/dist/{types-Cxf4nHNr.d.ts → types-CokovIMH.d.ts} +98 -4
  57. package/index-dev.js +16 -0
  58. package/package.json +5 -3
  59. package/dist/chunk-2KUHNJXF.mjs +0 -90
  60. package/dist/chunk-2KUHNJXF.mjs.map +0 -1
  61. package/dist/chunk-3WO4SAYB.js.map +0 -1
  62. package/dist/chunk-4HNUMWQK.mjs.map +0 -1
  63. package/dist/chunk-BFTKGAP3.js.map +0 -1
  64. package/dist/chunk-F6NQPYKT.js +0 -98
  65. package/dist/chunk-F6NQPYKT.js.map +0 -1
  66. package/dist/chunk-H5KMDLY3.js.map +0 -1
  67. package/dist/chunk-PBQSHIID.js +0 -4
  68. package/dist/chunk-R35HZZTA.mjs.map +0 -1
  69. package/dist/chunk-ZCXE6SR5.mjs.map +0 -1
  70. package/dist/chunk-ZWN22PS2.mjs +0 -3
@@ -1,5 +1,170 @@
1
1
  'use strict';
2
2
 
3
+ var chunkBJFPTW5Q_js = require('./chunk-BJFPTW5Q.js');
4
+
5
+ // src/core/constraints.ts
6
+ function clamp(value, min, max) {
7
+ return Math.max(min, Math.min(max, value));
8
+ }
9
+ var gridBounds = {
10
+ name: "gridBounds",
11
+ constrainPosition(item, x, y, { cols, maxRows }) {
12
+ return {
13
+ x: clamp(x, 0, Math.max(0, cols - item.w)),
14
+ y: clamp(y, 0, Math.max(0, maxRows - item.h))
15
+ };
16
+ },
17
+ constrainSize(item, w, h, handle, { cols, maxRows }) {
18
+ const maxW = handle === "w" || handle === "nw" || handle === "sw" ? item.x + item.w : cols - item.x;
19
+ const maxH = handle === "n" || handle === "nw" || handle === "ne" ? item.y + item.h : maxRows - item.y;
20
+ return {
21
+ w: clamp(w, 1, Math.max(1, maxW)),
22
+ h: clamp(h, 1, Math.max(1, maxH))
23
+ };
24
+ }
25
+ };
26
+ var minMaxSize = {
27
+ name: "minMaxSize",
28
+ constrainSize(item, w, h) {
29
+ return {
30
+ w: clamp(w, item.minW ?? 1, item.maxW ?? Infinity),
31
+ h: clamp(h, item.minH ?? 1, item.maxH ?? Infinity)
32
+ };
33
+ }
34
+ };
35
+ var containerBounds = {
36
+ name: "containerBounds",
37
+ constrainPosition(item, x, y, { cols, maxRows, containerHeight, rowHeight, margin }) {
38
+ const visibleRows = containerHeight > 0 ? Math.floor((containerHeight + margin[1]) / (rowHeight + margin[1])) : maxRows;
39
+ return {
40
+ x: clamp(x, 0, Math.max(0, cols - item.w)),
41
+ y: clamp(y, 0, Math.max(0, visibleRows - item.h))
42
+ };
43
+ }
44
+ };
45
+ var boundedX = {
46
+ name: "boundedX",
47
+ constrainPosition(item, x, y, { cols }) {
48
+ return {
49
+ x: clamp(x, 0, Math.max(0, cols - item.w)),
50
+ y
51
+ };
52
+ }
53
+ };
54
+ var boundedY = {
55
+ name: "boundedY",
56
+ constrainPosition(item, x, y, { maxRows }) {
57
+ return {
58
+ x,
59
+ y: clamp(y, 0, Math.max(0, maxRows - item.h))
60
+ };
61
+ }
62
+ };
63
+ function aspectRatio(ratio) {
64
+ return {
65
+ name: `aspectRatio(${ratio})`,
66
+ constrainSize(_item, w, _h, _handle, context) {
67
+ const { cols, containerWidth, rowHeight, margin } = context;
68
+ const colWidth = (containerWidth - margin[0] * (cols - 1)) / cols;
69
+ const pixelWidth = colWidth * w + margin[0] * Math.max(0, w - 1);
70
+ const pixelHeight = pixelWidth / ratio;
71
+ const h = Math.max(
72
+ 1,
73
+ Math.round((pixelHeight + margin[1]) / (rowHeight + margin[1]))
74
+ );
75
+ return { w, h };
76
+ }
77
+ };
78
+ }
79
+ function snapToGrid(stepX, stepY = stepX) {
80
+ if (stepX <= 0 || stepY <= 0) {
81
+ throw new Error(
82
+ `snapToGrid: step values must be positive (got stepX=${stepX}, stepY=${stepY})`
83
+ );
84
+ }
85
+ return {
86
+ name: `snapToGrid(${stepX}, ${stepY})`,
87
+ constrainPosition(_item, x, y) {
88
+ return {
89
+ x: Math.round(x / stepX) * stepX,
90
+ y: Math.round(y / stepY) * stepY
91
+ };
92
+ }
93
+ };
94
+ }
95
+ function minSize(minW, minH) {
96
+ return {
97
+ name: `minSize(${minW}, ${minH})`,
98
+ constrainSize(_item, w, h) {
99
+ return {
100
+ w: Math.max(minW, w),
101
+ h: Math.max(minH, h)
102
+ };
103
+ }
104
+ };
105
+ }
106
+ function maxSize(maxW, maxH) {
107
+ return {
108
+ name: `maxSize(${maxW}, ${maxH})`,
109
+ constrainSize(_item, w, h) {
110
+ return {
111
+ w: Math.min(maxW, w),
112
+ h: Math.min(maxH, h)
113
+ };
114
+ }
115
+ };
116
+ }
117
+ var defaultConstraints = [gridBounds, minMaxSize];
118
+ function applyPositionConstraints(constraints, item, x, y, context) {
119
+ let result = { x, y };
120
+ for (const constraint of constraints) {
121
+ if (constraint.constrainPosition) {
122
+ result = constraint.constrainPosition(item, result.x, result.y, context);
123
+ }
124
+ }
125
+ if (item.constraints) {
126
+ for (const constraint of item.constraints) {
127
+ if (constraint.constrainPosition) {
128
+ result = constraint.constrainPosition(
129
+ item,
130
+ result.x,
131
+ result.y,
132
+ context
133
+ );
134
+ }
135
+ }
136
+ }
137
+ return result;
138
+ }
139
+ function applySizeConstraints(constraints, item, w, h, handle, context) {
140
+ let result = { w, h };
141
+ for (const constraint of constraints) {
142
+ if (constraint.constrainSize) {
143
+ result = constraint.constrainSize(
144
+ item,
145
+ result.w,
146
+ result.h,
147
+ handle,
148
+ context
149
+ );
150
+ }
151
+ }
152
+ if (item.constraints) {
153
+ for (const constraint of item.constraints) {
154
+ if (constraint.constrainSize) {
155
+ result = constraint.constrainSize(
156
+ item,
157
+ result.w,
158
+ result.h,
159
+ handle,
160
+ context
161
+ );
162
+ }
163
+ }
164
+ }
165
+ return result;
166
+ }
167
+
3
168
  // src/core/position.ts
4
169
  function setTransform({
5
170
  top,
@@ -193,314 +358,28 @@ var defaultDropConfig = {
193
358
  defaultItem: { w: 1, h: 1 }
194
359
  };
195
360
 
196
- // src/core/collision.ts
197
- function collides(l1, l2) {
198
- if (l1.i === l2.i) return false;
199
- if (l1.x + l1.w <= l2.x) return false;
200
- if (l1.x >= l2.x + l2.w) return false;
201
- if (l1.y + l1.h <= l2.y) return false;
202
- if (l1.y >= l2.y + l2.h) return false;
203
- return true;
204
- }
205
- function getFirstCollision(layout, layoutItem) {
206
- for (let i = 0; i < layout.length; i++) {
207
- const item = layout[i];
208
- if (item !== void 0 && collides(item, layoutItem)) {
209
- return item;
210
- }
211
- }
212
- return void 0;
213
- }
214
- function getAllCollisions(layout, layoutItem) {
215
- return layout.filter((l) => collides(l, layoutItem));
216
- }
217
-
218
- // src/core/sort.ts
219
- function sortLayoutItems(layout, compactType) {
220
- if (compactType === "horizontal") {
221
- return sortLayoutItemsByColRow(layout);
222
- }
223
- if (compactType === "vertical") {
224
- return sortLayoutItemsByRowCol(layout);
225
- }
226
- return [...layout];
227
- }
228
- function sortLayoutItemsByRowCol(layout) {
229
- return [...layout].sort((a, b) => {
230
- if (a.y !== b.y) {
231
- return a.y - b.y;
232
- }
233
- return a.x - b.x;
234
- });
235
- }
236
- function sortLayoutItemsByColRow(layout) {
237
- return [...layout].sort((a, b) => {
238
- if (a.x !== b.x) {
239
- return a.x - b.x;
240
- }
241
- return a.y - b.y;
242
- });
243
- }
244
-
245
- // src/core/layout.ts
246
- function bottom(layout) {
247
- let max = 0;
248
- for (let i = 0; i < layout.length; i++) {
249
- const item = layout[i];
250
- if (item !== void 0) {
251
- const bottomY = item.y + item.h;
252
- if (bottomY > max) max = bottomY;
253
- }
254
- }
255
- return max;
256
- }
257
- function getLayoutItem(layout, id) {
258
- for (let i = 0; i < layout.length; i++) {
259
- const item = layout[i];
260
- if (item !== void 0 && item.i === id) {
261
- return item;
262
- }
263
- }
264
- return void 0;
265
- }
266
- function getStatics(layout) {
267
- return layout.filter((l) => l.static === true);
268
- }
269
- function cloneLayoutItem(layoutItem) {
270
- return {
271
- i: layoutItem.i,
272
- x: layoutItem.x,
273
- y: layoutItem.y,
274
- w: layoutItem.w,
275
- h: layoutItem.h,
276
- minW: layoutItem.minW,
277
- maxW: layoutItem.maxW,
278
- minH: layoutItem.minH,
279
- maxH: layoutItem.maxH,
280
- moved: Boolean(layoutItem.moved),
281
- static: Boolean(layoutItem.static),
282
- isDraggable: layoutItem.isDraggable,
283
- isResizable: layoutItem.isResizable,
284
- resizeHandles: layoutItem.resizeHandles,
285
- isBounded: layoutItem.isBounded
286
- };
287
- }
288
- function cloneLayout(layout) {
289
- const newLayout = new Array(layout.length);
290
- for (let i = 0; i < layout.length; i++) {
291
- const item = layout[i];
292
- if (item !== void 0) {
293
- newLayout[i] = cloneLayoutItem(item);
294
- }
295
- }
296
- return newLayout;
297
- }
298
- function modifyLayout(layout, layoutItem) {
299
- const newLayout = new Array(layout.length);
300
- for (let i = 0; i < layout.length; i++) {
301
- const item = layout[i];
302
- if (item !== void 0) {
303
- if (layoutItem.i === item.i) {
304
- newLayout[i] = layoutItem;
305
- } else {
306
- newLayout[i] = item;
307
- }
308
- }
309
- }
310
- return newLayout;
311
- }
312
- function withLayoutItem(layout, itemKey, cb) {
313
- let item = getLayoutItem(layout, itemKey);
314
- if (!item) {
315
- return [[...layout], null];
316
- }
317
- item = cb(cloneLayoutItem(item));
318
- const newLayout = modifyLayout(layout, item);
319
- return [newLayout, item];
320
- }
321
- function correctBounds(layout, bounds) {
322
- const collidesWith = getStatics(layout);
323
- for (let i = 0; i < layout.length; i++) {
324
- const l = layout[i];
325
- if (l === void 0) continue;
326
- if (l.x + l.w > bounds.cols) {
327
- l.x = bounds.cols - l.w;
328
- }
329
- if (l.x < 0) {
330
- l.x = 0;
331
- l.w = bounds.cols;
332
- }
333
- if (!l.static) {
334
- collidesWith.push(l);
335
- } else {
336
- while (getFirstCollision(collidesWith, l)) {
337
- l.y++;
338
- }
339
- }
340
- }
341
- return layout;
342
- }
343
- function moveElement(layout, l, x, y, isUserAction, preventCollision, compactType, cols, allowOverlap) {
344
- if (l.static && l.isDraggable !== true) {
345
- return [...layout];
346
- }
347
- if (l.y === y && l.x === x) {
348
- return [...layout];
349
- }
350
- const oldX = l.x;
351
- const oldY = l.y;
352
- if (typeof x === "number") l.x = x;
353
- if (typeof y === "number") l.y = y;
354
- l.moved = true;
355
- let sorted = sortLayoutItems(layout, compactType);
356
- const movingUp = compactType === "vertical" && typeof y === "number" ? oldY >= y : compactType === "horizontal" && typeof x === "number" ? oldX >= x : false;
357
- if (movingUp) {
358
- sorted = sorted.reverse();
359
- }
360
- const collisions = getAllCollisions(sorted, l);
361
- const hasCollisions = collisions.length > 0;
362
- if (hasCollisions && allowOverlap) {
363
- return cloneLayout(layout);
364
- }
365
- if (hasCollisions && preventCollision) {
366
- l.x = oldX;
367
- l.y = oldY;
368
- l.moved = false;
369
- return layout;
370
- }
371
- let resultLayout = [...layout];
372
- for (let i = 0; i < collisions.length; i++) {
373
- const collision = collisions[i];
374
- if (collision === void 0) continue;
375
- if (collision.moved) continue;
376
- if (collision.static) {
377
- resultLayout = moveElementAwayFromCollision(
378
- resultLayout,
379
- collision,
380
- l,
381
- isUserAction,
382
- compactType);
383
- } else {
384
- resultLayout = moveElementAwayFromCollision(
385
- resultLayout,
386
- l,
387
- collision,
388
- isUserAction,
389
- compactType);
390
- }
391
- }
392
- return resultLayout;
393
- }
394
- function moveElementAwayFromCollision(layout, collidesWith, itemToMove, isUserAction, compactType, cols) {
395
- const compactH = compactType === "horizontal";
396
- const compactV = compactType === "vertical";
397
- const preventCollision = collidesWith.static;
398
- if (isUserAction) {
399
- isUserAction = false;
400
- const fakeItem = {
401
- x: compactH ? Math.max(collidesWith.x - itemToMove.w, 0) : itemToMove.x,
402
- y: compactV ? Math.max(collidesWith.y - itemToMove.h, 0) : itemToMove.y,
403
- w: itemToMove.w,
404
- h: itemToMove.h,
405
- i: "-1"
406
- };
407
- const firstCollision = getFirstCollision(layout, fakeItem);
408
- const collisionNorth = firstCollision !== void 0 && firstCollision.y + firstCollision.h > collidesWith.y;
409
- const collisionWest = firstCollision !== void 0 && collidesWith.x + collidesWith.w > firstCollision.x;
410
- if (!firstCollision) {
411
- return moveElement(
412
- layout,
413
- itemToMove,
414
- compactH ? fakeItem.x : void 0,
415
- compactV ? fakeItem.y : void 0,
416
- isUserAction,
417
- preventCollision,
418
- compactType);
419
- }
420
- if (collisionNorth && compactV) {
421
- return moveElement(
422
- layout,
423
- itemToMove,
424
- void 0,
425
- itemToMove.y + 1,
426
- isUserAction,
427
- preventCollision,
428
- compactType);
429
- }
430
- if (collisionNorth && compactType === null) {
431
- collidesWith.y = itemToMove.y;
432
- itemToMove.y = itemToMove.y + itemToMove.h;
433
- return [...layout];
434
- }
435
- if (collisionWest && compactH) {
436
- return moveElement(
437
- layout,
438
- collidesWith,
439
- itemToMove.x,
440
- void 0,
441
- isUserAction,
442
- preventCollision,
443
- compactType);
444
- }
445
- }
446
- const newX = compactH ? itemToMove.x + 1 : void 0;
447
- const newY = compactV ? itemToMove.y + 1 : void 0;
448
- if (newX === void 0 && newY === void 0) {
449
- return [...layout];
450
- }
451
- return moveElement(
452
- layout,
453
- itemToMove,
454
- newX,
455
- newY,
456
- isUserAction,
457
- preventCollision,
458
- compactType);
459
- }
460
- function validateLayout(layout, contextName = "Layout") {
461
- const requiredProps = ["x", "y", "w", "h"];
462
- if (!Array.isArray(layout)) {
463
- throw new Error(`${contextName} must be an array!`);
464
- }
465
- for (let i = 0; i < layout.length; i++) {
466
- const item = layout[i];
467
- if (item === void 0) continue;
468
- for (const key of requiredProps) {
469
- const value = item[key];
470
- if (typeof value !== "number" || Number.isNaN(value)) {
471
- throw new Error(
472
- `ReactGridLayout: ${contextName}[${i}].${key} must be a number! Received: ${String(value)} (${typeof value})`
473
- );
474
- }
475
- }
476
- if (item.i !== void 0 && typeof item.i !== "string") {
477
- throw new Error(
478
- `ReactGridLayout: ${contextName}[${i}].i must be a string! Received: ${String(item.i)} (${typeof item.i})`
479
- );
480
- }
481
- }
482
- }
483
-
484
361
  // src/core/compact-compat.ts
485
362
  function getStatics2(layout) {
486
363
  return layout.filter((l) => l.static);
487
364
  }
488
365
  var heightWidth = { x: "w", y: "h" };
489
- function resolveCompactionCollision(layout, item, moveToCoord, axis) {
366
+ function resolveCompactionCollision(layout, item, moveToCoord, axis, hasStatics) {
490
367
  const sizeProp = heightWidth[axis];
491
368
  item[axis] += 1;
492
369
  const itemIndex = layout.findIndex((l) => l.i === item.i);
370
+ const layoutHasStatics = hasStatics ?? getStatics2(layout).length > 0;
493
371
  for (let i = itemIndex + 1; i < layout.length; i++) {
494
372
  const otherItem = layout[i];
495
373
  if (otherItem === void 0) continue;
496
374
  if (otherItem.static) continue;
497
- if (otherItem.y > item.y + item.h) break;
498
- if (collides(item, otherItem)) {
375
+ if (!layoutHasStatics && otherItem.y > item.y + item.h) break;
376
+ if (chunkBJFPTW5Q_js.collides(item, otherItem)) {
499
377
  resolveCompactionCollision(
500
378
  layout,
501
379
  otherItem,
502
380
  moveToCoord + item[sizeProp],
503
- axis
381
+ axis,
382
+ layoutHasStatics
504
383
  );
505
384
  }
506
385
  }
@@ -509,22 +388,24 @@ function resolveCompactionCollision(layout, item, moveToCoord, axis) {
509
388
  function compactItemInternal(compareWith, l, compactType, cols, fullLayout, allowOverlap, b) {
510
389
  const compactV = compactType === "vertical";
511
390
  const compactH = compactType === "horizontal";
512
- if (compactV) {
513
- if (typeof b === "number") {
514
- l.y = Math.min(b, l.y);
515
- } else {
516
- l.y = Math.min(bottom(compareWith), l.y);
517
- }
518
- while (l.y > 0 && !getFirstCollision(compareWith, l)) {
519
- l.y--;
520
- }
521
- } else if (compactH) {
522
- while (l.x > 0 && !getFirstCollision(compareWith, l)) {
523
- l.x--;
391
+ if (!allowOverlap) {
392
+ if (compactV) {
393
+ if (typeof b === "number") {
394
+ l.y = Math.min(b, l.y);
395
+ } else {
396
+ l.y = Math.min(chunkBJFPTW5Q_js.bottom(compareWith), l.y);
397
+ }
398
+ while (l.y > 0 && !chunkBJFPTW5Q_js.getFirstCollision(compareWith, l)) {
399
+ l.y--;
400
+ }
401
+ } else if (compactH) {
402
+ while (l.x > 0 && !chunkBJFPTW5Q_js.getFirstCollision(compareWith, l)) {
403
+ l.x--;
404
+ }
524
405
  }
525
406
  }
526
407
  let collision;
527
- while ((collision = getFirstCollision(compareWith, l)) !== void 0 && !(compactType === null && allowOverlap)) {
408
+ while ((collision = chunkBJFPTW5Q_js.getFirstCollision(compareWith, l)) !== void 0 && !allowOverlap) {
528
409
  if (compactH) {
529
410
  resolveCompactionCollision(fullLayout, l, collision.x + collision.w, "x");
530
411
  } else {
@@ -533,7 +414,7 @@ function compactItemInternal(compareWith, l, compactType, cols, fullLayout, allo
533
414
  if (compactH && l.x + l.w > cols) {
534
415
  l.x = cols - l.w;
535
416
  l.y++;
536
- while (l.x > 0 && !getFirstCollision(compareWith, l)) {
417
+ while (l.x > 0 && !chunkBJFPTW5Q_js.getFirstCollision(compareWith, l)) {
537
418
  l.x--;
538
419
  }
539
420
  }
@@ -544,13 +425,13 @@ function compactItemInternal(compareWith, l, compactType, cols, fullLayout, allo
544
425
  }
545
426
  function compact(layout, compactType, cols, allowOverlap) {
546
427
  const compareWith = getStatics2(layout);
547
- let b = bottom(compareWith);
548
- const sorted = sortLayoutItems(layout, compactType);
428
+ let b = chunkBJFPTW5Q_js.bottom(compareWith);
429
+ const sorted = chunkBJFPTW5Q_js.sortLayoutItems(layout, compactType);
549
430
  const out = new Array(layout.length);
550
431
  for (let i = 0; i < sorted.length; i++) {
551
432
  const sortedItem = sorted[i];
552
433
  if (sortedItem === void 0) continue;
553
- let l = cloneLayoutItem(sortedItem);
434
+ let l = chunkBJFPTW5Q_js.cloneLayoutItem(sortedItem);
554
435
  if (!l.static) {
555
436
  l = compactItemInternal(
556
437
  compareWith,
@@ -573,7 +454,7 @@ function compact(layout, compactType, cols, allowOverlap) {
573
454
  function compactItem(compareWith, l, compactType, cols, fullLayout, allowOverlap, maxY) {
574
455
  return compactItemInternal(
575
456
  compareWith,
576
- cloneLayoutItem(l),
457
+ chunkBJFPTW5Q_js.cloneLayoutItem(l),
577
458
  compactType,
578
459
  cols,
579
460
  fullLayout,
@@ -583,21 +464,23 @@ function compactItem(compareWith, l, compactType, cols, fullLayout, allowOverlap
583
464
  }
584
465
 
585
466
  // src/core/compactors.ts
586
- function resolveCompactionCollision2(layout, item, moveToCoord, axis) {
467
+ function resolveCompactionCollision2(layout, item, moveToCoord, axis, hasStatics) {
587
468
  const sizeProp = axis === "x" ? "w" : "h";
588
469
  item[axis] += 1;
589
470
  const itemIndex = layout.findIndex((l) => l.i === item.i);
471
+ const layoutHasStatics = hasStatics ?? chunkBJFPTW5Q_js.getStatics(layout).length > 0;
590
472
  for (let i = itemIndex + 1; i < layout.length; i++) {
591
473
  const otherItem = layout[i];
592
474
  if (otherItem === void 0) continue;
593
475
  if (otherItem.static) continue;
594
- if (otherItem.y > item.y + item.h) break;
595
- if (collides(item, otherItem)) {
476
+ if (!layoutHasStatics && otherItem.y > item.y + item.h) break;
477
+ if (chunkBJFPTW5Q_js.collides(item, otherItem)) {
596
478
  resolveCompactionCollision2(
597
479
  layout,
598
480
  otherItem,
599
481
  moveToCoord + item[sizeProp],
600
- axis
482
+ axis,
483
+ layoutHasStatics
601
484
  );
602
485
  }
603
486
  }
@@ -605,27 +488,27 @@ function resolveCompactionCollision2(layout, item, moveToCoord, axis) {
605
488
  }
606
489
  function compactItemVertical(compareWith, l, fullLayout, maxY) {
607
490
  l.y = Math.min(maxY, l.y);
608
- while (l.y > 0 && !getFirstCollision(compareWith, l)) {
491
+ while (l.y > 0 && !chunkBJFPTW5Q_js.getFirstCollision(compareWith, l)) {
609
492
  l.y--;
610
493
  }
611
494
  let collision;
612
- while ((collision = getFirstCollision(compareWith, l)) !== void 0) {
495
+ while ((collision = chunkBJFPTW5Q_js.getFirstCollision(compareWith, l)) !== void 0) {
613
496
  resolveCompactionCollision2(fullLayout, l, collision.y + collision.h, "y");
614
497
  }
615
498
  l.y = Math.max(l.y, 0);
616
499
  return l;
617
500
  }
618
501
  function compactItemHorizontal(compareWith, l, cols, fullLayout) {
619
- while (l.x > 0 && !getFirstCollision(compareWith, l)) {
502
+ while (l.x > 0 && !chunkBJFPTW5Q_js.getFirstCollision(compareWith, l)) {
620
503
  l.x--;
621
504
  }
622
505
  let collision;
623
- while ((collision = getFirstCollision(compareWith, l)) !== void 0) {
506
+ while ((collision = chunkBJFPTW5Q_js.getFirstCollision(compareWith, l)) !== void 0) {
624
507
  resolveCompactionCollision2(fullLayout, l, collision.x + collision.w, "x");
625
508
  if (l.x + l.w > cols) {
626
509
  l.x = cols - l.w;
627
510
  l.y++;
628
- while (l.x > 0 && !getFirstCollision(compareWith, l)) {
511
+ while (l.x > 0 && !chunkBJFPTW5Q_js.getFirstCollision(compareWith, l)) {
629
512
  l.x--;
630
513
  }
631
514
  }
@@ -637,14 +520,14 @@ var verticalCompactor = {
637
520
  type: "vertical",
638
521
  allowOverlap: false,
639
522
  compact(layout, _cols) {
640
- const compareWith = getStatics(layout);
641
- let maxY = bottom(compareWith);
642
- const sorted = sortLayoutItemsByRowCol(layout);
523
+ const compareWith = chunkBJFPTW5Q_js.getStatics(layout);
524
+ let maxY = chunkBJFPTW5Q_js.bottom(compareWith);
525
+ const sorted = chunkBJFPTW5Q_js.sortLayoutItemsByRowCol(layout);
643
526
  const out = new Array(layout.length);
644
527
  for (let i = 0; i < sorted.length; i++) {
645
528
  const sortedItem = sorted[i];
646
529
  if (sortedItem === void 0) continue;
647
- let l = cloneLayoutItem(sortedItem);
530
+ let l = chunkBJFPTW5Q_js.cloneLayoutItem(sortedItem);
648
531
  if (!l.static) {
649
532
  l = compactItemVertical(compareWith, l, sorted, maxY);
650
533
  maxY = Math.max(maxY, l.y + l.h);
@@ -657,7 +540,7 @@ var verticalCompactor = {
657
540
  return out;
658
541
  },
659
542
  onMove(layout, item, x, y, _cols) {
660
- const newLayout = cloneLayout(layout);
543
+ const newLayout = chunkBJFPTW5Q_js.cloneLayout(layout);
661
544
  const movedItem = newLayout.find((l) => l.i === item.i);
662
545
  if (movedItem) {
663
546
  movedItem.x = x;
@@ -671,13 +554,13 @@ var horizontalCompactor = {
671
554
  type: "horizontal",
672
555
  allowOverlap: false,
673
556
  compact(layout, cols) {
674
- const compareWith = getStatics(layout);
675
- const sorted = sortLayoutItemsByColRow(layout);
557
+ const compareWith = chunkBJFPTW5Q_js.getStatics(layout);
558
+ const sorted = chunkBJFPTW5Q_js.sortLayoutItemsByColRow(layout);
676
559
  const out = new Array(layout.length);
677
560
  for (let i = 0; i < sorted.length; i++) {
678
561
  const sortedItem = sorted[i];
679
562
  if (sortedItem === void 0) continue;
680
- let l = cloneLayoutItem(sortedItem);
563
+ let l = chunkBJFPTW5Q_js.cloneLayoutItem(sortedItem);
681
564
  if (!l.static) {
682
565
  l = compactItemHorizontal(compareWith, l, cols, sorted);
683
566
  compareWith.push(l);
@@ -689,7 +572,7 @@ var horizontalCompactor = {
689
572
  return out;
690
573
  },
691
574
  onMove(layout, item, x, y, _cols) {
692
- const newLayout = cloneLayout(layout);
575
+ const newLayout = chunkBJFPTW5Q_js.cloneLayout(layout);
693
576
  const movedItem = newLayout.find((l) => l.i === item.i);
694
577
  if (movedItem) {
695
578
  movedItem.x = x;
@@ -703,10 +586,10 @@ var noCompactor = {
703
586
  type: null,
704
587
  allowOverlap: false,
705
588
  compact(layout, _cols) {
706
- return cloneLayout(layout);
589
+ return chunkBJFPTW5Q_js.cloneLayout(layout);
707
590
  },
708
591
  onMove(layout, item, x, y, _cols) {
709
- const newLayout = cloneLayout(layout);
592
+ const newLayout = chunkBJFPTW5Q_js.cloneLayout(layout);
710
593
  const movedItem = newLayout.find((l) => l.i === item.i);
711
594
  if (movedItem) {
712
595
  movedItem.x = x;
@@ -720,23 +603,27 @@ var verticalOverlapCompactor = {
720
603
  ...verticalCompactor,
721
604
  allowOverlap: true,
722
605
  compact(layout, _cols) {
723
- return cloneLayout(layout);
606
+ return chunkBJFPTW5Q_js.cloneLayout(layout);
724
607
  }
725
608
  };
726
609
  var horizontalOverlapCompactor = {
727
610
  ...horizontalCompactor,
728
611
  allowOverlap: true,
729
612
  compact(layout, _cols) {
730
- return cloneLayout(layout);
613
+ return chunkBJFPTW5Q_js.cloneLayout(layout);
731
614
  }
732
615
  };
616
+ var noOverlapCompactor = {
617
+ ...noCompactor,
618
+ allowOverlap: true
619
+ };
733
620
  function getCompactor(compactType, allowOverlap = false, preventCollision = false) {
734
621
  let baseCompactor;
735
622
  if (allowOverlap) {
736
623
  if (compactType === "vertical") baseCompactor = verticalOverlapCompactor;
737
624
  else if (compactType === "horizontal")
738
625
  baseCompactor = horizontalOverlapCompactor;
739
- else baseCompactor = noCompactor;
626
+ else baseCompactor = noOverlapCompactor;
740
627
  } else {
741
628
  if (compactType === "vertical") baseCompactor = verticalCompactor;
742
629
  else if (compactType === "horizontal") baseCompactor = horizontalCompactor;
@@ -781,7 +668,7 @@ function getColsFromBreakpoint(breakpoint, cols) {
781
668
  function findOrGenerateResponsiveLayout(layouts, breakpoints, breakpoint, lastBreakpoint, cols, compactType) {
782
669
  const existingLayout = layouts[breakpoint];
783
670
  if (existingLayout) {
784
- return cloneLayout(existingLayout);
671
+ return chunkBJFPTW5Q_js.cloneLayout(existingLayout);
785
672
  }
786
673
  let layout = layouts[lastBreakpoint];
787
674
  const breakpointsSorted = sortBreakpoints(breakpoints);
@@ -797,8 +684,8 @@ function findOrGenerateResponsiveLayout(layouts, breakpoints, breakpoint, lastBr
797
684
  break;
798
685
  }
799
686
  }
800
- const clonedLayout = cloneLayout(layout || []);
801
- return compact(correctBounds(clonedLayout, { cols }), compactType, cols);
687
+ const clonedLayout = chunkBJFPTW5Q_js.cloneLayout(layout || []);
688
+ return compact(chunkBJFPTW5Q_js.correctBounds(clonedLayout, { cols }), compactType, cols);
802
689
  }
803
690
  function getIndentationValue(value, breakpoint) {
804
691
  if (Array.isArray(value)) {
@@ -820,49 +707,45 @@ function getIndentationValue(value, breakpoint) {
820
707
  }
821
708
 
822
709
  exports.absoluteStrategy = absoluteStrategy;
823
- exports.bottom = bottom;
824
- exports.cloneLayout = cloneLayout;
825
- exports.cloneLayoutItem = cloneLayoutItem;
826
- exports.collides = collides;
710
+ exports.applyPositionConstraints = applyPositionConstraints;
711
+ exports.applySizeConstraints = applySizeConstraints;
712
+ exports.aspectRatio = aspectRatio;
713
+ exports.boundedX = boundedX;
714
+ exports.boundedY = boundedY;
827
715
  exports.compact = compact;
828
716
  exports.compactItem = compactItem;
829
717
  exports.compactItemHorizontal = compactItemHorizontal;
830
718
  exports.compactItemVertical = compactItemVertical;
831
- exports.correctBounds = correctBounds;
719
+ exports.containerBounds = containerBounds;
832
720
  exports.createScaledStrategy = createScaledStrategy;
721
+ exports.defaultConstraints = defaultConstraints;
833
722
  exports.defaultDragConfig = defaultDragConfig;
834
723
  exports.defaultDropConfig = defaultDropConfig;
835
724
  exports.defaultGridConfig = defaultGridConfig;
836
725
  exports.defaultPositionStrategy = defaultPositionStrategy;
837
726
  exports.defaultResizeConfig = defaultResizeConfig;
838
727
  exports.findOrGenerateResponsiveLayout = findOrGenerateResponsiveLayout;
839
- exports.getAllCollisions = getAllCollisions;
840
728
  exports.getBreakpointFromWidth = getBreakpointFromWidth;
841
729
  exports.getColsFromBreakpoint = getColsFromBreakpoint;
842
730
  exports.getCompactor = getCompactor;
843
- exports.getFirstCollision = getFirstCollision;
844
731
  exports.getIndentationValue = getIndentationValue;
845
- exports.getLayoutItem = getLayoutItem;
846
- exports.getStatics = getStatics;
732
+ exports.gridBounds = gridBounds;
847
733
  exports.horizontalCompactor = horizontalCompactor;
848
734
  exports.horizontalOverlapCompactor = horizontalOverlapCompactor;
849
- exports.modifyLayout = modifyLayout;
850
- exports.moveElement = moveElement;
851
- exports.moveElementAwayFromCollision = moveElementAwayFromCollision;
735
+ exports.maxSize = maxSize;
736
+ exports.minMaxSize = minMaxSize;
737
+ exports.minSize = minSize;
852
738
  exports.noCompactor = noCompactor;
739
+ exports.noOverlapCompactor = noOverlapCompactor;
853
740
  exports.perc = perc;
854
741
  exports.resizeItemInDirection = resizeItemInDirection;
855
742
  exports.resolveCompactionCollision = resolveCompactionCollision2;
856
743
  exports.setTopLeft = setTopLeft;
857
744
  exports.setTransform = setTransform;
745
+ exports.snapToGrid = snapToGrid;
858
746
  exports.sortBreakpoints = sortBreakpoints;
859
- exports.sortLayoutItems = sortLayoutItems;
860
- exports.sortLayoutItemsByColRow = sortLayoutItemsByColRow;
861
- exports.sortLayoutItemsByRowCol = sortLayoutItemsByRowCol;
862
747
  exports.transformStrategy = transformStrategy;
863
- exports.validateLayout = validateLayout;
864
748
  exports.verticalCompactor = verticalCompactor;
865
749
  exports.verticalOverlapCompactor = verticalOverlapCompactor;
866
- exports.withLayoutItem = withLayoutItem;
867
- //# sourceMappingURL=chunk-3WO4SAYB.js.map
868
- //# sourceMappingURL=chunk-3WO4SAYB.js.map
750
+ //# sourceMappingURL=chunk-WWS3M5Y3.js.map
751
+ //# sourceMappingURL=chunk-WWS3M5Y3.js.map