@flowgram.ai/free-layout-core 0.2.23 → 0.2.25
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/esm/index.js +98 -39
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +98 -39
- package/dist/index.js.map +1 -1
- package/dist/typings/index.d.mts +1 -1
- package/dist/typings/index.d.ts +1 -1
- package/dist/typings/workflow-drag.d.mts +1 -1
- package/dist/typings/workflow-drag.d.ts +1 -1
- package/dist/typings/workflow-edge.d.mts +1 -0
- package/dist/typings/workflow-edge.d.ts +1 -0
- package/dist/typings/workflow-edge.js.map +1 -1
- package/dist/typings/workflow-json.d.mts +1 -1
- package/dist/typings/workflow-json.d.ts +1 -1
- package/dist/typings/workflow-line.d.mts +1 -1
- package/dist/typings/workflow-line.d.ts +1 -1
- package/dist/typings/workflow-node.d.mts +1 -1
- package/dist/typings/workflow-node.d.ts +1 -1
- package/dist/typings/workflow-registry.d.mts +1 -1
- package/dist/typings/workflow-registry.d.ts +1 -1
- package/dist/{workflow-line-entity-CW8YIX-0.d.mts → workflow-line-entity-BmfC83KK.d.mts} +43 -12
- package/dist/{workflow-line-entity-B2J3fUO1.d.ts → workflow-line-entity-pkRs4Hgt.d.ts} +43 -12
- package/package.json +9 -9
package/dist/esm/index.js
CHANGED
|
@@ -188,7 +188,7 @@ var WorkflowPortEntity = class extends Entity {
|
|
|
188
188
|
this.hasError = anyLineHasError || isPortHasError;
|
|
189
189
|
}
|
|
190
190
|
isErrorPort() {
|
|
191
|
-
return this.node.document.isErrorPort(this);
|
|
191
|
+
return this.node.document.isErrorPort(this, this.hasError);
|
|
192
192
|
}
|
|
193
193
|
get point() {
|
|
194
194
|
const { targetElement } = this;
|
|
@@ -692,8 +692,16 @@ var POINT_RADIUS = 10;
|
|
|
692
692
|
var _WorkflowLineEntity = class _WorkflowLineEntity extends Entity2 {
|
|
693
693
|
constructor(opts) {
|
|
694
694
|
super(opts);
|
|
695
|
-
this.
|
|
696
|
-
|
|
695
|
+
this._uiState = {
|
|
696
|
+
hasError: false,
|
|
697
|
+
flowing: false,
|
|
698
|
+
disabled: false,
|
|
699
|
+
vertical: false,
|
|
700
|
+
hideArrow: false,
|
|
701
|
+
reverse: false,
|
|
702
|
+
highlightColor: "",
|
|
703
|
+
lockedColor: ""
|
|
704
|
+
};
|
|
697
705
|
this.stackIndex = 0;
|
|
698
706
|
/**
|
|
699
707
|
* 线条数据
|
|
@@ -722,6 +730,43 @@ var _WorkflowLineEntity = class _WorkflowLineEntity extends Entity2 {
|
|
|
722
730
|
const { from, to, fromPort, toPort } = info;
|
|
723
731
|
return `${from}_${fromPort || ""}-${to || ""}_${toPort || ""}`;
|
|
724
732
|
}
|
|
733
|
+
/**
|
|
734
|
+
* 线条的 UI 状态
|
|
735
|
+
*/
|
|
736
|
+
get uiState() {
|
|
737
|
+
return this._uiState;
|
|
738
|
+
}
|
|
739
|
+
/**
|
|
740
|
+
* 更新线条的 ui 状态
|
|
741
|
+
* @param newState
|
|
742
|
+
*/
|
|
743
|
+
updateUIState(newState) {
|
|
744
|
+
let changed = false;
|
|
745
|
+
Object.keys(newState).forEach((key) => {
|
|
746
|
+
const value = newState[key];
|
|
747
|
+
if (this._uiState[key] !== value) {
|
|
748
|
+
this._uiState[key] = value;
|
|
749
|
+
changed = true;
|
|
750
|
+
}
|
|
751
|
+
});
|
|
752
|
+
if (changed) {
|
|
753
|
+
this.fireChange();
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
/**
|
|
757
|
+
* 线条的扩展数据
|
|
758
|
+
*/
|
|
759
|
+
get lineData() {
|
|
760
|
+
return this._lineData;
|
|
761
|
+
}
|
|
762
|
+
/**
|
|
763
|
+
* 更新线条扩展数据
|
|
764
|
+
* @param data
|
|
765
|
+
*/
|
|
766
|
+
set lineData(data) {
|
|
767
|
+
this._lineData = data;
|
|
768
|
+
this.fireChange();
|
|
769
|
+
}
|
|
725
770
|
/**
|
|
726
771
|
* 获取线条的前置节点
|
|
727
772
|
*/
|
|
@@ -743,29 +788,30 @@ var _WorkflowLineEntity = class _WorkflowLineEntity extends Entity2 {
|
|
|
743
788
|
}
|
|
744
789
|
/**
|
|
745
790
|
* 获取是否 testrun processing
|
|
791
|
+
* @deprecated use `uiState.flowing` instead
|
|
746
792
|
*/
|
|
747
793
|
get processing() {
|
|
748
|
-
return this.
|
|
794
|
+
return this._uiState.flowing;
|
|
749
795
|
}
|
|
750
796
|
/**
|
|
751
797
|
* 设置 testrun processing 状态
|
|
798
|
+
* @deprecated use `uiState.flowing` instead
|
|
752
799
|
*/
|
|
753
800
|
set processing(status) {
|
|
754
|
-
if (this.
|
|
755
|
-
this.
|
|
801
|
+
if (this._uiState.flowing !== status) {
|
|
802
|
+
this._uiState.flowing = status;
|
|
756
803
|
this.fireChange();
|
|
757
804
|
}
|
|
758
805
|
}
|
|
759
806
|
// 获取连线是否为错误态
|
|
760
807
|
get hasError() {
|
|
761
|
-
return this.
|
|
808
|
+
return this.uiState.hasError;
|
|
762
809
|
}
|
|
763
810
|
// 设置连线的错误态
|
|
764
811
|
set hasError(hasError) {
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
}
|
|
812
|
+
this.updateUIState({
|
|
813
|
+
hasError
|
|
814
|
+
});
|
|
769
815
|
if (this._node) {
|
|
770
816
|
this._node.dataset.hasError = this.hasError ? "true" : "false";
|
|
771
817
|
}
|
|
@@ -818,13 +864,20 @@ var _WorkflowLineEntity = class _WorkflowLineEntity extends Entity2 {
|
|
|
818
864
|
return this.info.drawingTo;
|
|
819
865
|
}
|
|
820
866
|
get highlightColor() {
|
|
821
|
-
return this.
|
|
867
|
+
return this.uiState.highlightColor || "";
|
|
822
868
|
}
|
|
823
|
-
set highlightColor(
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
869
|
+
set highlightColor(highlightColor) {
|
|
870
|
+
this.updateUIState({
|
|
871
|
+
highlightColor
|
|
872
|
+
});
|
|
873
|
+
}
|
|
874
|
+
get lockedColor() {
|
|
875
|
+
return this.uiState.lockedColor;
|
|
876
|
+
}
|
|
877
|
+
set lockedColor(lockedColor) {
|
|
878
|
+
this.updateUIState({
|
|
879
|
+
lockedColor
|
|
880
|
+
});
|
|
828
881
|
}
|
|
829
882
|
/**
|
|
830
883
|
* 获取线条的边框位置大小
|
|
@@ -855,23 +908,23 @@ var _WorkflowLineEntity = class _WorkflowLineEntity extends Entity2 {
|
|
|
855
908
|
}
|
|
856
909
|
/** 是否反转箭头 */
|
|
857
910
|
get reverse() {
|
|
858
|
-
return this.linesManager.isReverseLine(this);
|
|
911
|
+
return this.linesManager.isReverseLine(this, this.uiState.reverse);
|
|
859
912
|
}
|
|
860
913
|
/** 是否隐藏箭头 */
|
|
861
914
|
get hideArrow() {
|
|
862
|
-
return this.linesManager.isHideArrowLine(this);
|
|
915
|
+
return this.linesManager.isHideArrowLine(this, this.uiState.hideArrow);
|
|
863
916
|
}
|
|
864
917
|
/** 是否流动 */
|
|
865
918
|
get flowing() {
|
|
866
|
-
return this.linesManager.isFlowingLine(this);
|
|
919
|
+
return this.linesManager.isFlowingLine(this, this.uiState.flowing);
|
|
867
920
|
}
|
|
868
921
|
/** 是否禁用 */
|
|
869
922
|
get disabled() {
|
|
870
|
-
return this.linesManager.isDisabledLine(this);
|
|
923
|
+
return this.linesManager.isDisabledLine(this, this.uiState.disabled);
|
|
871
924
|
}
|
|
872
925
|
/** 是否竖向 */
|
|
873
926
|
get vertical() {
|
|
874
|
-
return this.linesManager.isVerticalLine(this);
|
|
927
|
+
return this.linesManager.isVerticalLine(this, this.uiState.vertical);
|
|
875
928
|
}
|
|
876
929
|
/** 获取线条渲染器类型 */
|
|
877
930
|
get renderType() {
|
|
@@ -906,7 +959,7 @@ var _WorkflowLineEntity = class _WorkflowLineEntity extends Entity2 {
|
|
|
906
959
|
validateSelf() {
|
|
907
960
|
const { fromPort, toPort } = this;
|
|
908
961
|
if (fromPort) {
|
|
909
|
-
this.hasError = this.linesManager.isErrorLine(fromPort, toPort);
|
|
962
|
+
this.hasError = this.linesManager.isErrorLine(fromPort, toPort, this.uiState.hasError);
|
|
910
963
|
}
|
|
911
964
|
}
|
|
912
965
|
is(line) {
|
|
@@ -937,6 +990,9 @@ var _WorkflowLineEntity = class _WorkflowLineEntity extends Entity2 {
|
|
|
937
990
|
sourcePortID: this.info.fromPort,
|
|
938
991
|
targetPortID: this.info.toPort
|
|
939
992
|
};
|
|
993
|
+
if (this._lineData !== void 0) {
|
|
994
|
+
json.data = this._lineData;
|
|
995
|
+
}
|
|
940
996
|
if (!json.sourcePortID) {
|
|
941
997
|
delete json.sourcePortID;
|
|
942
998
|
}
|
|
@@ -1383,41 +1439,41 @@ var WorkflowLinesManager = class {
|
|
|
1383
1439
|
get disposed() {
|
|
1384
1440
|
return this.toDispose.disposed;
|
|
1385
1441
|
}
|
|
1386
|
-
isErrorLine(fromPort, toPort) {
|
|
1442
|
+
isErrorLine(fromPort, toPort, defaultValue) {
|
|
1387
1443
|
if (this.options.isErrorLine) {
|
|
1388
1444
|
return this.options.isErrorLine(fromPort, toPort, this);
|
|
1389
1445
|
}
|
|
1390
|
-
return
|
|
1446
|
+
return !!defaultValue;
|
|
1391
1447
|
}
|
|
1392
|
-
isReverseLine(line) {
|
|
1448
|
+
isReverseLine(line, defaultValue = false) {
|
|
1393
1449
|
if (this.options.isReverseLine) {
|
|
1394
1450
|
return this.options.isReverseLine(line);
|
|
1395
1451
|
}
|
|
1396
|
-
return
|
|
1452
|
+
return defaultValue;
|
|
1397
1453
|
}
|
|
1398
|
-
isHideArrowLine(line) {
|
|
1454
|
+
isHideArrowLine(line, defaultValue = false) {
|
|
1399
1455
|
if (this.options.isHideArrowLine) {
|
|
1400
1456
|
return this.options.isHideArrowLine(line);
|
|
1401
1457
|
}
|
|
1402
|
-
return
|
|
1458
|
+
return defaultValue;
|
|
1403
1459
|
}
|
|
1404
|
-
isFlowingLine(line) {
|
|
1460
|
+
isFlowingLine(line, defaultValue = false) {
|
|
1405
1461
|
if (this.options.isFlowingLine) {
|
|
1406
1462
|
return this.options.isFlowingLine(line);
|
|
1407
1463
|
}
|
|
1408
|
-
return
|
|
1464
|
+
return defaultValue;
|
|
1409
1465
|
}
|
|
1410
|
-
isDisabledLine(line) {
|
|
1466
|
+
isDisabledLine(line, defaultValue = false) {
|
|
1411
1467
|
if (this.options.isDisabledLine) {
|
|
1412
1468
|
return this.options.isDisabledLine(line);
|
|
1413
1469
|
}
|
|
1414
|
-
return
|
|
1470
|
+
return defaultValue;
|
|
1415
1471
|
}
|
|
1416
|
-
isVerticalLine(line) {
|
|
1472
|
+
isVerticalLine(line, defaultValue = false) {
|
|
1417
1473
|
if (this.options.isVerticalLine) {
|
|
1418
1474
|
return this.options.isVerticalLine(line);
|
|
1419
1475
|
}
|
|
1420
|
-
return
|
|
1476
|
+
return defaultValue;
|
|
1421
1477
|
}
|
|
1422
1478
|
setLineRenderType(line) {
|
|
1423
1479
|
if (this.options.setLineRenderType) {
|
|
@@ -1435,6 +1491,9 @@ var WorkflowLinesManager = class {
|
|
|
1435
1491
|
if (line.isHidden) {
|
|
1436
1492
|
return this.lineColor.hidden;
|
|
1437
1493
|
}
|
|
1494
|
+
if (line.lockedColor) {
|
|
1495
|
+
return line.lockedColor;
|
|
1496
|
+
}
|
|
1438
1497
|
if (line.hasError) {
|
|
1439
1498
|
return this.lineColor.error;
|
|
1440
1499
|
}
|
|
@@ -2174,11 +2233,11 @@ var WorkflowDocument = class extends FlowDocument {
|
|
|
2174
2233
|
/**
|
|
2175
2234
|
* 判断端口是否为错误态
|
|
2176
2235
|
*/
|
|
2177
|
-
isErrorPort(port) {
|
|
2236
|
+
isErrorPort(port, defaultValue = false) {
|
|
2178
2237
|
if (typeof this.options.isErrorPort === "function") {
|
|
2179
2238
|
return this.options.isErrorPort(port);
|
|
2180
2239
|
}
|
|
2181
|
-
return
|
|
2240
|
+
return defaultValue;
|
|
2182
2241
|
}
|
|
2183
2242
|
/**
|
|
2184
2243
|
* 导出数据
|
|
@@ -2732,7 +2791,7 @@ var WorkflowDragService = class {
|
|
|
2732
2791
|
return;
|
|
2733
2792
|
}
|
|
2734
2793
|
config.updateCursor("grab");
|
|
2735
|
-
line.highlightColor = this.linesManager.lineColor.drawing;
|
|
2794
|
+
line.highlightColor = originLine?.lockedColor || this.linesManager.lineColor.drawing;
|
|
2736
2795
|
this.hoverService.updateHoveredKey("");
|
|
2737
2796
|
}
|
|
2738
2797
|
if (!line) {
|
|
@@ -2754,7 +2813,7 @@ var WorkflowDragService = class {
|
|
|
2754
2813
|
this._onDragLineEventEmitter.fire({
|
|
2755
2814
|
type: "onDrag"
|
|
2756
2815
|
});
|
|
2757
|
-
this.setLineColor(line, this.linesManager.lineColor.drawing);
|
|
2816
|
+
this.setLineColor(line, originLine?.lockedColor || this.linesManager.lineColor.drawing);
|
|
2758
2817
|
if (toNode && this.canBuildContainerLine(toNode, dragPos)) {
|
|
2759
2818
|
toPort = this.getNearestPort(toNode, dragPos);
|
|
2760
2819
|
const { hasError } = this.handleDragOnNode(toNode, fromPort, line, toPort, originLine);
|