@michael_home/workflow-engine-vue 1.0.2 → 1.0.4
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/dist/CanvasView.vue.d.ts +108 -0
- package/dist/CanvasView.vue.d.ts.map +1 -0
- package/dist/EdgeView.vue.d.ts +41 -0
- package/dist/EdgeView.vue.d.ts.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -3
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +810 -0
- package/dist/style.css +1 -1
- package/package.json +12 -10
- package/dist/index.mjs +0 -457
package/dist/index.js
ADDED
|
@@ -0,0 +1,810 @@
|
|
|
1
|
+
import { defineComponent as Pe, ref as Q, watch as Ce, computed as Y, reactive as B, onMounted as Ne, onUnmounted as ze, openBlock as k, createElementBlock as I, createElementVNode as M, toDisplayString as H, withModifiers as z, Fragment as E, renderList as q, normalizeClass as V, createCommentVNode as K, normalizeStyle as _e, withDirectives as Le, vShow as Te } from "vue";
|
|
2
|
+
const f = {
|
|
3
|
+
Top: "TOP",
|
|
4
|
+
Right: "RIGHT",
|
|
5
|
+
Bottom: "BOTTOM",
|
|
6
|
+
Left: "LEFT"
|
|
7
|
+
}, N = 20, S = (s, h) => {
|
|
8
|
+
const c = s.position.x + s.size.width / 2, u = s.position.y + s.size.height / 2;
|
|
9
|
+
switch (h.direction) {
|
|
10
|
+
case f.Top:
|
|
11
|
+
return { x: c, y: s.position.y };
|
|
12
|
+
case f.Right:
|
|
13
|
+
return { x: s.position.x + s.size.width, y: u };
|
|
14
|
+
case f.Bottom:
|
|
15
|
+
return { x: c, y: s.position.y + s.size.height };
|
|
16
|
+
case f.Left:
|
|
17
|
+
return { x: s.position.x, y: u };
|
|
18
|
+
}
|
|
19
|
+
}, Ye = (s, h, c, u) => {
|
|
20
|
+
for (const e of h)
|
|
21
|
+
if (e.id !== s)
|
|
22
|
+
for (const t of e.ports) {
|
|
23
|
+
const n = S(e, t);
|
|
24
|
+
if (Math.hypot(n.x - c.x, n.y - c.y) <= u)
|
|
25
|
+
return { node: e, port: t, point: n };
|
|
26
|
+
}
|
|
27
|
+
}, Re = (s, h, c) => {
|
|
28
|
+
switch (h) {
|
|
29
|
+
case f.Top:
|
|
30
|
+
return c.y < s.y - N ? f.Bottom : f.Top;
|
|
31
|
+
case f.Bottom:
|
|
32
|
+
return c.y > s.y + N ? f.Top : f.Bottom;
|
|
33
|
+
case f.Left:
|
|
34
|
+
return c.x < s.x - N ? f.Right : f.Left;
|
|
35
|
+
case f.Right:
|
|
36
|
+
return c.x > s.x + N ? f.Left : f.Right;
|
|
37
|
+
}
|
|
38
|
+
}, R = (s, h, c) => {
|
|
39
|
+
const u = [];
|
|
40
|
+
for (const t of s) {
|
|
41
|
+
const n = u[u.length - 1];
|
|
42
|
+
(!n || n.x !== t.x || n.y !== t.y) && u.push(t);
|
|
43
|
+
}
|
|
44
|
+
const e = u.slice();
|
|
45
|
+
for (let t = 1; t <= e.length - 3; t += 1) {
|
|
46
|
+
const n = e[t - 1], i = e[t], o = e[t + 1], l = e[t + 2];
|
|
47
|
+
if (n.x === i.x && i.y === o.y && o.x === l.x) {
|
|
48
|
+
const p = Math.abs(o.x - i.x), b = i.y - n.y, v = l.y - o.y;
|
|
49
|
+
p <= N / 2 && Math.sign(b) !== 0 && Math.sign(v) !== 0 && Math.sign(b) !== Math.sign(v) && (e.splice(t, 2, { x: n.x, y: l.y }), t = Math.max(0, t - 2));
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if (n.y === i.y && i.x === o.x && o.y === l.y) {
|
|
53
|
+
const p = Math.abs(o.y - i.y), b = i.x - n.x, v = l.x - o.x;
|
|
54
|
+
p <= N / 2 && Math.sign(b) !== 0 && Math.sign(v) !== 0 && Math.sign(b) !== Math.sign(v) && (e.splice(t, 2, { x: l.x, y: n.y }), t = Math.max(0, t - 2));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
for (let t = e.length - 1; t >= 2; t -= 1) {
|
|
58
|
+
const n = e[t - 2], i = e[t - 1], o = e[t];
|
|
59
|
+
(n.x === i.x && i.x === o.x || n.y === i.y && i.y === o.y) && e.splice(t - 1, 1);
|
|
60
|
+
}
|
|
61
|
+
if (h !== void 0 && c !== void 0 && h === c && e.length >= 4)
|
|
62
|
+
if (h === f.Top || h === f.Bottom)
|
|
63
|
+
for (let n = 1; n <= e.length - 3; n += 1) {
|
|
64
|
+
const i = e[n - 1], o = e[n], l = e[n + 1], y = e[n + 2];
|
|
65
|
+
if (!(i.x === o.x && o.y === l.y && l.x === y.x))
|
|
66
|
+
continue;
|
|
67
|
+
Math.abs(l.x - o.x) <= N && (e.splice(n, 2), n = Math.max(0, n - 2));
|
|
68
|
+
}
|
|
69
|
+
else
|
|
70
|
+
for (let n = 1; n <= e.length - 3; n += 1) {
|
|
71
|
+
const i = e[n - 1], o = e[n], l = e[n + 1], y = e[n + 2];
|
|
72
|
+
if (!(i.y === o.y && o.x === l.x && l.y === y.y))
|
|
73
|
+
continue;
|
|
74
|
+
Math.abs(l.y - o.y) <= N && (e.splice(n, 2), n = Math.max(0, n - 2));
|
|
75
|
+
}
|
|
76
|
+
return e;
|
|
77
|
+
}, Xe = (s, h, c) => {
|
|
78
|
+
switch (c) {
|
|
79
|
+
case f.Right:
|
|
80
|
+
return s > 0;
|
|
81
|
+
case f.Left:
|
|
82
|
+
return s < 0;
|
|
83
|
+
case f.Bottom:
|
|
84
|
+
return h > 0;
|
|
85
|
+
case f.Top:
|
|
86
|
+
return h < 0;
|
|
87
|
+
}
|
|
88
|
+
}, Ee = (s, h, c) => {
|
|
89
|
+
switch (c) {
|
|
90
|
+
case f.Right:
|
|
91
|
+
case f.Left:
|
|
92
|
+
return Math.abs(h);
|
|
93
|
+
case f.Bottom:
|
|
94
|
+
case f.Top:
|
|
95
|
+
return Math.abs(s);
|
|
96
|
+
}
|
|
97
|
+
}, Se = (s, h, c, u) => {
|
|
98
|
+
const e = s.x, t = s.y, n = c.x, i = c.y, o = N, l = [s], y = Math.round((e + n) / 2), x = Math.round((t + i) / 2), p = n >= e && i <= t, b = n < e && i <= t, v = n < e && i > t;
|
|
99
|
+
if (e === n && t === i && h === u) {
|
|
100
|
+
switch (h) {
|
|
101
|
+
case f.Left:
|
|
102
|
+
l.push({ x: e - o, y: t });
|
|
103
|
+
break;
|
|
104
|
+
case f.Right:
|
|
105
|
+
l.push({ x: e + o, y: t });
|
|
106
|
+
break;
|
|
107
|
+
case f.Top:
|
|
108
|
+
l.push({ x: e, y: t - o });
|
|
109
|
+
break;
|
|
110
|
+
case f.Bottom:
|
|
111
|
+
l.push({ x: e, y: t + o });
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
return l.push(c), R(l, h, u);
|
|
115
|
+
}
|
|
116
|
+
const m = h === f.Top || h === f.Bottom, g = u === f.Top || u === f.Bottom, C = h === f.Left || h === f.Right, A = u === f.Left || u === f.Right;
|
|
117
|
+
if (h === u) {
|
|
118
|
+
if (m && Math.abs(n - e) <= o)
|
|
119
|
+
return l.push({ x: e, y: i }, c), R(l, h, u);
|
|
120
|
+
if (C && Math.abs(i - t) <= o)
|
|
121
|
+
return l.push({ x: n, y: t }, c), R(l, h, u);
|
|
122
|
+
}
|
|
123
|
+
const $ = Math.abs(n - e) <= o * 2 && Math.abs(i - t) <= o * 8;
|
|
124
|
+
if ($ && m && g)
|
|
125
|
+
return l.push({ x: e, y: x }, { x: n, y: x }, c), R(l, h, u);
|
|
126
|
+
if ($ && C && A)
|
|
127
|
+
return l.push({ x: y, y: t }, { x: y, y: i }, c), R(l, h, u);
|
|
128
|
+
switch (h) {
|
|
129
|
+
case f.Top:
|
|
130
|
+
switch (u) {
|
|
131
|
+
case f.Left:
|
|
132
|
+
p ? l.push({ x: e, y: i }) : b ? l.push({ x: e, y: x }, { x: n - o, y: x }, { x: n - o, y: i }) : v ? l.push({ x: e, y: t - o }, { x: n - o, y: t - o }, { x: n - o, y: i }) : l.push({ x: e, y: t - o }, { x: y, y: t - o }, { x: y, y: i });
|
|
133
|
+
break;
|
|
134
|
+
case f.Bottom:
|
|
135
|
+
if (n === e && i < t)
|
|
136
|
+
break;
|
|
137
|
+
i < t - o ? l.push({ x: e, y: x }, { x: n, y: x }) : l.push({ x: e, y: t - o }, { x: y, y: t - o }, { x: y, y: i + o }, { x: n, y: i + o });
|
|
138
|
+
break;
|
|
139
|
+
case f.Right:
|
|
140
|
+
p ? l.push({ x: e, y: x }, { x: n + o, y: x }, { x: n + o, y: i }) : b ? l.push({ x: e, y: i }) : v ? l.push({ x: e, y: t - o }, { x: y, y: t - o }, { x: y, y: i }) : l.push({ x: e, y: t - o }, { x: n + o, y: t - o }, { x: n + o, y: i });
|
|
141
|
+
break;
|
|
142
|
+
case f.Top: {
|
|
143
|
+
const _ = i < t ? i - o : t - o;
|
|
144
|
+
if (Math.abs(i - t) <= o * 3) {
|
|
145
|
+
const L = Math.round((t + i) / 2);
|
|
146
|
+
l.push({ x: e, y: L }, { x: n, y: L });
|
|
147
|
+
} else
|
|
148
|
+
l.push({ x: e, y: _ }, { x: n, y: _ });
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
break;
|
|
153
|
+
case f.Bottom:
|
|
154
|
+
switch (u) {
|
|
155
|
+
case f.Left:
|
|
156
|
+
b ? l.push({ x: e, y: t + o }, { x: n - o, y: t + o }, { x: n - o, y: i }) : v ? l.push({ x: e, y: x }, { x: n - o, y: x }, { x: n - o, y: i }) : p ? l.push({ x: e, y: t + o }, { x: y, y: t + o }, { x: y, y: i }) : l.push({ x: e, y: i });
|
|
157
|
+
break;
|
|
158
|
+
case f.Bottom: {
|
|
159
|
+
const _ = i < t ? t + o : i + o;
|
|
160
|
+
if (Math.abs(i - t) <= o * 3) {
|
|
161
|
+
const L = Math.round((t + i) / 2);
|
|
162
|
+
l.push({ x: e, y: L }, { x: n, y: L });
|
|
163
|
+
} else
|
|
164
|
+
l.push({ x: e, y: _ }, { x: n, y: _ });
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
case f.Right:
|
|
168
|
+
b ? l.push({ x: e, y: t + o }, { x: y, y: t + o }, { x: y, y: i }) : v ? l.push({ x: e, y: i }) : p ? l.push({ x: e, y: t + o }, { x: n + o, y: t + o }, { x: n + o, y: i }) : l.push({ x: e, y: x }, { x: n + o, y: x }, { x: n + o, y: i });
|
|
169
|
+
break;
|
|
170
|
+
case f.Top:
|
|
171
|
+
if (n === e && i > t)
|
|
172
|
+
break;
|
|
173
|
+
i - o < t ? l.push({ x: e, y: t + o }, { x: y, y: t + o }, { x: y, y: i - o }, { x: n, y: i - o }) : l.push({ x: e, y: x }, { x: n, y: x });
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
break;
|
|
177
|
+
case f.Left:
|
|
178
|
+
switch (u) {
|
|
179
|
+
case f.Left:
|
|
180
|
+
n < e ? l.push({ x: n - o, y: t }, { x: n - o, y: i }) : l.push({ x: e - o, y: t }, { x: e - o, y: i });
|
|
181
|
+
break;
|
|
182
|
+
case f.Bottom:
|
|
183
|
+
b ? l.push({ x: n, y: t }) : v ? l.push({ x: y, y: t }, { x: y, y: i + o }, { x: n, y: i + o }) : p ? l.push({ x: e - o, y: t }, { x: e - o, y: x }, { x: n, y: x }) : l.push({ x: e - o, y: t }, { x: e - o, y: i + o }, { x: n, y: i + o });
|
|
184
|
+
break;
|
|
185
|
+
case f.Right:
|
|
186
|
+
if (n < e - o)
|
|
187
|
+
l.push({ x: y, y: t }, { x: y, y: i });
|
|
188
|
+
else {
|
|
189
|
+
if (n < e && i === t)
|
|
190
|
+
break;
|
|
191
|
+
l.push({ x: e - o, y: t }, { x: e - o, y: x }, { x: n + o, y: x }, { x: n + o, y: i });
|
|
192
|
+
}
|
|
193
|
+
break;
|
|
194
|
+
case f.Top:
|
|
195
|
+
p ? l.push({ x: e - o, y: t }, { x: e - o, y: i - o }, { x: n, y: i - o }) : b ? l.push({ x: y, y: t }, { x: y, y: i - o }, { x: n, y: i - o }) : v ? l.push({ x: n, y: t }) : l.push({ x: e - o, y: t }, { x: e - o, y: x }, { x: n, y: x });
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
break;
|
|
199
|
+
case f.Right:
|
|
200
|
+
switch (u) {
|
|
201
|
+
case f.Left:
|
|
202
|
+
if (n - o < e)
|
|
203
|
+
l.push({ x: e + o, y: t }, { x: e + o, y: x }, { x: n - o, y: x }, { x: n - o, y: i });
|
|
204
|
+
else {
|
|
205
|
+
if (n > e && i === t)
|
|
206
|
+
break;
|
|
207
|
+
l.push({ x: y, y: t }, { x: y, y: i });
|
|
208
|
+
}
|
|
209
|
+
break;
|
|
210
|
+
case f.Bottom:
|
|
211
|
+
b ? l.push({ x: e + o, y: t }, { x: e + o, y: x }, { x: n, y: x }) : v ? l.push({ x: e + o, y: t }, { x: e + o, y: i + o }, { x: n, y: i + o }) : p ? l.push({ x: n, y: t }) : l.push({ x: y, y: t }, { x: y, y: i + o }, { x: n, y: i + o });
|
|
212
|
+
break;
|
|
213
|
+
case f.Right:
|
|
214
|
+
n < e ? l.push({ x: e + o, y: t }, { x: e + o, y: i }) : l.push({ x: n + o, y: t }, { x: n + o, y: i });
|
|
215
|
+
break;
|
|
216
|
+
case f.Top:
|
|
217
|
+
n > e && i < t ? l.push({ x: y, y: t }, { x: y, y: i - o }, { x: n, y: i - o }) : n <= e && i <= t ? l.push({ x: e + o, y: t }, { x: e + o, y: i - o }, { x: n, y: i - o }) : n < e && i > t ? l.push({ x: e + o, y: t }, { x: e + o, y: x }, { x: n, y: x }) : l.push({ x: n, y: t });
|
|
218
|
+
break;
|
|
219
|
+
}
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
return l.push(c), R(l);
|
|
223
|
+
}, ue = (s) => {
|
|
224
|
+
const h = S(s.sourceNode, s.sourcePort), c = Ye(s.sourceNode.id, s.nodes, s.currentPoint, s.hitRadius), u = (c == null ? void 0 : c.point) ?? s.currentPoint, e = (c == null ? void 0 : c.port.direction) ?? Re(h, s.sourcePort.direction, u);
|
|
225
|
+
return {
|
|
226
|
+
points: Se(h, s.sourcePort.direction, u, e),
|
|
227
|
+
snappedTarget: c
|
|
228
|
+
};
|
|
229
|
+
}, $e = (s, h, c) => {
|
|
230
|
+
const u = S(s, h);
|
|
231
|
+
let e;
|
|
232
|
+
for (const t of c)
|
|
233
|
+
if (t.id !== s.id)
|
|
234
|
+
for (const n of t.ports) {
|
|
235
|
+
const i = S(t, n), o = i.x - u.x, l = i.y - u.y;
|
|
236
|
+
if (!Xe(o, l, h.direction))
|
|
237
|
+
continue;
|
|
238
|
+
const y = Math.hypot(o, l), x = Ee(o, l, h.direction);
|
|
239
|
+
(!e || x < e.axisDistance || x === e.axisDistance && y < e.distance) && (e = { node: t, port: n, distance: y, axisDistance: x });
|
|
240
|
+
}
|
|
241
|
+
if (e)
|
|
242
|
+
return { node: e.node, port: e.port };
|
|
243
|
+
}, Be = (s) => {
|
|
244
|
+
if (s.mode === "click")
|
|
245
|
+
return $e(s.sourceNode, s.sourcePort, s.nodes);
|
|
246
|
+
if (!s.currentPoint || s.hitRadius === void 0)
|
|
247
|
+
return;
|
|
248
|
+
const c = ue({
|
|
249
|
+
sourceNode: s.sourceNode,
|
|
250
|
+
sourcePort: s.sourcePort,
|
|
251
|
+
nodes: s.nodes,
|
|
252
|
+
currentPoint: s.currentPoint,
|
|
253
|
+
hitRadius: s.hitRadius
|
|
254
|
+
}).snappedTarget;
|
|
255
|
+
if (c)
|
|
256
|
+
return { node: c.node, port: c.port };
|
|
257
|
+
}, le = (s) => {
|
|
258
|
+
const h = s.nodes.find((u) => u.id === s.sourceNodeId);
|
|
259
|
+
if (!h)
|
|
260
|
+
return;
|
|
261
|
+
const c = h.ports.find((u) => u.id === s.sourcePortId);
|
|
262
|
+
if (c)
|
|
263
|
+
return { sourceNode: h, sourcePort: c };
|
|
264
|
+
}, He = (s) => {
|
|
265
|
+
const h = Be(s);
|
|
266
|
+
return h ? {
|
|
267
|
+
sourceNodeId: s.sourceNodeId,
|
|
268
|
+
sourcePortId: s.sourcePortId,
|
|
269
|
+
targetNodeId: h.node.id,
|
|
270
|
+
targetPortId: h.port.id
|
|
271
|
+
} : {
|
|
272
|
+
sourceNodeId: s.sourceNodeId,
|
|
273
|
+
sourcePortId: s.sourcePortId
|
|
274
|
+
};
|
|
275
|
+
}, Ve = (s) => Math.hypot(s.currentClientX - s.pressedClientX, s.currentClientY - s.pressedClientY) >= s.threshold, Ae = (s) => {
|
|
276
|
+
let h = s.clientX - s.offsetX, c = s.clientY - s.offsetY;
|
|
277
|
+
s.snapToGrid && (h = Math.round(h / s.gridSize) * s.gridSize, c = Math.round(c / s.gridSize) * s.gridSize);
|
|
278
|
+
const u = s.alignThreshold ?? 10, e = h + s.node.size.width / 2, t = c + s.node.size.height / 2;
|
|
279
|
+
if (s.nodes && s.nodes.length > 1 && u > 0) {
|
|
280
|
+
let n, i = Number.POSITIVE_INFINITY, o, l = Number.POSITIVE_INFINITY;
|
|
281
|
+
for (const y of s.nodes) {
|
|
282
|
+
if (y.id === s.node.id)
|
|
283
|
+
continue;
|
|
284
|
+
const x = y.position.x + y.size.width / 2, p = y.position.y + y.size.height / 2, b = Math.abs(x - e);
|
|
285
|
+
b <= u && b < i && (i = b, n = x - s.node.size.width / 2);
|
|
286
|
+
const v = Math.abs(p - t);
|
|
287
|
+
v <= u && v < l && (l = v, o = p - s.node.size.height / 2);
|
|
288
|
+
}
|
|
289
|
+
n !== void 0 && (h = n), o !== void 0 && (c = o);
|
|
290
|
+
}
|
|
291
|
+
return h = Math.min(s.canvasWidth - s.node.size.width, Math.max(0, h)), c = Math.min(s.canvasHeight - s.node.size.height, Math.max(0, c)), { x: h, y: c };
|
|
292
|
+
}, Oe = 10, Fe = 6, We = 3, de = (s) => Math.round(s), De = (s) => ({
|
|
293
|
+
x: de(s.x),
|
|
294
|
+
y: de(s.y)
|
|
295
|
+
}), Ge = (s, h, c, u) => {
|
|
296
|
+
const e = Math.hypot(h.x - s.x, h.y - s.y), t = Math.hypot(c.x - h.x, c.y - h.y);
|
|
297
|
+
return e === 0 || t === 0 ? 0 : Math.min(u, e / 2, t / 2);
|
|
298
|
+
}, Ue = (s) => {
|
|
299
|
+
if (s.length === 0)
|
|
300
|
+
return "";
|
|
301
|
+
if (s.length < 3) {
|
|
302
|
+
const [u, ...e] = s, t = [`M ${u.x} ${u.y}`];
|
|
303
|
+
for (const n of e)
|
|
304
|
+
t.push(`L ${n.x} ${n.y}`);
|
|
305
|
+
return t.join(" ");
|
|
306
|
+
}
|
|
307
|
+
const h = [`M ${s[0].x} ${s[0].y}`];
|
|
308
|
+
for (let u = 1; u < s.length - 1; u += 1) {
|
|
309
|
+
const e = s[u - 1], t = s[u], n = s[u + 1];
|
|
310
|
+
if (!(e.x === t.x && t.y === n.y || e.y === t.y && t.x === n.x)) {
|
|
311
|
+
h.push(`L ${t.x} ${t.y}`);
|
|
312
|
+
continue;
|
|
313
|
+
}
|
|
314
|
+
const o = Ge(e, t, n, We);
|
|
315
|
+
if (o <= 0) {
|
|
316
|
+
h.push(`L ${t.x} ${t.y}`);
|
|
317
|
+
continue;
|
|
318
|
+
}
|
|
319
|
+
const l = t.x + Math.sign(e.x - t.x) * o, y = t.y + Math.sign(e.y - t.y) * o, x = t.x + Math.sign(n.x - t.x) * o, p = t.y + Math.sign(n.y - t.y) * o, v = (t.x - e.x) * (n.y - t.y) - (t.y - e.y) * (n.x - t.x) > 0 ? 1 : 0;
|
|
320
|
+
h.push(`L ${l} ${y}`), h.push(`A ${o} ${o} 0 0 ${v} ${x} ${p}`);
|
|
321
|
+
}
|
|
322
|
+
const c = s[s.length - 1];
|
|
323
|
+
return h.push(`L ${c.x} ${c.y}`), h.join(" ");
|
|
324
|
+
}, je = (s, h, c) => {
|
|
325
|
+
const u = s.x - h.x, e = s.y - h.y, t = Math.hypot(u, e);
|
|
326
|
+
if (t === 0)
|
|
327
|
+
return s;
|
|
328
|
+
const n = u / t, i = e / t;
|
|
329
|
+
return {
|
|
330
|
+
x: s.x - n * c,
|
|
331
|
+
y: s.y - i * c
|
|
332
|
+
};
|
|
333
|
+
}, Qe = (s, h) => {
|
|
334
|
+
if (s.length < 2)
|
|
335
|
+
return "";
|
|
336
|
+
const c = s[s.length - 1], u = s[s.length - 2], e = c.x - u.x, t = c.y - u.y, n = Math.hypot(e, t);
|
|
337
|
+
if (n === 0)
|
|
338
|
+
return "";
|
|
339
|
+
const i = e / n, o = t / n, l = c.x - i * h.arrowLength, y = c.y - o * h.arrowLength, x = -o, p = i, b = l + x * (h.arrowWidth / 2), v = y + p * (h.arrowWidth / 2), m = l - x * (h.arrowWidth / 2), g = y - p * (h.arrowWidth / 2);
|
|
340
|
+
return `${c.x},${c.y} ${b},${v} ${m},${g}`;
|
|
341
|
+
}, he = (s, h = {}) => {
|
|
342
|
+
const c = {
|
|
343
|
+
arrowLength: h.arrowLength ?? Oe,
|
|
344
|
+
arrowWidth: h.arrowWidth ?? Fe,
|
|
345
|
+
pixelSnap: h.pixelSnap ?? !0
|
|
346
|
+
}, u = Qe(s, c);
|
|
347
|
+
let e = s.slice();
|
|
348
|
+
if (e.length >= 2) {
|
|
349
|
+
const t = e[e.length - 1], n = e[e.length - 2];
|
|
350
|
+
e[e.length - 1] = je(t, n, c.arrowLength);
|
|
351
|
+
}
|
|
352
|
+
return c.pixelSnap && (e = e.map((t) => De(t))), {
|
|
353
|
+
points: s,
|
|
354
|
+
path: Ue(e),
|
|
355
|
+
arrow: u
|
|
356
|
+
};
|
|
357
|
+
}, qe = { class: "zoom-controls" }, Ke = { class: "zoom-text" }, Ze = ["viewBox"], Je = ["transform"], et = { class: "edge-layer" }, tt = ["d", "onMousedown"], ot = ["d", "stroke", "stroke-dasharray", "onMousedown"], st = ["points", "fill", "stroke", "onMousedown"], nt = ["x", "y", "fill"], rt = ["d"], it = ["points"], ct = { class: "node-layer" }, at = ["transform"], lt = ["x", "y", "width", "height", "fill", "onMousedown"], dt = ["x", "y", "width", "height", "rx", "ry", "fill", "onMousedown"], ht = ["points", "fill", "onMousedown"], ut = ["x", "y", "width", "height"], ft = {
|
|
358
|
+
key: 0,
|
|
359
|
+
width: "14",
|
|
360
|
+
height: "14",
|
|
361
|
+
class: "node-icon-dom",
|
|
362
|
+
"aria-hidden": "true"
|
|
363
|
+
}, yt = ["href", "fill"], xt = {
|
|
364
|
+
key: 1,
|
|
365
|
+
class: "node-icon-fallback"
|
|
366
|
+
}, gt = { class: "node-title-text" }, pt = ["cx", "cy", "onMousedown"], wt = /* @__PURE__ */ Pe({
|
|
367
|
+
__name: "CanvasView",
|
|
368
|
+
props: {
|
|
369
|
+
nodes: {},
|
|
370
|
+
edges: {},
|
|
371
|
+
selectedNodeId: {},
|
|
372
|
+
selectedEdgeId: {},
|
|
373
|
+
width: {},
|
|
374
|
+
height: {},
|
|
375
|
+
panX: { default: 0 },
|
|
376
|
+
panY: { default: 0 },
|
|
377
|
+
zoom: { default: 1 },
|
|
378
|
+
snapToGrid: { type: Boolean, default: !0 },
|
|
379
|
+
gridSize: { default: 10 },
|
|
380
|
+
alignThreshold: { default: 10 },
|
|
381
|
+
portHitRadius: { default: 14 },
|
|
382
|
+
portDragThreshold: { default: 4 }
|
|
383
|
+
},
|
|
384
|
+
emits: ["selectionChange", "nodePositionChange", "edgeCreate", "edgeDelete", "nodeDelete"],
|
|
385
|
+
setup(s, { emit: h }) {
|
|
386
|
+
const c = s, u = h, e = Q(c.zoom), t = (a) => Math.min(2, Math.max(0.4, Number(a.toFixed(2)))), n = () => {
|
|
387
|
+
e.value = t(e.value + 0.1);
|
|
388
|
+
}, i = () => {
|
|
389
|
+
e.value = t(e.value - 0.1);
|
|
390
|
+
};
|
|
391
|
+
Ce(
|
|
392
|
+
() => c.zoom,
|
|
393
|
+
(a) => {
|
|
394
|
+
e.value = t(a);
|
|
395
|
+
}
|
|
396
|
+
);
|
|
397
|
+
const o = Y(
|
|
398
|
+
() => `translate(${c.panX} ${c.panY}) scale(${e.value})`
|
|
399
|
+
), l = Q(), y = Q(), x = B({ width: 700, height: 240 });
|
|
400
|
+
let p;
|
|
401
|
+
const b = Y(() => c.width ?? x.width), v = Y(() => c.height ?? x.height), m = B({
|
|
402
|
+
active: !1,
|
|
403
|
+
nodeId: "",
|
|
404
|
+
offsetX: 0,
|
|
405
|
+
offsetY: 0,
|
|
406
|
+
latestClientX: 0,
|
|
407
|
+
latestClientY: 0
|
|
408
|
+
}), g = B({
|
|
409
|
+
active: !1,
|
|
410
|
+
sourceNodeId: "",
|
|
411
|
+
sourcePortId: "",
|
|
412
|
+
pendingClick: !1,
|
|
413
|
+
pressedClientX: 0,
|
|
414
|
+
pressedClientY: 0,
|
|
415
|
+
currentX: 0,
|
|
416
|
+
currentY: 0
|
|
417
|
+
}), C = B({ rafId: 0, scheduled: !1 }), A = (a) => {
|
|
418
|
+
const d = a.data;
|
|
419
|
+
return (d == null ? void 0 : d.text) ?? "";
|
|
420
|
+
}, $ = (a) => {
|
|
421
|
+
const d = a.data;
|
|
422
|
+
return (d == null ? void 0 : d.lineColor) ?? "#1c7ed6";
|
|
423
|
+
}, _ = (a) => {
|
|
424
|
+
const d = a.data;
|
|
425
|
+
return (d == null ? void 0 : d.fontColor) ?? "#0f172a";
|
|
426
|
+
}, L = (a) => {
|
|
427
|
+
const d = a.data;
|
|
428
|
+
return (d == null ? void 0 : d.lineStyle) === "dashed" ? "6 4" : void 0;
|
|
429
|
+
}, fe = (a) => {
|
|
430
|
+
const d = a.data;
|
|
431
|
+
return (d == null ? void 0 : d.runtimeStatus) ?? "idle";
|
|
432
|
+
}, ye = (a) => fe(a) === "pending", xe = (a) => {
|
|
433
|
+
if (a.length < 2) return;
|
|
434
|
+
const d = [];
|
|
435
|
+
let r = 0;
|
|
436
|
+
for (let P = 1; P < a.length; P += 1) {
|
|
437
|
+
const T = a[P - 1], U = a[P], j = Math.hypot(U.x - T.x, U.y - T.y);
|
|
438
|
+
j !== 0 && (d.push({ start: T, end: U, length: j }), r += j);
|
|
439
|
+
}
|
|
440
|
+
if (d.length === 0 || r === 0) return;
|
|
441
|
+
const w = r / 2;
|
|
442
|
+
let X = 0;
|
|
443
|
+
for (const P of d) {
|
|
444
|
+
if (X + P.length >= w) {
|
|
445
|
+
const T = (w - X) / P.length;
|
|
446
|
+
return {
|
|
447
|
+
x: P.start.x + (P.end.x - P.start.x) * T,
|
|
448
|
+
y: P.start.y + (P.end.y - P.start.y) * T
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
X += P.length;
|
|
452
|
+
}
|
|
453
|
+
const ae = d[d.length - 1];
|
|
454
|
+
return { x: ae.end.x, y: ae.end.y };
|
|
455
|
+
}, ge = Y(
|
|
456
|
+
() => c.edges.map((a) => {
|
|
457
|
+
const d = a.points ?? [], r = he(d, { pixelSnap: !0 });
|
|
458
|
+
return {
|
|
459
|
+
edge: a,
|
|
460
|
+
edgeId: a.id,
|
|
461
|
+
path: r.path,
|
|
462
|
+
arrow: r.arrow,
|
|
463
|
+
label: A(a),
|
|
464
|
+
lineColor: $(a),
|
|
465
|
+
lineDasharray: L(a),
|
|
466
|
+
labelColor: _(a),
|
|
467
|
+
labelPoint: xe(d),
|
|
468
|
+
flowing: ye(a)
|
|
469
|
+
};
|
|
470
|
+
})
|
|
471
|
+
), pe = (a) => {
|
|
472
|
+
const d = a.data;
|
|
473
|
+
return (d == null ? void 0 : d.title) ?? a.id;
|
|
474
|
+
}, O = (a) => {
|
|
475
|
+
const d = a.data;
|
|
476
|
+
return (d == null ? void 0 : d.icon) ?? "";
|
|
477
|
+
}, Z = (a) => {
|
|
478
|
+
const d = O(a);
|
|
479
|
+
return !d || !d.startsWith("icon-") ? "" : `#${d}`;
|
|
480
|
+
}, F = (a) => {
|
|
481
|
+
const d = a.data;
|
|
482
|
+
return (d == null ? void 0 : d.runtimeStatus) === "completed" ? d.completedFillColor ?? "#bbf7d0" : (d == null ? void 0 : d.runtimeStatus) === "active" ? "#dcfce7" : (d == null ? void 0 : d.nodeColor) ?? "#ffffff";
|
|
483
|
+
}, J = (a) => {
|
|
484
|
+
const d = a.data;
|
|
485
|
+
return (d == null ? void 0 : d.fontColor) ?? "#0f172a";
|
|
486
|
+
}, ee = (a) => {
|
|
487
|
+
const d = a.data;
|
|
488
|
+
return (d == null ? void 0 : d.nodeShape) ?? "rect";
|
|
489
|
+
}, we = (a) => {
|
|
490
|
+
const d = a.size.width / 2, r = a.size.height / 2;
|
|
491
|
+
return `0,${-r} ${d},0 0,${r} ${-d},0`;
|
|
492
|
+
}, ve = (a) => {
|
|
493
|
+
const d = new Map(a.ports.map((r) => [r.direction, r]));
|
|
494
|
+
return [
|
|
495
|
+
{ direction: f.Top, dx: 0, dy: -a.size.height / 2 },
|
|
496
|
+
{ direction: f.Right, dx: a.size.width / 2, dy: 0 },
|
|
497
|
+
{ direction: f.Bottom, dx: 0, dy: a.size.height / 2 },
|
|
498
|
+
{ direction: f.Left, dx: -a.size.width / 2, dy: 0 }
|
|
499
|
+
].map((r) => ({
|
|
500
|
+
...r,
|
|
501
|
+
port: d.get(r.direction)
|
|
502
|
+
})).filter((r) => !!r.port);
|
|
503
|
+
}, te = (a) => {
|
|
504
|
+
const d = y.value;
|
|
505
|
+
if (!d)
|
|
506
|
+
return { x: a.clientX, y: a.clientY };
|
|
507
|
+
const r = d.getBoundingClientRect();
|
|
508
|
+
return {
|
|
509
|
+
x: a.clientX - r.left,
|
|
510
|
+
y: a.clientY - r.top
|
|
511
|
+
};
|
|
512
|
+
}, W = (a) => ({
|
|
513
|
+
x: (a.x - c.panX) / e.value,
|
|
514
|
+
y: (a.y - c.panY) / e.value
|
|
515
|
+
}), me = () => {
|
|
516
|
+
if (C.scheduled = !1, !m.active) return;
|
|
517
|
+
const a = c.nodes.find((r) => r.id === m.nodeId);
|
|
518
|
+
if (!a) return;
|
|
519
|
+
const d = Ae({
|
|
520
|
+
node: a,
|
|
521
|
+
nodes: c.nodes,
|
|
522
|
+
alignThreshold: c.alignThreshold,
|
|
523
|
+
clientX: m.latestClientX,
|
|
524
|
+
clientY: m.latestClientY,
|
|
525
|
+
offsetX: m.offsetX,
|
|
526
|
+
offsetY: m.offsetY,
|
|
527
|
+
canvasWidth: b.value / e.value,
|
|
528
|
+
canvasHeight: v.value / e.value,
|
|
529
|
+
gridSize: c.gridSize,
|
|
530
|
+
snapToGrid: c.snapToGrid
|
|
531
|
+
});
|
|
532
|
+
u("nodePositionChange", { nodeId: m.nodeId, position: d });
|
|
533
|
+
}, be = () => {
|
|
534
|
+
g.active = !1, g.pendingClick = !1, g.sourceNodeId = "", g.sourcePortId = "";
|
|
535
|
+
}, oe = () => {
|
|
536
|
+
m.active = !1, m.nodeId = "", C.rafId && (window.cancelAnimationFrame(C.rafId), C.rafId = 0), C.scheduled = !1;
|
|
537
|
+
}, ke = () => {
|
|
538
|
+
if (!g.active && !g.pendingClick) return;
|
|
539
|
+
const a = le({
|
|
540
|
+
sourceNodeId: g.sourceNodeId,
|
|
541
|
+
sourcePortId: g.sourcePortId,
|
|
542
|
+
nodes: c.nodes
|
|
543
|
+
});
|
|
544
|
+
if (a) {
|
|
545
|
+
const d = He({
|
|
546
|
+
sourceNodeId: a.sourceNode.id,
|
|
547
|
+
sourcePortId: a.sourcePort.id,
|
|
548
|
+
sourceNode: a.sourceNode,
|
|
549
|
+
sourcePort: a.sourcePort,
|
|
550
|
+
nodes: c.nodes,
|
|
551
|
+
mode: g.pendingClick ? "click" : "drag",
|
|
552
|
+
currentPoint: { x: g.currentX, y: g.currentY },
|
|
553
|
+
hitRadius: c.portHitRadius
|
|
554
|
+
});
|
|
555
|
+
d.targetNodeId && d.targetPortId && u("edgeCreate", {
|
|
556
|
+
sourceNodeId: d.sourceNodeId,
|
|
557
|
+
sourcePortId: d.sourcePortId,
|
|
558
|
+
targetNodeId: d.targetNodeId,
|
|
559
|
+
targetPortId: d.targetPortId
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
be();
|
|
563
|
+
}, se = Y(() => {
|
|
564
|
+
if (!g.active) return [];
|
|
565
|
+
const a = le({
|
|
566
|
+
sourceNodeId: g.sourceNodeId,
|
|
567
|
+
sourcePortId: g.sourcePortId,
|
|
568
|
+
nodes: c.nodes
|
|
569
|
+
});
|
|
570
|
+
return a ? ue({
|
|
571
|
+
sourceNode: a.sourceNode,
|
|
572
|
+
sourcePort: a.sourcePort,
|
|
573
|
+
nodes: c.nodes,
|
|
574
|
+
currentPoint: { x: g.currentX, y: g.currentY },
|
|
575
|
+
hitRadius: c.portHitRadius
|
|
576
|
+
}).points : [];
|
|
577
|
+
}), ne = Y(() => he(se.value, { pixelSnap: !0 })), D = (a, d) => {
|
|
578
|
+
if (g.active) return;
|
|
579
|
+
d.preventDefault(), u("selectionChange", { nodeId: a.id }), m.active = !0, m.nodeId = a.id;
|
|
580
|
+
const r = W(te(d));
|
|
581
|
+
m.offsetX = r.x - a.position.x, m.offsetY = r.y - a.position.y, m.latestClientX = r.x, m.latestClientY = r.y;
|
|
582
|
+
}, Ie = (a, d, r) => {
|
|
583
|
+
r.preventDefault(), u("selectionChange", { nodeId: a.id });
|
|
584
|
+
const w = S(a, d);
|
|
585
|
+
g.active = !1, g.pendingClick = !0, g.pressedClientX = r.clientX, g.pressedClientY = r.clientY, g.sourceNodeId = a.id, g.sourcePortId = d.id, g.currentX = w.x, g.currentY = w.y;
|
|
586
|
+
}, G = (a, d) => {
|
|
587
|
+
d.preventDefault(), d.stopPropagation(), u("selectionChange", { edgeId: a.id });
|
|
588
|
+
}, Me = () => {
|
|
589
|
+
g.active || m.active || u("selectionChange", {});
|
|
590
|
+
}, re = (a) => {
|
|
591
|
+
const d = te(a);
|
|
592
|
+
if (g.pendingClick && !g.active && Ve({
|
|
593
|
+
pressedClientX: g.pressedClientX,
|
|
594
|
+
pressedClientY: g.pressedClientY,
|
|
595
|
+
currentClientX: a.clientX,
|
|
596
|
+
currentClientY: a.clientY,
|
|
597
|
+
threshold: c.portDragThreshold
|
|
598
|
+
}) && (g.active = !0, g.pendingClick = !1), g.active) {
|
|
599
|
+
const w = W(d);
|
|
600
|
+
g.currentX = w.x, g.currentY = w.y;
|
|
601
|
+
return;
|
|
602
|
+
}
|
|
603
|
+
if (!m.active) return;
|
|
604
|
+
const r = W(d);
|
|
605
|
+
m.latestClientX = r.x, m.latestClientY = r.y, !C.scheduled && (C.scheduled = !0, C.rafId = window.requestAnimationFrame(me));
|
|
606
|
+
}, ie = () => {
|
|
607
|
+
oe(), ke();
|
|
608
|
+
}, ce = (a) => {
|
|
609
|
+
if (a.key !== "Delete" && a.key !== "Backspace") return;
|
|
610
|
+
const d = a.target;
|
|
611
|
+
if (d) {
|
|
612
|
+
const r = d.tagName;
|
|
613
|
+
if (r === "INPUT" || r === "TEXTAREA" || d.isContentEditable)
|
|
614
|
+
return;
|
|
615
|
+
}
|
|
616
|
+
if (c.selectedEdgeId) {
|
|
617
|
+
a.preventDefault(), u("edgeDelete", { edgeId: c.selectedEdgeId });
|
|
618
|
+
return;
|
|
619
|
+
}
|
|
620
|
+
c.selectedNodeId && (a.preventDefault(), u("nodeDelete", { nodeId: c.selectedNodeId }));
|
|
621
|
+
};
|
|
622
|
+
return Ne(() => {
|
|
623
|
+
const a = () => {
|
|
624
|
+
const d = l.value;
|
|
625
|
+
if (!d) return;
|
|
626
|
+
const r = d.getBoundingClientRect();
|
|
627
|
+
r.width > 0 && (x.width = r.width), r.height > 0 && (x.height = r.height);
|
|
628
|
+
};
|
|
629
|
+
a(), p = new ResizeObserver(a), l.value && p.observe(l.value), window.addEventListener("mousemove", re), window.addEventListener("mouseup", ie), window.addEventListener("keydown", ce);
|
|
630
|
+
}), ze(() => {
|
|
631
|
+
oe(), p == null || p.disconnect(), window.removeEventListener("mousemove", re), window.removeEventListener("mouseup", ie), window.removeEventListener("keydown", ce);
|
|
632
|
+
}), (a, d) => (k(), I("section", {
|
|
633
|
+
ref_key: "containerRef",
|
|
634
|
+
ref: l,
|
|
635
|
+
class: "canvas-view",
|
|
636
|
+
style: { width: "100%", height: "100%" }
|
|
637
|
+
}, [
|
|
638
|
+
M("div", qe, [
|
|
639
|
+
M("button", {
|
|
640
|
+
type: "button",
|
|
641
|
+
class: "zoom-btn",
|
|
642
|
+
onClick: i
|
|
643
|
+
}, "-"),
|
|
644
|
+
M("span", Ke, H(Math.round(e.value * 100)) + "%", 1),
|
|
645
|
+
M("button", {
|
|
646
|
+
type: "button",
|
|
647
|
+
class: "zoom-btn",
|
|
648
|
+
onClick: n
|
|
649
|
+
}, "+")
|
|
650
|
+
]),
|
|
651
|
+
(k(), I("svg", {
|
|
652
|
+
ref_key: "svgRef",
|
|
653
|
+
ref: y,
|
|
654
|
+
class: "canvas-svg",
|
|
655
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
656
|
+
viewBox: `0 0 ${b.value} ${v.value}`,
|
|
657
|
+
onMousedown: z(Me, ["self"])
|
|
658
|
+
}, [
|
|
659
|
+
M("g", { transform: o.value }, [
|
|
660
|
+
M("g", et, [
|
|
661
|
+
(k(!0), I(E, null, q(ge.value, (r) => (k(), I(E, {
|
|
662
|
+
key: r.edgeId
|
|
663
|
+
}, [
|
|
664
|
+
M("path", {
|
|
665
|
+
d: r.path,
|
|
666
|
+
fill: "none",
|
|
667
|
+
stroke: "transparent",
|
|
668
|
+
"stroke-width": "15",
|
|
669
|
+
"vector-effect": "non-scaling-stroke",
|
|
670
|
+
class: "edge-hit",
|
|
671
|
+
onMousedown: z((w) => G(r.edge, w), ["stop"])
|
|
672
|
+
}, null, 40, tt),
|
|
673
|
+
M("path", {
|
|
674
|
+
d: r.path,
|
|
675
|
+
stroke: s.selectedEdgeId === r.edgeId ? "#2563eb" : r.lineColor,
|
|
676
|
+
"stroke-width": "1",
|
|
677
|
+
fill: "none",
|
|
678
|
+
"stroke-linecap": "round",
|
|
679
|
+
"stroke-linejoin": "round",
|
|
680
|
+
"vector-effect": "non-scaling-stroke",
|
|
681
|
+
"shape-rendering": "geometricPrecision",
|
|
682
|
+
class: V(["edge-path", { "edge-flowing": r.flowing }]),
|
|
683
|
+
"stroke-dasharray": r.lineDasharray ?? (r.flowing ? "7 6" : void 0),
|
|
684
|
+
onMousedown: z((w) => G(r.edge, w), ["stop"])
|
|
685
|
+
}, null, 42, ot),
|
|
686
|
+
M("polygon", {
|
|
687
|
+
points: r.arrow,
|
|
688
|
+
fill: s.selectedEdgeId === r.edgeId ? "#2563eb" : r.lineColor,
|
|
689
|
+
stroke: s.selectedEdgeId === r.edgeId ? "#2563eb" : r.lineColor,
|
|
690
|
+
"vector-effect": "non-scaling-stroke",
|
|
691
|
+
"shape-rendering": "geometricPrecision",
|
|
692
|
+
class: "edge-arrow",
|
|
693
|
+
onMousedown: z((w) => G(r.edge, w), ["stop"])
|
|
694
|
+
}, null, 40, st),
|
|
695
|
+
r.label && r.labelPoint ? (k(), I("text", {
|
|
696
|
+
key: 0,
|
|
697
|
+
x: r.labelPoint.x,
|
|
698
|
+
y: r.labelPoint.y,
|
|
699
|
+
class: "edge-label",
|
|
700
|
+
fill: r.labelColor,
|
|
701
|
+
"text-anchor": "middle",
|
|
702
|
+
"dominant-baseline": "central"
|
|
703
|
+
}, H(r.label), 9, nt)) : K("", !0)
|
|
704
|
+
], 64))), 128)),
|
|
705
|
+
se.value.length > 1 ? (k(), I(E, { key: 0 }, [
|
|
706
|
+
M("path", {
|
|
707
|
+
d: ne.value.path,
|
|
708
|
+
stroke: "#94a3b8",
|
|
709
|
+
"stroke-width": "2",
|
|
710
|
+
fill: "none",
|
|
711
|
+
"stroke-linecap": "round",
|
|
712
|
+
"stroke-linejoin": "round",
|
|
713
|
+
"vector-effect": "non-scaling-stroke",
|
|
714
|
+
"shape-rendering": "geometricPrecision"
|
|
715
|
+
}, null, 8, rt),
|
|
716
|
+
M("polygon", {
|
|
717
|
+
points: ne.value.arrow,
|
|
718
|
+
fill: "#94a3b8",
|
|
719
|
+
stroke: "#94a3b8",
|
|
720
|
+
"vector-effect": "non-scaling-stroke",
|
|
721
|
+
"shape-rendering": "geometricPrecision"
|
|
722
|
+
}, null, 8, it)
|
|
723
|
+
], 64)) : K("", !0)
|
|
724
|
+
]),
|
|
725
|
+
M("g", ct, [
|
|
726
|
+
(k(!0), I(E, null, q(s.nodes, (r) => (k(), I("g", {
|
|
727
|
+
key: r.id,
|
|
728
|
+
class: "node-group",
|
|
729
|
+
transform: `translate(${r.position.x + r.size.width / 2} ${r.position.y + r.size.height / 2})`
|
|
730
|
+
}, [
|
|
731
|
+
ee(r) === "rect" ? (k(), I("rect", {
|
|
732
|
+
key: 0,
|
|
733
|
+
x: -r.size.width / 2,
|
|
734
|
+
y: -r.size.height / 2,
|
|
735
|
+
width: r.size.width,
|
|
736
|
+
height: r.size.height,
|
|
737
|
+
rx: "4",
|
|
738
|
+
ry: "4",
|
|
739
|
+
fill: F(r),
|
|
740
|
+
stroke: "#0f172a",
|
|
741
|
+
class: V({ selected: s.selectedNodeId === r.id }),
|
|
742
|
+
onMousedown: z((w) => D(r, w), ["stop"])
|
|
743
|
+
}, null, 42, lt)) : ee(r) === "ellipse" ? (k(), I("rect", {
|
|
744
|
+
key: 1,
|
|
745
|
+
x: -r.size.width / 2,
|
|
746
|
+
y: -r.size.height / 2,
|
|
747
|
+
width: r.size.width,
|
|
748
|
+
height: r.size.height,
|
|
749
|
+
rx: r.size.height / 2,
|
|
750
|
+
ry: r.size.height / 2,
|
|
751
|
+
fill: F(r),
|
|
752
|
+
stroke: "#0f172a",
|
|
753
|
+
class: V({ selected: s.selectedNodeId === r.id }),
|
|
754
|
+
onMousedown: z((w) => D(r, w), ["stop"])
|
|
755
|
+
}, null, 42, dt)) : (k(), I("polygon", {
|
|
756
|
+
key: 2,
|
|
757
|
+
points: we(r),
|
|
758
|
+
fill: F(r),
|
|
759
|
+
stroke: "#0f172a",
|
|
760
|
+
class: V({ selected: s.selectedNodeId === r.id }),
|
|
761
|
+
onMousedown: z((w) => D(r, w), ["stop"])
|
|
762
|
+
}, null, 42, ht)),
|
|
763
|
+
(k(), I("foreignObject", {
|
|
764
|
+
x: -r.size.width / 2,
|
|
765
|
+
y: -r.size.height / 2,
|
|
766
|
+
width: r.size.width,
|
|
767
|
+
height: r.size.height,
|
|
768
|
+
class: "node-title-foreign"
|
|
769
|
+
}, [
|
|
770
|
+
M("div", {
|
|
771
|
+
xmlns: "http://www.w3.org/1999/xhtml",
|
|
772
|
+
class: "node-title-dom",
|
|
773
|
+
style: _e({ color: J(r) })
|
|
774
|
+
}, [
|
|
775
|
+
Z(r) ? (k(), I("svg", ft, [
|
|
776
|
+
M("use", {
|
|
777
|
+
href: Z(r),
|
|
778
|
+
fill: J(r)
|
|
779
|
+
}, null, 8, yt)
|
|
780
|
+
])) : O(r) ? (k(), I("span", xt, H(O(r)), 1)) : K("", !0),
|
|
781
|
+
M("span", gt, H(pe(r)), 1)
|
|
782
|
+
], 4)
|
|
783
|
+
], 8, ut)),
|
|
784
|
+
(k(!0), I(E, null, q(ve(r), (w) => Le((k(), I("circle", {
|
|
785
|
+
key: w.port.id,
|
|
786
|
+
cx: w.dx,
|
|
787
|
+
cy: w.dy,
|
|
788
|
+
r: "5",
|
|
789
|
+
fill: "#ffffff",
|
|
790
|
+
stroke: "#1d4ed8",
|
|
791
|
+
class: "port-dot",
|
|
792
|
+
onMousedown: z((X) => Ie(r, w.port, X), ["stop"])
|
|
793
|
+
}, null, 40, pt)), [
|
|
794
|
+
[Te, s.selectedNodeId === r.id]
|
|
795
|
+
])), 128))
|
|
796
|
+
], 8, at))), 128))
|
|
797
|
+
])
|
|
798
|
+
], 8, Je)
|
|
799
|
+
], 40, Ze))
|
|
800
|
+
], 512));
|
|
801
|
+
}
|
|
802
|
+
}), vt = (s, h) => {
|
|
803
|
+
const c = s.__vccOpts || s;
|
|
804
|
+
for (const [u, e] of h)
|
|
805
|
+
c[u] = e;
|
|
806
|
+
return c;
|
|
807
|
+
}, bt = /* @__PURE__ */ vt(wt, [["__scopeId", "data-v-209f0bd3"]]);
|
|
808
|
+
export {
|
|
809
|
+
bt as CanvasView
|
|
810
|
+
};
|