react-grid-layout 1.5.3 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/README.md +1156 -442
  2. package/css/styles.css +5 -4
  3. package/dist/ResponsiveGridLayout-BkHF9YHa.d.mts +133 -0
  4. package/dist/ResponsiveGridLayout-CLn16-X3.d.ts +133 -0
  5. package/dist/calculate-DsVTldEE.d.ts +196 -0
  6. package/dist/calculate-DwbL1D06.d.mts +196 -0
  7. package/dist/chunk-2O3ZME4Q.mjs +703 -0
  8. package/dist/chunk-2O3ZME4Q.mjs.map +1 -0
  9. package/dist/chunk-526JND3R.mjs +3 -0
  10. package/dist/chunk-526JND3R.mjs.map +1 -0
  11. package/dist/chunk-7ELO5FRW.js +4 -0
  12. package/dist/chunk-7ELO5FRW.js.map +1 -0
  13. package/dist/chunk-AWM66AWF.mjs +422 -0
  14. package/dist/chunk-AWM66AWF.mjs.map +1 -0
  15. package/dist/chunk-BJFPTW5Q.js +449 -0
  16. package/dist/chunk-BJFPTW5Q.js.map +1 -0
  17. package/dist/chunk-FN6MIZ24.js +744 -0
  18. package/dist/chunk-FN6MIZ24.js.map +1 -0
  19. package/dist/chunk-GPZBANOK.js +435 -0
  20. package/dist/chunk-GPZBANOK.js.map +1 -0
  21. package/dist/chunk-LWF5EYMO.mjs +429 -0
  22. package/dist/chunk-LWF5EYMO.mjs.map +1 -0
  23. package/dist/chunk-MXXN7GUE.mjs +1408 -0
  24. package/dist/chunk-MXXN7GUE.mjs.map +1 -0
  25. package/dist/chunk-QRW3ND4U.js +1417 -0
  26. package/dist/chunk-QRW3ND4U.js.map +1 -0
  27. package/dist/core.d.mts +186 -0
  28. package/dist/core.d.ts +186 -0
  29. package/dist/core.js +274 -0
  30. package/dist/core.js.map +1 -0
  31. package/dist/core.mjs +5 -0
  32. package/dist/core.mjs.map +1 -0
  33. package/dist/extras.d.mts +208 -0
  34. package/dist/extras.d.ts +208 -0
  35. package/dist/extras.js +462 -0
  36. package/dist/extras.js.map +1 -0
  37. package/dist/extras.mjs +454 -0
  38. package/dist/extras.mjs.map +1 -0
  39. package/dist/index.d.mts +7 -0
  40. package/dist/index.d.ts +7 -0
  41. package/dist/index.js +154 -0
  42. package/dist/index.js.map +1 -0
  43. package/dist/index.mjs +7 -0
  44. package/dist/index.mjs.map +1 -0
  45. package/dist/legacy.d.mts +163 -0
  46. package/dist/legacy.d.ts +163 -0
  47. package/dist/legacy.js +320 -0
  48. package/dist/legacy.js.map +1 -0
  49. package/dist/legacy.mjs +308 -0
  50. package/dist/legacy.mjs.map +1 -0
  51. package/dist/position-C8a5g6bb.d.mts +324 -0
  52. package/dist/position-H8tBL91b.d.ts +324 -0
  53. package/dist/react.d.mts +357 -0
  54. package/dist/react.d.ts +357 -0
  55. package/dist/react.js +96 -0
  56. package/dist/react.js.map +1 -0
  57. package/dist/react.mjs +7 -0
  58. package/dist/react.mjs.map +1 -0
  59. package/dist/responsive-BB5d98xz.d.mts +145 -0
  60. package/dist/responsive-BXI-GCXG.d.ts +145 -0
  61. package/dist/types-CokovIMH.d.mts +469 -0
  62. package/dist/types-CokovIMH.d.ts +469 -0
  63. package/index-dev.js +24 -0
  64. package/package.json +133 -40
  65. package/.babelrc.js +0 -22
  66. package/.browserslistrc +0 -3
  67. package/.eslintignore +0 -4
  68. package/.flowconfig +0 -20
  69. package/.prettierignore +0 -4
  70. package/.prettierrc +0 -17
  71. package/CHANGELOG.md +0 -985
  72. package/build/GridItem.js +0 -638
  73. package/build/ReactGridLayout.js +0 -741
  74. package/build/ReactGridLayoutPropTypes.js +0 -210
  75. package/build/ResponsiveReactGridLayout.js +0 -297
  76. package/build/calculateUtils.js +0 -165
  77. package/build/components/WidthProvider.js +0 -115
  78. package/build/fastRGLPropsEqual.js +0 -5
  79. package/build/responsiveUtils.js +0 -101
  80. package/build/utils.js +0 -842
  81. package/dist/react-grid-layout.min.js +0 -2
  82. package/dist/react-grid-layout.min.js.map +0 -1
  83. package/index.js.flow +0 -8
  84. package/ip_fetcher +0 -0
  85. package/ip_fetcher.c +0 -47
  86. package/lib/GridItem.jsx +0 -689
  87. package/lib/ReactGridLayout.jsx +0 -855
  88. package/lib/ReactGridLayoutPropTypes.js +0 -241
  89. package/lib/ResponsiveReactGridLayout.jsx +0 -349
  90. package/lib/calculateUtils.js +0 -169
  91. package/lib/components/WidthProvider.jsx +0 -110
  92. package/lib/fastRGLPropsEqual.js +0 -46
  93. package/lib/responsiveUtils.js +0 -118
  94. package/lib/utils.js +0 -995
  95. package/yarn-error.log +0 -7780
