publ-echo-test 0.0.108 → 0.0.110
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.
@@ -40,21 +40,19 @@ 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
|
54
|
-
export declare const getBlockIdByComponentId: (blockStructure: Block[], componentId: number) => string | null;
|
55
|
-
export declare const blockStructure: Block[];
|
56
|
-
export declare const mapComponentBlockIdsToBlockIds: (blockStructure: Block[]) => {
|
43
|
+
export declare const findBlockByBlockId: (block: RootBlock, blockId: string) => Block | null;
|
44
|
+
export declare const findChildrenComponentIds: (block: RootBlock, targetId: string) => string[];
|
45
|
+
export declare const findAllChildrenIds: (block: RootBlock, targetId: string, depth?: 'current' | 'deep') => string[];
|
46
|
+
export declare const findAllChildrenComponentIds: (block: RootBlock, targetId: string) => number[];
|
47
|
+
export declare const findAllParentGroups: (block: RootBlock, targetId: string) => GroupBlock[];
|
48
|
+
export declare const findGroupBlocks: (block: RootBlock, targetId: string) => GroupBlock[];
|
49
|
+
export declare const findAllComponentBlockIds: (block: RootBlock) => number[];
|
50
|
+
export declare const findParentGroupByGroupId: (block: RootBlock, targetId: string) => string | null;
|
51
|
+
export declare const addBlockToRoot: (block: RootBlock, newBlock: Block) => RootBlock;
|
52
|
+
export declare const getBlockWorkDirPath: (blockStructure: RootBlock, blockId: string) => string | null;
|
53
|
+
export declare const mapComponentBlockIdsToBlockIds: (blockStructure: RootBlock) => {
|
57
54
|
CB_ID: Record<number, string>;
|
58
55
|
BLOCK_ID: Record<string, number>;
|
59
56
|
};
|
60
|
-
export declare const
|
57
|
+
export declare const getBlockIdByComponentId: (block: RootBlock, componentId: number) => string | null;
|
58
|
+
export declare const addBulkToTarget: (block: RootBlock, targetId: string, bulkIds: string[]) => RootBlock;
|
@@ -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 (block) { return JSON.parse(JSON.stringify(block)); };
|
38
|
+
export var findBlockByBlockId = function (block, blockId) {
|
39
|
+
for (var _i = 0, _a = block.children; _i < _a.length; _i++) {
|
40
|
+
var child = _a[_i];
|
41
|
+
if (child.blockId === blockId) {
|
42
|
+
return child;
|
43
43
|
}
|
44
|
-
if (
|
45
|
-
var found = findBlockByBlockId(
|
44
|
+
if (child.type === 'GROUP_BLOCK' && child.children) {
|
45
|
+
var found = findBlockByBlockId({ blockId: "ROOT", type: "GROUP_BLOCK", zOrderDesktopInternal: null, zOrderMobileInternal: null, children: child.children }, blockId);
|
46
46
|
if (found) {
|
47
47
|
return found;
|
48
48
|
}
|
@@ -50,15 +50,15 @@ export var findBlockByBlockId = function (blocks, blockId) {
|
|
50
50
|
}
|
51
51
|
return null;
|
52
52
|
};
|
53
|
-
export var findChildrenComponentIds = function (
|
54
|
-
var targetBlock = findBlockByBlockId(
|
53
|
+
export var findChildrenComponentIds = function (block, targetId) {
|
54
|
+
var targetBlock = findBlockByBlockId(block, 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 (block, 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 (blockStructure, targetId, depth) {
|
|
73
73
|
}
|
74
74
|
return ids;
|
75
75
|
};
|
76
|
-
var targetBlock = findBlockByBlockId(
|
76
|
+
var targetBlock = findBlockByBlockId(block, targetId);
|
77
77
|
return targetBlock ? collectChildrenIds(targetBlock) : [];
|
78
78
|
};
|
79
|
-
export var findAllChildrenComponentIds = function (
|
79
|
+
export var findAllChildrenComponentIds = function (block, 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 (blockStructure, targetId) {
|
|
90
90
|
}
|
91
91
|
return ids;
|
92
92
|
};
|
93
|
-
var targetBlock = findBlockByBlockId(
|
93
|
+
var targetBlock = findBlockByBlockId(block, targetId);
|
94
94
|
return targetBlock ? collectComponentIds(targetBlock) : [];
|
95
95
|
};
|
96
|
-
export var findAllParentGroups = function (
|
96
|
+
export var findAllParentGroups = function (block, 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_1 = blocks; _i < blocks_1.length; _i++) {
|
100
|
+
var block_1 = blocks_1[_i];
|
101
|
+
if (block_1.blockId === id && block_1.type === 'GROUP_BLOCK') {
|
102
102
|
return parents;
|
103
103
|
}
|
104
|
-
if ('children' in
|
105
|
-
var result = findParentGroups(
|
104
|
+
if ('children' in block_1 && block_1.children) {
|
105
|
+
var result = findParentGroups(block_1.children, id, block_1.type === 'GROUP_BLOCK' ? __spreadArray(__spreadArray([], parents, true), [block_1], false) : parents);
|
106
106
|
if (result) {
|
107
107
|
return result;
|
108
108
|
}
|
@@ -110,26 +110,10 @@ export var findAllParentGroups = function (blockStructure, targetId) {
|
|
110
110
|
}
|
111
111
|
return null;
|
112
112
|
};
|
113
|
-
return findParentGroups(
|
113
|
+
return findParentGroups(block.children, targetId) || [];
|
114
114
|
};
|
115
|
-
|
116
|
-
|
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);
|
115
|
+
export var findGroupBlocks = function (block, targetId) {
|
116
|
+
var targetBlock = findBlockByBlockId(block, targetId);
|
133
117
|
var groupBlocks = [];
|
134
118
|
if (targetBlock && targetBlock.blockId === 'ROOT') {
|
135
119
|
if ('children' in targetBlock) {
|
@@ -159,32 +143,32 @@ export var findGroupBlocks = function (blockStructure, targetId) {
|
|
159
143
|
}
|
160
144
|
return groupBlocks;
|
161
145
|
};
|
162
|
-
export var findAllComponentBlockIds = function (
|
146
|
+
export var findAllComponentBlockIds = function (block) {
|
163
147
|
var collectComponentBlockIds = function (blocks) {
|
164
148
|
var ids = [];
|
165
|
-
for (var _i = 0,
|
166
|
-
var
|
167
|
-
if (
|
168
|
-
ids.push(
|
149
|
+
for (var _i = 0, blocks_2 = blocks; _i < blocks_2.length; _i++) {
|
150
|
+
var block_2 = blocks_2[_i];
|
151
|
+
if (block_2.type === 'COMPONENT_BLOCK') {
|
152
|
+
ids.push(block_2.componentBlockId);
|
169
153
|
}
|
170
|
-
if ('children' in
|
171
|
-
ids = ids.concat(collectComponentBlockIds(
|
154
|
+
if ('children' in block_2 && block_2.children) {
|
155
|
+
ids = ids.concat(collectComponentBlockIds(block_2.children));
|
172
156
|
}
|
173
157
|
}
|
174
158
|
return ids;
|
175
159
|
};
|
176
|
-
return collectComponentBlockIds(
|
160
|
+
return collectComponentBlockIds(block.children);
|
177
161
|
};
|
178
|
-
export var findParentGroupByGroupId = function (
|
162
|
+
export var findParentGroupByGroupId = function (block, targetId) {
|
179
163
|
var findParentGroup = function (blocks, id, parent) {
|
180
164
|
if (parent === void 0) { parent = null; }
|
181
|
-
for (var _i = 0,
|
182
|
-
var
|
183
|
-
if (
|
165
|
+
for (var _i = 0, blocks_3 = blocks; _i < blocks_3.length; _i++) {
|
166
|
+
var block_3 = blocks_3[_i];
|
167
|
+
if (block_3.blockId === id && block_3.type === 'GROUP_BLOCK') {
|
184
168
|
return parent ? parent.blockId : null;
|
185
169
|
}
|
186
|
-
if ('children' in
|
187
|
-
var result = findParentGroup(
|
170
|
+
if ('children' in block_3 && block_3.children) {
|
171
|
+
var result = findParentGroup(block_3.children, id, block_3.type === 'GROUP_BLOCK' ? block_3 : parent);
|
188
172
|
if (result) {
|
189
173
|
return result;
|
190
174
|
}
|
@@ -192,59 +176,15 @@ export var findParentGroupByGroupId = function (blockStructure, targetId) {
|
|
192
176
|
}
|
193
177
|
return null;
|
194
178
|
};
|
195
|
-
return findParentGroup(
|
179
|
+
return findParentGroup(block.children, targetId);
|
196
180
|
};
|
197
|
-
export var addBlockToRoot = function (
|
198
|
-
return
|
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;
|
181
|
+
export var addBlockToRoot = function (block, newBlock) {
|
182
|
+
return __assign(__assign({}, block), { children: __spreadArray(__spreadArray([], block.children, true), [newBlock], false) });
|
243
183
|
};
|
244
184
|
export var getBlockWorkDirPath = function (blockStructure, blockId) {
|
245
185
|
var findPath = function (blocks, id, path) {
|
246
|
-
for (var _i = 0,
|
247
|
-
var block =
|
186
|
+
for (var _i = 0, blocks_4 = blocks; _i < blocks_4.length; _i++) {
|
187
|
+
var block = blocks_4[_i];
|
248
188
|
var currentPath = __spreadArray(__spreadArray([], path, true), [block.blockId], false);
|
249
189
|
if (block.blockId === id) {
|
250
190
|
return currentPath;
|
@@ -258,182 +198,15 @@ export var getBlockWorkDirPath = function (blockStructure, blockId) {
|
|
258
198
|
}
|
259
199
|
return null;
|
260
200
|
};
|
261
|
-
var path = findPath(blockStructure, blockId, ['']);
|
201
|
+
var path = findPath(blockStructure.children, blockId, ['']);
|
262
202
|
return path ? path.join('/') : null;
|
263
203
|
};
|
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
|
-
];
|
431
204
|
export var mapComponentBlockIdsToBlockIds = function (blockStructure) {
|
432
205
|
var cbToBlockMap = {};
|
433
206
|
var blockToCbMap = {};
|
434
207
|
var traverse = function (blocks) {
|
435
|
-
for (var _i = 0,
|
436
|
-
var block =
|
208
|
+
for (var _i = 0, blocks_5 = blocks; _i < blocks_5.length; _i++) {
|
209
|
+
var block = blocks_5[_i];
|
437
210
|
if (block.type === 'COMPONENT_BLOCK') {
|
438
211
|
cbToBlockMap[block.componentBlockId] = block.blockId;
|
439
212
|
blockToCbMap[block.blockId] = block.componentBlockId;
|
@@ -443,39 +216,63 @@ export var mapComponentBlockIdsToBlockIds = function (blockStructure) {
|
|
443
216
|
}
|
444
217
|
}
|
445
218
|
};
|
446
|
-
traverse(blockStructure);
|
219
|
+
traverse(blockStructure.children);
|
447
220
|
return { CB_ID: cbToBlockMap, BLOCK_ID: blockToCbMap };
|
448
221
|
};
|
449
|
-
export var
|
450
|
-
var
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
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
|
222
|
+
export var getBlockIdByComponentId = function (block, componentId) {
|
223
|
+
var findBlock = function (blocks) {
|
224
|
+
for (var _i = 0, blocks_6 = blocks; _i < blocks_6.length; _i++) {
|
225
|
+
var block_4 = blocks_6[_i];
|
226
|
+
if (block_4.type === 'COMPONENT_BLOCK' && block_4.componentBlockId === componentId) {
|
227
|
+
return block_4.blockId;
|
228
|
+
}
|
229
|
+
if ('children' in block_4 && block_4.children) {
|
230
|
+
var result = findBlock(block_4.children);
|
231
|
+
if (result) {
|
232
|
+
return result;
|
466
233
|
}
|
467
234
|
}
|
468
235
|
}
|
469
|
-
return
|
236
|
+
return null;
|
470
237
|
};
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
238
|
+
return findBlock(block.children);
|
239
|
+
};
|
240
|
+
export var addBulkToTarget = function (block, targetId, bulkIds // componentBlockId
|
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;
|
475
250
|
}
|
476
|
-
|
477
|
-
|
251
|
+
if (child.type === 'GROUP_BLOCK' && bulkIds.includes(child.blockId)) {
|
252
|
+
return true;
|
478
253
|
}
|
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;
|
479
264
|
}
|
480
|
-
|
265
|
+
// Remove bulk blocks from target's children
|
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;
|
481
278
|
};
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { DragEvent, ReactElement, RefObject } from "react";
|
2
2
|
import { ResizeHandleAxis, ResizeHandleType } from "../Resizable/types";
|
3
3
|
import { ResizeEventType } from "../GridItem/types";
|
4
|
-
import {
|
4
|
+
import { RootBlock } from "./group";
|
5
5
|
export type CompactType = "vertical" | "horizontal";
|
6
6
|
export type LayoutItem = {
|
7
7
|
w: number;
|
@@ -79,7 +79,7 @@ export type ReactGridLayoutProps = {
|
|
79
79
|
minNbRow?: number;
|
80
80
|
customColWidth?: number;
|
81
81
|
onFitToContent?: OnFitContentCallBack;
|
82
|
-
blockStructure?:
|
82
|
+
blockStructure?: RootBlock;
|
83
83
|
onDoubleClickGroup?: (e: React.MouseEvent, id: string, type: string) => void;
|
84
84
|
selectedGroupBlock?: 'ROOT' | string;
|
85
85
|
editingGroupBlock?: 'ROOT' | string;
|