publ-echo-test 0.0.330 → 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 -385
  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,748 +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
- var __rest = (this && this.__rest) || function (s, e) {
13
- var t = {};
14
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
- t[p] = s[p];
16
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
- t[p[i]] = s[p[i]];
20
- }
21
- return t;
22
- };
23
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
24
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
25
- if (ar || !(i in from)) {
26
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
27
- ar[i] = from[i];
28
- }
29
- }
30
- return to.concat(ar || Array.prototype.slice.call(from));
31
- };
32
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
33
- import * as React from "react";
34
- import { useState, useRef, useLayoutEffect } from "react";
35
- import classNames from "../../external-lib/classnames";
36
- import { bottom, cloneLayoutItem, compact, getAllCollisions, getBoundingArea, getLayoutItem, moveElement, noop, synchronizeLayoutWithChildren, withLayoutItem, } from "./utils/renderHelpers";
37
- import { calcGridColWidth, calcXY, resolveRowHeight, } from "../GridItem/utils/calculateUtils";
38
- // NOTE: 필수 변경하기
39
- import GridItem from "../GridItem/GridItem";
40
- import isEqual from "../../external-lib/lodash.isEqual";
41
- import { findAllChildrenCbIds, findBlockByBlockId, findDirectChildrenBlockIds, findDirectChildrenCbIds, findGroupBlocks, findParentGroupBlock, formatCbIdToBlockId, getBlockSpecificType, zIndexMap, } from "./group";
42
- import GroupItem from "../GridItem/GroupItem";
43
- import OutsideClickHandler from "../GridItem/OutsideClickHandler";
44
- var layoutClassName = "react-grid-layout";
45
- var ReactGridLayout = function (_a) {
46
- var children = _a.children, props = __rest(_a, ["children"]);
47
- var sectionId = props.sectionId, _b = props.autoSize, autoSize = _b === void 0 ? true : _b, _c = props.cols, cols = _c === void 0 ? 12 : _c, _d = props.className, className = _d === void 0 ? "" : _d, _e = props.style, style = _e === void 0 ? {} : _e, _f = props.draggableHandle, draggableHandle = _f === void 0 ? "" : _f, _g = props.draggableCancel, draggableCancel = _g === void 0 ? "" : _g, _h = props.containerPadding, containerPadding = _h === void 0 ? undefined : _h, _j = props.rowHeight, rowHeight = _j === void 0 ? 150 : _j, _k = props.maxRows, maxRows = _k === void 0 ? Infinity : _k, _l = props.margin, margin = _l === void 0 ? [10, 10] : _l, _m = props.isBounded, isBounded = _m === void 0 ? false : _m, _o = props.isDraggable, isDraggable = _o === void 0 ? true : _o, _p = props.isResizable, isResizable = _p === void 0 ? true : _p, _q = props.allowOverlap, allowOverlap = _q === void 0 ? false : _q, _r = props.isDroppable, isDroppable = _r === void 0 ? false : _r, _s = props.useCSSTransforms, useCSSTransforms = _s === void 0 ? true : _s, _t = props.transformScale, transformScale = _t === void 0 ? 1 : _t, _u = props.compactType, compactType = _u === void 0 ? "vertical" : _u, _v = props.preventCollision, preventCollision = _v === void 0 ? false : _v, _w = props.droppingItem, droppingItem = _w === void 0 ? {
48
- i: "__dropping-elem__",
49
- h: 1,
50
- w: 1,
51
- } : _w, // TODO fix
52
- _x = props.resizeHandles, // TODO fix
53
- resizeHandles = _x === void 0 ? ["se"] : _x, _y = props.width, width = _y === void 0 ? 0 : _y, resizeHandle = props.resizeHandle, _z = props.isHiddenVisibility, isHiddenVisibility = _z === void 0 ? true : _z, innerRef = props.innerRef, minNbRow = props.minNbRow, customColWidth = props.customColWidth, blockStructure = props.blockStructure, onDoubleClickGroup = props.onDoubleClickGroup, _0 = props.editingGroupBlock, editingGroupBlock = _0 === void 0 ? "ROOT" : _0, _1 = props.selectedGroupBlock, selectedGroupBlock = _1 === void 0 ? "ROOT" : _1, onClickGroup = props.onClickGroup, bulkIds = props.bulkIds, onDoubleClickOutsideGroup = props.onDoubleClickOutsideGroup;
54
- var device = cols === 24 ? "DESKTOP" : "MOBILE";
55
- var _2 = useState(), activeDrag = _2[0], setActiveDrag = _2[1];
56
- var _3 = useState(), oldDragItem = _3[0], setOldDragItem = _3[1];
57
- var _4 = useState(), oldLayout = _4[0], setOldLayout = _4[1];
58
- var _5 = useState(), oldResizeItem = _5[0], setOldResizeItem = _5[1];
59
- var _6 = useState(), droppingDOMNode = _6[0], setDroppingDOMNode = _6[1];
60
- var _7 = useState(), droppingPosition = _7[0], setDroppingPosition = _7[1];
61
- var _8 = useState(false), isMounted = _8[0], setIsMounted = _8[1];
62
- var editorMode = props.isDraggable && props.isResizable ? "EDIT" : "VIEW";
63
- var editableBlockIds = blockStructure
64
- ? findDirectChildrenCbIds(blockStructure, editingGroupBlock)
65
- : [];
66
- var editingGroupAllChildren = blockStructure && editingGroupBlock
67
- ? findAllChildrenCbIds(blockStructure, editingGroupBlock).map(function (i) {
68
- return i.toString();
69
- })
70
- : [];
71
- var _9 = useState([]), oldGroupChildren = _9[0], setOldGroupChildren = _9[1];
72
- var _10 = useState(function () {
73
- return synchronizeLayoutWithChildren(props.layout || [], children, cols, compactType, allowOverlap);
74
- }), layout = _10[0], setLayout = _10[1];
75
- var dragEnterCounter = useRef(0);
76
- useLayoutEffect(function () {
77
- setIsMounted(true);
78
- onLayoutMaybeChanged(layout, layout);
79
- }, []);
80
- useLayoutEffect(function () {
81
- if (props.layout && !Array.isArray(props.layout)) {
82
- console.error("Expecting layout to be an Array but got: ", props.layout);
83
- }
84
- setLayout(synchronizeLayoutWithChildren(props.layout || [], children, cols, compactType, allowOverlap));
85
- }, [props.layout]);
86
- useLayoutEffect(function () {
87
- var newLayout = synchronizeLayoutWithChildren(props.layout || layout, children, props.cols || cols, props.compactType || "vertical", props.allowOverlap);
88
- setLayout(newLayout);
89
- }, [children]);
90
- var getPositionParams = function () {
91
- return {
92
- cols: cols,
93
- margin: margin,
94
- maxRows: maxRows,
95
- rowHeight: rowHeight,
96
- containerWidth: width,
97
- containerPadding: containerPadding || margin,
98
- };
99
- };
100
- var colWidth = customColWidth !== null && customColWidth !== void 0 ? customColWidth : calcGridColWidth(getPositionParams());
101
- /**
102
- * Calculates a pixel value for the container.
103
- * @return {String} Container height in pixels.
104
- */
105
- var containerHeight = function () {
106
- if (!autoSize)
107
- return;
108
- var nbRow = bottom(layout);
109
- var biggerNbRow = minNbRow ? Math.max(nbRow, minNbRow) : nbRow;
110
- var containerPaddingY = containerPadding
111
- ? containerPadding[1]
112
- : margin[1];
113
- return (biggerNbRow * resolveRowHeight(rowHeight, colWidth) +
114
- (biggerNbRow - 1) * margin[1] +
115
- containerPaddingY * 2 +
116
- "px");
117
- };
118
- var getBackgroundHeight = function () {
119
- if (!autoSize)
120
- return;
121
- var nbRow = bottom(layout);
122
- var biggerNbRow = minNbRow ? Math.max(nbRow, minNbRow) : nbRow;
123
- var containerPaddingY = containerPadding
124
- ? containerPadding[1]
125
- : margin[1];
126
- return (biggerNbRow * resolveRowHeight(rowHeight, colWidth) +
127
- (biggerNbRow - 1) * margin[1] +
128
- containerPaddingY * 2 -
129
- 2 * margin[1] +
130
- "px");
131
- };
132
- var getBackgroundWidth = function () {
133
- if (!autoSize)
134
- return;
135
- return width - margin[0] * 2 + "px";
136
- };
137
- /**
138
- * When dragging starts
139
- * @param {String} i Id of the child
140
- * @param {Number} x X position of the move
141
- * @param {Number} y Y position of the move
142
- * @param {Event} e The mousedown event
143
- * @param {Element} node The current dragging DOM element
144
- */
145
- var onDragStartHandler = function (i, x, y, _a, isGroup) {
146
- var _b;
147
- var e = _a.e, node = _a.node;
148
- var l = (_b = getLayoutItem(layout, i)) !== null && _b !== void 0 ? _b : { i: i, x: x, y: y, w: 1, h: 1 };
149
- if (!l)
150
- return;
151
- setOldDragItem(cloneLayoutItem(l));
152
- setOldLayout(layout);
153
- if (isGroup) {
154
- if (!blockStructure) {
155
- return;
156
- }
157
- var childrenIds = findAllChildrenCbIds(blockStructure, i).map(function (i) {
158
- return i.toString();
159
- });
160
- var children_1 = childrenIds.map(function (id) {
161
- var item = getLayoutItem(layout, id);
162
- return cloneLayoutItem(item);
163
- });
164
- setOldGroupChildren(children_1);
165
- }
166
- props.onDragStart &&
167
- props.onDragStart({
168
- layout: layout,
169
- prev: l,
170
- item: l,
171
- placeholder: undefined,
172
- e: e,
173
- node: node,
174
- });
175
- };
176
- var onDragStartHandlerGroup = function (i, x, y, _a, isGroup) {
177
- // const l = getLayoutItem(layout, i);
178
- var e = _a.e, node = _a.node;
179
- // if (!l) return;
180
- // setOldDragItem(cloneLayoutItem(l));
181
- setOldLayout(layout);
182
- if (isGroup) {
183
- if (!blockStructure) {
184
- return;
185
- }
186
- var children_2 = findDirectChildrenBlockIds(blockStructure, i).map(function (id) {
187
- var item = getLayoutItem(layout, id);
188
- return cloneLayoutItem(item);
189
- });
190
- setOldGroupChildren(children_2);
191
- }
192
- // props.onDragStart &&
193
- // props.onDragStart({
194
- // layout,
195
- // prev: l,
196
- // item: l,
197
- // placeholder: undefined,
198
- // e,
199
- // node,
200
- // });
201
- };
202
- /**
203
- * Each drag movement create a new dragelement and move the element to the dragged location
204
- * @param {String} i Id of the child
205
- * @param {Number} x X position of the move
206
- * @param {Number} y Y position of the move
207
- * @param {Event} e The mousedown event
208
- * @param {Element} node The current dragging DOM element
209
- */
210
- var onDragHandler = function (i, x, y, _a, isGroup) {
211
- var _b;
212
- var e = _a.e, node = _a.node;
213
- var l = (_b = getLayoutItem(layout, i)) !== null && _b !== void 0 ? _b : { i: i, x: x, y: y, w: 10, h: 10 };
214
- if (!l)
215
- return;
216
- if (!oldDragItem) {
217
- return;
218
- }
219
- var xgap = x - oldDragItem.x;
220
- var ygap = y - oldDragItem.y;
221
- var placeholder = {
222
- w: l.w,
223
- h: l.h,
224
- x: l.x,
225
- y: l.y,
226
- z: l.z,
227
- placeholder: true,
228
- i: i,
229
- };
230
- var isUserAction = true;
231
- var newLayout = isGroup
232
- ? layout
233
- : moveElement({
234
- layout: layout,
235
- l: l,
236
- x: x,
237
- y: y,
238
- isUserAction: isUserAction,
239
- preventCollision: preventCollision,
240
- compactType: compactType,
241
- cols: cols,
242
- allowOverlap: allowOverlap,
243
- });
244
- if (isGroup) {
245
- oldGroupChildren.forEach(function (item) {
246
- var layoutItem = getLayoutItem(layout, item.i);
247
- newLayout = moveElement({
248
- layout: layout,
249
- l: layoutItem,
250
- x: item.x + xgap,
251
- y: item.y + ygap,
252
- isUserAction: isUserAction,
253
- preventCollision: preventCollision,
254
- compactType: compactType,
255
- cols: cols,
256
- allowOverlap: allowOverlap,
257
- });
258
- });
259
- }
260
- props.onDrag &&
261
- props.onDrag({
262
- layout: newLayout,
263
- prev: oldDragItem,
264
- item: l,
265
- placeholder: placeholder,
266
- e: e,
267
- node: node,
268
- });
269
- setLayout(allowOverlap ? newLayout : compact(newLayout, compactType, cols));
270
- setActiveDrag(placeholder);
271
- };
272
- /**
273
- * When dragging stops, figure out which position the element is closest to and update its x and y.
274
- * @param {String} i Index of the child.
275
- * @param {Number} x X position of the move
276
- * @param {Number} y Y position of the move
277
- * @param {Event} e The mousedown event
278
- * @param {Element} node The current dragging DOM element
279
- */
280
- var onDragStopHandler = function (i, x, y, _a) {
281
- var _b;
282
- var e = _a.e, node = _a.node;
283
- if (!activeDrag || !oldDragItem) {
284
- return;
285
- }
286
- var l = (_b = getLayoutItem(layout, i)) !== null && _b !== void 0 ? _b : { i: i, x: x, y: y, w: 10, h: 10 };
287
- if (!l)
288
- return;
289
- // NOTE: z-index 원래대로 복귀
290
- l.z = oldDragItem.z;
291
- var isUserAction = true;
292
- var movedLayout = moveElement({
293
- layout: layout,
294
- l: l,
295
- x: x,
296
- y: y,
297
- isUserAction: isUserAction,
298
- preventCollision: preventCollision,
299
- compactType: compactType,
300
- cols: cols,
301
- allowOverlap: allowOverlap,
302
- overrideZ: oldDragItem.z,
303
- });
304
- props.onDragStop &&
305
- props.onDragStop({
306
- layout: movedLayout,
307
- prev: oldDragItem,
308
- item: l,
309
- placeholder: undefined,
310
- e: e,
311
- node: node,
312
- });
313
- var newLayout = allowOverlap
314
- ? movedLayout
315
- : compact(movedLayout, compactType, cols);
316
- setActiveDrag(undefined);
317
- setLayout(newLayout);
318
- setOldDragItem(undefined);
319
- setOldLayout(undefined);
320
- setOldGroupChildren([]);
321
- props.onLayoutChange && props.onLayoutChange(newLayout);
322
- };
323
- var onDragStopGroupHandler = function (i, x, y, _a) {
324
- var _b;
325
- var e = _a.e, node = _a.node;
326
- if (!activeDrag || !oldDragItem) {
327
- return;
328
- }
329
- var l = (_b = getLayoutItem(layout, i)) !== null && _b !== void 0 ? _b : { i: i, x: x, y: y, w: 10, h: 10 };
330
- if (!l)
331
- return;
332
- // NOTE: z-index 원래대로 복귀
333
- l.z = oldDragItem.z;
334
- var isUserAction = true;
335
- var movedLayout = moveElement({
336
- layout: layout,
337
- l: l,
338
- x: x,
339
- y: y,
340
- isUserAction: isUserAction,
341
- preventCollision: preventCollision,
342
- compactType: compactType,
343
- cols: cols,
344
- allowOverlap: allowOverlap,
345
- overrideZ: oldDragItem.z,
346
- });
347
- var updatedItems = oldGroupChildren.map(function (item) {
348
- var layoutItem = getLayoutItem(layout, item.i);
349
- return {
350
- id: layoutItem.i,
351
- x: layoutItem.x,
352
- y: layoutItem.y,
353
- };
354
- });
355
- props.onDragStopForGroup &&
356
- props.onDragStopForGroup({
357
- layout: movedLayout,
358
- prev: oldDragItem,
359
- item: l,
360
- placeholder: undefined,
361
- e: e,
362
- node: node,
363
- updatedItems: updatedItems,
364
- });
365
- var newLayout = allowOverlap
366
- ? movedLayout
367
- : compact(movedLayout, compactType, cols);
368
- setActiveDrag(undefined);
369
- setLayout(newLayout);
370
- setOldDragItem(undefined);
371
- setOldLayout(undefined);
372
- setOldGroupChildren([]);
373
- props.onLayoutChange && props.onLayoutChange(newLayout);
374
- };
375
- var onLayoutMaybeChanged = function (newLayout, oldLayout) {
376
- if (!oldLayout) {
377
- oldLayout = layout;
378
- }
379
- if (!isEqual(oldLayout, newLayout)) {
380
- props.onLayoutChange && props.onLayoutChange(newLayout);
381
- }
382
- };
383
- var onResizeStartHandler = function (i, x, y, _a) {
384
- var e = _a.e, node = _a.node;
385
- var l = getLayoutItem(layout, i);
386
- if (!l)
387
- return;
388
- setOldResizeItem(cloneLayoutItem(l));
389
- setOldLayout(layout);
390
- props.onResizeStart &&
391
- props.onResizeStart({
392
- layout: layout,
393
- prev: l,
394
- item: l,
395
- e: e,
396
- node: node,
397
- });
398
- };
399
- var onResizeHandler = function (i, w, h, _a, x, y) {
400
- var e = _a.e, node = _a.node;
401
- var _b = withLayoutItem(layout, i, function (l) {
402
- var hasCollisions;
403
- if (preventCollision && !allowOverlap) {
404
- var collisions = getAllCollisions(layout, __assign(__assign({}, l), { w: x, h: y })).filter(function (layoutItem) { return layoutItem.i !== l.i; });
405
- hasCollisions = collisions.length > 0;
406
- if (hasCollisions) {
407
- var leastX_1 = Infinity, leastY_1 = Infinity;
408
- collisions.forEach(function (layoutItem) {
409
- if (layoutItem.x > l.x)
410
- leastX_1 = Math.min(leastX_1, layoutItem.x);
411
- if (layoutItem.y > l.y)
412
- leastY_1 = Math.min(leastY_1, layoutItem.y);
413
- });
414
- if (Number.isFinite(leastX_1))
415
- l.w = leastX_1 - l.x;
416
- if (Number.isFinite(leastY_1))
417
- l.h = leastY_1 - l.y;
418
- }
419
- }
420
- if (!hasCollisions) {
421
- // NOTE - 여기서 x, y를 추가적으로 세팅해줘야 nw, w, n, sw 방향에서 placeholder가 반대로 resize되지 않고 해당 element와 똑같이 resize
422
- l.w = w;
423
- l.h = h;
424
- l.x = x;
425
- l.y = y;
426
- }
427
- return l;
428
- }), newLayout = _b[0], l = _b[1];
429
- if (!l)
430
- return;
431
- var placeholder = {
432
- w: l.w,
433
- h: l.h,
434
- x: l.x,
435
- y: l.y,
436
- z: l.z,
437
- static: true,
438
- i: i,
439
- };
440
- props.onResize &&
441
- props.onResize({
442
- layout: newLayout,
443
- prev: oldResizeItem,
444
- item: l,
445
- placeholder: placeholder,
446
- e: e,
447
- node: node,
448
- });
449
- setLayout(allowOverlap ? newLayout : compact(newLayout, compactType, cols));
450
- setActiveDrag(placeholder);
451
- };
452
- var onResizeStopHandler = function (i, x, y, _a) {
453
- var e = _a.e, node = _a.node;
454
- var l = getLayoutItem(layout, i);
455
- props.onResizeStop &&
456
- props.onResizeStop({ layout: layout, prev: oldResizeItem, item: l, e: e, node: node });
457
- var newLayout = allowOverlap
458
- ? layout
459
- : compact(layout, compactType, cols);
460
- setActiveDrag(undefined);
461
- setLayout(newLayout);
462
- setOldResizeItem(undefined);
463
- setOldLayout(undefined);
464
- onLayoutMaybeChanged(newLayout, oldLayout);
465
- };
466
- var onFitToContentHandler = function (i, w, h, x, y, _a) {
467
- var hasPaddingChanged = _a.hasPaddingChanged;
468
- var _b = withLayoutItem(layout, i, function (l) {
469
- var hasCollisions;
470
- if (preventCollision && !allowOverlap) {
471
- var collisions = getAllCollisions(layout, __assign(__assign({}, l), { w: x, h: y })).filter(function (layoutItem) { return layoutItem.i !== l.i; });
472
- hasCollisions = collisions.length > 0;
473
- if (hasCollisions) {
474
- var leastX_2 = Infinity, leastY_2 = Infinity;
475
- collisions.forEach(function (layoutItem) {
476
- if (layoutItem.x > l.x)
477
- leastX_2 = Math.min(leastX_2, layoutItem.x);
478
- if (layoutItem.y > l.y)
479
- leastY_2 = Math.min(leastY_2, layoutItem.y);
480
- });
481
- if (Number.isFinite(leastX_2))
482
- l.w = leastX_2 - l.x;
483
- if (Number.isFinite(leastY_2))
484
- l.h = leastY_2 - l.y;
485
- }
486
- }
487
- if (!hasCollisions) {
488
- // NOTE - 여기서 x, y를 추가적으로 세팅해줘야 nw, w, n, sw 방향에서 placeholder가 반대로 resize되지 않고 해당 element와 똑같이 resize
489
- l.w = w;
490
- l.h = h;
491
- l.x = x;
492
- l.y = y;
493
- l.minH = h;
494
- }
495
- return l;
496
- }), newLayout = _b[0], l = _b[1];
497
- if (!l)
498
- return;
499
- props.onFitToContent &&
500
- props.onFitToContent({
501
- layout: newLayout,
502
- prev: oldResizeItem,
503
- item: l,
504
- hasPaddingChanged: hasPaddingChanged,
505
- });
506
- setLayout(allowOverlap ? newLayout : compact(newLayout, compactType, cols));
507
- };
508
- /**
509
- * Create a placeholder object.
510
- * @return {Element} Placeholder div.
511
- */
512
- var placeholder = function () {
513
- if (!activeDrag)
514
- return;
515
- // {...activeDrag} is pretty slow, actually
516
- var l = getLayoutItem(props.layout, String(activeDrag.i));
517
- if (!l) {
518
- return null;
519
- }
520
- // NOTE: toChildren changes key
521
- // LINK: https://legacy.reactjs.org/docs/react-api.html
522
- var items = React.Children.toArray(children);
523
- var item = items.find(function (child) {
524
- var originalKey = String(child.key).split(".$");
525
- return originalKey[1] === l.i;
526
- });
527
- var isInBulk = blockStructure &&
528
- (bulkIds === null || bulkIds === void 0 ? void 0 : bulkIds.includes(formatCbIdToBlockId(Number(activeDrag.i))));
529
- if (!item) {
530
- return null;
531
- }
532
- return (_jsx(GridItem, { w: activeDrag.w, h: activeDrag.h, x: activeDrag.x, y: activeDrag.y, z: zIndexMap.ISDRAGGING, i: activeDrag.i, className: "placeholder", containerWidth: width, cols: cols, margin: margin, containerPadding: containerPadding || margin, maxRows: maxRows, rowHeight: rowHeight, isDraggable: false, isResizable: false, isBounded: false, useCSSTransforms: useCSSTransforms, transformScale: transformScale, autoResize: !!l.autoResize, minH: l.minH, minW: l.minW, children: item && item }));
533
- };
534
- /**
535
- * Given a grid item, set its style attributes & surround in a <Draggable>.
536
- * @param {Element} child React element.
537
- * @return {Element} Element wrapped in draggable and properly placed.
538
- */
539
- var processGridItem = function (child, isDroppingItem) {
540
- var _a;
541
- if (!child || !child.key)
542
- return;
543
- var l = getLayoutItem(layout, String(child.key));
544
- if (!l) {
545
- return;
546
- }
547
- var draggable = typeof l.isDraggable === "boolean"
548
- ? l.isDraggable
549
- : !l.static && isDraggable;
550
- var resizable = typeof l.isResizable === "boolean"
551
- ? l.isResizable
552
- : !l.static && isResizable;
553
- var resizeHandlesOptions = l.resizeHandles || resizeHandles;
554
- var bounded = draggable && isBounded && l.isBounded !== false;
555
- var editable = editableBlockIds.includes(Number(l.i));
556
- var z = l.z || 0;
557
- var isInBulk = blockStructure && (bulkIds === null || bulkIds === void 0 ? void 0 : bulkIds.includes(formatCbIdToBlockId(Number(l.i))));
558
- var isRoot = editingGroupBlock === "ROOT";
559
- var block = blockStructure
560
- ? findBlockByBlockId(blockStructure, formatCbIdToBlockId(Number(l.i)))
561
- : undefined;
562
- var parent = blockStructure
563
- ? findParentGroupBlock(blockStructure, formatCbIdToBlockId(Number(l.i)))
564
- : null;
565
- if (!block) {
566
- return _jsx(_Fragment, { children: "NO-BLOCK-FOUND" });
567
- }
568
- var zOrder = (_a = block[device === "DESKTOP" ? "zOrderDesktopInternal" : "zOrderMobileInternal"]) !== null && _a !== void 0 ? _a : 0;
569
- var isInsideOfEditingGroup = editingGroupAllChildren.includes(l.i);
570
- var editorZIndex = (function () {
571
- if (isRoot && isInBulk) {
572
- return z;
573
- }
574
- if (!isRoot && isInsideOfEditingGroup) {
575
- return zIndexMap.CB_IN_EDITING_GROUP + z;
576
- }
577
- if (isRoot && editable) {
578
- return zIndexMap.ROOT + z;
579
- }
580
- if (isRoot && !editable) {
581
- return zIndexMap.ROOT + z;
582
- }
583
- if (!editable) {
584
- return z;
585
- }
586
- return z;
587
- })();
588
- var zIndex = editorMode === "EDIT" ? editorZIndex : z;
589
- return (_jsx(GridItem, { className: classNames({
590
- "editable-grid-item": !isRoot && editable,
591
- "not-editable-grid-item": !isRoot && !editable,
592
- "bulk-child-item": isInBulk,
593
- "outside-of-editing-group": !isInsideOfEditingGroup,
594
- }), z: zIndex, zOrder: l.z, zOrderInternal: parent
595
- ? "".concat(parent[device === "DESKTOP"
596
- ? "zOrderDesktopInternal"
597
- : "zOrderMobileInternal"], " > ").concat(zOrder)
598
- : zOrder.toString(), isDraggable: editable && !isInBulk, isResizable: editable && !isInBulk, containerWidth: width, cols: cols, margin: margin, containerPadding: containerPadding || margin, maxRows: maxRows, rowHeight: rowHeight, cancel: draggableCancel, handle: draggableHandle, onDragStop: onDragStopHandler, onDragStart: onDragStartHandler, onDrag: onDragHandler, onResizeStart: onResizeStartHandler, onResize: onResizeHandler, onResizeStop: onResizeStopHandler, onFitToContent: onFitToContentHandler, isBounded: bounded, useCSSTransforms: useCSSTransforms && isMounted, usePercentages: !isMounted, transformScale: transformScale, w: l.w, h: l.h, x: l.x, y: l.y, i: l.i, minH: l.minH, minW: l.minW, maxH: l.maxH, maxW: l.maxW, static: l.static, droppingPosition: isDroppingItem ? droppingPosition : undefined, resizeHandles: resizeHandlesOptions, resizeHandle: resizeHandle, isHiddenVisibility: isHiddenVisibility, customColWidth: colWidth, autoResize: !!l.autoResize, children: child }, l.i));
599
- };
600
- var onDragOverHandler = function (e) {
601
- var _a;
602
- e.preventDefault();
603
- e.stopPropagation();
604
- var onDragOverResult = (_a = props.onDropDragOver) === null || _a === void 0 ? void 0 : _a.call(props, e); // TODO fix
605
- if (onDragOverResult === false) {
606
- if (droppingDOMNode) {
607
- removeDroppingPlaceholder();
608
- }
609
- return false;
610
- }
611
- var finalDroppingItem = __assign(__assign({}, droppingItem), onDragOverResult);
612
- var _b = e.nativeEvent, layerX = _b.layerX, layerY = _b.layerY; // TODO fix
613
- var droppingPosition = {
614
- left: layerX / transformScale,
615
- top: layerY / transformScale,
616
- e: e,
617
- };
618
- if (!droppingDOMNode) {
619
- var calculatedPosition = calcXY(getPositionParams(), layerY, layerX, finalDroppingItem.w, finalDroppingItem.h);
620
- setDroppingDOMNode(_jsx("div", {}, finalDroppingItem.i));
621
- setDroppingPosition(droppingPosition);
622
- setLayout(__spreadArray(__spreadArray([], layout, true), [
623
- __assign(__assign({}, finalDroppingItem), { x: calculatedPosition.x, y: calculatedPosition.y, static: false, isDraggable: true }),
624
- ], false));
625
- }
626
- else if (droppingPosition) {
627
- var left = droppingPosition.left, top_1 = droppingPosition.top;
628
- var shouldUpdatePosition = left != layerX || top_1 != layerY;
629
- if (shouldUpdatePosition) {
630
- setDroppingPosition(droppingPosition);
631
- }
632
- }
633
- };
634
- var removeDroppingPlaceholder = function () {
635
- var newLayout = compact(layout.filter(function (l) { return l.i !== droppingItem.i; }), compactType, cols, allowOverlap);
636
- setLayout(newLayout);
637
- setDroppingDOMNode(undefined);
638
- setActiveDrag(undefined);
639
- setDroppingPosition(undefined);
640
- };
641
- var onDragLeaveHandler = function (e) {
642
- e.preventDefault();
643
- e.stopPropagation();
644
- dragEnterCounter.current = dragEnterCounter.current - 1;
645
- if (dragEnterCounter.current === 0) {
646
- removeDroppingPlaceholder();
647
- }
648
- };
649
- var onDragEnterHandler = function (e) {
650
- e.preventDefault();
651
- e.stopPropagation();
652
- dragEnterCounter.current += 1;
653
- };
654
- var onDropHandler = function (e) {
655
- e.preventDefault();
656
- e.stopPropagation();
657
- var item = layout.find(function (l) { return l.i === droppingItem.i; });
658
- dragEnterCounter.current = 0;
659
- removeDroppingPlaceholder();
660
- if (item) {
661
- props.onDrop && props.onDrop(layout, item, e);
662
- }
663
- };
664
- var mergedClassName = classNames(layoutClassName, className);
665
- var mergedStyle = __assign({ height: containerHeight() }, style);
666
- var processGroup = function (block, viewOnly) {
667
- var _a;
668
- if (!blockStructure) {
669
- return;
670
- }
671
- var childrenIds = findAllChildrenCbIds(blockStructure, block.blockId).map(function (i) { return i.toString(); });
672
- var groupItem = getBoundingArea(layout, childrenIds);
673
- if (!groupItem) {
674
- return _jsx(_Fragment, {});
675
- }
676
- var internalZOrder = (_a = block[device === "DESKTOP" ? "zOrderDesktopInternal" : "zOrderMobileInternal"]) !== null && _a !== void 0 ? _a : 0;
677
- var isEditingGroup = block.blockId === editingGroupBlock;
678
- var type = getBlockSpecificType(block);
679
- var isRoot = editingGroupBlock === "ROOT";
680
- var isInBulk = bulkIds === null || bulkIds === void 0 ? void 0 : bulkIds.includes(block.blockId);
681
- var isBulk = block.blockId === "BULK";
682
- var baseZ = (function () {
683
- if (isBulk) {
684
- // groupItem.z : 그룹 내 CB중 가장 큰 zorder
685
- return zIndexMap.BULK + groupItem.z;
686
- }
687
- if (isInBulk) {
688
- if (!isRoot) {
689
- return zIndexMap.EDITABLE_GROUP + internalZOrder;
690
- }
691
- return zIndexMap.CB_IN_EDITING_GROUP + internalZOrder;
692
- }
693
- if (isEditingGroup) {
694
- return zIndexMap.EDITING_GROUP;
695
- }
696
- if (!isRoot && type === "GROUP_BLOCK") {
697
- return zIndexMap.EDITABLE_GROUP + internalZOrder;
698
- }
699
- if (type === "GROUP_BLOCK") {
700
- return zIndexMap.GROUP;
701
- }
702
- return -1; // NOTE: ERROR
703
- })();
704
- var zIndex = editorMode === "EDIT" ? baseZ : internalZOrder;
705
- var handleClick = function (e) {
706
- onClickGroup && onClickGroup(e, block.blockId, type);
707
- };
708
- var handleDoubleClick = function (e) {
709
- onDoubleClickGroup && onDoubleClickGroup(e, block.blockId, type);
710
- };
711
- var handleClickContextGroup = function (e) {
712
- (props === null || props === void 0 ? void 0 : props.onContextGroup) &&
713
- props.onContextGroup(e, block.blockId, isEditingGroup);
714
- };
715
- var parent = blockStructure
716
- ? findParentGroupBlock(blockStructure, block.blockId)
717
- : null;
718
- return (_jsx(OutsideClickHandler, { onOutsideClick: onDoubleClickOutsideGroup, children: _jsx(GroupItem, { className: classNames({
719
- "bulk-child-item": isInBulk,
720
- "grid-bulk-block": block.blockId === "BULK",
721
- editing: editingGroupBlock === block.blockId,
722
- selected: selectedGroupBlock === block.blockId,
723
- }), z: zIndex, minZ: groupItem.minZ, zOrder: internalZOrder, zOrderInternal: parent
724
- ? "".concat(parent[device === "DESKTOP"
725
- ? "zOrderDesktopInternal"
726
- : "zOrderMobileInternal"], " > ").concat(internalZOrder)
727
- : internalZOrder.toString(), containerWidth: width, cols: cols, margin: margin, containerPadding: containerPadding || margin, maxRows: maxRows, rowHeight: rowHeight, cancel: draggableCancel, handle: draggableHandle, onDragStop: onDragStopGroupHandler, onDragStart: onDragStartHandler, onDrag: onDragHandler, onResizeStart: onResizeStartHandler, onResize: onResizeHandler, onResizeStop: onResizeStopHandler, onFitToContent: onFitToContentHandler, isDraggable: !viewOnly && !isEditingGroup && !isInBulk, isResizable: !viewOnly && !isEditingGroup && !isInBulk, isBounded: false, useCSSTransforms: useCSSTransforms && isMounted, usePercentages: !isMounted, transformScale: transformScale, w: groupItem.w, h: groupItem.h, x: groupItem.x, y: groupItem.y, i: block.blockId,
728
- // minH={l.minH}
729
- // minW={l.minW}
730
- // maxH={l.maxH}
731
- // maxW={l.maxW}
732
- // static={l.static}
733
- // droppingPosition={isDroppingItem ? droppingPosition : undefined}
734
- // resizeHandles={resizeHandlesOptions}
735
- // resizeHandle={resizeHandle}
736
- isHiddenVisibility: isHiddenVisibility, customColWidth: colWidth, autoResize: false, onContextGroup: handleClickContextGroup, children: _jsx("div", { onClick: handleClick, onDoubleClick: handleDoubleClick }) }, block.blockId) }));
737
- };
738
- var currentGroupBlocks = blockStructure
739
- ? findGroupBlocks(blockStructure, editingGroupBlock)
740
- : [];
741
- return (_jsxs("div", { ref: innerRef, className: mergedClassName, style: mergedStyle, onDrop: isDroppable ? onDropHandler : noop, onDragLeave: isDroppable ? onDragLeaveHandler : noop, onDragEnter: isDroppable ? onDragEnterHandler : noop, onDragOver: isDroppable ? onDragOverHandler : noop, "data-grid-row-height": rowHeight, "data-grid-cols": cols, "data-section-id": sectionId, children: [currentGroupBlocks.map(function (each) { return processGroup(each); }), React.Children.map(children, function (child) { return processGridItem(child); }), placeholder(), activeDrag && _jsx("div", { className: "grid-guide-line-center" }), activeDrag && (_jsx("div", { className: "grid-placeholder", style: {
742
- marginTop: margin[1] + "px",
743
- marginBottom: margin[1] + "px",
744
- marginLeft: margin[0] + "px",
745
- marginRight: margin[0] + "px",
746
- }, children: _jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: getBackgroundWidth(), height: getBackgroundHeight(), children: [_jsx("defs", { children: _jsx("pattern", { id: "grid-pattern", height: rowHeight + margin[1], width: colWidth + margin[0], patternUnits: "userSpaceOnUse", children: _jsx("rect", { x: 0.5, y: 0.5, className: "grid-pattern-rect", height: rowHeight, width: colWidth }) }) }), _jsx("rect", { width: width, height: "100%", fill: "url(#grid-pattern)" })] }) }))] }));
747
- };
748
- export default ReactGridLayout;