@@ -0,0 +1,744 @@
1
+ 'use strict';
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
+
168
+ // src/core/position.ts
169
+ function setTransform({
170
+ top,
171
+ left,
172
+ width,
173
+ height
174
+ }) {
175
+ const translate = `translate(${left}px,${top}px)`;
176
+ return {
177
+ transform: translate,
178
+ WebkitTransform: translate,
179
+ MozTransform: translate,
180
+ msTransform: translate,
181
+ OTransform: translate,
182
+ width: `${width}px`,
183
+ height: `${height}px`,
184
+ position: "absolute"
185
+ };
186
+ }
187
+ function setTopLeft({
188
+ top,
189
+ left,
190
+ width,
191
+ height
192
+ }) {
193
+ return {
194
+ top: `${top}px`,
195
+ left: `${left}px`,
196
+ width: `${width}px`,
197
+ height: `${height}px`,
198
+ position: "absolute"
199
+ };
200
+ }
201
+ function perc(num) {
202
+ return num * 100 + "%";
203
+ }
204
+ function constrainWidth(left, currentWidth, newWidth, containerWidth) {
205
+ return left + newWidth > containerWidth ? currentWidth : newWidth;
206
+ }
207
+ function constrainHeight(top, currentHeight, newHeight) {
208
+ return top < 0 ? currentHeight : newHeight;
209
+ }
210
+ function constrainLeft(left) {
211
+ return Math.max(0, left);
212
+ }
213
+ function constrainTop(top) {
214
+ return Math.max(0, top);
215
+ }
216
+ var resizeNorth = (currentSize, newSize, _containerWidth) => {
217
+ const { left, height, width } = newSize;
218
+ const top = currentSize.top - (height - currentSize.height);
219
+ return {
220
+ left,
221
+ width,
222
+ height: constrainHeight(top, currentSize.height, height),
223
+ top: constrainTop(top)
224
+ };
225
+ };
226
+ var resizeEast = (currentSize, newSize, containerWidth) => {
227
+ const { top, left, height, width } = newSize;
228
+ return {
229
+ top,
230
+ height,
231
+ width: constrainWidth(
232
+ currentSize.left,
233
+ currentSize.width,
234
+ width,
235
+ containerWidth
236
+ ),
237
+ left: constrainLeft(left)
238
+ };
239
+ };
240
+ var resizeWest = (currentSize, newSize, _containerWidth) => {
241
+ const { top, height, width } = newSize;
242
+ const left = currentSize.left + currentSize.width - width;
243
+ if (left < 0) {
244
+ return {
245
+ height,
246
+ width: currentSize.left + currentSize.width,
247
+ top: constrainTop(top),
248
+ left: 0
249
+ };
250
+ }
251
+ return {
252
+ height,
253
+ width,
254
+ top: constrainTop(top),
255
+ left
256
+ };
257
+ };
258
+ var resizeSouth = (currentSize, newSize, _containerWidth) => {
259
+ const { top, left, height, width } = newSize;
260
+ return {
261
+ width,
262
+ left,
263
+ height: constrainHeight(top, currentSize.height, height),
264
+ top: constrainTop(top)
265
+ };
266
+ };
267
+ var resizeNorthEast = (currentSize, newSize, containerWidth) => resizeNorth(
268
+ currentSize,
269
+ resizeEast(currentSize, newSize, containerWidth));
270
+ var resizeNorthWest = (currentSize, newSize, containerWidth) => resizeNorth(
271
+ currentSize,
272
+ resizeWest(currentSize, newSize));
273
+ var resizeSouthEast = (currentSize, newSize, containerWidth) => resizeSouth(
274
+ currentSize,
275
+ resizeEast(currentSize, newSize, containerWidth));
276
+ var resizeSouthWest = (currentSize, newSize, containerWidth) => resizeSouth(
277
+ currentSize,
278
+ resizeWest(currentSize, newSize));
279
+ var resizeHandlerMap = {
280
+ n: resizeNorth,
281
+ ne: resizeNorthEast,
282
+ e: resizeEast,
283
+ se: resizeSouthEast,
284
+ s: resizeSouth,
285
+ sw: resizeSouthWest,
286
+ w: resizeWest,
287
+ nw: resizeNorthWest
288
+ };
289
+ function resizeItemInDirection(direction, currentSize, newSize, containerWidth) {
290
+ const handler = resizeHandlerMap[direction];
291
+ if (!handler) {
292
+ return newSize;
293
+ }
294
+ return handler(currentSize, { ...currentSize, ...newSize }, containerWidth);
295
+ }
296
+ var transformStrategy = {
297
+ type: "transform",
298
+ scale: 1,
299
+ calcStyle(pos) {
300
+ return setTransform(pos);
301
+ },
302
+ calcDragPosition(clientX, clientY, offsetX, offsetY) {
303
+ return {
304
+ left: clientX - offsetX,
305
+ top: clientY - offsetY
306
+ };
307
+ }
308
+ };
309
+ var absoluteStrategy = {
310
+ type: "absolute",
311
+ scale: 1,
312
+ calcStyle(pos) {
313
+ return setTopLeft(pos);
314
+ },
315
+ calcDragPosition(clientX, clientY, offsetX, offsetY) {
316
+ return {
317
+ left: clientX - offsetX,
318
+ top: clientY - offsetY
319
+ };
320
+ }
321
+ };
322
+ function createScaledStrategy(scale) {
323
+ return {
324
+ type: "transform",
325
+ scale,
326
+ calcStyle(pos) {
327
+ return setTransform(pos);
328
+ },
329
+ calcDragPosition(clientX, clientY, offsetX, offsetY) {
330
+ return {
331
+ left: (clientX - offsetX) / scale,
332
+ top: (clientY - offsetY) / scale
333
+ };
334
+ }
335
+ };
336
+ }
337
+ var defaultPositionStrategy = transformStrategy;
338
+
339
+ // src/core/types.ts
340
+ var defaultGridConfig = {
341
+ cols: 12,
342
+ rowHeight: 150,
343
+ margin: [10, 10],
344
+ containerPadding: null,
345
+ maxRows: Infinity
346
+ };
347
+ var defaultDragConfig = {
348
+ enabled: true,
349
+ bounded: false,
350
+ threshold: 3
351
+ };
352
+ var defaultResizeConfig = {
353
+ enabled: true,
354
+ handles: ["se"]
355
+ };
356
+ var defaultDropConfig = {
357
+ enabled: false,
358
+ defaultItem: { w: 1, h: 1 }
359
+ };
360
+
361
+ // src/core/compact-compat.ts
362
+ function getStatics2(layout) {
363
+ return layout.filter((l) => l.static);
364
+ }
365
+ var heightWidth = { x: "w", y: "h" };
366
+ function resolveCompactionCollision(layout, item, moveToCoord, axis, hasStatics) {
367
+ const sizeProp = heightWidth[axis];
368
+ item[axis] += 1;
369
+ const itemIndex = layout.findIndex((l) => l.i === item.i);
370
+ const layoutHasStatics = hasStatics ?? getStatics2(layout).length > 0;
371
+ for (let i = itemIndex + 1; i < layout.length; i++) {
372
+ const otherItem = layout[i];
373
+ if (otherItem === void 0) continue;
374
+ if (otherItem.static) continue;
375
+ if (!layoutHasStatics && otherItem.y > item.y + item.h) break;
376
+ if (chunkBJFPTW5Q_js.collides(item, otherItem)) {
377
+ resolveCompactionCollision(
378
+ layout,
379
+ otherItem,
380
+ moveToCoord + item[sizeProp],
381
+ axis,
382
+ layoutHasStatics
383
+ );
384
+ }
385
+ }
386
+ item[axis] = moveToCoord;
387
+ }
388
+ function compactItemInternal(compareWith, l, compactType, cols, fullLayout, allowOverlap, b) {
389
+ const compactV = compactType === "vertical";
390
+ const compactH = compactType === "horizontal";
391
+ if (compactV) {
392
+ if (typeof b === "number") {
393
+ l.y = Math.min(b, l.y);
394
+ } else {
395
+ l.y = Math.min(chunkBJFPTW5Q_js.bottom(compareWith), l.y);
396
+ }
397
+ while (l.y > 0 && !chunkBJFPTW5Q_js.getFirstCollision(compareWith, l)) {
398
+ l.y--;
399
+ }
400
+ } else if (compactH) {
401
+ while (l.x > 0 && !chunkBJFPTW5Q_js.getFirstCollision(compareWith, l)) {
402
+ l.x--;
403
+ }
404
+ }
405
+ let collision;
406
+ while ((collision = chunkBJFPTW5Q_js.getFirstCollision(compareWith, l)) !== void 0 && !(compactType === null && allowOverlap)) {
407
+ if (compactH) {
408
+ resolveCompactionCollision(fullLayout, l, collision.x + collision.w, "x");
409
+ } else {
410
+ resolveCompactionCollision(fullLayout, l, collision.y + collision.h, "y");
411
+ }
412
+ if (compactH && l.x + l.w > cols) {
413
+ l.x = cols - l.w;
414
+ l.y++;
415
+ while (l.x > 0 && !chunkBJFPTW5Q_js.getFirstCollision(compareWith, l)) {
416
+ l.x--;
417
+ }
418
+ }
419
+ }
420
+ l.y = Math.max(l.y, 0);
421
+ l.x = Math.max(l.x, 0);
422
+ return l;
423
+ }
424
+ function compact(layout, compactType, cols, allowOverlap) {
425
+ const compareWith = getStatics2(layout);
426
+ let b = chunkBJFPTW5Q_js.bottom(compareWith);
427
+ const sorted = chunkBJFPTW5Q_js.sortLayoutItems(layout, compactType);
428
+ const out = new Array(layout.length);
429
+ for (let i = 0; i < sorted.length; i++) {
430
+ const sortedItem = sorted[i];
431
+ if (sortedItem === void 0) continue;
432
+ let l = chunkBJFPTW5Q_js.cloneLayoutItem(sortedItem);
433
+ if (!l.static) {
434
+ l = compactItemInternal(
435
+ compareWith,
436
+ l,
437
+ compactType,
438
+ cols,
439
+ sorted,
440
+ allowOverlap,
441
+ b
442
+ );
443
+ b = Math.max(b, l.y + l.h);
444
+ compareWith.push(l);
445
+ }
446
+ const originalIndex = layout.indexOf(sortedItem);
447
+ out[originalIndex] = l;
448
+ l.moved = false;
449
+ }
450
+ return out;
451
+ }
452
+ function compactItem(compareWith, l, compactType, cols, fullLayout, allowOverlap, maxY) {
453
+ return compactItemInternal(
454
+ compareWith,
455
+ chunkBJFPTW5Q_js.cloneLayoutItem(l),
456
+ compactType,
457
+ cols,
458
+ fullLayout,
459
+ allowOverlap,
460
+ maxY
461
+ );
462
+ }
463
+
464
+ // src/core/compactors.ts
465
+ function resolveCompactionCollision2(layout, item, moveToCoord, axis, hasStatics) {
466
+ const sizeProp = axis === "x" ? "w" : "h";
467
+ item[axis] += 1;
468
+ const itemIndex = layout.findIndex((l) => l.i === item.i);
469
+ const layoutHasStatics = hasStatics ?? chunkBJFPTW5Q_js.getStatics(layout).length > 0;
470
+ for (let i = itemIndex + 1; i < layout.length; i++) {
471
+ const otherItem = layout[i];
472
+ if (otherItem === void 0) continue;
473
+ if (otherItem.static) continue;
474
+ if (!layoutHasStatics && otherItem.y > item.y + item.h) break;
475
+ if (chunkBJFPTW5Q_js.collides(item, otherItem)) {
476
+ resolveCompactionCollision2(
477
+ layout,
478
+ otherItem,
479
+ moveToCoord + item[sizeProp],
480
+ axis,
481
+ layoutHasStatics
482
+ );
483
+ }
484
+ }
485
+ item[axis] = moveToCoord;
486
+ }
487
+ function compactItemVertical(compareWith, l, fullLayout, maxY) {
488
+ l.y = Math.min(maxY, l.y);
489
+ while (l.y > 0 && !chunkBJFPTW5Q_js.getFirstCollision(compareWith, l)) {
490
+ l.y--;
491
+ }
492
+ let collision;
493
+ while ((collision = chunkBJFPTW5Q_js.getFirstCollision(compareWith, l)) !== void 0) {
494
+ resolveCompactionCollision2(fullLayout, l, collision.y + collision.h, "y");
495
+ }
496
+ l.y = Math.max(l.y, 0);
497
+ return l;
498
+ }
499
+ function compactItemHorizontal(compareWith, l, cols, fullLayout) {
500
+ while (l.x > 0 && !chunkBJFPTW5Q_js.getFirstCollision(compareWith, l)) {
501
+ l.x--;
502
+ }
503
+ let collision;
504
+ while ((collision = chunkBJFPTW5Q_js.getFirstCollision(compareWith, l)) !== void 0) {
505
+ resolveCompactionCollision2(fullLayout, l, collision.x + collision.w, "x");
506
+ if (l.x + l.w > cols) {
507
+ l.x = cols - l.w;
508
+ l.y++;
509
+ while (l.x > 0 && !chunkBJFPTW5Q_js.getFirstCollision(compareWith, l)) {
510
+ l.x--;
511
+ }
512
+ }
513
+ }
514
+ l.x = Math.max(l.x, 0);
515
+ return l;
516
+ }
517
+ var verticalCompactor = {
518
+ type: "vertical",
519
+ allowOverlap: false,
520
+ compact(layout, _cols) {
521
+ const compareWith = chunkBJFPTW5Q_js.getStatics(layout);
522
+ let maxY = chunkBJFPTW5Q_js.bottom(compareWith);
523
+ const sorted = chunkBJFPTW5Q_js.sortLayoutItemsByRowCol(layout);
524
+ const out = new Array(layout.length);
525
+ for (let i = 0; i < sorted.length; i++) {
526
+ const sortedItem = sorted[i];
527
+ if (sortedItem === void 0) continue;
528
+ let l = chunkBJFPTW5Q_js.cloneLayoutItem(sortedItem);
529
+ if (!l.static) {
530
+ l = compactItemVertical(compareWith, l, sorted, maxY);
531
+ maxY = Math.max(maxY, l.y + l.h);
532
+ compareWith.push(l);
533
+ }
534
+ const originalIndex = layout.indexOf(sortedItem);
535
+ out[originalIndex] = l;
536
+ l.moved = false;
537
+ }
538
+ return out;
539
+ },
540
+ onMove(layout, item, x, y, _cols) {
541
+ const newLayout = chunkBJFPTW5Q_js.cloneLayout(layout);
542
+ const movedItem = newLayout.find((l) => l.i === item.i);
543
+ if (movedItem) {
544
+ movedItem.x = x;
545
+ movedItem.y = y;
546
+ movedItem.moved = true;
547
+ }
548
+ return newLayout;
549
+ }
550
+ };
551
+ var horizontalCompactor = {
552
+ type: "horizontal",
553
+ allowOverlap: false,
554
+ compact(layout, cols) {
555
+ const compareWith = chunkBJFPTW5Q_js.getStatics(layout);
556
+ const sorted = chunkBJFPTW5Q_js.sortLayoutItemsByColRow(layout);
557
+ const out = new Array(layout.length);
558
+ for (let i = 0; i < sorted.length; i++) {
559
+ const sortedItem = sorted[i];
560
+ if (sortedItem === void 0) continue;
561
+ let l = chunkBJFPTW5Q_js.cloneLayoutItem(sortedItem);
562
+ if (!l.static) {
563
+ l = compactItemHorizontal(compareWith, l, cols, sorted);
564
+ compareWith.push(l);
565
+ }
566
+ const originalIndex = layout.indexOf(sortedItem);
567
+ out[originalIndex] = l;
568
+ l.moved = false;
569
+ }
570
+ return out;
571
+ },
572
+ onMove(layout, item, x, y, _cols) {
573
+ const newLayout = chunkBJFPTW5Q_js.cloneLayout(layout);
574
+ const movedItem = newLayout.find((l) => l.i === item.i);
575
+ if (movedItem) {
576
+ movedItem.x = x;
577
+ movedItem.y = y;
578
+ movedItem.moved = true;
579
+ }
580
+ return newLayout;
581
+ }
582
+ };
583
+ var noCompactor = {
584
+ type: null,
585
+ allowOverlap: false,
586
+ compact(layout, _cols) {
587
+ return chunkBJFPTW5Q_js.cloneLayout(layout);
588
+ },
589
+ onMove(layout, item, x, y, _cols) {
590
+ const newLayout = chunkBJFPTW5Q_js.cloneLayout(layout);
591
+ const movedItem = newLayout.find((l) => l.i === item.i);
592
+ if (movedItem) {
593
+ movedItem.x = x;
594
+ movedItem.y = y;
595
+ movedItem.moved = true;
596
+ }
597
+ return newLayout;
598
+ }
599
+ };
600
+ var verticalOverlapCompactor = {
601
+ ...verticalCompactor,
602
+ allowOverlap: true,
603
+ compact(layout, _cols) {
604
+ return chunkBJFPTW5Q_js.cloneLayout(layout);
605
+ }
606
+ };
607
+ var horizontalOverlapCompactor = {
608
+ ...horizontalCompactor,
609
+ allowOverlap: true,
610
+ compact(layout, _cols) {
611
+ return chunkBJFPTW5Q_js.cloneLayout(layout);
612
+ }
613
+ };
614
+ function getCompactor(compactType, allowOverlap = false, preventCollision = false) {
615
+ let baseCompactor;
616
+ if (allowOverlap) {
617
+ if (compactType === "vertical") baseCompactor = verticalOverlapCompactor;
618
+ else if (compactType === "horizontal")
619
+ baseCompactor = horizontalOverlapCompactor;
620
+ else baseCompactor = noCompactor;
621
+ } else {
622
+ if (compactType === "vertical") baseCompactor = verticalCompactor;
623
+ else if (compactType === "horizontal") baseCompactor = horizontalCompactor;
624
+ else baseCompactor = noCompactor;
625
+ }
626
+ if (preventCollision) {
627
+ return { ...baseCompactor, preventCollision };
628
+ }
629
+ return baseCompactor;
630
+ }
631
+
632
+ // src/core/responsive.ts
633
+ function sortBreakpoints(breakpoints) {
634
+ const keys = Object.keys(breakpoints);
635
+ return keys.sort((a, b) => breakpoints[a] - breakpoints[b]);
636
+ }
637
+ function getBreakpointFromWidth(breakpoints, width) {
638
+ const sorted = sortBreakpoints(breakpoints);
639
+ let matching = sorted[0];
640
+ if (matching === void 0) {
641
+ throw new Error("No breakpoints defined");
642
+ }
643
+ for (let i = 1; i < sorted.length; i++) {
644
+ const breakpointName = sorted[i];
645
+ if (breakpointName === void 0) continue;
646
+ const breakpointWidth = breakpoints[breakpointName];
647
+ if (width > breakpointWidth) {
648
+ matching = breakpointName;
649
+ }
650
+ }
651
+ return matching;
652
+ }
653
+ function getColsFromBreakpoint(breakpoint, cols) {
654
+ const colCount = cols[breakpoint];
655
+ if (colCount === void 0) {
656
+ throw new Error(
657
+ `ResponsiveReactGridLayout: \`cols\` entry for breakpoint ${String(breakpoint)} is missing!`
658
+ );
659
+ }
660
+ return colCount;
661
+ }
662
+ function findOrGenerateResponsiveLayout(layouts, breakpoints, breakpoint, lastBreakpoint, cols, compactType) {
663
+ const existingLayout = layouts[breakpoint];
664
+ if (existingLayout) {
665
+ return chunkBJFPTW5Q_js.cloneLayout(existingLayout);
666
+ }
667
+ let layout = layouts[lastBreakpoint];
668
+ const breakpointsSorted = sortBreakpoints(breakpoints);
669
+ const breakpointsAbove = breakpointsSorted.slice(
670
+ breakpointsSorted.indexOf(breakpoint)
671
+ );
672
+ for (let i = 0; i < breakpointsAbove.length; i++) {
673
+ const b = breakpointsAbove[i];
674
+ if (b === void 0) continue;
675
+ const layoutForBreakpoint = layouts[b];
676
+ if (layoutForBreakpoint) {
677
+ layout = layoutForBreakpoint;
678
+ break;
679
+ }
680
+ }
681
+ const clonedLayout = chunkBJFPTW5Q_js.cloneLayout(layout || []);
682
+ return compact(chunkBJFPTW5Q_js.correctBounds(clonedLayout, { cols }), compactType, cols);
683
+ }
684
+ function getIndentationValue(value, breakpoint) {
685
+ if (Array.isArray(value)) {
686
+ return value;
687
+ }
688
+ const breakpointMap = value;
689
+ const breakpointValue = breakpointMap[breakpoint];
690
+ if (breakpointValue !== void 0) {
691
+ return breakpointValue;
692
+ }
693
+ const keys = Object.keys(breakpointMap);
694
+ for (const key of keys) {
695
+ const v = breakpointMap[key];
696
+ if (v !== void 0) {
697
+ return v;
698
+ }
699
+ }
700
+ return [10, 10];
701
+ }
702
+
703
+ exports.absoluteStrategy = absoluteStrategy;
704
+ exports.applyPositionConstraints = applyPositionConstraints;
705
+ exports.applySizeConstraints = applySizeConstraints;
706
+ exports.aspectRatio = aspectRatio;
707
+ exports.boundedX = boundedX;
708
+ exports.boundedY = boundedY;
709
+ exports.compact = compact;
710
+ exports.compactItem = compactItem;
711
+ exports.compactItemHorizontal = compactItemHorizontal;
712
+ exports.compactItemVertical = compactItemVertical;
713
+ exports.containerBounds = containerBounds;
714
+ exports.createScaledStrategy = createScaledStrategy;
715
+ exports.defaultConstraints = defaultConstraints;
716
+ exports.defaultDragConfig = defaultDragConfig;
717
+ exports.defaultDropConfig = defaultDropConfig;
718
+ exports.defaultGridConfig = defaultGridConfig;
719
+ exports.defaultPositionStrategy = defaultPositionStrategy;
720
+ exports.defaultResizeConfig = defaultResizeConfig;
721
+ exports.findOrGenerateResponsiveLayout = findOrGenerateResponsiveLayout;
722
+ exports.getBreakpointFromWidth = getBreakpointFromWidth;
723
+ exports.getColsFromBreakpoint = getColsFromBreakpoint;
724
+ exports.getCompactor = getCompactor;
725
+ exports.getIndentationValue = getIndentationValue;
726
+ exports.gridBounds = gridBounds;
727
+ exports.horizontalCompactor = horizontalCompactor;
728
+ exports.horizontalOverlapCompactor = horizontalOverlapCompactor;
729
+ exports.maxSize = maxSize;
730
+ exports.minMaxSize = minMaxSize;
731
+ exports.minSize = minSize;
732
+ exports.noCompactor = noCompactor;
733
+ exports.perc = perc;
734
+ exports.resizeItemInDirection = resizeItemInDirection;
735
+ exports.resolveCompactionCollision = resolveCompactionCollision2;
736
+ exports.setTopLeft = setTopLeft;
737
+ exports.setTransform = setTransform;
738
+ exports.snapToGrid = snapToGrid;
739
+ exports.sortBreakpoints = sortBreakpoints;
740
+ exports.transformStrategy = transformStrategy;
741
+ exports.verticalCompactor = verticalCompactor;
742
+ exports.verticalOverlapCompactor = verticalOverlapCompactor;
743
+ //# sourceMappingURL=chunk-FN6MIZ24.js.map
744
+ //# sourceMappingURL=chunk-FN6MIZ24.js.map