publ-echo-test 0.0.331 → 0.0.332

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 (76) hide show
  1. package/css/gle-styles.css +0 -1
  2. package/package.json +1 -1
  3. package/dist/external-lib/classnames/index.d.ts +0 -5
  4. package/dist/external-lib/classnames/index.js +0 -60
  5. package/dist/external-lib/lodash.isEqual/index.d.ts +0 -30
  6. package/dist/external-lib/lodash.isEqual/index.js +0 -1661
  7. package/dist/lib/Draggable/Draggable.d.ts +0 -17
  8. package/dist/lib/Draggable/Draggable.js +0 -192
  9. package/dist/lib/Draggable/DraggableCore.d.ts +0 -5
  10. package/dist/lib/Draggable/DraggableCore.js +0 -267
  11. package/dist/lib/Draggable/constants.d.ts +0 -12
  12. package/dist/lib/Draggable/constants.js +0 -12
  13. package/dist/lib/Draggable/index.d.ts +0 -2
  14. package/dist/lib/Draggable/index.js +0 -2
  15. package/dist/lib/Draggable/types.d.ts +0 -55
  16. package/dist/lib/Draggable/types.js +0 -1
  17. package/dist/lib/Draggable/utils/domHelpers.d.ts +0 -22
  18. package/dist/lib/Draggable/utils/domHelpers.js +0 -222
  19. package/dist/lib/Draggable/utils/getPrefix.d.ts +0 -5
  20. package/dist/lib/Draggable/utils/getPrefix.js +0 -41
  21. package/dist/lib/Draggable/utils/positionHelpers.d.ts +0 -7
  22. package/dist/lib/Draggable/utils/positionHelpers.js +0 -32
  23. package/dist/lib/Draggable/utils/types.d.ts +0 -30
  24. package/dist/lib/Draggable/utils/types.js +0 -1
  25. package/dist/lib/Draggable/utils/validationHelpers.d.ts +0 -4
  26. package/dist/lib/Draggable/utils/validationHelpers.js +0 -16
  27. package/dist/lib/GridItem/GridItem.d.ts +0 -5
  28. package/dist/lib/GridItem/GridItem.js +0 -633
  29. package/dist/lib/GridItem/GridItemCopy.d.ts +0 -5
  30. package/dist/lib/GridItem/GridItemCopy.js +0 -613
  31. package/dist/lib/GridItem/GroupItem.d.ts +0 -10
  32. package/dist/lib/GridItem/GroupItem.js +0 -472
  33. package/dist/lib/GridItem/OutsideClickHandler.d.ts +0 -7
  34. package/dist/lib/GridItem/OutsideClickHandler.js +0 -112
  35. package/dist/lib/GridItem/index.d.ts +0 -1
  36. package/dist/lib/GridItem/index.js +0 -1
  37. package/dist/lib/GridItem/types.d.ts +0 -112
  38. package/dist/lib/GridItem/types.js +0 -1
  39. package/dist/lib/GridItem/utils/calculateUtils.d.ts +0 -30
  40. package/dist/lib/GridItem/utils/calculateUtils.js +0 -115
  41. package/dist/lib/GridLayoutEditor/ReactGridLayout.d.ts +0 -6
  42. package/dist/lib/GridLayoutEditor/ReactGridLayout.js +0 -748
  43. package/dist/lib/GridLayoutEditor/ResponsiveGridLayout.d.ts +0 -4
  44. package/dist/lib/GridLayoutEditor/ResponsiveGridLayout.js +0 -117
  45. package/dist/lib/GridLayoutEditor/group.d.ts +0 -58
  46. package/dist/lib/GridLayoutEditor/group.js +0 -341
  47. package/dist/lib/GridLayoutEditor/index.d.ts +0 -3
  48. package/dist/lib/GridLayoutEditor/index.js +0 -2
  49. package/dist/lib/GridLayoutEditor/types.d.ts +0 -170
  50. package/dist/lib/GridLayoutEditor/types.js +0 -1
  51. package/dist/lib/GridLayoutEditor/utils/renderHelpers.d.ts +0 -173
  52. package/dist/lib/GridLayoutEditor/utils/renderHelpers.js +0 -607
  53. package/dist/lib/GridLayoutEditor/utils/responsiveUtils.d.ts +0 -26
  54. package/dist/lib/GridLayoutEditor/utils/responsiveUtils.js +0 -77
  55. package/dist/lib/Resizable/Resizable.d.ts +0 -6
  56. package/dist/lib/Resizable/Resizable.js +0 -386
  57. package/dist/lib/Resizable/ResizableBox.d.ts +0 -7
  58. package/dist/lib/Resizable/ResizableBox.js +0 -57
  59. package/dist/lib/Resizable/index.d.ts +0 -1
  60. package/dist/lib/Resizable/index.js +0 -1
  61. package/dist/lib/Resizable/types.d.ts +0 -69
  62. package/dist/lib/Resizable/types.js +0 -1
  63. package/dist/lib/Resizable/utils/cloneElement.d.ts +0 -2
  64. package/dist/lib/Resizable/utils/cloneElement.js +0 -21
  65. package/dist/lib/components/WidthProvider.d.ts +0 -9
  66. package/dist/lib/components/WidthProvider.js +0 -65
  67. package/dist/lib/components/index.d.ts +0 -1
  68. package/dist/lib/components/index.js +0 -1
  69. package/dist/lib/components/types.d.ts +0 -13
  70. package/dist/lib/components/types.js +0 -1
  71. package/dist/lib/index.d.ts +0 -5
  72. package/dist/lib/index.js +0 -5
  73. package/dist/lib/types.d.ts +0 -4
  74. package/dist/lib/types.js +0 -1
  75. package/dist/lib/utils/classNames.d.ts +0 -3
  76. package/dist/lib/utils/classNames.js +0 -10
