@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,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
|