w-flow-vue 1.0.0
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/.editorconfig +9 -0
- package/.eslintignore +3 -0
- package/.eslintrc.js +55 -0
- package/.jsdoc +25 -0
- package/AGENT.md +223 -0
- package/LICENSE +21 -0
- package/README.md +37 -0
- package/SECURITY.md +5 -0
- package/babel.config.js +16 -0
- package/dist/w-flow-vue.umd.js +15 -0
- package/dist/w-flow-vue.umd.js.map +1 -0
- package/docs/components_WFlowVue.vue.html +1214 -0
- package/docs/examples/app.html +62 -0
- package/docs/examples/app.umd.js +20 -0
- package/docs/examples/app.umd.js.map +1 -0
- package/docs/examples/ex-AppBasic.html +440 -0
- package/docs/examples/ex-AppConnectivity.html +131 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.eot +0 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.woff +0 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.eot +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.woff +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +978 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +1049 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
- package/docs/global.html +1919 -0
- package/docs/index.html +84 -0
- package/docs/js_defaults.mjs.html +105 -0
- package/docs/js_edge-path.mjs.html +237 -0
- package/docs/js_geometry.mjs.html +298 -0
- package/docs/js_graph.mjs.html +103 -0
- package/docs/js_step-routing.mjs.html +346 -0
- package/docs/module-WFlowVue.html +2790 -0
- package/docs/scripts/collapse.js +39 -0
- package/docs/scripts/commonNav.js +28 -0
- package/docs/scripts/linenumber.js +25 -0
- package/docs/scripts/nav.js +12 -0
- package/docs/scripts/polyfill.js +4 -0
- package/docs/scripts/prettify/Apache-License-2.0.txt +202 -0
- package/docs/scripts/prettify/lang-css.js +2 -0
- package/docs/scripts/prettify/prettify.js +28 -0
- package/docs/scripts/search.js +99 -0
- package/docs/styles/jsdoc.css +776 -0
- package/docs/styles/prettify.css +80 -0
- package/jest.config.js +20 -0
- package/package.json +80 -0
- package/public/index.html +38 -0
- package/script.txt +22 -0
- package/src/App.vue +326 -0
- package/src/AppBasic.vue +125 -0
- package/src/AppConnectivity.vue +186 -0
- package/src/components/WFlowVue.vue +1142 -0
- package/src/components/canvas/BackgroundLayer.vue +78 -0
- package/src/components/canvas/FlowCanvas.vue +64 -0
- package/src/components/canvas/SelectionBox.vue +36 -0
- package/src/components/canvas/ViewportTransform.vue +35 -0
- package/src/components/edges/ConnectionLine.vue +65 -0
- package/src/components/edges/EdgeMarkerDefs.vue +76 -0
- package/src/components/edges/EdgeRenderer.vue +120 -0
- package/src/components/edges/EdgeWrapper.vue +379 -0
- package/src/components/nodes/DefaultNode.vue +276 -0
- package/src/components/nodes/Handle.vue +101 -0
- package/src/components/nodes/InputNode.vue +47 -0
- package/src/components/nodes/NodeBody.vue +103 -0
- package/src/components/nodes/NodeFace.vue +128 -0
- package/src/components/nodes/NodeRenderer.vue +95 -0
- package/src/components/nodes/NodeWrapper.vue +475 -0
- package/src/components/nodes/OutputNode.vue +47 -0
- package/src/components/ui/ConnSettingsForm.vue +158 -0
- package/src/components/ui/Controls.vue +83 -0
- package/src/components/ui/NodeSettingsForm.vue +185 -0
- package/src/js/defaults.mjs +33 -0
- package/src/js/edge-path.mjs +165 -0
- package/src/js/geometry.mjs +226 -0
- package/src/js/graph.mjs +31 -0
- package/src/js/step-routing.mjs +274 -0
- package/src/main.js +22 -0
- package/test/WFlowVue-features.test.mjs +760 -0
- package/test/WFlowVue.test.mjs +421 -0
- package/test/components-canvas.test.mjs +102 -0
- package/test/components-edge.test.mjs +147 -0
- package/test/components-node.test.mjs +174 -0
- package/test/components-ui.test.mjs +69 -0
- package/test/defaults.test.mjs +86 -0
- package/test/edge-path.test.mjs +102 -0
- package/test/generate-routing-snapshots.mjs +77 -0
- package/test/generate-visual-baselines.mjs +206 -0
- package/test/geometry.test.mjs +236 -0
- package/test/graph.test.mjs +72 -0
- package/test/jsons/routing-snapshots.json +24994 -0
- package/test/pics/_check2.png +0 -0
- package/test/pics/_check3.png +0 -0
- package/test/pics/_check4.png +0 -0
- package/test/pics/_check5.png +0 -0
- package/test/pics/_v1.png +0 -0
- package/test/pics/_v2.png +0 -0
- package/test/pics/_v3.png +0 -0
- package/test/pics/_v4.png +0 -0
- package/test/pics/_v5.png +0 -0
- package/test/pics/_v6.png +0 -0
- package/test/pics/_v7.png +0 -0
- package/test/pics/vb-edge-hovered.png +0 -0
- package/test/pics/vb-edges-normal.png +0 -0
- package/test/pics/vb-locked-edge-hovered.png +0 -0
- package/test/pics/vb-locked-node-hovered.png +0 -0
- package/test/pics/vb-locked-node-selected.png +0 -0
- package/test/pics/vb-locked-overview.png +0 -0
- package/test/pics/vb-node-1.png +0 -0
- package/test/pics/vb-node-10.png +0 -0
- package/test/pics/vb-node-11.png +0 -0
- package/test/pics/vb-node-12.png +0 -0
- package/test/pics/vb-node-2.png +0 -0
- package/test/pics/vb-node-3.png +0 -0
- package/test/pics/vb-node-4.png +0 -0
- package/test/pics/vb-node-5.png +0 -0
- package/test/pics/vb-node-6.png +0 -0
- package/test/pics/vb-node-7.png +0 -0
- package/test/pics/vb-node-8.png +0 -0
- package/test/pics/vb-node-9.png +0 -0
- package/test/pics/vb-node-hovered.png +0 -0
- package/test/pics/vb-node-selected.png +0 -0
- package/test/pics/vb-overview.png +0 -0
- package/test/step-routing-connectivity.test.mjs +78 -0
- package/test/step-routing.test.mjs +88 -0
- package/test/visual-regression.test.mjs +274 -0
- package/toolg/addVersion.mjs +4 -0
- package/toolg/cleanFolder.mjs +4 -0
- package/toolg/gDistApp.mjs +34 -0
- package/toolg/gDistRollupComps.mjs +22 -0
- package/toolg/gDocExams.mjs +47 -0
- package/toolg/gExtractHtml.mjs +179 -0
- package/toolg/modifyReadme.mjs +4 -0
- package/vue.config.js +9 -0
- package/vue2/344/271/213foreignObject/345/205/247/346/270/262/346/237/223/345/225/217/351/241/214/350/210/207/344/277/256/346/255/243.md +151 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<svg class="vue-flow__background">
|
|
3
|
+
<pattern
|
|
4
|
+
:id="patternId"
|
|
5
|
+
:x="transformedX"
|
|
6
|
+
:y="transformedY"
|
|
7
|
+
:width="scaledGap"
|
|
8
|
+
:height="scaledGap"
|
|
9
|
+
patternUnits="userSpaceOnUse"
|
|
10
|
+
>
|
|
11
|
+
<template v-if="variant === 'dots'">
|
|
12
|
+
<circle
|
|
13
|
+
:cx="scaledSize"
|
|
14
|
+
:cy="scaledSize"
|
|
15
|
+
:r="scaledSize"
|
|
16
|
+
:fill="patternColor"
|
|
17
|
+
/>
|
|
18
|
+
</template>
|
|
19
|
+
<template v-else>
|
|
20
|
+
<path
|
|
21
|
+
:d="`M ${scaledGap} 0 L 0 0 0 ${scaledGap}`"
|
|
22
|
+
fill="none"
|
|
23
|
+
:stroke="patternColor"
|
|
24
|
+
:stroke-width="scaledSize"
|
|
25
|
+
/>
|
|
26
|
+
</template>
|
|
27
|
+
</pattern>
|
|
28
|
+
<rect
|
|
29
|
+
x="0" y="0"
|
|
30
|
+
width="100%" height="100%"
|
|
31
|
+
:fill="`url(#${patternId})`"
|
|
32
|
+
/>
|
|
33
|
+
</svg>
|
|
34
|
+
</template>
|
|
35
|
+
|
|
36
|
+
<script>
|
|
37
|
+
export default {
|
|
38
|
+
name: 'BackgroundLayer',
|
|
39
|
+
props: {
|
|
40
|
+
variant: { type: String, default: 'dots' },
|
|
41
|
+
gap: { type: Number, default: 20 },
|
|
42
|
+
size: { type: Number, default: 1 },
|
|
43
|
+
patternColor: { type: String, default: '#81818a' },
|
|
44
|
+
bgColor: { type: String, default: null },
|
|
45
|
+
viewportX: { type: Number, default: 0 },
|
|
46
|
+
viewportY: { type: Number, default: 0 },
|
|
47
|
+
viewportZoom: { type: Number, default: 1 },
|
|
48
|
+
},
|
|
49
|
+
computed: {
|
|
50
|
+
patternId() {
|
|
51
|
+
return 'vue-flow-bg-pattern'
|
|
52
|
+
},
|
|
53
|
+
scaledGap() {
|
|
54
|
+
return this.gap * this.viewportZoom
|
|
55
|
+
},
|
|
56
|
+
scaledSize() {
|
|
57
|
+
return this.size * this.viewportZoom
|
|
58
|
+
},
|
|
59
|
+
transformedX() {
|
|
60
|
+
return (this.viewportX % this.scaledGap)
|
|
61
|
+
},
|
|
62
|
+
transformedY() {
|
|
63
|
+
return (this.viewportY % this.scaledGap)
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
}
|
|
67
|
+
</script>
|
|
68
|
+
|
|
69
|
+
<style scoped>
|
|
70
|
+
.vue-flow__background {
|
|
71
|
+
position: absolute;
|
|
72
|
+
top: 0;
|
|
73
|
+
left: 0;
|
|
74
|
+
width: 100%;
|
|
75
|
+
height: 100%;
|
|
76
|
+
pointer-events: none;
|
|
77
|
+
}
|
|
78
|
+
</style>
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="vue-flow"
|
|
4
|
+
ref="container"
|
|
5
|
+
@mousedown="onMouseDown"
|
|
6
|
+
@mousemove="onMouseMove"
|
|
7
|
+
@mouseup="onMouseUp"
|
|
8
|
+
@wheel.prevent="onWheel"
|
|
9
|
+
@dblclick="onDoubleClick"
|
|
10
|
+
@contextmenu="onContextMenu"
|
|
11
|
+
>
|
|
12
|
+
<slot />
|
|
13
|
+
</div>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<script>
|
|
17
|
+
export default {
|
|
18
|
+
name: 'FlowCanvas',
|
|
19
|
+
methods: {
|
|
20
|
+
onMouseDown(event) {
|
|
21
|
+
this._downPos = { x: event.clientX, y: event.clientY }
|
|
22
|
+
this.$emit('canvas-mousedown', event)
|
|
23
|
+
},
|
|
24
|
+
onMouseMove(event) {
|
|
25
|
+
this.$emit('canvas-mousemove', event)
|
|
26
|
+
},
|
|
27
|
+
onMouseUp(event) {
|
|
28
|
+
this.$emit('canvas-mouseup', event)
|
|
29
|
+
// Emit click only if mouse didn't move (distinguish from drag/pan/select)
|
|
30
|
+
if (this._downPos) {
|
|
31
|
+
let dx = event.clientX - this._downPos.x
|
|
32
|
+
let dy = event.clientY - this._downPos.y
|
|
33
|
+
if (Math.abs(dx) < 3 && Math.abs(dy) < 3) {
|
|
34
|
+
this.$emit('canvas-click', event)
|
|
35
|
+
}
|
|
36
|
+
this._downPos = null
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
onWheel(event) {
|
|
40
|
+
this.$emit('canvas-wheel', event)
|
|
41
|
+
},
|
|
42
|
+
onDoubleClick(event) {
|
|
43
|
+
this.$emit('canvas-dblclick', event)
|
|
44
|
+
},
|
|
45
|
+
onContextMenu(event) {
|
|
46
|
+
this.$emit('canvas-contextmenu', event)
|
|
47
|
+
},
|
|
48
|
+
getContainerRect() {
|
|
49
|
+
return this.$refs.container ? this.$refs.container.getBoundingClientRect() : null
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
}
|
|
53
|
+
</script>
|
|
54
|
+
|
|
55
|
+
<style scoped>
|
|
56
|
+
.vue-flow {
|
|
57
|
+
position: relative;
|
|
58
|
+
width: 100%;
|
|
59
|
+
height: 100%;
|
|
60
|
+
overflow: hidden;
|
|
61
|
+
background-color: #fff;
|
|
62
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
63
|
+
}
|
|
64
|
+
</style>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
v-if="box"
|
|
4
|
+
class="vue-flow__selection-box"
|
|
5
|
+
:style="boxStyle"
|
|
6
|
+
/>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script>
|
|
10
|
+
export default {
|
|
11
|
+
name: 'SelectionBox',
|
|
12
|
+
props: {
|
|
13
|
+
box: { type: Object, default: null }, // { x, y, width, height }
|
|
14
|
+
},
|
|
15
|
+
computed: {
|
|
16
|
+
boxStyle() {
|
|
17
|
+
if (!this.box) return {}
|
|
18
|
+
return {
|
|
19
|
+
left: `${this.box.x}px`,
|
|
20
|
+
top: `${this.box.y}px`,
|
|
21
|
+
width: `${this.box.width}px`,
|
|
22
|
+
height: `${this.box.height}px`,
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
}
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<style scoped>
|
|
30
|
+
.vue-flow__selection-box {
|
|
31
|
+
position: absolute;
|
|
32
|
+
background: rgba(0, 65, 208, 0.08);
|
|
33
|
+
border: 1px solid rgba(0, 65, 208, 0.4);
|
|
34
|
+
pointer-events: none;
|
|
35
|
+
}
|
|
36
|
+
</style>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="vue-flow__viewport" :style="transformStyle">
|
|
3
|
+
<slot />
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script>
|
|
8
|
+
export default {
|
|
9
|
+
name: 'ViewportTransform',
|
|
10
|
+
props: {
|
|
11
|
+
x: { type: Number, default: 0 },
|
|
12
|
+
y: { type: Number, default: 0 },
|
|
13
|
+
zoom: { type: Number, default: 1 },
|
|
14
|
+
},
|
|
15
|
+
computed: {
|
|
16
|
+
transformStyle() {
|
|
17
|
+
return {
|
|
18
|
+
transform: `translate(${this.x}px, ${this.y}px) scale(${this.zoom})`,
|
|
19
|
+
transformOrigin: '0 0',
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
}
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<style scoped>
|
|
27
|
+
.vue-flow__viewport {
|
|
28
|
+
position: absolute;
|
|
29
|
+
top: 0;
|
|
30
|
+
left: 0;
|
|
31
|
+
width: 100%;
|
|
32
|
+
height: 100%;
|
|
33
|
+
transform-origin: 0 0;
|
|
34
|
+
}
|
|
35
|
+
</style>
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<svg v-if="active" class="vue-flow__connection-line">
|
|
3
|
+
<path class="vue-flow__connection-path" :d="pathD" :style="computedLineStyle" />
|
|
4
|
+
</svg>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script>
|
|
8
|
+
import { getBezierPath, getStraightPath, getStepPath, getSmoothStepPath } from '../../js/edge-path'
|
|
9
|
+
|
|
10
|
+
const pathFunctions = {
|
|
11
|
+
bezier: getBezierPath,
|
|
12
|
+
straight: getStraightPath,
|
|
13
|
+
step: getStepPath,
|
|
14
|
+
smoothstep: getSmoothStepPath,
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default {
|
|
18
|
+
name: 'ConnectionLine',
|
|
19
|
+
props: {
|
|
20
|
+
active: { type: Boolean, default: false },
|
|
21
|
+
sourceX: { type: Number, default: 0 },
|
|
22
|
+
sourceY: { type: Number, default: 0 },
|
|
23
|
+
sourcePosition: { type: String, default: 'bottom' },
|
|
24
|
+
targetX: { type: Number, default: 0 },
|
|
25
|
+
targetY: { type: Number, default: 0 },
|
|
26
|
+
type: { type: String, default: 'bezier' },
|
|
27
|
+
lineStyle: { type: Object, default: null },
|
|
28
|
+
},
|
|
29
|
+
computed: {
|
|
30
|
+
pathD() {
|
|
31
|
+
const fn = pathFunctions[this.type] || pathFunctions.bezier
|
|
32
|
+
const result = fn({
|
|
33
|
+
sourceX: this.sourceX,
|
|
34
|
+
sourceY: this.sourceY,
|
|
35
|
+
sourcePosition: this.sourcePosition,
|
|
36
|
+
targetX: this.targetX,
|
|
37
|
+
targetY: this.targetY,
|
|
38
|
+
targetPosition: 'top',
|
|
39
|
+
})
|
|
40
|
+
return result.path
|
|
41
|
+
},
|
|
42
|
+
computedLineStyle() {
|
|
43
|
+
return this.lineStyle || {}
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
}
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<style scoped>
|
|
50
|
+
.vue-flow__connection-line {
|
|
51
|
+
position: absolute;
|
|
52
|
+
top: 0;
|
|
53
|
+
left: 0;
|
|
54
|
+
width: 100%;
|
|
55
|
+
height: 100%;
|
|
56
|
+
overflow: visible;
|
|
57
|
+
pointer-events: none;
|
|
58
|
+
}
|
|
59
|
+
.vue-flow__connection-path {
|
|
60
|
+
stroke: #b1b1b7;
|
|
61
|
+
stroke-width: 1;
|
|
62
|
+
stroke-dasharray: 5 5;
|
|
63
|
+
fill: none;
|
|
64
|
+
}
|
|
65
|
+
</style>
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<defs>
|
|
3
|
+
<marker
|
|
4
|
+
v-for="marker in markers"
|
|
5
|
+
:key="marker.id"
|
|
6
|
+
:id="marker.id"
|
|
7
|
+
markerWidth="12.5"
|
|
8
|
+
markerHeight="12.5"
|
|
9
|
+
:viewBox="marker.viewBox"
|
|
10
|
+
refX="10"
|
|
11
|
+
refY="5"
|
|
12
|
+
orient="auto-start-reverse"
|
|
13
|
+
markerUnits="strokeWidth"
|
|
14
|
+
>
|
|
15
|
+
<path
|
|
16
|
+
:d="marker.path"
|
|
17
|
+
:fill="marker.fill"
|
|
18
|
+
:stroke="marker.stroke"
|
|
19
|
+
stroke-width="1"
|
|
20
|
+
/>
|
|
21
|
+
</marker>
|
|
22
|
+
</defs>
|
|
23
|
+
</template>
|
|
24
|
+
|
|
25
|
+
<script>
|
|
26
|
+
export default {
|
|
27
|
+
name: 'EdgeMarkerDefs',
|
|
28
|
+
props: {
|
|
29
|
+
conns: { type: Array, default: () => [] },
|
|
30
|
+
},
|
|
31
|
+
computed: {
|
|
32
|
+
markers() {
|
|
33
|
+
const set = new Map()
|
|
34
|
+
this.conns.forEach(conn => {
|
|
35
|
+
this.collectMarker(conn.markerStart, set)
|
|
36
|
+
this.collectMarker(conn.markerEnd, set)
|
|
37
|
+
})
|
|
38
|
+
return Array.from(set.values())
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
methods: {
|
|
42
|
+
collectMarker(marker, set) {
|
|
43
|
+
if (!marker) return
|
|
44
|
+
const config = typeof marker === 'string' ? { type: marker } : marker
|
|
45
|
+
const color = config.color || '#b1b1b7'
|
|
46
|
+
const id = this.getMarkerId(config)
|
|
47
|
+
if (set.has(id)) return
|
|
48
|
+
|
|
49
|
+
if (config.type === 'arrowclosed') {
|
|
50
|
+
set.set(id, {
|
|
51
|
+
id,
|
|
52
|
+
viewBox: '0 0 12.5 12.5',
|
|
53
|
+
path: 'M 0 0 L 10 5 L 0 10 z',
|
|
54
|
+
fill: color,
|
|
55
|
+
stroke: color,
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
// 'arrow' - open
|
|
60
|
+
set.set(id, {
|
|
61
|
+
id,
|
|
62
|
+
viewBox: '0 0 12.5 12.5',
|
|
63
|
+
path: 'M 0 0 L 10 5 L 0 10',
|
|
64
|
+
fill: 'none',
|
|
65
|
+
stroke: color,
|
|
66
|
+
})
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
getMarkerId(config) {
|
|
70
|
+
const type = typeof config === 'string' ? config : config.type
|
|
71
|
+
const color = (typeof config === 'object' && config.color) || '#b1b1b7'
|
|
72
|
+
return `vue-flow__${type}_${color.replace('#', '')}`
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
}
|
|
76
|
+
</script>
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<svg class="vue-flow__edges">
|
|
3
|
+
<EdgeMarkerDefs :conns="conns" />
|
|
4
|
+
<EdgeWrapper
|
|
5
|
+
v-for="conn in visibleConns"
|
|
6
|
+
:key="conn.id"
|
|
7
|
+
:conn="conn"
|
|
8
|
+
:source-x="getFromPos(conn).x"
|
|
9
|
+
:source-y="getFromPos(conn).y"
|
|
10
|
+
:source-position="getFromHandlePosition(conn)"
|
|
11
|
+
:target-x="getToPos(conn).x"
|
|
12
|
+
:target-y="getToPos(conn).y"
|
|
13
|
+
:target-position="getToHandlePosition(conn)"
|
|
14
|
+
:selected="isSelected(conn.id)"
|
|
15
|
+
:all-nodes="nodes"
|
|
16
|
+
:node-internals="nodeInternals"
|
|
17
|
+
:interactive="interactive"
|
|
18
|
+
:locked="locked"
|
|
19
|
+
:settings-popup-background-color="settingsPopupBackgroundColor"
|
|
20
|
+
:settings-popup-text-color="settingsPopupTextColor"
|
|
21
|
+
:settings-popup-text-font-size="settingsPopupTextFontSize"
|
|
22
|
+
:infor-popup-background-color="inforPopupBackgroundColor"
|
|
23
|
+
:infor-popup-title-text-color="inforPopupTitleTextColor"
|
|
24
|
+
:infor-popup-title-text-font-size="inforPopupTitleTextFontSize"
|
|
25
|
+
:infor-popup-description-text-color="inforPopupDescriptionTextColor"
|
|
26
|
+
:infor-popup-description-text-font-size="inforPopupDescriptionTextFontSize"
|
|
27
|
+
@conn-click="$emit('conn-click', $event)"
|
|
28
|
+
@conn-double-click="$emit('conn-double-click', $event)"
|
|
29
|
+
@conn-context-menu="$emit('conn-context-menu', $event)"
|
|
30
|
+
@conn-mouseenter="$emit('conn-mouseenter', $event)"
|
|
31
|
+
@conn-mouseleave="$emit('conn-mouseleave', $event)"
|
|
32
|
+
@conn-settings-click="$emit('conn-settings-click', $event)"
|
|
33
|
+
@conn-settings-update="$emit('conn-settings-update', $event)"
|
|
34
|
+
@conn-settings-delete="$emit('conn-settings-delete', $event)"
|
|
35
|
+
>
|
|
36
|
+
<template v-if="$scopedSlots['conn-popup']" v-slot:conn-popup="scope">
|
|
37
|
+
<slot name="conn-popup" v-bind="scope" />
|
|
38
|
+
</template>
|
|
39
|
+
</EdgeWrapper>
|
|
40
|
+
</svg>
|
|
41
|
+
</template>
|
|
42
|
+
|
|
43
|
+
<script>
|
|
44
|
+
import EdgeWrapper from './EdgeWrapper.vue'
|
|
45
|
+
import EdgeMarkerDefs from './EdgeMarkerDefs.vue'
|
|
46
|
+
import { getHandlePosition } from '../../js/geometry'
|
|
47
|
+
|
|
48
|
+
export default {
|
|
49
|
+
name: 'EdgeRenderer', // lock support
|
|
50
|
+
components: { EdgeWrapper, EdgeMarkerDefs },
|
|
51
|
+
props: {
|
|
52
|
+
conns: { type: Array, default: () => [] },
|
|
53
|
+
nodes: { type: Array, default: () => [] },
|
|
54
|
+
nodeInternals: { type: Object, default: () => ({}) },
|
|
55
|
+
selectedConnIds: { type: Array, default: () => [] },
|
|
56
|
+
interactive: { type: Boolean, default: true },
|
|
57
|
+
locked: { type: Boolean, default: false },
|
|
58
|
+
settingsPopupBackgroundColor: { type: String, default: '#fff' },
|
|
59
|
+
settingsPopupTextColor: { type: String, default: '#333' },
|
|
60
|
+
settingsPopupTextFontSize: { type: String, default: '12px' },
|
|
61
|
+
inforPopupBackgroundColor: { type: String, default: '#fff' },
|
|
62
|
+
inforPopupTitleTextColor: { type: String, default: '#333' },
|
|
63
|
+
inforPopupTitleTextFontSize: { type: String, default: '12px' },
|
|
64
|
+
inforPopupDescriptionTextColor: { type: String, default: '#888' },
|
|
65
|
+
inforPopupDescriptionTextFontSize: { type: String, default: '10px' },
|
|
66
|
+
},
|
|
67
|
+
computed: {
|
|
68
|
+
visibleConns() {
|
|
69
|
+
const visibleNodeIds = new Set(this.nodes.filter(n => !n.hidden).map(n => n.id))
|
|
70
|
+
return this.conns.filter(
|
|
71
|
+
e => !e.hidden && visibleNodeIds.has(e.from) && visibleNodeIds.has(e.to)
|
|
72
|
+
)
|
|
73
|
+
},
|
|
74
|
+
nodeMap() {
|
|
75
|
+
const map = {}
|
|
76
|
+
this.nodes.forEach(n => {
|
|
77
|
+
map[n.id] = n
|
|
78
|
+
})
|
|
79
|
+
return map
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
methods: {
|
|
83
|
+
getFromPos(conn) {
|
|
84
|
+
const node = this.nodeMap[conn.from]
|
|
85
|
+
if (!node) return { x: 0, y: 0 }
|
|
86
|
+
const pos = node.toPosition || 'bottom'
|
|
87
|
+
return getHandlePosition(node, pos, this.nodeInternals[node.id] || {}, 'source')
|
|
88
|
+
},
|
|
89
|
+
getToPos(conn) {
|
|
90
|
+
const node = this.nodeMap[conn.to]
|
|
91
|
+
if (!node) return { x: 0, y: 0 }
|
|
92
|
+
const pos = node.fromPosition || 'top'
|
|
93
|
+
return getHandlePosition(node, pos, this.nodeInternals[node.id] || {}, 'target')
|
|
94
|
+
},
|
|
95
|
+
getFromHandlePosition(conn) {
|
|
96
|
+
const node = this.nodeMap[conn.from]
|
|
97
|
+
return (node && node.toPosition) || 'bottom'
|
|
98
|
+
},
|
|
99
|
+
getToHandlePosition(conn) {
|
|
100
|
+
const node = this.nodeMap[conn.to]
|
|
101
|
+
return (node && node.fromPosition) || 'top'
|
|
102
|
+
},
|
|
103
|
+
isSelected(id) {
|
|
104
|
+
return this.selectedConnIds.includes(id)
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
}
|
|
108
|
+
</script>
|
|
109
|
+
|
|
110
|
+
<style scoped>
|
|
111
|
+
.vue-flow__edges {
|
|
112
|
+
position: absolute;
|
|
113
|
+
top: 0;
|
|
114
|
+
left: 0;
|
|
115
|
+
width: 100%;
|
|
116
|
+
height: 100%;
|
|
117
|
+
overflow: visible;
|
|
118
|
+
pointer-events: none;
|
|
119
|
+
}
|
|
120
|
+
</style>
|