@lupinum/vue-board 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 +61 -0
- package/dist/components/BoardBoxSelect.d.vue.ts +16 -0
- package/dist/components/BoardGrid.d.vue.ts +3 -0
- package/dist/components/BoardNode.d.vue.ts +35 -0
- package/dist/components/BoardNodeHandle.d.vue.ts +8 -0
- package/dist/components/BoardRoot.d.vue.ts +139 -0
- package/dist/components/BoardSelectionToolbar.d.vue.ts +3 -0
- package/dist/components/BoardSnapGuides.d.vue.ts +3 -0
- package/dist/components/BoardViewport.d.vue.ts +13 -0
- package/dist/composables/runBoardCommand.d.ts +3 -0
- package/dist/composables/useKeyboardShortcuts.d.ts +20 -0
- package/dist/composables/useLodCulling.d.ts +20 -0
- package/dist/composables/usePointerInteraction.d.ts +24 -0
- package/dist/composables/useResolvedGrid.d.ts +14 -0
- package/dist/composables/useViewportSize.d.ts +19 -0
- package/dist/context.d.ts +18 -0
- package/dist/eventTargets.d.ts +4 -0
- package/dist/grid.d.ts +22 -0
- package/dist/index.css +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +1180 -0
- package/dist/minimap.d.ts +82 -0
- package/dist/minimap.js +192 -0
- package/dist/nodeColors.d.ts +10 -0
- package/dist/useBoardEngine-GWeHBmOy.js +128 -0
- package/dist/useBoardEngine.d.ts +52 -0
- package/package.json +56 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1180 @@
|
|
|
1
|
+
import { ref as W, onMounted as be, onBeforeUnmount as me, computed as I, shallowRef as G, defineComponent as q, unref as w, renderSlot as L, openBlock as x, createElementBlock as z, normalizeStyle as Z, normalizeClass as te, createCommentVNode as O, useSlots as Ee, watch as ve, nextTick as Se, withKeys as Ce, withModifiers as U, normalizeProps as ze, guardReactiveProps as Ie, Fragment as F, withDirectives as De, createElementVNode as K, vModelText as Te, createTextVNode as he, toDisplayString as xe, renderList as ge, createVNode as Be, useId as Ne, createStaticVNode as ye, toRef as we, provide as je, shallowReadonly as Y, markRaw as Me, createBlock as re, withCtx as ue, mergeProps as ce, resolveDynamicComponent as Oe } from "vue";
|
|
2
|
+
import { CommandBlockedError as Ae, asNodeId as ee, colorForPreset as Ke, BOARD_COLOR_PRESETS as Le, createBoardEngine as Xe } from "@lupinum/board-core";
|
|
3
|
+
import { BOARD_COLOR_PRESETS as Lt, colorForPreset as Xt } from "@lupinum/board-core";
|
|
4
|
+
import { u as Ve, a as Ye, b as ie, c as Fe, d as Ge, e as He } from "./useBoardEngine-GWeHBmOy.js";
|
|
5
|
+
import { f as Yt, g as Ft, h as Gt, i as Ht, j as Ut } from "./useBoardEngine-GWeHBmOy.js";
|
|
6
|
+
import { getBoardInteractionAdapter as Pe } from "@lupinum/board-core/internal";
|
|
7
|
+
function Ue(o) {
|
|
8
|
+
const e = W({ x: 0, y: 0 });
|
|
9
|
+
let n = null;
|
|
10
|
+
function l() {
|
|
11
|
+
const p = o.rootElement.value?.getBoundingClientRect();
|
|
12
|
+
e.value = {
|
|
13
|
+
x: p?.width ?? 0,
|
|
14
|
+
y: p?.height ?? 0
|
|
15
|
+
}, o.engine.setViewportSize(e.value);
|
|
16
|
+
}
|
|
17
|
+
return be(() => {
|
|
18
|
+
l(), o.rootElement.value && typeof ResizeObserver < "u" ? (n = new ResizeObserver(l), n.observe(o.rootElement.value)) : window.addEventListener("resize", l);
|
|
19
|
+
}), me(() => {
|
|
20
|
+
n ? (n.disconnect(), n = null) : window.removeEventListener("resize", l);
|
|
21
|
+
}), { viewportSize: e, updateViewportSize: l };
|
|
22
|
+
}
|
|
23
|
+
const ae = {
|
|
24
|
+
visible: !0,
|
|
25
|
+
minorOpacity: 0.14,
|
|
26
|
+
majorOpacity: 0.18,
|
|
27
|
+
fadeEdges: !0
|
|
28
|
+
};
|
|
29
|
+
function We(o, e) {
|
|
30
|
+
if (o === !1)
|
|
31
|
+
return {
|
|
32
|
+
...ae,
|
|
33
|
+
visible: !1,
|
|
34
|
+
size: e.size,
|
|
35
|
+
majorEvery: e.majorEvery,
|
|
36
|
+
snap: e.snap,
|
|
37
|
+
edgeSnap: e.edgeSnap,
|
|
38
|
+
edgeSnapThreshold: e.edgeSnapThreshold,
|
|
39
|
+
pattern: e.pattern
|
|
40
|
+
};
|
|
41
|
+
const n = o === !0 ? {} : o;
|
|
42
|
+
return {
|
|
43
|
+
visible: n.visible ?? ae.visible,
|
|
44
|
+
size: e.size,
|
|
45
|
+
majorEvery: e.majorEvery,
|
|
46
|
+
snap: e.snap,
|
|
47
|
+
edgeSnap: e.edgeSnap,
|
|
48
|
+
edgeSnapThreshold: e.edgeSnapThreshold,
|
|
49
|
+
pattern: e.pattern,
|
|
50
|
+
minorOpacity: n.minorOpacity ?? ae.minorOpacity,
|
|
51
|
+
majorOpacity: n.majorOpacity ?? ae.majorOpacity,
|
|
52
|
+
fadeEdges: n.fadeEdges ?? ae.fadeEdges
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function Ze(o) {
|
|
56
|
+
return I(
|
|
57
|
+
() => We(o.gridProp.value, o.grid.value)
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
const qe = 6, Je = 96;
|
|
61
|
+
function Qe(o, e, n) {
|
|
62
|
+
if (n) return "full";
|
|
63
|
+
const l = Math.max(o.width, o.height) * e;
|
|
64
|
+
return l < qe ? "hidden" : l < Je ? "simple" : "full";
|
|
65
|
+
}
|
|
66
|
+
function et(o) {
|
|
67
|
+
return I(() => {
|
|
68
|
+
const n = o.viewportSize.value.x > 0 && o.viewportSize.value.y > 0 ? o.engine.getVisibleBounds(
|
|
69
|
+
o.viewportSize.value.x,
|
|
70
|
+
o.viewportSize.value.y
|
|
71
|
+
) : null, l = o.camera.value.z, p = o.selectionSet.value, a = o.cullMargin.value, i = [];
|
|
72
|
+
for (const u of o.nodes.value.values()) {
|
|
73
|
+
if (!u.visible || n && (u.x + u.width <= n.minX - a || u.x >= n.maxX + a || u.y + u.height <= n.minY - a || u.y >= n.maxY + a))
|
|
74
|
+
continue;
|
|
75
|
+
const y = Qe(u, l, p.has(u.id));
|
|
76
|
+
y !== "hidden" && i.push({ ...u, lod: y });
|
|
77
|
+
}
|
|
78
|
+
return i;
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
function $(o) {
|
|
82
|
+
try {
|
|
83
|
+
return o();
|
|
84
|
+
} catch (e) {
|
|
85
|
+
if (e instanceof Ae) return;
|
|
86
|
+
throw e;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function pe(o) {
|
|
90
|
+
let e = !1;
|
|
91
|
+
const n = $(() => {
|
|
92
|
+
o(), e = !0;
|
|
93
|
+
});
|
|
94
|
+
return e || n !== void 0;
|
|
95
|
+
}
|
|
96
|
+
const tt = '[data-board-root="true"]', ot = [
|
|
97
|
+
'[data-board-interactive="true"]',
|
|
98
|
+
'[data-editor="true"]',
|
|
99
|
+
"input",
|
|
100
|
+
"textarea",
|
|
101
|
+
"select",
|
|
102
|
+
"button",
|
|
103
|
+
"a[href]",
|
|
104
|
+
'[contenteditable]:not([contenteditable="false"])'
|
|
105
|
+
].join(",");
|
|
106
|
+
function _e(o) {
|
|
107
|
+
return o instanceof Element ? o : null;
|
|
108
|
+
}
|
|
109
|
+
function H(o, e) {
|
|
110
|
+
const n = _e(o);
|
|
111
|
+
return !!(n && e && n.closest(tt) === e);
|
|
112
|
+
}
|
|
113
|
+
function fe(o) {
|
|
114
|
+
const e = _e(o);
|
|
115
|
+
return e?.closest("[data-resize]") ? !1 : !!e?.closest(ot);
|
|
116
|
+
}
|
|
117
|
+
function rt(o) {
|
|
118
|
+
const { engine: e, grid: n, rootElement: l, spacePressed: p } = o, a = Pe(e);
|
|
119
|
+
function i() {
|
|
120
|
+
p.value = !1;
|
|
121
|
+
}
|
|
122
|
+
be(() => {
|
|
123
|
+
window.addEventListener("blur", i), document.addEventListener("visibilitychange", i);
|
|
124
|
+
}), me(() => {
|
|
125
|
+
window.removeEventListener("blur", i), document.removeEventListener("visibilitychange", i);
|
|
126
|
+
});
|
|
127
|
+
function u(r) {
|
|
128
|
+
$(() => y(r));
|
|
129
|
+
}
|
|
130
|
+
function y(r) {
|
|
131
|
+
if (!H(r.target, l.value) || fe(r.target)) return;
|
|
132
|
+
r.code === "Space" && (r.preventDefault(), p.value = !0);
|
|
133
|
+
const b = r.metaKey || r.ctrlKey, h = e.getSelection(), C = e.plugins.history;
|
|
134
|
+
if (r.key === "Escape") {
|
|
135
|
+
e.clearSelection(), a.cancelInteraction();
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
if (r.key === "Delete" || r.key === "Backspace") {
|
|
139
|
+
h.length > 0 && (r.preventDefault(), e.deleteSelected());
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
if (r.key === "Enter" && h.length === 1) {
|
|
143
|
+
const P = e.getNode(h[0]);
|
|
144
|
+
P.type === "text" && e.beginTextEdit(P.id);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
if (b && r.key.toLowerCase() === "a") {
|
|
148
|
+
r.preventDefault(), e.selectAll();
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
if (b && r.key.toLowerCase() === "d" && h.length > 0) {
|
|
152
|
+
r.preventDefault(), e.duplicateNodes(h);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
if (b && r.key.toLowerCase() === "c" && h.length > 0) {
|
|
156
|
+
r.preventDefault(), e.copySelected();
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
if (b && r.key.toLowerCase() === "v") {
|
|
160
|
+
r.preventDefault(), e.pasteClipboard();
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
if (b && r.key === "0") {
|
|
164
|
+
r.preventDefault(), e.zoomTo(1, !0);
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
if (b && r.key === "1") {
|
|
168
|
+
r.preventDefault(), e.zoomToFit(40, !0);
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
if (b && r.key.toLowerCase() === "z") {
|
|
172
|
+
r.preventDefault(), r.shiftKey ? C?.redo() : C?.undo();
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
if (b && r.key.toLowerCase() === "y") {
|
|
176
|
+
r.preventDefault(), C?.redo();
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
if (h.length > 0 && r.key.startsWith("Arrow")) {
|
|
180
|
+
r.preventDefault();
|
|
181
|
+
const P = r.shiftKey ? n.value.size * n.value.majorEvery : n.value.size, D = r.key === "ArrowLeft" ? { x: -P, y: 0 } : r.key === "ArrowRight" ? { x: P, y: 0 } : r.key === "ArrowUp" ? { x: 0, y: -P } : { x: 0, y: P };
|
|
182
|
+
e.translateSelectedNodes(D.x, D.y);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
function k(r) {
|
|
186
|
+
H(r.target, l.value) && r.code === "Space" && i();
|
|
187
|
+
}
|
|
188
|
+
return { onKeyDown: u, onKeyUp: k };
|
|
189
|
+
}
|
|
190
|
+
const nt = 6;
|
|
191
|
+
function $e(o) {
|
|
192
|
+
return o instanceof HTMLElement ? o.closest("[data-node-id]")?.dataset.nodeId : void 0;
|
|
193
|
+
}
|
|
194
|
+
function ke(o) {
|
|
195
|
+
return o instanceof HTMLElement ? o.closest("[data-resize]")?.dataset.resize : void 0;
|
|
196
|
+
}
|
|
197
|
+
function at(o) {
|
|
198
|
+
const { engine: e, rootElement: n, spacePressed: l, toLocalPoint: p } = o, a = Pe(e), i = G(null), u = /* @__PURE__ */ new Map();
|
|
199
|
+
let y = !1, k = 0, r = null, b = !1, h = null;
|
|
200
|
+
function C(t) {
|
|
201
|
+
const c = e.screenToWorld(t);
|
|
202
|
+
return e.getNodeAt(c)?.id;
|
|
203
|
+
}
|
|
204
|
+
function P() {
|
|
205
|
+
const t = M(), c = t[0], v = t[1];
|
|
206
|
+
return !c || !v ? 0 : Math.hypot(v.x - c.x, v.y - c.y);
|
|
207
|
+
}
|
|
208
|
+
function D() {
|
|
209
|
+
const t = M(), c = t[0], v = t[1];
|
|
210
|
+
return !c || !v ? { x: 0, y: 0 } : { x: (c.x + v.x) / 2, y: (c.y + v.y) / 2 };
|
|
211
|
+
}
|
|
212
|
+
function M() {
|
|
213
|
+
return [...u.values()].filter((t) => t.type === "touch").map((t) => t.point);
|
|
214
|
+
}
|
|
215
|
+
function A(t, c, v, E, R) {
|
|
216
|
+
const j = pe(() => {
|
|
217
|
+
v === "pan" ? a.beginPan(t, c) : v === "drag" && E ? a.beginNodeDrag(ee(E), t, c) : v === "resize" && E && R ? a.beginResize(ee(E), R, t, c) : a.beginBoxSelect(t, c);
|
|
218
|
+
});
|
|
219
|
+
return j && n.value?.focus(), j;
|
|
220
|
+
}
|
|
221
|
+
function T(t) {
|
|
222
|
+
i.value && (t !== void 0 && i.value.pointerId !== t || (i.value = null));
|
|
223
|
+
}
|
|
224
|
+
function X(t, c) {
|
|
225
|
+
return Math.hypot(c.x - t.x, c.y - t.y) >= nt;
|
|
226
|
+
}
|
|
227
|
+
function N(t, c, v) {
|
|
228
|
+
const E = p(t.clientX, t.clientY);
|
|
229
|
+
if (n.value?.setPointerCapture(t.pointerId), n.value?.focus(), v && c) {
|
|
230
|
+
if (!pe(() => e.select(ee(c)))) return;
|
|
231
|
+
i.value = {
|
|
232
|
+
kind: "resize",
|
|
233
|
+
pointerId: t.pointerId,
|
|
234
|
+
startPoint: E,
|
|
235
|
+
nodeId: c,
|
|
236
|
+
handle: v
|
|
237
|
+
};
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
if (c) {
|
|
241
|
+
if (!e.getSelection().includes(ee(c)) && !pe(() => e.select(ee(c))))
|
|
242
|
+
return;
|
|
243
|
+
i.value = {
|
|
244
|
+
kind: "drag",
|
|
245
|
+
pointerId: t.pointerId,
|
|
246
|
+
startPoint: E,
|
|
247
|
+
nodeId: c
|
|
248
|
+
};
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
pe(() => e.clearSelection()) && (i.value = {
|
|
252
|
+
kind: "box-select",
|
|
253
|
+
pointerId: t.pointerId,
|
|
254
|
+
startPoint: E
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
function m(t, c) {
|
|
258
|
+
const v = i.value;
|
|
259
|
+
if (!v || v.pointerId !== t.pointerId || !X(v.startPoint, c))
|
|
260
|
+
return !1;
|
|
261
|
+
let E = !1;
|
|
262
|
+
if (v.kind === "drag")
|
|
263
|
+
if (t.altKey) {
|
|
264
|
+
const R = e.findNode(ee(v.nodeId)), j = $(
|
|
265
|
+
() => e.duplicateNodes(e.getSelection(), { x: 0, y: 0 })
|
|
266
|
+
), Q = j?.nodes ?? [], oe = R ? j?.idMap.get(R.id) : void 0, de = (oe ? Q.find((g) => g.id === oe) : void 0) ?? Q[0];
|
|
267
|
+
de && (E = A(
|
|
268
|
+
t.pointerId,
|
|
269
|
+
v.startPoint,
|
|
270
|
+
"drag",
|
|
271
|
+
String(de.id)
|
|
272
|
+
));
|
|
273
|
+
} else
|
|
274
|
+
E = A(
|
|
275
|
+
t.pointerId,
|
|
276
|
+
v.startPoint,
|
|
277
|
+
"drag",
|
|
278
|
+
v.nodeId
|
|
279
|
+
);
|
|
280
|
+
else v.kind === "resize" ? E = A(
|
|
281
|
+
t.pointerId,
|
|
282
|
+
v.startPoint,
|
|
283
|
+
"resize",
|
|
284
|
+
v.nodeId,
|
|
285
|
+
v.handle
|
|
286
|
+
) : E = A(
|
|
287
|
+
t.pointerId,
|
|
288
|
+
v.startPoint,
|
|
289
|
+
"box-select"
|
|
290
|
+
);
|
|
291
|
+
return i.value = null, E;
|
|
292
|
+
}
|
|
293
|
+
function _() {
|
|
294
|
+
h !== null && (cancelAnimationFrame(h), h = null), r && ($(
|
|
295
|
+
() => a.updatePointer(r.id, r.point, {
|
|
296
|
+
shift: r.shift,
|
|
297
|
+
space: r.space
|
|
298
|
+
})
|
|
299
|
+
), r = null, b = !1);
|
|
300
|
+
}
|
|
301
|
+
function s(t) {
|
|
302
|
+
if (!H(t.target, n.value) || fe(t.target)) return;
|
|
303
|
+
const c = p(t.clientX, t.clientY);
|
|
304
|
+
if (u.set(t.pointerId, {
|
|
305
|
+
point: c,
|
|
306
|
+
type: t.pointerType
|
|
307
|
+
}), M().length === 2 && t.pointerType === "touch") {
|
|
308
|
+
$(() => a.endInteraction()), n.value?.setPointerCapture(t.pointerId), T(), r = null, y = !0, k = P();
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
if (t.button === 1 || l.value) {
|
|
312
|
+
t.preventDefault(), n.value?.setPointerCapture(t.pointerId), A(t.pointerId, c, "pan");
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
if (t.button !== 0) return;
|
|
316
|
+
const v = $e(t.target), E = ke(t.target);
|
|
317
|
+
N(t, v, E);
|
|
318
|
+
}
|
|
319
|
+
function f(t) {
|
|
320
|
+
if (!H(t.target, n.value)) return;
|
|
321
|
+
const c = p(t.clientX, t.clientY), v = u.get(t.pointerId);
|
|
322
|
+
if (!v)
|
|
323
|
+
return;
|
|
324
|
+
if (u.set(t.pointerId, {
|
|
325
|
+
point: c,
|
|
326
|
+
type: v.type
|
|
327
|
+
}), y) {
|
|
328
|
+
const R = P();
|
|
329
|
+
if (k > 0 && R > 0) {
|
|
330
|
+
const j = R / k, Q = -100 * Math.log2(j);
|
|
331
|
+
$(() => e.zoomAt(D(), Q));
|
|
332
|
+
}
|
|
333
|
+
k = R;
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
!m(t, c) && i.value?.pointerId === t.pointerId || (r = {
|
|
337
|
+
id: t.pointerId,
|
|
338
|
+
point: c,
|
|
339
|
+
shift: t.shiftKey,
|
|
340
|
+
space: l.value
|
|
341
|
+
}, b || (b = !0, h = requestAnimationFrame(() => {
|
|
342
|
+
r && $(
|
|
343
|
+
() => a.updatePointer(
|
|
344
|
+
r.id,
|
|
345
|
+
r.point,
|
|
346
|
+
{
|
|
347
|
+
shift: r.shift,
|
|
348
|
+
space: r.space
|
|
349
|
+
}
|
|
350
|
+
)
|
|
351
|
+
), b = !1, h = null, r = null;
|
|
352
|
+
})));
|
|
353
|
+
}
|
|
354
|
+
function B(t) {
|
|
355
|
+
if (H(t.target, n.value)) {
|
|
356
|
+
if (u.delete(t.pointerId), n.value?.hasPointerCapture(t.pointerId) && n.value.releasePointerCapture(t.pointerId), y) {
|
|
357
|
+
M().length < 2 && (y = !1, k = 0, T(), $(() => a.endInteraction()));
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
if (i.value?.pointerId === t.pointerId) {
|
|
361
|
+
T(t.pointerId);
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
_(), $(() => a.endInteraction(t.pointerId));
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
function V(t) {
|
|
368
|
+
H(t.target, n.value) && (u.delete(t.pointerId), T(t.pointerId), r = null, h !== null && (cancelAnimationFrame(h), h = null), b = !1, $(() => a.cancelInteraction(t.pointerId)));
|
|
369
|
+
}
|
|
370
|
+
function le(t) {
|
|
371
|
+
if (!H(t.target, n.value) || fe(t.target)) return;
|
|
372
|
+
t.preventDefault();
|
|
373
|
+
const c = p(t.clientX, t.clientY);
|
|
374
|
+
t.ctrlKey || t.metaKey || l.value ? $(
|
|
375
|
+
() => e.zoomAt(c, Math.max(-10, Math.min(10, t.deltaY)))
|
|
376
|
+
) : t.shiftKey ? $(() => e.panBy(t.deltaX || t.deltaY, 0)) : $(() => e.panBy(t.deltaX, t.deltaY));
|
|
377
|
+
}
|
|
378
|
+
function se(t) {
|
|
379
|
+
if (!H(t.target, n.value) || fe(t.target) || ke(t.target))
|
|
380
|
+
return;
|
|
381
|
+
const c = p(t.clientX, t.clientY), v = $e(t.target) ?? C(c);
|
|
382
|
+
if (v) {
|
|
383
|
+
const j = ee(v);
|
|
384
|
+
e.getNode(j).type === "text" && $(() => e.beginTextEdit(j));
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
const E = e.screenToWorld(c), R = $(
|
|
388
|
+
() => e.createNode({
|
|
389
|
+
type: "text",
|
|
390
|
+
x: E.x,
|
|
391
|
+
y: E.y,
|
|
392
|
+
text: "New node"
|
|
393
|
+
})
|
|
394
|
+
);
|
|
395
|
+
R && $(() => e.beginTextEdit(R.id));
|
|
396
|
+
}
|
|
397
|
+
return me(() => {
|
|
398
|
+
h !== null && cancelAnimationFrame(h), h = null, b = !1, r = null, u.clear(), T(), $(() => a.cancelInteraction());
|
|
399
|
+
}), {
|
|
400
|
+
onPointerDown: s,
|
|
401
|
+
onPointerMove: f,
|
|
402
|
+
onPointerUp: B,
|
|
403
|
+
onPointerCancel: V,
|
|
404
|
+
onWheel: le,
|
|
405
|
+
onDoubleClick: se
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
const it = ["data-mode"], lt = /* @__PURE__ */ q({
|
|
409
|
+
__name: "BoardBoxSelect",
|
|
410
|
+
setup(o) {
|
|
411
|
+
const e = Ve(), n = Ye(), l = I(() => n.value.mode !== "box-select" ? "window" : n.value.selectionMode), p = I(() => e.value ? {
|
|
412
|
+
left: `${e.value.minX}px`,
|
|
413
|
+
top: `${e.value.minY}px`,
|
|
414
|
+
width: `${e.value.maxX - e.value.minX}px`,
|
|
415
|
+
height: `${e.value.maxY - e.value.minY}px`
|
|
416
|
+
} : {});
|
|
417
|
+
return (a, i) => w(e) ? L(a.$slots, "default", {
|
|
418
|
+
bounds: w(e),
|
|
419
|
+
mode: l.value
|
|
420
|
+
}, () => [
|
|
421
|
+
w(e) ? (x(), z("div", {
|
|
422
|
+
key: 0,
|
|
423
|
+
class: te(["board-box-select", `board-box-select--${l.value}`]),
|
|
424
|
+
"data-mode": l.value,
|
|
425
|
+
style: Z(p.value)
|
|
426
|
+
}, null, 14, it)) : O("", !0)
|
|
427
|
+
], !0, 0) : O("", !0);
|
|
428
|
+
}
|
|
429
|
+
}), J = (o, e) => {
|
|
430
|
+
const n = o.__vccOpts || o;
|
|
431
|
+
for (const [l, p] of e)
|
|
432
|
+
n[l] = p;
|
|
433
|
+
return n;
|
|
434
|
+
}, st = /* @__PURE__ */ J(lt, [["__scopeId", "data-v-fb31d12b"]]), dt = /* @__PURE__ */ q({
|
|
435
|
+
__name: "BoardGrid",
|
|
436
|
+
setup(o) {
|
|
437
|
+
const { resolvedGrid: e } = ie(), n = Fe(), l = I(() => {
|
|
438
|
+
switch (e.value.pattern) {
|
|
439
|
+
case "dot":
|
|
440
|
+
return [
|
|
441
|
+
"radial-gradient(circle, var(--grid-major-color) 1px, transparent 1px)",
|
|
442
|
+
"radial-gradient(circle, var(--grid-minor-color) 1px, transparent 1px)"
|
|
443
|
+
].join(", ");
|
|
444
|
+
case "cross":
|
|
445
|
+
return [
|
|
446
|
+
"linear-gradient(to right, var(--grid-major-color) 1px, transparent 1px)",
|
|
447
|
+
"linear-gradient(to bottom, var(--grid-major-color) 1px, transparent 1px)",
|
|
448
|
+
"linear-gradient(to right, var(--grid-minor-color) 1px, transparent 1px)",
|
|
449
|
+
"linear-gradient(to bottom, var(--grid-minor-color) 1px, transparent 1px)"
|
|
450
|
+
].join(", ");
|
|
451
|
+
case "none":
|
|
452
|
+
return "none";
|
|
453
|
+
default:
|
|
454
|
+
return [
|
|
455
|
+
"linear-gradient(to right, var(--grid-minor-color) 1px, transparent 1px)",
|
|
456
|
+
"linear-gradient(to bottom, var(--grid-minor-color) 1px, transparent 1px)",
|
|
457
|
+
"linear-gradient(to right, var(--grid-major-color) 1px, transparent 1px)",
|
|
458
|
+
"linear-gradient(to bottom, var(--grid-major-color) 1px, transparent 1px)"
|
|
459
|
+
].join(", ");
|
|
460
|
+
}
|
|
461
|
+
}), p = I(() => e.value.pattern === "dot" ? [
|
|
462
|
+
"var(--grid-major-size) var(--grid-major-size)",
|
|
463
|
+
"var(--grid-minor-size) var(--grid-minor-size)"
|
|
464
|
+
].join(", ") : [
|
|
465
|
+
"var(--grid-minor-size) var(--grid-minor-size)",
|
|
466
|
+
"var(--grid-minor-size) var(--grid-minor-size)",
|
|
467
|
+
"var(--grid-major-size) var(--grid-major-size)",
|
|
468
|
+
"var(--grid-major-size) var(--grid-major-size)"
|
|
469
|
+
].join(", ")), a = I(() => e.value.pattern === "dot" ? [
|
|
470
|
+
"var(--grid-major-x) var(--grid-major-y)",
|
|
471
|
+
"var(--grid-minor-x) var(--grid-minor-y)"
|
|
472
|
+
].join(", ") : [
|
|
473
|
+
"var(--grid-minor-x) var(--grid-minor-y)",
|
|
474
|
+
"var(--grid-minor-x) var(--grid-minor-y)",
|
|
475
|
+
"var(--grid-major-x) var(--grid-major-y)",
|
|
476
|
+
"var(--grid-major-x) var(--grid-major-y)"
|
|
477
|
+
].join(", "));
|
|
478
|
+
return (i, u) => w(e).visible && w(e).pattern !== "none" ? (x(), z("div", {
|
|
479
|
+
key: 0,
|
|
480
|
+
class: "board-grid",
|
|
481
|
+
style: Z({
|
|
482
|
+
...w(n),
|
|
483
|
+
backgroundImage: l.value,
|
|
484
|
+
backgroundSize: p.value,
|
|
485
|
+
backgroundPosition: a.value
|
|
486
|
+
})
|
|
487
|
+
}, null, 4)) : O("", !0);
|
|
488
|
+
}
|
|
489
|
+
}), ut = /* @__PURE__ */ J(dt, [["__scopeId", "data-v-f3663c53"]]);
|
|
490
|
+
function Re(o) {
|
|
491
|
+
if (!o)
|
|
492
|
+
return {};
|
|
493
|
+
const e = o.startsWith("#") ? o : Ke(o);
|
|
494
|
+
if (!e) return {};
|
|
495
|
+
const n = `var(--board-preset-${o}, ${e})`;
|
|
496
|
+
return {
|
|
497
|
+
"--board-node-color": n,
|
|
498
|
+
"--board-node-tint": `color-mix(in srgb, ${n} 7%, var(--board-node-bg, #fff))`,
|
|
499
|
+
"--board-node-tint-strong": `color-mix(in srgb, ${n} 13%, var(--board-node-bg, #fff))`,
|
|
500
|
+
"--board-node-color-soft": `color-mix(in srgb, ${n} 24%, transparent)`,
|
|
501
|
+
"--board-node-color-ring": `color-mix(in srgb, ${n} 70%, transparent)`
|
|
502
|
+
};
|
|
503
|
+
}
|
|
504
|
+
const ct = ["data-resize", "aria-label"], pt = /* @__PURE__ */ q({
|
|
505
|
+
__name: "BoardNodeHandle",
|
|
506
|
+
props: {
|
|
507
|
+
handle: {},
|
|
508
|
+
nodeId: {}
|
|
509
|
+
},
|
|
510
|
+
setup(o) {
|
|
511
|
+
const e = o, { engine: n, $grid: l } = ie(), p = {
|
|
512
|
+
n: "Resize from top",
|
|
513
|
+
ne: "Resize from top right",
|
|
514
|
+
e: "Resize from right",
|
|
515
|
+
se: "Resize from bottom right",
|
|
516
|
+
s: "Resize from bottom",
|
|
517
|
+
sw: "Resize from bottom left",
|
|
518
|
+
w: "Resize from left",
|
|
519
|
+
nw: "Resize from top left"
|
|
520
|
+
};
|
|
521
|
+
function a(i) {
|
|
522
|
+
if (!e.nodeId || !i.key.startsWith("Arrow")) return;
|
|
523
|
+
const u = e.handle.includes("e") || e.handle.includes("w"), y = e.handle.includes("n") || e.handle.includes("s"), k = i.shiftKey ? l.value.size * l.value.majorEvery : l.value.size, r = u ? i.key === "ArrowLeft" ? -k : i.key === "ArrowRight" ? k : 0 : 0, b = y ? i.key === "ArrowUp" ? -k : i.key === "ArrowDown" ? k : 0 : 0;
|
|
524
|
+
r === 0 && b === 0 || (i.preventDefault(), i.stopPropagation(), $(() => n.resizeNode(e.nodeId, e.handle, r, b)));
|
|
525
|
+
}
|
|
526
|
+
return (i, u) => (x(), z("button", {
|
|
527
|
+
type: "button",
|
|
528
|
+
class: te(["board-node-handle", `is-${o.handle}`]),
|
|
529
|
+
"data-resize": o.handle,
|
|
530
|
+
"aria-label": p[o.handle],
|
|
531
|
+
onKeydown: a
|
|
532
|
+
}, null, 42, ct));
|
|
533
|
+
}
|
|
534
|
+
}), ft = /* @__PURE__ */ J(pt, [["__scopeId", "data-v-004da51c"]]), vt = ["data-node-id", "aria-label", "onKeydown"], mt = ["aria-describedby"], gt = ["id"], yt = {
|
|
535
|
+
key: 1,
|
|
536
|
+
class: "board-node__content"
|
|
537
|
+
}, bt = /* @__PURE__ */ q({
|
|
538
|
+
__name: "BoardNode",
|
|
539
|
+
props: {
|
|
540
|
+
node: {},
|
|
541
|
+
selected: { type: Boolean },
|
|
542
|
+
editing: { type: Boolean },
|
|
543
|
+
customRenderer: { type: Boolean }
|
|
544
|
+
},
|
|
545
|
+
setup(o) {
|
|
546
|
+
const e = o, n = Ee(), { engine: l } = ie(), p = ["n", "ne", "e", "se", "s", "sw", "w", "nw"], a = W(N(e.node)), i = W(null), u = I(() => ({
|
|
547
|
+
left: `${e.node.x}px`,
|
|
548
|
+
top: `${e.node.y}px`,
|
|
549
|
+
width: `${e.node.width}px`,
|
|
550
|
+
height: `${e.node.height}px`,
|
|
551
|
+
zIndex: String(e.node.zIndex),
|
|
552
|
+
...Re(e.node.color)
|
|
553
|
+
}));
|
|
554
|
+
function y() {
|
|
555
|
+
e.node.type === "text" && $(() => l.beginTextEdit(e.node.id));
|
|
556
|
+
}
|
|
557
|
+
function k(m) {
|
|
558
|
+
e.node.type === "text" && $(() => l.commitTextEdit(e.node.id, m));
|
|
559
|
+
}
|
|
560
|
+
const r = I(() => ({
|
|
561
|
+
node: e.node,
|
|
562
|
+
selected: e.selected,
|
|
563
|
+
editing: e.editing,
|
|
564
|
+
beginEdit: y,
|
|
565
|
+
commitText: k
|
|
566
|
+
}));
|
|
567
|
+
function b() {
|
|
568
|
+
return e.customRenderer !== void 0 ? e.customRenderer : !!n.default;
|
|
569
|
+
}
|
|
570
|
+
const h = I(() => {
|
|
571
|
+
let m;
|
|
572
|
+
return e.node.type === "text" ? m = N(e.node) || "Empty text node" : m = `${e.node.type} node`, e.selected ? `${m}, selected` : m;
|
|
573
|
+
}), C = I(
|
|
574
|
+
() => `${e.node.id}-editor-help`.replace(/[^A-Za-z0-9_-]/g, "-").replace(/-+/g, "-")
|
|
575
|
+
);
|
|
576
|
+
ve(
|
|
577
|
+
() => e.node,
|
|
578
|
+
(m) => {
|
|
579
|
+
a.value = N(m);
|
|
580
|
+
},
|
|
581
|
+
{ deep: !0 }
|
|
582
|
+
), ve(
|
|
583
|
+
() => e.editing,
|
|
584
|
+
(m) => {
|
|
585
|
+
m ? Se(() => {
|
|
586
|
+
i.value?.focus(), i.value?.select();
|
|
587
|
+
}) : a.value = N(e.node);
|
|
588
|
+
}
|
|
589
|
+
);
|
|
590
|
+
function P() {
|
|
591
|
+
$(() => l.commitTextEdit(e.node.id, a.value));
|
|
592
|
+
}
|
|
593
|
+
function D() {
|
|
594
|
+
a.value = N(e.node), $(() => l.cancelTextEdit());
|
|
595
|
+
}
|
|
596
|
+
function M(m) {
|
|
597
|
+
if (m.stopPropagation(), m.key === "Escape") {
|
|
598
|
+
m.preventDefault(), D();
|
|
599
|
+
return;
|
|
600
|
+
}
|
|
601
|
+
m.key === "Enter" && (m.metaKey || m.ctrlKey) && (m.preventDefault(), P());
|
|
602
|
+
}
|
|
603
|
+
function A(m) {
|
|
604
|
+
X(m.target) || e.node.type === "text" && (m.preventDefault(), y());
|
|
605
|
+
}
|
|
606
|
+
function T() {
|
|
607
|
+
e.selected || $(() => l.select(e.node.id));
|
|
608
|
+
}
|
|
609
|
+
function X(m) {
|
|
610
|
+
return m instanceof HTMLElement && !!m.closest("[data-editor]");
|
|
611
|
+
}
|
|
612
|
+
function N(m) {
|
|
613
|
+
return m.type !== "text" ? "" : typeof m.text == "string" ? m.text : "";
|
|
614
|
+
}
|
|
615
|
+
return (m, _) => (x(), z("article", {
|
|
616
|
+
class: te(["board-node", {
|
|
617
|
+
"is-selected": o.selected,
|
|
618
|
+
"is-editing": o.editing,
|
|
619
|
+
"is-locked": o.node.locked,
|
|
620
|
+
"is-group": o.node.type === "group",
|
|
621
|
+
"is-colored": !!o.node.color
|
|
622
|
+
}]),
|
|
623
|
+
style: Z(u.value),
|
|
624
|
+
"data-node-id": o.node.id,
|
|
625
|
+
tabindex: "0",
|
|
626
|
+
role: "group",
|
|
627
|
+
"aria-roledescription": "board node",
|
|
628
|
+
"aria-label": h.value,
|
|
629
|
+
onFocus: T,
|
|
630
|
+
onKeydown: Ce(U(A, ["stop"]), ["enter"])
|
|
631
|
+
}, [
|
|
632
|
+
b() ? L(m.$slots, "default", ze(Ie(r.value)), void 0, !0, 0) : (x(), z(F, { key: 1 }, [
|
|
633
|
+
o.editing && o.node.type === "text" ? (x(), z(F, { key: 0 }, [
|
|
634
|
+
De(K("textarea", {
|
|
635
|
+
ref_key: "textareaRef",
|
|
636
|
+
ref: i,
|
|
637
|
+
"onUpdate:modelValue": _[0] || (_[0] = (s) => a.value = s),
|
|
638
|
+
class: "board-node__editor",
|
|
639
|
+
"data-editor": "true",
|
|
640
|
+
"aria-describedby": C.value,
|
|
641
|
+
spellcheck: "true",
|
|
642
|
+
onBlur: P,
|
|
643
|
+
onKeydown: M,
|
|
644
|
+
onPointerdown: _[1] || (_[1] = U(() => {
|
|
645
|
+
}, ["stop"])),
|
|
646
|
+
onDblclick: _[2] || (_[2] = U(() => {
|
|
647
|
+
}, ["stop"]))
|
|
648
|
+
}, null, 40, mt), [
|
|
649
|
+
[Te, a.value]
|
|
650
|
+
]),
|
|
651
|
+
K("span", {
|
|
652
|
+
id: C.value,
|
|
653
|
+
class: "board-node__editor-help"
|
|
654
|
+
}, " Enter inserts a new line. Control Enter or Command Enter saves. ", 8, gt)
|
|
655
|
+
], 64)) : (x(), z("div", yt, [
|
|
656
|
+
o.node.type === "text" ? (x(), z(F, { key: 0 }, [
|
|
657
|
+
he(xe(N(o.node) || "Double-click to edit"), 1)
|
|
658
|
+
], 64)) : (x(), z(F, { key: 1 }, [
|
|
659
|
+
he(xe(o.node.type), 1)
|
|
660
|
+
], 64))
|
|
661
|
+
]))
|
|
662
|
+
], 64)),
|
|
663
|
+
o.selected && !o.editing && !o.node.locked ? (x(), z(F, { key: 2 }, ge(p, (s) => L(m.$slots, "handle", {
|
|
664
|
+
key: s,
|
|
665
|
+
node: o.node,
|
|
666
|
+
handle: s
|
|
667
|
+
}, () => [
|
|
668
|
+
Be(ft, {
|
|
669
|
+
handle: s,
|
|
670
|
+
"node-id": o.node.id
|
|
671
|
+
}, null, 8, ["handle", "node-id"])
|
|
672
|
+
], !0)), 64)) : O("", !0)
|
|
673
|
+
], 46, vt));
|
|
674
|
+
}
|
|
675
|
+
}), ht = /* @__PURE__ */ J(bt, [["__scopeId", "data-v-9aa9b6cd"]]), xt = {
|
|
676
|
+
key: 0,
|
|
677
|
+
class: "board-snap-guides"
|
|
678
|
+
}, wt = /* @__PURE__ */ q({
|
|
679
|
+
__name: "BoardSnapGuides",
|
|
680
|
+
setup(o) {
|
|
681
|
+
const { $camera: e, $snapGuides: n } = ie(), l = I(() => {
|
|
682
|
+
const p = n.value;
|
|
683
|
+
if (!p || p.length === 0) return [];
|
|
684
|
+
const { x: a, y: i, z: u } = e.value;
|
|
685
|
+
return p.map((y) => y.axis === "x" ? {
|
|
686
|
+
axis: "x",
|
|
687
|
+
pos: (y.position + a) * u,
|
|
688
|
+
from: (y.from + i) * u,
|
|
689
|
+
to: (y.to + i) * u
|
|
690
|
+
} : {
|
|
691
|
+
axis: "y",
|
|
692
|
+
pos: (y.position + i) * u,
|
|
693
|
+
from: (y.from + a) * u,
|
|
694
|
+
to: (y.to + a) * u
|
|
695
|
+
});
|
|
696
|
+
});
|
|
697
|
+
return (p, a) => l.value.length > 0 ? (x(), z("div", xt, [
|
|
698
|
+
(x(!0), z(F, null, ge(l.value, (i, u) => (x(), z("div", {
|
|
699
|
+
key: u,
|
|
700
|
+
class: te([
|
|
701
|
+
"board-snap-guide",
|
|
702
|
+
i.axis === "x" ? "board-snap-guide--vertical" : "board-snap-guide--horizontal"
|
|
703
|
+
]),
|
|
704
|
+
style: Z(
|
|
705
|
+
i.axis === "x" ? {
|
|
706
|
+
left: i.pos + "px",
|
|
707
|
+
top: i.from + "px",
|
|
708
|
+
height: i.to - i.from + "px"
|
|
709
|
+
} : {
|
|
710
|
+
top: i.pos + "px",
|
|
711
|
+
left: i.from + "px",
|
|
712
|
+
width: i.to - i.from + "px"
|
|
713
|
+
}
|
|
714
|
+
)
|
|
715
|
+
}, null, 6))), 128))
|
|
716
|
+
])) : O("", !0);
|
|
717
|
+
}
|
|
718
|
+
}), $t = /* @__PURE__ */ J(wt, [["__scopeId", "data-v-2c604885"]]), kt = /* @__PURE__ */ q({
|
|
719
|
+
__name: "BoardViewport",
|
|
720
|
+
setup(o) {
|
|
721
|
+
const e = Ge(), n = I(() => ({
|
|
722
|
+
transform: `scale(${e.value.z}) translate(${e.value.x}px, ${e.value.y}px)`,
|
|
723
|
+
"--board-zoom": e.value.z
|
|
724
|
+
}));
|
|
725
|
+
return (l, p) => (x(), z("div", {
|
|
726
|
+
class: "board-viewport",
|
|
727
|
+
style: Z(n.value)
|
|
728
|
+
}, [
|
|
729
|
+
L(l.$slots, "default", {}, void 0, !0)
|
|
730
|
+
], 4));
|
|
731
|
+
}
|
|
732
|
+
}), Et = /* @__PURE__ */ J(kt, [["__scopeId", "data-v-9eeb9aab"]]), St = { class: "board-selection-toolbar__popover-anchor" }, zt = ["aria-expanded"], It = ["aria-checked"], Bt = ["aria-label", "title", "data-node-color-option", "aria-checked", "onClick"], Pt = ["disabled"], _t = /* @__PURE__ */ q({
|
|
733
|
+
__name: "BoardSelectionToolbar",
|
|
734
|
+
setup(o) {
|
|
735
|
+
const { engine: e, $camera: n, $nodes: l, $selection: p, $interaction: a } = ie(), i = W(!1), u = W(null), y = W(null), k = `board-colour-menu-${Ne()}`, r = I(
|
|
736
|
+
() => Array.from(p.value).map((s) => l.value.get(s)).filter((s) => !!s)
|
|
737
|
+
), b = I(() => {
|
|
738
|
+
if (r.value.length === 0)
|
|
739
|
+
return null;
|
|
740
|
+
let s = 1 / 0, f = 1 / 0, B = -1 / 0;
|
|
741
|
+
for (const V of r.value)
|
|
742
|
+
s = Math.min(s, V.x), f = Math.min(f, V.y), B = Math.max(B, V.x + V.width);
|
|
743
|
+
return { minX: s, minY: f, maxX: B };
|
|
744
|
+
}), h = I(() => {
|
|
745
|
+
if (!b.value)
|
|
746
|
+
return null;
|
|
747
|
+
const s = n.value;
|
|
748
|
+
return {
|
|
749
|
+
left: `${((b.value.minX + b.value.maxX) / 2 + s.x) * s.z}px`,
|
|
750
|
+
top: `${(b.value.minY + s.y) * s.z}px`
|
|
751
|
+
};
|
|
752
|
+
}), C = I(
|
|
753
|
+
() => r.value.length > 0 && a.value.mode !== "dragging-nodes" && a.value.mode !== "resizing-node" && a.value.mode !== "editing-text"
|
|
754
|
+
), P = I(
|
|
755
|
+
() => r.value.length === 1 && r.value[0]?.type === "text"
|
|
756
|
+
);
|
|
757
|
+
ve(
|
|
758
|
+
() => Array.from(p.value).join("\0"),
|
|
759
|
+
() => {
|
|
760
|
+
i.value = !1;
|
|
761
|
+
}
|
|
762
|
+
);
|
|
763
|
+
function D(s) {
|
|
764
|
+
s.preventDefault(), s.stopPropagation();
|
|
765
|
+
}
|
|
766
|
+
function M(s) {
|
|
767
|
+
e.batch(() => {
|
|
768
|
+
for (const f of r.value)
|
|
769
|
+
f.locked || $(() => e.updateNode(f.id, { color: s }));
|
|
770
|
+
}), i.value = !1;
|
|
771
|
+
}
|
|
772
|
+
function A(s) {
|
|
773
|
+
D(s), $(() => e.deleteSelected());
|
|
774
|
+
}
|
|
775
|
+
function T(s) {
|
|
776
|
+
D(s), i.value = !i.value, i.value && Se(() => {
|
|
777
|
+
const f = y.value?.querySelector(
|
|
778
|
+
'[aria-checked="true"]'
|
|
779
|
+
), B = y.value?.querySelector(
|
|
780
|
+
'[role="menuitemradio"]'
|
|
781
|
+
);
|
|
782
|
+
(f ?? B)?.focus();
|
|
783
|
+
});
|
|
784
|
+
}
|
|
785
|
+
function X(s) {
|
|
786
|
+
s.key === "Escape" && (s.preventDefault(), s.stopPropagation(), i.value = !1, u.value?.focus());
|
|
787
|
+
}
|
|
788
|
+
function N(s) {
|
|
789
|
+
D(s), e.zoomToNodes(
|
|
790
|
+
r.value.map((f) => f.id),
|
|
791
|
+
80,
|
|
792
|
+
!0
|
|
793
|
+
);
|
|
794
|
+
}
|
|
795
|
+
function m(s) {
|
|
796
|
+
D(s);
|
|
797
|
+
const f = r.value[0];
|
|
798
|
+
f?.type === "text" && $(() => e.beginTextEdit(f.id));
|
|
799
|
+
}
|
|
800
|
+
const _ = I(() => {
|
|
801
|
+
const s = r.value.map((f) => f.color ?? null);
|
|
802
|
+
return s.every((f) => f === s[0]) ? s[0] : "mixed";
|
|
803
|
+
});
|
|
804
|
+
return (s, f) => C.value && h.value ? (x(), z("div", {
|
|
805
|
+
key: 0,
|
|
806
|
+
class: "board-selection-toolbar",
|
|
807
|
+
"data-board-interactive": "true",
|
|
808
|
+
"data-node-selection-toolbar": "true",
|
|
809
|
+
style: Z(h.value),
|
|
810
|
+
onPointerdown: f[1] || (f[1] = U(() => {
|
|
811
|
+
}, ["stop"])),
|
|
812
|
+
onMousedown: f[2] || (f[2] = U(() => {
|
|
813
|
+
}, ["stop"])),
|
|
814
|
+
onDblclick: f[3] || (f[3] = U(() => {
|
|
815
|
+
}, ["stop"]))
|
|
816
|
+
}, [
|
|
817
|
+
K("button", {
|
|
818
|
+
type: "button",
|
|
819
|
+
class: "board-selection-toolbar__button is-danger",
|
|
820
|
+
"aria-label": "Remove",
|
|
821
|
+
title: "Remove",
|
|
822
|
+
onClick: A
|
|
823
|
+
}, [...f[4] || (f[4] = [
|
|
824
|
+
ye('<svg viewBox="0 0 24 24" aria-hidden="true" data-v-c1436955><path d="M4 7h16" data-v-c1436955></path><path d="M10 11v6" data-v-c1436955></path><path d="M14 11v6" data-v-c1436955></path><path d="M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l1 -12" data-v-c1436955></path><path d="M9 7v-3a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3" data-v-c1436955></path></svg>', 1)
|
|
825
|
+
])]),
|
|
826
|
+
K("div", St, [
|
|
827
|
+
K("button", {
|
|
828
|
+
ref_key: "paletteButton",
|
|
829
|
+
ref: u,
|
|
830
|
+
type: "button",
|
|
831
|
+
class: "board-selection-toolbar__button",
|
|
832
|
+
"aria-label": "Set colour",
|
|
833
|
+
title: "Set colour",
|
|
834
|
+
"data-node-color-menu-button": "true",
|
|
835
|
+
"aria-haspopup": "menu",
|
|
836
|
+
"aria-expanded": i.value,
|
|
837
|
+
"aria-controls": k,
|
|
838
|
+
onClick: T
|
|
839
|
+
}, [...f[5] || (f[5] = [
|
|
840
|
+
ye('<svg viewBox="0 0 24 24" aria-hidden="true" data-v-c1436955><path d="M19 3h-4a2 2 0 0 0 -2 2v12a4 4 0 0 0 8 0v-12a2 2 0 0 0 -2 -2" data-v-c1436955></path><path d="M13 7.35l-2 -2a2 2 0 0 0 -2.828 0l-2.828 2.828a2 2 0 0 0 0 2.828l9 9" data-v-c1436955></path><path d="M7.3 13h-2.3a2 2 0 0 0 -2 2v4a2 2 0 0 0 2 2h12" data-v-c1436955></path><path d="M17 17l0 .01" data-v-c1436955></path></svg>', 1)
|
|
841
|
+
])], 8, zt),
|
|
842
|
+
i.value ? (x(), z("div", {
|
|
843
|
+
key: 0,
|
|
844
|
+
id: k,
|
|
845
|
+
ref_key: "palette",
|
|
846
|
+
ref: y,
|
|
847
|
+
class: "board-selection-toolbar__palette",
|
|
848
|
+
"data-node-color-menu": "true",
|
|
849
|
+
role: "menu",
|
|
850
|
+
"aria-label": "Node colour",
|
|
851
|
+
onKeydown: X
|
|
852
|
+
}, [
|
|
853
|
+
K("button", {
|
|
854
|
+
type: "button",
|
|
855
|
+
class: te(["board-selection-toolbar__swatch is-default", { "is-active": _.value === null }]),
|
|
856
|
+
"aria-label": "Default colour",
|
|
857
|
+
title: "Default colour",
|
|
858
|
+
"data-node-color-option": "default",
|
|
859
|
+
role: "menuitemradio",
|
|
860
|
+
"aria-checked": _.value === null,
|
|
861
|
+
onClick: f[0] || (f[0] = U((B) => M(void 0), ["stop", "prevent"]))
|
|
862
|
+
}, null, 10, It),
|
|
863
|
+
(x(!0), z(F, null, ge(w(Le), (B) => (x(), z("button", {
|
|
864
|
+
key: B.preset,
|
|
865
|
+
type: "button",
|
|
866
|
+
class: te(["board-selection-toolbar__swatch", { "is-active": _.value === B.preset }]),
|
|
867
|
+
style: Z({
|
|
868
|
+
"--swatch-color": `var(--board-preset-${B.preset}, ${B.hex})`
|
|
869
|
+
}),
|
|
870
|
+
"aria-label": B.label,
|
|
871
|
+
title: B.label,
|
|
872
|
+
"data-node-color-option": B.preset,
|
|
873
|
+
role: "menuitemradio",
|
|
874
|
+
"aria-checked": _.value === B.preset,
|
|
875
|
+
onClick: U((V) => M(B.preset), ["stop", "prevent"])
|
|
876
|
+
}, null, 14, Bt))), 128))
|
|
877
|
+
], 544)) : O("", !0)
|
|
878
|
+
]),
|
|
879
|
+
K("button", {
|
|
880
|
+
type: "button",
|
|
881
|
+
class: "board-selection-toolbar__button",
|
|
882
|
+
"aria-label": "Zoom to selection",
|
|
883
|
+
title: "Zoom to selection",
|
|
884
|
+
onClick: N
|
|
885
|
+
}, [...f[6] || (f[6] = [
|
|
886
|
+
ye('<svg viewBox="0 0 24 24" aria-hidden="true" data-v-c1436955><circle cx="12" cy="12" r="1" data-v-c1436955></circle><circle cx="12" cy="12" r="5" data-v-c1436955></circle><path d="M12 3v2" data-v-c1436955></path><path d="M3 12h2" data-v-c1436955></path><path d="M12 19v2" data-v-c1436955></path><path d="M19 12h2" data-v-c1436955></path></svg>', 1)
|
|
887
|
+
])]),
|
|
888
|
+
K("button", {
|
|
889
|
+
type: "button",
|
|
890
|
+
class: "board-selection-toolbar__button",
|
|
891
|
+
disabled: !P.value,
|
|
892
|
+
"aria-label": "Edit",
|
|
893
|
+
title: "Edit",
|
|
894
|
+
onClick: m
|
|
895
|
+
}, [...f[7] || (f[7] = [
|
|
896
|
+
K("svg", {
|
|
897
|
+
viewBox: "0 0 24 24",
|
|
898
|
+
"aria-hidden": "true"
|
|
899
|
+
}, [
|
|
900
|
+
K("path", { d: "M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4" }),
|
|
901
|
+
K("path", { d: "M13.5 6.5l4 4" })
|
|
902
|
+
], -1)
|
|
903
|
+
])], 8, Pt)
|
|
904
|
+
], 36)) : O("", !0);
|
|
905
|
+
}
|
|
906
|
+
}), Rt = /* @__PURE__ */ J(_t, [["__scopeId", "data-v-c1436955"]]), Ct = ["data-node-id"], Dt = /* @__PURE__ */ q({
|
|
907
|
+
__name: "BoardRoot",
|
|
908
|
+
props: {
|
|
909
|
+
engine: {
|
|
910
|
+
type: Object,
|
|
911
|
+
default: void 0
|
|
912
|
+
},
|
|
913
|
+
cullMargin: {
|
|
914
|
+
type: Number,
|
|
915
|
+
default: 200
|
|
916
|
+
},
|
|
917
|
+
grid: {
|
|
918
|
+
type: [Boolean, Object],
|
|
919
|
+
default: !0
|
|
920
|
+
},
|
|
921
|
+
selectionToolbar: {
|
|
922
|
+
type: Boolean,
|
|
923
|
+
default: !0
|
|
924
|
+
},
|
|
925
|
+
snapGuides: {
|
|
926
|
+
type: Boolean,
|
|
927
|
+
default: !0
|
|
928
|
+
},
|
|
929
|
+
boxSelect: {
|
|
930
|
+
type: Boolean,
|
|
931
|
+
default: !0
|
|
932
|
+
},
|
|
933
|
+
renderers: {
|
|
934
|
+
type: Object,
|
|
935
|
+
default: () => ({})
|
|
936
|
+
},
|
|
937
|
+
fallbackRenderer: {
|
|
938
|
+
type: Object,
|
|
939
|
+
default: null
|
|
940
|
+
}
|
|
941
|
+
},
|
|
942
|
+
emits: ["ready"],
|
|
943
|
+
setup(o, { emit: e }) {
|
|
944
|
+
const n = o, l = e, p = W(null), a = n.engine ?? Xe(), i = n.engine === void 0, u = G({}), y = G(a.$camera.get()), k = G(a.$grid.get()), r = G(
|
|
945
|
+
a.$nodes.get()
|
|
946
|
+
), b = G(a.$selection.get()), h = G(a.$interaction.get()), C = G(a.$snapGuides.get()), P = Ee(), D = W(!1), { viewportSize: M } = Ue({ rootElement: p, engine: a }), A = Ze({
|
|
947
|
+
grid: k,
|
|
948
|
+
gridProp: we(n, "grid")
|
|
949
|
+
});
|
|
950
|
+
je(He, {
|
|
951
|
+
engine: a,
|
|
952
|
+
rootElement: Y(p),
|
|
953
|
+
viewportSize: Y(M),
|
|
954
|
+
renderers: Y(u),
|
|
955
|
+
resolvedGrid: A,
|
|
956
|
+
toLocalPoint: le,
|
|
957
|
+
$camera: Y(y),
|
|
958
|
+
$grid: Y(k),
|
|
959
|
+
$nodes: Y(r),
|
|
960
|
+
$selection: Y(b),
|
|
961
|
+
$interaction: Y(h),
|
|
962
|
+
$snapGuides: Y(C)
|
|
963
|
+
});
|
|
964
|
+
let T = [], X = /* @__PURE__ */ new Set();
|
|
965
|
+
const N = I(() => {
|
|
966
|
+
const g = Array.from(b.value);
|
|
967
|
+
return g.length === T.length && g.every((S, d) => S === T[d]) || (T = g, X = new Set(g)), X;
|
|
968
|
+
}), m = et({
|
|
969
|
+
engine: a,
|
|
970
|
+
nodes: r,
|
|
971
|
+
camera: y,
|
|
972
|
+
selectionSet: N,
|
|
973
|
+
viewportSize: M,
|
|
974
|
+
cullMargin: we(n, "cullMargin")
|
|
975
|
+
}), _ = I(() => ({
|
|
976
|
+
camera: y.value,
|
|
977
|
+
grid: k.value,
|
|
978
|
+
nodes: r.value,
|
|
979
|
+
selection: b.value,
|
|
980
|
+
interaction: h.value,
|
|
981
|
+
snapGuides: C.value
|
|
982
|
+
})), s = I(() => ({
|
|
983
|
+
state: _.value,
|
|
984
|
+
camera: y.value,
|
|
985
|
+
grid: k.value,
|
|
986
|
+
selection: Array.from(b.value),
|
|
987
|
+
interaction: h.value,
|
|
988
|
+
visibleNodeCount: m.value.length,
|
|
989
|
+
trace: a.exportTrace().slice(-20)
|
|
990
|
+
}));
|
|
991
|
+
let f = [];
|
|
992
|
+
function B() {
|
|
993
|
+
y.value = a.$camera.get(), k.value = a.$grid.get(), r.value = a.$nodes.get(), b.value = a.$selection.get(), h.value = a.$interaction.get(), C.value = a.$snapGuides.get();
|
|
994
|
+
}
|
|
995
|
+
function V() {
|
|
996
|
+
f = [
|
|
997
|
+
a.$camera.subscribe((g) => {
|
|
998
|
+
y.value = g;
|
|
999
|
+
}),
|
|
1000
|
+
a.$grid.subscribe((g) => {
|
|
1001
|
+
k.value = g;
|
|
1002
|
+
}),
|
|
1003
|
+
a.$nodes.subscribe((g) => {
|
|
1004
|
+
r.value = g;
|
|
1005
|
+
}),
|
|
1006
|
+
a.$selection.subscribe((g) => {
|
|
1007
|
+
b.value = g;
|
|
1008
|
+
}),
|
|
1009
|
+
a.$interaction.subscribe((g) => {
|
|
1010
|
+
h.value = g;
|
|
1011
|
+
}),
|
|
1012
|
+
a.$snapGuides.subscribe((g) => {
|
|
1013
|
+
C.value = g;
|
|
1014
|
+
})
|
|
1015
|
+
], B();
|
|
1016
|
+
}
|
|
1017
|
+
ve(
|
|
1018
|
+
() => n.renderers,
|
|
1019
|
+
(g) => {
|
|
1020
|
+
u.value = Object.fromEntries(
|
|
1021
|
+
Object.entries(g).map(([S, d]) => [
|
|
1022
|
+
S,
|
|
1023
|
+
Me(d)
|
|
1024
|
+
])
|
|
1025
|
+
);
|
|
1026
|
+
},
|
|
1027
|
+
{ immediate: !0 }
|
|
1028
|
+
);
|
|
1029
|
+
function le(g, S) {
|
|
1030
|
+
const d = p.value?.getBoundingClientRect();
|
|
1031
|
+
return {
|
|
1032
|
+
x: g - (d?.left ?? 0),
|
|
1033
|
+
y: S - (d?.top ?? 0)
|
|
1034
|
+
};
|
|
1035
|
+
}
|
|
1036
|
+
const {
|
|
1037
|
+
onPointerDown: se,
|
|
1038
|
+
onPointerMove: t,
|
|
1039
|
+
onPointerUp: c,
|
|
1040
|
+
onPointerCancel: v,
|
|
1041
|
+
onWheel: E,
|
|
1042
|
+
onDoubleClick: R
|
|
1043
|
+
} = at({
|
|
1044
|
+
engine: a,
|
|
1045
|
+
rootElement: p,
|
|
1046
|
+
spacePressed: D,
|
|
1047
|
+
toLocalPoint: le
|
|
1048
|
+
}), { onKeyDown: j, onKeyUp: Q } = rt({
|
|
1049
|
+
engine: a,
|
|
1050
|
+
grid: k,
|
|
1051
|
+
rootElement: p,
|
|
1052
|
+
spacePressed: D
|
|
1053
|
+
});
|
|
1054
|
+
function oe(g) {
|
|
1055
|
+
return u.value[g.type] ?? n.fallbackRenderer;
|
|
1056
|
+
}
|
|
1057
|
+
function de(g) {
|
|
1058
|
+
return !!oe(g) || !!P[`node:${g.type}`] || !!P.node;
|
|
1059
|
+
}
|
|
1060
|
+
return be(() => {
|
|
1061
|
+
V(), l("ready", a);
|
|
1062
|
+
}), me(() => {
|
|
1063
|
+
for (const g of f)
|
|
1064
|
+
g();
|
|
1065
|
+
i && a.destroy();
|
|
1066
|
+
}), (g, S) => (x(), z("div", {
|
|
1067
|
+
ref_key: "rootElement",
|
|
1068
|
+
ref: p,
|
|
1069
|
+
class: "board-root",
|
|
1070
|
+
"data-board-root": "true",
|
|
1071
|
+
tabindex: "0",
|
|
1072
|
+
role: "application",
|
|
1073
|
+
"aria-label": "Board canvas",
|
|
1074
|
+
onPointerdown: S[0] || (S[0] = //@ts-ignore
|
|
1075
|
+
(...d) => w(se) && w(se)(...d)),
|
|
1076
|
+
onPointermove: S[1] || (S[1] = //@ts-ignore
|
|
1077
|
+
(...d) => w(t) && w(t)(...d)),
|
|
1078
|
+
onPointerup: S[2] || (S[2] = //@ts-ignore
|
|
1079
|
+
(...d) => w(c) && w(c)(...d)),
|
|
1080
|
+
onPointercancel: S[3] || (S[3] = //@ts-ignore
|
|
1081
|
+
(...d) => w(v) && w(v)(...d)),
|
|
1082
|
+
onWheel: S[4] || (S[4] = //@ts-ignore
|
|
1083
|
+
(...d) => w(E) && w(E)(...d)),
|
|
1084
|
+
onDblclick: S[5] || (S[5] = //@ts-ignore
|
|
1085
|
+
(...d) => w(R) && w(R)(...d)),
|
|
1086
|
+
onKeydown: S[6] || (S[6] = //@ts-ignore
|
|
1087
|
+
(...d) => w(j) && w(j)(...d)),
|
|
1088
|
+
onKeyup: S[7] || (S[7] = //@ts-ignore
|
|
1089
|
+
(...d) => w(Q) && w(Q)(...d))
|
|
1090
|
+
}, [
|
|
1091
|
+
o.grid !== !1 ? (x(), re(ut, { key: 0 })) : O("", !0),
|
|
1092
|
+
Be(Et, null, {
|
|
1093
|
+
default: ue(() => [
|
|
1094
|
+
L(g.$slots, "viewport", {
|
|
1095
|
+
engine: w(a),
|
|
1096
|
+
state: _.value
|
|
1097
|
+
}, void 0, !0),
|
|
1098
|
+
(x(!0), z(F, null, ge(w(m), (d) => (x(), z(F, {
|
|
1099
|
+
key: d.id
|
|
1100
|
+
}, [
|
|
1101
|
+
d.lod === "full" ? (x(), re(ht, {
|
|
1102
|
+
key: 0,
|
|
1103
|
+
node: d,
|
|
1104
|
+
selected: N.value.has(d.id),
|
|
1105
|
+
editing: h.value.mode === "editing-text" && h.value.nodeId === d.id,
|
|
1106
|
+
"custom-renderer": de(d)
|
|
1107
|
+
}, {
|
|
1108
|
+
default: ue((ne) => [
|
|
1109
|
+
L(g.$slots, `node:${d.type}`, ce({ ref_for: !0 }, ne), () => [
|
|
1110
|
+
L(g.$slots, "node", ce({ ref_for: !0 }, ne), () => [
|
|
1111
|
+
oe(d) ? (x(), re(Oe(oe(d)), ce({
|
|
1112
|
+
key: 0,
|
|
1113
|
+
ref_for: !0
|
|
1114
|
+
}, ne), null, 16)) : O("", !0)
|
|
1115
|
+
], !0)
|
|
1116
|
+
], !0)
|
|
1117
|
+
]),
|
|
1118
|
+
handle: ue((ne) => [
|
|
1119
|
+
L(g.$slots, "handle", ce({ ref_for: !0 }, ne), void 0, !0)
|
|
1120
|
+
]),
|
|
1121
|
+
_: 2
|
|
1122
|
+
}, 1032, ["node", "selected", "editing", "custom-renderer"])) : (x(), z("div", {
|
|
1123
|
+
key: 1,
|
|
1124
|
+
class: te(["board-node-simple", {
|
|
1125
|
+
"is-colored": !!d.color,
|
|
1126
|
+
"is-group": d.type === "group"
|
|
1127
|
+
}]),
|
|
1128
|
+
"data-node-id": d.id,
|
|
1129
|
+
style: Z({
|
|
1130
|
+
left: d.x + "px",
|
|
1131
|
+
top: d.y + "px",
|
|
1132
|
+
width: d.width + "px",
|
|
1133
|
+
height: d.height + "px",
|
|
1134
|
+
zIndex: d.zIndex,
|
|
1135
|
+
...w(Re)(d.color)
|
|
1136
|
+
})
|
|
1137
|
+
}, null, 14, Ct))
|
|
1138
|
+
], 64))), 128))
|
|
1139
|
+
]),
|
|
1140
|
+
_: 3
|
|
1141
|
+
}),
|
|
1142
|
+
o.selectionToolbar ? (x(), re(Rt, { key: 1 })) : O("", !0),
|
|
1143
|
+
o.snapGuides ? (x(), re($t, { key: 2 })) : O("", !0),
|
|
1144
|
+
o.boxSelect ? (x(), re(st, { key: 3 }, {
|
|
1145
|
+
default: ue((d) => [
|
|
1146
|
+
L(g.$slots, "box-select", ze(Ie(d)), void 0, !0)
|
|
1147
|
+
]),
|
|
1148
|
+
_: 3
|
|
1149
|
+
})) : O("", !0),
|
|
1150
|
+
L(g.$slots, "default", {
|
|
1151
|
+
engine: w(a),
|
|
1152
|
+
state: _.value,
|
|
1153
|
+
debugState: s.value
|
|
1154
|
+
}, void 0, !0)
|
|
1155
|
+
], 544));
|
|
1156
|
+
}
|
|
1157
|
+
}), Ot = /* @__PURE__ */ J(Dt, [["__scopeId", "data-v-931e1ec3"]]);
|
|
1158
|
+
export {
|
|
1159
|
+
Lt as BOARD_COLOR_PRESETS,
|
|
1160
|
+
st as BoardBoxSelect,
|
|
1161
|
+
ut as BoardGrid,
|
|
1162
|
+
ht as BoardNode,
|
|
1163
|
+
ft as BoardNodeHandle,
|
|
1164
|
+
Ot as BoardRoot,
|
|
1165
|
+
Rt as BoardSelectionToolbar,
|
|
1166
|
+
$t as BoardSnapGuides,
|
|
1167
|
+
Et as BoardViewport,
|
|
1168
|
+
Xt as colorForPreset,
|
|
1169
|
+
Re as resolveNodeColorStyle,
|
|
1170
|
+
Ve as useBoardBoxSelectBounds,
|
|
1171
|
+
Ge as useBoardCamera,
|
|
1172
|
+
ie as useBoardEngine,
|
|
1173
|
+
Fe as useBoardGridStyle,
|
|
1174
|
+
Ye as useBoardInteraction,
|
|
1175
|
+
Yt as useBoardNode,
|
|
1176
|
+
Ft as useBoardNodes,
|
|
1177
|
+
Gt as useBoardSelection,
|
|
1178
|
+
Ht as useBoardVisibleBounds,
|
|
1179
|
+
Ut as useBoardVisibleNodes
|
|
1180
|
+
};
|