publ-echo 0.0.103 → 0.0.105
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.
- package/dist/lib/Draggable/DraggableCore.js +3 -2
- package/dist/lib/GridItem/GridItem.d.ts +3 -3
- package/dist/lib/GridItem/GridItem.js +36 -25
- package/dist/lib/GridItem/GroupItem.d.ts +10 -0
- package/dist/lib/GridItem/GroupItem.js +473 -0
- package/dist/lib/GridItem/OutsideClickHandler.d.ts +7 -0
- package/dist/lib/GridItem/OutsideClickHandler.js +112 -0
- package/dist/lib/GridItem/types.d.ts +7 -5
- package/dist/lib/GridLayoutEditor/ReactGridLayout.d.ts +4 -4
- package/dist/lib/GridLayoutEditor/ReactGridLayout.js +312 -61
- package/dist/lib/GridLayoutEditor/ResponsiveGridLayout.js +2 -2
- package/dist/lib/GridLayoutEditor/group.d.ts +57 -0
- package/dist/lib/GridLayoutEditor/group.js +340 -0
- package/dist/lib/GridLayoutEditor/types.d.ts +32 -6
- package/dist/lib/GridLayoutEditor/utils/renderHelpers.d.ts +8 -0
- package/dist/lib/GridLayoutEditor/utils/renderHelpers.js +41 -0
- package/dist/lib/Resizable/Resizable.js +2 -3
- package/dist/lib/utils/classNames.d.ts +3 -0
- package/dist/lib/utils/classNames.js +10 -0
- package/package.json +1 -1
|
@@ -29,34 +29,48 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
29
29
|
}
|
|
30
30
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
31
31
|
};
|
|
32
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
33
|
-
import * as React from
|
|
34
|
-
import { useState, useRef, useLayoutEffect } from
|
|
35
|
-
import classNames from
|
|
36
|
-
import { bottom, cloneLayoutItem, compact, getAllCollisions, getLayoutItem, moveElement, noop, synchronizeLayoutWithChildren, withLayoutItem, } from
|
|
37
|
-
import { calcGridColWidth, calcXY, resolveRowHeight, } from
|
|
38
|
-
import GridItem from
|
|
39
|
-
import isEqual from
|
|
40
|
-
|
|
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
|
+
import GridItem from '../GridItem/GridItem';
|
|
39
|
+
import isEqual from '../../external-lib/lodash.isEqual';
|
|
40
|
+
import { findAllChildrenCbIds, findBlockByBlockId, findDirectChildrenBlockIds, findDirectChildrenCbIds, findGroupBlocks, findParentGroupBlock, formatCbIdToBlockId, getBlockSpecificType, zIndexMap, } from './group';
|
|
41
|
+
import GroupItem from '../GridItem/GroupItem';
|
|
42
|
+
import OutsideClickHandler from '../GridItem/OutsideClickHandler';
|
|
43
|
+
var layoutClassName = 'react-grid-layout';
|
|
41
44
|
var ReactGridLayout = function (_a) {
|
|
42
45
|
var children = _a.children, props = __rest(_a, ["children"]);
|
|
43
|
-
var _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 ?
|
|
44
|
-
i:
|
|
46
|
+
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 ? {
|
|
47
|
+
i: '__dropping-elem__',
|
|
45
48
|
h: 1,
|
|
46
49
|
w: 1,
|
|
47
50
|
} : _w, // TODO fix
|
|
48
51
|
_x = props.resizeHandles, // TODO fix
|
|
49
|
-
resizeHandles = _x === void 0 ? [
|
|
50
|
-
var
|
|
51
|
-
var
|
|
52
|
-
var
|
|
53
|
-
var
|
|
54
|
-
var
|
|
55
|
-
var
|
|
56
|
-
var
|
|
57
|
-
var
|
|
52
|
+
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;
|
|
53
|
+
var device = cols === 24 ? 'DESKTOP' : 'MOBILE';
|
|
54
|
+
var _2 = useState(), activeDrag = _2[0], setActiveDrag = _2[1];
|
|
55
|
+
var _3 = useState(), oldDragItem = _3[0], setOldDragItem = _3[1];
|
|
56
|
+
var _4 = useState(), oldLayout = _4[0], setOldLayout = _4[1];
|
|
57
|
+
var _5 = useState(), oldResizeItem = _5[0], setOldResizeItem = _5[1];
|
|
58
|
+
var _6 = useState(), droppingDOMNode = _6[0], setDroppingDOMNode = _6[1];
|
|
59
|
+
var _7 = useState(), droppingPosition = _7[0], setDroppingPosition = _7[1];
|
|
60
|
+
var _8 = useState(false), isMounted = _8[0], setIsMounted = _8[1];
|
|
61
|
+
var editorMode = props.isDraggable && props.isResizable ? 'EDIT' : 'VIEW';
|
|
62
|
+
var editableBlockIds = blockStructure
|
|
63
|
+
? findDirectChildrenCbIds(blockStructure, editingGroupBlock)
|
|
64
|
+
: [];
|
|
65
|
+
var editingGroupAllChildren = blockStructure && editingGroupBlock
|
|
66
|
+
? findAllChildrenCbIds(blockStructure, editingGroupBlock).map(function (i) {
|
|
67
|
+
return i.toString();
|
|
68
|
+
})
|
|
69
|
+
: [];
|
|
70
|
+
var _9 = useState([]), oldGroupChildren = _9[0], setOldGroupChildren = _9[1];
|
|
71
|
+
var _10 = useState(function () {
|
|
58
72
|
return synchronizeLayoutWithChildren(props.layout || [], children, cols, compactType, allowOverlap);
|
|
59
|
-
}), layout =
|
|
73
|
+
}), layout = _10[0], setLayout = _10[1];
|
|
60
74
|
var dragEnterCounter = useRef(0);
|
|
61
75
|
useLayoutEffect(function () {
|
|
62
76
|
setIsMounted(true);
|
|
@@ -64,12 +78,12 @@ var ReactGridLayout = function (_a) {
|
|
|
64
78
|
}, []);
|
|
65
79
|
useLayoutEffect(function () {
|
|
66
80
|
if (props.layout && !Array.isArray(props.layout)) {
|
|
67
|
-
console.error(
|
|
81
|
+
console.error('Expecting layout to be an Array but got: ', props.layout);
|
|
68
82
|
}
|
|
69
83
|
setLayout(synchronizeLayoutWithChildren(props.layout || [], children, cols, compactType, allowOverlap));
|
|
70
84
|
}, [props.layout]);
|
|
71
85
|
useLayoutEffect(function () {
|
|
72
|
-
var newLayout = synchronizeLayoutWithChildren(props.layout || layout, children, props.cols || cols, props.compactType ||
|
|
86
|
+
var newLayout = synchronizeLayoutWithChildren(props.layout || layout, children, props.cols || cols, props.compactType || 'vertical', props.allowOverlap);
|
|
73
87
|
setLayout(newLayout);
|
|
74
88
|
}, [children]);
|
|
75
89
|
var getPositionParams = function () {
|
|
@@ -95,11 +109,10 @@ var ReactGridLayout = function (_a) {
|
|
|
95
109
|
var containerPaddingY = containerPadding
|
|
96
110
|
? containerPadding[1]
|
|
97
111
|
: margin[1];
|
|
98
|
-
return (biggerNbRow *
|
|
99
|
-
resolveRowHeight(rowHeight, colWidth) +
|
|
112
|
+
return (biggerNbRow * resolveRowHeight(rowHeight, colWidth) +
|
|
100
113
|
(biggerNbRow - 1) * margin[1] +
|
|
101
114
|
containerPaddingY * 2 +
|
|
102
|
-
|
|
115
|
+
'px');
|
|
103
116
|
};
|
|
104
117
|
var getBackgroundHeight = function () {
|
|
105
118
|
if (!autoSize)
|
|
@@ -109,17 +122,16 @@ var ReactGridLayout = function (_a) {
|
|
|
109
122
|
var containerPaddingY = containerPadding
|
|
110
123
|
? containerPadding[1]
|
|
111
124
|
: margin[1];
|
|
112
|
-
return (biggerNbRow *
|
|
113
|
-
resolveRowHeight(rowHeight, colWidth) +
|
|
125
|
+
return (biggerNbRow * resolveRowHeight(rowHeight, colWidth) +
|
|
114
126
|
(biggerNbRow - 1) * margin[1] +
|
|
115
127
|
containerPaddingY * 2 -
|
|
116
128
|
2 * margin[1] +
|
|
117
|
-
|
|
129
|
+
'px');
|
|
118
130
|
};
|
|
119
131
|
var getBackgroundWidth = function () {
|
|
120
132
|
if (!autoSize)
|
|
121
133
|
return;
|
|
122
|
-
return width - margin[0] * 2 +
|
|
134
|
+
return width - margin[0] * 2 + 'px';
|
|
123
135
|
};
|
|
124
136
|
/**
|
|
125
137
|
* When dragging starts
|
|
@@ -129,13 +141,27 @@ var ReactGridLayout = function (_a) {
|
|
|
129
141
|
* @param {Event} e The mousedown event
|
|
130
142
|
* @param {Element} node The current dragging DOM element
|
|
131
143
|
*/
|
|
132
|
-
var onDragStartHandler = function (i, x, y, _a) {
|
|
144
|
+
var onDragStartHandler = function (i, x, y, _a, isGroup) {
|
|
145
|
+
var _b;
|
|
133
146
|
var e = _a.e, node = _a.node;
|
|
134
|
-
var l = getLayoutItem(layout, i);
|
|
147
|
+
var l = (_b = getLayoutItem(layout, i)) !== null && _b !== void 0 ? _b : { i: i, x: x, y: y, w: 1, h: 1 };
|
|
135
148
|
if (!l)
|
|
136
149
|
return;
|
|
137
150
|
setOldDragItem(cloneLayoutItem(l));
|
|
138
151
|
setOldLayout(layout);
|
|
152
|
+
if (isGroup) {
|
|
153
|
+
if (!blockStructure) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
var childrenIds = findAllChildrenCbIds(blockStructure, i).map(function (i) {
|
|
157
|
+
return i.toString();
|
|
158
|
+
});
|
|
159
|
+
var children_1 = childrenIds.map(function (id) {
|
|
160
|
+
var item = getLayoutItem(layout, id);
|
|
161
|
+
return cloneLayoutItem(item);
|
|
162
|
+
});
|
|
163
|
+
setOldGroupChildren(children_1);
|
|
164
|
+
}
|
|
139
165
|
props.onDragStart &&
|
|
140
166
|
props.onDragStart({
|
|
141
167
|
layout: layout,
|
|
@@ -146,6 +172,32 @@ var ReactGridLayout = function (_a) {
|
|
|
146
172
|
node: node,
|
|
147
173
|
});
|
|
148
174
|
};
|
|
175
|
+
var onDragStartHandlerGroup = function (i, x, y, _a, isGroup) {
|
|
176
|
+
// const l = getLayoutItem(layout, i);
|
|
177
|
+
var e = _a.e, node = _a.node;
|
|
178
|
+
// if (!l) return;
|
|
179
|
+
// setOldDragItem(cloneLayoutItem(l));
|
|
180
|
+
setOldLayout(layout);
|
|
181
|
+
if (isGroup) {
|
|
182
|
+
if (!blockStructure) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
var children_2 = findDirectChildrenBlockIds(blockStructure, i).map(function (id) {
|
|
186
|
+
var item = getLayoutItem(layout, id);
|
|
187
|
+
return cloneLayoutItem(item);
|
|
188
|
+
});
|
|
189
|
+
setOldGroupChildren(children_2);
|
|
190
|
+
}
|
|
191
|
+
// props.onDragStart &&
|
|
192
|
+
// props.onDragStart({
|
|
193
|
+
// layout,
|
|
194
|
+
// prev: l,
|
|
195
|
+
// item: l,
|
|
196
|
+
// placeholder: undefined,
|
|
197
|
+
// e,
|
|
198
|
+
// node,
|
|
199
|
+
// });
|
|
200
|
+
};
|
|
149
201
|
/**
|
|
150
202
|
* Each drag movement create a new dragelement and move the element to the dragged location
|
|
151
203
|
* @param {String} i Id of the child
|
|
@@ -154,11 +206,17 @@ var ReactGridLayout = function (_a) {
|
|
|
154
206
|
* @param {Event} e The mousedown event
|
|
155
207
|
* @param {Element} node The current dragging DOM element
|
|
156
208
|
*/
|
|
157
|
-
var onDragHandler = function (i, x, y, _a) {
|
|
209
|
+
var onDragHandler = function (i, x, y, _a, isGroup) {
|
|
210
|
+
var _b;
|
|
158
211
|
var e = _a.e, node = _a.node;
|
|
159
|
-
var l = getLayoutItem(layout, i);
|
|
212
|
+
var l = (_b = getLayoutItem(layout, i)) !== null && _b !== void 0 ? _b : { i: i, x: x, y: y, w: 10, h: 10 };
|
|
160
213
|
if (!l)
|
|
161
214
|
return;
|
|
215
|
+
if (!oldDragItem) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
var xgap = x - oldDragItem.x;
|
|
219
|
+
var ygap = y - oldDragItem.y;
|
|
162
220
|
var placeholder = {
|
|
163
221
|
w: l.w,
|
|
164
222
|
h: l.h,
|
|
@@ -169,17 +227,35 @@ var ReactGridLayout = function (_a) {
|
|
|
169
227
|
i: i,
|
|
170
228
|
};
|
|
171
229
|
var isUserAction = true;
|
|
172
|
-
var newLayout =
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
230
|
+
var newLayout = isGroup
|
|
231
|
+
? layout
|
|
232
|
+
: moveElement({
|
|
233
|
+
layout: layout,
|
|
234
|
+
l: l,
|
|
235
|
+
x: x,
|
|
236
|
+
y: y,
|
|
237
|
+
isUserAction: isUserAction,
|
|
238
|
+
preventCollision: preventCollision,
|
|
239
|
+
compactType: compactType,
|
|
240
|
+
cols: cols,
|
|
241
|
+
allowOverlap: allowOverlap,
|
|
242
|
+
});
|
|
243
|
+
if (isGroup) {
|
|
244
|
+
oldGroupChildren.forEach(function (item) {
|
|
245
|
+
var layoutItem = getLayoutItem(layout, item.i);
|
|
246
|
+
newLayout = moveElement({
|
|
247
|
+
layout: layout,
|
|
248
|
+
l: layoutItem,
|
|
249
|
+
x: item.x + xgap,
|
|
250
|
+
y: item.y + ygap,
|
|
251
|
+
isUserAction: isUserAction,
|
|
252
|
+
preventCollision: preventCollision,
|
|
253
|
+
compactType: compactType,
|
|
254
|
+
cols: cols,
|
|
255
|
+
allowOverlap: allowOverlap,
|
|
256
|
+
});
|
|
257
|
+
});
|
|
258
|
+
}
|
|
183
259
|
props.onDrag &&
|
|
184
260
|
props.onDrag({
|
|
185
261
|
layout: newLayout,
|
|
@@ -201,12 +277,12 @@ var ReactGridLayout = function (_a) {
|
|
|
201
277
|
* @param {Element} node The current dragging DOM element
|
|
202
278
|
*/
|
|
203
279
|
var onDragStopHandler = function (i, x, y, _a) {
|
|
280
|
+
var _b;
|
|
204
281
|
var e = _a.e, node = _a.node;
|
|
205
282
|
if (!activeDrag || !oldDragItem) {
|
|
206
283
|
return;
|
|
207
284
|
}
|
|
208
|
-
;
|
|
209
|
-
var l = getLayoutItem(layout, i);
|
|
285
|
+
var l = (_b = getLayoutItem(layout, i)) !== null && _b !== void 0 ? _b : { i: i, x: x, y: y, w: 10, h: 10 };
|
|
210
286
|
if (!l)
|
|
211
287
|
return;
|
|
212
288
|
// NOTE: z-index 원래대로 복귀
|
|
@@ -222,7 +298,7 @@ var ReactGridLayout = function (_a) {
|
|
|
222
298
|
compactType: compactType,
|
|
223
299
|
cols: cols,
|
|
224
300
|
allowOverlap: allowOverlap,
|
|
225
|
-
overrideZ: oldDragItem.z
|
|
301
|
+
overrideZ: oldDragItem.z,
|
|
226
302
|
});
|
|
227
303
|
props.onDragStop &&
|
|
228
304
|
props.onDragStop({
|
|
@@ -240,6 +316,59 @@ var ReactGridLayout = function (_a) {
|
|
|
240
316
|
setLayout(newLayout);
|
|
241
317
|
setOldDragItem(undefined);
|
|
242
318
|
setOldLayout(undefined);
|
|
319
|
+
setOldGroupChildren([]);
|
|
320
|
+
props.onLayoutChange && props.onLayoutChange(newLayout);
|
|
321
|
+
};
|
|
322
|
+
var onDragStopGroupHandler = function (i, x, y, _a) {
|
|
323
|
+
var _b;
|
|
324
|
+
var e = _a.e, node = _a.node;
|
|
325
|
+
if (!activeDrag || !oldDragItem) {
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
var l = (_b = getLayoutItem(layout, i)) !== null && _b !== void 0 ? _b : { i: i, x: x, y: y, w: 10, h: 10 };
|
|
329
|
+
if (!l)
|
|
330
|
+
return;
|
|
331
|
+
// NOTE: z-index 원래대로 복귀
|
|
332
|
+
l.z = oldDragItem.z;
|
|
333
|
+
var isUserAction = true;
|
|
334
|
+
var movedLayout = moveElement({
|
|
335
|
+
layout: layout,
|
|
336
|
+
l: l,
|
|
337
|
+
x: x,
|
|
338
|
+
y: y,
|
|
339
|
+
isUserAction: isUserAction,
|
|
340
|
+
preventCollision: preventCollision,
|
|
341
|
+
compactType: compactType,
|
|
342
|
+
cols: cols,
|
|
343
|
+
allowOverlap: allowOverlap,
|
|
344
|
+
overrideZ: oldDragItem.z,
|
|
345
|
+
});
|
|
346
|
+
var updatedItems = oldGroupChildren.map(function (item) {
|
|
347
|
+
var layoutItem = getLayoutItem(layout, item.i);
|
|
348
|
+
return {
|
|
349
|
+
id: layoutItem.i,
|
|
350
|
+
x: layoutItem.x,
|
|
351
|
+
y: layoutItem.y,
|
|
352
|
+
};
|
|
353
|
+
});
|
|
354
|
+
props.onDragStopForGroup &&
|
|
355
|
+
props.onDragStopForGroup({
|
|
356
|
+
layout: movedLayout,
|
|
357
|
+
prev: oldDragItem,
|
|
358
|
+
item: l,
|
|
359
|
+
placeholder: undefined,
|
|
360
|
+
e: e,
|
|
361
|
+
node: node,
|
|
362
|
+
updatedItems: updatedItems,
|
|
363
|
+
});
|
|
364
|
+
var newLayout = allowOverlap
|
|
365
|
+
? movedLayout
|
|
366
|
+
: compact(movedLayout, compactType, cols);
|
|
367
|
+
setActiveDrag(undefined);
|
|
368
|
+
setLayout(newLayout);
|
|
369
|
+
setOldDragItem(undefined);
|
|
370
|
+
setOldLayout(undefined);
|
|
371
|
+
setOldGroupChildren([]);
|
|
243
372
|
props.onLayoutChange && props.onLayoutChange(newLayout);
|
|
244
373
|
};
|
|
245
374
|
var onLayoutMaybeChanged = function (newLayout, oldLayout) {
|
|
@@ -371,7 +500,7 @@ var ReactGridLayout = function (_a) {
|
|
|
371
500
|
layout: newLayout,
|
|
372
501
|
prev: oldResizeItem,
|
|
373
502
|
item: l,
|
|
374
|
-
hasPaddingChanged: hasPaddingChanged
|
|
503
|
+
hasPaddingChanged: hasPaddingChanged,
|
|
375
504
|
});
|
|
376
505
|
setLayout(allowOverlap ? newLayout : compact(newLayout, compactType, cols));
|
|
377
506
|
};
|
|
@@ -391,13 +520,15 @@ var ReactGridLayout = function (_a) {
|
|
|
391
520
|
// LINK: https://legacy.reactjs.org/docs/react-api.html
|
|
392
521
|
var items = React.Children.toArray(children);
|
|
393
522
|
var item = items.find(function (child) {
|
|
394
|
-
var originalKey = String(child.key).split(
|
|
523
|
+
var originalKey = String(child.key).split('.$');
|
|
395
524
|
return originalKey[1] === l.i;
|
|
396
525
|
});
|
|
526
|
+
var isInBulk = blockStructure &&
|
|
527
|
+
(bulkIds === null || bulkIds === void 0 ? void 0 : bulkIds.includes(formatCbIdToBlockId(Number(activeDrag.i))));
|
|
397
528
|
if (!item) {
|
|
398
529
|
return null;
|
|
399
530
|
}
|
|
400
|
-
return (_jsx(GridItem, { w: activeDrag.w, h: activeDrag.h, x: activeDrag.x, y: activeDrag.y, z:
|
|
531
|
+
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, children: item && item }));
|
|
401
532
|
};
|
|
402
533
|
/**
|
|
403
534
|
* Given a grid item, set its style attributes & surround in a <Draggable>.
|
|
@@ -405,22 +536,65 @@ var ReactGridLayout = function (_a) {
|
|
|
405
536
|
* @return {Element} Element wrapped in draggable and properly placed.
|
|
406
537
|
*/
|
|
407
538
|
var processGridItem = function (child, isDroppingItem) {
|
|
539
|
+
var _a;
|
|
408
540
|
if (!child || !child.key)
|
|
409
541
|
return;
|
|
410
542
|
var l = getLayoutItem(layout, String(child.key));
|
|
411
543
|
if (!l) {
|
|
412
544
|
return;
|
|
413
545
|
}
|
|
414
|
-
|
|
415
|
-
var draggable = typeof l.isDraggable === "boolean"
|
|
546
|
+
var draggable = typeof l.isDraggable === 'boolean'
|
|
416
547
|
? l.isDraggable
|
|
417
548
|
: !l.static && isDraggable;
|
|
418
|
-
var resizable = typeof l.isResizable ===
|
|
549
|
+
var resizable = typeof l.isResizable === 'boolean'
|
|
419
550
|
? l.isResizable
|
|
420
551
|
: !l.static && isResizable;
|
|
421
552
|
var resizeHandlesOptions = l.resizeHandles || resizeHandles;
|
|
422
553
|
var bounded = draggable && isBounded && l.isBounded !== false;
|
|
423
|
-
|
|
554
|
+
var editable = editableBlockIds.includes(Number(l.i));
|
|
555
|
+
var z = l.z || 0;
|
|
556
|
+
var isInBulk = blockStructure && (bulkIds === null || bulkIds === void 0 ? void 0 : bulkIds.includes(formatCbIdToBlockId(Number(l.i))));
|
|
557
|
+
var isRoot = editingGroupBlock === 'ROOT';
|
|
558
|
+
var block = blockStructure
|
|
559
|
+
? findBlockByBlockId(blockStructure, formatCbIdToBlockId(Number(l.i)))
|
|
560
|
+
: undefined;
|
|
561
|
+
var parent = blockStructure
|
|
562
|
+
? findParentGroupBlock(blockStructure, formatCbIdToBlockId(Number(l.i)))
|
|
563
|
+
: null;
|
|
564
|
+
if (!block) {
|
|
565
|
+
return _jsx(_Fragment, { children: "NO-BLOCK-FOUND" });
|
|
566
|
+
}
|
|
567
|
+
var zOrder = (_a = block[device === 'DESKTOP' ? 'zOrderDesktopInternal' : 'zOrderMobileInternal']) !== null && _a !== void 0 ? _a : 0;
|
|
568
|
+
var editorZIndex = (function () {
|
|
569
|
+
if (isInBulk) {
|
|
570
|
+
return zIndexMap.EDITING_GROUP_CHILD + z;
|
|
571
|
+
}
|
|
572
|
+
if (!isRoot && editable) {
|
|
573
|
+
return zIndexMap.EDITING_GROUP_CHILD + z;
|
|
574
|
+
}
|
|
575
|
+
if (isRoot && editable) {
|
|
576
|
+
return zIndexMap.ROOT + z;
|
|
577
|
+
}
|
|
578
|
+
if (isRoot && !editable) {
|
|
579
|
+
return zIndexMap.ROOT + z;
|
|
580
|
+
}
|
|
581
|
+
if (!editable) {
|
|
582
|
+
return z;
|
|
583
|
+
}
|
|
584
|
+
return z;
|
|
585
|
+
})();
|
|
586
|
+
var outsideOfEditingGroup = !editingGroupAllChildren.includes(l.i);
|
|
587
|
+
var zIndex = editorMode === 'EDIT' ? editorZIndex : z;
|
|
588
|
+
return (_jsx(GridItem, { className: classNames({
|
|
589
|
+
'editable-grid-item': !isRoot && editable,
|
|
590
|
+
'not-editable-grid-item': !isRoot && !editable,
|
|
591
|
+
'bulk-child-item': isInBulk,
|
|
592
|
+
'outside-of-editing-group': outsideOfEditingGroup,
|
|
593
|
+
}), z: zIndex, zOrder: l.z, zOrderInternal: parent
|
|
594
|
+
? "".concat(parent[device === 'DESKTOP'
|
|
595
|
+
? 'zOrderDesktopInternal'
|
|
596
|
+
: 'zOrderMobileInternal'], " > ").concat(zOrder)
|
|
597
|
+
: 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));
|
|
424
598
|
};
|
|
425
599
|
var onDragOverHandler = function (e) {
|
|
426
600
|
var _a;
|
|
@@ -488,11 +662,88 @@ var ReactGridLayout = function (_a) {
|
|
|
488
662
|
};
|
|
489
663
|
var mergedClassName = classNames(layoutClassName, className);
|
|
490
664
|
var mergedStyle = __assign({ height: containerHeight() }, style);
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
665
|
+
var processGroup = function (block, viewOnly) {
|
|
666
|
+
var _a;
|
|
667
|
+
if (!blockStructure) {
|
|
668
|
+
return;
|
|
669
|
+
}
|
|
670
|
+
var childrenIds = findAllChildrenCbIds(blockStructure, block.blockId).map(function (i) { return i.toString(); });
|
|
671
|
+
var groupItem = getBoundingArea(layout, childrenIds);
|
|
672
|
+
if (!groupItem) {
|
|
673
|
+
return _jsx(_Fragment, {});
|
|
674
|
+
}
|
|
675
|
+
var zOrder = (_a = block[device === 'DESKTOP' ? 'zOrderDesktopInternal' : 'zOrderMobileInternal']) !== null && _a !== void 0 ? _a : 0;
|
|
676
|
+
var isEditingGroup = block.blockId === editingGroupBlock;
|
|
677
|
+
var type = getBlockSpecificType(block);
|
|
678
|
+
var isRoot = editingGroupBlock === 'ROOT';
|
|
679
|
+
var isInBulk = bulkIds === null || bulkIds === void 0 ? void 0 : bulkIds.includes(block.blockId);
|
|
680
|
+
var isBulk = block.blockId === 'BULK';
|
|
681
|
+
var baseZ = (function () {
|
|
682
|
+
if (isEditingGroup) {
|
|
683
|
+
return zIndexMap.EDITING_GROUP;
|
|
684
|
+
}
|
|
685
|
+
if (isBulk) {
|
|
686
|
+
return zIndexMap.EDITING_GROUP_CHILD + groupItem.z;
|
|
687
|
+
}
|
|
688
|
+
if (isInBulk) {
|
|
689
|
+
// 위와 같지만 이것은 not-editable이긴 함.
|
|
690
|
+
// const bulkBlock = findBlockByBlockId(blockStructure, 'BULK');
|
|
691
|
+
// const bulkZOrder = bulkBlock?.[device === 'DESKTOP' ? 'zOrderDesktopInternal' : 'zOrderMobileInternal'] ?? 0;
|
|
692
|
+
return zIndexMap.EDITING_GROUP_CHILD + zOrder;
|
|
693
|
+
}
|
|
694
|
+
if (!isRoot && type === 'GROUP_BLOCK') {
|
|
695
|
+
return zIndexMap.EDITING_GROUP;
|
|
696
|
+
}
|
|
697
|
+
if (type === 'GROUP_BLOCK') {
|
|
698
|
+
return zIndexMap.GROUP;
|
|
699
|
+
}
|
|
700
|
+
if (type === 'BULK') {
|
|
701
|
+
return zIndexMap.BULK;
|
|
702
|
+
}
|
|
703
|
+
return zIndexMap.CB;
|
|
704
|
+
})();
|
|
705
|
+
var zIndex = editorMode === 'EDIT' ? baseZ : zOrder;
|
|
706
|
+
var handleClick = function (e) {
|
|
707
|
+
onClickGroup && onClickGroup(e, block.blockId, type);
|
|
708
|
+
};
|
|
709
|
+
var handleDoubleClick = function (e) {
|
|
710
|
+
onDoubleClickGroup && onDoubleClickGroup(e, block.blockId, type);
|
|
711
|
+
};
|
|
712
|
+
var handleClickContextGroup = function (e) {
|
|
713
|
+
(props === null || props === void 0 ? void 0 : props.onContextGroup) &&
|
|
714
|
+
props.onContextGroup(e, block.blockId, isEditingGroup);
|
|
715
|
+
};
|
|
716
|
+
var parent = blockStructure
|
|
717
|
+
? findParentGroupBlock(blockStructure, block.blockId)
|
|
718
|
+
: null;
|
|
719
|
+
return (_jsx(OutsideClickHandler, { onOutsideClick: onDoubleClickOutsideGroup, children: _jsx(GroupItem, { className: classNames({
|
|
720
|
+
'bulk-child-item': isInBulk,
|
|
721
|
+
'grid-bulk-block': block.blockId === 'BULK',
|
|
722
|
+
editing: editingGroupBlock === block.blockId,
|
|
723
|
+
selected: selectedGroupBlock === block.blockId,
|
|
724
|
+
}), z: zIndex, minZ: groupItem.minZ, zOrder: zOrder, zOrderInternal: parent
|
|
725
|
+
? "".concat(parent[device === 'DESKTOP'
|
|
726
|
+
? 'zOrderDesktopInternal'
|
|
727
|
+
: 'zOrderMobileInternal'], " > ").concat(zOrder)
|
|
728
|
+
: zOrder.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,
|
|
729
|
+
// minH={l.minH}
|
|
730
|
+
// minW={l.minW}
|
|
731
|
+
// maxH={l.maxH}
|
|
732
|
+
// maxW={l.maxW}
|
|
733
|
+
// static={l.static}
|
|
734
|
+
// droppingPosition={isDroppingItem ? droppingPosition : undefined}
|
|
735
|
+
// resizeHandles={resizeHandlesOptions}
|
|
736
|
+
// resizeHandle={resizeHandle}
|
|
737
|
+
isHiddenVisibility: isHiddenVisibility, customColWidth: colWidth, autoResize: false, onContextGroup: handleClickContextGroup, children: _jsx("div", { onClick: handleClick, onDoubleClick: handleDoubleClick }) }, block.blockId) }));
|
|
738
|
+
};
|
|
739
|
+
var currentGroupBlocks = blockStructure
|
|
740
|
+
? findGroupBlocks(blockStructure, editingGroupBlock)
|
|
741
|
+
: [];
|
|
742
|
+
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: {
|
|
743
|
+
marginTop: margin[1] + 'px',
|
|
744
|
+
marginBottom: margin[1] + 'px',
|
|
745
|
+
marginLeft: margin[0] + 'px',
|
|
746
|
+
marginRight: margin[0] + 'px',
|
|
747
|
+
}, 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)' })] }) }))] }));
|
|
497
748
|
};
|
|
498
749
|
export default ReactGridLayout;
|
|
@@ -38,7 +38,7 @@ function getIndentationValue(param, breakpoint) {
|
|
|
38
38
|
}
|
|
39
39
|
export var ResponsiveGridLayout = function (_a) {
|
|
40
40
|
var children = _a.children, props = __rest(_a, ["children"]);
|
|
41
|
-
var breakpoint = props.breakpoint, compactType = props.compactType, _b = props.breakpoints, breakpoints = _b === void 0 ? { lg: 1200, md: 996, sm: 768, xs: 480, xxs: 0 } : _b, _c = props.cols, cols = _c === void 0 ? { lg: 12, md: 10, sm: 6, xs: 4, xxs: 2 } : _c, _d = props.containerPadding, containerPadding = _d === void 0 ? {} : _d, _e = props.layouts, layouts = _e === void 0 ? {} : _e, _f = props.width, width = _f === void 0 ? 0 : _f, _g = props.margin, margin = _g === void 0 ? [10, 10] : _g, _h = props.onBreakpointChange, onBreakpointChange = _h === void 0 ? noop : _h, _j = props.onLayoutChange, onLayoutChange = _j === void 0 ? noop : _j, _k = props.onWidthChange, onWidthChange = _k === void 0 ? noop : _k,
|
|
41
|
+
var breakpoint = props.breakpoint, compactType = props.compactType, _b = props.breakpoints, breakpoints = _b === void 0 ? { lg: 1200, md: 996, sm: 768, xs: 480, xxs: 0 } : _b, _c = props.cols, cols = _c === void 0 ? { lg: 12, md: 10, sm: 6, xs: 4, xxs: 2 } : _c, _d = props.containerPadding, containerPadding = _d === void 0 ? {} : _d, _e = props.layouts, layouts = _e === void 0 ? {} : _e, _f = props.width, width = _f === void 0 ? 0 : _f, _g = props.margin, margin = _g === void 0 ? [10, 10] : _g, _h = props.onBreakpointChange, onBreakpointChange = _h === void 0 ? noop : _h, _j = props.onLayoutChange, onLayoutChange = _j === void 0 ? noop : _j, _k = props.onWidthChange, onWidthChange = _k === void 0 ? noop : _k, zoom = props.zoom, restProps = __rest(props, ["breakpoint", "compactType", "breakpoints", "cols", "containerPadding", "layouts", "width", "margin", "onBreakpointChange", "onLayoutChange", "onWidthChange", "zoom"]);
|
|
42
42
|
var _l = useState({ width: width, breakpoints: breakpoints, cols: cols }), prevProps = _l[0], setPrevProps = _l[1];
|
|
43
43
|
var generateInitialState = function () {
|
|
44
44
|
var breakpoint = getBreakpointFromWidth(breakpoints, width);
|
|
@@ -112,6 +112,6 @@ export var ResponsiveGridLayout = function (_a) {
|
|
|
112
112
|
var containerPaddingModified = getIndentationValue(containerPadding, newBreakpoint);
|
|
113
113
|
onWidthChange(width, modifiedMargin, newCols, containerPaddingModified);
|
|
114
114
|
};
|
|
115
|
-
return (_jsx(ReactGridLayout, __assign({}, restProps, { children: children, width: width, margin: getIndentationValue(margin, state.breakpoint), containerPadding: getIndentationValue(containerPadding, state.breakpoint), onLayoutChange: onLayoutChangeHandler, layout: state.layout, cols: state.cols, transformScale:
|
|
115
|
+
return (_jsx(ReactGridLayout, __assign({}, restProps, { children: children, width: width, margin: getIndentationValue(margin, state.breakpoint), containerPadding: getIndentationValue(containerPadding, state.breakpoint), onLayoutChange: onLayoutChangeHandler, layout: state.layout, cols: state.cols, transformScale: zoom !== null && zoom !== void 0 ? zoom : 1 })));
|
|
116
116
|
};
|
|
117
117
|
export default ResponsiveGridLayout;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export declare const zIndexMap: {
|
|
2
|
+
ISDRAGGING: number;
|
|
3
|
+
BULK: number;
|
|
4
|
+
EDITING_GROUP_CHILD: number;
|
|
5
|
+
EDITING_GROUP: number;
|
|
6
|
+
GROUP: number;
|
|
7
|
+
CB: number;
|
|
8
|
+
ROOT: number;
|
|
9
|
+
};
|
|
10
|
+
export declare function getBlockSpecificType(block: Block): "ROOT" | "BULK" | "COMPONENT_BLOCK" | "GROUP_BLOCK";
|
|
11
|
+
export type SectionPedigree = RootBlock;
|
|
12
|
+
export type Block = ComponentBlock | GroupBlock | RootBlock;
|
|
13
|
+
export type ZOrder = {
|
|
14
|
+
[platform in 'mobile' | 'desktop']: {
|
|
15
|
+
[componentBlockId: string]: number;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export type ComponentBlock = {
|
|
19
|
+
blockId: string;
|
|
20
|
+
type: 'COMPONENT_BLOCK';
|
|
21
|
+
zOrderDesktopInternal: number | null;
|
|
22
|
+
zOrderMobileInternal: number | null;
|
|
23
|
+
componentBlockId: number;
|
|
24
|
+
};
|
|
25
|
+
export type GroupBlock = {
|
|
26
|
+
blockId: string;
|
|
27
|
+
type: 'GROUP_BLOCK';
|
|
28
|
+
zOrderDesktopInternal: number | null;
|
|
29
|
+
zOrderMobileInternal: number | null;
|
|
30
|
+
children: (ComponentBlock | GroupBlock)[];
|
|
31
|
+
};
|
|
32
|
+
export type RootBlock = {
|
|
33
|
+
blockId: 'ROOT';
|
|
34
|
+
type: 'GROUP_BLOCK';
|
|
35
|
+
zOrderDesktopInternal: number | null;
|
|
36
|
+
zOrderMobileInternal: number | null;
|
|
37
|
+
children: (ComponentBlock | GroupBlock)[];
|
|
38
|
+
};
|
|
39
|
+
export type BulkBlockInternal = {
|
|
40
|
+
blockId: 'BULK';
|
|
41
|
+
type: 'GROUP_BLOCK';
|
|
42
|
+
zOrderDesktopInternal: number;
|
|
43
|
+
zOrderMobileInternal: number;
|
|
44
|
+
children: (ComponentBlock | GroupBlock)[];
|
|
45
|
+
};
|
|
46
|
+
export declare const findBlockByBlockId: (block: Block, blockId: string) => Block | null;
|
|
47
|
+
export declare const findDirectChildrenCbIds: (block: Block, targetId: string) => number[];
|
|
48
|
+
export declare const findAllChildrenCbIds: (block: Block, targetId: string) => number[];
|
|
49
|
+
export declare const findAllChildrenBlockIds: (block: Block, targetId: string) => string[];
|
|
50
|
+
export declare const findDirectChildrenBlockIds: (block: Block, targetId: string) => string[];
|
|
51
|
+
export declare const findGroupBlocks: (block: Block, targetId: string) => GroupBlock[];
|
|
52
|
+
export declare const addBulkToTarget: (block: Block, targetId: string, bulkBlockIds: string[]) => Block;
|
|
53
|
+
export declare function getBlockWorkDirPath(blockStructure: Block, targetBlockId: string): string;
|
|
54
|
+
export declare function formatBlockIdToCbId(blockId: string): number | null;
|
|
55
|
+
export declare function formatCbIdToBlockId(cbId: number): string;
|
|
56
|
+
export declare function findParentGroupBlock(current: Block, targetBlockId: string): GroupBlock | null;
|
|
57
|
+
export declare function findOneComponentBlock(current: Block, targetBlockId: string): number | null;
|