@@ -1,607 +0,0 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- import React from "react";
13
- var isProduction = process.env.NODE_ENV === "production";
14
- var DEBUG = false;
15
- /**
16
- * Return the bottom coordinate of the layout.
17
- *
18
- * @param {Array} layout Layout array.
19
- * @return {Number} Bottom coordinate.
20
- */
21
- export function bottom(layout) {
22
- var max = 0, bottomY;
23
- for (var i = 0, len = layout.length; i < len; i++) {
24
- bottomY = layout[i].y + layout[i].h;
25
- if (bottomY > max)
26
- max = bottomY;
27
- }
28
- return max;
29
- }
30
- export function cloneLayout(layout) {
31
- var newLayout = Array(layout.length);
32
- for (var i = 0, len = layout.length; i < len; i++) {
33
- newLayout[i] = cloneLayoutItem(layout[i]);
34
- }
35
- return newLayout;
36
- }
37
- export function modifyLayout(layout, layoutItem) {
38
- var newLayout = Array(layout.length);
39
- for (var i = 0, len = layout.length; i < len; i++) {
40
- if (layoutItem.i === layout[i].i) {
41
- newLayout[i] = layoutItem;
42
- }
43
- else {
44
- newLayout[i] = layout[i];
45
- }
46
- }
47
- return newLayout;
48
- }
49
- // Function to be called to modify a layout item.
50
- // Does defensive clones to ensure the layout is not modified.
51
- export function withLayoutItem(layout, itemKey, cb) {
52
- var item = getLayoutItem(layout, itemKey);
53
- if (!item)
54
- return [layout, null];
55
- item = cb(cloneLayoutItem(item)); // defensive clone then modify
56
- // FIXME could do this faster if we already knew the index
57
- layout = modifyLayout(layout, item);
58
- return [layout, item];
59
- }
60
- // Fast path to cloning, since this is monomorphic
61
- export function cloneLayoutItem(layoutItem) {
62
- return __assign(__assign({}, layoutItem), { w: layoutItem.w, h: layoutItem.h, x: layoutItem.x, y: layoutItem.y, z: layoutItem.z, i: layoutItem.i, minW: layoutItem.minW, maxW: layoutItem.maxW, minH: layoutItem.minH, maxH: layoutItem.maxH, moved: Boolean(layoutItem.moved), static: Boolean(layoutItem.static), isDraggable: layoutItem.isDraggable, isResizable: layoutItem.isResizable, resizeHandles: layoutItem.resizeHandles, isBounded: layoutItem.isBounded });
63
- }
64
- /**
65
- * Comparing React `children` is a bit difficult. This is a good way to compare them.
66
- * This will catch differences in keys, order, and length.
67
- */
68
- // NOTE - 쓰이는 곳이 없음
69
- // export function childrenEqual(a: ReactChildren, b: ReactChildren): boolean {
70
- // return isEqual(
71
- // React.Children.map(a, (c) => c?.["key"]),
72
- // React.Children.map(b, (c) => c?.["key"])
73
- // );
74
- // }
75
- export function fastPositionEqual(a, b) {
76
- return (a.left === b.left &&
77
- a.top === b.top &&
78
- a.width === b.width &&
79
- a.height === b.height);
80
- }
81
- /**
82
- * Given two layoutItems, check if they collide.
83
- */
84
- export function collides(l1, l2) {
85
- if (l1.i === l2.i)
86
- return false; // same element
87
- if (l1.x + l1.w <= l2.x)
88
- return false; // l1 is left of l2
89
- if (l1.x >= l2.x + l2.w)
90
- return false; // l1 is right of l2
91
- if (l1.y + l1.h <= l2.y)
92
- return false; // l1 is above l2
93
- if (l1.y >= l2.y + l2.h)
94
- return false; // l1 is below l2
95
- return true; // boxes overlap
96
- }
97
- /**
98
- * Given a layout, compact it. This involves going down each y coordinate and removing gaps
99
- * between items.
100
- *
101
- * Does not modify layout items (clones). Creates a new layout array.
102
- *
103
- * @param {Array} layout Layout.
104
- * @param {Boolean} verticalCompact Whether or not to compact the layout
105
- * vertically.
106
- * @param {Boolean} allowOverlap When `true`, allows overlapping grid items.
107
- * @return {Array} Compacted Layout.
108
- */
109
- export function compact(layout, compactType, cols, allowOverlap) {
110
- var compareWith = getStatics(layout);
111
- var sorted = sortLayoutItems(layout, compactType);
112
- var out = Array(layout.length);
113
- for (var i = 0, len = sorted.length; i < len; i++) {
114
- var l = cloneLayoutItem(sorted[i]);
115
- // Don't move static elements
116
- if (!l.static) {
117
- l = compactItem(compareWith, l, compactType, cols, sorted, allowOverlap);
118
- // Add to comparison array. We only collide with items before this one.
119
- // Statics are already in this array.
120
- compareWith.push(l);
121
- }
122
- // Add to output array to make sure they still come out in the right order.
123
- out[layout.indexOf(sorted[i])] = l;
124
- // Clear moved flag, if it exists.
125
- l.moved = false;
126
- }
127
- return out;
128
- }
129
- var heightWidth = { x: "w", y: "h" };
130
- /**
131
- * Before moving item down, it will check if the movement will cause collisions and move those items down before.
132
- */
133
- function resolveCompactionCollision(layout, item, moveToCoord, axis) {
134
- var sizeProp = heightWidth[axis];
135
- item[axis] += 1;
136
- var itemIndex = layout
137
- .map(function (layoutItem) {
138
- return layoutItem.i;
139
- })
140
- .indexOf(item.i);
141
- for (var i = itemIndex + 1; i < layout.length; i++) {
142
- var otherItem = layout[i];
143
- // Ignore static items
144
- if (otherItem.static)
145
- continue;
146
- if (otherItem.y > item.y + item.h)
147
- break;
148
- if (collides(item, otherItem)) {
149
- resolveCompactionCollision(layout, otherItem, moveToCoord + item[sizeProp], axis);
150
- }
151
- }
152
- item[axis] = moveToCoord;
153
- }
154
- /**
155
- * Compact an item in the layout.
156
- *
157
- * Modifies item.
158
- *
159
- */
160
- export function compactItem(compareWith, l, compactType, cols, fullLayout, allowOverlap) {
161
- var compactV = compactType === "vertical";
162
- var compactH = compactType === "horizontal";
163
- if (compactV) {
164
- l.y = Math.min(bottom(compareWith), l.y);
165
- while (l.y > 0 && !getFirstCollision(compareWith, l)) {
166
- l.y--;
167
- }
168
- }
169
- else if (compactH) {
170
- while (l.x > 0 && !getFirstCollision(compareWith, l)) {
171
- l.x--;
172
- }
173
- }
174
- var collides;
175
- while ((collides = getFirstCollision(compareWith, l)) &&
176
- !(compactType === null && allowOverlap)) {
177
- if (compactH) {
178
- resolveCompactionCollision(fullLayout, l, collides.x + collides.w, "x");
179
- }
180
- else {
181
- resolveCompactionCollision(fullLayout, l, collides.y + collides.h, "y");
182
- }
183
- if (compactH && l.x + l.w > cols) {
184
- l.x = cols - l.w;
185
- l.y++;
186
- while (l.x > 0 && !getFirstCollision(compareWith, l)) {
187
- l.x--;
188
- }
189
- }
190
- }
191
- l.y = Math.max(l.y, 0);
192
- l.x = Math.max(l.x, 0);
193
- return l;
194
- }
195
- /**
196
- * Given a layout, make sure all elements fit within its bounds.
197
- *
198
- * Modifies layout items.
199
- *
200
- * @param {Array} layout Layout array.
201
- * @param {Number} bounds Number of columns.
202
- */
203
- export function correctBounds(layout, bounds) {
204
- var collidesWith = getStatics(layout);
205
- for (var i = 0, len = layout.length; i < len; i++) {
206
- var l = layout[i];
207
- if (l.x + l.w > bounds.cols)
208
- l.x = bounds.cols - l.w;
209
- if (l.x < 0) {
210
- l.x = 0;
211
- l.w = bounds.cols;
212
- }
213
- if (l.z == null) {
214
- l.z = 0;
215
- }
216
- if (!l.static)
217
- collidesWith.push(l);
218
- else {
219
- while (getFirstCollision(collidesWith, l)) {
220
- l.y++;
221
- }
222
- }
223
- }
224
- return layout;
225
- }
226
- /**
227
- * Get a layout item by ID. Used so we can override later on if necessary.
228
- *
229
- * @param {Array} layout Layout array.
230
- * @param {String} id ID
231
- * @return {LayoutItem} Item at ID.
232
- */
233
- export function getLayoutItem(layout, id) {
234
- for (var i = 0, len = layout.length; i < len; i++) {
235
- if (layout[i].i === id)
236
- return layout[i];
237
- }
238
- }
239
- /**
240
- * Returns the first item this layout collides with.
241
- * It doesn't appear to matter which order we approach this from, although
242
- * perhaps that is the wrong thing to do.
243
- *
244
- * @param {Object} layoutItem Layout item.
245
- * @return {Object|undefined} A colliding layout item, or undefined.
246
- */
247
- export function getFirstCollision(layout, layoutItem) {
248
- for (var i = 0, len = layout.length; i < len; i++) {
249
- if (collides(layout[i], layoutItem))
250
- return layout[i];
251
- }
252
- }
253
- export function getAllCollisions(layout, layoutItem) {
254
- return layout.filter(function (l) { return collides(l, layoutItem); });
255
- }
256
- /**
257
- * Get all static elements.
258
- * @param {Array} layout Array of layout objects.
259
- * @return {Array} Array of static layout items..
260
- */
261
- export function getStatics(layout) {
262
- return layout.filter(function (l) { return l.static; });
263
- }
264
- /**
265
- * Move an element. Responsible for doing cascading movements of other elements.
266
- *
267
- * Modifies layout items.
268
- *
269
- * @param {Array} layout Full layout to modify.
270
- * @param {LayoutItem} l element to move.
271
- * @param {Number} [x] X position in grid units.
272
- * @param {Number} [y] Y position in grid units.
273
- */
274
- export function moveElement(properties) {
275
- var l = properties.l, x = properties.x, y = properties.y, z = properties.z, isUserAction = properties.isUserAction, preventCollision = properties.preventCollision, cols = properties.cols, compactType = properties.compactType, allowOverlap = properties.allowOverlap, overrideZ = properties.overrideZ;
276
- var layout = properties.layout;
277
- if (l.static && l.isDraggable !== true)
278
- return layout;
279
- if (l.y === y && l.x === x && l.z === z)
280
- return layout;
281
- log("Moving element ".concat(l.i, " to [").concat(String(x), ",").concat(String(y), "] from [").concat(l.x, ",").concat(l.y, "]"));
282
- var oldX = l.x;
283
- var oldY = l.y;
284
- var oldZ = l.z;
285
- // This is quite a bit faster than extending the object
286
- if (typeof x === "number")
287
- l.x = x;
288
- if (typeof y === "number")
289
- l.y = y;
290
- if (typeof z === "number")
291
- l.z = y;
292
- l.moved = true;
293
- // If this collides with anything, move it.
294
- // When doing this comparison, we have to sort the items we compare with
295
- // to ensure, in the case of multiple collisions, that we're getting the
296
- // nearest collision.
297
- var sorted = sortLayoutItems(layout, compactType);
298
- var movingUp = compactType === "vertical" && typeof y === "number"
299
- ? oldY >= y
300
- : compactType === "horizontal" && typeof x === "number"
301
- ? oldX >= x
302
- : false;
303
- // $FlowIgnore acceptable modification of read-only array as it was recently cloned
304
- if (movingUp)
305
- sorted = sorted.reverse();
306
- var collisions = getAllCollisions(sorted, l);
307
- var hasCollisions = collisions.length > 0;
308
- // We may have collisions. We can short-circuit if we've turned off collisions or
309
- // allowed overlap.
310
- if (hasCollisions && allowOverlap) {
311
- // Easy, we don't need to resolve collisions. But we can make sure the newly movedo item appears on top!
312
- var maxZ = Math.max.apply(Math, collisions.map(function (x) { var _a; return (_a = x.z) !== null && _a !== void 0 ? _a : Number.MIN_SAFE_INTEGER; }));
313
- l.z = overrideZ !== undefined ? overrideZ : maxZ + 1;
314
- return cloneLayout(layout);
315
- }
316
- else if (hasCollisions && preventCollision) {
317
- // If we are preventing collision but not allowing overlap, we need to
318
- // revert the position of this element so it goes to where it came from, rather
319
- // than the user's desired location.
320
- log("Collision prevented on ".concat(l.i, ", reverting."));
321
- l.x = oldX;
322
- l.y = oldY;
323
- l.z = oldZ;
324
- l.moved = false;
325
- return layout; // did not change so don't clone
326
- }
327
- // Move each item that collides away from this element.
328
- for (var i = 0, len = collisions.length; i < len; i++) {
329
- var collision = collisions[i];
330
- log("Resolving collision between ".concat(l.i, " at [").concat(l.x, ",").concat(l.y, "] and ").concat(collision.i, " at [").concat(collision.x, ",").concat(collision.y, "]"));
331
- // Short circuit so we can't infinite loop
332
- if (collision.moved)
333
- continue;
334
- // Don't move static items - we have to move *this* element away
335
- if (collision.static) {
336
- layout = moveElementAwayFromCollision({
337
- layout: layout,
338
- collidesWith: collision,
339
- itemToMove: l,
340
- isUserAction: isUserAction,
341
- compactType: compactType,
342
- cols: cols,
343
- });
344
- }
345
- else {
346
- layout = moveElementAwayFromCollision({
347
- layout: layout,
348
- collidesWith: l,
349
- itemToMove: collision,
350
- isUserAction: isUserAction,
351
- compactType: compactType,
352
- cols: cols,
353
- });
354
- }
355
- }
356
- return layout;
357
- }
358
- /**
359
- * This is where the magic needs to happen - given a collision, move an element away from the collision.
360
- * We attempt to move it up if there's room, otherwise it goes below.
361
- *
362
- * @param {Array} layout Full layout to modify.
363
- * @param {LayoutItem} collidesWith Layout item we're colliding with.
364
- * @param {LayoutItem} itemToMove Layout item we're moving.
365
- */
366
- export function moveElementAwayFromCollision(properties) {
367
- var collidesWith = properties.collidesWith, cols = properties.cols, compactType = properties.compactType, itemToMove = properties.itemToMove, layout = properties.layout;
368
- var isUserAction = properties.isUserAction;
369
- var compactH = compactType === "horizontal";
370
- var compactV = compactType !== "horizontal";
371
- var preventCollision = collidesWith.static; // we're already colliding (not for static items)
372
- if (isUserAction) {
373
- isUserAction = false;
374
- var fakeItem = {
375
- x: compactH ? Math.max(collidesWith.x - itemToMove.w, 0) : itemToMove.x,
376
- y: compactV ? Math.max(collidesWith.y - itemToMove.h, 0) : itemToMove.y,
377
- z: itemToMove.z,
378
- w: itemToMove.w,
379
- h: itemToMove.h,
380
- i: "-1",
381
- };
382
- if (!getFirstCollision(layout, fakeItem)) {
383
- log("Doing reverse collision on ".concat(itemToMove.i, " up to [").concat(fakeItem.x, ",").concat(fakeItem.y, "]."));
384
- return moveElement({
385
- layout: layout,
386
- l: itemToMove,
387
- x: compactH ? fakeItem.x : undefined,
388
- y: compactV ? fakeItem.y : undefined,
389
- isUserAction: isUserAction,
390
- preventCollision: preventCollision,
391
- compactType: compactType,
392
- cols: cols,
393
- });
394
- }
395
- }
396
- return moveElement({
397
- layout: layout,
398
- l: itemToMove,
399
- x: compactH ? itemToMove.x + 1 : undefined,
400
- y: compactV ? itemToMove.y + 1 : undefined,
401
- isUserAction: isUserAction,
402
- preventCollision: preventCollision,
403
- compactType: compactType,
404
- cols: cols,
405
- });
406
- }
407
- /**
408
- * Helper to convert a number to a percentage string.
409
- *
410
- * @param {Number} num Any number
411
- * @return {String} That number as a percentage.
412
- */
413
- export function perc(num) {
414
- return num * 100 + "%";
415
- }
416
- export function setTransform(_a) {
417
- var top = _a.top, left = _a.left, z = _a.z, width = _a.width, height = _a.height;
418
- var translate = "translate(".concat(left, "px,").concat(top, "px)");
419
- return {
420
- transform: translate,
421
- WebkitTransform: translate,
422
- MozTransform: translate,
423
- msTransform: translate,
424
- OTransform: translate,
425
- width: "".concat(width, "px"),
426
- height: "".concat(height, "px"),
427
- zIndex: z || 0,
428
- position: "absolute",
429
- };
430
- }
431
- export function setTopLeft(_a) {
432
- var top = _a.top, left = _a.left, z = _a.z, width = _a.width, height = _a.height;
433
- return {
434
- top: "".concat(top, "px"),
435
- left: "".concat(left, "px"),
436
- width: "".concat(width, "px"),
437
- height: "".concat(height, "px"),
438
- zIndex: z || 0,
439
- position: "absolute",
440
- };
441
- }
442
- /**
443
- * Get layout items sorted from top left to right and down.
444
- *
445
- * @return {Array} Array of layout objects.
446
- * @return {Array} Layout, sorted static items first.
447
- */
448
- export function sortLayoutItems(layout, compactType) {
449
- if (compactType === "horizontal")
450
- return sortLayoutItemsByColRow(layout);
451
- if (compactType === "vertical")
452
- return sortLayoutItemsByRowCol(layout);
453
- else
454
- return layout;
455
- }
456
- /**
457
- * Sort layout items by row ascending and column ascending.
458
- *
459
- * Does not modify Layout.
460
- */
461
- export function sortLayoutItemsByRowCol(layout) {
462
- return layout.slice(0).sort(function (a, b) {
463
- if (a.y > b.y || (a.y === b.y && a.x > b.x)) {
464
- return 1;
465
- }
466
- else if (a.y === b.y && a.x === b.x) {
467
- // Without this, we can get different sort results in IE vs. Chrome/FF
468
- return 0;
469
- }
470
- return -1;
471
- });
472
- }
473
- /**
474
- * Sort layout items by column ascending then row ascending.
475
- *
476
- * Does not modify Layout.
477
- */
478
- export function sortLayoutItemsByColRow(layout) {
479
- return layout.slice(0).sort(function (a, b) {
480
- if (a.x > b.x || (a.x === b.x && a.y > b.y)) {
481
- return 1;
482
- }
483
- return -1;
484
- });
485
- }
486
- /**
487
- * Generate a layout using the initialLayout and children as a template.
488
- * Missing entries will be added, extraneous ones will be truncated.
489
- *
490
- * Does not modify initialLayout.
491
- *
492
- * @param {Array} initialLayout Layout passed in through props.
493
- * @param {String} breakpoint Current responsive breakpoint.
494
- * @param {?String} compact Compaction option.
495
- * @return {Array} Working layout.
496
- */
497
- export function synchronizeLayoutWithChildren(initialLayout, children, cols, compactType, allowOverlap) {
498
- initialLayout = initialLayout || [];
499
- var layout = [];
500
- children &&
501
- React.Children.forEach(Array.isArray(children) ? children : [children], function (child) {
502
- if ((child === null || child === void 0 ? void 0 : child.key) == null)
503
- return;
504
- var exists = getLayoutItem(initialLayout, String(child.key));
505
- if (exists) {
506
- layout.push(cloneLayoutItem(exists));
507
- }
508
- else {
509
- if (!isProduction && child.props._grid) {
510
- console.warn("`_grid` properties on children have been deprecated as of React 15.2. " +
511
- "Please use `data-grid` or add your properties directly to the `layout`.");
512
- }
513
- var g = child.props["data-grid"] || child.props._grid;
514
- if (g) {
515
- if (!isProduction) {
516
- validateLayout([g], "GridLayout.children");
517
- }
518
- layout.push(cloneLayoutItem(__assign(__assign({}, g), { i: child.key })));
519
- }
520
- else {
521
- }
522
- }
523
- });
524
- var correctedLayout = correctBounds(layout, { cols: cols });
525
- return allowOverlap
526
- ? correctedLayout
527
- : compact(correctedLayout, compactType, cols);
528
- }
529
- /**
530
- * Validate a layout. Throws errors.
531
- *
532
- * @param {Array} layout Array of layout items.
533
- * @param {String} [contextName] Context name for errors.
534
- * @throw {Error} Validation error.
535
- */
536
- export function validateLayout(layout, contextName) {
537
- if (contextName === void 0) { contextName = "Layout"; }
538
- var subProps = ["x", "y", "w", "h"];
539
- if (!Array.isArray(layout)) {
540
- throw new Error(contextName + " must be an array!");
541
- }
542
- for (var i = 0, len = layout.length; i < len; i++) {
543
- var item = layout[i];
544
- for (var j = 0; j < subProps.length; j++) {
545
- if (typeof item[subProps[j]] !== "number") {
546
- throw new Error("GridLayout: " +
547
- contextName +
548
- "[" +
549
- i +
550
- "]." +
551
- subProps[j] +
552
- " must be a number!");
553
- }
554
- }
555
- }
556
- }
557
- function log() {
558
- var args = [];
559
- for (var _i = 0; _i < arguments.length; _i++) {
560
- args[_i] = arguments[_i];
561
- }
562
- if (!DEBUG)
563
- return;
564
- console.log.apply(console, args);
565
- }
566
- export var noop = function (_args) { return undefined; };
567
- export function getBoundingArea(layout, ids) {
568
- var layoutItems = ids.map(function (id) { return getLayoutItem(layout, id); }).filter(function (item) { return item !== undefined; });
569
- if (layoutItems.length === 0) {
570
- return null;
571
- }
572
- if (layoutItems.length === 1) {
573
- return {
574
- x: layoutItems[0].x,
575
- y: layoutItems[0].y,
576
- w: layoutItems[0].w,
577
- h: layoutItems[0].h,
578
- z: layoutItems[0].z,
579
- minZ: layoutItems[0].z,
580
- };
581
- }
582
- var _a = layoutItems.reduce(function (acc, elem, idx, arr) {
583
- var _a, _b, _c, _d;
584
- if (idx === arr.length - 1) {
585
- return acc;
586
- }
587
- var elem1 = idx === 0 ? elem : acc;
588
- var elem2 = arr[idx + 1];
589
- var minX = Math.min(elem1.x, elem2.x);
590
- var minY = Math.min(elem1.y, elem2.y);
591
- var elem1W = elem1.x - minX + elem1.w;
592
- var elem2W = elem2.x - minX + elem2.w;
593
- var elem1H = elem1.y - minY + elem1.h;
594
- var elem2H = elem2.y - minY + elem2.h;
595
- var maxZ = Math.max((_a = elem1 === null || elem1 === void 0 ? void 0 : elem1.z) !== null && _a !== void 0 ? _a : 0, (_b = elem2 === null || elem2 === void 0 ? void 0 : elem2.z) !== null && _b !== void 0 ? _b : 0);
596
- var minZ = Math.min((_c = elem1 === null || elem1 === void 0 ? void 0 : elem1.z) !== null && _c !== void 0 ? _c : 0, (_d = elem2 === null || elem2 === void 0 ? void 0 : elem2.z) !== null && _d !== void 0 ? _d : 0);
597
- return {
598
- x: Math.min(elem1.x, elem2.x),
599
- y: Math.min(elem1.y, elem2.y),
600
- w: Math.max(elem1W, elem2W),
601
- h: Math.max(elem1H, elem2H),
602
- z: maxZ,
603
- minZ: minZ,
604
- };
605
- }, { x: 0, y: 0, w: 0, h: 0, z: 0, minZ: 0 }), minX = _a.x, minY = _a.y, maxW = _a.w, maxH = _a.h, maxZ = _a.z, minZ = _a.minZ;
606
- return { x: minX, y: minY, w: maxW, h: maxH, z: maxZ, minZ: minZ };
607
- }
@@ -1,26 +0,0 @@
1
- import { Breakpoint, Breakpoints, CompactType, Layout, Layouts } from "../types";
2
- /**
3
- * Given a width, find the highest breakpoint that matches is valid for it (width > breakpoint).
4
- *
5
- * @param {Object} breakpoints Breakpoints object (e.g. {lg: 1200, md: 960, ...})
6
- * @param {Number} width Screen width.
7
- */
8
- export declare function getBreakpointFromWidth(breakpoints: Breakpoints<Breakpoint>, width: number): Breakpoint;
9
- /**
10
- * Given a breakpoint, get the # of cols set for it.
11
- */
12
- export declare function getColsFromBreakpoint(breakpoint: Breakpoint, cols: Breakpoints<Breakpoint>): number;
13
- /**
14
- * Given existing layouts and a new breakpoint, find or generate a new layout.
15
- *
16
- * This finds the layout above the new one and generates from it, if it exists.
17
- */
18
- export declare function findOrGenerateResponsiveLayout(layouts: Layouts, breakpoints: Breakpoints<Breakpoint>, breakpoint: Breakpoint, lastBreakpoint: Breakpoint, cols: number, compactType: CompactType, overlap: boolean): Layout;
19
- /**
20
- * Given breakpoints, return an array of breakpoints sorted by width. This is usually
21
- * e.g. ['xxs', 'xs', 'sm', ...]
22
- *
23
- * @param {Object} breakpoints Key/value pair of breakpoint names to widths.
24
- * @return {Array} Sorted breakpoints.
25
- */
26
- export declare function sortBreakpoints(breakpoints: Breakpoints<Breakpoint>): Array<Breakpoint>;