publ-echo-test 0.0.114 → 0.0.116
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.
@@ -37,7 +37,7 @@ import { bottom, cloneLayoutItem, compact, getAllCollisions, getBoundingArea, ge
|
|
37
37
|
import { calcGridColWidth, calcXY, resolveRowHeight, } from "../GridItem/utils/calculateUtils";
|
38
38
|
import GridItem from "../GridItem/GridItem";
|
39
39
|
import isEqual from "../../external-lib/lodash.isEqual";
|
40
|
-
import {
|
40
|
+
import { findAllChildrenCbIds, findDirectChildrenBlockIds, findGroupBlocks, formatBlockIdToCbId, getBlockSpecificType, zIndexMap } from "./group";
|
41
41
|
import GroupItem from "../GridItem/GroupItem";
|
42
42
|
import OutsideClickHandler from "../GridItem/OutsideClickHandler";
|
43
43
|
var layoutClassName = "react-grid-layout";
|
@@ -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 ?
|
61
|
-
var editingGroupAllChildren = (blockStructure && editingGroupBlock) ?
|
60
|
+
var editableItems = blockStructure ? findDirectChildrenBlockIds(blockStructure, editingGroupBlock) : [];
|
61
|
+
var editingGroupAllChildren = (blockStructure && editingGroupBlock) ? findAllChildrenCbIds(blockStructure, 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 =
|
150
|
+
var childrenIds = findAllChildrenCbIds(blockStructure, 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 =
|
177
|
+
var children_2 = findDirectChildrenBlockIds(blockStructure, 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(
|
518
|
+
var isInBulk = blockStructure && (bulkIds === null || bulkIds === void 0 ? void 0 : bulkIds.includes(formatBlockIdToCbId(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(
|
547
|
+
var isInBulk = blockStructure && (bulkIds === null || bulkIds === void 0 ? void 0 : bulkIds.includes(formatBlockIdToCbId(Number(activeDrag === null || activeDrag === void 0 ? void 0 : activeDrag.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 =
|
642
|
+
var childrenIds = findAllChildrenCbIds(blockStructure, 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"
|
@@ -6,6 +6,7 @@ export declare const zIndexMap: {
|
|
6
6
|
ROOT: number;
|
7
7
|
};
|
8
8
|
export declare function getBlockSpecificType(block: Block): "ROOT" | "BULK" | "COMPONENT_BLOCK" | "GROUP_BLOCK";
|
9
|
+
export type SectionPedigree = RootBlock;
|
9
10
|
export type Block = ComponentBlock | GroupBlock | RootBlock;
|
10
11
|
export type ZOrder = {
|
11
12
|
[platform in "mobile" | "desktop"]: {
|
@@ -40,21 +41,13 @@ export type BulkBlockInternal = {
|
|
40
41
|
zOrderMobileInternal: number;
|
41
42
|
children: (ComponentBlock | GroupBlock)[];
|
42
43
|
};
|
43
|
-
export declare const findBlockByBlockId: (
|
44
|
-
export declare const
|
45
|
-
export declare const
|
46
|
-
export declare const
|
47
|
-
export declare const
|
48
|
-
export declare const findGroupBlocks: (blockStructure: Block
|
49
|
-
export declare const
|
50
|
-
export declare const
|
51
|
-
export declare
|
52
|
-
export declare
|
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[]) => {
|
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[];
|
44
|
+
export declare const findBlockByBlockId: (block: Block, blockId: string) => Block | null;
|
45
|
+
export declare const findDirectChildrenCbIds: (block: Block, targetId: string) => number[];
|
46
|
+
export declare const findAllChildrenCbIds: (block: Block, targetId: string) => number[];
|
47
|
+
export declare const findAllChildrenBlockIds: (block: Block, targetId: string) => string[];
|
48
|
+
export declare const findDirectChildrenBlockIds: (block: Block, targetId: string) => string[];
|
49
|
+
export declare const findGroupBlocks: (blockStructure: Block, targetId: string) => GroupBlock[];
|
50
|
+
export declare const addBulkToTarget: (block: Block, targetId: string, bulkBlockIds: string[]) => Block;
|
51
|
+
export declare const getBlockWorkDirPath: (block: Block, blockId: string) => string | null;
|
52
|
+
export declare function formatBlockIdToCbId(cbId: number): string;
|
53
|
+
export declare function formatCbIdToBlockId(cbId: number): string | null;
|
@@ -1,14 +1,3 @@
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
2
|
-
__assign = Object.assign || function(t) {
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
4
|
-
s = arguments[i];
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
6
|
-
t[p] = s[p];
|
7
|
-
}
|
8
|
-
return t;
|
9
|
-
};
|
10
|
-
return __assign.apply(this, arguments);
|
11
|
-
};
|
12
1
|
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
13
2
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
14
3
|
if (ar || !(i in from)) {
|
@@ -35,14 +24,45 @@ export function getBlockSpecificType(block) {
|
|
35
24
|
return block.type;
|
36
25
|
}
|
37
26
|
var deepClone = function (blocks) { return JSON.parse(JSON.stringify(blocks)); };
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
27
|
+
var collectChildrenCbIds = function (block, depth) {
|
28
|
+
var ids = [];
|
29
|
+
if ('children' in block && block.children) {
|
30
|
+
for (var _i = 0, _a = block.children; _i < _a.length; _i++) {
|
31
|
+
var child = _a[_i];
|
32
|
+
if (child.type === 'COMPONENT_BLOCK') {
|
33
|
+
ids.push(child.componentBlockId);
|
34
|
+
}
|
35
|
+
if (depth === 'deep' && child.type === 'GROUP_BLOCK') {
|
36
|
+
ids = ids.concat(collectChildrenCbIds(child, depth));
|
37
|
+
}
|
38
|
+
}
|
39
|
+
}
|
40
|
+
return ids;
|
41
|
+
};
|
42
|
+
var collectChildrenBlockIds = function (block, depth) {
|
43
|
+
var ids = [];
|
44
|
+
if ('children' in block && block.children) {
|
45
|
+
for (var _i = 0, _a = block.children; _i < _a.length; _i++) {
|
46
|
+
var child = _a[_i];
|
47
|
+
ids.push(child.blockId);
|
48
|
+
if (depth === 'deep') {
|
49
|
+
ids = ids.concat(collectChildrenBlockIds(child, depth));
|
50
|
+
}
|
51
|
+
}
|
52
|
+
}
|
53
|
+
return ids;
|
54
|
+
};
|
55
|
+
export var findBlockByBlockId = function (block, blockId) {
|
56
|
+
if (block.type !== 'GROUP_BLOCK' || block.children.length === 0) {
|
57
|
+
return null;
|
58
|
+
}
|
59
|
+
for (var _i = 0, _a = block.children; _i < _a.length; _i++) {
|
60
|
+
var child = _a[_i];
|
61
|
+
if (child.blockId === blockId) {
|
62
|
+
return child;
|
43
63
|
}
|
44
|
-
if (
|
45
|
-
var found = findBlockByBlockId(
|
64
|
+
if (child.type === 'GROUP_BLOCK' && child.children) {
|
65
|
+
var found = findBlockByBlockId(child, blockId);
|
46
66
|
if (found) {
|
47
67
|
return found;
|
48
68
|
}
|
@@ -50,84 +70,34 @@ export var findBlockByBlockId = function (blocks, blockId) {
|
|
50
70
|
}
|
51
71
|
return null;
|
52
72
|
};
|
53
|
-
export var
|
54
|
-
var targetBlock = findBlockByBlockId(
|
73
|
+
export var findDirectChildrenCbIds = function (block, targetId) {
|
74
|
+
var targetBlock = findBlockByBlockId(block, targetId);
|
55
75
|
if (!targetBlock || targetBlock.type !== 'GROUP_BLOCK') {
|
56
76
|
return [];
|
57
77
|
}
|
58
|
-
|
59
|
-
return blockCBChildren.map(function (cb) { return cb.componentBlockId.toString(); });
|
78
|
+
return collectChildrenCbIds(targetBlock, 'current');
|
60
79
|
};
|
61
|
-
export var
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
var child = _a[_i];
|
68
|
-
ids.push(child.blockId);
|
69
|
-
if (depth === 'deep') {
|
70
|
-
ids = ids.concat(collectChildrenIds(child));
|
71
|
-
}
|
72
|
-
}
|
73
|
-
}
|
74
|
-
return ids;
|
75
|
-
};
|
76
|
-
var targetBlock = findBlockByBlockId(blockStructure, targetId);
|
77
|
-
return targetBlock ? collectChildrenIds(targetBlock) : [];
|
80
|
+
export var findAllChildrenCbIds = function (block, targetId) {
|
81
|
+
var targetBlock = findBlockByBlockId(block, targetId);
|
82
|
+
if (!targetBlock || targetBlock.type !== 'GROUP_BLOCK') {
|
83
|
+
return [];
|
84
|
+
}
|
85
|
+
return collectChildrenCbIds(targetBlock, 'deep');
|
78
86
|
};
|
79
|
-
export var
|
80
|
-
var
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
if (child.type === 'COMPONENT_BLOCK') {
|
86
|
-
ids.push(child.componentBlockId);
|
87
|
-
}
|
88
|
-
ids = ids.concat(collectComponentIds(child));
|
89
|
-
}
|
90
|
-
}
|
91
|
-
return ids;
|
92
|
-
};
|
93
|
-
var targetBlock = findBlockByBlockId(blockStructure, targetId);
|
94
|
-
return targetBlock ? collectComponentIds(targetBlock) : [];
|
87
|
+
export var findAllChildrenBlockIds = function (block, targetId) {
|
88
|
+
var targetBlock = findBlockByBlockId(block, targetId);
|
89
|
+
if (!targetBlock || targetBlock.type !== 'GROUP_BLOCK') {
|
90
|
+
return [];
|
91
|
+
}
|
92
|
+
return collectChildrenBlockIds(targetBlock, 'deep');
|
95
93
|
};
|
96
|
-
export var
|
97
|
-
var
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
return parents;
|
103
|
-
}
|
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
|
-
if (result) {
|
107
|
-
return result;
|
108
|
-
}
|
109
|
-
}
|
110
|
-
}
|
111
|
-
return null;
|
112
|
-
};
|
113
|
-
return findParentGroups(blockStructure, targetId) || [];
|
94
|
+
export var findDirectChildrenBlockIds = function (block, targetId) {
|
95
|
+
var targetBlock = findBlockByBlockId(block, targetId);
|
96
|
+
if (!targetBlock || targetBlock.type !== 'GROUP_BLOCK') {
|
97
|
+
return [];
|
98
|
+
}
|
99
|
+
return collectChildrenBlockIds(targetBlock, 'current');
|
114
100
|
};
|
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
101
|
export var findGroupBlocks = function (blockStructure, targetId) {
|
132
102
|
var targetBlock = findBlockByBlockId(blockStructure, targetId);
|
133
103
|
var groupBlocks = [];
|
@@ -159,76 +129,76 @@ export var findGroupBlocks = function (blockStructure, targetId) {
|
|
159
129
|
}
|
160
130
|
return groupBlocks;
|
161
131
|
};
|
162
|
-
export
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
};
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
132
|
+
// export const findAllComponentBlockIds = (blockStructure: Block[]): number[] => {
|
133
|
+
// const collectComponentBlockIds = (blocks: Block[]): number[] => {
|
134
|
+
// let ids: number[] = [];
|
135
|
+
// for (const block of blocks) {
|
136
|
+
// if (block.type === 'COMPONENT_BLOCK') {
|
137
|
+
// ids.push(block.componentBlockId);
|
138
|
+
// }
|
139
|
+
// if ('children' in block && block.children) {
|
140
|
+
// ids = ids.concat(collectComponentBlockIds(block.children));
|
141
|
+
// }
|
142
|
+
// }
|
143
|
+
// return ids;
|
144
|
+
// };
|
145
|
+
// return collectComponentBlockIds(blockStructure);
|
146
|
+
// };
|
147
|
+
// export const findParentGroupByGroupId = (blockStructure: Block[], targetId: string): string | null => {
|
148
|
+
// const findParentGroup = (
|
149
|
+
// blocks: Block[],
|
150
|
+
// id: string,
|
151
|
+
// parent: GroupBlock | null = null
|
152
|
+
// ): string | null => {
|
153
|
+
// for (const block of blocks) {
|
154
|
+
// if (block.blockId === id && block.type === 'GROUP_BLOCK') {
|
155
|
+
// return parent ? parent.blockId : null;
|
156
|
+
// }
|
157
|
+
// if ('children' in block && block.children) {
|
158
|
+
// const result = findParentGroup(block.children, id, block.type === 'GROUP_BLOCK' ? block : parent);
|
159
|
+
// if (result) {
|
160
|
+
// return result;
|
161
|
+
// }
|
162
|
+
// }
|
163
|
+
// }
|
164
|
+
// return null;
|
165
|
+
// };
|
166
|
+
// return findParentGroup(blockStructure, targetId);
|
167
|
+
// };
|
168
|
+
// export const addBlockToRoot = (block: RootBlock, newBlock: Block): Block[] => {
|
169
|
+
// return block.map(block => {
|
170
|
+
// if (block.blockId === 'ROOT' && block.type === 'GROUP_BLOCK') {
|
171
|
+
// return {
|
172
|
+
// ...block,
|
173
|
+
// children: block.children ? [...block.children, newBlock] : [newBlock]
|
174
|
+
// };
|
175
|
+
// }
|
176
|
+
// return block;
|
177
|
+
// });
|
178
|
+
// };
|
179
|
+
export var addBulkToTarget = function (block, targetId, bulkBlockIds) {
|
180
|
+
var blockCopy = deepClone(block);
|
181
|
+
var targetBlock = findBlockByBlockId(blockCopy, targetId);
|
209
182
|
if (!targetBlock || targetBlock.type !== 'GROUP_BLOCK' || !targetBlock.children) {
|
210
|
-
return
|
183
|
+
return block;
|
211
184
|
}
|
212
185
|
var bulkBlocks = targetBlock.children.filter(function (child) {
|
213
|
-
if (child.type === 'COMPONENT_BLOCK' &&
|
186
|
+
if (child.type === 'COMPONENT_BLOCK' && bulkBlockIds.includes(child.blockId.toString())) {
|
214
187
|
return true;
|
215
188
|
}
|
216
|
-
if (child.type === 'GROUP_BLOCK' &&
|
189
|
+
if (child.type === 'GROUP_BLOCK' && bulkBlockIds.includes(child.blockId)) {
|
217
190
|
return true;
|
218
191
|
}
|
219
192
|
return false;
|
220
193
|
});
|
221
|
-
if (bulkBlocks.length !==
|
222
|
-
|
223
|
-
console.log('bulkBLocks: ', bulkBlocks);
|
224
|
-
console.log('bulkIds: ', bulkIds);
|
225
|
-
return blockStructure;
|
194
|
+
if (bulkBlocks.length !== bulkBlockIds.length) {
|
195
|
+
return block;
|
226
196
|
}
|
227
197
|
if (bulkBlocks.length === 0) {
|
228
|
-
return
|
198
|
+
return block;
|
229
199
|
}
|
230
200
|
// Remove bulk blocks from target's children
|
231
|
-
targetBlock.children = targetBlock.children.filter(function (child) { return !
|
201
|
+
targetBlock.children = targetBlock.children.filter(function (child) { return !bulkBlockIds.includes(child.blockId); });
|
232
202
|
// Create the new bulkBlock
|
233
203
|
var bulkBlock = {
|
234
204
|
blockId: 'BULK',
|
@@ -239,243 +209,69 @@ export var addBulkToTarget = function (blockStructure, targetId, bulkIds // comp
|
|
239
209
|
};
|
240
210
|
// Add the bulkBlock to the target's children
|
241
211
|
targetBlock.children.push(bulkBlock);
|
242
|
-
return
|
243
|
-
};
|
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;
|
212
|
+
return blockCopy;
|
263
213
|
};
|
264
|
-
|
265
|
-
|
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
|
-
}
|
214
|
+
var findPath = function (block, id, path) {
|
215
|
+
if (block.type === 'COMPONENT_BLOCK') {
|
278
216
|
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
217
|
}
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
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
|
-
}
|
218
|
+
for (var _i = 0, _a = block.children; _i < _a.length; _i++) {
|
219
|
+
var child = _a[_i];
|
220
|
+
var currentPath = __spreadArray(__spreadArray([], path, true), [child.blockId], false);
|
221
|
+
if (child.blockId === id) {
|
222
|
+
return currentPath;
|
444
223
|
}
|
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
224
|
if ('children' in block && block.children) {
|
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
|
466
|
-
}
|
225
|
+
var result = findPath(block, id, currentPath);
|
226
|
+
if (result) {
|
227
|
+
return result;
|
467
228
|
}
|
468
229
|
}
|
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
230
|
}
|
480
|
-
return
|
231
|
+
return null;
|
232
|
+
};
|
233
|
+
export var getBlockWorkDirPath = function (block, blockId) {
|
234
|
+
var path = findPath(block, blockId, ['']);
|
235
|
+
return path ? path.join('/') : null;
|
481
236
|
};
|
237
|
+
export function formatBlockIdToCbId(cbId) {
|
238
|
+
return "CB_".concat(cbId);
|
239
|
+
}
|
240
|
+
export function formatCbIdToBlockId(cbId) {
|
241
|
+
var match = cbId.toString().match(/^CB_(\d+)$/);
|
242
|
+
return match ? parseInt(match[1], 10).toString() : null;
|
243
|
+
}
|
244
|
+
// export const findAccessibleChildrenBlocks = (
|
245
|
+
// block: Block,
|
246
|
+
// targetGroupId: string,
|
247
|
+
// blockIds: string[]
|
248
|
+
// ): string[] => {
|
249
|
+
// const targetBlock = findBlockByBlockId(block, targetGroupId);
|
250
|
+
// if (!targetBlock || !('children' in targetBlock) || !targetBlock.children) {
|
251
|
+
// return [];
|
252
|
+
// }
|
253
|
+
// const result = new Set<string>();
|
254
|
+
// const traverse = (block: Block, rootId: string): boolean => {
|
255
|
+
// if ('children' in block && block.children) {
|
256
|
+
// for (const child of block.children) {
|
257
|
+
// if (blockIds.includes(child.blockId)) {
|
258
|
+
// result.add(rootId);
|
259
|
+
// return true; // Stop traversal for this branch
|
260
|
+
// }
|
261
|
+
// if (traverse(child, rootId)) {
|
262
|
+
// result.add(rootId);
|
263
|
+
// return true; // Stop traversal for this branch
|
264
|
+
// }
|
265
|
+
// }
|
266
|
+
// }
|
267
|
+
// return false;
|
268
|
+
// };
|
269
|
+
// for (const child of targetBlock.children) {
|
270
|
+
// if (blockIds.includes(child.blockId)) {
|
271
|
+
// result.add(child.blockId);
|
272
|
+
// } else {
|
273
|
+
// traverse(child, child.blockId);
|
274
|
+
// }
|
275
|
+
// }
|
276
|
+
// return Array.from(result);
|
277
|
+
// };
|
@@ -79,7 +79,7 @@ export type ReactGridLayoutProps = {
|
|
79
79
|
minNbRow?: number;
|
80
80
|
customColWidth?: number;
|
81
81
|
onFitToContent?: OnFitContentCallBack;
|
82
|
-
blockStructure?: Block
|
82
|
+
blockStructure?: Block;
|
83
83
|
onDoubleClickGroup?: (e: React.MouseEvent, id: string, type: string) => void;
|
84
84
|
selectedGroupBlock?: 'ROOT' | string;
|
85
85
|
editingGroupBlock?: 'ROOT' | string;
|