publ-echo-test 0.0.110 → 0.0.112
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.
@@ -57,8 +57,8 @@ var ReactGridLayout = function (_a) {
|
|
57
57
|
var _6 = useState(), droppingDOMNode = _6[0], setDroppingDOMNode = _6[1];
|
58
58
|
var _7 = useState(), droppingPosition = _7[0], setDroppingPosition = _7[1];
|
59
59
|
var _8 = useState(false), isMounted = _8[0], setIsMounted = _8[1];
|
60
|
-
var editableItems = blockStructure ? findChildrenComponentIds(blockStructure, editingGroupBlock) : [];
|
61
|
-
var editingGroupAllChildren = (blockStructure && editingGroupBlock) ? findAllChildrenComponentIds(blockStructure, editingGroupBlock).map(function (i) { return i.toString(); }) : [];
|
60
|
+
var editableItems = blockStructure ? findChildrenComponentIds(blockStructure.children, editingGroupBlock) : [];
|
61
|
+
var editingGroupAllChildren = (blockStructure && editingGroupBlock) ? findAllChildrenComponentIds(blockStructure.children, editingGroupBlock).map(function (i) { return i.toString(); }) : [];
|
62
62
|
var _9 = useState([]), oldGroupChildren = _9[0], setOldGroupChildren = _9[1];
|
63
63
|
var _10 = useState(function () {
|
64
64
|
return synchronizeLayoutWithChildren(props.layout || [], children, cols, compactType, allowOverlap);
|
@@ -147,7 +147,7 @@ var ReactGridLayout = function (_a) {
|
|
147
147
|
if (!blockStructure) {
|
148
148
|
return;
|
149
149
|
}
|
150
|
-
var childrenIds = findAllChildrenComponentIds(blockStructure, i).map(function (i) { return i.toString(); });
|
150
|
+
var childrenIds = findAllChildrenComponentIds(blockStructure.children, i).map(function (i) { return i.toString(); });
|
151
151
|
var children_1 = childrenIds.map(function (id) {
|
152
152
|
var item = getLayoutItem(layout, id);
|
153
153
|
return cloneLayoutItem(item);
|
@@ -174,7 +174,7 @@ var ReactGridLayout = function (_a) {
|
|
174
174
|
if (!blockStructure) {
|
175
175
|
return;
|
176
176
|
}
|
177
|
-
var children_2 = findChildrenComponentIds(blockStructure, i).map(function (id) {
|
177
|
+
var children_2 = findChildrenComponentIds(blockStructure.children, i).map(function (id) {
|
178
178
|
var item = getLayoutItem(layout, id);
|
179
179
|
return cloneLayoutItem(item);
|
180
180
|
});
|
@@ -515,7 +515,7 @@ var ReactGridLayout = function (_a) {
|
|
515
515
|
var originalKey = String(child.key).split(".$");
|
516
516
|
return originalKey[1] === l.i;
|
517
517
|
});
|
518
|
-
var isInBulk = blockStructure && (bulkIds === null || bulkIds === void 0 ? void 0 : bulkIds.includes(getBlockIdByComponentId(blockStructure, Number(activeDrag.i))));
|
518
|
+
var isInBulk = blockStructure && (bulkIds === null || bulkIds === void 0 ? void 0 : bulkIds.includes(getBlockIdByComponentId(blockStructure.children, Number(activeDrag.i))));
|
519
519
|
if (!item) {
|
520
520
|
return null;
|
521
521
|
}
|
@@ -544,7 +544,7 @@ var ReactGridLayout = function (_a) {
|
|
544
544
|
var bounded = draggable && isBounded && l.isBounded !== false;
|
545
545
|
var editable = editableItems.includes(l.i);
|
546
546
|
var z = l.z || 0;
|
547
|
-
var isInBulk = blockStructure && (bulkIds === null || bulkIds === void 0 ? void 0 : bulkIds.includes(getBlockIdByComponentId(blockStructure, Number(l.i))));
|
547
|
+
var isInBulk = blockStructure && (bulkIds === null || bulkIds === void 0 ? void 0 : bulkIds.includes(getBlockIdByComponentId(blockStructure.children, Number(l.i))));
|
548
548
|
var isRoot = editingGroupBlock === 'ROOT';
|
549
549
|
var baseZ = function () {
|
550
550
|
if (isInBulk) {
|
@@ -639,7 +639,7 @@ var ReactGridLayout = function (_a) {
|
|
639
639
|
if (!blockStructure) {
|
640
640
|
return;
|
641
641
|
}
|
642
|
-
var childrenIds = findAllChildrenComponentIds(blockStructure, block.blockId).map(function (i) { return i.toString(); });
|
642
|
+
var childrenIds = findAllChildrenComponentIds(blockStructure.children, block.blockId).map(function (i) { return i.toString(); });
|
643
643
|
var groupItem = getBoundingArea(layout, childrenIds);
|
644
644
|
// const draggable =
|
645
645
|
// typeof l.isDraggable === "boolean"
|
@@ -698,7 +698,7 @@ var ReactGridLayout = function (_a) {
|
|
698
698
|
// resizeHandle={resizeHandle}
|
699
699
|
isHiddenVisibility: isHiddenVisibility, customColWidth: colWidth, autoResize: false, onContextGroup: handleClickContextGroup, children: _jsx("div", { onClick: handleClick, onDoubleClick: handleDoubleClick }) }, block.blockId) }));
|
700
700
|
};
|
701
|
-
var currentGroupBlocks = blockStructure ? findGroupBlocks(blockStructure, editingGroupBlock) : [];
|
701
|
+
var currentGroupBlocks = blockStructure ? findGroupBlocks(blockStructure.children, editingGroupBlock) : [];
|
702
702
|
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, 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: {
|
703
703
|
marginTop: margin[1] + "px",
|
704
704
|
marginBottom: margin[1] + "px",
|
@@ -40,19 +40,21 @@ export type BulkBlockInternal = {
|
|
40
40
|
zOrderMobileInternal: number;
|
41
41
|
children: (ComponentBlock | GroupBlock)[];
|
42
42
|
};
|
43
|
-
export declare const findBlockByBlockId: (
|
44
|
-
export declare const findChildrenComponentIds: (
|
45
|
-
export declare const findAllChildrenIds: (
|
46
|
-
export declare const findAllChildrenComponentIds: (
|
47
|
-
export declare const findAllParentGroups: (
|
48
|
-
export declare const findGroupBlocks: (
|
49
|
-
export declare const findAllComponentBlockIds: (
|
50
|
-
export declare const findParentGroupByGroupId: (
|
51
|
-
export declare const addBlockToRoot: (
|
52
|
-
export declare const
|
53
|
-
export declare const
|
43
|
+
export declare const findBlockByBlockId: (blocks: Block[], blockId: string) => Block | null;
|
44
|
+
export declare const findChildrenComponentIds: (blockStructure: Block[], targetId: string) => string[];
|
45
|
+
export declare const findAllChildrenIds: (blockStructure: Block[], targetId: string, depth?: 'current' | 'deep') => string[];
|
46
|
+
export declare const findAllChildrenComponentIds: (blockStructure: Block[], targetId: string) => number[];
|
47
|
+
export declare const findAllParentGroups: (blockStructure: Block[], targetId: string) => GroupBlock[];
|
48
|
+
export declare const findGroupBlocks: (blockStructure: Block[], targetId: string) => GroupBlock[];
|
49
|
+
export declare const findAllComponentBlockIds: (blockStructure: Block[]) => number[];
|
50
|
+
export declare const findParentGroupByGroupId: (blockStructure: Block[], targetId: string) => string | null;
|
51
|
+
export declare const addBlockToRoot: (blockStructure: Block[], newBlock: Block) => Block[];
|
52
|
+
export declare const addBulkToTarget: (blockStructure: Block[], targetId: string, bulkIds: string[]) => Block[];
|
53
|
+
export declare const getBlockWorkDirPath: (blockStructure: Block[], blockId: string) => string | null;
|
54
|
+
export declare const getBlockIdByComponentId: (blockStructure: Block[], componentId: number) => string | null;
|
55
|
+
export declare const blockStructure: Block[];
|
56
|
+
export declare const mapComponentBlockIdsToBlockIds: (blockStructure: Block[]) => {
|
54
57
|
CB_ID: Record<number, string>;
|
55
58
|
BLOCK_ID: Record<string, number>;
|
56
59
|
};
|
57
|
-
export declare const
|
58
|
-
export declare const addBulkToTarget: (block: RootBlock, targetId: string, bulkIds: string[]) => RootBlock;
|
60
|
+
export declare const findAccessibleChildrenBlocks: (blockStructure: Block[], targetGroupId: string, blockIds: string[]) => string[];
|
@@ -34,15 +34,15 @@ export function getBlockSpecificType(block) {
|
|
34
34
|
}
|
35
35
|
return block.type;
|
36
36
|
}
|
37
|
-
var deepClone = function (
|
38
|
-
export var findBlockByBlockId = function (
|
39
|
-
for (var _i = 0,
|
40
|
-
var
|
41
|
-
if (
|
42
|
-
return
|
37
|
+
var deepClone = function (blocks) { return JSON.parse(JSON.stringify(blocks)); };
|
38
|
+
export var findBlockByBlockId = function (blocks, blockId) {
|
39
|
+
for (var _i = 0, blocks_1 = blocks; _i < blocks_1.length; _i++) {
|
40
|
+
var block = blocks_1[_i];
|
41
|
+
if (block.blockId === blockId) {
|
42
|
+
return block;
|
43
43
|
}
|
44
|
-
if (
|
45
|
-
var found = findBlockByBlockId(
|
44
|
+
if (block.type === 'GROUP_BLOCK' && block.children) {
|
45
|
+
var found = findBlockByBlockId(block.children, blockId);
|
46
46
|
if (found) {
|
47
47
|
return found;
|
48
48
|
}
|
@@ -50,15 +50,15 @@ export var findBlockByBlockId = function (block, blockId) {
|
|
50
50
|
}
|
51
51
|
return null;
|
52
52
|
};
|
53
|
-
export var findChildrenComponentIds = function (
|
54
|
-
var targetBlock = findBlockByBlockId(
|
53
|
+
export var findChildrenComponentIds = function (blockStructure, targetId) {
|
54
|
+
var targetBlock = findBlockByBlockId(blockStructure, targetId);
|
55
55
|
if (!targetBlock || targetBlock.type !== 'GROUP_BLOCK') {
|
56
56
|
return [];
|
57
57
|
}
|
58
58
|
var blockCBChildren = targetBlock.children.filter(function (child) { return child.type === 'COMPONENT_BLOCK'; });
|
59
59
|
return blockCBChildren.map(function (cb) { return cb.componentBlockId.toString(); });
|
60
60
|
};
|
61
|
-
export var findAllChildrenIds = function (
|
61
|
+
export var findAllChildrenIds = function (blockStructure, targetId, depth) {
|
62
62
|
if (depth === void 0) { depth = 'deep'; }
|
63
63
|
var collectChildrenIds = function (block) {
|
64
64
|
var ids = [];
|
@@ -73,10 +73,10 @@ export var findAllChildrenIds = function (block, targetId, depth) {
|
|
73
73
|
}
|
74
74
|
return ids;
|
75
75
|
};
|
76
|
-
var targetBlock = findBlockByBlockId(
|
76
|
+
var targetBlock = findBlockByBlockId(blockStructure, targetId);
|
77
77
|
return targetBlock ? collectChildrenIds(targetBlock) : [];
|
78
78
|
};
|
79
|
-
export var findAllChildrenComponentIds = function (
|
79
|
+
export var findAllChildrenComponentIds = function (blockStructure, targetId) {
|
80
80
|
var collectComponentIds = function (block) {
|
81
81
|
var ids = [];
|
82
82
|
if ('children' in block && block.children) {
|
@@ -90,19 +90,19 @@ export var findAllChildrenComponentIds = function (block, targetId) {
|
|
90
90
|
}
|
91
91
|
return ids;
|
92
92
|
};
|
93
|
-
var targetBlock = findBlockByBlockId(
|
93
|
+
var targetBlock = findBlockByBlockId(blockStructure, targetId);
|
94
94
|
return targetBlock ? collectComponentIds(targetBlock) : [];
|
95
95
|
};
|
96
|
-
export var findAllParentGroups = function (
|
96
|
+
export var findAllParentGroups = function (blockStructure, targetId) {
|
97
97
|
var findParentGroups = function (blocks, id, parents) {
|
98
98
|
if (parents === void 0) { parents = []; }
|
99
|
-
for (var _i = 0,
|
100
|
-
var
|
101
|
-
if (
|
99
|
+
for (var _i = 0, blocks_2 = blocks; _i < blocks_2.length; _i++) {
|
100
|
+
var block = blocks_2[_i];
|
101
|
+
if (block.blockId === id && block.type === 'GROUP_BLOCK') {
|
102
102
|
return parents;
|
103
103
|
}
|
104
|
-
if ('children' in
|
105
|
-
var result = findParentGroups(
|
104
|
+
if ('children' in block && block.children) {
|
105
|
+
var result = findParentGroups(block.children, id, block.type === 'GROUP_BLOCK' ? __spreadArray(__spreadArray([], parents, true), [block], false) : parents);
|
106
106
|
if (result) {
|
107
107
|
return result;
|
108
108
|
}
|
@@ -110,10 +110,26 @@ export var findAllParentGroups = function (block, targetId) {
|
|
110
110
|
}
|
111
111
|
return null;
|
112
112
|
};
|
113
|
-
return findParentGroups(
|
113
|
+
return findParentGroups(blockStructure, targetId) || [];
|
114
114
|
};
|
115
|
-
export
|
116
|
-
|
115
|
+
// export const findAllChildrenButGroup = (blockStructure: Block[], targetId: string): string[] => {
|
116
|
+
// const collectChildrenIds = (block: Block): string[] => {
|
117
|
+
// let ids: string[] = [];
|
118
|
+
// if ('children' in block && block.children) {
|
119
|
+
// for (const child of block.children) {
|
120
|
+
// if (child.type !== 'GROUP_BLOCK') {
|
121
|
+
// ids.push(child.blockId);
|
122
|
+
// }
|
123
|
+
// ids = ids.concat(collectChildrenIds(child));
|
124
|
+
// }
|
125
|
+
// }
|
126
|
+
// return ids;
|
127
|
+
// };
|
128
|
+
// const targetBlock = findBlockById(blockStructure, targetId);
|
129
|
+
// return targetBlock ? collectChildrenIds(targetBlock) : [];
|
130
|
+
// };
|
131
|
+
export var findGroupBlocks = function (blockStructure, targetId) {
|
132
|
+
var targetBlock = findBlockByBlockId(blockStructure, targetId);
|
117
133
|
var groupBlocks = [];
|
118
134
|
if (targetBlock && targetBlock.blockId === 'ROOT') {
|
119
135
|
if ('children' in targetBlock) {
|
@@ -143,32 +159,32 @@ export var findGroupBlocks = function (block, targetId) {
|
|
143
159
|
}
|
144
160
|
return groupBlocks;
|
145
161
|
};
|
146
|
-
export var findAllComponentBlockIds = function (
|
162
|
+
export var findAllComponentBlockIds = function (blockStructure) {
|
147
163
|
var collectComponentBlockIds = function (blocks) {
|
148
164
|
var ids = [];
|
149
|
-
for (var _i = 0,
|
150
|
-
var
|
151
|
-
if (
|
152
|
-
ids.push(
|
165
|
+
for (var _i = 0, blocks_3 = blocks; _i < blocks_3.length; _i++) {
|
166
|
+
var block = blocks_3[_i];
|
167
|
+
if (block.type === 'COMPONENT_BLOCK') {
|
168
|
+
ids.push(block.componentBlockId);
|
153
169
|
}
|
154
|
-
if ('children' in
|
155
|
-
ids = ids.concat(collectComponentBlockIds(
|
170
|
+
if ('children' in block && block.children) {
|
171
|
+
ids = ids.concat(collectComponentBlockIds(block.children));
|
156
172
|
}
|
157
173
|
}
|
158
174
|
return ids;
|
159
175
|
};
|
160
|
-
return collectComponentBlockIds(
|
176
|
+
return collectComponentBlockIds(blockStructure);
|
161
177
|
};
|
162
|
-
export var findParentGroupByGroupId = function (
|
178
|
+
export var findParentGroupByGroupId = function (blockStructure, targetId) {
|
163
179
|
var findParentGroup = function (blocks, id, parent) {
|
164
180
|
if (parent === void 0) { parent = null; }
|
165
|
-
for (var _i = 0,
|
166
|
-
var
|
167
|
-
if (
|
181
|
+
for (var _i = 0, blocks_4 = blocks; _i < blocks_4.length; _i++) {
|
182
|
+
var block = blocks_4[_i];
|
183
|
+
if (block.blockId === id && block.type === 'GROUP_BLOCK') {
|
168
184
|
return parent ? parent.blockId : null;
|
169
185
|
}
|
170
|
-
if ('children' in
|
171
|
-
var result = findParentGroup(
|
186
|
+
if ('children' in block && block.children) {
|
187
|
+
var result = findParentGroup(block.children, id, block.type === 'GROUP_BLOCK' ? block : parent);
|
172
188
|
if (result) {
|
173
189
|
return result;
|
174
190
|
}
|
@@ -176,15 +192,59 @@ export var findParentGroupByGroupId = function (block, targetId) {
|
|
176
192
|
}
|
177
193
|
return null;
|
178
194
|
};
|
179
|
-
return findParentGroup(
|
195
|
+
return findParentGroup(blockStructure, targetId);
|
180
196
|
};
|
181
|
-
export var addBlockToRoot = function (
|
182
|
-
return
|
197
|
+
export var addBlockToRoot = function (blockStructure, newBlock) {
|
198
|
+
return blockStructure.map(function (block) {
|
199
|
+
if (block.blockId === 'ROOT' && block.type === 'GROUP_BLOCK') {
|
200
|
+
return __assign(__assign({}, block), { children: block.children ? __spreadArray(__spreadArray([], block.children, true), [newBlock], false) : [newBlock] });
|
201
|
+
}
|
202
|
+
return block;
|
203
|
+
});
|
204
|
+
};
|
205
|
+
export var addBulkToTarget = function (blockStructure, targetId, bulkIds // componentBlockId
|
206
|
+
) {
|
207
|
+
var structure = deepClone(blockStructure);
|
208
|
+
var targetBlock = findBlockByBlockId(structure, targetId);
|
209
|
+
if (!targetBlock || targetBlock.type !== 'GROUP_BLOCK' || !targetBlock.children) {
|
210
|
+
return blockStructure;
|
211
|
+
}
|
212
|
+
var bulkBlocks = targetBlock.children.filter(function (child) {
|
213
|
+
if (child.type === 'COMPONENT_BLOCK' && bulkIds.includes(child.blockId.toString())) {
|
214
|
+
return true;
|
215
|
+
}
|
216
|
+
if (child.type === 'GROUP_BLOCK' && bulkIds.includes(child.blockId)) {
|
217
|
+
return true;
|
218
|
+
}
|
219
|
+
return false;
|
220
|
+
});
|
221
|
+
if (bulkBlocks.length !== bulkIds.length) {
|
222
|
+
window.alert('Some bulkIds do not exist as children of the target block.');
|
223
|
+
console.log('bulkBLocks: ', bulkBlocks);
|
224
|
+
console.log('bulkIds: ', bulkIds);
|
225
|
+
return blockStructure;
|
226
|
+
}
|
227
|
+
if (bulkBlocks.length === 0) {
|
228
|
+
return blockStructure;
|
229
|
+
}
|
230
|
+
// Remove bulk blocks from target's children
|
231
|
+
targetBlock.children = targetBlock.children.filter(function (child) { return !bulkIds.includes(child.blockId); });
|
232
|
+
// Create the new bulkBlock
|
233
|
+
var bulkBlock = {
|
234
|
+
blockId: 'BULK',
|
235
|
+
type: 'GROUP_BLOCK',
|
236
|
+
zOrderDesktopInternal: zIndexMap.BULK,
|
237
|
+
zOrderMobileInternal: zIndexMap.BULK,
|
238
|
+
children: bulkBlocks,
|
239
|
+
};
|
240
|
+
// Add the bulkBlock to the target's children
|
241
|
+
targetBlock.children.push(bulkBlock);
|
242
|
+
return structure;
|
183
243
|
};
|
184
244
|
export var getBlockWorkDirPath = function (blockStructure, blockId) {
|
185
245
|
var findPath = function (blocks, id, path) {
|
186
|
-
for (var _i = 0,
|
187
|
-
var block =
|
246
|
+
for (var _i = 0, blocks_5 = blocks; _i < blocks_5.length; _i++) {
|
247
|
+
var block = blocks_5[_i];
|
188
248
|
var currentPath = __spreadArray(__spreadArray([], path, true), [block.blockId], false);
|
189
249
|
if (block.blockId === id) {
|
190
250
|
return currentPath;
|
@@ -198,15 +258,182 @@ export var getBlockWorkDirPath = function (blockStructure, blockId) {
|
|
198
258
|
}
|
199
259
|
return null;
|
200
260
|
};
|
201
|
-
var path = findPath(blockStructure
|
261
|
+
var path = findPath(blockStructure, blockId, ['']);
|
202
262
|
return path ? path.join('/') : null;
|
203
263
|
};
|
264
|
+
export var getBlockIdByComponentId = function (blockStructure, componentId) {
|
265
|
+
var findBlock = function (blocks) {
|
266
|
+
for (var _i = 0, blocks_6 = blocks; _i < blocks_6.length; _i++) {
|
267
|
+
var block = blocks_6[_i];
|
268
|
+
if (block.type === 'COMPONENT_BLOCK' && block.componentBlockId === componentId) {
|
269
|
+
return block.blockId;
|
270
|
+
}
|
271
|
+
if ('children' in block && block.children) {
|
272
|
+
var result = findBlock(block.children);
|
273
|
+
if (result) {
|
274
|
+
return result;
|
275
|
+
}
|
276
|
+
}
|
277
|
+
}
|
278
|
+
return null;
|
279
|
+
};
|
280
|
+
return findBlock(blockStructure);
|
281
|
+
};
|
282
|
+
export var blockStructure = [
|
283
|
+
{
|
284
|
+
blockId: 'ROOT',
|
285
|
+
type: 'GROUP_BLOCK',
|
286
|
+
zOrderDesktopInternal: null,
|
287
|
+
zOrderMobileInternal: null,
|
288
|
+
children: [
|
289
|
+
{
|
290
|
+
blockId: 'GB_2',
|
291
|
+
type: 'GROUP_BLOCK',
|
292
|
+
zOrderDesktopInternal: null,
|
293
|
+
zOrderMobileInternal: null,
|
294
|
+
children: [
|
295
|
+
{
|
296
|
+
blockId: 'GB_3',
|
297
|
+
type: 'GROUP_BLOCK',
|
298
|
+
zOrderDesktopInternal: null,
|
299
|
+
zOrderMobileInternal: null,
|
300
|
+
children: [
|
301
|
+
{
|
302
|
+
blockId: 'CB_4',
|
303
|
+
type: 'COMPONENT_BLOCK',
|
304
|
+
zOrderDesktopInternal: null,
|
305
|
+
zOrderMobileInternal: null,
|
306
|
+
componentBlockId: 4
|
307
|
+
},
|
308
|
+
{
|
309
|
+
blockId: 'CB_5',
|
310
|
+
type: 'COMPONENT_BLOCK',
|
311
|
+
zOrderDesktopInternal: null,
|
312
|
+
zOrderMobileInternal: null,
|
313
|
+
componentBlockId: 5
|
314
|
+
},
|
315
|
+
{
|
316
|
+
blockId: 'GB_6',
|
317
|
+
type: 'GROUP_BLOCK',
|
318
|
+
zOrderDesktopInternal: null,
|
319
|
+
zOrderMobileInternal: null,
|
320
|
+
children: [
|
321
|
+
{
|
322
|
+
blockId: 'CB_7',
|
323
|
+
type: 'COMPONENT_BLOCK',
|
324
|
+
zOrderDesktopInternal: null,
|
325
|
+
zOrderMobileInternal: null,
|
326
|
+
componentBlockId: 7
|
327
|
+
},
|
328
|
+
{
|
329
|
+
blockId: 'CB_8',
|
330
|
+
type: 'COMPONENT_BLOCK',
|
331
|
+
zOrderDesktopInternal: null,
|
332
|
+
zOrderMobileInternal: null,
|
333
|
+
componentBlockId: 8
|
334
|
+
},
|
335
|
+
{
|
336
|
+
blockId: 'GB_9',
|
337
|
+
type: 'GROUP_BLOCK',
|
338
|
+
zOrderDesktopInternal: null,
|
339
|
+
zOrderMobileInternal: null,
|
340
|
+
children: [
|
341
|
+
{
|
342
|
+
blockId: 'CB_10',
|
343
|
+
type: 'COMPONENT_BLOCK',
|
344
|
+
zOrderDesktopInternal: null,
|
345
|
+
zOrderMobileInternal: null,
|
346
|
+
componentBlockId: 10
|
347
|
+
},
|
348
|
+
{
|
349
|
+
blockId: 'CB_11',
|
350
|
+
type: 'COMPONENT_BLOCK',
|
351
|
+
zOrderDesktopInternal: null,
|
352
|
+
zOrderMobileInternal: null,
|
353
|
+
componentBlockId: 11
|
354
|
+
}
|
355
|
+
]
|
356
|
+
}
|
357
|
+
]
|
358
|
+
}
|
359
|
+
]
|
360
|
+
},
|
361
|
+
{
|
362
|
+
blockId: 'GB_12',
|
363
|
+
type: 'GROUP_BLOCK',
|
364
|
+
zOrderDesktopInternal: null,
|
365
|
+
zOrderMobileInternal: null,
|
366
|
+
children: [
|
367
|
+
{
|
368
|
+
blockId: 'CB_13',
|
369
|
+
type: 'COMPONENT_BLOCK',
|
370
|
+
zOrderDesktopInternal: null,
|
371
|
+
zOrderMobileInternal: null,
|
372
|
+
componentBlockId: 13
|
373
|
+
},
|
374
|
+
{
|
375
|
+
blockId: 'CB_14',
|
376
|
+
type: 'COMPONENT_BLOCK',
|
377
|
+
zOrderDesktopInternal: null,
|
378
|
+
zOrderMobileInternal: null,
|
379
|
+
componentBlockId: 14
|
380
|
+
}
|
381
|
+
]
|
382
|
+
},
|
383
|
+
{
|
384
|
+
blockId: 'CB_15',
|
385
|
+
type: 'COMPONENT_BLOCK',
|
386
|
+
zOrderDesktopInternal: null,
|
387
|
+
zOrderMobileInternal: null,
|
388
|
+
componentBlockId: 15
|
389
|
+
},
|
390
|
+
{
|
391
|
+
blockId: 'CB_16',
|
392
|
+
type: 'COMPONENT_BLOCK',
|
393
|
+
zOrderDesktopInternal: null,
|
394
|
+
zOrderMobileInternal: null,
|
395
|
+
componentBlockId: 16
|
396
|
+
}
|
397
|
+
]
|
398
|
+
},
|
399
|
+
{
|
400
|
+
blockId: 'GB_17',
|
401
|
+
type: 'GROUP_BLOCK',
|
402
|
+
zOrderDesktopInternal: null,
|
403
|
+
zOrderMobileInternal: null,
|
404
|
+
children: [
|
405
|
+
{
|
406
|
+
blockId: 'CB_18',
|
407
|
+
type: 'COMPONENT_BLOCK',
|
408
|
+
zOrderDesktopInternal: null,
|
409
|
+
zOrderMobileInternal: null,
|
410
|
+
componentBlockId: 18
|
411
|
+
}
|
412
|
+
]
|
413
|
+
},
|
414
|
+
{
|
415
|
+
blockId: 'CB_19',
|
416
|
+
type: 'COMPONENT_BLOCK',
|
417
|
+
zOrderDesktopInternal: null,
|
418
|
+
zOrderMobileInternal: null,
|
419
|
+
componentBlockId: 19
|
420
|
+
},
|
421
|
+
{
|
422
|
+
blockId: 'CB_20',
|
423
|
+
type: 'COMPONENT_BLOCK',
|
424
|
+
zOrderDesktopInternal: null,
|
425
|
+
zOrderMobileInternal: null,
|
426
|
+
componentBlockId: 20
|
427
|
+
}
|
428
|
+
]
|
429
|
+
}
|
430
|
+
];
|
204
431
|
export var mapComponentBlockIdsToBlockIds = function (blockStructure) {
|
205
432
|
var cbToBlockMap = {};
|
206
433
|
var blockToCbMap = {};
|
207
434
|
var traverse = function (blocks) {
|
208
|
-
for (var _i = 0,
|
209
|
-
var block =
|
435
|
+
for (var _i = 0, blocks_7 = blocks; _i < blocks_7.length; _i++) {
|
436
|
+
var block = blocks_7[_i];
|
210
437
|
if (block.type === 'COMPONENT_BLOCK') {
|
211
438
|
cbToBlockMap[block.componentBlockId] = block.blockId;
|
212
439
|
blockToCbMap[block.blockId] = block.componentBlockId;
|
@@ -216,63 +443,39 @@ export var mapComponentBlockIdsToBlockIds = function (blockStructure) {
|
|
216
443
|
}
|
217
444
|
}
|
218
445
|
};
|
219
|
-
traverse(blockStructure
|
446
|
+
traverse(blockStructure);
|
220
447
|
return { CB_ID: cbToBlockMap, BLOCK_ID: blockToCbMap };
|
221
448
|
};
|
222
|
-
export var
|
223
|
-
var
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
449
|
+
export var findAccessibleChildrenBlocks = function (blockStructure, targetGroupId, blockIds) {
|
450
|
+
var targetBlock = findBlockByBlockId(blockStructure, targetGroupId);
|
451
|
+
if (!targetBlock || !('children' in targetBlock) || !targetBlock.children) {
|
452
|
+
return [];
|
453
|
+
}
|
454
|
+
var result = new Set();
|
455
|
+
var traverse = function (block, rootId) {
|
456
|
+
if ('children' in block && block.children) {
|
457
|
+
for (var _i = 0, _a = block.children; _i < _a.length; _i++) {
|
458
|
+
var child = _a[_i];
|
459
|
+
if (blockIds.includes(child.blockId)) {
|
460
|
+
result.add(rootId);
|
461
|
+
return true; // Stop traversal for this branch
|
462
|
+
}
|
463
|
+
if (traverse(child, rootId)) {
|
464
|
+
result.add(rootId);
|
465
|
+
return true; // Stop traversal for this branch
|
233
466
|
}
|
234
467
|
}
|
235
468
|
}
|
236
|
-
return
|
469
|
+
return false;
|
237
470
|
};
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
)
|
242
|
-
var structure = deepClone(block);
|
243
|
-
var targetBlock = findBlockByBlockId(structure, targetId);
|
244
|
-
if (!targetBlock || targetBlock.type !== 'GROUP_BLOCK' || !targetBlock.children) {
|
245
|
-
return block;
|
246
|
-
}
|
247
|
-
var bulkBlocks = targetBlock.children.filter(function (child) {
|
248
|
-
if (child.type === 'COMPONENT_BLOCK' && bulkIds.includes(child.blockId)) {
|
249
|
-
return true;
|
471
|
+
for (var _i = 0, _a = targetBlock.children; _i < _a.length; _i++) {
|
472
|
+
var child = _a[_i];
|
473
|
+
if (blockIds.includes(child.blockId)) {
|
474
|
+
result.add(child.blockId);
|
250
475
|
}
|
251
|
-
|
252
|
-
|
476
|
+
else {
|
477
|
+
traverse(child, child.blockId);
|
253
478
|
}
|
254
|
-
return false;
|
255
|
-
});
|
256
|
-
if (bulkBlocks.length !== bulkIds.length) {
|
257
|
-
window.alert('Some bulkIds do not exist as children of the target block.');
|
258
|
-
console.log('bulkBlocks: ', bulkBlocks);
|
259
|
-
console.log('bulkIds: ', bulkIds);
|
260
|
-
return block;
|
261
|
-
}
|
262
|
-
if (bulkBlocks.length === 0) {
|
263
|
-
return block;
|
264
479
|
}
|
265
|
-
|
266
|
-
targetBlock.children = targetBlock.children.filter(function (child) { return !bulkIds.includes(child.blockId); });
|
267
|
-
// Create the new bulkBlock
|
268
|
-
var bulkBlock = {
|
269
|
-
blockId: 'BULK',
|
270
|
-
type: 'GROUP_BLOCK',
|
271
|
-
zOrderDesktopInternal: zIndexMap.BULK,
|
272
|
-
zOrderMobileInternal: zIndexMap.BULK,
|
273
|
-
children: bulkBlocks,
|
274
|
-
};
|
275
|
-
// Add the bulkBlock to the target's children
|
276
|
-
targetBlock.children.push(bulkBlock);
|
277
|
-
return structure;
|
480
|
+
return Array.from(result);
|
278
481
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "publ-echo-test",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.112",
|
4
4
|
"private": false,
|
5
5
|
"main": "dist/lib/index.js",
|
6
6
|
"types": "dist/lib/index.d.js",
|
@@ -52,5 +52,8 @@
|
|
52
52
|
"styled-components": "^5.3.10",
|
53
53
|
"typescript": "^5.1.6",
|
54
54
|
"web-vitals": "^2.1.4"
|
55
|
+
},
|
56
|
+
"dependencies": {
|
57
|
+
"pds-dev-kit-web-test": "^2.5.67"
|
55
58
|
}
|
56
59
|
}
|