@logicflow/extension 2.2.0-alpha.7 → 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.
Files changed (125) hide show
  1. package/README.md +16 -0
  2. package/package.json +10 -7
  3. package/.turbo/turbo-build.log +0 -38
  4. package/CHANGELOG.md +0 -1829
  5. package/__test__/bpmn-adapter.test.js +0 -227
  6. package/es/materials/curved-edge/__test__/curved-edge.test.d.ts +0 -1
  7. package/es/materials/curved-edge/__test__/curved-edge.test.js +0 -18
  8. package/jest.config.js +0 -198
  9. package/lib/materials/curved-edge/__test__/curved-edge.test.d.ts +0 -1
  10. package/lib/materials/curved-edge/__test__/curved-edge.test.js +0 -20
  11. package/rollup.config.js +0 -52
  12. package/src/NodeResize/BasicShape/Ellipse.tsx +0 -22
  13. package/src/NodeResize/BasicShape/Polygon.tsx +0 -24
  14. package/src/NodeResize/BasicShape/Rect.tsx +0 -44
  15. package/src/NodeResize/control/Control.tsx +0 -537
  16. package/src/NodeResize/control/ControlGroup.tsx +0 -76
  17. package/src/NodeResize/control/Util.ts +0 -206
  18. package/src/NodeResize/index.ts +0 -26
  19. package/src/NodeResize/node/DiamondResize.tsx +0 -149
  20. package/src/NodeResize/node/EllipseResize.tsx +0 -140
  21. package/src/NodeResize/node/HtmlResize.tsx +0 -125
  22. package/src/NodeResize/node/RectResize.tsx +0 -126
  23. package/src/NodeResize/node/index.ts +0 -4
  24. package/src/bpmn/constant.ts +0 -56
  25. package/src/bpmn/events/EndEvent.ts +0 -73
  26. package/src/bpmn/events/StartEvent.ts +0 -52
  27. package/src/bpmn/events/index.ts +0 -2
  28. package/src/bpmn/flow/SequenceFlow.ts +0 -25
  29. package/src/bpmn/flow/index.ts +0 -1
  30. package/src/bpmn/gateways/ExclusiveGateway.ts +0 -71
  31. package/src/bpmn/gateways/index.ts +0 -1
  32. package/src/bpmn/getBpmnId.ts +0 -31
  33. package/src/bpmn/index.ts +0 -60
  34. package/src/bpmn/tasks/ServiceTask.ts +0 -63
  35. package/src/bpmn/tasks/UserTask.ts +0 -64
  36. package/src/bpmn/tasks/index.ts +0 -2
  37. package/src/bpmn-adapter/bpmnIds.ts +0 -31
  38. package/src/bpmn-adapter/index.ts +0 -835
  39. package/src/bpmn-adapter/json2xml.ts +0 -127
  40. package/src/bpmn-adapter/xml2json.ts +0 -544
  41. package/src/bpmn-elements/README.md +0 -223
  42. package/src/bpmn-elements/__tests__/definition.test.js +0 -72
  43. package/src/bpmn-elements/index.d.ts +0 -26
  44. package/src/bpmn-elements/index.ts +0 -107
  45. package/src/bpmn-elements/presets/Event/EndEventFactory.ts +0 -114
  46. package/src/bpmn-elements/presets/Event/IntermediateCatchEvent.ts +0 -108
  47. package/src/bpmn-elements/presets/Event/IntermediateThrowEvent.ts +0 -109
  48. package/src/bpmn-elements/presets/Event/StartEventFactory.ts +0 -114
  49. package/src/bpmn-elements/presets/Event/boundaryEventFactory.ts +0 -117
  50. package/src/bpmn-elements/presets/Event/index.ts +0 -14
  51. package/src/bpmn-elements/presets/Flow/flow.d.ts +0 -6
  52. package/src/bpmn-elements/presets/Flow/index.ts +0 -8
  53. package/src/bpmn-elements/presets/Flow/manhattan.ts +0 -691
  54. package/src/bpmn-elements/presets/Flow/sequenceFlow.ts +0 -65
  55. package/src/bpmn-elements/presets/Gateway/gateway.ts +0 -107
  56. package/src/bpmn-elements/presets/Gateway/index.ts +0 -23
  57. package/src/bpmn-elements/presets/Pool/Lane.ts +0 -211
  58. package/src/bpmn-elements/presets/Pool/Pool.ts +0 -284
  59. package/src/bpmn-elements/presets/Pool/index.ts +0 -89
  60. package/src/bpmn-elements/presets/Task/index.ts +0 -122
  61. package/src/bpmn-elements/presets/Task/subProcess.ts +0 -189
  62. package/src/bpmn-elements/presets/Task/task.ts +0 -193
  63. package/src/bpmn-elements/presets/icons.ts +0 -155
  64. package/src/bpmn-elements/utils.ts +0 -52
  65. package/src/bpmn-elements-adapter/README.md +0 -293
  66. package/src/bpmn-elements-adapter/__tests__/adapter_in.test.js +0 -528
  67. package/src/bpmn-elements-adapter/__tests__/adapter_out.test.js +0 -569
  68. package/src/bpmn-elements-adapter/constant.ts +0 -76
  69. package/src/bpmn-elements-adapter/index.ts +0 -1134
  70. package/src/bpmn-elements-adapter/json2xml.ts +0 -105
  71. package/src/bpmn-elements-adapter/xml2json.ts +0 -542
  72. package/src/components/context-menu/index.ts +0 -253
  73. package/src/components/control/index.ts +0 -155
  74. package/src/components/dnd-panel/index.ts +0 -137
  75. package/src/components/highlight/index.ts +0 -227
  76. package/src/components/menu/index.ts +0 -748
  77. package/src/components/mini-map/index.ts +0 -686
  78. package/src/components/selection-select/index.ts +0 -387
  79. package/src/dynamic-group/index.ts +0 -774
  80. package/src/dynamic-group/model.ts +0 -580
  81. package/src/dynamic-group/node.ts +0 -288
  82. package/src/dynamic-group/utils.ts +0 -46
  83. package/src/index.less +0 -1
  84. package/src/index.ts +0 -47
  85. package/src/insert-node-in-polyline/edge.ts +0 -175
  86. package/src/insert-node-in-polyline/index.ts +0 -193
  87. package/src/materials/curved-edge/__test__/curved-edge.test.ts +0 -46
  88. package/src/materials/curved-edge/index.ts +0 -217
  89. package/src/materials/group/GroupNode.ts +0 -437
  90. package/src/materials/group/index.ts +0 -542
  91. package/src/materials/node-selection/index.ts +0 -380
  92. package/src/mindmap/fakerRoot.ts +0 -19
  93. package/src/mindmap/index.ts +0 -328
  94. package/src/mindmap/markContent.ts +0 -81
  95. package/src/mindmap/markContentOption.ts +0 -81
  96. package/src/mindmap/markEntity.ts +0 -82
  97. package/src/mindmap/markRoot.ts +0 -83
  98. package/src/mindmap/theme.ts +0 -11
  99. package/src/pool/LaneModel.ts +0 -226
  100. package/src/pool/LaneView.ts +0 -220
  101. package/src/pool/PoolModel.ts +0 -631
  102. package/src/pool/PoolView.ts +0 -75
  103. package/src/pool/constant.ts +0 -19
  104. package/src/pool/index.ts +0 -621
  105. package/src/pool/utils.ts +0 -46
  106. package/src/rect-label-node/RectLabelNodeView.ts +0 -33
  107. package/src/rect-label-node/index.ts +0 -15
  108. package/src/style/index.less +0 -381
  109. package/src/style/raw.ts +0 -328
  110. package/src/tools/auto-layout/index.ts +0 -282
  111. package/src/tools/flow-path/index.ts +0 -233
  112. package/src/tools/label/Label.tsx +0 -357
  113. package/src/tools/label/LabelModel.ts +0 -83
  114. package/src/tools/label/LabelOverlay.tsx +0 -162
  115. package/src/tools/label/algorithm.ts +0 -42
  116. package/src/tools/label/index.ts +0 -479
  117. package/src/tools/label/mediumEditor.ts +0 -121
  118. package/src/tools/label/utils.ts +0 -395
  119. package/src/tools/proximity-connect/index.ts +0 -435
  120. package/src/tools/snapshot/README.md +0 -145
  121. package/src/tools/snapshot/index.ts +0 -701
  122. package/src/tools/snapshot/utils.ts +0 -163
  123. package/src/turbo-adapter/index.ts +0 -212
  124. package/stats.html +0 -4842
  125. 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
- }