@logicflow/extension 2.2.0-alpha.5 → 2.2.0-alpha.7
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/.turbo/turbo-build.log +7 -7
- package/CHANGELOG.md +15 -0
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/es/bpmn-elements-adapter/json2xml.d.ts +2 -1
- package/es/bpmn-elements-adapter/json2xml.js +18 -4
- package/es/bpmn-elements-adapter/xml2json.js +2 -7
- package/es/components/control/index.js +3 -3
- package/es/index.d.ts +1 -0
- package/es/index.js +2 -0
- package/es/materials/curved-edge/index.js +41 -25
- package/es/pool/LaneModel.d.ts +90 -0
- package/es/pool/LaneModel.js +252 -0
- package/es/pool/LaneView.d.ts +40 -0
- package/es/pool/LaneView.js +202 -0
- package/es/pool/PoolModel.d.ts +120 -0
- package/es/pool/PoolModel.js +586 -0
- package/es/pool/PoolView.d.ts +17 -0
- package/es/pool/PoolView.js +76 -0
- package/es/pool/constant.d.ts +15 -0
- package/es/pool/constant.js +17 -0
- package/es/pool/index.d.ts +89 -0
- package/es/pool/index.js +524 -0
- package/es/pool/utils.d.ts +19 -0
- package/es/pool/utils.js +33 -0
- package/lib/bpmn-elements-adapter/json2xml.d.ts +2 -1
- package/lib/bpmn-elements-adapter/json2xml.js +19 -4
- package/lib/bpmn-elements-adapter/xml2json.js +2 -7
- package/lib/components/control/index.js +3 -3
- package/lib/index.d.ts +1 -0
- package/lib/index.js +2 -0
- package/lib/materials/curved-edge/index.js +41 -25
- package/lib/pool/LaneModel.d.ts +90 -0
- package/lib/pool/LaneModel.js +255 -0
- package/lib/pool/LaneView.d.ts +40 -0
- package/lib/pool/LaneView.js +205 -0
- package/lib/pool/PoolModel.d.ts +120 -0
- package/lib/pool/PoolModel.js +589 -0
- package/lib/pool/PoolView.d.ts +17 -0
- package/lib/pool/PoolView.js +79 -0
- package/lib/pool/constant.d.ts +15 -0
- package/lib/pool/constant.js +20 -0
- package/lib/pool/index.d.ts +89 -0
- package/lib/pool/index.js +527 -0
- package/lib/pool/utils.d.ts +19 -0
- package/lib/pool/utils.js +38 -0
- package/package.json +5 -5
- package/src/bpmn-elements-adapter/json2xml.ts +18 -4
- package/src/bpmn-elements-adapter/xml2json.ts +2 -8
- package/src/components/control/index.ts +3 -3
- package/src/dynamic-group/index.ts +0 -1
- package/src/index.ts +2 -0
- package/src/materials/curved-edge/index.ts +47 -30
- package/src/pool/LaneModel.ts +226 -0
- package/src/pool/LaneView.ts +220 -0
- package/src/pool/PoolModel.ts +631 -0
- package/src/pool/PoolView.ts +75 -0
- package/src/pool/constant.ts +19 -0
- package/src/pool/index.ts +621 -0
- package/src/pool/utils.ts +46 -0
- package/stats.html +1 -1
package/es/pool/utils.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param bounds
|
|
4
|
+
* @param group
|
|
5
|
+
*/
|
|
6
|
+
export function isBoundsInLane(bounds, group) {
|
|
7
|
+
var minX = bounds.minX, minY = bounds.minY, maxX = bounds.maxX, maxY = bounds.maxY;
|
|
8
|
+
var x = group.x, y = group.y, width = group.width, height = group.height;
|
|
9
|
+
return (minX >= x - width / 2 &&
|
|
10
|
+
maxX <= x + width / 2 &&
|
|
11
|
+
minY >= y - height / 2 &&
|
|
12
|
+
maxY <= y + height / 2);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* 判断 bounds 是否可以移动到下一个范围
|
|
16
|
+
* @param groupBounds
|
|
17
|
+
* @param node
|
|
18
|
+
* @param deltaX
|
|
19
|
+
* @param deltaY
|
|
20
|
+
*/
|
|
21
|
+
export function isAllowMoveTo(groupBounds, node, deltaX, deltaY) {
|
|
22
|
+
var minX = groupBounds.minX, minY = groupBounds.minY, maxX = groupBounds.maxX, maxY = groupBounds.maxY;
|
|
23
|
+
var x = node.x, y = node.y, width = node.width, height = node.height;
|
|
24
|
+
// DONE: 计算节点坐标 (x, y) 可移动的范围,并判断 x + deltaX, y + deltaY 是否在范围内
|
|
25
|
+
var allowMoveMinX = minX + width / 2;
|
|
26
|
+
var allowMoveMinY = minY + height / 2;
|
|
27
|
+
var allowMoveMaxX = maxX - width / 2;
|
|
28
|
+
var allowMoveMaxY = maxY - height / 2;
|
|
29
|
+
return {
|
|
30
|
+
x: x + deltaX >= allowMoveMinX && x + deltaX <= allowMoveMaxX,
|
|
31
|
+
y: y + deltaY >= allowMoveMinY && y + deltaY <= allowMoveMaxY,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.handleAttributes = exports.lfJson2Xml = void 0;
|
|
3
|
+
exports.escapeXml = exports.handleAttributes = exports.lfJson2Xml = void 0;
|
|
4
4
|
/* eslint-disable guard-for-in */
|
|
5
5
|
function type(obj) {
|
|
6
6
|
return Object.prototype.toString.call(obj);
|
|
@@ -25,6 +25,18 @@ function handleAttributes(obj) {
|
|
|
25
25
|
return obj;
|
|
26
26
|
}
|
|
27
27
|
exports.handleAttributes = handleAttributes;
|
|
28
|
+
function escapeXml(text) {
|
|
29
|
+
if (text == null)
|
|
30
|
+
return '';
|
|
31
|
+
return text
|
|
32
|
+
.toString()
|
|
33
|
+
.replace(/&/g, '&')
|
|
34
|
+
.replace(/</g, '<')
|
|
35
|
+
.replace(/>/g, '>')
|
|
36
|
+
.replace(/"/g, '"')
|
|
37
|
+
.replace(/'/g, ''');
|
|
38
|
+
}
|
|
39
|
+
exports.escapeXml = escapeXml;
|
|
28
40
|
function getAttributes(obj) {
|
|
29
41
|
var tmp = obj;
|
|
30
42
|
try {
|
|
@@ -35,7 +47,7 @@ function getAttributes(obj) {
|
|
|
35
47
|
catch (error) {
|
|
36
48
|
tmp = JSON.stringify(handleAttributes(obj)).replace(/"/g, "'");
|
|
37
49
|
}
|
|
38
|
-
return tmp;
|
|
50
|
+
return escapeXml(String(tmp));
|
|
39
51
|
}
|
|
40
52
|
var tn = '\t\n';
|
|
41
53
|
// @see issue https://github.com/didi/LogicFlow/issues/718, refactoring of function toXml
|
|
@@ -45,8 +57,11 @@ function toXml(obj, name, depth) {
|
|
|
45
57
|
var prefix = tn + frontSpace;
|
|
46
58
|
if (name === '-json')
|
|
47
59
|
return '';
|
|
60
|
+
if (obj !== 0 && obj !== false && !obj) {
|
|
61
|
+
return "".concat(prefix, "<").concat(name, " />");
|
|
62
|
+
}
|
|
48
63
|
if (name === '#text') {
|
|
49
|
-
return prefix + obj;
|
|
64
|
+
return prefix + escapeXml(String(obj));
|
|
50
65
|
}
|
|
51
66
|
if (name === '#cdata-section') {
|
|
52
67
|
return "".concat(prefix, "<![CDATA[").concat(obj, "]]>");
|
|
@@ -74,7 +89,7 @@ function toXml(obj, name, depth) {
|
|
|
74
89
|
attributes_1 + (children_1 !== '' ? ">".concat(children_1).concat(prefix, "</").concat(name, ">") : ' />');
|
|
75
90
|
}
|
|
76
91
|
else {
|
|
77
|
-
str += "".concat(prefix, "<").concat(name, ">").concat(obj
|
|
92
|
+
str += "".concat(prefix, "<").concat(name, ">").concat(escapeXml(String(obj)), "</").concat(name, ">");
|
|
78
93
|
}
|
|
79
94
|
return str;
|
|
80
95
|
}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.lfXml2Json = void 0;
|
|
10
10
|
var lodash_es_1 = require("lodash-es");
|
|
11
|
+
var json2xml_1 = require("./json2xml");
|
|
11
12
|
// ========================================================================
|
|
12
13
|
// XML.ObjTree -- XML source code from/to JavaScript object like E4X
|
|
13
14
|
// ========================================================================
|
|
@@ -298,13 +299,7 @@ XML.ObjTree.prototype.scalar_to_xml = function (name, text) {
|
|
|
298
299
|
return "<".concat(name, ">").concat(this.xml_escape(text), "</").concat(name, ">\n");
|
|
299
300
|
};
|
|
300
301
|
// method: xml_escape( text )
|
|
301
|
-
XML.ObjTree.prototype.xml_escape =
|
|
302
|
-
return text
|
|
303
|
-
.replace(/&/g, '&')
|
|
304
|
-
.replace(/</g, '<')
|
|
305
|
-
.replace(/>/g, '>')
|
|
306
|
-
.replace(/"/g, '"');
|
|
307
|
-
};
|
|
302
|
+
XML.ObjTree.prototype.xml_escape = json2xml_1.escapeXml;
|
|
308
303
|
/*
|
|
309
304
|
// ========================================================================
|
|
310
305
|
|
|
@@ -135,14 +135,14 @@ var Control = /** @class */ (function () {
|
|
|
135
135
|
else {
|
|
136
136
|
itemContainer.append(icon);
|
|
137
137
|
}
|
|
138
|
-
switch (item.
|
|
139
|
-
case '
|
|
138
|
+
switch (item.key) {
|
|
139
|
+
case 'undo':
|
|
140
140
|
_this.lf.on('history:change', function (_a) {
|
|
141
141
|
var undoAble = _a.data.undoAble;
|
|
142
142
|
itemContainer.className = undoAble ? NORMAL : DISABLED;
|
|
143
143
|
});
|
|
144
144
|
break;
|
|
145
|
-
case '
|
|
145
|
+
case 'redo':
|
|
146
146
|
_this.lf.on('history:change', function (_a) {
|
|
147
147
|
var redoAble = _a.data.redoAble;
|
|
148
148
|
itemContainer.className = redoAble ? NORMAL : DISABLED;
|
package/lib/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export * from './bpmn-elements-adapter';
|
|
|
5
5
|
export * from './bpmn-adapter/xml2json';
|
|
6
6
|
export * from './bpmn-adapter/json2xml';
|
|
7
7
|
export * from './turbo-adapter';
|
|
8
|
+
export * from './pool';
|
|
8
9
|
export * from './dynamic-group';
|
|
9
10
|
export * from './insert-node-in-polyline';
|
|
10
11
|
export * from './tools/label';
|
package/lib/index.js
CHANGED
|
@@ -23,6 +23,8 @@ __exportStar(require("./bpmn-adapter/xml2json"), exports);
|
|
|
23
23
|
__exportStar(require("./bpmn-adapter/json2xml"), exports);
|
|
24
24
|
// Adapter
|
|
25
25
|
__exportStar(require("./turbo-adapter"), exports);
|
|
26
|
+
// 泳道相关
|
|
27
|
+
__exportStar(require("./pool"), exports);
|
|
26
28
|
// 新版 Group
|
|
27
29
|
__exportStar(require("./dynamic-group"), exports);
|
|
28
30
|
// 折线上动态插入节点
|
|
@@ -130,38 +130,54 @@ function getMidPoints(cur, key, orientation, radius) {
|
|
|
130
130
|
return [];
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
-
|
|
133
|
+
/**
|
|
134
|
+
* 生成局部路径片段(包含圆角)
|
|
135
|
+
* - 输入为上一个顶点、当前拐点、下一个顶点,计算方向组合并选择圆弧象限
|
|
136
|
+
* - 将圆角半径限制在相邻两段长度的一半以内,避免过度弯曲
|
|
137
|
+
* @param prevPoint 上一个顶点
|
|
138
|
+
* @param cornerPoint 当前拐点(圆角所在拐点)
|
|
139
|
+
* @param nextPoint 下一个顶点
|
|
140
|
+
* @param cornerRadius 圆角半径上限
|
|
141
|
+
* @returns 局部 path 字符串(包含 L/Q 操作)
|
|
142
|
+
*/
|
|
143
|
+
function getPartialPath(prevPoint, cornerPoint, nextPoint, cornerRadius) {
|
|
134
144
|
var _a;
|
|
135
|
-
//
|
|
136
|
-
var
|
|
137
|
-
var
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
145
|
+
// 轴对齐容差(像素),用于消除微小误差
|
|
146
|
+
var epsilon = 1;
|
|
147
|
+
var resolveDir = function (a, b) {
|
|
148
|
+
var dx = b[0] - a[0];
|
|
149
|
+
var dy = b[1] - a[1];
|
|
150
|
+
var adx = Math.abs(dx);
|
|
151
|
+
var ady = Math.abs(dy);
|
|
152
|
+
if (ady <= epsilon && adx > epsilon) {
|
|
153
|
+
return dx < 0 ? 'l' : 'r';
|
|
154
|
+
}
|
|
155
|
+
if (adx <= epsilon && ady > epsilon) {
|
|
156
|
+
return dy < 0 ? 't' : 'b';
|
|
157
|
+
}
|
|
158
|
+
if (adx <= epsilon && ady <= epsilon) {
|
|
159
|
+
return '';
|
|
160
|
+
}
|
|
161
|
+
// 非严格对齐时,选择更接近的轴
|
|
162
|
+
return adx < ady ? (dx < 0 ? 'l' : 'r') : dy < 0 ? 't' : 'b';
|
|
163
|
+
};
|
|
164
|
+
var dir1 = resolveDir(prevPoint, cornerPoint);
|
|
165
|
+
var dir2 = resolveDir(cornerPoint, nextPoint);
|
|
166
|
+
var r = Math.min(Math.hypot(cornerPoint[0] - prevPoint[0], cornerPoint[1] - prevPoint[1]) /
|
|
167
|
+
2, Math.hypot(nextPoint[0] - cornerPoint[0], nextPoint[1] - cornerPoint[1]) /
|
|
168
|
+
2, cornerRadius) || (1 / 5) * cornerRadius;
|
|
154
169
|
var key = "".concat(dir1).concat(dir2);
|
|
155
170
|
var orientation = directionMap[key] || '-';
|
|
156
|
-
var path =
|
|
171
|
+
var path = '';
|
|
157
172
|
if (orientation === '-') {
|
|
158
|
-
|
|
173
|
+
// 仅移动到当前拐点,由下一次迭代决定如何从拐点继续(直线或圆角)
|
|
174
|
+
path += "L ".concat(cornerPoint[0], " ").concat(cornerPoint[1]);
|
|
159
175
|
}
|
|
160
176
|
else {
|
|
161
|
-
var _b = __read(getMidPoints(
|
|
177
|
+
var _b = __read(getMidPoints(cornerPoint, key, orientation, r), 2), mid1 = _b[0], mid2 = _b[1];
|
|
162
178
|
if (mid1 && mid2) {
|
|
163
|
-
path += "L ".concat(mid1[0], " ").concat(mid1[1], " Q ").concat(
|
|
164
|
-
_a = __read(mid2, 2),
|
|
179
|
+
path += "L ".concat(mid1[0], " ").concat(mid1[1], " Q ").concat(cornerPoint[0], " ").concat(cornerPoint[1], " ").concat(mid2[0], " ").concat(mid2[1]);
|
|
180
|
+
_a = __read(mid2, 2), cornerPoint[0] = _a[0], cornerPoint[1] = _a[1];
|
|
165
181
|
}
|
|
166
182
|
}
|
|
167
183
|
return path;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 基于DynamicGroup重新实现的泳道节点组件
|
|
3
|
+
* 继承DynamicGroupNodeModel和DynamicGroupNode,提供泳道特定功能
|
|
4
|
+
*/
|
|
5
|
+
import LogicFlow from '@logicflow/core';
|
|
6
|
+
import { DynamicGroupNodeModel } from '../dynamic-group';
|
|
7
|
+
export declare class LaneModel extends DynamicGroupNodeModel {
|
|
8
|
+
readonly isLane: boolean;
|
|
9
|
+
defaultZIndex: number;
|
|
10
|
+
initNodeData(data: LogicFlow.NodeConfig): void;
|
|
11
|
+
setAttributes(): void;
|
|
12
|
+
setZIndex(zIndex: number): void;
|
|
13
|
+
/**
|
|
14
|
+
* 重写折叠方法 - 泳道不支持折叠
|
|
15
|
+
*/
|
|
16
|
+
toggleCollapse(): void;
|
|
17
|
+
/**
|
|
18
|
+
* 获取所属泳池ID
|
|
19
|
+
*/
|
|
20
|
+
getPoolId(): string | null;
|
|
21
|
+
/**
|
|
22
|
+
* 获取所属泳池模型
|
|
23
|
+
*/
|
|
24
|
+
getPoolModel(): any;
|
|
25
|
+
/**
|
|
26
|
+
* 动态修改泳道属性
|
|
27
|
+
*/
|
|
28
|
+
changeAttribute({ width, height, x, y }: any): void;
|
|
29
|
+
/**
|
|
30
|
+
* 重写获取数据方法,添加泳道特定属性
|
|
31
|
+
*/
|
|
32
|
+
getData(): LogicFlow.NodeData;
|
|
33
|
+
/**
|
|
34
|
+
* 重写 isAllowAppendIn,禁止 Lane 嵌套
|
|
35
|
+
*/
|
|
36
|
+
isAllowAppendIn(nodeData: LogicFlow.NodeData): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* 获取需要移动的节点
|
|
39
|
+
* @param groupModel
|
|
40
|
+
*/
|
|
41
|
+
getNodesInGroup(groupModel: DynamicGroupNodeModel): string[];
|
|
42
|
+
getNodeStyle(): {
|
|
43
|
+
[x: string]: unknown;
|
|
44
|
+
fill?: string | undefined;
|
|
45
|
+
stroke?: string | undefined;
|
|
46
|
+
strokeWidth?: number | undefined;
|
|
47
|
+
radius?: number | undefined;
|
|
48
|
+
rx?: number | undefined;
|
|
49
|
+
ry?: number | undefined;
|
|
50
|
+
width?: number | undefined;
|
|
51
|
+
height?: number | undefined;
|
|
52
|
+
path?: string | undefined;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* 获取文本样式
|
|
56
|
+
*/
|
|
57
|
+
getTextStyle(): {
|
|
58
|
+
[x: string]: unknown;
|
|
59
|
+
fill?: string | undefined;
|
|
60
|
+
stroke?: string | undefined;
|
|
61
|
+
strokeWidth?: number | undefined;
|
|
62
|
+
radius?: number | undefined;
|
|
63
|
+
rx?: number | undefined;
|
|
64
|
+
ry?: number | undefined;
|
|
65
|
+
width?: number | undefined;
|
|
66
|
+
height?: number | undefined;
|
|
67
|
+
path?: string | undefined;
|
|
68
|
+
overflowMode?: "default" | "autoWrap" | "ellipsis" | undefined;
|
|
69
|
+
textWidth?: number | undefined; /**
|
|
70
|
+
* 获取子泳道
|
|
71
|
+
*/
|
|
72
|
+
background?: LogicFlow.CommonTheme | undefined;
|
|
73
|
+
wrapPadding?: string | undefined;
|
|
74
|
+
color?: string | undefined;
|
|
75
|
+
fontSize: number;
|
|
76
|
+
lineHeight?: number | undefined;
|
|
77
|
+
textAnchor?: "middle" | "start" | "end" | undefined;
|
|
78
|
+
dominantBaseline?: "middle" | "central" | "auto" | "text-bottom" | "alphabetic" | "ideographic" | "mathematical" | "hanging" | "text-top" | undefined;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* 获取子泳道
|
|
82
|
+
*/
|
|
83
|
+
getSubNodes(): any[];
|
|
84
|
+
/**
|
|
85
|
+
* 初始化文本位置 - 根据布局方向设置文本位置
|
|
86
|
+
*/
|
|
87
|
+
updateTextPosition(): void;
|
|
88
|
+
}
|
|
89
|
+
declare const _default: null;
|
|
90
|
+
export default _default;
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __assign = (this && this.__assign) || function () {
|
|
18
|
+
__assign = Object.assign || function(t) {
|
|
19
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
+
s = arguments[i];
|
|
21
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
+
t[p] = s[p];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
return __assign.apply(this, arguments);
|
|
27
|
+
};
|
|
28
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
29
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
30
|
+
if (!m) return o;
|
|
31
|
+
var i = m.call(o), r, ar = [], e;
|
|
32
|
+
try {
|
|
33
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
34
|
+
}
|
|
35
|
+
catch (error) { e = { error: error }; }
|
|
36
|
+
finally {
|
|
37
|
+
try {
|
|
38
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
39
|
+
}
|
|
40
|
+
finally { if (e) throw e.error; }
|
|
41
|
+
}
|
|
42
|
+
return ar;
|
|
43
|
+
};
|
|
44
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
45
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
46
|
+
if (ar || !(i in from)) {
|
|
47
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
48
|
+
ar[i] = from[i];
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
52
|
+
};
|
|
53
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
+
exports.LaneModel = void 0;
|
|
55
|
+
var dynamic_group_1 = require("../dynamic-group");
|
|
56
|
+
var lodash_es_1 = require("lodash-es");
|
|
57
|
+
var constant_1 = require("./constant");
|
|
58
|
+
var LaneModel = /** @class */ (function (_super) {
|
|
59
|
+
__extends(LaneModel, _super);
|
|
60
|
+
function LaneModel() {
|
|
61
|
+
var _this = _super.apply(this, __spreadArray([], __read(arguments), false)) || this;
|
|
62
|
+
_this.isLane = true;
|
|
63
|
+
_this.defaultZIndex = -1;
|
|
64
|
+
return _this;
|
|
65
|
+
}
|
|
66
|
+
LaneModel.prototype.initNodeData = function (data) {
|
|
67
|
+
var _a;
|
|
68
|
+
_super.prototype.initNodeData.call(this, data);
|
|
69
|
+
// 泳道特定配置
|
|
70
|
+
this.width = data.width || constant_1.laneConfig.defaultWidth;
|
|
71
|
+
this.height = data.height || constant_1.laneConfig.defaultHeight;
|
|
72
|
+
this.draggable = true; // 允许拖拽(实际拖拽逻辑由泳池控制)
|
|
73
|
+
this.resizable = true; // 允许调整大小
|
|
74
|
+
this.rotatable = false; // 禁止旋转
|
|
75
|
+
// 设置泳道层级
|
|
76
|
+
// 如果传入了zIndex,使用传入的值,否则默认为2
|
|
77
|
+
// 泳道层级应该比所属泳池高,确保显示在泳池上方
|
|
78
|
+
this.defaultZIndex = data.zIndex || -1;
|
|
79
|
+
this.setZIndex(this.defaultZIndex);
|
|
80
|
+
this.autoToFront = true;
|
|
81
|
+
this.text.editable = true;
|
|
82
|
+
this.style.stroke = '#000';
|
|
83
|
+
this.style.strokeWidth = 1;
|
|
84
|
+
// 泳道属性配置
|
|
85
|
+
this.properties = __assign(__assign({}, this.properties), { processRef: '', panels: ['processRef'], direction: ((_a = data.properties) === null || _a === void 0 ? void 0 : _a.direction) || 'vertical' });
|
|
86
|
+
// 设置折叠尺寸(泳道不支持折叠,设置为与正常尺寸相同)
|
|
87
|
+
this.collapsedWidth = this.width;
|
|
88
|
+
this.collapsedHeight = this.height;
|
|
89
|
+
this.expandWidth = this.width;
|
|
90
|
+
this.expandHeight = this.height;
|
|
91
|
+
};
|
|
92
|
+
LaneModel.prototype.setAttributes = function () {
|
|
93
|
+
_super.prototype.setAttributes.call(this);
|
|
94
|
+
this.updateTextPosition();
|
|
95
|
+
};
|
|
96
|
+
LaneModel.prototype.setZIndex = function (zIndex) {
|
|
97
|
+
this.zIndex = Math.min(zIndex, this.defaultZIndex) || this.defaultZIndex;
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* 重写折叠方法 - 泳道不支持折叠
|
|
101
|
+
*/
|
|
102
|
+
LaneModel.prototype.toggleCollapse = function () {
|
|
103
|
+
// 泳道不支持折叠功能,保持展开状态
|
|
104
|
+
this.isCollapsed = false;
|
|
105
|
+
this.setProperties({ isCollapsed: false });
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* 获取所属泳池ID
|
|
109
|
+
*/
|
|
110
|
+
LaneModel.prototype.getPoolId = function () {
|
|
111
|
+
var _this = this;
|
|
112
|
+
try {
|
|
113
|
+
// 检查graphModel是否存在
|
|
114
|
+
if (!this.graphModel) {
|
|
115
|
+
console.warn('GraphModel is not available');
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
// 安全地获取泳池ID
|
|
119
|
+
var poolModel = this.graphModel.nodes.find(function (node) {
|
|
120
|
+
return node.children && node.children.has(_this.id);
|
|
121
|
+
});
|
|
122
|
+
return (poolModel === null || poolModel === void 0 ? void 0 : poolModel.id) || null;
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
console.error('Error getting pool ID:', error);
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* 获取所属泳池模型
|
|
131
|
+
*/
|
|
132
|
+
LaneModel.prototype.getPoolModel = function () {
|
|
133
|
+
try {
|
|
134
|
+
var poolId = this.getPoolId();
|
|
135
|
+
if (!poolId) {
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
// 检查graphModel是否存在
|
|
139
|
+
if (!this.graphModel) {
|
|
140
|
+
console.warn('GraphModel is not available for getting pool model');
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
var poolModel = this.graphModel.getNodeModelById(poolId);
|
|
144
|
+
return poolModel || null;
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
console.error('Error getting pool model:', error);
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* 动态修改泳道属性
|
|
153
|
+
*/
|
|
154
|
+
LaneModel.prototype.changeAttribute = function (_a) {
|
|
155
|
+
var width = _a.width, height = _a.height, x = _a.x, y = _a.y;
|
|
156
|
+
if (width)
|
|
157
|
+
this.width = width; // 更新宽度
|
|
158
|
+
if (height)
|
|
159
|
+
this.height = height; // 更新高度
|
|
160
|
+
if (x)
|
|
161
|
+
this.x = x; // 更新X坐标
|
|
162
|
+
if (y)
|
|
163
|
+
this.y = y; // 更新Y坐标
|
|
164
|
+
};
|
|
165
|
+
/**
|
|
166
|
+
* 重写获取数据方法,添加泳道特定属性
|
|
167
|
+
*/
|
|
168
|
+
LaneModel.prototype.getData = function () {
|
|
169
|
+
var data = _super.prototype.getData.call(this);
|
|
170
|
+
// const poolModel = this.getPoolModel()
|
|
171
|
+
return __assign(__assign({}, data), { properties: __assign(__assign({}, data.properties), { width: this.width, height: this.height, processRef: this.properties.processRef, direction: this.properties.direction }) });
|
|
172
|
+
};
|
|
173
|
+
/**
|
|
174
|
+
* 重写 isAllowAppendIn,禁止 Lane 嵌套
|
|
175
|
+
*/
|
|
176
|
+
LaneModel.prototype.isAllowAppendIn = function (nodeData) {
|
|
177
|
+
// 禁止 Lane 节点被添加到 Lane 中
|
|
178
|
+
return String(nodeData.type) !== 'lane';
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* 获取需要移动的节点
|
|
182
|
+
* @param groupModel
|
|
183
|
+
*/
|
|
184
|
+
LaneModel.prototype.getNodesInGroup = function (groupModel) {
|
|
185
|
+
var _this = this;
|
|
186
|
+
var nodeIds = [];
|
|
187
|
+
var parent = groupModel.properties.parent, isDragging = groupModel.isDragging;
|
|
188
|
+
if (isDragging && parent) {
|
|
189
|
+
nodeIds.push(parent);
|
|
190
|
+
}
|
|
191
|
+
(0, lodash_es_1.forEach)(Array.from(groupModel.children), function (nodeId) {
|
|
192
|
+
var nodeModel = _this.graphModel.getNodeModelById(nodeId);
|
|
193
|
+
// 只有非 Lane 类型的节点才会被带动
|
|
194
|
+
if (nodeModel &&
|
|
195
|
+
!nodeModel.isDragging &&
|
|
196
|
+
String(nodeModel.type) !== 'lane') {
|
|
197
|
+
nodeIds.push(nodeId);
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
return nodeIds;
|
|
201
|
+
};
|
|
202
|
+
LaneModel.prototype.getNodeStyle = function () {
|
|
203
|
+
var style = _super.prototype.getNodeStyle.call(this);
|
|
204
|
+
style.strokeWidth = 2;
|
|
205
|
+
return style;
|
|
206
|
+
};
|
|
207
|
+
/**
|
|
208
|
+
* 获取文本样式
|
|
209
|
+
*/
|
|
210
|
+
LaneModel.prototype.getTextStyle = function () {
|
|
211
|
+
var _a = this.properties.isHorizontal, isHorizontal = _a === void 0 ? false : _a;
|
|
212
|
+
var style = _super.prototype.getTextStyle.call(this);
|
|
213
|
+
style.overflowMode = 'ellipsis';
|
|
214
|
+
style.strokeWidth = 2;
|
|
215
|
+
style.textWidth = isHorizontal ? this.height : this.width;
|
|
216
|
+
style.textHeight = isHorizontal ? this.width : this.height;
|
|
217
|
+
if (isHorizontal) {
|
|
218
|
+
style.transform = 'rotate(-90deg)';
|
|
219
|
+
style.textAlign = 'center';
|
|
220
|
+
}
|
|
221
|
+
return style;
|
|
222
|
+
};
|
|
223
|
+
/**
|
|
224
|
+
* 获取子泳道
|
|
225
|
+
*/
|
|
226
|
+
LaneModel.prototype.getSubNodes = function () {
|
|
227
|
+
var _this = this;
|
|
228
|
+
var children = [];
|
|
229
|
+
Array.from(this.children).forEach(function (childId) {
|
|
230
|
+
var childModel = _this.graphModel.getNodeModelById(childId);
|
|
231
|
+
if (childModel) {
|
|
232
|
+
children.push(childModel);
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
return children;
|
|
236
|
+
};
|
|
237
|
+
/**
|
|
238
|
+
* 初始化文本位置 - 根据布局方向设置文本位置
|
|
239
|
+
*/
|
|
240
|
+
LaneModel.prototype.updateTextPosition = function () {
|
|
241
|
+
if (this.properties.isHorizontal) {
|
|
242
|
+
// 横向泳池:文本显示在左侧标题区域
|
|
243
|
+
this.text.x = this.x - this.width / 2 + constant_1.laneConfig.titleSize / 2;
|
|
244
|
+
this.text.y = this.y;
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
// 纵向泳池:文本显示在顶部标题区域
|
|
248
|
+
this.text.x = this.x;
|
|
249
|
+
this.text.y = this.y - this.height / 2 + constant_1.laneConfig.titleSize / 2;
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
return LaneModel;
|
|
253
|
+
}(dynamic_group_1.DynamicGroupNodeModel));
|
|
254
|
+
exports.LaneModel = LaneModel;
|
|
255
|
+
exports.default = null;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 基于DynamicGroup重新实现的泳道节点组件
|
|
3
|
+
* 继承DynamicGroupNodeModel和DynamicGroupNode,提供泳道特定功能
|
|
4
|
+
*/
|
|
5
|
+
import { h } from '@logicflow/core';
|
|
6
|
+
import { DynamicGroupNode } from '../dynamic-group';
|
|
7
|
+
export declare class LaneView extends DynamicGroupNode {
|
|
8
|
+
getAppendAreaShape(): h.JSX.Element | null;
|
|
9
|
+
getShape(): import("preact").VNode<import("preact").ClassAttributes<HTMLElement>>;
|
|
10
|
+
/**
|
|
11
|
+
* 获取操作图标
|
|
12
|
+
*/
|
|
13
|
+
getOperateIcons(): (import("preact").VNode<import("preact").ClassAttributes<HTMLElement> & {
|
|
14
|
+
cursor: string;
|
|
15
|
+
onClick: () => void;
|
|
16
|
+
}> | import("preact").VNode<import("preact").ClassAttributes<HTMLElement> & {
|
|
17
|
+
cursor: string;
|
|
18
|
+
onClick: () => void;
|
|
19
|
+
width: number;
|
|
20
|
+
height: number;
|
|
21
|
+
transform: string;
|
|
22
|
+
}>)[];
|
|
23
|
+
addBeforeLaneIcon(isHorizontal: boolean, callback: () => void): import("preact").VNode<import("preact").ClassAttributes<HTMLElement> & {
|
|
24
|
+
cursor: string;
|
|
25
|
+
onClick: () => void;
|
|
26
|
+
}>;
|
|
27
|
+
addAfterLaneIcon(isHorizontal: boolean, callback: () => void): import("preact").VNode<import("preact").ClassAttributes<HTMLElement> & {
|
|
28
|
+
cursor: string;
|
|
29
|
+
onClick: () => void;
|
|
30
|
+
}>;
|
|
31
|
+
deleteLaneIcon(callback: () => void): import("preact").VNode<import("preact").ClassAttributes<HTMLElement> & {
|
|
32
|
+
cursor: string;
|
|
33
|
+
onClick: () => void;
|
|
34
|
+
width: number;
|
|
35
|
+
height: number;
|
|
36
|
+
transform: string;
|
|
37
|
+
}>;
|
|
38
|
+
}
|
|
39
|
+
declare const _default: null;
|
|
40
|
+
export default _default;
|