@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,126 +0,0 @@
1
- import LogicFlow, {
2
- h,
3
- RectNode,
4
- RectNodeModel,
5
- GraphModel,
6
- } from '@logicflow/core'
7
- import ControlGroup from '../control/ControlGroup'
8
-
9
- import NodeConfig = LogicFlow.NodeConfig
10
-
11
- export type ResizeNodeConfig = NodeConfig & {
12
- properties: {
13
- nodeSize: {
14
- width: number
15
- height: number
16
- }
17
- } & Record<string, unknown>
18
- }
19
-
20
- export type PCTResizeParams = {
21
- ResizePCT: { widthPCT: number; heightPCT: number }
22
- ResizeBasis: { basisWidth: number; basisHeight: number }
23
- ScaleLimit: { maxScaleLimit: number; minScaleLimit: number }
24
- }
25
-
26
- export class RectResizeModel extends RectNodeModel {
27
- PCTResizeInfo?: PCTResizeParams
28
- minWidth!: number
29
- minHeight!: number
30
- maxWidth!: number
31
- maxHeight!: number
32
-
33
- constructor(data: ResizeNodeConfig, graphModel: GraphModel) {
34
- super(data, graphModel)
35
- const { nodeSize } = data.properties
36
- if (nodeSize) {
37
- this.width = nodeSize.width
38
- this.height = nodeSize.height
39
- }
40
- }
41
-
42
- initNodeData(data: any): void {
43
- super.initNodeData(data)
44
- this.minWidth = 30
45
- this.minHeight = 30
46
- this.maxWidth = 2000
47
- this.maxHeight = 2000
48
- }
49
-
50
- getOutlineStyle() {
51
- const style = super.getOutlineStyle()
52
- const {
53
- editConfigModel: { isSilentMode },
54
- } = this.graphModel
55
- if (isSilentMode) return style
56
- style.stroke = 'none'
57
- if (style.hover) {
58
- style.hover.stroke = 'none'
59
- }
60
- return style
61
- }
62
-
63
- getControlPointStyle() {
64
- return {
65
- width: 7,
66
- height: 7,
67
- fill: '#FFFFFF',
68
- stroke: '#000000',
69
- }
70
- }
71
-
72
- // 该方法需要在重设宽高和最大、最小限制后被调用,不建议在 initNodeData() 方法中使用
73
- enableProportionResize(turnOn = true) {
74
- if (turnOn) {
75
- const ResizePCT = {
76
- widthPCT: 100,
77
- heightPCT: 100,
78
- }
79
- const ResizeBasis = {
80
- basisWidth: this.width,
81
- basisHeight: this.height,
82
- }
83
- const ScaleLimit = {
84
- maxScaleLimit: Math.min(
85
- (this.maxWidth / this.width) * 100,
86
- (this.maxHeight / this.height) * 100,
87
- ),
88
- minScaleLimit: Math.max(
89
- (this.minWidth / this.width) * 100,
90
- (this.minHeight / this.height) * 100,
91
- ),
92
- }
93
- this.PCTResizeInfo = {
94
- ResizePCT,
95
- ResizeBasis,
96
- ScaleLimit,
97
- }
98
- } else {
99
- delete this.PCTResizeInfo
100
- }
101
- }
102
- }
103
-
104
- export class RectResizeView extends RectNode {
105
- getControlGroup(): h.JSX.Element | null {
106
- const { model, graphModel } = this.props
107
- return <ControlGroup model={model} graphModel={graphModel} />
108
- }
109
-
110
- // getResizeShape绘制图形,功能等同于基础矩形的getShape功能,可以通过复写此方法,进行节点自定义
111
- getResizeShape() {
112
- return super.getShape()
113
- }
114
-
115
- getShape(): h.JSX.Element {
116
- return <g>{this.getResizeShape()}</g>
117
- }
118
- }
119
-
120
- export const RectResize = {
121
- type: 'rect',
122
- view: RectResizeView,
123
- model: RectResizeModel,
124
- }
125
-
126
- export default RectResize
@@ -1,4 +0,0 @@
1
- export * from './DiamondResize'
2
- export * from './EllipseResize'
3
- export * from './HtmlResize'
4
- export * from './RectResize'
@@ -1,56 +0,0 @@
1
- import LogicFlow from '@logicflow/core'
2
-
3
- export const StartEventConfig = {
4
- width: 40,
5
- height: 40,
6
- }
7
-
8
- export const EndEventConfig = {
9
- width: 40,
10
- height: 40,
11
- }
12
-
13
- export const ExclusiveGatewayConfig = {
14
- width: 40,
15
- height: 40,
16
- }
17
-
18
- export const ServiceTaskConfig = {
19
- width: 100,
20
- height: 80,
21
- }
22
-
23
- export const UserTaskConfig = {
24
- width: 100,
25
- height: 80,
26
- }
27
-
28
- export const theme: Partial<LogicFlow.Theme> = {
29
- rect: {
30
- radius: 5,
31
- stroke: 'rgb(24, 125, 255)',
32
- },
33
- circle: {
34
- r: 18,
35
- stroke: 'rgb(24, 125, 255)',
36
- },
37
- polygon: {
38
- stroke: 'rgb(24, 125, 255)',
39
- },
40
- polyline: {
41
- stroke: 'rgb(24, 125, 255)',
42
- hoverStroke: 'rgb(24, 125, 255)',
43
- selectedStroke: 'rgb(24, 125, 255)',
44
- },
45
- edgeText: {
46
- textWidth: 100,
47
- overflowMode: 'default',
48
- fontSize: 12,
49
- background: {
50
- fill: 'white',
51
- height: 14,
52
- stroke: 'transparent',
53
- radius: 3,
54
- },
55
- },
56
- }
@@ -1,73 +0,0 @@
1
- import { CircleNode, CircleNodeModel, h } from '@logicflow/core'
2
- import { getBpmnId } from '../getBpmnId'
3
-
4
- export class EndEventModel extends CircleNodeModel {
5
- static extendKey = 'EndEventModel'
6
-
7
- constructor(data, graphModel) {
8
- if (!data.id) {
9
- data.id = `Event_${getBpmnId()}`
10
- }
11
- if (!data.text) {
12
- data.text = ''
13
- }
14
- if (data.text && typeof data.text === 'string') {
15
- data.text = {
16
- value: data.text,
17
- x: data.x,
18
- y: data.y + 40,
19
- }
20
- }
21
- super(data, graphModel)
22
- }
23
-
24
- setAttributes(): void {
25
- this.r = 18
26
- }
27
-
28
- getConnectedSourceRules() {
29
- const rules = super.getConnectedSourceRules()
30
- const notAsSource = {
31
- message: '结束节点不能作为边的起点',
32
- validate: () => false,
33
- }
34
- rules.push(notAsSource)
35
- return rules
36
- }
37
- }
38
-
39
- export class EndEventView extends CircleNode {
40
- static extendKey = 'EndEventView'
41
-
42
- getAnchorStyle() {
43
- return {
44
- visibility: 'hidden',
45
- }
46
- }
47
-
48
- getShape(): h.JSX.Element {
49
- const { model } = this.props
50
- const style = model.getNodeStyle()
51
- const { x, y, r } = model as CircleNodeModel
52
- const outCircle = super.getShape()
53
- return h(
54
- 'g',
55
- {},
56
- outCircle,
57
- h('circle', {
58
- ...style,
59
- cx: x,
60
- cy: y,
61
- r: r - 5,
62
- }),
63
- )
64
- }
65
- }
66
-
67
- export const EndEvent = {
68
- type: 'bpmn:endEvent',
69
- view: EndEventView,
70
- model: EndEventModel,
71
- }
72
-
73
- export default EndEvent
@@ -1,52 +0,0 @@
1
- import { CircleNode, CircleNodeModel } from '@logicflow/core'
2
- import { getBpmnId } from '../getBpmnId'
3
-
4
- class StartEventModel extends CircleNodeModel {
5
- static extendKey = 'StartEventModel'
6
-
7
- constructor(data, graphModel) {
8
- if (!data.id) {
9
- data.id = `Event_${getBpmnId()}`
10
- }
11
- if (!data.text) {
12
- data.text = ''
13
- }
14
- if (data.text && typeof data.text === 'string') {
15
- data.text = {
16
- value: data.text,
17
- x: data.x,
18
- y: data.y + 40,
19
- }
20
- }
21
- // fix: 不能直接全部加,会导致下载后再次上传,位置错误。
22
- // data.text.y += 40;
23
- super(data, graphModel)
24
- }
25
-
26
- setAttributes(): void {
27
- this.r = 18
28
- }
29
-
30
- getConnectedTargetRules() {
31
- const rules = super.getConnectedTargetRules()
32
- const notAsTarget = {
33
- message: '起始节点不能作为边的终点',
34
- validate: () => false,
35
- }
36
- rules.push(notAsTarget)
37
- return rules
38
- }
39
- }
40
-
41
- class StartEventView extends CircleNode {
42
- static extendKey = 'StartEventNode'
43
- }
44
-
45
- export const StartEvent = {
46
- type: 'bpmn:startEvent',
47
- view: StartEventView,
48
- model: StartEventModel,
49
- }
50
-
51
- export { StartEventModel, StartEventView }
52
- export default StartEvent
@@ -1,2 +0,0 @@
1
- export * from './StartEvent'
2
- export * from './EndEvent'
@@ -1,25 +0,0 @@
1
- import { PolylineEdge, PolylineEdgeModel } from '@logicflow/core'
2
- import { getBpmnId } from '../getBpmnId'
3
-
4
- export class SequenceFlowModel extends PolylineEdgeModel {
5
- static extendKey = 'SequenceFlowModel'
6
-
7
- constructor(data, graphModel) {
8
- if (!data.id) {
9
- data.id = `Flow_${getBpmnId()}`
10
- }
11
- super(data, graphModel)
12
- }
13
- }
14
-
15
- export class SequenceFlowView extends PolylineEdge {
16
- static extendKey = 'SequenceFlowEdge'
17
- }
18
-
19
- export const SequenceFlow = {
20
- type: 'bpmn:sequenceFlow',
21
- view: SequenceFlowView,
22
- model: SequenceFlowModel,
23
- }
24
-
25
- export default SequenceFlow
@@ -1 +0,0 @@
1
- export * from './SequenceFlow'
@@ -1,71 +0,0 @@
1
- import LogicFlow, {
2
- h,
3
- GraphModel,
4
- PolygonNode,
5
- PolygonNodeModel,
6
- } from '@logicflow/core'
7
- import { getBpmnId } from '../getBpmnId'
8
-
9
- import NodeConfig = LogicFlow.NodeConfig
10
-
11
- export class ExclusiveGatewayModel extends PolygonNodeModel {
12
- static extendKey = 'ExclusiveGatewayModel'
13
-
14
- constructor(data: NodeConfig, graphModel: GraphModel) {
15
- if (!data.id) {
16
- data.id = `Gateway_${getBpmnId()}`
17
- }
18
- if (!data.text) {
19
- data.text = ''
20
- }
21
- if (data.text && typeof data.text === 'string') {
22
- data.text = {
23
- value: data.text,
24
- x: data.x,
25
- y: data.y + 40,
26
- }
27
- }
28
- super(data, graphModel)
29
- this.points = [
30
- [25, 0],
31
- [50, 25],
32
- [25, 50],
33
- [0, 25],
34
- ]
35
- }
36
- }
37
-
38
- export class ExclusiveGatewayView extends PolygonNode {
39
- static extendKey = 'ExclusiveGatewayNode'
40
-
41
- getShape(): h.JSX.Element {
42
- const { model } = this.props
43
- const { x, y, width, height, points } = model as PolygonNodeModel
44
- const style = model.getNodeStyle()
45
- return h(
46
- 'g',
47
- {
48
- transform: `matrix(1 0 0 1 ${x - width / 2} ${y - height / 2})`,
49
- },
50
- // @ts-ignore TODO: 确认 h('polygon') 报错的问题
51
- h('polygon', {
52
- ...style,
53
- x,
54
- y,
55
- points,
56
- }),
57
- h('path', {
58
- d: 'm 16,15 7.42857142857143,9.714285714285715 -7.42857142857143,9.714285714285715 3.428571428571429,0 5.714285714285715,-7.464228571428572 5.714285714285715,7.464228571428572 3.428571428571429,0 -7.42857142857143,-9.714285714285715 7.42857142857143,-9.714285714285715 -3.428571428571429,0 -5.714285714285715,7.464228571428572 -5.714285714285715,-7.464228571428572 -3.428571428571429,0 z',
59
- ...style,
60
- }),
61
- )
62
- }
63
- }
64
-
65
- export const ExclusiveGateway = {
66
- type: 'bpmn:exclusiveGateway',
67
- view: ExclusiveGatewayView,
68
- model: ExclusiveGatewayModel,
69
- }
70
-
71
- export default ExclusiveGateway
@@ -1 +0,0 @@
1
- export * from './ExclusiveGateway'
@@ -1,31 +0,0 @@
1
- class IDS {
2
- private _ids: Set<string>
3
-
4
- constructor() {
5
- globalThis._ids = this
6
- this._ids = new Set()
7
- }
8
-
9
- generateId() {
10
- return 'xxxxxxx'.replace(/[x]/g, (c) => {
11
- const r = (Math.random() * 16) | 0
12
- const v = c === 'x' ? r : (r & 0x3) | 0x8
13
- return v.toString(16)
14
- })
15
- }
16
-
17
- next() {
18
- let id = this.generateId()
19
- while (this._ids.has(id)) {
20
- id = this.generateId()
21
- }
22
- this._ids.add(id)
23
- return id
24
- }
25
- }
26
-
27
- const ids = globalThis?._ids || new IDS()
28
-
29
- export function getBpmnId(): string {
30
- return ids.next()
31
- }
package/src/bpmn/index.ts DELETED
@@ -1,60 +0,0 @@
1
- import LogicFlow from '@logicflow/core'
2
- import { theme } from './constant'
3
- import {
4
- StartEvent,
5
- StartEventView,
6
- StartEventModel,
7
- EndEvent,
8
- EndEventView,
9
- EndEventModel,
10
- } from './events'
11
- import { SequenceFlow, SequenceFlowView, SequenceFlowModel } from './flow'
12
- import {
13
- ExclusiveGateway,
14
- ExclusiveGatewayView,
15
- ExclusiveGatewayModel,
16
- } from './gateways'
17
- import {
18
- UserTask,
19
- UserTaskView,
20
- UserTaskModel,
21
- ServiceTask,
22
- ServiceTaskView,
23
- ServiceTaskModel,
24
- } from './tasks'
25
-
26
- import ExtensionDefinition = LogicFlow.ExtensionDefinition
27
-
28
- const BpmnElement: ExtensionDefinition = {
29
- pluginName: 'bpmnElement',
30
-
31
- install(lf) {
32
- lf.setTheme(theme)
33
- lf.register(StartEvent)
34
- lf.register(EndEvent)
35
- lf.register(ExclusiveGateway)
36
- lf.register(UserTask)
37
- lf.register(ServiceTask)
38
- // 支持自定义bpmn元素的边
39
- if (!lf.options.customBpmnEdge) {
40
- lf.register(SequenceFlow)
41
- lf.setDefaultEdgeType('bpmn:sequenceFlow')
42
- }
43
- },
44
- }
45
-
46
- export {
47
- BpmnElement,
48
- StartEventModel,
49
- StartEventView,
50
- EndEventView,
51
- EndEventModel,
52
- ExclusiveGatewayView,
53
- ExclusiveGatewayModel,
54
- UserTaskView,
55
- UserTaskModel,
56
- ServiceTaskView,
57
- ServiceTaskModel,
58
- SequenceFlowView,
59
- SequenceFlowModel,
60
- }
@@ -1,63 +0,0 @@
1
- import { h, RectNodeModel, RectNode } from '@logicflow/core'
2
- import { getBpmnId } from '../getBpmnId'
3
-
4
- export class ServiceTaskModel extends RectNodeModel {
5
- static extendKey = 'ServiceTaskModel'
6
-
7
- constructor(data, graphModel) {
8
- if (!data.id) {
9
- data.id = `Activity_${getBpmnId()}`
10
- }
11
- super(data, graphModel)
12
- }
13
- }
14
-
15
- export class ServiceTaskView extends RectNode {
16
- static extendKey = 'ServiceTaskNode'
17
-
18
- getLabelShape(): h.JSX.Element {
19
- const { model } = this.props
20
- const { x, y, width, height } = model
21
- const style = model.getNodeStyle()
22
- return h(
23
- 'svg',
24
- {
25
- x: x - width / 2 + 5,
26
- y: y - height / 2 + 5,
27
- width: 30,
28
- height: 30,
29
- viewBox: '0 0 1274 1024',
30
- },
31
- h('path', {
32
- fill: style.stroke,
33
- d: 'M882.527918 434.149934c-2.234901-5.303796-7.311523-8.853645-13.059434-9.138124l-61.390185-3.009544c-6.635117-20.973684-15.521508-41.175795-26.513864-60.282968l42.051745-47.743374c4.308119-4.889357 4.955872-12.004405 1.602498-17.59268-46.384423-77.30362-103.969956-101.422947-106.400309-102.410438-5.332449-2.170432-11.432377-1.090844-15.693424 2.77009L654.674467 240.664222c-17.004279-8.654101-35.092239-15.756869-53.995775-21.210068l-3.26537-66.490344c-0.280386-5.747911-3.833305-10.824533-9.134031-13.059434-1.683339-0.709151-30.193673-12.391215-76.866668-12.051477-46.672996-0.339738-75.18333 11.342326-76.866668 12.051477-5.300726 2.234901-8.853645 7.311523-9.134031 13.059434l-3.26537 66.490344c-18.903535 5.453199-36.991496 12.555967-53.995775 21.210068l-48.450479-43.922349c-4.261047-3.860934-10.360975-4.940522-15.693424-2.77009-2.430352 0.98749-60.015885 25.106818-106.400309 102.410438-3.353374 5.588275-2.705622 12.703323 1.602498 17.59268l42.051745 47.743374c-10.992355 19.107173-19.878746 39.309284-26.513864 60.282968l-61.390185 3.009544c-5.747911 0.284479-10.824533 3.834328-13.059434 9.138124-1.01512 2.415003-24.687262 60.190871-2.822278 147.651828 1.583055 6.324032 7.072069 10.893094 13.57518 11.308557 5.892197 0.37146 11.751648 0.523933 17.419741 0.667196 14.498202 0.372483 28.193109 0.723477 40.908712 4.63353 4.212952 1.294482 6.435573 8.270361 9.349949 18.763342 1.287319 4.640694 2.617617 9.43693 4.484128 14.010085 1.794879 4.393054 3.75758 8.570189 5.66093 12.607132 1.302669 2.765997 2.529613 5.380544 3.689019 8.018627 2.986007 6.803963 2.682086 9.773598 2.578732 10.349719-3.061732 3.672646-6.391571 7.238868-9.91379 11.015891-1.810229 1.943258-3.680832 3.949962-5.523807 5.980201l-22.560832 24.8909c-3.865028 4.261047-4.940522 10.365068-2.774183 15.693424 0.991584 2.426259 25.102724 60.011792 102.414531 106.400309 5.588275 3.353374 12.703323 2.701528 17.591657-1.603521l23.476691-20.682042c2.346441-2.061962 4.64888-4.336772 6.875594-6.534833 9.05319-8.93858 14.018272-12.95608 17.73185-11.576663 3.305279 1.222851 6.907317 3.166109 10.720156 5.228071 3.325745 1.794879 6.764054 3.650133 10.465352 5.288446 6.016017 2.662643 12.120039 4.688789 18.019399 6.65149 6.827499 2.266623 13.279445 4.409426 18.819624 7.275707 1.518586 0.782829 1.926886 0.994654 2.358721 7.830339 0.726547 11.496845 1.25048 23.276123 1.753947 34.672684 0.264013 5.900384 0.528026 11.803837 0.815575 17.700127 0.284479 5.743818 3.833305 10.82044 9.138124 13.05534 1.654686 0.698918 29.371958 12.063757 74.869175 12.063757 0.328481 0 3.65832 0 3.986801 0 45.497217 0 73.214489-11.364839 74.869175-12.063757 5.304819-2.234901 8.853645-7.311523 9.138124-13.05534 0.287549-5.89629 0.551562-11.799744 0.815575-17.700127 0.503467-11.396561 1.027399-23.175839 1.753947-34.672684 0.431835-6.835685 0.840134-7.04751 2.358721-7.830339 5.54018-2.866281 11.992125-5.009084 18.819624-7.275707 5.89936-1.962701 12.003382-3.988848 18.019399-6.65149 3.701299-1.638313 7.139607-3.493567 10.465352-5.288446 3.812839-2.061962 7.414877-4.00522 10.720156-5.228071 3.713578-1.379417 8.67866 2.638083 17.73185 11.576663 2.226714 2.198062 4.529153 4.472871 6.875594 6.534833l23.476691 20.682042c4.888334 4.305049 12.003382 4.956895 17.591657 1.603521 77.311807-46.388517 101.422947-103.97405 102.414531-106.400309 2.166339-5.328355 1.090844-11.432377-2.774183-15.693424l-22.560832-24.8909c-1.842974-2.030239-3.713578-4.036943-5.523807-5.980201-3.52222-3.777023-6.852058-7.343245-9.91379-11.015891-0.103354-0.576121-0.407276-3.545756 2.578732-10.349719 1.159406-2.638083 2.38635-5.252631 3.689019-8.018627 1.90335-4.036943 3.866051-8.214079 5.66093-12.607132 1.866511-4.573155 3.196809-9.369392 4.484128-14.010085 2.914376-10.492982 5.136997-17.46886 9.349949-18.763342 12.715603-3.910053 26.41051-4.261047 40.908712-4.63353 5.668093-0.143263 11.527544-0.295735 17.419741-0.667196 6.503111-0.415462 11.992125-4.984524 13.57518-11.308557C907.21518 494.340805 883.543038 436.564937 882.527918 434.149934zM643.49894 643.761929c-35.280528 35.280528-82.191954 54.711066-132.086317 54.711066s-96.806813-19.430538-132.086317-54.711066c-35.280528-35.279504-54.711066-82.191954-54.711066-132.086317 0-49.894364 19.430538-96.80272 54.711066-132.082224 35.283598-35.284621 82.191954-54.711066 132.086317-54.711066s96.80579 19.426445 132.086317 54.711066c35.279504 35.279504 54.711066 82.187861 54.711066 132.082224C698.210006 561.569976 678.782537 608.482425 643.49894 643.761929z',
34
- }),
35
- )
36
- }
37
-
38
- getShape(): h.JSX.Element {
39
- const { model } = this.props
40
- const { x, y, width, height, radius } = model
41
- const style = model.getNodeStyle()
42
- return h('g', {}, [
43
- h('rect', {
44
- x: x - width / 2,
45
- y: y - height / 2,
46
- rx: radius,
47
- ry: radius,
48
- width,
49
- height,
50
- ...style,
51
- }),
52
- this.getLabelShape(),
53
- ])
54
- }
55
- }
56
-
57
- export const ServiceTask = {
58
- type: 'bpmn:serviceTask',
59
- view: ServiceTaskView,
60
- model: ServiceTaskModel,
61
- }
62
-
63
- export default ServiceTask
@@ -1,64 +0,0 @@
1
- import { h, RectNode, RectNodeModel } from '@logicflow/core'
2
- import { getBpmnId } from '../getBpmnId'
3
-
4
- export class UserTaskModel extends RectNodeModel {
5
- static extendKey = 'UserTaskModel'
6
-
7
- constructor(data, graphModel) {
8
- if (!data.id) {
9
- data.id = `Activity_${getBpmnId()}`
10
- }
11
- super(data, graphModel)
12
- }
13
- }
14
-
15
- export class UserTaskView extends RectNode {
16
- static extendKey = 'UserTaskNode'
17
-
18
- getLabelShape(): h.JSX.Element {
19
- const { model } = this.props
20
- const { x, y, width, height } = model
21
- const style = model.getNodeStyle()
22
- return h(
23
- 'svg',
24
- {
25
- x: x - width / 2 + 5,
26
- y: y - height / 2 + 5,
27
- width: 25,
28
- height: 25,
29
- viewBox: '0 0 1274 1024',
30
- },
31
- h('path', {
32
- fill: style.stroke,
33
- d: 'M655.807326 287.35973m-223.989415 0a218.879 218.879 0 1 0 447.978829 0 218.879 218.879 0 1 0-447.978829 0ZM1039.955839 895.482975c-0.490184-212.177424-172.287821-384.030443-384.148513-384.030443-211.862739 0-383.660376 171.85302-384.15056 384.030443L1039.955839 895.482975z',
34
- }),
35
- )
36
- }
37
-
38
- getShape(): h.JSX.Element {
39
- const { model } = this.props
40
- const { x, y, width, height, radius } = model
41
- const style = model.getNodeStyle()
42
- // todo: 将basic-shape对外暴露,在这里可以直接用。现在纯手写有点麻烦。
43
- return h('g', {}, [
44
- h('rect', {
45
- ...style,
46
- x: x - width / 2,
47
- y: y - height / 2,
48
- rx: radius,
49
- ry: radius,
50
- width,
51
- height,
52
- }),
53
- this.getLabelShape(),
54
- ])
55
- }
56
- }
57
-
58
- export const UserTask = {
59
- type: 'bpmn:userTask',
60
- view: UserTaskView,
61
- model: UserTaskModel,
62
- }
63
-
64
- export default UserTask
@@ -1,2 +0,0 @@
1
- export * from './ServiceTask'
2
- export * from './UserTask'
@@ -1,31 +0,0 @@
1
- export class IDs {
2
- private _ids: Set<string>
3
-
4
- constructor() {
5
- globalThis._ids = this
6
- this._ids = new Set()
7
- }
8
-
9
- generateId() {
10
- return 'xxxxxxx'.replace(/[x]/g, (c) => {
11
- const r = (Math.random() * 16) | 0
12
- const v = c === 'x' ? r : (r & 0x3) | 0x8
13
- return v.toString(16)
14
- })
15
- }
16
-
17
- next() {
18
- let id = this.generateId()
19
- while (this._ids.has(id)) {
20
- id = this.generateId()
21
- }
22
- this._ids.add(id)
23
- return id
24
- }
25
- }
26
-
27
- const ids = globalThis?._ids || new IDs()
28
-
29
- export function getBpmnId(): string {
30
- return ids.next()
31
- }