@logicflow/extension 2.2.0 → 2.2.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/README.md +16 -0
- package/dist/index.css +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/es/NodeResize/node/RectResize.d.ts +0 -6
- package/es/NodeResize/node/RectResize.js +2 -11
- 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.d.ts +1 -0
- package/es/components/control/index.js +24 -11
- package/es/components/mini-map/index.js +1 -1
- package/es/dynamic-group/model.d.ts +2 -1
- package/es/dynamic-group/model.js +28 -11
- package/es/dynamic-group/node.js +1 -0
- package/es/index.css +1 -1
- package/es/index.d.ts +1 -0
- package/es/index.js +2 -0
- package/es/insert-node-in-polyline/index.js +11 -35
- package/es/materials/curved-edge/index.js +49 -21
- package/es/materials/group/GroupNode.d.ts +0 -6
- package/es/materials/group/GroupNode.js +1 -6
- 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/es/style/index.css +1 -1
- package/es/style/raw.d.ts +1 -1
- package/es/style/raw.js +1 -1
- package/es/tools/label/LabelOverlay.js +3 -3
- package/es/tools/label/mediumEditor.d.ts +1 -1
- package/es/tools/label/mediumEditor.js +89 -52
- package/es/tools/snapshot/index.d.ts +7 -3
- package/es/tools/snapshot/index.js +72 -77
- package/lib/NodeResize/node/RectResize.d.ts +0 -6
- package/lib/NodeResize/node/RectResize.js +1 -10
- 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.d.ts +1 -0
- package/lib/components/control/index.js +24 -11
- package/lib/components/mini-map/index.js +1 -1
- package/lib/dynamic-group/model.d.ts +2 -1
- package/lib/dynamic-group/model.js +28 -11
- package/lib/dynamic-group/node.js +1 -0
- package/lib/index.css +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +2 -0
- package/lib/insert-node-in-polyline/index.js +10 -34
- package/lib/materials/curved-edge/index.js +49 -21
- package/lib/materials/group/GroupNode.d.ts +0 -6
- package/lib/materials/group/GroupNode.js +1 -6
- 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/lib/style/index.css +1 -1
- package/lib/style/raw.d.ts +1 -1
- package/lib/style/raw.js +1 -1
- package/lib/tools/label/LabelOverlay.js +2 -2
- package/lib/tools/label/mediumEditor.d.ts +1 -1
- package/lib/tools/label/mediumEditor.js +91 -53
- package/lib/tools/snapshot/index.d.ts +7 -3
- package/lib/tools/snapshot/index.js +72 -77
- package/package.json +10 -7
- package/.turbo/turbo-build.log +0 -38
- package/CHANGELOG.md +0 -1766
- package/__test__/bpmn-adapter.test.js +0 -227
- package/es/materials/curved-edge/__test__/curved-edge.test.d.ts +0 -1
- package/es/materials/curved-edge/__test__/curved-edge.test.js +0 -18
- package/jest.config.js +0 -198
- package/lib/materials/curved-edge/__test__/curved-edge.test.d.ts +0 -1
- package/lib/materials/curved-edge/__test__/curved-edge.test.js +0 -20
- package/rollup.config.js +0 -52
- package/src/NodeResize/BasicShape/Ellipse.tsx +0 -22
- package/src/NodeResize/BasicShape/Polygon.tsx +0 -24
- package/src/NodeResize/BasicShape/Rect.tsx +0 -44
- package/src/NodeResize/control/Control.tsx +0 -537
- package/src/NodeResize/control/ControlGroup.tsx +0 -76
- package/src/NodeResize/control/Util.ts +0 -206
- package/src/NodeResize/index.ts +0 -26
- package/src/NodeResize/node/DiamondResize.tsx +0 -149
- package/src/NodeResize/node/EllipseResize.tsx +0 -140
- package/src/NodeResize/node/HtmlResize.tsx +0 -125
- package/src/NodeResize/node/RectResize.tsx +0 -146
- package/src/NodeResize/node/index.ts +0 -4
- package/src/bpmn/constant.ts +0 -56
- package/src/bpmn/events/EndEvent.ts +0 -73
- package/src/bpmn/events/StartEvent.ts +0 -52
- package/src/bpmn/events/index.ts +0 -2
- package/src/bpmn/flow/SequenceFlow.ts +0 -25
- package/src/bpmn/flow/index.ts +0 -1
- package/src/bpmn/gateways/ExclusiveGateway.ts +0 -71
- package/src/bpmn/gateways/index.ts +0 -1
- package/src/bpmn/getBpmnId.ts +0 -31
- package/src/bpmn/index.ts +0 -60
- package/src/bpmn/tasks/ServiceTask.ts +0 -63
- package/src/bpmn/tasks/UserTask.ts +0 -64
- package/src/bpmn/tasks/index.ts +0 -2
- package/src/bpmn-adapter/bpmnIds.ts +0 -31
- package/src/bpmn-adapter/index.ts +0 -835
- package/src/bpmn-adapter/json2xml.ts +0 -127
- package/src/bpmn-adapter/xml2json.ts +0 -544
- package/src/bpmn-elements/README.md +0 -223
- package/src/bpmn-elements/__tests__/definition.test.js +0 -72
- package/src/bpmn-elements/index.d.ts +0 -26
- package/src/bpmn-elements/index.ts +0 -107
- package/src/bpmn-elements/presets/Event/EndEventFactory.ts +0 -114
- package/src/bpmn-elements/presets/Event/IntermediateCatchEvent.ts +0 -108
- package/src/bpmn-elements/presets/Event/IntermediateThrowEvent.ts +0 -109
- package/src/bpmn-elements/presets/Event/StartEventFactory.ts +0 -114
- package/src/bpmn-elements/presets/Event/boundaryEventFactory.ts +0 -117
- package/src/bpmn-elements/presets/Event/index.ts +0 -14
- package/src/bpmn-elements/presets/Flow/flow.d.ts +0 -6
- package/src/bpmn-elements/presets/Flow/index.ts +0 -8
- package/src/bpmn-elements/presets/Flow/manhattan.ts +0 -691
- package/src/bpmn-elements/presets/Flow/sequenceFlow.ts +0 -65
- package/src/bpmn-elements/presets/Gateway/gateway.ts +0 -107
- package/src/bpmn-elements/presets/Gateway/index.ts +0 -23
- package/src/bpmn-elements/presets/Pool/Lane.ts +0 -211
- package/src/bpmn-elements/presets/Pool/Pool.ts +0 -284
- package/src/bpmn-elements/presets/Pool/index.ts +0 -89
- package/src/bpmn-elements/presets/Task/index.ts +0 -122
- package/src/bpmn-elements/presets/Task/subProcess.ts +0 -189
- package/src/bpmn-elements/presets/Task/task.ts +0 -193
- package/src/bpmn-elements/presets/icons.ts +0 -155
- package/src/bpmn-elements/utils.ts +0 -52
- package/src/bpmn-elements-adapter/README.md +0 -293
- package/src/bpmn-elements-adapter/__tests__/adapter_in.test.js +0 -528
- package/src/bpmn-elements-adapter/__tests__/adapter_out.test.js +0 -569
- package/src/bpmn-elements-adapter/constant.ts +0 -76
- package/src/bpmn-elements-adapter/index.ts +0 -1134
- package/src/bpmn-elements-adapter/json2xml.ts +0 -91
- package/src/bpmn-elements-adapter/xml2json.ts +0 -548
- package/src/components/context-menu/index.ts +0 -253
- package/src/components/control/index.ts +0 -141
- package/src/components/dnd-panel/index.ts +0 -137
- package/src/components/highlight/index.ts +0 -227
- package/src/components/menu/index.ts +0 -748
- package/src/components/mini-map/index.ts +0 -686
- package/src/components/selection-select/index.ts +0 -387
- package/src/dynamic-group/index.ts +0 -775
- package/src/dynamic-group/model.ts +0 -562
- package/src/dynamic-group/node.ts +0 -288
- package/src/dynamic-group/utils.ts +0 -46
- package/src/index.less +0 -1
- package/src/index.ts +0 -45
- package/src/insert-node-in-polyline/edge.ts +0 -175
- package/src/insert-node-in-polyline/index.ts +0 -187
- package/src/materials/curved-edge/__test__/curved-edge.test.ts +0 -46
- package/src/materials/curved-edge/index.ts +0 -185
- package/src/materials/group/GroupNode.ts +0 -442
- package/src/materials/group/index.ts +0 -542
- package/src/materials/node-selection/index.ts +0 -380
- package/src/mindmap/fakerRoot.ts +0 -19
- package/src/mindmap/index.ts +0 -328
- package/src/mindmap/markContent.ts +0 -81
- package/src/mindmap/markContentOption.ts +0 -81
- package/src/mindmap/markEntity.ts +0 -82
- package/src/mindmap/markRoot.ts +0 -83
- package/src/mindmap/theme.ts +0 -11
- package/src/rect-label-node/RectLabelNodeView.ts +0 -33
- package/src/rect-label-node/index.ts +0 -15
- package/src/style/index.less +0 -342
- package/src/style/raw.ts +0 -295
- package/src/tools/auto-layout/index.ts +0 -282
- package/src/tools/flow-path/index.ts +0 -233
- package/src/tools/label/Label.tsx +0 -357
- package/src/tools/label/LabelModel.ts +0 -83
- package/src/tools/label/LabelOverlay.tsx +0 -158
- package/src/tools/label/algorithm.ts +0 -42
- package/src/tools/label/index.ts +0 -479
- package/src/tools/label/mediumEditor.ts +0 -94
- package/src/tools/label/utils.ts +0 -395
- package/src/tools/proximity-connect/index.ts +0 -435
- package/src/tools/snapshot/README.md +0 -145
- package/src/tools/snapshot/index.ts +0 -718
- package/src/tools/snapshot/utils.ts +0 -163
- package/src/turbo-adapter/index.ts +0 -212
- package/stats.html +0 -4842
- package/tsconfig.json +0 -18
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
## 内置基础节点
|
|
2
|
-
|
|
3
|
-
### 事件
|
|
4
|
-
|
|
5
|
-
**开始事件 (bpmn:startEvent)**
|
|
6
|
-
|
|
7
|
-
- 开始事件
|
|
8
|
-
- 中断子流程事件 (与开始事件通过isInterrupting属性区分,即是否有isInterrupting属性, `isInterrupting = 'false'`)
|
|
9
|
-
- 非中断子流程事件 (与开始事件通过isInterrupting属性区分,即是否有isInterrupting属性, `isInterrupting = 'true'`)
|
|
10
|
-
|
|
11
|
-
**边界事件 (bpmn:boundaryEvent)**
|
|
12
|
-
|
|
13
|
-
- 中断边界事件 (属性`cancelActivity = 'true'`)
|
|
14
|
-
- 非中断边界事件 (属性`cancelActivity = 'false'`)
|
|
15
|
-
|
|
16
|
-
**中间事件**
|
|
17
|
-
|
|
18
|
-
- 捕捉事件 (bpmn:intermediateCatchEvent)
|
|
19
|
-
|
|
20
|
-
- 抛出事件 (bpmn:intermediateThrowEvent)
|
|
21
|
-
|
|
22
|
-
**结束事件 (bpmn:endEvent)**
|
|
23
|
-
|
|
24
|
-
### 任务
|
|
25
|
-
|
|
26
|
-
- 服务任务 (bpmn:serviceTask)
|
|
27
|
-
- 用户任务 (bpmn:userTask)
|
|
28
|
-
|
|
29
|
-
### 网关
|
|
30
|
-
|
|
31
|
-
- 并行网关 (bpmn:parallelGateway)
|
|
32
|
-
- 排他网关 (bpmn:exclusiveGateway)
|
|
33
|
-
- 包容网关 (bpmn:inclusiveGateway)
|
|
34
|
-
|
|
35
|
-
### 子流程
|
|
36
|
-
|
|
37
|
-
- 嵌入子流程 (bpmn:subProcess)
|
|
38
|
-
|
|
39
|
-
### 流(flow)
|
|
40
|
-
|
|
41
|
-
- 顺序流 (bpmn:sequenceFlow) 可以通过`isDefaultFlow`(是否为缺省流)属性改变顺序流的样式
|
|
42
|
-
|
|
43
|
-
## 节点扩展
|
|
44
|
-
|
|
45
|
-
### 事件
|
|
46
|
-
|
|
47
|
-
在基础节点的基础上,我们需要通过定义definition属性来扩展事件节点。
|
|
48
|
-
|
|
49
|
-
``` ts
|
|
50
|
-
import { h } from '@logicflow/core'
|
|
51
|
-
|
|
52
|
-
// 例如,我们想要扩展出时间开始事件,时间捕获事件,时间边界事件
|
|
53
|
-
const [definition, setDefinition] = lf.useDefinition()
|
|
54
|
-
const customDefinition = [
|
|
55
|
-
{
|
|
56
|
-
// 为startEvent、intermediateCatchEvent、boundaryEvent添加definition
|
|
57
|
-
nodes: ['startEvent', 'intermediateCatchEvent', 'boundaryEvent'],
|
|
58
|
-
definition: {
|
|
59
|
-
/**
|
|
60
|
-
* definition的type属性,对应XML数据中的节点名
|
|
61
|
-
* 例如一个时间非中断边界事件的XML数据如下:
|
|
62
|
-
* <bpmn:boundaryEvent id="BoundaryEvent_1" cancelActivity="false" attachedToRef="Task_1">
|
|
63
|
-
* <bpmn:timerEventDefinition>
|
|
64
|
-
* <bpmn:timeDuration>
|
|
65
|
-
* P1D
|
|
66
|
-
* </bpmn:timeDuration>
|
|
67
|
-
* </bpmn:timerEventDefinition>
|
|
68
|
-
* </bpmn:boundaryEvent>
|
|
69
|
-
*/
|
|
70
|
-
type: 'bpmn:timerEventDefinition',
|
|
71
|
-
// icon可以是svg的path路径m, 也可以是@logicflow/core 导出的h函数生成的svg, 这里是通过h函数生成的svg
|
|
72
|
-
icon: timerIcon,
|
|
73
|
-
/**
|
|
74
|
-
* 对应definition需要的属性,例如这里是timerType和timerValue
|
|
75
|
-
* timerType值可以"timeCycle", "timerDate", "timeDuration", 用于区分 <bpmn:timeCycle/>、<bpmn:timeDate/>、<bpmn:timeDuration/>
|
|
76
|
-
* timerValue是timerType对应的cron表达式
|
|
77
|
-
* 最终会生成 `<bpmn:${timerType} xsi:type="bpmn:tFormalExpression">${timerValue}</bpmn:${timerType}>`
|
|
78
|
-
*/
|
|
79
|
-
properties: {
|
|
80
|
-
timerType: '',
|
|
81
|
-
timerValue: ''
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
]
|
|
86
|
-
|
|
87
|
-
setDefinition(customDefinition)
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
<details>
|
|
91
|
-
<summary>timerIcon的定义如下:</summary>
|
|
92
|
-
<pre><code>
|
|
93
|
-
import { h } from '@logicflow/core'
|
|
94
|
-
const timerIcon = [
|
|
95
|
-
h('circle', {
|
|
96
|
-
cx: 18,
|
|
97
|
-
cy: 18,
|
|
98
|
-
r: 11,
|
|
99
|
-
style:
|
|
100
|
-
'stroke-linecap: round;stroke-linejoin: round;stroke: rgb(34, 36, 42);stroke-width: 2px;fill: white',
|
|
101
|
-
}),
|
|
102
|
-
h('path', {
|
|
103
|
-
d: 'M 18,18 l 2.25,-7.5 m -2.25,7.5 l 5.25,1.5',
|
|
104
|
-
style:
|
|
105
|
-
'fill: none; stroke-linecap: round; stroke-linejoin: round; stroke: rgb(34, 36, 42); stroke-width: 2px;',
|
|
106
|
-
}),
|
|
107
|
-
h('path', {
|
|
108
|
-
d: 'M 18,18 m 0,7.5 l -0,2.25',
|
|
109
|
-
transform: 'rotate(0,18,18)',
|
|
110
|
-
style:
|
|
111
|
-
'fill: none; stroke-linecap: round; stroke-linejoin: round; stroke: rgb(34, 36, 42); stroke-width: 1px;',
|
|
112
|
-
}),
|
|
113
|
-
h('path', {
|
|
114
|
-
d: 'M 18,18 m 0,7.5 l -0,2.25',
|
|
115
|
-
transform: 'rotate(30,18,18)',
|
|
116
|
-
style:
|
|
117
|
-
'fill: none; stroke-linecap: round; stroke-linejoin: round; stroke: rgb(34, 36, 42); stroke-width: 1px;',
|
|
118
|
-
}),
|
|
119
|
-
h('path', {
|
|
120
|
-
d: 'M 18,18 m 0,7.5 l -0,2.25',
|
|
121
|
-
transform: 'rotate(60,18,18)',
|
|
122
|
-
style:
|
|
123
|
-
'fill: none; stroke-linecap: round; stroke-linejoin: round; stroke: rgb(34, 36, 42); stroke-width: 1px;',
|
|
124
|
-
}),
|
|
125
|
-
h('path', {
|
|
126
|
-
d: 'M 18,18 m 0,7.5 l -0,2.25',
|
|
127
|
-
transform: 'rotate(90,18,18)',
|
|
128
|
-
style:
|
|
129
|
-
'fill: none; stroke-linecap: round; stroke-linejoin: round; stroke: rgb(34, 36, 42); stroke-width: 1px;',
|
|
130
|
-
}),
|
|
131
|
-
h('path', {
|
|
132
|
-
d: 'M 18,18 m 0,7.5 l -0,2.25',
|
|
133
|
-
transform: 'rotate(120,18,18)',
|
|
134
|
-
style:
|
|
135
|
-
'fill: none; stroke-linecap: round; stroke-linejoin: round; stroke: rgb(34, 36, 42); stroke-width: 1px;',
|
|
136
|
-
}),
|
|
137
|
-
h('path', {
|
|
138
|
-
d: 'M 18,18 m 0,7.5 l -0,2.25',
|
|
139
|
-
transform: 'rotate(150,18,18)',
|
|
140
|
-
style:
|
|
141
|
-
'fill: none; stroke-linecap: round; stroke-linejoin: round; stroke: rgb(34, 36, 42); stroke-width: 1px;',
|
|
142
|
-
}),
|
|
143
|
-
h('path', {
|
|
144
|
-
d: 'M 18,18 m 0,7.5 l -0,2.25',
|
|
145
|
-
transform: 'rotate(180,18,18)',
|
|
146
|
-
style:
|
|
147
|
-
'fill: none; stroke-linecap: round; stroke-linejoin: round; stroke: rgb(34, 36, 42); stroke-width: 1px;',
|
|
148
|
-
}),
|
|
149
|
-
h('path', {
|
|
150
|
-
d: 'M 18,18 m 0,7.5 l -0,2.25',
|
|
151
|
-
transform: 'rotate(210,18,18)',
|
|
152
|
-
style:
|
|
153
|
-
'fill: none; stroke-linecap: round; stroke-linejoin: round; stroke: rgb(34, 36, 42); stroke-width: 1px;',
|
|
154
|
-
}),
|
|
155
|
-
h('path', {
|
|
156
|
-
d: 'M 18,18 m 0,7.5 l -0,2.25',
|
|
157
|
-
transform: 'rotate(240,18,18)',
|
|
158
|
-
style:
|
|
159
|
-
'fill: none; stroke-linecap: round; stroke-linejoin: round; stroke: rgb(34, 36, 42); stroke-width: 1px;',
|
|
160
|
-
}),
|
|
161
|
-
h('path', {
|
|
162
|
-
d: 'M 18,18 m 0,7.5 l -0,2.25',
|
|
163
|
-
transform: 'rotate(270,18,18)',
|
|
164
|
-
style:
|
|
165
|
-
'fill: none; stroke-linecap: round; stroke-linejoin: round; stroke: rgb(34, 36, 42); stroke-width: 1px;',
|
|
166
|
-
}),
|
|
167
|
-
h('path', {
|
|
168
|
-
d: 'M 18,18 m 0,7.5 l -0,2.25',
|
|
169
|
-
transform: 'rotate(300,18,18)',
|
|
170
|
-
style:
|
|
171
|
-
'fill: none; stroke-linecap: round; stroke-linejoin: round; stroke: rgb(34, 36, 42); stroke-width: 1px;',
|
|
172
|
-
}),
|
|
173
|
-
h('path', {
|
|
174
|
-
d: 'M 18,18 m 0,7.5 l -0,2.25',
|
|
175
|
-
transform: 'rotate(330,18,18)',
|
|
176
|
-
style:
|
|
177
|
-
'fill: none; stroke-linecap: round; stroke-linejoin: round; stroke: rgb(34, 36, 42); stroke-width: 1px;',
|
|
178
|
-
}),
|
|
179
|
-
];</code></pre>
|
|
180
|
-
</details>
|
|
181
|
-
|
|
182
|
-
### 任务
|
|
183
|
-
|
|
184
|
-
任务节点的扩展方式如下:
|
|
185
|
-
|
|
186
|
-
```ts
|
|
187
|
-
import { TaskNodeFactory } from '@logicflow/extension'
|
|
188
|
-
|
|
189
|
-
// 例如,扩展一个脚本任务
|
|
190
|
-
|
|
191
|
-
const scriptTaskIcon = 'M6.402,0.5H20.902C20.902,0.5,15.069,3.333,15.069,6.083S19.486,12.083,19.486,15.25S15.319,20.333,15.319,20.333H0.235C0.235,20.333,5.235,17.665999999999997,5.235,15.332999999999998S0.6520000000000001,8.582999999999998,0.6520000000000001,6.082999999999998S6.402,0.5,6.402,0.5ZM3.5,4.5L13.5,4.5M3.8,8.5L13.8,8.5M6.3,12.5L16.3,12.5M6.5,16.5L16.5,16.5';
|
|
192
|
-
|
|
193
|
-
// TaskNodeFactory的第一个参数是节点类型;第二个参数是节点图标(可以说svg path也可以是h函数生成的svg);第三个参数(可选的)需要给节点设置属性
|
|
194
|
-
const receiveTask = TaskNodeFactory('bpmn:scriptTask', scriptTaskIcon)
|
|
195
|
-
|
|
196
|
-
lf.register(receiveTask)
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
### 网关
|
|
200
|
-
|
|
201
|
-
网关节点的扩展方式如下:
|
|
202
|
-
|
|
203
|
-
```ts
|
|
204
|
-
|
|
205
|
-
import { GatewayNodeFactory } from '@logicflow/extension'
|
|
206
|
-
|
|
207
|
-
// 例如,扩展一个复杂网关
|
|
208
|
-
const complexIcon = 'm 23,13 0,7.116788321167883 -5.018248175182482,-5.018248175182482 -3.102189781021898,3.102189781021898 5.018248175182482,5.018248175182482 -7.116788321167883,0 0,4.37956204379562 7.116788321167883,0 -5.018248175182482,5.018248175182482 l 3.102189781021898,3.102189781021898 5.018248175182482,-5.018248175182482 0,7.116788321167883 4.37956204379562,0 0,-7.116788321167883 5.018248175182482,5.018248175182482 3.102189781021898,-3.102189781021898 -5.018248175182482,-5.018248175182482 7.116788321167883,0 0,-4.37956204379562 -7.116788321167883,0 5.018248175182482,-5.018248175182482 -3.102189781021898,-3.102189781021898 -5.018248175182482,5.018248175182482 0,-7.116788321167883 -4.37956204379562,0 z'
|
|
209
|
-
|
|
210
|
-
const complexGateway = GatewayNodeFactory('bpmn:complexGateway', complexIcon)
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
### 子流程
|
|
214
|
-
|
|
215
|
-
*不支持扩展*
|
|
216
|
-
|
|
217
|
-
### 流
|
|
218
|
-
|
|
219
|
-
流的扩展和自定义边的定义方法完全相同,参考 <https://docs.logic-flow.cn/docs/#/zh/guide/basic/edge>
|
|
220
|
-
|
|
221
|
-
### 其他节点
|
|
222
|
-
|
|
223
|
-
其他类型的节点大家可以根据自己的需要通过自定义节点的方式进行扩展
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
|
-
/* eslint-disable no-undef */
|
|
3
|
-
import LogicFlow from '@logicflow/core'
|
|
4
|
-
import { BPMNElements } from '../index'
|
|
5
|
-
|
|
6
|
-
// const registerEventNodes = new (jest.fn())();
|
|
7
|
-
// const registerGatewayNodes = new (jest.fn())();
|
|
8
|
-
// const registerFlows = new (jest.fn())();
|
|
9
|
-
// const registerTaskNodes = new (jest.fn())();
|
|
10
|
-
|
|
11
|
-
/** */
|
|
12
|
-
describe('Test bpmn elements: definitionConfig', () => {
|
|
13
|
-
LogicFlow.use(BPMNElements)
|
|
14
|
-
const div = document.createElement('div')
|
|
15
|
-
document.body.appendChild(div)
|
|
16
|
-
const lf = new LogicFlow({
|
|
17
|
-
container: div,
|
|
18
|
-
})
|
|
19
|
-
const [definition, setDefinition] = lf.useDefinition()
|
|
20
|
-
|
|
21
|
-
// 默认definition配置
|
|
22
|
-
// const definitionConfig: DefinitionConfigType[] = [
|
|
23
|
-
// {
|
|
24
|
-
// nodes: ['startEvent', 'intermediateCatchEvent', 'boundaryEvent'],
|
|
25
|
-
// definition: [
|
|
26
|
-
// {
|
|
27
|
-
// type: 'bpmn:timerEventDefinition',
|
|
28
|
-
// icon: timerIcon,
|
|
29
|
-
// properties: {
|
|
30
|
-
// definitionType: 'bpmn:timerEventDefinition',
|
|
31
|
-
// timerValue: '',
|
|
32
|
-
// timerType: '',
|
|
33
|
-
// },
|
|
34
|
-
// },
|
|
35
|
-
// ],
|
|
36
|
-
// },
|
|
37
|
-
// ]
|
|
38
|
-
|
|
39
|
-
test('nodes startEvent, intermediateCatchEvent, boundaryEvent, contain default definition: bpmn:timerEventDefinition', () => {
|
|
40
|
-
expect(Object.keys(definition)).toEqual([
|
|
41
|
-
'boundaryEvent',
|
|
42
|
-
'intermediateCatchEvent',
|
|
43
|
-
'startEvent',
|
|
44
|
-
])
|
|
45
|
-
expect(definition.startEvent.has('bpmn:timerEventDefinition')).toBe(true)
|
|
46
|
-
expect(definition.boundaryEvent.has('bpmn:timerEventDefinition')).toBe(true)
|
|
47
|
-
expect(
|
|
48
|
-
definition.intermediateCatchEvent.has('bpmn:timerEventDefinition'),
|
|
49
|
-
).toBe(true)
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
test('after setting new definition by setDefinition for startEvent, startEvent should contain two definition: bpmn:timerEventDefinition, bpmn:messageEventDefinition', () => {
|
|
53
|
-
setDefinition([
|
|
54
|
-
{
|
|
55
|
-
nodes: ['startEvent'],
|
|
56
|
-
definition: [
|
|
57
|
-
{
|
|
58
|
-
type: 'bpmn:messageEventDefinition',
|
|
59
|
-
icon: messageIcon,
|
|
60
|
-
properties: {
|
|
61
|
-
panels: [],
|
|
62
|
-
definitionType: 'bpmn:messageEventDefinition',
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
],
|
|
66
|
-
},
|
|
67
|
-
])
|
|
68
|
-
|
|
69
|
-
expect(Array.from(definition.startEvent.keys()).length).toBe(2)
|
|
70
|
-
expect(definition.startEvent.has('bpmn:messageEventDefinition')).toBe(true)
|
|
71
|
-
})
|
|
72
|
-
})
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
type DefinitionConfigType = {
|
|
2
|
-
nodes: string[]
|
|
3
|
-
definition: EventDefinitionType[] | TaskDefinitionType[]
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
type DefinitionPropertiesType = {
|
|
7
|
-
definitionType: string
|
|
8
|
-
timerType?: TimerType
|
|
9
|
-
timerValue?: string
|
|
10
|
-
[key: string]: any
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
type EventDefinitionType = {
|
|
14
|
-
type: string
|
|
15
|
-
icon: string | Object
|
|
16
|
-
toJSON: Function
|
|
17
|
-
properties: DefinitionPropertiesType
|
|
18
|
-
[key: string]: any
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
type TaskDefinitionType = {
|
|
22
|
-
type: string
|
|
23
|
-
[key: string]: any
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
type TimerType = 'timerCycle' | 'timerDate' | 'timerDuration'
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { registerEventNodes } from './presets/Event'
|
|
2
|
-
import { registerGatewayNodes } from './presets/Gateway'
|
|
3
|
-
import { registerTaskNodes } from './presets/Task'
|
|
4
|
-
import { registerFlows } from './presets/Flow'
|
|
5
|
-
import { timerIcon } from './presets/icons'
|
|
6
|
-
import * as icons from './presets/icons'
|
|
7
|
-
import * as bpmnUtils from './utils'
|
|
8
|
-
|
|
9
|
-
type DefinitionConfigType = {
|
|
10
|
-
nodes: string[]
|
|
11
|
-
definition: EventDefinitionType[] | TaskDefinitionType[]
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
type DefinitionPropertiesType = {
|
|
15
|
-
definitionType: string
|
|
16
|
-
timerType?: TimerType
|
|
17
|
-
timerValue?: string
|
|
18
|
-
[key: string]: any
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
type EventDefinitionType = {
|
|
22
|
-
type: string
|
|
23
|
-
icon: string | Record<string, any>
|
|
24
|
-
toJSON: (data?: unknown) => unknown
|
|
25
|
-
properties: DefinitionPropertiesType
|
|
26
|
-
[key: string]: any
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
type TaskDefinitionType = {
|
|
30
|
-
type: string
|
|
31
|
-
[key: string]: any
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
type TimerType = 'timerCycle' | 'timerDate' | 'timerDuration'
|
|
35
|
-
|
|
36
|
-
const definitionConfig: DefinitionConfigType[] = [
|
|
37
|
-
{
|
|
38
|
-
nodes: ['startEvent', 'intermediateCatchEvent', 'boundaryEvent'],
|
|
39
|
-
definition: [
|
|
40
|
-
{
|
|
41
|
-
type: 'bpmn:timerEventDefinition',
|
|
42
|
-
icon: timerIcon,
|
|
43
|
-
properties: {
|
|
44
|
-
definitionType: 'bpmn:timerEventDefinition',
|
|
45
|
-
timerValue: '',
|
|
46
|
-
timerType: '',
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
],
|
|
50
|
-
},
|
|
51
|
-
]
|
|
52
|
-
|
|
53
|
-
export function useDefinition(definition: any) {
|
|
54
|
-
function setDefinition(config: DefinitionConfigType[]) {
|
|
55
|
-
function set(
|
|
56
|
-
nodes: any[],
|
|
57
|
-
definitions: EventDefinitionType[] | TaskDefinitionType[],
|
|
58
|
-
) {
|
|
59
|
-
nodes.forEach((name) => {
|
|
60
|
-
if (!definition?.[name]) {
|
|
61
|
-
definition[name] = new Map()
|
|
62
|
-
}
|
|
63
|
-
const map = definition?.[name]
|
|
64
|
-
definitions.forEach((define) => {
|
|
65
|
-
map.set(define.type, define)
|
|
66
|
-
})
|
|
67
|
-
})
|
|
68
|
-
return definition
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
config.forEach((define: any) => {
|
|
72
|
-
set(define.nodes, define.definition)
|
|
73
|
-
})
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return () => [definition, setDefinition]
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export class BPMNElements {
|
|
80
|
-
static pluginName = 'BpmnElementsPlugin'
|
|
81
|
-
|
|
82
|
-
constructor({ lf }: any) {
|
|
83
|
-
lf.definition = {}
|
|
84
|
-
lf.useDefinition = useDefinition(lf.definition)
|
|
85
|
-
const [_definition, setDefinition] = lf.useDefinition()
|
|
86
|
-
console.log('_definition', _definition)
|
|
87
|
-
setDefinition(definitionConfig)
|
|
88
|
-
|
|
89
|
-
registerEventNodes(lf)
|
|
90
|
-
registerGatewayNodes(lf)
|
|
91
|
-
registerFlows(lf)
|
|
92
|
-
registerTaskNodes(lf)
|
|
93
|
-
|
|
94
|
-
lf.setDefaultEdgeType('bpmn:sequenceFlow')
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export * from './presets/Event/EndEventFactory'
|
|
99
|
-
export * from './presets/Event/IntermediateCatchEvent'
|
|
100
|
-
export * from './presets/Event/StartEventFactory'
|
|
101
|
-
export * from './presets/Event/boundaryEventFactory'
|
|
102
|
-
export * from './presets/Event/IntermediateThrowEvent'
|
|
103
|
-
export * from './presets/Flow/sequenceFlow'
|
|
104
|
-
export * from './presets/Task/task'
|
|
105
|
-
export * from './presets/Task/subProcess'
|
|
106
|
-
export * from './presets/Gateway/gateway'
|
|
107
|
-
export { icons, bpmnUtils }
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
|
-
import {
|
|
3
|
-
h,
|
|
4
|
-
CircleNode,
|
|
5
|
-
CircleNodeModel,
|
|
6
|
-
GraphModel,
|
|
7
|
-
LogicFlow,
|
|
8
|
-
} from '@logicflow/core'
|
|
9
|
-
import { genBpmnId, groupRule } from '../../utils'
|
|
10
|
-
|
|
11
|
-
import NodeConfig = LogicFlow.NodeConfig
|
|
12
|
-
|
|
13
|
-
export function EndEventFactory(lf: any): {
|
|
14
|
-
type: string
|
|
15
|
-
model: any
|
|
16
|
-
view: any
|
|
17
|
-
} {
|
|
18
|
-
const [definition] = lf.useDefinition()
|
|
19
|
-
|
|
20
|
-
class view extends CircleNode {
|
|
21
|
-
getAnchorStyle() {
|
|
22
|
-
return {
|
|
23
|
-
visibility: 'hidden',
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
getShape() {
|
|
28
|
-
const { model } = this.props
|
|
29
|
-
const style = model.getNodeStyle()
|
|
30
|
-
const { x, y, r, width, height, properties } = model as CircleNodeModel
|
|
31
|
-
const outCircle = super.getShape()
|
|
32
|
-
const { definitionType } = properties
|
|
33
|
-
const { icon } = definition.endEvent?.get(definitionType) || {}
|
|
34
|
-
const i = Array.isArray(icon)
|
|
35
|
-
? h(
|
|
36
|
-
'g',
|
|
37
|
-
{
|
|
38
|
-
transform: `matrix(1 0 0 1 ${x - width / 2} ${y - height / 2})`,
|
|
39
|
-
},
|
|
40
|
-
...icon,
|
|
41
|
-
)
|
|
42
|
-
: h('path', {
|
|
43
|
-
transform: `matrix(1 0 0 1 ${x - width / 2} ${y - height / 2})`,
|
|
44
|
-
d: icon,
|
|
45
|
-
style:
|
|
46
|
-
'fill: black; stroke-linecap: round; stroke-linejoin: round; stroke: white; stroke-width: 1px;',
|
|
47
|
-
})
|
|
48
|
-
return h(
|
|
49
|
-
'g',
|
|
50
|
-
{},
|
|
51
|
-
outCircle,
|
|
52
|
-
h('circle', {
|
|
53
|
-
...style,
|
|
54
|
-
strokeWidth: 2,
|
|
55
|
-
cx: x,
|
|
56
|
-
cy: y,
|
|
57
|
-
r: r - 2,
|
|
58
|
-
}),
|
|
59
|
-
i,
|
|
60
|
-
)
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
class model extends CircleNodeModel {
|
|
65
|
-
constructor(data: NodeConfig, graphModel: GraphModel) {
|
|
66
|
-
if (!data.id) {
|
|
67
|
-
data.id = `Event_${genBpmnId()}`
|
|
68
|
-
}
|
|
69
|
-
if (!data.text) {
|
|
70
|
-
data.text = ''
|
|
71
|
-
}
|
|
72
|
-
if (data.text && typeof data.text === 'string') {
|
|
73
|
-
data.text = {
|
|
74
|
-
value: data.text,
|
|
75
|
-
x: data.x,
|
|
76
|
-
y: data.y + 40,
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
const { properties = {} } =
|
|
80
|
-
definition.endEvent?.get(data.properties?.definitionType) || {}
|
|
81
|
-
data.properties = {
|
|
82
|
-
...properties,
|
|
83
|
-
...data.properties,
|
|
84
|
-
}
|
|
85
|
-
data.properties?.definitionType &&
|
|
86
|
-
(data.properties!.definitionId = `Definition_${genBpmnId()}`)
|
|
87
|
-
super(data, graphModel)
|
|
88
|
-
groupRule.call(this)
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
setAttributes(): void {
|
|
92
|
-
this.r = 18
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
getConnectedSourceRules() {
|
|
96
|
-
const rules = super.getConnectedSourceRules()
|
|
97
|
-
const notAsSource = {
|
|
98
|
-
message: '结束节点不能作为边的起点',
|
|
99
|
-
validate: (source: any, _target: any) => {
|
|
100
|
-
console.log('_target', _target)
|
|
101
|
-
return source !== this
|
|
102
|
-
},
|
|
103
|
-
}
|
|
104
|
-
rules.push(notAsSource)
|
|
105
|
-
return rules
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
return {
|
|
110
|
-
type: 'bpmn:endEvent',
|
|
111
|
-
view,
|
|
112
|
-
model,
|
|
113
|
-
}
|
|
114
|
-
}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
|
-
import LogicFlow, {
|
|
3
|
-
h,
|
|
4
|
-
CircleNode,
|
|
5
|
-
CircleNodeModel,
|
|
6
|
-
GraphModel,
|
|
7
|
-
} from '@logicflow/core'
|
|
8
|
-
import { genBpmnId, groupRule } from '../../utils'
|
|
9
|
-
|
|
10
|
-
import NodeConfig = LogicFlow.NodeConfig
|
|
11
|
-
|
|
12
|
-
export function IntermediateCatchEventFactory(lf: any): {
|
|
13
|
-
type: string
|
|
14
|
-
model: any
|
|
15
|
-
view: any
|
|
16
|
-
} {
|
|
17
|
-
const [definition] = lf.useDefinition()
|
|
18
|
-
|
|
19
|
-
class view extends CircleNode {
|
|
20
|
-
getAnchorStyle() {
|
|
21
|
-
return {
|
|
22
|
-
visibility: 'hidden',
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
getShape() {
|
|
27
|
-
// @ts-ignore
|
|
28
|
-
const { model } = this.props
|
|
29
|
-
const style = model.getNodeStyle()
|
|
30
|
-
const { x, y, r, width, height, properties } = model as CircleNodeModel
|
|
31
|
-
const { definitionType } = properties
|
|
32
|
-
const { icon } =
|
|
33
|
-
definition.intermediateCatchEvent?.get(definitionType) || {}
|
|
34
|
-
|
|
35
|
-
const i = Array.isArray(icon)
|
|
36
|
-
? h(
|
|
37
|
-
'g',
|
|
38
|
-
{
|
|
39
|
-
transform: `matrix(1 0 0 1 ${x - width / 2} ${y - height / 2})`,
|
|
40
|
-
},
|
|
41
|
-
...icon,
|
|
42
|
-
)
|
|
43
|
-
: h('path', {
|
|
44
|
-
transform: `matrix(1 0 0 1 ${x - width / 2} ${y - height / 2})`,
|
|
45
|
-
d: icon,
|
|
46
|
-
})
|
|
47
|
-
return h(
|
|
48
|
-
'g',
|
|
49
|
-
{},
|
|
50
|
-
h('circle', {
|
|
51
|
-
...style,
|
|
52
|
-
cx: x,
|
|
53
|
-
cy: y,
|
|
54
|
-
r,
|
|
55
|
-
strokeWidth: 1.5,
|
|
56
|
-
}),
|
|
57
|
-
h('circle', {
|
|
58
|
-
...style,
|
|
59
|
-
cx: x,
|
|
60
|
-
cy: y,
|
|
61
|
-
r: r - 3,
|
|
62
|
-
strokeWidth: 1.5,
|
|
63
|
-
}),
|
|
64
|
-
i,
|
|
65
|
-
)
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
class model extends CircleNodeModel {
|
|
70
|
-
constructor(data: NodeConfig, graphModel: GraphModel) {
|
|
71
|
-
if (!data.id) {
|
|
72
|
-
data.id = `Event_${genBpmnId()}`
|
|
73
|
-
}
|
|
74
|
-
if (!data.text) {
|
|
75
|
-
data.text = ''
|
|
76
|
-
}
|
|
77
|
-
if (data.text && typeof data.text === 'string') {
|
|
78
|
-
data.text = {
|
|
79
|
-
value: data.text,
|
|
80
|
-
x: data.x,
|
|
81
|
-
y: data.y + 40,
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
const { properties = {} } =
|
|
85
|
-
definition.intermediateCatchEvent?.get(
|
|
86
|
-
data.properties?.definitionType,
|
|
87
|
-
) || {}
|
|
88
|
-
data.properties = {
|
|
89
|
-
...properties,
|
|
90
|
-
...data.properties,
|
|
91
|
-
}
|
|
92
|
-
data.properties?.definitionType &&
|
|
93
|
-
(data.properties!.definitionId = `Definition_${genBpmnId()}`)
|
|
94
|
-
super(data, graphModel)
|
|
95
|
-
groupRule.call(this)
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
setAttributes(): void {
|
|
99
|
-
this.r = 18
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return {
|
|
104
|
-
type: 'bpmn:intermediateCatchEvent',
|
|
105
|
-
view,
|
|
106
|
-
model,
|
|
107
|
-
}
|
|
108
|
-
}
|