spell-ui 0.8.12 → 0.8.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README-components.md +5 -3
- package/dist/{Dragging-B93hbRxF.js → Dragging-tHPSvf3G.js} +56 -13
- package/dist/Dragging-tHPSvf3G.js.map +1 -0
- package/dist/_spell-element/DOMElement.d.ts +8 -1
- package/dist/_spell-element/drawnWindow.d.ts +62 -0
- package/dist/_util/Dragging.d.ts +7 -0
- package/dist/components/components.types.d.ts +2 -0
- package/dist/components/ui-diagram/UIDiagram.d.ts +3 -0
- package/dist/components/ui-graph/GraphLayout.d.ts +54 -0
- package/dist/components/ui-graph/UIGraph.d.ts +355 -0
- package/dist/components/ui-graph/UIGraph.en.d.ts +137 -0
- package/dist/components/ui-graph/UIGraph.es.d.ts +48 -0
- package/dist/components/ui-graph/UIGraph.types.d.ts +193 -0
- package/dist/components/ui-graph/index.d.ts +5 -0
- package/dist/components/ui-json/UIJson.d.ts +275 -10
- package/dist/components/ui-json/UIJson.en.d.ts +148 -9
- package/dist/components/ui-json/UIJson.es.d.ts +34 -3
- package/dist/components/ui-json/index.d.ts +2 -2
- package/dist/components/ui-split-panel/UISplitPanel.d.ts +2 -16
- package/dist/components/ui-tree/UITree.d.ts +758 -26
- package/dist/components/ui-tree/UITree.en.d.ts +113 -3
- package/dist/components/ui-tree/UITree.es.d.ts +24 -0
- package/dist/components/ui-tree/UITree.types.d.ts +34 -0
- package/dist/components/ui-tree/UITreeItem.d.ts +40 -1
- package/dist/components/ui-tree/UITreeItem.en.d.ts +9 -0
- package/dist/components/ui-tree/UITreeItem.es.d.ts +2 -0
- package/dist/components/ui-tree/index.d.ts +3 -2
- package/dist/components/ui-tree-diagram/UITreeDiagram.d.ts +3 -0
- package/dist/{components.es-DEa8Ep42.js → components.es-DilRG1VO.js} +117 -9
- package/dist/components.es-DilRG1VO.js.map +1 -0
- package/dist/core.js +713 -671
- package/dist/core.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +97 -96
- package/dist/jsx.d.ts +489 -20
- package/dist/ui-diagram.js +2 -2
- package/dist/ui-diagram.js.map +1 -1
- package/dist/ui-graph.editor-DLsXPyby.js +5 -0
- package/dist/ui-graph.editor-DLsXPyby.js.map +1 -0
- package/dist/ui-graph.js +1295 -0
- package/dist/ui-graph.js.map +1 -0
- package/dist/ui-json.editor-BS-v1bqO.js +5 -0
- package/dist/ui-json.editor-BS-v1bqO.js.map +1 -0
- package/dist/ui-json.js +629 -32
- package/dist/ui-json.js.map +1 -1
- package/dist/ui-property-editor.js +3 -2
- package/dist/ui-property-editor.js.map +1 -1
- package/dist/ui-root.js +34 -3
- package/dist/ui-root.js.map +1 -1
- package/dist/ui-site-nav.js +4 -4
- package/dist/ui-site-nav.js.map +1 -1
- package/dist/ui-split-panel.js +31 -61
- package/dist/ui-split-panel.js.map +1 -1
- package/dist/ui-tree-diagram.js +1 -1
- package/dist/ui-tree-diagram.js.map +1 -1
- package/dist/ui-tree.editor-Bqsa0dYQ.js +5 -0
- package/dist/ui-tree.editor-Bqsa0dYQ.js.map +1 -0
- package/dist/ui-tree.js +1734 -237
- package/dist/ui-tree.js.map +1 -1
- package/dist/util/PaneSizes.d.ts +42 -0
- package/dist/util/index.d.ts +2 -0
- package/package.json +1 -1
- package/dist/Dragging-B93hbRxF.js.map +0 -1
- package/dist/components.es-DEa8Ep42.js.map +0 -1
- package/dist/ui-json.editor-BgZbrB_W.js +0 -5
- package/dist/ui-json.editor-BgZbrB_W.js.map +0 -1
- package/dist/ui-tree.editor-BoQztwdz.js +0 -5
- package/dist/ui-tree.editor-BoQztwdz.js.map +0 -1
package/dist/ui-graph.js
ADDED
|
@@ -0,0 +1,1295 @@
|
|
|
1
|
+
import "./rolldown-runtime-c6e9CmGy.js";
|
|
2
|
+
import { DOMElement as e, F as t, Gt as n, Jt as r, Kt as i, UIComponent as a, Ut as o, Warnings as s, Wt as c, Yt as l, cssState as u, derived as d, lazy as f, on as p, onChange as m, proto as h, protoMerged as g, qt as _, soon as ee, state as v, untracked as y, whileConnected as te } from "./core.js";
|
|
3
|
+
import { t as ne } from "./TreeMeasure-BK74uexu.js";
|
|
4
|
+
import "./ui-modal.js";
|
|
5
|
+
import "./ui-breadcrumbs.js";
|
|
6
|
+
import { For as b, Show as x } from "solid-js";
|
|
7
|
+
import { addEvent as S, className as C, createComponent as w, delegateEvents as re, effect as T, getOwner as E, insert as D, isServer as ie, memo as ae, readShallow as O, ref as k, setAttribute as A, template as j } from "@solidjs/web";
|
|
8
|
+
// src/components/ui-graph/UIGraph.types.ts
|
|
9
|
+
var oe = [
|
|
10
|
+
"left",
|
|
11
|
+
"right",
|
|
12
|
+
"top",
|
|
13
|
+
"bottom"
|
|
14
|
+
], M = [
|
|
15
|
+
"inline",
|
|
16
|
+
"modal",
|
|
17
|
+
"drill"
|
|
18
|
+
], N = {
|
|
19
|
+
fontSize: 12,
|
|
20
|
+
portFontSize: 10,
|
|
21
|
+
charWidth: .6,
|
|
22
|
+
paddingX: 12,
|
|
23
|
+
nodeHeight: 32,
|
|
24
|
+
minNodeWidth: 48,
|
|
25
|
+
portSpacing: 18,
|
|
26
|
+
portRadius: 3.5,
|
|
27
|
+
layerGap: 56,
|
|
28
|
+
nodeGap: 18,
|
|
29
|
+
headerHeight: 26,
|
|
30
|
+
containerPadding: 14,
|
|
31
|
+
toggleWidth: 18,
|
|
32
|
+
margin: 24
|
|
33
|
+
}, P = class GraphLayout {
|
|
34
|
+
static of(e, t = {}) {
|
|
35
|
+
let n = new GraphLayout(t), r = t.prefix ?? "", i = n.level(e, r, t.boundary ?? []), a = [], o = [], { margin: s } = n.metrics;
|
|
36
|
+
n.flatten(i, s, s, 0, a, o);
|
|
37
|
+
let c = i.pins.map((e) => ({
|
|
38
|
+
port: e.port,
|
|
39
|
+
side: e.side,
|
|
40
|
+
path: `${r}:${e.port.id}`,
|
|
41
|
+
x: e.x + s,
|
|
42
|
+
y: e.y + s
|
|
43
|
+
}));
|
|
44
|
+
return {
|
|
45
|
+
width: i.width + 2 * s,
|
|
46
|
+
height: i.height + 2 * s,
|
|
47
|
+
nodes: a,
|
|
48
|
+
edges: o,
|
|
49
|
+
pins: c
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
static pathFor(e) {
|
|
53
|
+
let { points: t, fromSide: n, toSide: r } = e;
|
|
54
|
+
if (t.length < 2) return "";
|
|
55
|
+
let i = `M${round(t[0].x)} ${round(t[0].y)}`;
|
|
56
|
+
for (let e = 1; e < t.length; e++) {
|
|
57
|
+
let a = t[e - 1], o = t[e], s = Math.max(16, Math.abs(o.x - a.x) / 2, Math.abs(o.y - a.y) / 4), c = Math.sign(o.x - a.x) || 1, [l, u] = e === 1 ? GraphLayout.toward(a, n, s) : [a.x + c * s, a.y], [d, f] = e === t.length - 1 ? GraphLayout.toward(o, r, s) : [o.x - c * s, o.y];
|
|
58
|
+
i += `C${round(l)} ${round(u)} ${round(d)} ${round(f)} ${round(o.x)} ${round(o.y)}`;
|
|
59
|
+
}
|
|
60
|
+
return i;
|
|
61
|
+
}
|
|
62
|
+
static toward(e, t, n) {
|
|
63
|
+
switch (t) {
|
|
64
|
+
case "left": return [e.x - n, e.y];
|
|
65
|
+
case "right": return [e.x + n, e.y];
|
|
66
|
+
case "top": return [e.x, e.y - n];
|
|
67
|
+
case "bottom": return [e.x, e.y + n];
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
static middleOf(e) {
|
|
71
|
+
let { points: t } = e;
|
|
72
|
+
if (t.length % 2 == 1) return t[(t.length - 1) / 2];
|
|
73
|
+
let n = t[t.length / 2 - 1], r = t[t.length / 2];
|
|
74
|
+
return {
|
|
75
|
+
x: (n.x + r.x) / 2,
|
|
76
|
+
y: (n.y + r.y) / 2
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
static sideOf(e, t) {
|
|
80
|
+
if (e.side) return e.side;
|
|
81
|
+
let n = e.kind?.toLowerCase();
|
|
82
|
+
return n === "in" || n === "input" ? "left" : n === "out" || n === "output" || !t ? "right" : t.asTarget > t.asSource ? "left" : "right";
|
|
83
|
+
}
|
|
84
|
+
metrics;
|
|
85
|
+
options;
|
|
86
|
+
constructor(e) {
|
|
87
|
+
this.options = e, this.metrics = e.metrics ?? N;
|
|
88
|
+
}
|
|
89
|
+
textWidth(e, t) {
|
|
90
|
+
return this.options.textWidth?.(e, t) ?? e.length * t * this.metrics.charWidth;
|
|
91
|
+
}
|
|
92
|
+
labelOf(e) {
|
|
93
|
+
return this.options.label?.(e) ?? e.label ?? e.id;
|
|
94
|
+
}
|
|
95
|
+
level(e, t, n, r) {
|
|
96
|
+
let i = this.metrics, a = e.nodes ?? [], o = /* @__PURE__ */ new Map(), s = [], c = e.edges ?? [], l = /* @__PURE__ */ new Map(), vote = (e, t) => {
|
|
97
|
+
if (e.port === void 0) return;
|
|
98
|
+
let n = `${e.node ?? ""}:${e.port}`, r = l.get(n) ?? {
|
|
99
|
+
asSource: 0,
|
|
100
|
+
asTarget: 0
|
|
101
|
+
};
|
|
102
|
+
r[t]++, l.set(n, r);
|
|
103
|
+
};
|
|
104
|
+
for (let e of c) vote(e.from, "asSource"), vote(e.to, "asTarget");
|
|
105
|
+
for (let e of a) {
|
|
106
|
+
if (!e || typeof e.id != "string" || o.has(e.id)) continue;
|
|
107
|
+
let n = t ? `${t}/${e.id}` : e.id, r = this.box(e, n, (t) => GraphLayout.sideOf(t, l.get(`${e.id}:${t.id}`)));
|
|
108
|
+
o.set(e.id, r), s.push(r);
|
|
109
|
+
}
|
|
110
|
+
let u = /* @__PURE__ */ new Map();
|
|
111
|
+
for (let e of n) {
|
|
112
|
+
let t = l.get(`:${e.id}`), n = r?.get(e) ?? GraphLayout.sideOf(e, t && flip(t)), a = {
|
|
113
|
+
kind: "pin",
|
|
114
|
+
width: 0,
|
|
115
|
+
height: i.portSpacing,
|
|
116
|
+
layer: 0,
|
|
117
|
+
order: 0,
|
|
118
|
+
x: 0,
|
|
119
|
+
y: 0,
|
|
120
|
+
ports: [],
|
|
121
|
+
pin: {
|
|
122
|
+
port: e,
|
|
123
|
+
side: n === "left" || n === "top" ? "left" : "right"
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
u.set(e.id, a), s.push(a);
|
|
127
|
+
}
|
|
128
|
+
let d = [];
|
|
129
|
+
c.forEach((e, n) => {
|
|
130
|
+
if (!e?.from || !e?.to) return;
|
|
131
|
+
let r = this.endOf(e.from, "from", o, u, t), i = this.endOf(e.to, "to", o, u, t);
|
|
132
|
+
if (!r || !i) return;
|
|
133
|
+
let a = e.id ?? `#${n}`;
|
|
134
|
+
d.push({
|
|
135
|
+
edge: e,
|
|
136
|
+
id: a,
|
|
137
|
+
from: r,
|
|
138
|
+
to: i,
|
|
139
|
+
reversed: !1,
|
|
140
|
+
chain: []
|
|
141
|
+
});
|
|
142
|
+
}), this.assignLayers(s, d);
|
|
143
|
+
let f = Math.max(0, ...s.map((e) => e.layer)) + 1;
|
|
144
|
+
for (let e of d) {
|
|
145
|
+
let [t, n] = e.reversed ? [e.to, e.from] : [e.from, e.to];
|
|
146
|
+
e.chain = [t.unit];
|
|
147
|
+
for (let r = t.unit.layer + 1; r < n.unit.layer; r++) {
|
|
148
|
+
let t = {
|
|
149
|
+
kind: "dummy",
|
|
150
|
+
width: 0,
|
|
151
|
+
height: 4,
|
|
152
|
+
layer: r,
|
|
153
|
+
order: 0,
|
|
154
|
+
x: 0,
|
|
155
|
+
y: 0,
|
|
156
|
+
ports: []
|
|
157
|
+
};
|
|
158
|
+
s.push(t), e.chain.push(t);
|
|
159
|
+
}
|
|
160
|
+
e.chain.push(n.unit);
|
|
161
|
+
}
|
|
162
|
+
let p = Array.from({ length: f }, () => []);
|
|
163
|
+
for (let e of s) p[e.layer].push(e);
|
|
164
|
+
p.forEach((e) => e.forEach((e, t) => e.order = t));
|
|
165
|
+
for (let e of d) {
|
|
166
|
+
let [t, n] = e.reversed ? [e.to, e.from] : [e.from, e.to];
|
|
167
|
+
for (let r = 0; r + 1 < e.chain.length; r++) {
|
|
168
|
+
let i = e.chain[r], a = e.chain[r + 1];
|
|
169
|
+
if (i.layer === a.layer) continue;
|
|
170
|
+
let o = r === 0 ? t.dy : i.height / 2, s = r + 1 === e.chain.length - 1 ? n.dy : a.height / 2;
|
|
171
|
+
(i.down ??= []).push({
|
|
172
|
+
unit: a,
|
|
173
|
+
mine: o,
|
|
174
|
+
theirs: s
|
|
175
|
+
}), (a.up ??= []).push({
|
|
176
|
+
unit: i,
|
|
177
|
+
mine: s,
|
|
178
|
+
theirs: o
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
this.order(p);
|
|
183
|
+
let { width: m, height: h } = this.place(p, d), g = [];
|
|
184
|
+
for (let e of d) {
|
|
185
|
+
let [t, n] = e.reversed ? [e.to, e.from] : [e.from, e.to], r = [{
|
|
186
|
+
x: t.unit.x + t.dx,
|
|
187
|
+
y: t.unit.y + t.dy
|
|
188
|
+
}];
|
|
189
|
+
for (let t = 1; t < e.chain.length - 1; t++) {
|
|
190
|
+
let n = e.chain[t];
|
|
191
|
+
r.push({
|
|
192
|
+
x: n.x,
|
|
193
|
+
y: n.y + n.height / 2
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
r.push({
|
|
197
|
+
x: n.unit.x + n.dx,
|
|
198
|
+
y: n.unit.y + n.dy
|
|
199
|
+
}), e.reversed && r.reverse(), g.push({
|
|
200
|
+
edge: e.edge,
|
|
201
|
+
id: e.id,
|
|
202
|
+
points: r,
|
|
203
|
+
fromSide: e.from.side,
|
|
204
|
+
toSide: e.to.side,
|
|
205
|
+
fromPath: e.from.path,
|
|
206
|
+
toPath: e.to.path,
|
|
207
|
+
fromPin: e.from.unit.kind === "pin" ? e.from.unit.pin.port.id : void 0,
|
|
208
|
+
toPin: e.to.unit.kind === "pin" ? e.to.unit.pin.port.id : void 0
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
let _ = [...u.values()].map((e) => ({
|
|
212
|
+
port: e.pin.port,
|
|
213
|
+
side: e.pin.side,
|
|
214
|
+
x: e.pin.side === "left" ? 0 : m,
|
|
215
|
+
y: e.y + e.height / 2
|
|
216
|
+
}));
|
|
217
|
+
return {
|
|
218
|
+
width: m,
|
|
219
|
+
height: h,
|
|
220
|
+
units: s.filter((e) => e.kind === "node"),
|
|
221
|
+
edges: g,
|
|
222
|
+
pins: _,
|
|
223
|
+
prefix: t
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
box(e, t, n) {
|
|
227
|
+
let r = this.metrics, i = this.labelOf(e), a = (e.ports ?? []).filter((e) => e && typeof e.id == "string"), o = new Map(a.map((e) => [e, n(e)])), on = (e) => a.filter((t) => o.get(t) === e), portLabelWidth = (e) => Math.max(0, ...on(e).map((e) => e.label ? this.textWidth(e.label, r.portFontSize) + 6 : 0)), s = e.children !== void 0, c = this.options.openChildren?.get(t), l = this.textWidth(i, r.fontSize) + 2 * r.paddingX + (s ? r.toggleWidth : 0), u = {
|
|
228
|
+
kind: "node",
|
|
229
|
+
node: e,
|
|
230
|
+
path: t,
|
|
231
|
+
width: 0,
|
|
232
|
+
height: 0,
|
|
233
|
+
layer: 0,
|
|
234
|
+
order: 0,
|
|
235
|
+
x: 0,
|
|
236
|
+
y: 0,
|
|
237
|
+
ports: [],
|
|
238
|
+
hasChildren: s,
|
|
239
|
+
isLoading: this.options.loading?.has(t)
|
|
240
|
+
};
|
|
241
|
+
if (c) {
|
|
242
|
+
let e = this.level(c, t, a, o);
|
|
243
|
+
u.child = e, u.width = Math.max(l, e.width + 2 * r.containerPadding), u.height = r.headerHeight + e.height + r.containerPadding;
|
|
244
|
+
let n = (u.width - e.width) / 2;
|
|
245
|
+
for (let t of e.pins) {
|
|
246
|
+
let e = t.side;
|
|
247
|
+
u.ports.push({
|
|
248
|
+
port: t.port,
|
|
249
|
+
side: e,
|
|
250
|
+
dx: e === "left" ? 0 : u.width,
|
|
251
|
+
dy: r.headerHeight + t.y
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
return u.childOffset = {
|
|
255
|
+
x: n,
|
|
256
|
+
y: r.headerHeight
|
|
257
|
+
}, this.spread(u, on("top"), "top"), this.spread(u, on("bottom"), "bottom"), u;
|
|
258
|
+
}
|
|
259
|
+
let d = Math.max(on("left").length, on("right").length), f = Math.max(on("top").length, on("bottom").length);
|
|
260
|
+
u.height = Math.max(r.nodeHeight, (d + 1) * r.portSpacing), u.width = Math.max(r.minNodeWidth, l + portLabelWidth("left") + portLabelWidth("right"), (f + 1) * r.portSpacing);
|
|
261
|
+
for (let e of [
|
|
262
|
+
"left",
|
|
263
|
+
"right",
|
|
264
|
+
"top",
|
|
265
|
+
"bottom"
|
|
266
|
+
]) this.spread(u, on(e), e);
|
|
267
|
+
return u;
|
|
268
|
+
}
|
|
269
|
+
spread(e, t, n) {
|
|
270
|
+
t.forEach((r, i) => {
|
|
271
|
+
let a = (i + 1) / (t.length + 1);
|
|
272
|
+
n === "left" || n === "right" ? e.ports.push({
|
|
273
|
+
port: r,
|
|
274
|
+
side: n,
|
|
275
|
+
dx: n === "left" ? 0 : e.width,
|
|
276
|
+
dy: a * e.height
|
|
277
|
+
}) : e.ports.push({
|
|
278
|
+
port: r,
|
|
279
|
+
side: n,
|
|
280
|
+
dx: a * e.width,
|
|
281
|
+
dy: n === "top" ? 0 : e.height
|
|
282
|
+
});
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
endOf(e, t, n, r, i) {
|
|
286
|
+
if (!e.node) {
|
|
287
|
+
let t = e.port === void 0 ? void 0 : r.get(e.port);
|
|
288
|
+
return t ? {
|
|
289
|
+
unit: t,
|
|
290
|
+
dx: 0,
|
|
291
|
+
dy: t.height / 2,
|
|
292
|
+
side: t.pin.side === "left" ? "right" : "left",
|
|
293
|
+
path: `${i}:${e.port}`
|
|
294
|
+
} : void 0;
|
|
295
|
+
}
|
|
296
|
+
let a = n.get(e.node);
|
|
297
|
+
if (!a) return;
|
|
298
|
+
let o = e.port === void 0 ? void 0 : a.ports.find((t) => t.port.id === e.port);
|
|
299
|
+
return o ? {
|
|
300
|
+
unit: a,
|
|
301
|
+
dx: o.dx,
|
|
302
|
+
dy: o.dy,
|
|
303
|
+
side: o.side,
|
|
304
|
+
path: `${a.path}:${o.port.id}`
|
|
305
|
+
} : t === "from" ? {
|
|
306
|
+
unit: a,
|
|
307
|
+
dx: a.width,
|
|
308
|
+
dy: a.height / 2,
|
|
309
|
+
side: "right",
|
|
310
|
+
path: a.path
|
|
311
|
+
} : {
|
|
312
|
+
unit: a,
|
|
313
|
+
dx: 0,
|
|
314
|
+
dy: a.height / 2,
|
|
315
|
+
side: "left",
|
|
316
|
+
path: a.path
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
assignLayers(e, t) {
|
|
320
|
+
let n = e.filter((e) => e.kind === "node"), r = new Map(n.map((e) => [e, []])), i = new Map(n.map((e) => [e, 0])), a = t.filter((e) => e.from.unit.kind === "node" && e.to.unit.kind === "node");
|
|
321
|
+
for (let e of a) r.get(e.from.unit).push(e);
|
|
322
|
+
let o = /* @__PURE__ */ new Map();
|
|
323
|
+
for (let e of n) {
|
|
324
|
+
if (o.has(e)) continue;
|
|
325
|
+
let t = [[e, 0]];
|
|
326
|
+
o.set(e, 1);
|
|
327
|
+
let outs = (e) => r.get(e);
|
|
328
|
+
for (; t.length;) {
|
|
329
|
+
let e = t[t.length - 1], n = outs(e[0]);
|
|
330
|
+
if (e[1] >= n.length) {
|
|
331
|
+
o.set(e[0], 2), t.pop();
|
|
332
|
+
continue;
|
|
333
|
+
}
|
|
334
|
+
let r = n[e[1]++], i = r.to.unit;
|
|
335
|
+
if (i === e[0]) continue;
|
|
336
|
+
let a = o.get(i);
|
|
337
|
+
a === 1 ? r.reversed = !0 : a || (o.set(i, 1), t.push([i, 0]));
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
let s = new Map(n.map((e) => [e, []])), c = new Map(n.map((e) => [e, []]));
|
|
341
|
+
for (let e of a) {
|
|
342
|
+
let [t, n] = e.reversed ? [e.to.unit, e.from.unit] : [e.from.unit, e.to.unit];
|
|
343
|
+
t !== n && (s.get(t).push(n), c.get(n).push(t), i.set(n, i.get(n) + 1));
|
|
344
|
+
}
|
|
345
|
+
let l = n.filter((e) => i.get(e) === 0), u = [];
|
|
346
|
+
for (let e = 0; e < l.length; e++) {
|
|
347
|
+
let t = l[e];
|
|
348
|
+
u.push(t);
|
|
349
|
+
for (let e of s.get(t)) e.layer = Math.max(e.layer, t.layer + 1), i.set(e, i.get(e) - 1), i.get(e) === 0 && l.push(e);
|
|
350
|
+
}
|
|
351
|
+
for (let e = u.length - 1; e >= 0; e--) {
|
|
352
|
+
let t = u[e], n = s.get(t);
|
|
353
|
+
c.get(t).length === 0 && n.length && (t.layer = Math.max(t.layer, Math.min(...n.map((e) => e.layer)) - 1));
|
|
354
|
+
}
|
|
355
|
+
let d = e.filter((e) => e.kind === "pin");
|
|
356
|
+
if (d.some((e) => e.pin.side === "left")) for (let e of n) e.layer++;
|
|
357
|
+
let f = Math.max(0, ...n.map((e) => e.layer));
|
|
358
|
+
for (let e of d) e.layer = e.pin.side === "left" ? 0 : f + +!!n.length;
|
|
359
|
+
for (let e of t) (e.from.unit.kind === "pin" || e.to.unit.kind === "pin") && (e.reversed = e.from.unit.layer > e.to.unit.layer);
|
|
360
|
+
}
|
|
361
|
+
order(e) {
|
|
362
|
+
let position = (e, t) => e.order + t / Math.max(1, e.height), sweep = (e, t) => {
|
|
363
|
+
let n = /* @__PURE__ */ new Map();
|
|
364
|
+
for (let r of e) {
|
|
365
|
+
let e = r[t];
|
|
366
|
+
e?.length ? n.set(r, e.reduce((e, t) => e + position(t.unit, t.theirs), 0) / e.length) : n.set(r, r.order);
|
|
367
|
+
}
|
|
368
|
+
e.sort((e, t) => n.get(e) - n.get(t) || e.order - t.order), e.forEach((e, t) => e.order = t);
|
|
369
|
+
};
|
|
370
|
+
for (let t = 0; t < 6; t++) if (t % 2 == 0) for (let t = 1; t < e.length; t++) sweep(e[t], "up");
|
|
371
|
+
else for (let t = e.length - 2; t >= 0; t--) sweep(e[t], "down");
|
|
372
|
+
}
|
|
373
|
+
place(e, t) {
|
|
374
|
+
let n = this.metrics, gapAfter = (e) => e.kind === "dummy" ? 6 : n.nodeGap, r = Array(e.length).fill(0);
|
|
375
|
+
for (let e of t) for (let t = 0; t + 1 < e.chain.length; t++) r[e.chain[t].layer]++;
|
|
376
|
+
let i = 0;
|
|
377
|
+
e.forEach((e, t) => {
|
|
378
|
+
let a = Math.max(0, ...e.map((e) => e.width));
|
|
379
|
+
for (let t of e) t.x = i + (a - t.width) / 2;
|
|
380
|
+
i += a + n.layerGap + Math.min(60, Math.sqrt(r[t]) * 4);
|
|
381
|
+
});
|
|
382
|
+
for (let t of e) {
|
|
383
|
+
let e = 0;
|
|
384
|
+
for (let n of t) n.y = e, e += n.height + gapAfter(n);
|
|
385
|
+
}
|
|
386
|
+
let a = Math.max(0, ...e.map((e) => e.reduce((e, t) => e + t.height + gapAfter(t), 0)));
|
|
387
|
+
for (let t of e) {
|
|
388
|
+
let e = t.reduce((e, t) => e + t.height + gapAfter(t), 0);
|
|
389
|
+
for (let n of t) n.y += (a - e) / 2;
|
|
390
|
+
}
|
|
391
|
+
let pull = (e, t) => {
|
|
392
|
+
let n = e.map((e) => {
|
|
393
|
+
let n = [...e[t] ?? [], ...e[t === "up" ? "down" : "up"] ?? []];
|
|
394
|
+
return n.length ? n.reduce((e, t) => e + t.unit.y + t.theirs - t.mine, 0) / n.length : e.y;
|
|
395
|
+
});
|
|
396
|
+
GraphLayout.separate(e, n, gapAfter);
|
|
397
|
+
};
|
|
398
|
+
for (let t = 0; t < 8; t++) if (t % 2 == 0) for (let t = 1; t < e.length; t++) pull(e[t], "up");
|
|
399
|
+
else for (let t = e.length - 2; t >= 0; t--) pull(e[t], "down");
|
|
400
|
+
let o = e.flat(), s = Math.min(0, ...o.map((e) => e.y));
|
|
401
|
+
for (let e of o) e.y -= s;
|
|
402
|
+
return {
|
|
403
|
+
width: Math.max(0, ...o.map((e) => e.x + e.width)),
|
|
404
|
+
height: Math.max(0, ...o.map((e) => e.y + e.height))
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
static separate(e, t, n) {
|
|
408
|
+
let r = [];
|
|
409
|
+
e.forEach((e, i) => {
|
|
410
|
+
let a = e.height + n(e), o = {
|
|
411
|
+
start: i,
|
|
412
|
+
end: i,
|
|
413
|
+
top: t[i],
|
|
414
|
+
height: a,
|
|
415
|
+
weight: 1,
|
|
416
|
+
sum: t[i]
|
|
417
|
+
};
|
|
418
|
+
for (; r.length;) {
|
|
419
|
+
let e = r[r.length - 1];
|
|
420
|
+
if (e.top + e.height <= o.top) break;
|
|
421
|
+
r.pop();
|
|
422
|
+
let t = e.sum + o.sum - o.weight * e.height, n = e.weight + o.weight;
|
|
423
|
+
o = {
|
|
424
|
+
start: e.start,
|
|
425
|
+
end: o.end,
|
|
426
|
+
top: t / n,
|
|
427
|
+
height: e.height + o.height,
|
|
428
|
+
weight: n,
|
|
429
|
+
sum: t
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
r.push(o);
|
|
433
|
+
});
|
|
434
|
+
for (let t of r) {
|
|
435
|
+
let r = t.top;
|
|
436
|
+
for (let i = t.start; i <= t.end; i++) e[i].y = r, r += e[i].height + n(e[i]);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
flatten(e, t, n, r, i, a, o) {
|
|
440
|
+
for (let o of e.units) {
|
|
441
|
+
let e = t + o.x, s = n + o.y, c = o.ports.map((t) => ({
|
|
442
|
+
port: t.port,
|
|
443
|
+
side: t.side,
|
|
444
|
+
path: `${o.path}:${t.port.id}`,
|
|
445
|
+
x: e + t.dx,
|
|
446
|
+
y: s + t.dy
|
|
447
|
+
}));
|
|
448
|
+
i.push({
|
|
449
|
+
node: o.node,
|
|
450
|
+
path: o.path,
|
|
451
|
+
depth: r,
|
|
452
|
+
x: e,
|
|
453
|
+
y: s,
|
|
454
|
+
width: o.width,
|
|
455
|
+
height: o.height,
|
|
456
|
+
ports: c,
|
|
457
|
+
hasChildren: !!o.hasChildren,
|
|
458
|
+
isOpen: !!o.child,
|
|
459
|
+
isLoading: o.isLoading
|
|
460
|
+
}), o.child && o.childOffset && this.flatten(o.child, e + o.childOffset.x, s + o.childOffset.y, r + 1, i, a, {
|
|
461
|
+
unit: o,
|
|
462
|
+
x: e,
|
|
463
|
+
y: s
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
let s = e.prefix;
|
|
467
|
+
for (let i of e.edges) {
|
|
468
|
+
let e = i.points.map((e) => ({
|
|
469
|
+
x: e.x + t,
|
|
470
|
+
y: e.y + n
|
|
471
|
+
}));
|
|
472
|
+
if (o) {
|
|
473
|
+
let portAt = (e) => o.unit.ports.find((t) => t.port.id === e), t = i.fromPin === void 0 ? void 0 : portAt(i.fromPin), n = i.toPin === void 0 ? void 0 : portAt(i.toPin);
|
|
474
|
+
t && e.unshift({
|
|
475
|
+
x: o.x + t.dx,
|
|
476
|
+
y: o.y + t.dy
|
|
477
|
+
}), n && e.push({
|
|
478
|
+
x: o.x + n.dx,
|
|
479
|
+
y: o.y + n.dy
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
a.push({
|
|
483
|
+
edge: i.edge,
|
|
484
|
+
id: i.id,
|
|
485
|
+
path: `${s}#${i.id}`,
|
|
486
|
+
fromPath: i.fromPath,
|
|
487
|
+
toPath: i.toPath,
|
|
488
|
+
points: e,
|
|
489
|
+
fromSide: o && i.fromPin !== void 0 ? "right" : i.fromSide,
|
|
490
|
+
toSide: o && i.toPin !== void 0 ? "left" : i.toSide,
|
|
491
|
+
depth: r
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
};
|
|
496
|
+
function flip(e) {
|
|
497
|
+
return {
|
|
498
|
+
asSource: e.asTarget,
|
|
499
|
+
asTarget: e.asSource
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
function round(e) {
|
|
503
|
+
return Math.round(e * 10) / 10;
|
|
504
|
+
}
|
|
505
|
+
// src/components/ui-graph/UIGraph.en.ts
|
|
506
|
+
var se = {
|
|
507
|
+
tag: "ui-graph",
|
|
508
|
+
icon: "project diagram",
|
|
509
|
+
topics: [
|
|
510
|
+
"data display",
|
|
511
|
+
"images",
|
|
512
|
+
"views"
|
|
513
|
+
],
|
|
514
|
+
aka: [
|
|
515
|
+
"graph",
|
|
516
|
+
"node graph",
|
|
517
|
+
"network diagram",
|
|
518
|
+
"flow chart",
|
|
519
|
+
"dataflow",
|
|
520
|
+
"netlist",
|
|
521
|
+
"schematic",
|
|
522
|
+
"block diagram",
|
|
523
|
+
"DAG"
|
|
524
|
+
],
|
|
525
|
+
skeleton: "16 tall",
|
|
526
|
+
noun: "graph",
|
|
527
|
+
description: "A graph draws nodes joined by edges, laid out left to right. A node may hold a graph of its own, opened in place, in a modal, or in its stead.",
|
|
528
|
+
attributes: [
|
|
529
|
+
{
|
|
530
|
+
name: "graph",
|
|
531
|
+
group: "content",
|
|
532
|
+
kind: "json",
|
|
533
|
+
reflect: !1,
|
|
534
|
+
description: "The graph to draw, a `GraphData`: `nodes` (`id`, `label`, `kind`, `ports`, `children`, `data`) and `edges` (`from` / `to` `{ node, port }`). An end with no `node` is the enclosing node's port. A JS property (JSON in the attribute); set a NEW graph to redraw."
|
|
535
|
+
},
|
|
536
|
+
{
|
|
537
|
+
name: "child-view",
|
|
538
|
+
group: "behaviour",
|
|
539
|
+
kind: "enum",
|
|
540
|
+
values: M,
|
|
541
|
+
default: "inline",
|
|
542
|
+
description: "How a node's children show when it's opened: `inline`, inside the node, which grows round them; `modal`, a graph in a modal; `drill`, the graph replaced by them, with breadcrumbs back. A node's own `childView` wins."
|
|
543
|
+
},
|
|
544
|
+
{
|
|
545
|
+
name: "path",
|
|
546
|
+
group: "behaviour",
|
|
547
|
+
kind: "string",
|
|
548
|
+
default: "",
|
|
549
|
+
description: "The node whose child graph is shown, drilled to, by its ids from the top joined by `/` (`cpu/alu`); `\"\"`: the top. Setting it drills there, loading lazy children on the way; drilling and the breadcrumbs set it back, with `ui-changed` `{ kind: 'path', path }`."
|
|
550
|
+
},
|
|
551
|
+
{
|
|
552
|
+
name: "selected",
|
|
553
|
+
group: "states",
|
|
554
|
+
kind: "json",
|
|
555
|
+
reflect: !1,
|
|
556
|
+
description: "PROPERTY: what's selected, `{ kind: 'node' | 'edge' | 'port', id, path }`; `undefined`: nothing. Clicks set it."
|
|
557
|
+
},
|
|
558
|
+
{
|
|
559
|
+
name: "boundary",
|
|
560
|
+
group: "content",
|
|
561
|
+
kind: "json",
|
|
562
|
+
reflect: !1,
|
|
563
|
+
description: "PROPERTY: the enclosing node's ports, drawn as pins on the graph's sides, for edges with no `node`. Set by a modal's graph; a page rarely needs it."
|
|
564
|
+
}
|
|
565
|
+
],
|
|
566
|
+
events: [
|
|
567
|
+
{
|
|
568
|
+
name: "ui-selecting",
|
|
569
|
+
cancelable: !0,
|
|
570
|
+
detail: "{ kind: 'node' | 'edge' | 'port', id: string, path: string, item: object, originalEvent?: Event }",
|
|
571
|
+
description: "A node, edge or port is about to be selected by a click: cancel it to keep the selection."
|
|
572
|
+
},
|
|
573
|
+
{
|
|
574
|
+
name: "ui-changed",
|
|
575
|
+
detail: "{ value: { kind: string, id: string, path: string } | undefined, kind?: string, id?: string, path?: string, item?: object, originalEvent?: Event } | { kind: 'path', path: string, originalEvent?: Event }",
|
|
576
|
+
description: "What's selected changed: `value` is the new `selected`; `item` the node, edge or port itself. ALSO when the graph shown changes by a drill or a breadcrumb: `{ kind: 'path', path }` (`path` the new `path`), so one listener keeps a page in step with both."
|
|
577
|
+
},
|
|
578
|
+
{
|
|
579
|
+
name: "ui-node-toggled",
|
|
580
|
+
detail: "{ node: object, path: string, open: boolean, view: 'inline' | 'modal' | 'drill', originalEvent?: Event }",
|
|
581
|
+
description: "A node with children was opened or closed, by a person or by `open()` / `close()`."
|
|
582
|
+
}
|
|
583
|
+
],
|
|
584
|
+
slots: [],
|
|
585
|
+
parts: [
|
|
586
|
+
{
|
|
587
|
+
name: "graph",
|
|
588
|
+
description: "The box round it all."
|
|
589
|
+
},
|
|
590
|
+
{
|
|
591
|
+
name: "canvas",
|
|
592
|
+
description: "The `<svg>`."
|
|
593
|
+
},
|
|
594
|
+
{
|
|
595
|
+
name: "node",
|
|
596
|
+
description: "Each node's `<g>`."
|
|
597
|
+
},
|
|
598
|
+
{
|
|
599
|
+
name: "container",
|
|
600
|
+
description: "A node opened in place, its child graph inside; also part `node`."
|
|
601
|
+
},
|
|
602
|
+
{
|
|
603
|
+
name: "edge",
|
|
604
|
+
description: "Each edge's `<path>`."
|
|
605
|
+
},
|
|
606
|
+
{
|
|
607
|
+
name: "edge-label",
|
|
608
|
+
description: "Each edge's label."
|
|
609
|
+
},
|
|
610
|
+
{
|
|
611
|
+
name: "port",
|
|
612
|
+
description: "Each port's `<g>`: its dot and label."
|
|
613
|
+
},
|
|
614
|
+
{
|
|
615
|
+
name: "pin",
|
|
616
|
+
description: "Each pin, the enclosing node's port, on a modal or drilled graph's side."
|
|
617
|
+
},
|
|
618
|
+
{
|
|
619
|
+
name: "toggle",
|
|
620
|
+
description: "Each node's open / close button."
|
|
621
|
+
},
|
|
622
|
+
{
|
|
623
|
+
name: "toolbar",
|
|
624
|
+
description: "The buttons over the drawing (fit)."
|
|
625
|
+
},
|
|
626
|
+
{
|
|
627
|
+
name: "breadcrumbs",
|
|
628
|
+
description: "The trail back up, when drilled in."
|
|
629
|
+
}
|
|
630
|
+
],
|
|
631
|
+
states: [{
|
|
632
|
+
name: "drilled",
|
|
633
|
+
description: "It shows a node's children instead of its graph."
|
|
634
|
+
}, {
|
|
635
|
+
name: "panning",
|
|
636
|
+
description: "A drag is moving the view."
|
|
637
|
+
}],
|
|
638
|
+
texts: [
|
|
639
|
+
{
|
|
640
|
+
key: "graphSummary",
|
|
641
|
+
text: "Graph: {count} nodes",
|
|
642
|
+
description: "Name of the drawing."
|
|
643
|
+
},
|
|
644
|
+
{
|
|
645
|
+
key: "graphOpenNode",
|
|
646
|
+
text: "Open {label}",
|
|
647
|
+
description: "A closed node's toggle."
|
|
648
|
+
},
|
|
649
|
+
{
|
|
650
|
+
key: "graphCloseNode",
|
|
651
|
+
text: "Close {label}",
|
|
652
|
+
description: "An open node's toggle."
|
|
653
|
+
},
|
|
654
|
+
{
|
|
655
|
+
key: "graphFit",
|
|
656
|
+
text: "Fit",
|
|
657
|
+
description: "The button that fits the drawing to the view."
|
|
658
|
+
},
|
|
659
|
+
{
|
|
660
|
+
key: "graphTop",
|
|
661
|
+
text: "Top",
|
|
662
|
+
description: "The first breadcrumb, the graph itself."
|
|
663
|
+
},
|
|
664
|
+
{
|
|
665
|
+
key: "graphLoading",
|
|
666
|
+
text: "Loading …",
|
|
667
|
+
description: "A node whose children are loading."
|
|
668
|
+
}
|
|
669
|
+
]
|
|
670
|
+
}, ce = "@layer ui.components.graph.types{:host{font-family:var(--ui-graph-font-family,var(--ui-font-family));display:block}.ui.graph,.ui.graph :is(.node,.edge-group,.port,.pin){--_ui-graph-height:var(--ui-graph-height,28em);--_ui-graph-background:var(--ui-graph-background,var(--ui-surface));--_ui-graph-border-color:var(--ui-graph-border-color,var(--ui-border-color));--_ui-graph-radius:var(--ui-graph-radius,var(--ui-radius-m));--_ui-graph-node-background:var(--ui-graph-node-background,var(--ui-surface-muted));--_ui-graph-node-border-color:var(--ui-graph-node-border-color,var(--ui-border-color-strong));--_ui-graph-container-background:var(--ui-graph-container-background,transparent);--_ui-graph-container-border-color:var(--ui-graph-container-border-color,var(--ui-border-color-strong));--_ui-graph-label-color:var(--ui-graph-label-color,var(--ui-text-color));--_ui-graph-port-color:var(--ui-graph-port-color,var(--ui-text-muted));--_ui-graph-edge-color:var(--ui-graph-edge-color,var(--ui-text-light));--_ui-graph-edge-label-color:var(--ui-graph-edge-label-color,var(--ui-text-muted));--_ui-graph-highlight-color:var(--ui-graph-highlight-color,var(--ui-primary));--_ui-graph-selected-color:var(--ui-graph-selected-color,var(--ui-orange,var(--ui-primary)))}.ui.graph{height:var(--_ui-graph-height);border:1px solid var(--_ui-graph-border-color);border-radius:var(--_ui-graph-radius);background:var(--_ui-graph-background);flex-direction:column;display:flex;position:relative;overflow:hidden}.breadcrumbs{border-bottom:1px solid var(--_ui-graph-border-color);flex:none;padding:.5em .75em;display:block}.breadcrumbs ui-breadcrumb:not([selected]){cursor:var(--ui-control-cursor,pointer)}.toolbar{z-index:1;gap:.25em;display:flex;position:absolute;bottom:.5em;right:.5em}.toolbar button{border:1px solid var(--_ui-graph-border-color);border-radius:var(--ui-radius-s,4px);background:var(--_ui-graph-background);color:var(--ui-text-color);font:inherit;cursor:var(--ui-control-cursor,pointer);padding:.25em .75em;font-size:.8125em}.toolbar button:hover{border-color:var(--_ui-graph-highlight-color)}.canvas{cursor:grab;touch-action:none;-webkit-user-select:none;user-select:none;flex:auto;width:100%;min-height:0;display:block}:host(:state(panning)) .canvas{cursor:grabbing}.modal-graph-box{padding:1em}}@layer ui.components.graph.content{.canvas{& .box{fill:var(--_ui-graph-node-background);stroke:var(--_ui-graph-node-border-color);stroke-width:1px;rx:4px}& .container>.box{fill:var(--_ui-graph-container-background);stroke:var(--_ui-graph-container-border-color);stroke-dasharray:4 3}& .label{fill:var(--_ui-graph-label-color);dominant-baseline:central}& .container>.label{font-weight:var(--ui-font-weight-semibold)}& .node{cursor:var(--ui-control-cursor,pointer)}& .loading>.label{fill:var(--_ui-graph-port-color)}& .port-dot{fill:var(--_ui-graph-background);stroke:var(--_ui-graph-port-color);stroke-width:1.25px}& .port-label{fill:var(--_ui-graph-port-color);dominant-baseline:central}& .pin-mark{fill:var(--_ui-graph-node-border-color)}& .edge{fill:none;stroke:var(--_ui-graph-edge-color);stroke-width:1.25px;pointer-events:none}& .edge-hit{fill:none;stroke:#0000;stroke-width:8px;cursor:var(--ui-control-cursor,pointer)}& .edge-label{fill:var(--_ui-graph-edge-label-color);paint-order:stroke;stroke:var(--_ui-graph-background);stroke-width:3px;pointer-events:none}& .toggle{cursor:var(--ui-control-cursor,pointer)}& .toggle-target{fill:#0000}& .toggle-circle{fill:var(--_ui-graph-edge-color)}& .toggle-mark{fill:none;stroke:var(--ui-text-inverted-color);stroke-width:1.5px;stroke-linecap:round}& .toggle:focus{outline:none}& .toggle:focus-visible .toggle-circle{fill:var(--_ui-graph-highlight-color)}}}@layer ui.components.graph.variations;@layer ui.components.graph.states{.canvas{& .node.lit>.box,& .node:hover>.box{stroke:var(--_ui-graph-highlight-color)}& .edge-group.lit .edge,& .edge-group:hover .edge{stroke:var(--_ui-graph-highlight-color);stroke-width:2.25px}& .port.lit .port-dot,& .port:hover .port-dot,& .pin.lit .pin-mark{fill:var(--_ui-graph-highlight-color);stroke:var(--_ui-graph-highlight-color)}& .node.selected>.box,& .edge-group.selected .edge{stroke:var(--_ui-graph-selected-color);stroke-width:2.5px}& .port.selected .port-dot{fill:var(--_ui-graph-selected-color);stroke:var(--_ui-graph-selected-color)}}}", le = /* @__PURE__ */ j("<svg><rect></svg>", 2), ue = /* @__PURE__ */ j("<svg><text></svg>", 2), de = /* @__PURE__ */ j("<div><div><button type=button></button></div><svg role=group><g><!><!><!><!></g></svg><ui-modal size=large closable><div>", 1), fe = /* @__PURE__ */ j("<ui-breadcrumbs divider=›>", 1), pe = /* @__PURE__ */ j("<ui-breadcrumb>", 1), me = /* @__PURE__ */ j("<svg><g><!><!><!><!></svg>", 2), he = /* @__PURE__ */ j("<title>"), ge = /* @__PURE__ */ j("<svg><g role=button tabindex=0><title></title><circle r=10></circle><circle r=6></circle><path></svg>", 2), _e = /* @__PURE__ */ j("<svg><g><circle></svg>", 2), ve = /* @__PURE__ */ j("<svg><g><path></path><text text-anchor=middle></svg>", 2), ye = /* @__PURE__ */ j("<svg><text text-anchor=middle></svg>", 2), be = /* @__PURE__ */ j("<svg><g><path></path><path></svg>", 2), F, I, L, R, xe, Se, Ce, we, z, Te, Ee, De, Oe, ke, Ae, je, Me, Ne, Pe, Fe, Ie, Le, Re, ze, Be, B, V, H, U, W, G, K, q, J, Y, DOMGraphElement = class extends e {
|
|
671
|
+
static {
|
|
672
|
+
i(this, "DOMGraphElement");
|
|
673
|
+
}
|
|
674
|
+
fit() {
|
|
675
|
+
this.component?.fit();
|
|
676
|
+
}
|
|
677
|
+
open(e, t) {
|
|
678
|
+
return this.component?.openNode(e, t) ?? Promise.resolve();
|
|
679
|
+
}
|
|
680
|
+
close(e) {
|
|
681
|
+
this.component?.closeNode(e);
|
|
682
|
+
}
|
|
683
|
+
drillTo(e) {
|
|
684
|
+
return this.component?.drillTo(e) ?? Promise.resolve();
|
|
685
|
+
}
|
|
686
|
+
get layout() {
|
|
687
|
+
return this.component?.layout;
|
|
688
|
+
}
|
|
689
|
+
}, X = class _UIGraph extends (B = a, Be = [h], ze = [g], Re = [v], Le = [v], Ie = [v], Fe = [v], Pe = [v], Ne = [d], Me = [d], je = [f], Ae = [m("path")], ke = [y], Oe = [u("drilled")], De = [v], Ee = [d], Te = [y], z = [v], we = [v], Ce = [u("panning")], Se = [y], xe = [m("graph")], R = [m("layout", "isReady")], L = [te], I = [m("modalPath", "isReady")], F = [p("ui-closed", { target: "renderRoot" })], B) {
|
|
690
|
+
constructor() {
|
|
691
|
+
super(...arguments), l(V, 5, this), _(this, H, l(V, 8, this, /* @__PURE__ */ new Map())), l(V, 11, this), _(this, U, l(V, 12, this, /* @__PURE__ */ new Set())), l(V, 15, this), _(this, W, l(V, 16, this, /* @__PURE__ */ new Set())), l(V, 19, this), _(this, G, l(V, 20, this, [])), l(V, 23, this), _(this, K, l(V, 24, this)), l(V, 27, this), _(this, q, l(V, 28, this)), l(V, 31, this), _(this, J, l(V, 32, this, {
|
|
692
|
+
x: 0,
|
|
693
|
+
y: 0,
|
|
694
|
+
k: 1
|
|
695
|
+
})), l(V, 35, this), _(this, Y, l(V, 36, this, !1)), l(V, 39, this), r(this, "needsFit", !0), r(this, "isFitted", !1), r(this, "wasDragged", !1), r(this, "svg"), r(this, "onWheel", /* @__PURE__ */ i((e) => {
|
|
696
|
+
if (!this.svg) return;
|
|
697
|
+
e.preventDefault();
|
|
698
|
+
let t = this.svg.getBoundingClientRect(), n = e.clientX - t.left, r = e.clientY - t.top, { x: i, y: a, k: o } = this.view, s = Math.min(4, Math.max(.05, o * Math.exp(-e.deltaY * (e.ctrlKey ? .01 : .0015))));
|
|
699
|
+
this.view = {
|
|
700
|
+
x: n - (n - i) * s / o,
|
|
701
|
+
y: r - (r - a) * s / o,
|
|
702
|
+
k: s
|
|
703
|
+
}, this.isFitted = !1;
|
|
704
|
+
}, "onWheel")), r(this, "onPointerDown", /* @__PURE__ */ i((e) => {
|
|
705
|
+
if (e.button !== 0 || !this.svg) return;
|
|
706
|
+
let t = this.svg, n = {
|
|
707
|
+
x: e.clientX,
|
|
708
|
+
y: e.clientY,
|
|
709
|
+
view: this.view
|
|
710
|
+
};
|
|
711
|
+
this.wasDragged = !1;
|
|
712
|
+
let r = /* @__PURE__ */ i((r) => {
|
|
713
|
+
let i = r.clientX - n.x, a = r.clientY - n.y;
|
|
714
|
+
!this.wasDragged && Math.hypot(i, a) < He || (this.wasDragged || (this.wasDragged = !0, this.isFitted = !1, this.isPanning = !0, t.setPointerCapture(e.pointerId)), this.view = {
|
|
715
|
+
...n.view,
|
|
716
|
+
x: n.view.x + i,
|
|
717
|
+
y: n.view.y + a
|
|
718
|
+
});
|
|
719
|
+
}, "move"), a = /* @__PURE__ */ i(() => {
|
|
720
|
+
t.removeEventListener("pointermove", r), t.removeEventListener("pointerup", a), t.removeEventListener("pointercancel", a), this.isPanning = !1, ee(() => this.wasDragged = !1);
|
|
721
|
+
}, "up");
|
|
722
|
+
t.addEventListener("pointermove", r), t.addEventListener("pointerup", a), t.addEventListener("pointercancel", a);
|
|
723
|
+
}, "onPointerDown")), r(this, "onBackgroundClick", /* @__PURE__ */ i((e) => {
|
|
724
|
+
!this.wasDragged && this.selected && (this.selected = void 0, this.send("ui-changed", {
|
|
725
|
+
value: void 0,
|
|
726
|
+
originalEvent: e
|
|
727
|
+
}));
|
|
728
|
+
}, "onBackgroundClick")), r(this, "modalBody"), r(this, "modalElement");
|
|
729
|
+
}
|
|
730
|
+
nodeLabel(e) {
|
|
731
|
+
return e.label ?? e.id;
|
|
732
|
+
}
|
|
733
|
+
nodeClass(e) {}
|
|
734
|
+
edgeLabel(e) {
|
|
735
|
+
return e.label;
|
|
736
|
+
}
|
|
737
|
+
edgeClass(e) {}
|
|
738
|
+
portLabel(e, t) {
|
|
739
|
+
return e.label;
|
|
740
|
+
}
|
|
741
|
+
portClass(e, t) {}
|
|
742
|
+
get metrics() {
|
|
743
|
+
return N;
|
|
744
|
+
}
|
|
745
|
+
trail() {
|
|
746
|
+
return this.drillPaths.length ? [{
|
|
747
|
+
label: this.translationForKey("graphTop"),
|
|
748
|
+
pick: /* @__PURE__ */ i(() => this.goToDrill(0), "pick")
|
|
749
|
+
}, ...this.drillPaths.map((e, t) => {
|
|
750
|
+
let n = this.nodeAt(e);
|
|
751
|
+
return {
|
|
752
|
+
label: n ? this.nodeLabel(n) : e,
|
|
753
|
+
pick: /* @__PURE__ */ i(() => this.goToDrill(t + 1), "pick")
|
|
754
|
+
};
|
|
755
|
+
})] : [];
|
|
756
|
+
}
|
|
757
|
+
get minFitZoom() {
|
|
758
|
+
return 0;
|
|
759
|
+
}
|
|
760
|
+
toolButtons() {}
|
|
761
|
+
overlay() {}
|
|
762
|
+
nodeDoubleClicked(e, t) {
|
|
763
|
+
e.hasChildren && this.openNode(e.path, "drill", t);
|
|
764
|
+
}
|
|
765
|
+
changedDetail(e, t, n) {
|
|
766
|
+
return {
|
|
767
|
+
value: e,
|
|
768
|
+
...e,
|
|
769
|
+
item: t,
|
|
770
|
+
originalEvent: n
|
|
771
|
+
};
|
|
772
|
+
}
|
|
773
|
+
renderNode(e) {
|
|
774
|
+
let { fontSize: t } = N, { x: n, y: r, width: i, height: a, isOpen: o } = e, s = this.nodeLabel(e.node), c = this;
|
|
775
|
+
return [(() => {
|
|
776
|
+
var e = le();
|
|
777
|
+
return A(e, "x", n), A(e, "y", r), A(e, "width", i), A(e, "height", a), T(() => O(Ye), (t, n) => {
|
|
778
|
+
C(e, t, n);
|
|
779
|
+
}), e;
|
|
780
|
+
})(), (() => {
|
|
781
|
+
var l = ue();
|
|
782
|
+
return A(l, "text-anchor", o ? "start" : "middle"), D(l, (() => {
|
|
783
|
+
var t = ae(() => !!e.isLoading);
|
|
784
|
+
return () => t() ? `${s} ${c.translationForKey("graphLoading")}` : s;
|
|
785
|
+
})()), T(() => ({
|
|
786
|
+
e: O(Xe),
|
|
787
|
+
t: o ? n + N.paddingX : n + i / 2 - (e.hasChildren ? N.toggleWidth / 2 : 0),
|
|
788
|
+
a: o ? r + N.headerHeight / 2 : r + a / 2,
|
|
789
|
+
o: String(t)
|
|
790
|
+
}), ({ e, t, a: n, o: r }, i) => {
|
|
791
|
+
C(l, e, i?.e), t !== i?.t && A(l, "x", t), n !== i?.a && A(l, "y", n), r !== i?.o && A(l, "font-size", r);
|
|
792
|
+
}), l;
|
|
793
|
+
})()];
|
|
794
|
+
}
|
|
795
|
+
get topGraph() {
|
|
796
|
+
return _UIGraph.graphFrom(this.graph);
|
|
797
|
+
}
|
|
798
|
+
nodeAt(e) {
|
|
799
|
+
let t = this.topGraph, n = "", r;
|
|
800
|
+
for (let i of e.split("/")) {
|
|
801
|
+
if (!t || (r = t.nodes.find((e) => e?.id === i), !r)) return;
|
|
802
|
+
n = n ? `${n}/${i}` : i, t = this.childrenOf(r, n);
|
|
803
|
+
}
|
|
804
|
+
return r;
|
|
805
|
+
}
|
|
806
|
+
childrenOf(e, t) {
|
|
807
|
+
let n = e.children;
|
|
808
|
+
return n && typeof n == "object" ? _UIGraph.graphFrom(n) : this.loadedChildren.get(t);
|
|
809
|
+
}
|
|
810
|
+
get drillPath() {
|
|
811
|
+
return this.drillPaths.at(-1);
|
|
812
|
+
}
|
|
813
|
+
get shownGraph() {
|
|
814
|
+
let e = this.drillPath;
|
|
815
|
+
if (e === void 0) return this.topGraph;
|
|
816
|
+
let t = this.nodeAt(e);
|
|
817
|
+
return t && this.childrenOf(t, e);
|
|
818
|
+
}
|
|
819
|
+
get shownBoundary() {
|
|
820
|
+
let e = this.drillPath;
|
|
821
|
+
return e === void 0 ? Array.isArray(this.boundary) ? this.boundary : [] : this.nodeAt(e)?.ports ?? [];
|
|
822
|
+
}
|
|
823
|
+
get layout() {
|
|
824
|
+
let e = this.shownGraph;
|
|
825
|
+
if (!e) return;
|
|
826
|
+
let t = /* @__PURE__ */ new Map();
|
|
827
|
+
for (let e of this.openPaths) {
|
|
828
|
+
let n = this.nodeAt(e), r = n && this.childrenOf(n, e);
|
|
829
|
+
r && t.set(e, r);
|
|
830
|
+
}
|
|
831
|
+
return P.of(e, {
|
|
832
|
+
metrics: this.metrics,
|
|
833
|
+
prefix: this.drillPath ?? "",
|
|
834
|
+
openChildren: t,
|
|
835
|
+
loading: this.loadingPaths,
|
|
836
|
+
boundary: this.shownBoundary,
|
|
837
|
+
label: /* @__PURE__ */ i((e) => this.nodeLabel(e), "label"),
|
|
838
|
+
textWidth: ie ? void 0 : (e, t) => _UIGraph.measure(e, t, this.fontFamily)
|
|
839
|
+
});
|
|
840
|
+
}
|
|
841
|
+
get fontFamily() {
|
|
842
|
+
return getComputedStyle(this.domElement).fontFamily || "sans-serif";
|
|
843
|
+
}
|
|
844
|
+
get containers() {
|
|
845
|
+
return this.layout?.nodes.filter((e) => e.isOpen) ?? [];
|
|
846
|
+
}
|
|
847
|
+
get leaves() {
|
|
848
|
+
return this.layout?.nodes.filter((e) => !e.isOpen) ?? [];
|
|
849
|
+
}
|
|
850
|
+
async openNode(e, t, n) {
|
|
851
|
+
let r = this.nodeAt(e);
|
|
852
|
+
if (!r?.children) return;
|
|
853
|
+
let i = t ?? _UIGraph.viewFrom(r.childView) ?? _UIGraph.viewFrom(this.childView) ?? "inline";
|
|
854
|
+
await this.load(r, e) && (i === "inline" ? this.openPaths = new Set(this.openPaths).add(e) : i === "modal" ? this.modalPath = e : (this.drillPaths = [...this.drillPaths, e], this.needsFit = !0, this.drilled(n)), this.send("ui-node-toggled", {
|
|
855
|
+
node: r,
|
|
856
|
+
path: e,
|
|
857
|
+
open: !0,
|
|
858
|
+
view: i,
|
|
859
|
+
originalEvent: n
|
|
860
|
+
}));
|
|
861
|
+
}
|
|
862
|
+
closeNode(e, t) {
|
|
863
|
+
let n = this.nodeAt(e), r = this.drillPaths.indexOf(e);
|
|
864
|
+
r >= 0 ? (this.drillPaths = this.drillPaths.slice(0, r), this.needsFit = !0, this.drilled(t)) : this.openPaths = new Set([...this.openPaths].filter((t) => t !== e && !t.startsWith(`${e}/`))), n && this.send("ui-node-toggled", {
|
|
865
|
+
node: n,
|
|
866
|
+
path: e,
|
|
867
|
+
open: !1,
|
|
868
|
+
view: r >= 0 ? "drill" : "inline",
|
|
869
|
+
originalEvent: t
|
|
870
|
+
});
|
|
871
|
+
}
|
|
872
|
+
async drillTo(e) {
|
|
873
|
+
e ? await this.openNode(e, "drill") : this.goToDrill(0);
|
|
874
|
+
}
|
|
875
|
+
goToDrill(e, t) {
|
|
876
|
+
e >= this.drillPaths.length || (this.drillPaths = this.drillPaths.slice(0, e), this.needsFit = !0, this.drilled(t));
|
|
877
|
+
}
|
|
878
|
+
drilled(e) {
|
|
879
|
+
let t = this.drillPath ?? "";
|
|
880
|
+
t !== (this.path ?? "") && (this.path = t, this.send("ui-changed", {
|
|
881
|
+
kind: "path",
|
|
882
|
+
path: t,
|
|
883
|
+
originalEvent: e
|
|
884
|
+
}));
|
|
885
|
+
}
|
|
886
|
+
onPathChanged(e) {
|
|
887
|
+
this.applyPath(e ?? "");
|
|
888
|
+
}
|
|
889
|
+
async applyPath(e) {
|
|
890
|
+
if (e === (this.drillPath ?? "")) return;
|
|
891
|
+
let t = e ? e.split("/") : [], n = [];
|
|
892
|
+
for (let e = 0; e < t.length; e++) {
|
|
893
|
+
let r = t.slice(0, e + 1).join("/"), i = this.nodeAt(r);
|
|
894
|
+
if (!i?.children || !await this.load(i, r)) break;
|
|
895
|
+
n.push(r);
|
|
896
|
+
}
|
|
897
|
+
this.drillPaths = n, this.needsFit = !0;
|
|
898
|
+
}
|
|
899
|
+
async load(e, t) {
|
|
900
|
+
if (typeof e.children != "function" || this.loadedChildren.has(t)) return !0;
|
|
901
|
+
this.loadingPaths = new Set(this.loadingPaths).add(t);
|
|
902
|
+
try {
|
|
903
|
+
let n = _UIGraph.graphFrom(await e.children());
|
|
904
|
+
return n ? (this.loadedChildren = new Map(this.loadedChildren).set(t, n), !0) : !1;
|
|
905
|
+
} catch (e) {
|
|
906
|
+
return s.warn(`<${this.domElement.localName}>`, `${t}'s children failed to load`, e), !1;
|
|
907
|
+
} finally {
|
|
908
|
+
let e = new Set(this.loadingPaths);
|
|
909
|
+
e.delete(t), this.loadingPaths = e;
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
toggle(e, t) {
|
|
913
|
+
t.stopPropagation(), e.isOpen ? this.closeNode(e.path, t) : this.openNode(e.path, void 0, t);
|
|
914
|
+
}
|
|
915
|
+
get isDrilled() {
|
|
916
|
+
return this.drillPaths.length > 0;
|
|
917
|
+
}
|
|
918
|
+
get lit() {
|
|
919
|
+
let e = /* @__PURE__ */ new Set(), t = this.hovered, n = this.layout;
|
|
920
|
+
if (!t || !n) return e;
|
|
921
|
+
e.add(t.path);
|
|
922
|
+
let r = /* @__PURE__ */ i((e) => e.split(":")[0], "nodeOf");
|
|
923
|
+
for (let i of n.edges) if (t.kind === "edge" ? i.path === t.path : t.kind === "port" ? i.fromPath === t.path || i.toPath === t.path : r(i.fromPath) === t.path || r(i.toPath) === t.path) {
|
|
924
|
+
e.add(i.path);
|
|
925
|
+
for (let t of [i.fromPath, i.toPath]) e.add(t), e.add(r(t));
|
|
926
|
+
}
|
|
927
|
+
return e;
|
|
928
|
+
}
|
|
929
|
+
get selectedPath() {
|
|
930
|
+
let e = this.selected;
|
|
931
|
+
return e && typeof e == "object" ? e.path : void 0;
|
|
932
|
+
}
|
|
933
|
+
choose(e, t, n) {
|
|
934
|
+
n.stopPropagation(), this.wasDragged || this.send("ui-selecting", {
|
|
935
|
+
...e,
|
|
936
|
+
item: t,
|
|
937
|
+
originalEvent: n
|
|
938
|
+
}) && (this.selected = e, this.send("ui-changed", this.changedDetail(e, t, n)));
|
|
939
|
+
}
|
|
940
|
+
get isPanningNow() {
|
|
941
|
+
return this.isPanning;
|
|
942
|
+
}
|
|
943
|
+
fit() {
|
|
944
|
+
let e = this.layout, t = this.svg && {
|
|
945
|
+
width: this.svg.clientWidth,
|
|
946
|
+
height: this.svg.clientHeight
|
|
947
|
+
};
|
|
948
|
+
if (!e || !t?.width || !t.height) return;
|
|
949
|
+
let n = Math.max(this.minFitZoom, Math.min(t.width / e.width, t.height / e.height, 1.5)), r = /* @__PURE__ */ i((e, t) => (e - t * n) / 2, "along");
|
|
950
|
+
this.view = {
|
|
951
|
+
x: r(t.width, e.width),
|
|
952
|
+
y: r(t.height, e.height),
|
|
953
|
+
k: n
|
|
954
|
+
}, this.isFitted = !0;
|
|
955
|
+
}
|
|
956
|
+
onGraphChanged() {
|
|
957
|
+
this.needsFit = !0, this.drillPaths = [], this.openPaths = new Set(_UIGraph.startOpen(this.topGraph)), this.path && this.applyPath(String(this.path));
|
|
958
|
+
}
|
|
959
|
+
onLayoutChanged(e, t) {
|
|
960
|
+
t && e && this.needsFit && this.svg?.getBoundingClientRect().width && (this.needsFit = !1, this.fit());
|
|
961
|
+
}
|
|
962
|
+
watchSize() {
|
|
963
|
+
let e = new ResizeObserver(() => {
|
|
964
|
+
(this.needsFit || this.isFitted) && this.fit(), this.svg?.getBoundingClientRect().width && (this.needsFit = !1);
|
|
965
|
+
});
|
|
966
|
+
return this.svg && e.observe(this.svg), () => e.disconnect();
|
|
967
|
+
}
|
|
968
|
+
onModalPathChanged(e, t) {
|
|
969
|
+
if (!t || !this.modalBody) return;
|
|
970
|
+
if (e === void 0) {
|
|
971
|
+
this.modalBody.replaceChildren();
|
|
972
|
+
return;
|
|
973
|
+
}
|
|
974
|
+
let n = this.nodeAt(e), r = n && this.childrenOf(n, e), i = document.createElement(this.domElement.localName);
|
|
975
|
+
i.graph = r, i.boundary = n?.ports ?? [], this.childView && i.setAttribute("child-view", String(this.childView)), i.classList.add(dt), i.style.setProperty("--ui-graph-height", ft), this.modalBody.replaceChildren(i);
|
|
976
|
+
}
|
|
977
|
+
onModalClosed(e) {
|
|
978
|
+
e.target === this.modalElement && (this.modalPath = void 0);
|
|
979
|
+
}
|
|
980
|
+
get extraClass() {
|
|
981
|
+
return this.topGraph ? void 0 : Ue;
|
|
982
|
+
}
|
|
983
|
+
render() {
|
|
984
|
+
let e = this;
|
|
985
|
+
var t = de(), n = t.firstChild, r = n.firstChild, i = n.nextSibling, a = i.firstChild, o = a.firstChild, s = o.nextSibling, c = s.nextSibling, l = c.nextSibling, u = i.nextSibling, d = u.firstChild;
|
|
986
|
+
return D(t, w(x, {
|
|
987
|
+
get when() {
|
|
988
|
+
return e.trail().length > 1;
|
|
989
|
+
},
|
|
990
|
+
get children() {
|
|
991
|
+
return e.breadcrumbs();
|
|
992
|
+
}
|
|
993
|
+
}), n), D(n, () => e.toolButtons(), r), r._$$click = () => e.fit(), D(r, () => e.translationForKey("graphFit")), D(t, () => e.overlay(), i), S(i, "click", e.onBackgroundClick, !0), S(i, "pointerdown", e.onPointerDown, !0), S(i, "wheel", e.onWheel), k(() => (t) => e.svg = t, i), D(a, w(b, {
|
|
994
|
+
get each() {
|
|
995
|
+
return e.containers;
|
|
996
|
+
},
|
|
997
|
+
children: (t) => e.node(t)
|
|
998
|
+
}), o), D(a, w(b, {
|
|
999
|
+
get each() {
|
|
1000
|
+
return e.layout?.edges ?? [];
|
|
1001
|
+
},
|
|
1002
|
+
children: (t) => e.edge(t)
|
|
1003
|
+
}), s), D(a, w(b, {
|
|
1004
|
+
get each() {
|
|
1005
|
+
return e.leaves;
|
|
1006
|
+
},
|
|
1007
|
+
children: (t) => e.node(t)
|
|
1008
|
+
}), c), D(a, w(b, {
|
|
1009
|
+
get each() {
|
|
1010
|
+
return e.layout?.pins ?? [];
|
|
1011
|
+
},
|
|
1012
|
+
children: (t) => e.pin(t)
|
|
1013
|
+
}), l), k(() => (t) => e.modalElement = t, u), u._$owner = E(), k(() => (t) => e.modalBody = t, d), T(() => ({
|
|
1014
|
+
e: O(e.rootClass),
|
|
1015
|
+
t: e.partForName("graph"),
|
|
1016
|
+
a: O(We),
|
|
1017
|
+
o: e.partForName("toolbar"),
|
|
1018
|
+
i: O(Ke),
|
|
1019
|
+
n: e.partForName("canvas"),
|
|
1020
|
+
s: e.translationForKey("graphSummary", { count: e.layout?.nodes.length ?? 0 }),
|
|
1021
|
+
h: `translate(${e.view.x} ${e.view.y}) scale(${e.view.k})`,
|
|
1022
|
+
r: e.modalHeading(),
|
|
1023
|
+
d: e.modalPath === void 0 ? void 0 : "",
|
|
1024
|
+
l: O(ut)
|
|
1025
|
+
}), ({ e, t: r, a: o, o: s, i: c, n: l, s: f, h: p, r: m, d: h, l: g }, _) => {
|
|
1026
|
+
C(t, e, _?.e), r !== _?.t && A(t, "part", r), C(n, o, _?.a), s !== _?.o && A(n, "part", s), C(i, c, _?.i), l !== _?.n && A(i, "part", l), f !== _?.s && A(i, "aria-label", f), p !== _?.h && A(a, "transform", p), m !== _?.r && A(u, "heading", m), h !== _?.d && A(u, "visible", h), C(d, g, _?.l);
|
|
1027
|
+
}), t;
|
|
1028
|
+
}
|
|
1029
|
+
modalHeading() {
|
|
1030
|
+
let e = this.modalPath, t = e === void 0 ? void 0 : this.nodeAt(e);
|
|
1031
|
+
return t && this.nodeLabel(t);
|
|
1032
|
+
}
|
|
1033
|
+
breadcrumbs() {
|
|
1034
|
+
let e = this;
|
|
1035
|
+
var t = fe();
|
|
1036
|
+
return t._$owner = E(), D(t, w(b, {
|
|
1037
|
+
get each() {
|
|
1038
|
+
return e.trail();
|
|
1039
|
+
},
|
|
1040
|
+
children: (t, n) => (() => {
|
|
1041
|
+
var r = pe();
|
|
1042
|
+
return r._$$click = () => {
|
|
1043
|
+
n() !== e.trail().length - 1 && t.pick();
|
|
1044
|
+
}, r._$owner = E(), D(r, () => t.label), T(() => n() === e.trail().length - 1 ? "" : void 0, (e) => {
|
|
1045
|
+
A(r, "selected", e);
|
|
1046
|
+
}), r;
|
|
1047
|
+
})()
|
|
1048
|
+
})), T(() => ({
|
|
1049
|
+
e: O(Ge),
|
|
1050
|
+
t: e.partForName("breadcrumbs")
|
|
1051
|
+
}), ({ e, t: n }, r) => {
|
|
1052
|
+
C(t, e, r?.e), n !== r?.t && A(t, "part", n);
|
|
1053
|
+
}), t;
|
|
1054
|
+
}
|
|
1055
|
+
node(e) {
|
|
1056
|
+
let t = _UIGraph.wordFor(e.node.kind), n = e.path, r = this;
|
|
1057
|
+
var i = me(), a = i.firstChild, o = a.nextSibling, s = o.nextSibling, c = s.nextSibling;
|
|
1058
|
+
return i.addEventListener("pointerleave", () => r.unhover(n)), i.addEventListener("pointerenter", () => r.hovered = {
|
|
1059
|
+
kind: "node",
|
|
1060
|
+
path: n
|
|
1061
|
+
}), i._$$dblclick = (t) => {
|
|
1062
|
+
t.stopPropagation(), r.nodeDoubleClicked(e, t);
|
|
1063
|
+
}, i._$$click = (t) => r.choose({
|
|
1064
|
+
kind: "node",
|
|
1065
|
+
id: e.node.id,
|
|
1066
|
+
path: n
|
|
1067
|
+
}, e.node, t), A(i, "data-path", n), D(i, w(x, {
|
|
1068
|
+
get when() {
|
|
1069
|
+
return e.node.title;
|
|
1070
|
+
},
|
|
1071
|
+
children: (e) => (() => {
|
|
1072
|
+
var t = he();
|
|
1073
|
+
return D(t, e), t;
|
|
1074
|
+
})()
|
|
1075
|
+
}), a), D(i, () => r.renderNode(e), o), D(i, w(b, {
|
|
1076
|
+
get each() {
|
|
1077
|
+
return e.ports;
|
|
1078
|
+
},
|
|
1079
|
+
children: (t) => r.port(t, e)
|
|
1080
|
+
}), s), D(i, w(x, {
|
|
1081
|
+
get when() {
|
|
1082
|
+
return e.hasChildren;
|
|
1083
|
+
},
|
|
1084
|
+
get children() {
|
|
1085
|
+
return r.toggleButton(e);
|
|
1086
|
+
}
|
|
1087
|
+
}), c), T(() => ({
|
|
1088
|
+
e: O([
|
|
1089
|
+
qe,
|
|
1090
|
+
t && `kind-${t}`,
|
|
1091
|
+
r.nodeClass(e.node),
|
|
1092
|
+
{
|
|
1093
|
+
[Je]: e.isOpen,
|
|
1094
|
+
[Q]: r.lit.has(n),
|
|
1095
|
+
[$]: r.selectedPath === n,
|
|
1096
|
+
[at]: !!e.isLoading
|
|
1097
|
+
}
|
|
1098
|
+
]),
|
|
1099
|
+
t: [
|
|
1100
|
+
r.partForName("node"),
|
|
1101
|
+
e.isOpen && r.partForName("container"),
|
|
1102
|
+
t && `kind-${t}`
|
|
1103
|
+
].filter(Boolean).join(" ")
|
|
1104
|
+
}), ({ e, t }, n) => {
|
|
1105
|
+
C(i, e, n?.e), t !== n?.t && A(i, "part", t);
|
|
1106
|
+
}), i;
|
|
1107
|
+
}
|
|
1108
|
+
toggleButton(e) {
|
|
1109
|
+
let n = /* @__PURE__ */ i(() => this.translationForKey(e.isOpen ? "graphCloseNode" : "graphOpenNode", { label: this.nodeLabel(e.node) }), "label"), r = e.x + e.width - N.toggleWidth / 2 - 4, a = e.isOpen ? e.y + N.headerHeight / 2 : e.y + e.height / 2, o = this;
|
|
1110
|
+
var s = ge(), c = s.firstChild, l = c.nextSibling, u = l.nextSibling, d = u.nextSibling;
|
|
1111
|
+
return s._$$keydown = (n) => {
|
|
1112
|
+
(n.key === t.enter || n.key === t.space) && (n.preventDefault(), o.toggle(e, n));
|
|
1113
|
+
}, s._$$dblclick = (e) => e.stopPropagation(), s._$$click = (t) => o.toggle(e, t), A(s, "transform", `translate(${r} ${a})`), D(c, n), T(() => ({
|
|
1114
|
+
e: O(ot),
|
|
1115
|
+
t: o.partForName("toggle"),
|
|
1116
|
+
a: e.isOpen ? "true" : "false",
|
|
1117
|
+
o: n(),
|
|
1118
|
+
i: O(st),
|
|
1119
|
+
n: O(ct),
|
|
1120
|
+
s: O(lt),
|
|
1121
|
+
h: e.isOpen ? mt : pt
|
|
1122
|
+
}), ({ e, t, a: n, o: r, i, n: a, s: o, h: c }, f) => {
|
|
1123
|
+
C(s, e, f?.e), t !== f?.t && A(s, "part", t), n !== f?.a && A(s, "aria-expanded", n), r !== f?.o && A(s, "aria-label", r), C(l, i, f?.i), C(u, a, f?.n), C(d, o, f?.s), c !== f?.h && A(d, "d", c);
|
|
1124
|
+
}), s;
|
|
1125
|
+
}
|
|
1126
|
+
port(e, t) {
|
|
1127
|
+
let n = _UIGraph.wordFor(e.port.kind), r = this.portLabel(e.port, t.node), i = N.portRadius, a = e.side === "left" ? {
|
|
1128
|
+
x: e.x + i + 3,
|
|
1129
|
+
y: e.y,
|
|
1130
|
+
anchor: "start"
|
|
1131
|
+
} : e.side === "right" ? {
|
|
1132
|
+
x: e.x - i - 3,
|
|
1133
|
+
y: e.y,
|
|
1134
|
+
anchor: "end"
|
|
1135
|
+
} : {
|
|
1136
|
+
x: e.x,
|
|
1137
|
+
y: e.side === "top" ? e.y + i + 7 : e.y - i - 7,
|
|
1138
|
+
anchor: "middle"
|
|
1139
|
+
}, o = this;
|
|
1140
|
+
var s = _e(), c = s.firstChild;
|
|
1141
|
+
return s.addEventListener("pointerleave", () => o.hovered = {
|
|
1142
|
+
kind: "node",
|
|
1143
|
+
path: t.path
|
|
1144
|
+
}), s.addEventListener("pointerenter", (t) => {
|
|
1145
|
+
t.stopPropagation(), o.hovered = {
|
|
1146
|
+
kind: "port",
|
|
1147
|
+
path: e.path
|
|
1148
|
+
};
|
|
1149
|
+
}), s._$$click = (t) => o.choose({
|
|
1150
|
+
kind: "port",
|
|
1151
|
+
id: e.port.id,
|
|
1152
|
+
path: e.path
|
|
1153
|
+
}, e.port, t), A(c, "r", i), D(s, w(x, {
|
|
1154
|
+
get when() {
|
|
1155
|
+
return r && (!t.isOpen || e.side !== "left" && e.side !== "right");
|
|
1156
|
+
},
|
|
1157
|
+
get children() {
|
|
1158
|
+
var e = ue();
|
|
1159
|
+
return D(e, r), T(() => ({
|
|
1160
|
+
e: O(Z),
|
|
1161
|
+
t: a.x,
|
|
1162
|
+
a: a.y,
|
|
1163
|
+
o: a.anchor,
|
|
1164
|
+
i: String(N.portFontSize)
|
|
1165
|
+
}), ({ e: t, t: n, a: r, o: i, i: a }, o) => {
|
|
1166
|
+
C(e, t, o?.e), n !== o?.t && A(e, "x", n), r !== o?.a && A(e, "y", r), i !== o?.o && A(e, "text-anchor", i), a !== o?.i && A(e, "font-size", a);
|
|
1167
|
+
}), e;
|
|
1168
|
+
}
|
|
1169
|
+
}), null), T(() => ({
|
|
1170
|
+
e: O([
|
|
1171
|
+
Ze,
|
|
1172
|
+
n && `kind-${n}`,
|
|
1173
|
+
o.portClass(e.port, t.node),
|
|
1174
|
+
{
|
|
1175
|
+
[Q]: o.lit.has(e.path),
|
|
1176
|
+
[$]: o.selectedPath === e.path
|
|
1177
|
+
}
|
|
1178
|
+
]),
|
|
1179
|
+
t: [o.partForName("port"), n && `kind-${n}`].filter(Boolean).join(" "),
|
|
1180
|
+
a: O(Qe),
|
|
1181
|
+
o: e.x,
|
|
1182
|
+
i: e.y
|
|
1183
|
+
}), ({ e, t, a: n, o: r, i }, a) => {
|
|
1184
|
+
C(s, e, a?.e), t !== a?.t && A(s, "part", t), C(c, n, a?.a), r !== a?.o && A(c, "cx", r), i !== a?.i && A(c, "cy", i);
|
|
1185
|
+
}), s;
|
|
1186
|
+
}
|
|
1187
|
+
pin(e) {
|
|
1188
|
+
let t = e.port.label ?? e.port.id, n = this;
|
|
1189
|
+
var r = ve(), i = r.firstChild, a = i.nextSibling;
|
|
1190
|
+
return r._$$click = (t) => n.choose({
|
|
1191
|
+
kind: "port",
|
|
1192
|
+
id: e.port.id,
|
|
1193
|
+
path: e.path
|
|
1194
|
+
}, e.port, t), r.addEventListener("pointerleave", () => n.unhover(e.path)), r.addEventListener("pointerenter", () => n.hovered = {
|
|
1195
|
+
kind: "port",
|
|
1196
|
+
path: e.path
|
|
1197
|
+
}), D(a, t), T(() => ({
|
|
1198
|
+
e: O([$e, { [Q]: n.lit.has(e.path) }]),
|
|
1199
|
+
t: n.partForName("pin"),
|
|
1200
|
+
a: O(et),
|
|
1201
|
+
o: `M${e.x - 5} ${e.y - 5}h10v10h-10z`,
|
|
1202
|
+
i: O(Z),
|
|
1203
|
+
n: e.x,
|
|
1204
|
+
s: e.y - 10,
|
|
1205
|
+
h: String(N.portFontSize)
|
|
1206
|
+
}), ({ e, t, a: n, o, i: s, n: c, s: l, h: u }, d) => {
|
|
1207
|
+
C(r, e, d?.e), t !== d?.t && A(r, "part", t), C(i, n, d?.a), o !== d?.o && A(i, "d", o), C(a, s, d?.i), c !== d?.n && A(a, "x", c), l !== d?.s && A(a, "y", l), u !== d?.h && A(a, "font-size", u);
|
|
1208
|
+
}), r;
|
|
1209
|
+
}
|
|
1210
|
+
edge(e) {
|
|
1211
|
+
let t = P.pathFor(e), n = _UIGraph.wordFor(e.edge.kind), r = this.edgeLabel(e.edge), a = P.middleOf(e), o = /* @__PURE__ */ i((t) => this.choose({
|
|
1212
|
+
kind: "edge",
|
|
1213
|
+
id: e.id,
|
|
1214
|
+
path: e.path
|
|
1215
|
+
}, e.edge, t), "select"), s = this;
|
|
1216
|
+
var c = be(), l = c.firstChild, u = l.nextSibling;
|
|
1217
|
+
return S(c, "click", o, !0), c.addEventListener("pointerleave", () => s.unhover(e.path)), c.addEventListener("pointerenter", () => s.hovered = {
|
|
1218
|
+
kind: "edge",
|
|
1219
|
+
path: e.path
|
|
1220
|
+
}), A(l, "d", t), A(u, "d", t), D(c, w(x, {
|
|
1221
|
+
when: r,
|
|
1222
|
+
get children() {
|
|
1223
|
+
var e = ye();
|
|
1224
|
+
return D(e, r), T(() => ({
|
|
1225
|
+
e: O(it),
|
|
1226
|
+
t: s.partForName("edge-label"),
|
|
1227
|
+
a: a.x,
|
|
1228
|
+
o: a.y - 4,
|
|
1229
|
+
i: String(N.portFontSize)
|
|
1230
|
+
}), ({ e: t, t: n, a: r, o: i, i: a }, o) => {
|
|
1231
|
+
C(e, t, o?.e), n !== o?.t && A(e, "part", n), r !== o?.a && A(e, "x", r), i !== o?.o && A(e, "y", i), a !== o?.i && A(e, "font-size", a);
|
|
1232
|
+
}), e;
|
|
1233
|
+
}
|
|
1234
|
+
}), null), T(() => ({
|
|
1235
|
+
e: O([
|
|
1236
|
+
tt,
|
|
1237
|
+
n && `kind-${n}`,
|
|
1238
|
+
s.edgeClass(e.edge),
|
|
1239
|
+
{
|
|
1240
|
+
[Q]: s.lit.has(e.path),
|
|
1241
|
+
[$]: s.selectedPath === e.path
|
|
1242
|
+
}
|
|
1243
|
+
]),
|
|
1244
|
+
t: O(rt),
|
|
1245
|
+
a: O(nt),
|
|
1246
|
+
o: [s.partForName("edge"), n && `kind-${n}`].filter(Boolean).join(" ")
|
|
1247
|
+
}), ({ e, t, a: n, o: r }, i) => {
|
|
1248
|
+
C(c, e, i?.e), C(l, t, i?.t), C(u, n, i?.a), r !== i?.o && A(u, "part", r);
|
|
1249
|
+
}), c;
|
|
1250
|
+
}
|
|
1251
|
+
unhover(e) {
|
|
1252
|
+
this.hovered?.path === e && (this.hovered = void 0);
|
|
1253
|
+
}
|
|
1254
|
+
static graphFrom(e) {
|
|
1255
|
+
if (!e || typeof e != "object" || !Array.isArray(e.nodes)) return;
|
|
1256
|
+
let t = e;
|
|
1257
|
+
return {
|
|
1258
|
+
nodes: t.nodes,
|
|
1259
|
+
edges: Array.isArray(t.edges) ? t.edges : []
|
|
1260
|
+
};
|
|
1261
|
+
}
|
|
1262
|
+
static viewFrom(e) {
|
|
1263
|
+
return M.includes(e) ? e : void 0;
|
|
1264
|
+
}
|
|
1265
|
+
static startOpen(e, t = "") {
|
|
1266
|
+
let n = [];
|
|
1267
|
+
for (let r of e?.nodes ?? []) {
|
|
1268
|
+
let e = t ? `${t}/${r.id}` : r.id;
|
|
1269
|
+
r.open && r.children && typeof r.children == "object" && n.push(e, ..._UIGraph.startOpen(_UIGraph.graphFrom(r.children), e));
|
|
1270
|
+
}
|
|
1271
|
+
return n;
|
|
1272
|
+
}
|
|
1273
|
+
static wordFor(e) {
|
|
1274
|
+
return e && /^[\w-]+$/.test(e) ? e : void 0;
|
|
1275
|
+
}
|
|
1276
|
+
static measure(e, t, n) {
|
|
1277
|
+
return ne.widthOf(e, `${t}px ${n}`) ?? e.length * t * N.charWidth;
|
|
1278
|
+
}
|
|
1279
|
+
};
|
|
1280
|
+
V = n(B), H = /* @__PURE__ */ new WeakMap(), U = /* @__PURE__ */ new WeakMap(), W = /* @__PURE__ */ new WeakMap(), G = /* @__PURE__ */ new WeakMap(), K = /* @__PURE__ */ new WeakMap(), q = /* @__PURE__ */ new WeakMap(), J = /* @__PURE__ */ new WeakMap(), Y = /* @__PURE__ */ new WeakMap(), o(V, 4, "loadedChildren", Re, X, H), o(V, 4, "loadingPaths", Le, X, U), o(V, 4, "openPaths", Ie, X, W), o(V, 4, "drillPaths", Fe, X, G), o(V, 4, "modalPath", Pe, X, K), o(V, 2, "shownGraph", Ne, X), o(V, 2, "layout", Me, X), o(V, 2, "fontFamily", je, X), o(V, 1, "onPathChanged", Ae, X), o(V, 1, "toggle", ke, X), o(V, 2, "isDrilled", Oe, X), o(V, 4, "hovered", De, X, q), o(V, 2, "lit", Ee, X), o(V, 1, "choose", Te, X), o(V, 4, "view", z, X, J), o(V, 4, "isPanning", we, X, Y), o(V, 2, "isPanningNow", Ce, X), o(V, 1, "fit", Se, X), o(V, 1, "onGraphChanged", xe, X), o(V, 1, "onLayoutChanged", R, X), o(V, 1, "watchSize", L, X), o(V, 1, "onModalPathChanged", I, X), o(V, 1, "onModalClosed", F, X), o(V, 13, "vocabulary", Be, X), o(V, 13, "elementSetup", ze, X), c(V, X), i(X, "UIGraph"), r(X, "vocabulary", l(V, 40, X, se)), l(V, 43, X), r(X, "elementSetup", l(V, 44, X, {
|
|
1281
|
+
styleSheets: { graph: ce },
|
|
1282
|
+
delegatesFocus: !1,
|
|
1283
|
+
DOMElement: DOMGraphElement
|
|
1284
|
+
})), l(V, 47, X);
|
|
1285
|
+
var Ve = X, He = 4, Ue = "empty", We = "toolbar", Ge = "breadcrumbs", Ke = "canvas", qe = "node", Je = "container", Ye = "box", Xe = "label", Ze = "port", Qe = "port-dot", Z = "port-label", $e = "pin", et = "pin-mark", tt = "edge-group", nt = "edge", rt = "edge-hit", it = "edge-label", Q = "lit", $ = "selected", at = "loading", ot = "toggle", st = "toggle-target", ct = "toggle-circle", lt = "toggle-mark", ut = "modal-graph-box", dt = "modal-graph", ft = "70vh", pt = "M-3 0H3M0 -3V3", mt = "M-3 0H3";
|
|
1286
|
+
// src/components/ui-graph/index.ts
|
|
1287
|
+
re([
|
|
1288
|
+
"click",
|
|
1289
|
+
"pointerdown",
|
|
1290
|
+
"dblclick",
|
|
1291
|
+
"keydown"
|
|
1292
|
+
]), Ve.define();
|
|
1293
|
+
export { DOMGraphElement, N as GRAPH_METRICS, M as GraphChildViews, P as GraphLayout, oe as GraphPortSides, Ve as UIGraph };
|
|
1294
|
+
|
|
1295
|
+
//# sourceMappingURL=ui-graph.js.map
|