publ-echo-test 0.0.107 → 0.0.109
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.
@@ -2,7 +2,5 @@ import * as React from "react";
|
|
2
2
|
import type { ReactElement } from "react";
|
3
3
|
import { PropsWithChildren } from "../types";
|
4
4
|
import { ReactGridLayoutProps } from "./types";
|
5
|
-
declare const ReactGridLayout: ({ children, ...props }: PropsWithChildren<ReactGridLayoutProps
|
6
|
-
onContextGroup?: ((e: React.MouseEvent, blockId: string, isEditingGroup: boolean) => void) | undefined;
|
7
|
-
}>) => React.ReactElement;
|
5
|
+
declare const ReactGridLayout: ({ children, ...props }: PropsWithChildren<ReactGridLayoutProps>) => React.ReactElement;
|
8
6
|
export default ReactGridLayout;
|
@@ -40,21 +40,14 @@ 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[]) => {
|
57
|
-
CB_ID: Record<number, string>;
|
58
|
-
BLOCK_ID: Record<string, number>;
|
59
|
-
};
|
60
|
-
export declare const findAccessibleChildrenBlocks: (blockStructure: Block[], targetGroupId: string, blockIds: string[]) => string[];
|
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 getBlockIdByComponentId: (block: RootBlock, componentId: number) => string | null;
|
53
|
+
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,25 +176,38 @@ 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
|
-
|
200
|
-
|
181
|
+
export var addBlockToRoot = function (block, newBlock) {
|
182
|
+
return __assign(__assign({}, block), { children: __spreadArray(__spreadArray([], block.children, true), [newBlock], false) });
|
183
|
+
};
|
184
|
+
export var getBlockIdByComponentId = function (block, componentId) {
|
185
|
+
var findBlock = function (blocks) {
|
186
|
+
for (var _i = 0, blocks_4 = blocks; _i < blocks_4.length; _i++) {
|
187
|
+
var block_4 = blocks_4[_i];
|
188
|
+
if (block_4.type === 'COMPONENT_BLOCK' && block_4.componentBlockId === componentId) {
|
189
|
+
return block_4.blockId;
|
190
|
+
}
|
191
|
+
if ('children' in block_4 && block_4.children) {
|
192
|
+
var result = findBlock(block_4.children);
|
193
|
+
if (result) {
|
194
|
+
return result;
|
195
|
+
}
|
196
|
+
}
|
201
197
|
}
|
202
|
-
return
|
203
|
-
}
|
198
|
+
return null;
|
199
|
+
};
|
200
|
+
return findBlock(block.children);
|
204
201
|
};
|
205
|
-
export var addBulkToTarget = function (
|
202
|
+
export var addBulkToTarget = function (block, targetId, bulkIds // componentBlockId
|
206
203
|
) {
|
207
|
-
var structure = deepClone(
|
204
|
+
var structure = deepClone(block);
|
208
205
|
var targetBlock = findBlockByBlockId(structure, targetId);
|
209
206
|
if (!targetBlock || targetBlock.type !== 'GROUP_BLOCK' || !targetBlock.children) {
|
210
|
-
return
|
207
|
+
return block;
|
211
208
|
}
|
212
209
|
var bulkBlocks = targetBlock.children.filter(function (child) {
|
213
|
-
if (child.type === 'COMPONENT_BLOCK' && bulkIds.includes(child.blockId
|
210
|
+
if (child.type === 'COMPONENT_BLOCK' && bulkIds.includes(child.blockId)) {
|
214
211
|
return true;
|
215
212
|
}
|
216
213
|
if (child.type === 'GROUP_BLOCK' && bulkIds.includes(child.blockId)) {
|
@@ -220,12 +217,12 @@ export var addBulkToTarget = function (blockStructure, targetId, bulkIds // comp
|
|
220
217
|
});
|
221
218
|
if (bulkBlocks.length !== bulkIds.length) {
|
222
219
|
window.alert('Some bulkIds do not exist as children of the target block.');
|
223
|
-
console.log('
|
220
|
+
console.log('bulkBlocks: ', bulkBlocks);
|
224
221
|
console.log('bulkIds: ', bulkIds);
|
225
|
-
return
|
222
|
+
return block;
|
226
223
|
}
|
227
224
|
if (bulkBlocks.length === 0) {
|
228
|
-
return
|
225
|
+
return block;
|
229
226
|
}
|
230
227
|
// Remove bulk blocks from target's children
|
231
228
|
targetBlock.children = targetBlock.children.filter(function (child) { return !bulkIds.includes(child.blockId); });
|
@@ -241,241 +238,3 @@ export var addBulkToTarget = function (blockStructure, targetId, bulkIds // comp
|
|
241
238
|
targetBlock.children.push(bulkBlock);
|
242
239
|
return structure;
|
243
240
|
};
|
244
|
-
export var getBlockWorkDirPath = function (blockStructure, blockId) {
|
245
|
-
var findPath = function (blocks, id, path) {
|
246
|
-
for (var _i = 0, blocks_5 = blocks; _i < blocks_5.length; _i++) {
|
247
|
-
var block = blocks_5[_i];
|
248
|
-
var currentPath = __spreadArray(__spreadArray([], path, true), [block.blockId], false);
|
249
|
-
if (block.blockId === id) {
|
250
|
-
return currentPath;
|
251
|
-
}
|
252
|
-
if ('children' in block && block.children) {
|
253
|
-
var result = findPath(block.children, id, currentPath);
|
254
|
-
if (result) {
|
255
|
-
return result;
|
256
|
-
}
|
257
|
-
}
|
258
|
-
}
|
259
|
-
return null;
|
260
|
-
};
|
261
|
-
var path = findPath(blockStructure, blockId, ['']);
|
262
|
-
return path ? path.join('/') : null;
|
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
|
-
];
|
431
|
-
export var mapComponentBlockIdsToBlockIds = function (blockStructure) {
|
432
|
-
var cbToBlockMap = {};
|
433
|
-
var blockToCbMap = {};
|
434
|
-
var traverse = function (blocks) {
|
435
|
-
for (var _i = 0, blocks_7 = blocks; _i < blocks_7.length; _i++) {
|
436
|
-
var block = blocks_7[_i];
|
437
|
-
if (block.type === 'COMPONENT_BLOCK') {
|
438
|
-
cbToBlockMap[block.componentBlockId] = block.blockId;
|
439
|
-
blockToCbMap[block.blockId] = block.componentBlockId;
|
440
|
-
}
|
441
|
-
if ('children' in block && block.children) {
|
442
|
-
traverse(block.children);
|
443
|
-
}
|
444
|
-
}
|
445
|
-
};
|
446
|
-
traverse(blockStructure);
|
447
|
-
return { CB_ID: cbToBlockMap, BLOCK_ID: blockToCbMap };
|
448
|
-
};
|
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
|
466
|
-
}
|
467
|
-
}
|
468
|
-
}
|
469
|
-
return false;
|
470
|
-
};
|
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);
|
475
|
-
}
|
476
|
-
else {
|
477
|
-
traverse(child, child.blockId);
|
478
|
-
}
|
479
|
-
}
|
480
|
-
return Array.from(result);
|
481
|
-
};
|
@@ -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,13 +79,14 @@ 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;
|
86
86
|
onClickGroup?: (e: React.MouseEvent, id: string, type: string) => void;
|
87
87
|
bulkIds?: string[];
|
88
88
|
onDoubleClickOutsideGroup: () => void;
|
89
|
+
onContextGroup?: (e: React.MouseEvent, blockId: string, isEditingGroup: boolean) => void;
|
89
90
|
};
|
90
91
|
export type DragOverEvent = MouseEvent & {
|
91
92
|
nativeEvent: {
|