@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,65 +0,0 @@
1
- import LogicFlow, {
2
- h,
3
- GraphModel,
4
- PolylineEdge,
5
- PolylineEdgeModel,
6
- } from '@logicflow/core'
7
- import { genBpmnId } from '../../utils'
8
-
9
- import EdgeConfig = LogicFlow.EdgeConfig
10
-
11
- type SequenceFlowType = {
12
- panels: string[]
13
- [key: string]: any
14
- }
15
-
16
- export function sequenceFlowFactory(props?: any): {
17
- type: string
18
- model: any
19
- view: any
20
- } {
21
- class model extends PolylineEdgeModel {
22
- static extendKey = 'SequenceFlowModel'
23
-
24
- constructor(data: EdgeConfig, graphModel: GraphModel) {
25
- if (!data.id) {
26
- data.id = `Flow_${genBpmnId()}`
27
- }
28
- const properties: SequenceFlowType = {
29
- ...(props || {}),
30
- ...data.properties,
31
- // panels: ['condition'],
32
- isDefaultFlow: false,
33
- }
34
- data.properties = properties
35
-
36
- super(data, graphModel)
37
- }
38
- }
39
-
40
- class view extends PolylineEdge {
41
- static extendKey = 'SequenceFlowEdge'
42
-
43
- getStartArrow(): h.JSX.Element | null {
44
- // eslint-disable-next-line no-shadow
45
- const { model } = this.props
46
- const { isDefaultFlow } = model.properties
47
- return isDefaultFlow
48
- ? h('path', {
49
- refX: 15,
50
- stroke: '#000000',
51
- strokeWidth: 2,
52
- d: 'M 20 5 10 -5 z',
53
- })
54
- : h('path', {
55
- d: '',
56
- })
57
- }
58
- }
59
-
60
- return {
61
- type: 'bpmn:sequenceFlow',
62
- view,
63
- model,
64
- }
65
- }
@@ -1,107 +0,0 @@
1
- import LogicFlow, {
2
- h,
3
- Polygon,
4
- GraphModel,
5
- PolygonNode,
6
- PolygonNodeModel,
7
- } from '@logicflow/core'
8
- import { genBpmnId, groupRule } from '../../utils'
9
-
10
- import NodeConfig = LogicFlow.NodeConfig
11
-
12
- export const gateway = {
13
- exclusive: 0,
14
- inclusive: 1,
15
- parallel: 2,
16
- }
17
-
18
- /**
19
- * index 0 排他网关
20
- * index 1 包容网关
21
- * index 2 并行网关
22
- */
23
- export const gatewayComposable = [
24
- [1, 1, 0],
25
- [0, 0, 1],
26
- [0, 1, 1],
27
- ]
28
-
29
- /**
30
- * @param type 网关节点的type, 对应其XML定义中的节点名,如<bpmn:inclusiveGateway /> 其type为bpmn:inclusiveGateway
31
- * @param icon 网关节点左上角的图标,可以是svg path,也可以是h函数生成的svg
32
- * @param props (可选) 网关节点的属性
33
- * @returns { type: string, model: any, view: any }
34
- */
35
- export function GatewayNodeFactory(
36
- type: string,
37
- icon: string | object,
38
- props?: any,
39
- ): {
40
- type: string
41
- model: any
42
- view: any
43
- } {
44
- class view extends PolygonNode {
45
- getShape() {
46
- const { model } = this.props
47
- const { x, y, width, height, points } = model as PolygonNodeModel
48
- const style = model.getNodeStyle()
49
- return h(
50
- 'g',
51
- {
52
- transform: `matrix(1 0 0 1 ${x - width / 2} ${y - height / 2})`,
53
- },
54
- h(Polygon, {
55
- ...style,
56
- x,
57
- y,
58
- points,
59
- }),
60
- typeof icon === 'string'
61
- ? h('path', {
62
- d: icon,
63
- ...style,
64
- fill: 'rgb(34, 36, 42)',
65
- strokeWidth: 1,
66
- })
67
- : icon,
68
- )
69
- }
70
- }
71
-
72
- class model extends PolygonNodeModel {
73
- constructor(data: NodeConfig, graphModel: GraphModel) {
74
- if (!data.id) {
75
- data.id = `Gateway_${genBpmnId()}`
76
- }
77
- if (!data.text) {
78
- data.text = ''
79
- }
80
- if (data.text && typeof data.text === 'string') {
81
- data.text = {
82
- value: data.text,
83
- x: data.x,
84
- y: data.y + 40,
85
- }
86
- }
87
- data.properties = {
88
- ...(props || {}),
89
- ...data.properties,
90
- }
91
- super(data, graphModel)
92
- this.points = [
93
- [25, 0],
94
- [50, 25],
95
- [25, 50],
96
- [0, 25],
97
- ]
98
- groupRule.call(this)
99
- }
100
- }
101
-
102
- return {
103
- type,
104
- view,
105
- model,
106
- }
107
- }
@@ -1,23 +0,0 @@
1
- import LogicFlow from '@logicflow/core'
2
- import { exclusiveIcon, parallelIcon, inclusiveIcon } from '../icons'
3
- import { GatewayNodeFactory } from './gateway'
4
-
5
- export function registerGatewayNodes(lf: LogicFlow) {
6
- const ExclusiveGateway = GatewayNodeFactory(
7
- 'bpmn:exclusiveGateway',
8
- exclusiveIcon,
9
- )
10
-
11
- const ParallelGateway = GatewayNodeFactory(
12
- 'bpmn:parallelGateway',
13
- parallelIcon,
14
- )
15
-
16
- const InclusiveGateway = GatewayNodeFactory(
17
- 'bpmn:inclusiveGateway',
18
- inclusiveIcon,
19
- )
20
- lf.register(ExclusiveGateway)
21
- lf.register(InclusiveGateway)
22
- lf.register(ParallelGateway)
23
- }
@@ -1,211 +0,0 @@
1
- import LogicFlow, { h } from '@logicflow/core'
2
- import { laneToJSON } from '.'
3
- import { GroupNode, GroupNodeModel } from '../../../materials/group'
4
- import { HorizontalLaneModel } from './Pool'
5
-
6
- // 泳道
7
- class LaneModel extends GroupNodeModel {
8
- initNodeData(
9
- data: LogicFlow.NodeConfig & Record<'width' | 'height', number>,
10
- ) {
11
- data.properties = {
12
- ...data.properties,
13
- processRef: '',
14
- panels: ['processRef'],
15
- }
16
- super.initNodeData(data)
17
- if (data.width) {
18
- this.width = data.width
19
- }
20
- if (data.height) {
21
- this.height = data.height
22
- }
23
- if (data.properties) {
24
- this.properties = {
25
- ...this.properties,
26
- ...data.properties,
27
- }
28
- }
29
- this.draggable = false
30
- this.resizable = true
31
- this.zIndex = 1
32
- this.toJSON = laneToJSON
33
- }
34
-
35
- changeAttribute({ width, height, x, y }: any) {
36
- if (width) this.width = width
37
- if (height) this.height = height
38
- if (x) this.x = x
39
- if (y) this.y = y
40
- }
41
- }
42
-
43
- class LaneView extends GroupNode {
44
- getOperateIcon() {
45
- const { model } = this.props
46
- const { isSelected } = model
47
- if (!isSelected) {
48
- return null
49
- }
50
- return [this.addAboveIcon(), this.addBelowIcon(), this.deleteIcon()]
51
- }
52
-
53
- addAboveIcon() {
54
- const { x, y, width, height, id } = this.props.model
55
- return h(
56
- 'g',
57
- {
58
- cursor: 'pointer',
59
- onClick: () => {
60
- const groupId = this.props.graphModel.group.nodeGroupMap.get(id)
61
- if (groupId) {
62
- const groupModel = this.props.graphModel.getNodeModelById(groupId)
63
- if (groupModel) {
64
- ;(
65
- groupModel as GroupNodeModel as HorizontalLaneModel
66
- ).addChildAbove({
67
- x,
68
- y,
69
- width,
70
- height,
71
- })
72
- }
73
- }
74
- },
75
- },
76
- [
77
- h('rect', {
78
- height: 7,
79
- width: 20,
80
- strokeWidth: 1,
81
- fill: '#fff',
82
- stroke: '#000',
83
- strokeDasharray: '3 3',
84
- x: x + width / 2 + 15,
85
- y: y - height / 2 + 3,
86
- }),
87
- h('rect', {
88
- height: 10,
89
- width: 20,
90
- strokeWidth: 1,
91
- fill: '#fff',
92
- stroke: '#000',
93
- x: x + width / 2 + 15,
94
- y: y - height / 2 + 10,
95
- }),
96
- ],
97
- )
98
- }
99
-
100
- addBelowIcon() {
101
- const { x, y, width, height, id } = this.props.model
102
- return h(
103
- 'g',
104
- {
105
- cursor: 'pointer',
106
- onClick: () => {
107
- const groupId = this.props.graphModel.group.nodeGroupMap.get(id)
108
- if (groupId) {
109
- const groupModel = this.props.graphModel.getNodeModelById(groupId)
110
- if (groupModel) {
111
- ;(
112
- groupModel as GroupNodeModel as HorizontalLaneModel
113
- ).addChildBelow({
114
- x,
115
- y,
116
- width,
117
- height,
118
- })
119
- }
120
- }
121
- },
122
- },
123
- [
124
- h('rect', {
125
- height: 7,
126
- width: 20,
127
- strokeWidth: 1,
128
- fill: '#fff',
129
- stroke: '#000',
130
- strokeDasharray: '3 3',
131
- x: x + width / 2 + 15,
132
- y: y - height / 2 + 32 + 5,
133
- }),
134
- h('rect', {
135
- height: 10,
136
- width: 20,
137
- strokeWidth: 1,
138
- fill: '#fff',
139
- stroke: '#000',
140
- x: x + width / 2 + 15,
141
- y: y - height / 2 + 2.5 + 20 + 5,
142
- }),
143
- ],
144
- )
145
- }
146
-
147
- deleteIcon() {
148
- const { x, y, width, height, id } = this.props.model
149
- return h(
150
- 'g',
151
- {
152
- cursor: 'pointer',
153
- onClick: () => {
154
- const groupId = this.props.graphModel.group.nodeGroupMap.get(id)
155
- if (groupId) {
156
- const groupModel = this.props.graphModel.getNodeModelById(groupId)
157
- ;(groupModel as GroupNodeModel as HorizontalLaneModel).deleteChild(
158
- id,
159
- )
160
- }
161
- },
162
- },
163
- [
164
- h('rect', {
165
- height: 20,
166
- width: 20,
167
- rx: 2,
168
- ry: 2,
169
- strokeWidth: 1,
170
- fill: 'transparent',
171
- stroke: 'transparent',
172
- x: x + width / 2 + 14,
173
- y: y - height / 2 + 50,
174
- }),
175
- h(
176
- 'svg',
177
- {
178
- transform: 'translate(1.000000, 1.000000)',
179
- // fill: '#3C96FE',
180
- x: x + width / 2 + 14,
181
- y: y - height / 2 + 50,
182
- width: 20,
183
- height: 20,
184
- },
185
- [
186
- h('path', {
187
- 'pointer-events': 'none',
188
- d: 'M15.3,1.4 L12.6,1.4 L12.6,0 L5.4,0 L5.4,1.4 L0,1.4 L0,2.8 L2,2.8 L2,17.3 C2,17.6865993 2.31340068,18 2.7,18 L15.3,18 C15.6865993,18 16,17.6865993 16,17.3 L16,2.8 L18,2.8 L18,1.4 L15.3,1.4 Z M14.6,16.6 L3.4,16.6 L3.4,2.8 L14.6,2.8 L14.6,16.6 Z',
189
- }),
190
- h('path', {
191
- 'pointer-events': 'none',
192
- d: 'M6,5.4 L7.4,5.4 L7.4,14.4 L6,14.4 L6,5.4 Z M10.6,5.4 L12,5.4 L12,14.4 L10.6,14.4 L10.6,5.4 Z',
193
- }),
194
- ],
195
- ),
196
- ],
197
- )
198
- }
199
-
200
- getResizeShape() {
201
- return h('g', {}, [super.getResizeShape(), this.getOperateIcon()])
202
- }
203
- }
204
-
205
- const LaneNode = {
206
- type: 'lane',
207
- view: LaneView,
208
- model: LaneModel,
209
- }
210
-
211
- export default LaneNode
@@ -1,284 +0,0 @@
1
- /**
2
- * 泳道节点
3
- */
4
- import LogicFlow, { h } from '@logicflow/core'
5
- import { poolToJSON } from '.'
6
- import { GroupNode, GroupNodeModel } from '../../../materials/group'
7
-
8
- const laneMinSize = {
9
- width: 312,
10
- height: 72,
11
- }
12
-
13
- export class HorizontalLaneModel extends GroupNodeModel {
14
- initNodeData(
15
- data: LogicFlow.NodeConfig & Record<'width' | 'height', number>,
16
- ) {
17
- super.initNodeData(data)
18
- this.height = 260
19
- // this.foldable = true
20
- this.foldedWidth = 42
21
- this.resizable = true
22
- this.zIndex = 1
23
- this.text.editable = true
24
- this.toJSON = poolToJSON
25
- }
26
-
27
- setAttributes() {
28
- this.text = {
29
- ...this.text,
30
- value: this.text.value || '泳池示例',
31
- x: this.x - this.width / 2 + 11,
32
- y: this.y,
33
- }
34
- }
35
-
36
- getTextStyle() {
37
- const style = super.getTextStyle()
38
- style.textWidth = 16
39
- return style
40
- }
41
-
42
- foldGroup(isFolded: boolean) {
43
- this.setProperty('isFolded', isFolded)
44
- this.isFolded = isFolded
45
- // step 1
46
- if (isFolded) {
47
- this.x = this.x - this.width / 2 + this.foldedWidth / 2
48
- this.unfoldedWidth = this.width
49
- this.unfoldedHight = this.height
50
- this.width = this.foldedWidth
51
- } else {
52
- this.width = this.unfoldedWidth
53
- this.x = this.x + this.width / 2 - this.foldedWidth / 2
54
- }
55
- // step 2
56
- let allEdges = this.incoming.edges.concat(this.outgoing.edges)
57
- this.children.forEach((elementId) => {
58
- const nodeModel: any = this.graphModel.getElement(elementId)
59
- nodeModel.visible = !isFolded
60
- allEdges = allEdges.concat(
61
- nodeModel.incoming.edges.concat(nodeModel.outgoing.edges),
62
- )
63
- })
64
- // step 3
65
- this.foldEdge(isFolded, allEdges)
66
- }
67
-
68
- // 感应泳道变化,调整宽高
69
- resizePool(resizeId?: string, newNodeSize?: { x: number; width: number }) {
70
- if (!this.children.size) {
71
- return
72
- }
73
- let minX: number | null = null
74
- let maxX: number | null = null
75
- let minY: number | null = null
76
- let maxY: number | null = null
77
- let hasMaxX = false
78
- // 找到边界
79
- this.children.forEach((elementId) => {
80
- const nodeModel: any = this.graphModel.getElement(elementId)
81
- const { x, y, width, height, type, id } = nodeModel
82
- if (type !== 'lane') {
83
- return
84
- }
85
- if (id === resizeId && newNodeSize) {
86
- minX = newNodeSize.x - newNodeSize.width / 2
87
- maxX = newNodeSize.x + newNodeSize.width / 2
88
- hasMaxX = true
89
- }
90
- if (!hasMaxX && (!minX || x - width / 2 < minX)) {
91
- minX = x - width / 2
92
- }
93
- if (!hasMaxX && (!maxX || x + width / 2 > maxX)) {
94
- maxX = x + width / 2
95
- }
96
- if (!minY || y - height / 2 < minY) {
97
- minY = y - height / 2
98
- }
99
- if (!maxY || y + height / 2 > maxY) {
100
- maxY = y + height / 2
101
- }
102
- })
103
- if (minX && maxX && minY && maxY) {
104
- this.width = maxX - minX + 30
105
- this.height = maxY - minY
106
- this.x = minX + (maxX - minX) / 2 - 15
107
- this.y = minY + (maxY - minY) / 2
108
- this.setAttributes()
109
- this.resizeChildren({})
110
- }
111
- }
112
-
113
- resizeChildren({ resizeDir = '', deltaHeight = 0 }) {
114
- const { x, y, width } = this
115
- const laneChildren: any[] = []
116
- this.children.forEach((elementId) => {
117
- const nodeModel: any = this.graphModel.getElement(elementId)
118
- const { type } = nodeModel
119
- if (type === 'lane') {
120
- laneChildren.push(nodeModel)
121
- }
122
- })
123
- // 按照位置排序
124
- laneChildren.sort((a, b) => {
125
- if (a.y < b.y) {
126
- return -1
127
- }
128
- return 1
129
- })
130
- // 把泳池resize的高度加进来
131
- const firstLane = laneChildren[0]
132
- const lastLane = laneChildren[laneChildren.length - 1]
133
- switch (resizeDir) {
134
- case 'below':
135
- // 高度加在最下面的泳道上
136
- lastLane.height =
137
- lastLane.height + deltaHeight < laneMinSize.height
138
- ? laneMinSize.height
139
- : lastLane.height + deltaHeight
140
- laneChildren[laneChildren.length - 1] = lastLane
141
- break
142
- case 'above':
143
- // 高度加在最上面的泳道上
144
- firstLane.height =
145
- firstLane.height + deltaHeight < laneMinSize.height
146
- ? laneMinSize.height
147
- : firstLane.height + deltaHeight
148
- laneChildren[0] = firstLane
149
- break
150
- default:
151
- break
152
- }
153
- const poolHeight = laneChildren.reduce((a, b) => a + b.height, 0)
154
- let aboveNodeHeights = 0
155
- laneChildren.forEach((nodeModel) => {
156
- const { height } = nodeModel
157
- nodeModel.changeAttribute({
158
- width: width - 30,
159
- height,
160
- x: x + 15,
161
- y: y - poolHeight / 2 + aboveNodeHeights + height / 2,
162
- })
163
- aboveNodeHeights += height
164
- })
165
- this.height = poolHeight
166
- }
167
-
168
- addChild(childId: any) {
169
- super.addChild(childId)
170
- this.graphModel.group.nodeGroupMap?.set(childId, this.id)
171
- }
172
-
173
- addChildAbove({ x, y, width, height }: any) {
174
- this.children.forEach((elementId) => {
175
- const nodeModel: any = this.graphModel.getElement(elementId)
176
- const { type, y: childY } = nodeModel
177
- if (type !== 'lane') {
178
- return
179
- }
180
- // 在被操作的泳道之上
181
- if (childY < y) {
182
- nodeModel.changeAttribute({ y: childY - 120 })
183
- }
184
- })
185
- const { id: laneId } = this.graphModel.addNode({
186
- type: 'lane',
187
- properties: {
188
- nodeSize: {
189
- width,
190
- height: 120,
191
- },
192
- },
193
- x,
194
- y: y - height / 2 - 60,
195
- })
196
- this.addChild(laneId)
197
- this.height = this.height + 120
198
- this.y = this.y - 60
199
- }
200
-
201
- addChildBelow({ x, y, width, height }: any) {
202
- this.children.forEach((elementId) => {
203
- const nodeModel: any = this.graphModel.getElement(elementId)
204
- const { type, y: childY } = nodeModel
205
- if (type !== 'lane') {
206
- return
207
- }
208
- // 在被操作的泳道之下
209
- if (childY > y) {
210
- nodeModel.changeAttribute({ y: childY + 120 })
211
- }
212
- })
213
- const { id: laneId } = this.graphModel.addNode({
214
- type: 'lane',
215
- properties: {
216
- nodeSize: {
217
- width,
218
- height: 120,
219
- },
220
- },
221
- x,
222
- y: y + height / 2 + 60,
223
- })
224
- this.addChild(laneId)
225
- this.height = this.height + 120
226
- this.y = this.y + 60
227
- }
228
-
229
- deleteChild(childId: any) {
230
- const laneChildren: any[] = []
231
- this.children.forEach((elementId) => {
232
- const nodeModel: any = this.graphModel.getElement(elementId)
233
- const { type } = nodeModel
234
- if (type === 'lane') {
235
- laneChildren.push(nodeModel)
236
- }
237
- })
238
- if (laneChildren.length <= 1) {
239
- return
240
- }
241
- this.removeChild(childId)
242
- this.graphModel.deleteNode(childId)
243
- this.resizePool()
244
- }
245
- }
246
-
247
- export class HorizontalLaneView extends GroupNode {
248
- getResizeShape() {
249
- const { model } = this.props
250
- const { x, y, width, height } = model
251
- const style = model.getNodeStyle()
252
- // 标题区域
253
- const foldRectAttrs = {
254
- ...style,
255
- x: x - width / 2,
256
- y: y - height / 2,
257
- width: 30,
258
- height,
259
- }
260
- // 泳道区域
261
- const transRectAttrs = {
262
- ...style,
263
- x: x - width / 2 + 30,
264
- y: y - height / 2,
265
- width: width - 30,
266
- height,
267
- fill: 'transparent',
268
- }
269
- return h('g', {}, [
270
- // this.getAddAbleShape(),
271
- h('rect', { ...foldRectAttrs }),
272
- h('rect', { ...transRectAttrs }),
273
- this.getFoldIcon(),
274
- ])
275
- }
276
- }
277
-
278
- const PoolNode = {
279
- type: 'pool',
280
- view: HorizontalLaneView,
281
- model: HorizontalLaneModel,
282
- }
283
-
284
- export default PoolNode