@lupinum/board-connections 0.1.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/LICENSE +21 -0
- package/README.md +63 -0
- package/dist/colors-CI4AZ9tI.js +553 -0
- package/dist/colors.d.ts +10 -0
- package/dist/connection-actions.d.ts +41 -0
- package/dist/connection-label.d.ts +99 -0
- package/dist/connection-toolbar.d.ts +19 -0
- package/dist/controller.d.ts +50 -0
- package/dist/directionality.d.ts +8 -0
- package/dist/geometry.d.ts +23 -0
- package/dist/hit-testing.d.ts +11 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +298 -0
- package/dist/layer-helpers.d.ts +26 -0
- package/dist/layer.d.ts +38 -0
- package/dist/plugin.d.ts +7 -0
- package/dist/renderer.d.ts +32 -0
- package/dist/routing/arc.d.ts +11 -0
- package/dist/types.d.ts +113 -0
- package/dist/vue.d.ts +2 -0
- package/dist/vue.js +1479 -0
- package/package.json +62 -0
package/dist/vue.js
ADDED
|
@@ -0,0 +1,1479 @@
|
|
|
1
|
+
import { h as g, defineComponent as xe, nextTick as We, computed as z, shallowRef as H, useId as He, watch as F, Teleport as Oe } from "vue";
|
|
2
|
+
import { CommandBlockedError as Be, boundsIntersect as Ge } from "@lupinum/board-core";
|
|
3
|
+
import { useBoardEngine as Fe } from "@lupinum/vue-board";
|
|
4
|
+
import { E as Xe, j as Ze, e as je, h as Ye, f as Y, i as te, a as ne, r as U } from "./colors-CI4AZ9tI.js";
|
|
5
|
+
const Ue = 6, qe = 0.95, Ke = 0.45, ve = 18, Ve = 16, Je = 10, Qe = 22, et = 0.1, pe = 220, tt = 20, nt = 18, ot = 24, rt = 14, he = 13;
|
|
6
|
+
function K(e) {
|
|
7
|
+
return Math.max(0, Math.min(1, e));
|
|
8
|
+
}
|
|
9
|
+
function at(e, n, r) {
|
|
10
|
+
return e >= n ? 1 : e <= r ? 0 : K((e - r) / (n - r));
|
|
11
|
+
}
|
|
12
|
+
function dt(e) {
|
|
13
|
+
return Math.max(
|
|
14
|
+
Je,
|
|
15
|
+
Math.min(
|
|
16
|
+
Qe,
|
|
17
|
+
Ve * Math.sqrt(e)
|
|
18
|
+
)
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
function q(e, n, r, v) {
|
|
22
|
+
return n.screenToWorld(e.toLocalPoint(r, v));
|
|
23
|
+
}
|
|
24
|
+
function it(e, n) {
|
|
25
|
+
return {
|
|
26
|
+
id: `floating-${n}`,
|
|
27
|
+
x: e.x,
|
|
28
|
+
y: e.y,
|
|
29
|
+
width: 0,
|
|
30
|
+
height: 0
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function lt(e, n, r) {
|
|
34
|
+
const v = K(n === "top" || n === "bottom" ? (r.x - e.x) / Math.max(e.width, 1) : (r.y - e.y) / Math.max(e.height, 1));
|
|
35
|
+
return { side: n, offset: v };
|
|
36
|
+
}
|
|
37
|
+
function me(e, n) {
|
|
38
|
+
return !!(e && n && e.side === n.side && Math.abs(e.offset - n.offset) < 1e-3);
|
|
39
|
+
}
|
|
40
|
+
function Ie(e) {
|
|
41
|
+
return e instanceof Element ? e.closest("[data-connection-edge-id]")?.dataset.connectionEdgeId ?? null : null;
|
|
42
|
+
}
|
|
43
|
+
function ct(e) {
|
|
44
|
+
if (!(e instanceof Element)) return null;
|
|
45
|
+
const n = e.closest(
|
|
46
|
+
"[data-connection-node-id][data-connection-side]"
|
|
47
|
+
);
|
|
48
|
+
return !n?.dataset.connectionNodeId || !n.dataset.connectionSide ? null : {
|
|
49
|
+
nodeId: n.dataset.connectionNodeId,
|
|
50
|
+
side: n.dataset.connectionSide,
|
|
51
|
+
offset: K(Number(n.dataset.connectionOffset ?? 0.5))
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function ut(e, n) {
|
|
55
|
+
return Ie(e) === n;
|
|
56
|
+
}
|
|
57
|
+
function be(e, n, r, v) {
|
|
58
|
+
let A = null, N = -1 / 0;
|
|
59
|
+
for (const x of e) {
|
|
60
|
+
if (!x.visible || x.zIndex <= N) continue;
|
|
61
|
+
const C = x.x, w = x.x + x.width, S = x.y, y = x.y + x.height;
|
|
62
|
+
if (n.x < C - r || n.x > w + r || n.y < S - r || n.y > y + r)
|
|
63
|
+
continue;
|
|
64
|
+
const s = Math.min(
|
|
65
|
+
v,
|
|
66
|
+
Math.min(x.width, x.height) / 3
|
|
67
|
+
);
|
|
68
|
+
let I = null, c = 1 / 0;
|
|
69
|
+
const a = (u, f) => {
|
|
70
|
+
f < c && (I = u, c = f);
|
|
71
|
+
};
|
|
72
|
+
n.x >= C + s && n.x <= w - s && (a("top", Math.abs(n.y - S)), a("bottom", Math.abs(n.y - y))), n.y >= S + s && n.y <= y - s && (a("left", Math.abs(n.x - C)), a("right", Math.abs(n.x - w))), I && c <= r && (A = {
|
|
73
|
+
nodeId: x.id,
|
|
74
|
+
...lt(x, I, n)
|
|
75
|
+
}, N = x.zIndex);
|
|
76
|
+
}
|
|
77
|
+
return A;
|
|
78
|
+
}
|
|
79
|
+
function st(e) {
|
|
80
|
+
const n = e.active?.pointerId ?? e.pending?.pointerId;
|
|
81
|
+
if (n === void 0 || n !== e.pointerId)
|
|
82
|
+
return { pending: e.pending, active: e.active };
|
|
83
|
+
if (e.pending) {
|
|
84
|
+
if (Math.hypot(
|
|
85
|
+
e.pointerWorld.x - e.pending.startWorld.x,
|
|
86
|
+
e.pointerWorld.y - e.pending.startWorld.y
|
|
87
|
+
) * e.zoom < e.threshold)
|
|
88
|
+
return { pending: e.pending, active: null };
|
|
89
|
+
const v = {
|
|
90
|
+
pointerId: e.pending.pointerId,
|
|
91
|
+
pointerWorld: e.pointerWorld,
|
|
92
|
+
candidateNodeId: e.candidateNodeId,
|
|
93
|
+
candidateAnchor: e.candidateAnchor
|
|
94
|
+
};
|
|
95
|
+
return {
|
|
96
|
+
pending: null,
|
|
97
|
+
active: e.pending.mode === "reconnect" ? {
|
|
98
|
+
...v,
|
|
99
|
+
mode: "reconnect",
|
|
100
|
+
edgeId: e.pending.edgeId,
|
|
101
|
+
end: e.pending.end
|
|
102
|
+
} : {
|
|
103
|
+
...v,
|
|
104
|
+
mode: "create",
|
|
105
|
+
sourceNodeId: e.pending.sourceNodeId,
|
|
106
|
+
sourceSide: e.pending.sourceSide
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
return e.active ? {
|
|
111
|
+
pending: null,
|
|
112
|
+
active: {
|
|
113
|
+
...e.active,
|
|
114
|
+
pointerWorld: e.pointerWorld,
|
|
115
|
+
candidateNodeId: e.candidateNodeId,
|
|
116
|
+
candidateAnchor: e.candidateAnchor
|
|
117
|
+
}
|
|
118
|
+
} : { pending: null, active: null };
|
|
119
|
+
}
|
|
120
|
+
function gt(e) {
|
|
121
|
+
const { entry: n } = e;
|
|
122
|
+
return g("path", {
|
|
123
|
+
d: n.route.path,
|
|
124
|
+
stroke: e.stroke,
|
|
125
|
+
color: n.edge.color ?? "var(--board-edge-color)",
|
|
126
|
+
fill: "none",
|
|
127
|
+
opacity: e.opacity,
|
|
128
|
+
"stroke-width": e.strokeWidth,
|
|
129
|
+
"stroke-linecap": "round",
|
|
130
|
+
"stroke-linejoin": "round",
|
|
131
|
+
"vector-effect": "non-scaling-stroke",
|
|
132
|
+
"marker-start": n.edge.fromEnd === "arrow" ? `url(#${e.markerId})` : void 0,
|
|
133
|
+
"marker-end": n.edge.toEnd === "arrow" ? `url(#${e.markerId})` : void 0,
|
|
134
|
+
style: { pointerEvents: "none" }
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
function ft(e) {
|
|
138
|
+
const { preview: n, drag: r } = e, v = n.edge?.color ?? "var(--board-edge-active-color)", A = r.mode === "reconnect" && r.end === "from" ? n.target : n.source, N = r.mode === "reconnect" && r.end === "from" ? n.source : n.target;
|
|
139
|
+
return [
|
|
140
|
+
n.candidateNode ? g("rect", {
|
|
141
|
+
x: n.candidateNode.x,
|
|
142
|
+
y: n.candidateNode.y,
|
|
143
|
+
width: n.candidateNode.width,
|
|
144
|
+
height: n.candidateNode.height,
|
|
145
|
+
rx: 10,
|
|
146
|
+
ry: 10,
|
|
147
|
+
fill: "none",
|
|
148
|
+
stroke: "var(--board-edge-active-color)",
|
|
149
|
+
"stroke-width": 2 / e.zoom,
|
|
150
|
+
"vector-effect": "non-scaling-stroke",
|
|
151
|
+
opacity: 0.9,
|
|
152
|
+
style: { pointerEvents: "none" }
|
|
153
|
+
}) : null,
|
|
154
|
+
g("path", {
|
|
155
|
+
d: n.route.path,
|
|
156
|
+
stroke: v,
|
|
157
|
+
fill: "none",
|
|
158
|
+
opacity: 0.55,
|
|
159
|
+
"stroke-width": e.strokeWidth,
|
|
160
|
+
"stroke-linecap": "round",
|
|
161
|
+
"stroke-linejoin": "round",
|
|
162
|
+
"vector-effect": "non-scaling-stroke",
|
|
163
|
+
"marker-end": `url(#${e.markerId})`,
|
|
164
|
+
color: v,
|
|
165
|
+
style: { pointerEvents: "none" }
|
|
166
|
+
}),
|
|
167
|
+
g("circle", {
|
|
168
|
+
cx: A.point.x,
|
|
169
|
+
cy: A.point.y,
|
|
170
|
+
r: e.handleRadius,
|
|
171
|
+
fill: "#ffffff",
|
|
172
|
+
stroke: v,
|
|
173
|
+
"stroke-width": 1.5 / e.zoom,
|
|
174
|
+
"vector-effect": "non-scaling-stroke",
|
|
175
|
+
style: { pointerEvents: "none" }
|
|
176
|
+
}),
|
|
177
|
+
g("circle", {
|
|
178
|
+
cx: N.point.x,
|
|
179
|
+
cy: N.point.y,
|
|
180
|
+
r: e.handleRadius,
|
|
181
|
+
fill: "#ffffff",
|
|
182
|
+
stroke: "var(--board-edge-active-color)",
|
|
183
|
+
"stroke-width": 1.5 / e.zoom,
|
|
184
|
+
"vector-effect": "non-scaling-stroke",
|
|
185
|
+
style: { pointerEvents: "none" }
|
|
186
|
+
})
|
|
187
|
+
];
|
|
188
|
+
}
|
|
189
|
+
const vt = xe({
|
|
190
|
+
name: "ConnectionLabel",
|
|
191
|
+
props: {
|
|
192
|
+
edgeId: { type: String, required: !0 },
|
|
193
|
+
point: { type: Object, required: !0 },
|
|
194
|
+
label: { type: String, default: "" },
|
|
195
|
+
color: { type: String, default: "var(--board-edge-color)" },
|
|
196
|
+
zoom: { type: Number, required: !0 },
|
|
197
|
+
selected: { type: Boolean, default: !1 },
|
|
198
|
+
hovered: { type: Boolean, default: !1 },
|
|
199
|
+
editing: { type: Boolean, default: !1 },
|
|
200
|
+
draft: { type: String, default: "" }
|
|
201
|
+
},
|
|
202
|
+
emits: {
|
|
203
|
+
edgePointerDown: (e, n) => !0,
|
|
204
|
+
beginEdit: (e) => !0,
|
|
205
|
+
updateDraft: (e) => !0,
|
|
206
|
+
commitEdit: () => !0,
|
|
207
|
+
cancelEdit: () => !0
|
|
208
|
+
},
|
|
209
|
+
setup(e, { emit: n }) {
|
|
210
|
+
return () => {
|
|
211
|
+
if (!e.editing && !e.label) return null;
|
|
212
|
+
const r = e.editing || e.selected || e.hovered, A = 1 / Math.max(e.zoom, et), N = e.editing ? e.draft : e.label, x = Math.max(
|
|
213
|
+
r ? 40 : 24,
|
|
214
|
+
Math.min(
|
|
215
|
+
pe,
|
|
216
|
+
(N.length || 1) * 8 + tt
|
|
217
|
+
)
|
|
218
|
+
), C = r ? ot : nt, w = x * A, S = C * A, y = e.editing ? g("input", {
|
|
219
|
+
"data-connection-label-input": e.edgeId,
|
|
220
|
+
"data-board-interactive": "true",
|
|
221
|
+
"data-connection-edge-id": e.edgeId,
|
|
222
|
+
type: "text",
|
|
223
|
+
value: e.draft,
|
|
224
|
+
onInput: (s) => n("updateDraft", s.target.value),
|
|
225
|
+
onKeydown: (s) => {
|
|
226
|
+
s.key === "Enter" ? (s.preventDefault(), n("commitEdit")) : s.key === "Escape" && (s.preventDefault(), n("cancelEdit")), s.stopPropagation();
|
|
227
|
+
},
|
|
228
|
+
onBlur: () => n("commitEdit"),
|
|
229
|
+
onPointerdown: (s) => s.stopPropagation(),
|
|
230
|
+
style: {
|
|
231
|
+
width: "100%",
|
|
232
|
+
height: "100%",
|
|
233
|
+
boxSizing: "border-box",
|
|
234
|
+
padding: "2px 8px",
|
|
235
|
+
borderRadius: "999px",
|
|
236
|
+
border: "1px solid currentColor",
|
|
237
|
+
background: "var(--board-node-bg, #fff)",
|
|
238
|
+
color: "inherit",
|
|
239
|
+
font: "inherit",
|
|
240
|
+
fontSize: `${he}px`,
|
|
241
|
+
lineHeight: "1",
|
|
242
|
+
outline: "none",
|
|
243
|
+
boxShadow: "0 1px 2px rgba(0,0,0,0.06)"
|
|
244
|
+
}
|
|
245
|
+
}) : g(
|
|
246
|
+
"div",
|
|
247
|
+
{
|
|
248
|
+
"data-connection-label": e.edgeId,
|
|
249
|
+
"data-board-interactive": "true",
|
|
250
|
+
"data-connection-edge-id": e.edgeId,
|
|
251
|
+
title: e.label,
|
|
252
|
+
onPointerdown: (s) => n("edgePointerDown", e.edgeId, s),
|
|
253
|
+
onDblclick: (s) => {
|
|
254
|
+
s.preventDefault(), s.stopPropagation(), n("beginEdit", e.edgeId);
|
|
255
|
+
},
|
|
256
|
+
style: {
|
|
257
|
+
display: "inline-flex",
|
|
258
|
+
alignItems: "center",
|
|
259
|
+
justifyContent: "center",
|
|
260
|
+
padding: r ? "2px 8px" : "0 3px",
|
|
261
|
+
maxWidth: `${pe}px`,
|
|
262
|
+
borderRadius: "999px",
|
|
263
|
+
border: r ? "1px solid currentColor" : "1px solid transparent",
|
|
264
|
+
background: r ? "var(--board-node-bg, #fff)" : "transparent",
|
|
265
|
+
fontSize: `${r ? he : rt}px`,
|
|
266
|
+
lineHeight: r ? "1" : "1.2",
|
|
267
|
+
fontWeight: r ? "500" : "600",
|
|
268
|
+
color: "inherit",
|
|
269
|
+
cursor: "text",
|
|
270
|
+
whiteSpace: "nowrap",
|
|
271
|
+
overflow: "hidden",
|
|
272
|
+
textOverflow: "ellipsis",
|
|
273
|
+
textShadow: r ? "none" : "0 1px 0 var(--board-node-bg, #fff), 0 -1px 0 var(--board-node-bg, #fff), 1px 0 0 var(--board-node-bg, #fff), -1px 0 0 var(--board-node-bg, #fff)",
|
|
274
|
+
boxShadow: r ? "0 1px 2px rgba(0,0,0,0.06)" : "none"
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
e.label || " "
|
|
278
|
+
);
|
|
279
|
+
return g(
|
|
280
|
+
"foreignObject",
|
|
281
|
+
{
|
|
282
|
+
x: e.point.x - w / 2,
|
|
283
|
+
y: e.point.y - S / 2,
|
|
284
|
+
width: w,
|
|
285
|
+
height: S,
|
|
286
|
+
color: e.color,
|
|
287
|
+
style: { overflow: "visible", pointerEvents: "auto" }
|
|
288
|
+
},
|
|
289
|
+
[
|
|
290
|
+
g(
|
|
291
|
+
"div",
|
|
292
|
+
{
|
|
293
|
+
xmlns: "http://www.w3.org/1999/xhtml",
|
|
294
|
+
style: {
|
|
295
|
+
width: "100%",
|
|
296
|
+
height: "100%",
|
|
297
|
+
display: "flex",
|
|
298
|
+
alignItems: "center",
|
|
299
|
+
justifyContent: "center"
|
|
300
|
+
}
|
|
301
|
+
},
|
|
302
|
+
[
|
|
303
|
+
g(
|
|
304
|
+
"div",
|
|
305
|
+
{
|
|
306
|
+
style: {
|
|
307
|
+
width: `${x}px`,
|
|
308
|
+
height: `${C}px`,
|
|
309
|
+
display: "flex",
|
|
310
|
+
alignItems: "center",
|
|
311
|
+
justifyContent: "center"
|
|
312
|
+
}
|
|
313
|
+
},
|
|
314
|
+
[y]
|
|
315
|
+
)
|
|
316
|
+
]
|
|
317
|
+
)
|
|
318
|
+
]
|
|
319
|
+
);
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
}), Ee = 24;
|
|
323
|
+
function pt(e) {
|
|
324
|
+
const n = String(e.edge.id), r = e.screen, v = e, A = e.edge.color, N = !!e.edge.fromAnchor, x = !!e.edge.toAnchor, C = N || x, w = e.edge.fromEnd ?? "none", S = e.edge.toEnd ?? "arrow", y = w === "arrow" && S === "arrow" ? "both" : w === "none" && S === "none" ? "none" : "to", s = {
|
|
325
|
+
display: "inline-flex",
|
|
326
|
+
alignItems: "center",
|
|
327
|
+
justifyContent: "center",
|
|
328
|
+
width: "32px",
|
|
329
|
+
height: "32px",
|
|
330
|
+
padding: "0",
|
|
331
|
+
border: "none",
|
|
332
|
+
background: "transparent",
|
|
333
|
+
borderRadius: "6px",
|
|
334
|
+
cursor: "pointer",
|
|
335
|
+
fontSize: "14px",
|
|
336
|
+
lineHeight: "1",
|
|
337
|
+
color: "var(--board-muted-fg, #6b7280)"
|
|
338
|
+
}, I = (i, L) => ({
|
|
339
|
+
width: "20px",
|
|
340
|
+
height: "20px",
|
|
341
|
+
borderRadius: "50%",
|
|
342
|
+
background: i,
|
|
343
|
+
border: L ? "2px solid var(--board-fg, #0f172a)" : "1px solid rgba(15, 23, 42, 0.15)",
|
|
344
|
+
cursor: "pointer",
|
|
345
|
+
padding: "0",
|
|
346
|
+
boxSizing: "border-box"
|
|
347
|
+
}), c = (i, L) => g(
|
|
348
|
+
"svg",
|
|
349
|
+
{
|
|
350
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
351
|
+
width: Ee,
|
|
352
|
+
height: Ee,
|
|
353
|
+
viewBox: "0 0 24 24",
|
|
354
|
+
fill: "none",
|
|
355
|
+
stroke: "currentColor",
|
|
356
|
+
"stroke-width": "2",
|
|
357
|
+
"stroke-linecap": "round",
|
|
358
|
+
"stroke-linejoin": "round",
|
|
359
|
+
"aria-hidden": "true",
|
|
360
|
+
focusable: "false"
|
|
361
|
+
},
|
|
362
|
+
i.map((P) => g("path", { d: P }))
|
|
363
|
+
), a = (i, L, P, R) => g(
|
|
364
|
+
"button",
|
|
365
|
+
{
|
|
366
|
+
"data-board-interactive": "true",
|
|
367
|
+
...R?.testId ? { [R.testId]: n } : {},
|
|
368
|
+
type: "button",
|
|
369
|
+
title: i,
|
|
370
|
+
"aria-label": i,
|
|
371
|
+
disabled: R?.disabled,
|
|
372
|
+
style: {
|
|
373
|
+
...s,
|
|
374
|
+
opacity: R?.disabled ? "0.38" : "1",
|
|
375
|
+
color: R?.danger ? "#b45353" : "var(--board-muted-fg, #6b7280)",
|
|
376
|
+
cursor: R?.disabled ? "default" : "pointer"
|
|
377
|
+
},
|
|
378
|
+
onClick: P
|
|
379
|
+
},
|
|
380
|
+
[L]
|
|
381
|
+
), u = () => g("span", {
|
|
382
|
+
style: {
|
|
383
|
+
display: "inline-block",
|
|
384
|
+
width: "1px",
|
|
385
|
+
height: "22px",
|
|
386
|
+
background: "rgba(15,23,42,0.12)",
|
|
387
|
+
margin: "0 2px"
|
|
388
|
+
}
|
|
389
|
+
}), f = (i, L, P) => g(
|
|
390
|
+
"button",
|
|
391
|
+
{
|
|
392
|
+
"data-board-interactive": "true",
|
|
393
|
+
"data-connection-direction-option": P,
|
|
394
|
+
type: "button",
|
|
395
|
+
title: i,
|
|
396
|
+
"aria-label": i,
|
|
397
|
+
style: {
|
|
398
|
+
display: "grid",
|
|
399
|
+
gridTemplateColumns: "32px 1fr 24px",
|
|
400
|
+
alignItems: "center",
|
|
401
|
+
gap: "8px",
|
|
402
|
+
width: "100%",
|
|
403
|
+
minWidth: "250px",
|
|
404
|
+
height: "42px",
|
|
405
|
+
padding: "0 12px",
|
|
406
|
+
border: "none",
|
|
407
|
+
borderRadius: "7px",
|
|
408
|
+
background: y === P ? "rgba(107, 114, 128, 0.16)" : "transparent",
|
|
409
|
+
color: "var(--board-fg, #111827)",
|
|
410
|
+
cursor: "pointer",
|
|
411
|
+
font: "inherit",
|
|
412
|
+
fontSize: "18px",
|
|
413
|
+
lineHeight: "1",
|
|
414
|
+
textAlign: "left"
|
|
415
|
+
},
|
|
416
|
+
onClick: (R) => {
|
|
417
|
+
R.preventDefault(), R.stopPropagation(), v.onSetDirectionality(P);
|
|
418
|
+
}
|
|
419
|
+
},
|
|
420
|
+
[
|
|
421
|
+
g("span", { style: { color: "var(--board-muted-fg, #6b7280)" } }, [
|
|
422
|
+
L
|
|
423
|
+
]),
|
|
424
|
+
g("span", i),
|
|
425
|
+
y === P ? c(["m20 6-11 11-5-5"]) : g("span")
|
|
426
|
+
]
|
|
427
|
+
);
|
|
428
|
+
return g(
|
|
429
|
+
"div",
|
|
430
|
+
{
|
|
431
|
+
"data-board-interactive": "true",
|
|
432
|
+
"data-connection-toolbar": n,
|
|
433
|
+
onPointerdown: (i) => i.stopPropagation(),
|
|
434
|
+
style: {
|
|
435
|
+
position: "absolute",
|
|
436
|
+
left: `${r.x}px`,
|
|
437
|
+
top: `${r.y}px`,
|
|
438
|
+
transform: "translate(-50%, calc(-100% - 14px))",
|
|
439
|
+
zIndex: "7",
|
|
440
|
+
display: "inline-flex",
|
|
441
|
+
alignItems: "center",
|
|
442
|
+
gap: "4px",
|
|
443
|
+
padding: "5px",
|
|
444
|
+
background: "var(--board-node-bg, #ffffff)",
|
|
445
|
+
border: "1px solid var(--board-node-border, rgba(15,23,42,0.1))",
|
|
446
|
+
borderRadius: "6px",
|
|
447
|
+
boxShadow: "0 4px 14px rgba(15, 23, 42, 0.12), 0 1px 2px rgba(15, 23, 42, 0.08)",
|
|
448
|
+
fontSize: "12px",
|
|
449
|
+
color: "var(--board-fg, #0f172a)",
|
|
450
|
+
whiteSpace: "nowrap",
|
|
451
|
+
pointerEvents: "auto",
|
|
452
|
+
userSelect: "none"
|
|
453
|
+
}
|
|
454
|
+
},
|
|
455
|
+
[
|
|
456
|
+
a(
|
|
457
|
+
"Remove",
|
|
458
|
+
c([
|
|
459
|
+
"M10 11v6",
|
|
460
|
+
"M14 11v6",
|
|
461
|
+
"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",
|
|
462
|
+
"M3 6h18",
|
|
463
|
+
"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"
|
|
464
|
+
]),
|
|
465
|
+
(i) => {
|
|
466
|
+
i.preventDefault(), i.stopPropagation(), v.onDelete();
|
|
467
|
+
},
|
|
468
|
+
{ danger: !0 }
|
|
469
|
+
),
|
|
470
|
+
g(
|
|
471
|
+
"div",
|
|
472
|
+
{
|
|
473
|
+
style: {
|
|
474
|
+
position: "relative",
|
|
475
|
+
display: "inline-flex"
|
|
476
|
+
}
|
|
477
|
+
},
|
|
478
|
+
[
|
|
479
|
+
a(
|
|
480
|
+
"Set colour",
|
|
481
|
+
c([
|
|
482
|
+
"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",
|
|
483
|
+
"M13.5 6.5h.01",
|
|
484
|
+
"M17.5 10.5h.01",
|
|
485
|
+
"M6.5 12.5h.01",
|
|
486
|
+
"M8.5 7.5h.01"
|
|
487
|
+
]),
|
|
488
|
+
(i) => {
|
|
489
|
+
i.preventDefault(), i.stopPropagation(), v.onToggleColorMenu();
|
|
490
|
+
}
|
|
491
|
+
),
|
|
492
|
+
e.colorMenuOpen ? g(
|
|
493
|
+
"div",
|
|
494
|
+
{
|
|
495
|
+
"data-board-interactive": "true",
|
|
496
|
+
"data-connection-color-menu": n,
|
|
497
|
+
style: {
|
|
498
|
+
position: "absolute",
|
|
499
|
+
left: "50%",
|
|
500
|
+
top: "calc(100% + 8px)",
|
|
501
|
+
transform: "translateX(-50%)",
|
|
502
|
+
zIndex: "1",
|
|
503
|
+
display: "grid",
|
|
504
|
+
gridTemplateColumns: "repeat(4, 20px)",
|
|
505
|
+
gap: "8px",
|
|
506
|
+
padding: "8px",
|
|
507
|
+
background: "var(--board-node-bg, #ffffff)",
|
|
508
|
+
border: "1px solid var(--board-node-border, rgba(15,23,42,0.1))",
|
|
509
|
+
borderRadius: "6px",
|
|
510
|
+
boxShadow: "0 6px 18px rgba(15, 23, 42, 0.14), 0 1px 2px rgba(15, 23, 42, 0.08)"
|
|
511
|
+
}
|
|
512
|
+
},
|
|
513
|
+
[
|
|
514
|
+
g("button", {
|
|
515
|
+
"data-board-interactive": "true",
|
|
516
|
+
type: "button",
|
|
517
|
+
title: "Default color",
|
|
518
|
+
style: {
|
|
519
|
+
...I("transparent", !A),
|
|
520
|
+
backgroundImage: "repeating-linear-gradient(45deg, rgba(148,163,184,0.35) 0 3px, transparent 3px 6px)"
|
|
521
|
+
},
|
|
522
|
+
onClick: (i) => {
|
|
523
|
+
i.preventDefault(), i.stopPropagation(), v.onSetColor(void 0);
|
|
524
|
+
}
|
|
525
|
+
}),
|
|
526
|
+
...Xe.map(
|
|
527
|
+
(i) => g("button", {
|
|
528
|
+
"data-board-interactive": "true",
|
|
529
|
+
type: "button",
|
|
530
|
+
title: i.label,
|
|
531
|
+
style: I(
|
|
532
|
+
i.hex,
|
|
533
|
+
Ze(A) === i.hex
|
|
534
|
+
),
|
|
535
|
+
onClick: (L) => {
|
|
536
|
+
L.preventDefault(), L.stopPropagation(), v.onSetColor(i.hex);
|
|
537
|
+
}
|
|
538
|
+
})
|
|
539
|
+
)
|
|
540
|
+
]
|
|
541
|
+
) : null
|
|
542
|
+
]
|
|
543
|
+
),
|
|
544
|
+
u(),
|
|
545
|
+
g(
|
|
546
|
+
"div",
|
|
547
|
+
{
|
|
548
|
+
style: {
|
|
549
|
+
position: "relative",
|
|
550
|
+
display: "inline-flex"
|
|
551
|
+
}
|
|
552
|
+
},
|
|
553
|
+
[
|
|
554
|
+
a(
|
|
555
|
+
"Line direction",
|
|
556
|
+
c(["M5 12h14", "m12 5 7 7-7 7"]),
|
|
557
|
+
(i) => {
|
|
558
|
+
i.preventDefault(), i.stopPropagation(), v.onToggleDirectionMenu();
|
|
559
|
+
},
|
|
560
|
+
{ testId: "data-connection-direction-menu-button" }
|
|
561
|
+
),
|
|
562
|
+
e.directionMenuOpen ? g(
|
|
563
|
+
"div",
|
|
564
|
+
{
|
|
565
|
+
"data-board-interactive": "true",
|
|
566
|
+
"data-connection-direction-menu": n,
|
|
567
|
+
style: {
|
|
568
|
+
position: "absolute",
|
|
569
|
+
left: "50%",
|
|
570
|
+
top: "calc(100% + 8px)",
|
|
571
|
+
transform: "translateX(-50%)",
|
|
572
|
+
zIndex: "1",
|
|
573
|
+
display: "grid",
|
|
574
|
+
gap: "2px",
|
|
575
|
+
padding: "8px",
|
|
576
|
+
background: "var(--board-node-bg, #ffffff)",
|
|
577
|
+
border: "1px solid var(--board-node-border, rgba(15,23,42,0.1))",
|
|
578
|
+
borderRadius: "8px",
|
|
579
|
+
boxShadow: "0 8px 22px rgba(15, 23, 42, 0.16), 0 1px 2px rgba(15, 23, 42, 0.08)"
|
|
580
|
+
}
|
|
581
|
+
},
|
|
582
|
+
[
|
|
583
|
+
f(
|
|
584
|
+
"Nondirectional",
|
|
585
|
+
c(["M5 12h14"]),
|
|
586
|
+
"none"
|
|
587
|
+
),
|
|
588
|
+
f(
|
|
589
|
+
"Unidirectional",
|
|
590
|
+
c(["M5 12h14", "m12 5 7 7-7 7"]),
|
|
591
|
+
"to"
|
|
592
|
+
),
|
|
593
|
+
f(
|
|
594
|
+
"Bidirectional",
|
|
595
|
+
c(["M7 7 3 12l4 5", "M17 7l4 5-4 5", "M4 12h16"]),
|
|
596
|
+
"both"
|
|
597
|
+
)
|
|
598
|
+
]
|
|
599
|
+
) : null
|
|
600
|
+
]
|
|
601
|
+
),
|
|
602
|
+
C ? u() : null,
|
|
603
|
+
N ? a(
|
|
604
|
+
"Reset source anchor to auto",
|
|
605
|
+
c([
|
|
606
|
+
"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",
|
|
607
|
+
"M21 3v5h-5",
|
|
608
|
+
"M12 7v5l3 3"
|
|
609
|
+
]),
|
|
610
|
+
(i) => {
|
|
611
|
+
i.preventDefault(), i.stopPropagation(), v.onResetAnchor("from");
|
|
612
|
+
},
|
|
613
|
+
{ testId: "data-connection-reset-source-anchor" }
|
|
614
|
+
) : null,
|
|
615
|
+
x ? a(
|
|
616
|
+
"Reset target anchor to auto",
|
|
617
|
+
c([
|
|
618
|
+
"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",
|
|
619
|
+
"M3 21v-5h5",
|
|
620
|
+
"M12 7v5l3 3"
|
|
621
|
+
]),
|
|
622
|
+
(i) => {
|
|
623
|
+
i.preventDefault(), i.stopPropagation(), v.onResetAnchor("to");
|
|
624
|
+
},
|
|
625
|
+
{ testId: "data-connection-reset-target-anchor" }
|
|
626
|
+
) : null,
|
|
627
|
+
N && x ? a(
|
|
628
|
+
"Reset connection to auto",
|
|
629
|
+
c([
|
|
630
|
+
"M4 4v6h6",
|
|
631
|
+
"M20 20v-6h-6",
|
|
632
|
+
"M20 9A8 8 0 0 0 6.3 4.7L4 7",
|
|
633
|
+
"M4 15a8 8 0 0 0 13.7 4.3L20 17"
|
|
634
|
+
]),
|
|
635
|
+
(i) => {
|
|
636
|
+
i.preventDefault(), i.stopPropagation(), v.onResetAnchor("both");
|
|
637
|
+
},
|
|
638
|
+
{ testId: "data-connection-reset-all-anchors" }
|
|
639
|
+
) : null,
|
|
640
|
+
a(
|
|
641
|
+
"Remove label",
|
|
642
|
+
c(["M3 3h18v18H3z", "m15 9-6 6", "m9 9 6 6"]),
|
|
643
|
+
(i) => {
|
|
644
|
+
i.preventDefault(), i.stopPropagation(), v.onClearLabel();
|
|
645
|
+
},
|
|
646
|
+
{
|
|
647
|
+
disabled: !e.edge.label,
|
|
648
|
+
testId: "data-connection-remove-label"
|
|
649
|
+
}
|
|
650
|
+
),
|
|
651
|
+
a(
|
|
652
|
+
"Edit label",
|
|
653
|
+
c([
|
|
654
|
+
"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",
|
|
655
|
+
"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z"
|
|
656
|
+
]),
|
|
657
|
+
(i) => {
|
|
658
|
+
i.preventDefault(), i.stopPropagation(), v.onBeginLabelEdit();
|
|
659
|
+
}
|
|
660
|
+
)
|
|
661
|
+
]
|
|
662
|
+
);
|
|
663
|
+
}
|
|
664
|
+
function O(e) {
|
|
665
|
+
try {
|
|
666
|
+
return e();
|
|
667
|
+
} catch (n) {
|
|
668
|
+
if (n instanceof Be) return;
|
|
669
|
+
throw n;
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
function ht(e) {
|
|
673
|
+
const n = e.state;
|
|
674
|
+
function r(a, u) {
|
|
675
|
+
u.preventDefault(), u.stopPropagation(), n.editingEdgeId.value && n.editingEdgeId.value !== a && A(), n.selectedEdgeId.value = a, n.hoveredEdgeId.value = a, n.hoveredNodeHandle.value = null;
|
|
676
|
+
}
|
|
677
|
+
function v(a) {
|
|
678
|
+
const u = e.getEntry(a);
|
|
679
|
+
u && (n.selectedEdgeId.value = a, n.hoveredEdgeId.value = a, n.editingEdgeId.value = a, n.labelDraft.value = u.edge.label ?? "", We(() => {
|
|
680
|
+
const f = e.getRootElement()?.querySelector(
|
|
681
|
+
`[data-connection-label-input="${a}"]`
|
|
682
|
+
) ?? null;
|
|
683
|
+
f?.focus(), f?.select();
|
|
684
|
+
}));
|
|
685
|
+
}
|
|
686
|
+
function A() {
|
|
687
|
+
const a = n.editingEdgeId.value;
|
|
688
|
+
if (!a) return;
|
|
689
|
+
const u = e.getEntry(a);
|
|
690
|
+
if (n.editingEdgeId.value = null, !u) return;
|
|
691
|
+
const f = n.labelDraft.value.trim();
|
|
692
|
+
f !== (u.edge.label ?? "") && O(
|
|
693
|
+
() => e.getEngine().plugins.connections.updateEdge(u.edge.id, {
|
|
694
|
+
label: f || void 0
|
|
695
|
+
})
|
|
696
|
+
);
|
|
697
|
+
}
|
|
698
|
+
function N(a) {
|
|
699
|
+
const u = e.getEntry(a);
|
|
700
|
+
u?.edge.label && (n.editingEdgeId.value === a && (n.editingEdgeId.value = null), O(
|
|
701
|
+
() => e.getEngine().plugins.connections.updateEdge(u.edge.id, {
|
|
702
|
+
label: void 0
|
|
703
|
+
})
|
|
704
|
+
));
|
|
705
|
+
}
|
|
706
|
+
function x() {
|
|
707
|
+
n.editingEdgeId.value = null, n.labelDraft.value = "";
|
|
708
|
+
}
|
|
709
|
+
function C(a, u) {
|
|
710
|
+
const f = e.getEntry(a);
|
|
711
|
+
if (!f) return;
|
|
712
|
+
const i = je(
|
|
713
|
+
u === "to" ? "end" : u
|
|
714
|
+
);
|
|
715
|
+
O(
|
|
716
|
+
() => e.getEngine().plugins.connections.updateEdge(f.edge.id, {
|
|
717
|
+
fromEnd: i.fromEnd,
|
|
718
|
+
toEnd: i.toEnd
|
|
719
|
+
})
|
|
720
|
+
), n.directionMenuEdgeId.value = null;
|
|
721
|
+
}
|
|
722
|
+
function w(a, u) {
|
|
723
|
+
const f = e.getEntry(a);
|
|
724
|
+
f && (O(
|
|
725
|
+
() => e.getEngine().plugins.connections.updateEdge(f.edge.id, { color: u })
|
|
726
|
+
), n.colorMenuEdgeId.value = null);
|
|
727
|
+
}
|
|
728
|
+
function S(a, u) {
|
|
729
|
+
const f = e.getEntry(a);
|
|
730
|
+
f && O(
|
|
731
|
+
() => e.getEngine().plugins.connections.updateEdge(f.edge.id, {
|
|
732
|
+
...u === "from" || u === "both" ? { fromAnchor: void 0 } : {},
|
|
733
|
+
...u === "to" || u === "both" ? { toAnchor: void 0 } : {}
|
|
734
|
+
})
|
|
735
|
+
);
|
|
736
|
+
}
|
|
737
|
+
function y(a) {
|
|
738
|
+
const u = e.getEntry(a);
|
|
739
|
+
if (u) {
|
|
740
|
+
for (const f of [
|
|
741
|
+
n.editingEdgeId,
|
|
742
|
+
n.selectedEdgeId,
|
|
743
|
+
n.hoveredEdgeId,
|
|
744
|
+
n.colorMenuEdgeId,
|
|
745
|
+
n.directionMenuEdgeId
|
|
746
|
+
])
|
|
747
|
+
f.value === a && (f.value = null);
|
|
748
|
+
O(
|
|
749
|
+
() => e.getEngine().plugins.connections.deleteEdge(u.edge.id)
|
|
750
|
+
);
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
function s(a) {
|
|
754
|
+
const u = e.getEntry(a.edgeId);
|
|
755
|
+
if (!u || !a.candidateNodeId) return;
|
|
756
|
+
const f = a.candidateNodeId, i = e.getEngine().plugins.connections;
|
|
757
|
+
if (a.end === "from") {
|
|
758
|
+
if (u.edge.from === f && me(u.edge.fromAnchor, a.candidateAnchor))
|
|
759
|
+
return;
|
|
760
|
+
O(
|
|
761
|
+
() => i.updateEdge(u.edge.id, {
|
|
762
|
+
from: f,
|
|
763
|
+
fromAnchor: a.candidateAnchor ?? void 0
|
|
764
|
+
})
|
|
765
|
+
);
|
|
766
|
+
return;
|
|
767
|
+
}
|
|
768
|
+
u.edge.to === f && me(u.edge.toAnchor, a.candidateAnchor) || O(
|
|
769
|
+
() => i.updateEdge(u.edge.id, {
|
|
770
|
+
to: f,
|
|
771
|
+
toAnchor: a.candidateAnchor ?? void 0
|
|
772
|
+
})
|
|
773
|
+
);
|
|
774
|
+
}
|
|
775
|
+
function I(a) {
|
|
776
|
+
const u = e.getEngine(), f = u.findNode(a.sourceNodeId);
|
|
777
|
+
if (!f) return;
|
|
778
|
+
const i = a.candidateNodeId ? u.findNode(a.candidateNodeId) : e.createNodeForConnection()?.({
|
|
779
|
+
sourceNodeId: a.sourceNodeId,
|
|
780
|
+
sourceSide: a.sourceSide,
|
|
781
|
+
pointerWorld: { ...a.pointerWorld },
|
|
782
|
+
candidateAnchor: a.candidateAnchor ? { ...a.candidateAnchor } : null
|
|
783
|
+
});
|
|
784
|
+
if (!i) return;
|
|
785
|
+
const L = O(
|
|
786
|
+
() => u.plugins.connections.createEdge({
|
|
787
|
+
from: f.id,
|
|
788
|
+
to: i.id,
|
|
789
|
+
fromAnchor: e.getEndpointMode() === "manual" ? { side: a.sourceSide, offset: 0.5 } : void 0,
|
|
790
|
+
toAnchor: e.getEndpointMode() === "manual" && a.candidateAnchor ? a.candidateAnchor : void 0,
|
|
791
|
+
data: {}
|
|
792
|
+
})
|
|
793
|
+
);
|
|
794
|
+
L && (n.selectedEdgeId.value = String(L.id), n.hoveredEdgeId.value = String(L.id));
|
|
795
|
+
}
|
|
796
|
+
function c(a) {
|
|
797
|
+
a.mode === "reconnect" ? s(a) : I(a);
|
|
798
|
+
}
|
|
799
|
+
return {
|
|
800
|
+
onEdgePointerDown: r,
|
|
801
|
+
beginLabelEdit: v,
|
|
802
|
+
commitLabelEdit: A,
|
|
803
|
+
clearLabel: N,
|
|
804
|
+
cancelLabelEdit: x,
|
|
805
|
+
setDirectionality: C,
|
|
806
|
+
applyEdgeColor: w,
|
|
807
|
+
resetEndpointAnchor: S,
|
|
808
|
+
deleteEdge: y,
|
|
809
|
+
commitDrag: c
|
|
810
|
+
};
|
|
811
|
+
}
|
|
812
|
+
const It = xe({
|
|
813
|
+
name: "BoardConnectionLayer",
|
|
814
|
+
props: {
|
|
815
|
+
routing: {
|
|
816
|
+
type: String,
|
|
817
|
+
default: void 0
|
|
818
|
+
},
|
|
819
|
+
endpointMode: {
|
|
820
|
+
type: String,
|
|
821
|
+
default: void 0
|
|
822
|
+
},
|
|
823
|
+
createNodeForConnection: {
|
|
824
|
+
type: Function,
|
|
825
|
+
default: null
|
|
826
|
+
}
|
|
827
|
+
},
|
|
828
|
+
setup(e, { slots: n }) {
|
|
829
|
+
const r = Fe(), v = z(
|
|
830
|
+
() => r.engine
|
|
831
|
+
), A = H(0), N = `board-connection-arrow-${He().replace(/[^A-Za-z0-9_-]/g, "-")}`, x = /* @__PURE__ */ new Map(), C = /* @__PURE__ */ new Map(), w = H(null), S = H(null), y = H(null), s = H(null), I = H(null), c = H(null), a = H(null), u = H(""), f = H(null), i = H(null), L = typeof window < "u" && window.matchMedia?.("(pointer: coarse)").matches;
|
|
832
|
+
let P = !1;
|
|
833
|
+
function R() {
|
|
834
|
+
P || (P = !0, queueMicrotask(() => {
|
|
835
|
+
A.value += 1, P = !1;
|
|
836
|
+
}));
|
|
837
|
+
}
|
|
838
|
+
F(
|
|
839
|
+
v,
|
|
840
|
+
(t, d, o) => {
|
|
841
|
+
const l = [
|
|
842
|
+
t.on("edge:created", R),
|
|
843
|
+
t.on("edge:updated", R),
|
|
844
|
+
t.on("edge:deleted", R),
|
|
845
|
+
t.$nodes.subscribe(() => R())
|
|
846
|
+
];
|
|
847
|
+
o(() => {
|
|
848
|
+
for (const p of l)
|
|
849
|
+
p();
|
|
850
|
+
});
|
|
851
|
+
},
|
|
852
|
+
{ immediate: !0 }
|
|
853
|
+
), F(
|
|
854
|
+
() => r.rootElement.value,
|
|
855
|
+
(t, d, o) => {
|
|
856
|
+
if (!t)
|
|
857
|
+
return;
|
|
858
|
+
const l = (E) => {
|
|
859
|
+
if (c.value || I.value)
|
|
860
|
+
return;
|
|
861
|
+
const h = E.target;
|
|
862
|
+
h instanceof Element && h.closest('[data-board-interactive="true"]') || (s.value = null, w.value = null, y.value = null, f.value = null, i.value = null, re());
|
|
863
|
+
}, p = (E) => {
|
|
864
|
+
if (c.value || I.value)
|
|
865
|
+
return;
|
|
866
|
+
const h = Ie(E.target), D = v.value, _ = q(
|
|
867
|
+
r,
|
|
868
|
+
D,
|
|
869
|
+
E.clientX,
|
|
870
|
+
E.clientY
|
|
871
|
+
), $ = D.getNodeAt(_), k = ct(E.target) ?? be(
|
|
872
|
+
r.$nodes.value.values(),
|
|
873
|
+
_,
|
|
874
|
+
ce.value,
|
|
875
|
+
ue.value
|
|
876
|
+
);
|
|
877
|
+
w.value = h ?? (s.value ? s.value : null), y.value = h ? null : k, S.value = $?.id ?? null;
|
|
878
|
+
}, b = () => {
|
|
879
|
+
!c.value && !I.value && !s.value && (w.value = null, y.value = null), S.value = null;
|
|
880
|
+
};
|
|
881
|
+
t.addEventListener("pointerdown", l), t.addEventListener("pointermove", p), t.addEventListener("pointerleave", b), o(() => {
|
|
882
|
+
t.removeEventListener("pointerdown", l), t.removeEventListener("pointermove", p), t.removeEventListener("pointerleave", b);
|
|
883
|
+
});
|
|
884
|
+
},
|
|
885
|
+
{ immediate: !0 }
|
|
886
|
+
);
|
|
887
|
+
const V = z(() => {
|
|
888
|
+
A.value;
|
|
889
|
+
const t = r.$nodes.value, d = v.value, o = e.routing ?? d.plugins.connections.getConfig().routing, l = r.viewportSize.value, p = r.$camera.value, b = l.x > 0 && l.y > 0 ? d.getVisibleBounds(l.x, l.y) : null, E = 400 / Math.max(p.z, 0.1), h = b ? {
|
|
890
|
+
minX: b.minX - E,
|
|
891
|
+
minY: b.minY - E,
|
|
892
|
+
maxX: b.maxX + E,
|
|
893
|
+
maxY: b.maxY + E
|
|
894
|
+
} : null, D = /* @__PURE__ */ new Map(), _ = d.plugins.connections.getEdges(), $ = _.map((m) => {
|
|
895
|
+
const M = t.get(m.from), T = t.get(m.to);
|
|
896
|
+
if (!M || !T)
|
|
897
|
+
return null;
|
|
898
|
+
const W = String(m.id), ge = JSON.stringify([
|
|
899
|
+
m.from,
|
|
900
|
+
m.to,
|
|
901
|
+
m.fromAnchor,
|
|
902
|
+
m.toAnchor,
|
|
903
|
+
m.fromEnd,
|
|
904
|
+
m.toEnd
|
|
905
|
+
]), G = C.get(W), fe = x.get(W), B = G?.key === ge && G.routing === o && G.sourceNode === M && G.targetNode === T ? G.geometry : Ye(m, M, T, {
|
|
906
|
+
routing: o,
|
|
907
|
+
previousSourceSide: fe?.source,
|
|
908
|
+
previousTargetSide: fe?.target
|
|
909
|
+
});
|
|
910
|
+
return C.set(W, {
|
|
911
|
+
key: ge,
|
|
912
|
+
routing: o,
|
|
913
|
+
sourceNode: M,
|
|
914
|
+
targetNode: T,
|
|
915
|
+
geometry: B
|
|
916
|
+
}), D.set(W, {
|
|
917
|
+
source: B.source.side,
|
|
918
|
+
target: B.target.side
|
|
919
|
+
}), h && s.value !== W && !Ge(h, B.route.bounds) ? null : {
|
|
920
|
+
edge: m,
|
|
921
|
+
source: B.source,
|
|
922
|
+
target: B.target,
|
|
923
|
+
route: B.route
|
|
924
|
+
};
|
|
925
|
+
}).filter((m) => !!m);
|
|
926
|
+
x.clear();
|
|
927
|
+
for (const [m, M] of D)
|
|
928
|
+
x.set(m, M);
|
|
929
|
+
const k = new Set(_.map((m) => String(m.id)));
|
|
930
|
+
for (const m of C.keys())
|
|
931
|
+
k.has(m) || C.delete(m);
|
|
932
|
+
return $;
|
|
933
|
+
}), X = z(
|
|
934
|
+
() => new Map(
|
|
935
|
+
V.value.map((t) => [String(t.edge.id), t])
|
|
936
|
+
)
|
|
937
|
+
), J = z(
|
|
938
|
+
() => e.endpointMode ?? v.value.plugins.connections.getConfig().endpointMode
|
|
939
|
+
), {
|
|
940
|
+
onEdgePointerDown: oe,
|
|
941
|
+
beginLabelEdit: Q,
|
|
942
|
+
commitLabelEdit: re,
|
|
943
|
+
clearLabel: ye,
|
|
944
|
+
cancelLabelEdit: we,
|
|
945
|
+
setDirectionality: Me,
|
|
946
|
+
applyEdgeColor: ke,
|
|
947
|
+
resetEndpointAnchor: Se,
|
|
948
|
+
deleteEdge: ae,
|
|
949
|
+
commitDrag: Ae
|
|
950
|
+
} = ht({
|
|
951
|
+
getEngine: () => v.value,
|
|
952
|
+
getEntry: (t) => X.value.get(t),
|
|
953
|
+
getRootElement: () => r.rootElement.value,
|
|
954
|
+
getEndpointMode: () => J.value,
|
|
955
|
+
createNodeForConnection: () => e.createNodeForConnection,
|
|
956
|
+
state: {
|
|
957
|
+
hoveredEdgeId: w,
|
|
958
|
+
hoveredNodeHandle: y,
|
|
959
|
+
selectedEdgeId: s,
|
|
960
|
+
editingEdgeId: a,
|
|
961
|
+
labelDraft: u,
|
|
962
|
+
colorMenuEdgeId: f,
|
|
963
|
+
directionMenuEdgeId: i
|
|
964
|
+
}
|
|
965
|
+
});
|
|
966
|
+
F(V, (t) => {
|
|
967
|
+
const d = new Set(t.map((o) => String(o.edge.id)));
|
|
968
|
+
s.value && !d.has(s.value) && (s.value = null), w.value && !d.has(w.value) && (w.value = null), I.value?.mode === "reconnect" && !d.has(I.value.edgeId) && (I.value = null), c.value?.mode === "reconnect" && !d.has(c.value.edgeId) && (c.value = null);
|
|
969
|
+
});
|
|
970
|
+
const de = z(() => {
|
|
971
|
+
const t = c.value;
|
|
972
|
+
if (!t)
|
|
973
|
+
return null;
|
|
974
|
+
const d = r.$nodes.value, o = t.candidateNodeId ? d.get(t.candidateNodeId) : void 0, l = e.routing ?? v.value.plugins.connections.getConfig().routing;
|
|
975
|
+
if (t.mode === "reconnect") {
|
|
976
|
+
const k = X.value.get(t.edgeId);
|
|
977
|
+
if (!k)
|
|
978
|
+
return null;
|
|
979
|
+
if (t.end === "from") {
|
|
980
|
+
const T = k.target, W = o ? Y(
|
|
981
|
+
{
|
|
982
|
+
...k.edge,
|
|
983
|
+
from: o.id,
|
|
984
|
+
fromAnchor: t.candidateAnchor ?? void 0
|
|
985
|
+
},
|
|
986
|
+
o,
|
|
987
|
+
T.node,
|
|
988
|
+
"source",
|
|
989
|
+
t.candidateAnchor?.side ?? k.source.side
|
|
990
|
+
) : te(
|
|
991
|
+
t.pointerWorld,
|
|
992
|
+
T.point,
|
|
993
|
+
"source",
|
|
994
|
+
k.source.side
|
|
995
|
+
);
|
|
996
|
+
return {
|
|
997
|
+
edge: k.edge,
|
|
998
|
+
source: W,
|
|
999
|
+
target: T,
|
|
1000
|
+
route: ne({ source: W, target: T, routing: l }),
|
|
1001
|
+
candidateNode: o
|
|
1002
|
+
};
|
|
1003
|
+
}
|
|
1004
|
+
const m = k.source, M = o ? Y(
|
|
1005
|
+
{
|
|
1006
|
+
...k.edge,
|
|
1007
|
+
to: o.id,
|
|
1008
|
+
toAnchor: t.candidateAnchor ?? void 0
|
|
1009
|
+
},
|
|
1010
|
+
o,
|
|
1011
|
+
m.node,
|
|
1012
|
+
"target",
|
|
1013
|
+
t.candidateAnchor?.side ?? k.target.side
|
|
1014
|
+
) : te(
|
|
1015
|
+
t.pointerWorld,
|
|
1016
|
+
m.point,
|
|
1017
|
+
"target",
|
|
1018
|
+
k.target.side
|
|
1019
|
+
);
|
|
1020
|
+
return {
|
|
1021
|
+
edge: k.edge,
|
|
1022
|
+
source: m,
|
|
1023
|
+
target: M,
|
|
1024
|
+
route: ne({ source: m, target: M, routing: l }),
|
|
1025
|
+
candidateNode: o
|
|
1026
|
+
};
|
|
1027
|
+
}
|
|
1028
|
+
const p = d.get(t.sourceNodeId);
|
|
1029
|
+
if (!p)
|
|
1030
|
+
return null;
|
|
1031
|
+
const b = J.value === "manual" ? { side: t.sourceSide, offset: 0.5 } : void 0, E = J.value === "manual" && t.candidateAnchor ? t.candidateAnchor : void 0, h = {
|
|
1032
|
+
from: p.id,
|
|
1033
|
+
to: o?.id ?? "floating-target",
|
|
1034
|
+
fromAnchor: b,
|
|
1035
|
+
toAnchor: E
|
|
1036
|
+
}, D = o ?? it(t.pointerWorld, "target"), _ = Y(
|
|
1037
|
+
h,
|
|
1038
|
+
p,
|
|
1039
|
+
D,
|
|
1040
|
+
"source",
|
|
1041
|
+
t.sourceSide
|
|
1042
|
+
), $ = o ? Y(
|
|
1043
|
+
h,
|
|
1044
|
+
o,
|
|
1045
|
+
p,
|
|
1046
|
+
"target"
|
|
1047
|
+
) : te(t.pointerWorld, _.point, "target");
|
|
1048
|
+
return {
|
|
1049
|
+
edge: null,
|
|
1050
|
+
source: _,
|
|
1051
|
+
target: $,
|
|
1052
|
+
route: ne({ source: _, target: $, routing: l }),
|
|
1053
|
+
candidateNode: o
|
|
1054
|
+
};
|
|
1055
|
+
}), Z = z(
|
|
1056
|
+
() => 5 / Math.max(r.$camera.value.z, 0.25)
|
|
1057
|
+
), ie = z(
|
|
1058
|
+
() => Math.max(
|
|
1059
|
+
10,
|
|
1060
|
+
(L ? 22 : 12) / Math.max(r.$camera.value.z, 0.25)
|
|
1061
|
+
)
|
|
1062
|
+
), le = z(() => 1.85), Ne = z(
|
|
1063
|
+
() => Math.max(16, 20 / Math.max(r.$camera.value.z, 0.25))
|
|
1064
|
+
), De = z(
|
|
1065
|
+
() => 2.5 / Math.max(r.$camera.value.z, 0.25)
|
|
1066
|
+
), ce = z(
|
|
1067
|
+
() => Math.max(18, 22 / Math.max(r.$camera.value.z, 0.25))
|
|
1068
|
+
), ue = z(
|
|
1069
|
+
() => 18 / Math.max(r.$camera.value.z, 0.25)
|
|
1070
|
+
);
|
|
1071
|
+
function Ce(t, d, o) {
|
|
1072
|
+
o.preventDefault(), o.stopPropagation(), o.currentTarget?.setPointerCapture?.(
|
|
1073
|
+
o.pointerId
|
|
1074
|
+
);
|
|
1075
|
+
const l = v.value, p = q(
|
|
1076
|
+
r,
|
|
1077
|
+
l,
|
|
1078
|
+
o.clientX,
|
|
1079
|
+
o.clientY
|
|
1080
|
+
);
|
|
1081
|
+
s.value = String(t.edge.id), w.value = String(t.edge.id), y.value = null, I.value = {
|
|
1082
|
+
mode: "reconnect",
|
|
1083
|
+
edgeId: String(t.edge.id),
|
|
1084
|
+
end: d,
|
|
1085
|
+
pointerId: o.pointerId,
|
|
1086
|
+
startWorld: p
|
|
1087
|
+
};
|
|
1088
|
+
}
|
|
1089
|
+
function Le(t, d, o) {
|
|
1090
|
+
o.preventDefault(), o.stopPropagation(), o.currentTarget?.setPointerCapture?.(
|
|
1091
|
+
o.pointerId
|
|
1092
|
+
);
|
|
1093
|
+
const l = v.value, p = q(
|
|
1094
|
+
r,
|
|
1095
|
+
l,
|
|
1096
|
+
o.clientX,
|
|
1097
|
+
o.clientY
|
|
1098
|
+
);
|
|
1099
|
+
w.value = null, s.value = null, y.value = { nodeId: t, side: d, offset: 0.5 }, I.value = {
|
|
1100
|
+
mode: "create",
|
|
1101
|
+
sourceNodeId: t,
|
|
1102
|
+
sourceSide: d,
|
|
1103
|
+
pointerId: o.pointerId,
|
|
1104
|
+
startWorld: p
|
|
1105
|
+
};
|
|
1106
|
+
}
|
|
1107
|
+
F(s, (t, d, o) => {
|
|
1108
|
+
if (!s.value)
|
|
1109
|
+
return;
|
|
1110
|
+
const l = (p) => {
|
|
1111
|
+
const b = s.value;
|
|
1112
|
+
if (!b || a.value)
|
|
1113
|
+
return;
|
|
1114
|
+
const E = p.target;
|
|
1115
|
+
if (E instanceof HTMLElement) {
|
|
1116
|
+
const h = E.tagName;
|
|
1117
|
+
if (h === "INPUT" || h === "TEXTAREA" || E.isContentEditable)
|
|
1118
|
+
return;
|
|
1119
|
+
}
|
|
1120
|
+
p.key === "Delete" || p.key === "Backspace" ? (p.preventDefault(), ae(b)) : p.key === "Escape" && (f.value = null, i.value = null);
|
|
1121
|
+
};
|
|
1122
|
+
window.addEventListener("keydown", l), o(() => {
|
|
1123
|
+
window.removeEventListener("keydown", l);
|
|
1124
|
+
});
|
|
1125
|
+
}), F([I, c], ([t, d], o, l) => {
|
|
1126
|
+
if (!t && !d)
|
|
1127
|
+
return;
|
|
1128
|
+
const p = (h) => {
|
|
1129
|
+
const D = I.value, _ = c.value, $ = _?.pointerId ?? D?.pointerId;
|
|
1130
|
+
if ($ === void 0 || h.pointerId !== $)
|
|
1131
|
+
return;
|
|
1132
|
+
const k = v.value, m = q(
|
|
1133
|
+
r,
|
|
1134
|
+
k,
|
|
1135
|
+
h.clientX,
|
|
1136
|
+
h.clientY
|
|
1137
|
+
), M = be(
|
|
1138
|
+
r.$nodes.value.values(),
|
|
1139
|
+
m,
|
|
1140
|
+
ce.value,
|
|
1141
|
+
ue.value
|
|
1142
|
+
), T = M ? k.findNode(M.nodeId) : k.getNodeAt(m), W = st({
|
|
1143
|
+
pending: D,
|
|
1144
|
+
active: _,
|
|
1145
|
+
pointerId: h.pointerId,
|
|
1146
|
+
pointerWorld: m,
|
|
1147
|
+
candidateNodeId: T?.id ?? null,
|
|
1148
|
+
candidateAnchor: M ? { side: M.side, offset: M.offset } : null,
|
|
1149
|
+
zoom: r.$camera.value.z,
|
|
1150
|
+
threshold: Ue
|
|
1151
|
+
});
|
|
1152
|
+
I.value = W.pending, c.value = W.active;
|
|
1153
|
+
}, b = (h) => {
|
|
1154
|
+
if (I.value && h.pointerId === I.value.pointerId) {
|
|
1155
|
+
I.value = null;
|
|
1156
|
+
return;
|
|
1157
|
+
}
|
|
1158
|
+
!c.value || h.pointerId !== c.value.pointerId || (Ae(c.value), c.value = null);
|
|
1159
|
+
}, E = (h) => {
|
|
1160
|
+
I.value && h.pointerId === I.value.pointerId && (I.value = null), c.value && h.pointerId === c.value.pointerId && (c.value = null);
|
|
1161
|
+
};
|
|
1162
|
+
window.addEventListener("pointermove", p), window.addEventListener("pointerup", b), window.addEventListener("pointercancel", E), l(() => {
|
|
1163
|
+
window.removeEventListener("pointermove", p), window.removeEventListener("pointerup", b), window.removeEventListener("pointercancel", E);
|
|
1164
|
+
});
|
|
1165
|
+
});
|
|
1166
|
+
function se(t, d, o) {
|
|
1167
|
+
return g(
|
|
1168
|
+
"g",
|
|
1169
|
+
{
|
|
1170
|
+
"data-board-interactive": "true",
|
|
1171
|
+
"data-connection-interactive": "true",
|
|
1172
|
+
"data-connection-edge-id": String(t.edge.id),
|
|
1173
|
+
"data-connection-handle": d,
|
|
1174
|
+
style: {
|
|
1175
|
+
pointerEvents: "all",
|
|
1176
|
+
cursor: "grab"
|
|
1177
|
+
},
|
|
1178
|
+
onPointerdown: (l) => Ce(t, d, l)
|
|
1179
|
+
},
|
|
1180
|
+
[
|
|
1181
|
+
g("circle", {
|
|
1182
|
+
cx: o.point.x,
|
|
1183
|
+
cy: o.point.y,
|
|
1184
|
+
r: ie.value,
|
|
1185
|
+
fill: "rgba(15, 23, 42, 0.001)",
|
|
1186
|
+
stroke: "none"
|
|
1187
|
+
}),
|
|
1188
|
+
g("circle", {
|
|
1189
|
+
cx: o.point.x,
|
|
1190
|
+
cy: o.point.y,
|
|
1191
|
+
r: Z.value,
|
|
1192
|
+
fill: "#ffffff",
|
|
1193
|
+
stroke: t.edge.color ?? "var(--board-edge-active-color)",
|
|
1194
|
+
"stroke-width": 1.5 / Math.max(r.$camera.value.z, 0.25),
|
|
1195
|
+
"vector-effect": "non-scaling-stroke"
|
|
1196
|
+
})
|
|
1197
|
+
]
|
|
1198
|
+
);
|
|
1199
|
+
}
|
|
1200
|
+
function ee(t, d) {
|
|
1201
|
+
const o = r.$nodes.value.get(t);
|
|
1202
|
+
if (!o)
|
|
1203
|
+
return null;
|
|
1204
|
+
const l = U(o, { side: d, offset: 0.5 });
|
|
1205
|
+
return g(
|
|
1206
|
+
"g",
|
|
1207
|
+
{
|
|
1208
|
+
"data-board-interactive": "true",
|
|
1209
|
+
"data-connection-interactive": "true",
|
|
1210
|
+
"data-connection-create-handle": "true",
|
|
1211
|
+
"data-connection-node-id": String(t),
|
|
1212
|
+
"data-connection-side": d,
|
|
1213
|
+
"data-connection-offset": "0.5",
|
|
1214
|
+
style: {
|
|
1215
|
+
pointerEvents: "all",
|
|
1216
|
+
cursor: "crosshair"
|
|
1217
|
+
},
|
|
1218
|
+
onPointerdown: (p) => Le(t, d, p)
|
|
1219
|
+
},
|
|
1220
|
+
[
|
|
1221
|
+
g("circle", {
|
|
1222
|
+
cx: l.x,
|
|
1223
|
+
cy: l.y,
|
|
1224
|
+
r: ie.value,
|
|
1225
|
+
fill: "rgba(15, 23, 42, 0.001)",
|
|
1226
|
+
stroke: "none"
|
|
1227
|
+
}),
|
|
1228
|
+
g("circle", {
|
|
1229
|
+
cx: l.x,
|
|
1230
|
+
cy: l.y,
|
|
1231
|
+
r: Z.value * 0.9,
|
|
1232
|
+
fill: "var(--board-edge-active-color)",
|
|
1233
|
+
stroke: "#ffffff",
|
|
1234
|
+
"stroke-width": 1.25 / Math.max(r.$camera.value.z, 0.25),
|
|
1235
|
+
"vector-effect": "non-scaling-stroke"
|
|
1236
|
+
})
|
|
1237
|
+
]
|
|
1238
|
+
);
|
|
1239
|
+
}
|
|
1240
|
+
function j(t, d, o = {}) {
|
|
1241
|
+
const l = r.$nodes.value.get(t);
|
|
1242
|
+
if (!l)
|
|
1243
|
+
return null;
|
|
1244
|
+
const p = U(l, { side: d.side, offset: 0 }), b = U(l, { side: d.side, offset: 1 }), E = U(l, d), h = (o.active ? 2.4 : 1.6) / Math.max(r.$camera.value.z, 0.25);
|
|
1245
|
+
return g(
|
|
1246
|
+
"g",
|
|
1247
|
+
{
|
|
1248
|
+
"data-connection-anchor-rail": String(t),
|
|
1249
|
+
"data-connection-side": d.side,
|
|
1250
|
+
style: {
|
|
1251
|
+
pointerEvents: "none"
|
|
1252
|
+
}
|
|
1253
|
+
},
|
|
1254
|
+
[
|
|
1255
|
+
g("line", {
|
|
1256
|
+
x1: p.x,
|
|
1257
|
+
y1: p.y,
|
|
1258
|
+
x2: b.x,
|
|
1259
|
+
y2: b.y,
|
|
1260
|
+
stroke: "var(--board-edge-active-color)",
|
|
1261
|
+
"stroke-width": h,
|
|
1262
|
+
"stroke-linecap": "round",
|
|
1263
|
+
"vector-effect": "non-scaling-stroke",
|
|
1264
|
+
opacity: o.active ? 0.72 : 0.36
|
|
1265
|
+
}),
|
|
1266
|
+
g("circle", {
|
|
1267
|
+
cx: E.x,
|
|
1268
|
+
cy: E.y,
|
|
1269
|
+
r: Z.value * (o.active ? 1.12 : 0.92),
|
|
1270
|
+
fill: o.createHandle ? "var(--board-edge-active-color)" : "#ffffff",
|
|
1271
|
+
stroke: "var(--board-edge-active-color)",
|
|
1272
|
+
"stroke-width": 1.4 / Math.max(r.$camera.value.z, 0.25),
|
|
1273
|
+
"vector-effect": "non-scaling-stroke",
|
|
1274
|
+
opacity: o.active ? 1 : 0.9
|
|
1275
|
+
})
|
|
1276
|
+
]
|
|
1277
|
+
);
|
|
1278
|
+
}
|
|
1279
|
+
function Re() {
|
|
1280
|
+
const t = c.value?.mode === "create" ? c.value : null, d = c.value?.mode === "reconnect" ? c.value : null, o = t ? ee(t.sourceNodeId, t.sourceSide) : null, l = y.value && (!t || y.value.nodeId !== t.sourceNodeId || y.value.side !== t.sourceSide) ? ee(
|
|
1281
|
+
y.value.nodeId,
|
|
1282
|
+
y.value.side
|
|
1283
|
+
) : null, p = S.value && (!t || S.value !== t.sourceNodeId) ? ["top", "right", "bottom", "left"].filter(
|
|
1284
|
+
(D) => !y.value || y.value.nodeId !== S.value || y.value.side !== D
|
|
1285
|
+
).map(
|
|
1286
|
+
(D) => ee(S.value, D)
|
|
1287
|
+
) : [], b = s.value && !d ? X.value.get(s.value) : void 0, E = b ? [
|
|
1288
|
+
b.edge.fromAnchor ? j(
|
|
1289
|
+
b.edge.from,
|
|
1290
|
+
b.edge.fromAnchor
|
|
1291
|
+
) : null,
|
|
1292
|
+
b.edge.toAnchor ? j(
|
|
1293
|
+
b.edge.to,
|
|
1294
|
+
b.edge.toAnchor
|
|
1295
|
+
) : null
|
|
1296
|
+
] : [], h = d?.candidateNodeId && d.candidateAnchor ? j(
|
|
1297
|
+
d.candidateNodeId,
|
|
1298
|
+
d.candidateAnchor,
|
|
1299
|
+
{ active: !0 }
|
|
1300
|
+
) : t?.candidateNodeId && t.candidateAnchor ? j(
|
|
1301
|
+
t.candidateNodeId,
|
|
1302
|
+
t.candidateAnchor,
|
|
1303
|
+
{ active: !0, createHandle: !0 }
|
|
1304
|
+
) : null;
|
|
1305
|
+
return [
|
|
1306
|
+
...E,
|
|
1307
|
+
...h ? [h] : [],
|
|
1308
|
+
...o ? [o] : [],
|
|
1309
|
+
...l ? [l] : [],
|
|
1310
|
+
...p
|
|
1311
|
+
];
|
|
1312
|
+
}
|
|
1313
|
+
function _e(t, d) {
|
|
1314
|
+
const o = String(t.edge.id);
|
|
1315
|
+
return g(vt, {
|
|
1316
|
+
edgeId: o,
|
|
1317
|
+
point: t.route.labelPoint,
|
|
1318
|
+
label: t.edge.label ?? "",
|
|
1319
|
+
color: t.edge.color ?? "var(--board-edge-color)",
|
|
1320
|
+
zoom: r.$camera.value.z,
|
|
1321
|
+
selected: d.isSelected,
|
|
1322
|
+
hovered: d.isHovered,
|
|
1323
|
+
editing: a.value === o,
|
|
1324
|
+
draft: u.value,
|
|
1325
|
+
onEdgePointerDown: oe,
|
|
1326
|
+
onBeginEdit: Q,
|
|
1327
|
+
onUpdateDraft: (l) => {
|
|
1328
|
+
u.value = l;
|
|
1329
|
+
},
|
|
1330
|
+
onCommitEdit: re,
|
|
1331
|
+
onCancelEdit: we
|
|
1332
|
+
});
|
|
1333
|
+
}
|
|
1334
|
+
function Pe(t) {
|
|
1335
|
+
const d = String(t.edge.id), o = s.value === d, l = w.value === d, p = c.value?.mode === "reconnect" && c.value.edgeId === d, b = o || l || p, E = Math.max(r.$camera.value.z, 0.25), h = at(
|
|
1336
|
+
E,
|
|
1337
|
+
qe,
|
|
1338
|
+
Ke
|
|
1339
|
+
), D = t.edge.color ?? "var(--board-edge-color)", _ = p ? 0.22 : o ? 0.98 : l ? 0.92 : 0.24 + h * 0.46, $ = o ? le.value + 0.4 : l ? le.value + 0.2 : 1.15 + h * 0.7, k = n.edge ? n.edge(t) : gt({
|
|
1340
|
+
entry: t,
|
|
1341
|
+
markerId: N,
|
|
1342
|
+
stroke: D,
|
|
1343
|
+
opacity: _,
|
|
1344
|
+
strokeWidth: $
|
|
1345
|
+
}), m = _e(t, { isSelected: o, isHovered: l });
|
|
1346
|
+
return g(
|
|
1347
|
+
"g",
|
|
1348
|
+
{
|
|
1349
|
+
"data-connection-edge-id": d
|
|
1350
|
+
},
|
|
1351
|
+
[
|
|
1352
|
+
k,
|
|
1353
|
+
g("path", {
|
|
1354
|
+
d: t.route.path,
|
|
1355
|
+
stroke: "rgba(15, 23, 42, 0.001)",
|
|
1356
|
+
fill: "none",
|
|
1357
|
+
"stroke-width": Ne.value,
|
|
1358
|
+
"stroke-linecap": "round",
|
|
1359
|
+
"stroke-linejoin": "round",
|
|
1360
|
+
"vector-effect": "non-scaling-stroke",
|
|
1361
|
+
"data-board-interactive": "true",
|
|
1362
|
+
"data-connection-interactive": "true",
|
|
1363
|
+
"data-connection-edge-id": d,
|
|
1364
|
+
"data-connection-hit": "true",
|
|
1365
|
+
style: {
|
|
1366
|
+
pointerEvents: "stroke",
|
|
1367
|
+
cursor: "pointer"
|
|
1368
|
+
},
|
|
1369
|
+
onPointerdown: (M) => oe(d, M),
|
|
1370
|
+
onDblclick: (M) => {
|
|
1371
|
+
M.preventDefault(), M.stopPropagation(), Q(d);
|
|
1372
|
+
},
|
|
1373
|
+
onPointerleave: (M) => {
|
|
1374
|
+
!ut(M.relatedTarget, d) && s.value !== d && !(c.value?.mode === "reconnect" && c.value.edgeId === d) && (w.value = null);
|
|
1375
|
+
}
|
|
1376
|
+
}),
|
|
1377
|
+
...b ? [
|
|
1378
|
+
se(t, "from", t.source),
|
|
1379
|
+
se(t, "to", t.target)
|
|
1380
|
+
] : [],
|
|
1381
|
+
...m ? [m] : []
|
|
1382
|
+
]
|
|
1383
|
+
);
|
|
1384
|
+
}
|
|
1385
|
+
function ze() {
|
|
1386
|
+
return !de.value || !c.value ? [] : ft({
|
|
1387
|
+
preview: de.value,
|
|
1388
|
+
drag: c.value,
|
|
1389
|
+
markerId: N,
|
|
1390
|
+
zoom: Math.max(r.$camera.value.z, 0.25),
|
|
1391
|
+
handleRadius: Z.value,
|
|
1392
|
+
strokeWidth: De.value
|
|
1393
|
+
});
|
|
1394
|
+
}
|
|
1395
|
+
function $e() {
|
|
1396
|
+
const t = s.value;
|
|
1397
|
+
if (!t) return null;
|
|
1398
|
+
const d = X.value.get(t);
|
|
1399
|
+
if (!d || c.value?.mode === "reconnect" && c.value.edgeId === t || a.value === t)
|
|
1400
|
+
return null;
|
|
1401
|
+
const o = r.$camera.value;
|
|
1402
|
+
return pt({
|
|
1403
|
+
edge: d.edge,
|
|
1404
|
+
screen: {
|
|
1405
|
+
x: (d.route.labelPoint.x + o.x) * o.z,
|
|
1406
|
+
y: (d.route.labelPoint.y + o.y) * o.z
|
|
1407
|
+
},
|
|
1408
|
+
colorMenuOpen: f.value === t,
|
|
1409
|
+
directionMenuOpen: i.value === t,
|
|
1410
|
+
onDelete: () => ae(t),
|
|
1411
|
+
onToggleColorMenu: () => {
|
|
1412
|
+
f.value = f.value === t ? null : t, i.value = null;
|
|
1413
|
+
},
|
|
1414
|
+
onToggleDirectionMenu: () => {
|
|
1415
|
+
i.value = i.value === t ? null : t, f.value = null;
|
|
1416
|
+
},
|
|
1417
|
+
onSetColor: (l) => ke(t, l),
|
|
1418
|
+
onSetDirectionality: (l) => Me(t, l),
|
|
1419
|
+
onResetAnchor: (l) => Se(t, l),
|
|
1420
|
+
onClearLabel: () => ye(t),
|
|
1421
|
+
onBeginLabelEdit: () => Q(t)
|
|
1422
|
+
});
|
|
1423
|
+
}
|
|
1424
|
+
function Te() {
|
|
1425
|
+
const t = Math.max(r.$camera.value.z, 0.25), d = dt(t) / t;
|
|
1426
|
+
return g(
|
|
1427
|
+
"svg",
|
|
1428
|
+
{
|
|
1429
|
+
class: "board-connection-layer",
|
|
1430
|
+
style: {
|
|
1431
|
+
position: "absolute",
|
|
1432
|
+
inset: "0",
|
|
1433
|
+
width: "100%",
|
|
1434
|
+
height: "100%",
|
|
1435
|
+
overflow: "visible",
|
|
1436
|
+
pointerEvents: "none",
|
|
1437
|
+
transform: `scale(${r.$camera.value.z}) translate(${r.$camera.value.x}px, ${r.$camera.value.y}px)`,
|
|
1438
|
+
transformOrigin: "0 0",
|
|
1439
|
+
zIndex: "6",
|
|
1440
|
+
"--board-zoom": String(r.$camera.value.z)
|
|
1441
|
+
}
|
|
1442
|
+
},
|
|
1443
|
+
[
|
|
1444
|
+
g("defs", [
|
|
1445
|
+
g(
|
|
1446
|
+
"marker",
|
|
1447
|
+
{
|
|
1448
|
+
id: N,
|
|
1449
|
+
markerWidth: d,
|
|
1450
|
+
markerHeight: d,
|
|
1451
|
+
refX: 13.8,
|
|
1452
|
+
refY: 9,
|
|
1453
|
+
orient: "auto-start-reverse",
|
|
1454
|
+
markerUnits: "userSpaceOnUse",
|
|
1455
|
+
viewBox: `0 0 ${ve} ${ve}`
|
|
1456
|
+
},
|
|
1457
|
+
[
|
|
1458
|
+
g("path", {
|
|
1459
|
+
d: "M1.8,1.8 L15.6,9 L1.8,16.2 L6.3,9 Z",
|
|
1460
|
+
fill: "currentColor"
|
|
1461
|
+
})
|
|
1462
|
+
]
|
|
1463
|
+
)
|
|
1464
|
+
]),
|
|
1465
|
+
...V.value.map((o) => Pe(o)),
|
|
1466
|
+
...Re().filter(Boolean),
|
|
1467
|
+
...ze().filter(Boolean)
|
|
1468
|
+
]
|
|
1469
|
+
);
|
|
1470
|
+
}
|
|
1471
|
+
return () => {
|
|
1472
|
+
const t = Te(), d = $e(), o = r.rootElement.value;
|
|
1473
|
+
return o ? g(Oe, { to: o }, [t, ...d ? [d] : []]) : [t, ...d ? [d] : []];
|
|
1474
|
+
};
|
|
1475
|
+
}
|
|
1476
|
+
});
|
|
1477
|
+
export {
|
|
1478
|
+
It as BoardConnectionLayer
|
|
1479
|
+
};
|