@logicflow/extension 2.3.0-alpha.0 → 2.3.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.css +1 -0
- package/dist/index.min.js +2 -0
- package/dist/index.min.js.map +1 -0
- package/es/dynamic-group/index.d.ts +2 -1
- package/es/dynamic-group/index.js +98 -18
- package/lib/dynamic-group/index.d.ts +2 -1
- package/lib/dynamic-group/index.js +98 -18
- package/package.json +1 -1
|
@@ -36,7 +36,7 @@ export declare class DynamicGroup {
|
|
|
36
36
|
/** 拖拽节点进入分组时的感应外框样式 */
|
|
37
37
|
sensorOutline?: SensorOutlineOptions;
|
|
38
38
|
topGroupZIndex: number;
|
|
39
|
-
|
|
39
|
+
activeGroups: Set<DynamicGroupNodeModel>;
|
|
40
40
|
nodeGroupMap: Map<string, string>;
|
|
41
41
|
/** 折叠态虚拟边 id → 所属分组与真实边 id */
|
|
42
42
|
collapsedVirtualEdges: Map<string, {
|
|
@@ -98,6 +98,7 @@ export declare class DynamicGroup {
|
|
|
98
98
|
removeNodeFromGroup: ({ data: node, model, }: CallbackArgs<'node:delete'>) => void;
|
|
99
99
|
onSelectionDrag: () => void;
|
|
100
100
|
onNodeDrag: ({ data: node }: CallbackArgs<'node:drag'>) => void;
|
|
101
|
+
private getTargetGroupForNode;
|
|
101
102
|
setActiveGroup: (node: LogicFlow.NodeData) => void;
|
|
102
103
|
/**
|
|
103
104
|
* 1. 分组节点默认在普通节点下面
|
|
@@ -75,6 +75,8 @@ var DynamicGroup = /** @class */ (function () {
|
|
|
75
75
|
*/
|
|
76
76
|
this.cascadeDeleteChildren = true;
|
|
77
77
|
this.topGroupZIndex = DEFAULT_BOTTOM_Z_INDEX;
|
|
78
|
+
// 激活态的 group 节点(支持多组同时高亮)
|
|
79
|
+
this.activeGroups = new Set();
|
|
78
80
|
// 存储节点与 group 的映射关系
|
|
79
81
|
this.nodeGroupMap = new Map();
|
|
80
82
|
/** 折叠态虚拟边 id → 所属分组与真实边 id */
|
|
@@ -275,32 +277,85 @@ var DynamicGroup = /** @class */ (function () {
|
|
|
275
277
|
}
|
|
276
278
|
};
|
|
277
279
|
this.onSelectionDrag = function () {
|
|
280
|
+
var e_2, _a, e_3, _b;
|
|
278
281
|
var selectedNodes = _this.lf.graphModel.getSelectElements().nodes;
|
|
282
|
+
// 每个节点独立找目标组,合并为 Set,消除迭代顺序的影响
|
|
283
|
+
var next = new Set();
|
|
279
284
|
selectedNodes.forEach(function (node) {
|
|
280
|
-
_this.
|
|
285
|
+
var targetGroup = _this.getTargetGroupForNode(node);
|
|
286
|
+
if (targetGroup)
|
|
287
|
+
next.add(targetGroup);
|
|
281
288
|
});
|
|
289
|
+
try {
|
|
290
|
+
// diff 更新:只操作有变化的组,避免无谓的视觉抖动
|
|
291
|
+
for (var _c = __values(_this.activeGroups), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
292
|
+
var group = _d.value;
|
|
293
|
+
if (!next.has(group))
|
|
294
|
+
group.setAllowAppendChild(false);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
298
|
+
finally {
|
|
299
|
+
try {
|
|
300
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
301
|
+
}
|
|
302
|
+
finally { if (e_2) throw e_2.error; }
|
|
303
|
+
}
|
|
304
|
+
try {
|
|
305
|
+
for (var next_1 = __values(next), next_1_1 = next_1.next(); !next_1_1.done; next_1_1 = next_1.next()) {
|
|
306
|
+
var group = next_1_1.value;
|
|
307
|
+
if (!_this.activeGroups.has(group))
|
|
308
|
+
group.setAllowAppendChild(true);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
312
|
+
finally {
|
|
313
|
+
try {
|
|
314
|
+
if (next_1_1 && !next_1_1.done && (_b = next_1.return)) _b.call(next_1);
|
|
315
|
+
}
|
|
316
|
+
finally { if (e_3) throw e_3.error; }
|
|
317
|
+
}
|
|
318
|
+
_this.activeGroups = next;
|
|
282
319
|
};
|
|
283
320
|
this.onNodeDrag = function (_a) {
|
|
284
321
|
var node = _a.data;
|
|
285
322
|
_this.setActiveGroup(node);
|
|
286
323
|
};
|
|
287
324
|
this.setActiveGroup = function (node) {
|
|
288
|
-
var
|
|
289
|
-
var
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
325
|
+
var e_4, _a, e_5, _b;
|
|
326
|
+
var targetGroup = _this.getTargetGroupForNode(node);
|
|
327
|
+
var next = new Set();
|
|
328
|
+
if (targetGroup)
|
|
329
|
+
next.add(targetGroup);
|
|
330
|
+
try {
|
|
331
|
+
for (var _c = __values(_this.activeGroups), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
332
|
+
var group = _d.value;
|
|
333
|
+
if (!next.has(group))
|
|
334
|
+
group.setAllowAppendChild(false);
|
|
294
335
|
}
|
|
295
|
-
|
|
296
|
-
|
|
336
|
+
}
|
|
337
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
338
|
+
finally {
|
|
339
|
+
try {
|
|
340
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
297
341
|
}
|
|
298
|
-
|
|
299
|
-
if (!isAllowAppendIn)
|
|
300
|
-
return;
|
|
301
|
-
_this.activeGroup = targetGroup;
|
|
302
|
-
_this.activeGroup.setAllowAppendChild(true);
|
|
342
|
+
finally { if (e_4) throw e_4.error; }
|
|
303
343
|
}
|
|
344
|
+
try {
|
|
345
|
+
for (var next_2 = __values(next), next_2_1 = next_2.next(); !next_2_1.done; next_2_1 = next_2.next()) {
|
|
346
|
+
var group = next_2_1.value;
|
|
347
|
+
if (!_this.activeGroups.has(group))
|
|
348
|
+
group.setAllowAppendChild(true);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
352
|
+
finally {
|
|
353
|
+
try {
|
|
354
|
+
if (next_2_1 && !next_2_1.done && (_b = next_2.return)) _b.call(next_2);
|
|
355
|
+
}
|
|
356
|
+
finally { if (e_5) throw e_5.error; }
|
|
357
|
+
}
|
|
358
|
+
_this.activeGroups = next;
|
|
304
359
|
};
|
|
305
360
|
/**
|
|
306
361
|
* 1. 分组节点默认在普通节点下面
|
|
@@ -417,7 +472,7 @@ var DynamicGroup = /** @class */ (function () {
|
|
|
417
472
|
_this.nodeGroupMap.clear();
|
|
418
473
|
_this.collapsedVirtualEdges.clear();
|
|
419
474
|
_this.collapsedRealEdgeToGroup.clear();
|
|
420
|
-
_this.
|
|
475
|
+
_this.activeGroups.clear();
|
|
421
476
|
_this.topGroupZIndex = DEFAULT_BOTTOM_Z_INDEX;
|
|
422
477
|
forEach(data.nodes, function (node) {
|
|
423
478
|
if (node.children) {
|
|
@@ -569,10 +624,35 @@ var DynamicGroup = /** @class */ (function () {
|
|
|
569
624
|
this.topGroupZIndex = max;
|
|
570
625
|
};
|
|
571
626
|
DynamicGroup.prototype.clearDragTargetHighlight = function () {
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
this.
|
|
627
|
+
var e_6, _a;
|
|
628
|
+
try {
|
|
629
|
+
for (var _b = __values(this.activeGroups), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
630
|
+
var group = _c.value;
|
|
631
|
+
group.setAllowAppendChild(false);
|
|
632
|
+
}
|
|
575
633
|
}
|
|
634
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
635
|
+
finally {
|
|
636
|
+
try {
|
|
637
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
638
|
+
}
|
|
639
|
+
finally { if (e_6) throw e_6.error; }
|
|
640
|
+
}
|
|
641
|
+
this.activeGroups.clear();
|
|
642
|
+
};
|
|
643
|
+
DynamicGroup.prototype.getTargetGroupForNode = function (node) {
|
|
644
|
+
var nodeModel = this.lf.getNodeModelById(node.id);
|
|
645
|
+
var bounds = nodeModel === null || nodeModel === void 0 ? void 0 : nodeModel.getBounds();
|
|
646
|
+
if (!nodeModel || !bounds)
|
|
647
|
+
return undefined;
|
|
648
|
+
var targetGroup = this.getGroupByBounds(bounds, node);
|
|
649
|
+
if (!targetGroup)
|
|
650
|
+
return undefined;
|
|
651
|
+
if (nodeModel.isGroup && targetGroup.id === node.id)
|
|
652
|
+
return undefined;
|
|
653
|
+
if (!targetGroup.isAllowAppendIn(node))
|
|
654
|
+
return undefined;
|
|
655
|
+
return targetGroup;
|
|
576
656
|
};
|
|
577
657
|
DynamicGroup.prototype.removeChildrenInGroupNodeData = function (nodeData) {
|
|
578
658
|
var _a;
|
|
@@ -36,7 +36,7 @@ export declare class DynamicGroup {
|
|
|
36
36
|
/** 拖拽节点进入分组时的感应外框样式 */
|
|
37
37
|
sensorOutline?: SensorOutlineOptions;
|
|
38
38
|
topGroupZIndex: number;
|
|
39
|
-
|
|
39
|
+
activeGroups: Set<DynamicGroupNodeModel>;
|
|
40
40
|
nodeGroupMap: Map<string, string>;
|
|
41
41
|
/** 折叠态虚拟边 id → 所属分组与真实边 id */
|
|
42
42
|
collapsedVirtualEdges: Map<string, {
|
|
@@ -98,6 +98,7 @@ export declare class DynamicGroup {
|
|
|
98
98
|
removeNodeFromGroup: ({ data: node, model, }: CallbackArgs<'node:delete'>) => void;
|
|
99
99
|
onSelectionDrag: () => void;
|
|
100
100
|
onNodeDrag: ({ data: node }: CallbackArgs<'node:drag'>) => void;
|
|
101
|
+
private getTargetGroupForNode;
|
|
101
102
|
setActiveGroup: (node: LogicFlow.NodeData) => void;
|
|
102
103
|
/**
|
|
103
104
|
* 1. 分组节点默认在普通节点下面
|
|
@@ -92,6 +92,8 @@ var DynamicGroup = /** @class */ (function () {
|
|
|
92
92
|
*/
|
|
93
93
|
this.cascadeDeleteChildren = true;
|
|
94
94
|
this.topGroupZIndex = DEFAULT_BOTTOM_Z_INDEX;
|
|
95
|
+
// 激活态的 group 节点(支持多组同时高亮)
|
|
96
|
+
this.activeGroups = new Set();
|
|
95
97
|
// 存储节点与 group 的映射关系
|
|
96
98
|
this.nodeGroupMap = new Map();
|
|
97
99
|
/** 折叠态虚拟边 id → 所属分组与真实边 id */
|
|
@@ -292,32 +294,85 @@ var DynamicGroup = /** @class */ (function () {
|
|
|
292
294
|
}
|
|
293
295
|
};
|
|
294
296
|
this.onSelectionDrag = function () {
|
|
297
|
+
var e_2, _a, e_3, _b;
|
|
295
298
|
var selectedNodes = _this.lf.graphModel.getSelectElements().nodes;
|
|
299
|
+
// 每个节点独立找目标组,合并为 Set,消除迭代顺序的影响
|
|
300
|
+
var next = new Set();
|
|
296
301
|
selectedNodes.forEach(function (node) {
|
|
297
|
-
_this.
|
|
302
|
+
var targetGroup = _this.getTargetGroupForNode(node);
|
|
303
|
+
if (targetGroup)
|
|
304
|
+
next.add(targetGroup);
|
|
298
305
|
});
|
|
306
|
+
try {
|
|
307
|
+
// diff 更新:只操作有变化的组,避免无谓的视觉抖动
|
|
308
|
+
for (var _c = __values(_this.activeGroups), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
309
|
+
var group = _d.value;
|
|
310
|
+
if (!next.has(group))
|
|
311
|
+
group.setAllowAppendChild(false);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
315
|
+
finally {
|
|
316
|
+
try {
|
|
317
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
318
|
+
}
|
|
319
|
+
finally { if (e_2) throw e_2.error; }
|
|
320
|
+
}
|
|
321
|
+
try {
|
|
322
|
+
for (var next_1 = __values(next), next_1_1 = next_1.next(); !next_1_1.done; next_1_1 = next_1.next()) {
|
|
323
|
+
var group = next_1_1.value;
|
|
324
|
+
if (!_this.activeGroups.has(group))
|
|
325
|
+
group.setAllowAppendChild(true);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
329
|
+
finally {
|
|
330
|
+
try {
|
|
331
|
+
if (next_1_1 && !next_1_1.done && (_b = next_1.return)) _b.call(next_1);
|
|
332
|
+
}
|
|
333
|
+
finally { if (e_3) throw e_3.error; }
|
|
334
|
+
}
|
|
335
|
+
_this.activeGroups = next;
|
|
299
336
|
};
|
|
300
337
|
this.onNodeDrag = function (_a) {
|
|
301
338
|
var node = _a.data;
|
|
302
339
|
_this.setActiveGroup(node);
|
|
303
340
|
};
|
|
304
341
|
this.setActiveGroup = function (node) {
|
|
305
|
-
var
|
|
306
|
-
var
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
342
|
+
var e_4, _a, e_5, _b;
|
|
343
|
+
var targetGroup = _this.getTargetGroupForNode(node);
|
|
344
|
+
var next = new Set();
|
|
345
|
+
if (targetGroup)
|
|
346
|
+
next.add(targetGroup);
|
|
347
|
+
try {
|
|
348
|
+
for (var _c = __values(_this.activeGroups), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
349
|
+
var group = _d.value;
|
|
350
|
+
if (!next.has(group))
|
|
351
|
+
group.setAllowAppendChild(false);
|
|
311
352
|
}
|
|
312
|
-
|
|
313
|
-
|
|
353
|
+
}
|
|
354
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
355
|
+
finally {
|
|
356
|
+
try {
|
|
357
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
314
358
|
}
|
|
315
|
-
|
|
316
|
-
if (!isAllowAppendIn)
|
|
317
|
-
return;
|
|
318
|
-
_this.activeGroup = targetGroup;
|
|
319
|
-
_this.activeGroup.setAllowAppendChild(true);
|
|
359
|
+
finally { if (e_4) throw e_4.error; }
|
|
320
360
|
}
|
|
361
|
+
try {
|
|
362
|
+
for (var next_2 = __values(next), next_2_1 = next_2.next(); !next_2_1.done; next_2_1 = next_2.next()) {
|
|
363
|
+
var group = next_2_1.value;
|
|
364
|
+
if (!_this.activeGroups.has(group))
|
|
365
|
+
group.setAllowAppendChild(true);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
369
|
+
finally {
|
|
370
|
+
try {
|
|
371
|
+
if (next_2_1 && !next_2_1.done && (_b = next_2.return)) _b.call(next_2);
|
|
372
|
+
}
|
|
373
|
+
finally { if (e_5) throw e_5.error; }
|
|
374
|
+
}
|
|
375
|
+
_this.activeGroups = next;
|
|
321
376
|
};
|
|
322
377
|
/**
|
|
323
378
|
* 1. 分组节点默认在普通节点下面
|
|
@@ -434,7 +489,7 @@ var DynamicGroup = /** @class */ (function () {
|
|
|
434
489
|
_this.nodeGroupMap.clear();
|
|
435
490
|
_this.collapsedVirtualEdges.clear();
|
|
436
491
|
_this.collapsedRealEdgeToGroup.clear();
|
|
437
|
-
_this.
|
|
492
|
+
_this.activeGroups.clear();
|
|
438
493
|
_this.topGroupZIndex = DEFAULT_BOTTOM_Z_INDEX;
|
|
439
494
|
(0, lodash_es_1.forEach)(data.nodes, function (node) {
|
|
440
495
|
if (node.children) {
|
|
@@ -586,10 +641,35 @@ var DynamicGroup = /** @class */ (function () {
|
|
|
586
641
|
this.topGroupZIndex = max;
|
|
587
642
|
};
|
|
588
643
|
DynamicGroup.prototype.clearDragTargetHighlight = function () {
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
this.
|
|
644
|
+
var e_6, _a;
|
|
645
|
+
try {
|
|
646
|
+
for (var _b = __values(this.activeGroups), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
647
|
+
var group = _c.value;
|
|
648
|
+
group.setAllowAppendChild(false);
|
|
649
|
+
}
|
|
592
650
|
}
|
|
651
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
652
|
+
finally {
|
|
653
|
+
try {
|
|
654
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
655
|
+
}
|
|
656
|
+
finally { if (e_6) throw e_6.error; }
|
|
657
|
+
}
|
|
658
|
+
this.activeGroups.clear();
|
|
659
|
+
};
|
|
660
|
+
DynamicGroup.prototype.getTargetGroupForNode = function (node) {
|
|
661
|
+
var nodeModel = this.lf.getNodeModelById(node.id);
|
|
662
|
+
var bounds = nodeModel === null || nodeModel === void 0 ? void 0 : nodeModel.getBounds();
|
|
663
|
+
if (!nodeModel || !bounds)
|
|
664
|
+
return undefined;
|
|
665
|
+
var targetGroup = this.getGroupByBounds(bounds, node);
|
|
666
|
+
if (!targetGroup)
|
|
667
|
+
return undefined;
|
|
668
|
+
if (nodeModel.isGroup && targetGroup.id === node.id)
|
|
669
|
+
return undefined;
|
|
670
|
+
if (!targetGroup.isAllowAppendIn(node))
|
|
671
|
+
return undefined;
|
|
672
|
+
return targetGroup;
|
|
593
673
|
};
|
|
594
674
|
DynamicGroup.prototype.removeChildrenInGroupNodeData = function (nodeData) {
|
|
595
675
|
var _a;
|