glassbrain 0.2.0-alpha.5 → 0.2.0-alpha.7
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.md +18 -12
- package/dist/adapters.js +25 -1
- package/dist/chunks/{chunk-3JGZ27DC.js → chunk-3KUNYSJE.js} +6 -3
- package/dist/chunks/{chunk-F4HDKER4.js → chunk-FNTYI7VP.js} +291 -112
- package/dist/chunks/{chunk-WUBELTBU.js → chunk-GZSWZSSE.js} +392 -339
- package/dist/chunks/{chunk-G7XWVKHN.js → chunk-LK77SYCN.js} +39 -5
- package/dist/chunks/{chunk-ISWKAU5G.js → chunk-Q35ZKWKF.js} +3 -5
- package/dist/cli/glassbrain.js +552 -380
- package/dist/cli/viewer.js +92 -63
- package/dist/core.d.ts +1 -0
- package/dist/core.js +13 -5
- package/dist/edit.d.ts +5 -3
- package/dist/index.js +15 -7
- package/dist/internal.js +15 -7
- package/dist/kinds.d.ts +23 -0
- package/dist/layers.d.ts +1 -1
- package/dist/model.d.ts +15 -5
- package/dist/profile.d.ts +14 -2
- package/dist/react/DetailPanel.js +2 -2
- package/dist/react/GlassPlanes.d.ts +11 -0
- package/dist/react/GraphCanvas.d.ts +2 -0
- package/dist/react/GraphCanvas.js +4 -4
- package/dist/react/icons.d.ts +2 -0
- package/dist/strings.d.ts +2 -2
- package/dist/tree.d.ts +11 -0
- package/package.json +1 -1
- package/schema/graph.schema.json +125 -23
- package/schema/profile.schema.json +2 -2
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
indexModel,
|
|
32
32
|
isFiltering,
|
|
33
33
|
isNarrowing,
|
|
34
|
+
kindTable,
|
|
34
35
|
mixHex,
|
|
35
36
|
nodeWeight,
|
|
36
37
|
originView,
|
|
@@ -53,17 +54,17 @@ import {
|
|
|
53
54
|
unionSides,
|
|
54
55
|
untheme,
|
|
55
56
|
validateModel
|
|
56
|
-
} from "./chunk-
|
|
57
|
+
} from "./chunk-FNTYI7VP.js";
|
|
57
58
|
import {
|
|
58
59
|
DetailPanel,
|
|
59
60
|
I,
|
|
60
61
|
Icon,
|
|
61
62
|
StringsContext,
|
|
62
63
|
useStrings
|
|
63
|
-
} from "./chunk-
|
|
64
|
+
} from "./chunk-3KUNYSJE.js";
|
|
64
65
|
import {
|
|
65
66
|
EN
|
|
66
|
-
} from "./chunk-
|
|
67
|
+
} from "./chunk-Q35ZKWKF.js";
|
|
67
68
|
import {
|
|
68
69
|
LAYOUTS,
|
|
69
70
|
inlinePool
|
|
@@ -956,6 +957,11 @@ function readOrder(elements) {
|
|
|
956
957
|
orderedKids.set(parent, sorted);
|
|
957
958
|
any = true;
|
|
958
959
|
}
|
|
960
|
+
const roots = [...nodeIds].filter((id) => !rawParent.has(id));
|
|
961
|
+
if (roots.length > 1 && roots.every((id) => rawOrder.get(id) !== null) && new Set(roots.map((id) => rawOrder.get(id))).size === roots.length) {
|
|
962
|
+
orderedKids.set(VIRTUAL_PARENT, roots.sort((a, b) => rawOrder.get(a) - rawOrder.get(b)));
|
|
963
|
+
any = true;
|
|
964
|
+
}
|
|
959
965
|
return nodeIds.size ? { parentOf, orderedKids, nodeIds, any } : null;
|
|
960
966
|
}
|
|
961
967
|
function shuffled(ids, random) {
|
|
@@ -995,7 +1001,7 @@ function orderSeed(elements, info, dims = {}, random = Math.random) {
|
|
|
995
1001
|
};
|
|
996
1002
|
const out = {};
|
|
997
1003
|
const placeChildren = (parent, ids, parentRadius, sector) => {
|
|
998
|
-
const list =
|
|
1004
|
+
const list = info.orderedKids.get(parent ?? VIRTUAL_PARENT) ?? shuffled(ids, random);
|
|
999
1005
|
if (!list.length) return;
|
|
1000
1006
|
const span = sector ? (sector.to - sector.from) / list.length : TAU / (list.length + 1);
|
|
1001
1007
|
list.forEach((id, i) => {
|
|
@@ -1022,7 +1028,7 @@ function orderSeed(elements, info, dims = {}, random = Math.random) {
|
|
|
1022
1028
|
}
|
|
1023
1029
|
|
|
1024
1030
|
// src/layout/engine.ts
|
|
1025
|
-
var CACHE_PREFIX = "gb:pos:
|
|
1031
|
+
var CACHE_PREFIX = "gb:pos:v7:";
|
|
1026
1032
|
var CACHE_KEEP = 16;
|
|
1027
1033
|
function shapeHash(elements, salt) {
|
|
1028
1034
|
const parts = [];
|
|
@@ -1708,7 +1714,7 @@ function LayerPicker({ layers, view, setView, disabled, collapsed }) {
|
|
|
1708
1714
|
const ro = new ResizeObserver(measure);
|
|
1709
1715
|
ro.observe(root);
|
|
1710
1716
|
return () => ro.disconnect();
|
|
1711
|
-
}, [single, layers.length]);
|
|
1717
|
+
}, [single, layers.length, collapsed]);
|
|
1712
1718
|
useLayoutEffect2(() => {
|
|
1713
1719
|
const root = box.current;
|
|
1714
1720
|
if (!root) return;
|
|
@@ -1744,6 +1750,7 @@ function LayerPicker({ layers, view, setView, disabled, collapsed }) {
|
|
|
1744
1750
|
{
|
|
1745
1751
|
"data-v": l.id,
|
|
1746
1752
|
disabled,
|
|
1753
|
+
tabIndex: collapsed ? -1 : void 0,
|
|
1747
1754
|
className: lit ? "on" : "",
|
|
1748
1755
|
...stacked ? { "aria-pressed": lit } : { role: "radio", "aria-checked": lit },
|
|
1749
1756
|
title: stacked ? t.stackLayer(l.label, lit) : t.viewLayer(l.label),
|
|
@@ -2000,7 +2007,7 @@ function Toolbar(p) {
|
|
|
2000
2007
|
const originPick = controls.origins && p.origins.length > 1;
|
|
2001
2008
|
const multi = controls.layers && p.layers.length > 1;
|
|
2002
2009
|
const showLayer = (l) => setView(view.planes ? { layers: [...view.layers ?? [], l] } : { layers: [l] });
|
|
2003
|
-
return /* @__PURE__ */ jsxs("div", { className: `gb-bar${multi ? " has-layers" : ""}`, children: [
|
|
2010
|
+
return /* @__PURE__ */ jsxs("div", { className: `gb-bar${multi && view.planes ? " has-layers" : ""}`, children: [
|
|
2004
2011
|
controls.search && /* @__PURE__ */ jsx(
|
|
2005
2012
|
SearchBox,
|
|
2006
2013
|
{
|
|
@@ -2050,7 +2057,6 @@ function Toolbar(p) {
|
|
|
2050
2057
|
] })
|
|
2051
2058
|
] });
|
|
2052
2059
|
}
|
|
2053
|
-
var GROUP_CAP = 100;
|
|
2054
2060
|
function Issues({ issues, onPick }) {
|
|
2055
2061
|
const t = useStrings();
|
|
2056
2062
|
const pop = usePopover(ISSUES_PLACE);
|
|
@@ -2058,28 +2064,31 @@ function Issues({ issues, onPick }) {
|
|
|
2058
2064
|
const by = /* @__PURE__ */ new Map();
|
|
2059
2065
|
for (const it of issues) {
|
|
2060
2066
|
const name = it.group ?? it.kind;
|
|
2061
|
-
const
|
|
2067
|
+
const key = `${it.level}:${name}`;
|
|
2068
|
+
const g = by.get(key) ?? by.set(key, { name, level: it.level, items: [] }).get(key);
|
|
2062
2069
|
g.items.push(it);
|
|
2063
|
-
if (it.level === "error") g.error = true;
|
|
2064
2070
|
}
|
|
2065
|
-
|
|
2071
|
+
const rank = { error: 0, warn: 1, info: 2 };
|
|
2072
|
+
return [...by.values()].sort((a, b) => rank[a.level] - rank[b.level]);
|
|
2066
2073
|
}, [issues]);
|
|
2067
2074
|
const errors = issues.filter((i) => i.level === "error").length;
|
|
2068
|
-
const warns = issues.
|
|
2075
|
+
const warns = issues.filter((i) => i.level === "warn").length;
|
|
2076
|
+
const infos = issues.filter((i) => i.level === "info").length;
|
|
2077
|
+
const level = groups[0].level;
|
|
2069
2078
|
const target = (it) => it.nodeId ?? it.edge?.source;
|
|
2070
2079
|
return /* @__PURE__ */ jsxs("div", { className: "gb-menu", ref: pop.ref, children: [
|
|
2071
|
-
/* @__PURE__ */
|
|
2080
|
+
/* @__PURE__ */ jsx(
|
|
2072
2081
|
"button",
|
|
2073
2082
|
{
|
|
2074
|
-
className:
|
|
2083
|
+
className: "gb-icon-btn gb-check-button",
|
|
2075
2084
|
onClick: () => pop.setOpen(!pop.open),
|
|
2076
2085
|
"aria-expanded": pop.open,
|
|
2077
|
-
title: t.issuesTip(errors, warns),
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
]
|
|
2086
|
+
title: t.issuesTip(errors, warns, infos),
|
|
2087
|
+
"aria-label": t.issuesTip(errors, warns, infos),
|
|
2088
|
+
children: /* @__PURE__ */ jsxs("span", { className: `gb-check-${level}`, "aria-hidden": "true", children: [
|
|
2089
|
+
/* @__PURE__ */ jsx(Icon, { d: I[level], size: 18 }),
|
|
2090
|
+
/* @__PURE__ */ jsx("span", { className: "gb-check-badge", children: issues.length > 99 ? "99+" : issues.length })
|
|
2091
|
+
] })
|
|
2083
2092
|
}
|
|
2084
2093
|
),
|
|
2085
2094
|
pop.open && /* @__PURE__ */ jsxs(
|
|
@@ -2088,27 +2097,33 @@ function Issues({ issues, onPick }) {
|
|
|
2088
2097
|
ref: pop.panelRef,
|
|
2089
2098
|
className: "gb-panel gb-issues",
|
|
2090
2099
|
role: "dialog",
|
|
2100
|
+
"aria-label": t.issuesTitle(errors, warns, infos),
|
|
2091
2101
|
"data-x": pop.placement?.align,
|
|
2092
2102
|
"data-y": pop.placement?.side,
|
|
2093
2103
|
style: pop.placement ? { left: pop.placement.left, top: pop.placement.top, right: "auto", bottom: "auto" } : { visibility: "hidden" },
|
|
2094
2104
|
children: [
|
|
2095
|
-
/* @__PURE__ */ jsx("div", { className: "gb-panel-h", children: t.issuesTitle(errors, warns) }),
|
|
2096
|
-
groups.map((g) => /* @__PURE__ */ jsxs("details", { open:
|
|
2097
|
-
/* @__PURE__ */ jsxs("summary", { className: g.
|
|
2098
|
-
/* @__PURE__ */
|
|
2105
|
+
/* @__PURE__ */ jsx("div", { className: "gb-panel-h", children: t.issuesTitle(errors, warns, infos) }),
|
|
2106
|
+
groups.map((g) => /* @__PURE__ */ jsxs("details", { open: g.level !== "info", children: [
|
|
2107
|
+
/* @__PURE__ */ jsxs("summary", { className: `gb-check-${g.level}`, children: [
|
|
2108
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
2109
|
+
g.level,
|
|
2110
|
+
" \xB7 ",
|
|
2111
|
+
g.name
|
|
2112
|
+
] }),
|
|
2099
2113
|
/* @__PURE__ */ jsx("b", { children: g.items.length })
|
|
2100
2114
|
] }),
|
|
2101
|
-
/* @__PURE__ */
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2115
|
+
/* @__PURE__ */ jsx("ul", { children: g.items.map((it, i) => {
|
|
2116
|
+
const id = target(it);
|
|
2117
|
+
return /* @__PURE__ */ jsxs("li", { children: [
|
|
2118
|
+
id ? /* @__PURE__ */ jsx("button", { className: "gb-issue-target", onClick: () => {
|
|
2105
2119
|
onPick(id);
|
|
2106
2120
|
pop.setOpen(false);
|
|
2107
|
-
} :
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2121
|
+
}, children: it.message }) : /* @__PURE__ */ jsx("div", { children: it.message }),
|
|
2122
|
+
it.where && /* @__PURE__ */ jsx("small", { className: "gb-issue-where", children: it.where }),
|
|
2123
|
+
it.fix && /* @__PURE__ */ jsx("div", { className: "gb-issue-fix", children: it.fix })
|
|
2124
|
+
] }, i);
|
|
2125
|
+
}) })
|
|
2126
|
+
] }, `${g.level}:${g.name}`))
|
|
2112
2127
|
]
|
|
2113
2128
|
}
|
|
2114
2129
|
)
|
|
@@ -2298,7 +2313,8 @@ function installGraphInput(cy, el, actions) {
|
|
|
2298
2313
|
el.addEventListener(name, fn, { capture, passive: false });
|
|
2299
2314
|
bindings.push(() => el.removeEventListener(name, fn, capture));
|
|
2300
2315
|
};
|
|
2301
|
-
|
|
2316
|
+
const pane = el.parentElement;
|
|
2317
|
+
const wheel = (e) => {
|
|
2302
2318
|
e.preventDefault();
|
|
2303
2319
|
interact();
|
|
2304
2320
|
if (e.ctrlKey || e.metaKey) {
|
|
@@ -2308,7 +2324,9 @@ function installGraphInput(cy, el, actions) {
|
|
|
2308
2324
|
renderedPosition: { x: e.clientX - rect.left, y: e.clientY - rect.top }
|
|
2309
2325
|
});
|
|
2310
2326
|
} else cy.panBy({ x: -e.deltaX, y: -e.deltaY });
|
|
2311
|
-
}
|
|
2327
|
+
};
|
|
2328
|
+
pane.addEventListener("wheel", wheel, { passive: false });
|
|
2329
|
+
bindings.push(() => pane.removeEventListener("wheel", wheel));
|
|
2312
2330
|
on("mouseleave", () => actions.hover?.(null));
|
|
2313
2331
|
const captured = /* @__PURE__ */ new Set();
|
|
2314
2332
|
const point = (e) => {
|
|
@@ -2415,17 +2433,51 @@ function zoomPath(a, b) {
|
|
|
2415
2433
|
}
|
|
2416
2434
|
var easeInOut = (x) => x < 0.5 ? 4 * x * x * x : 1 - Math.pow(-2 * x + 2, 3) / 2;
|
|
2417
2435
|
|
|
2436
|
+
// src/react/GlassPlanes.tsx
|
|
2437
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
2438
|
+
function GlassPlanes({ plates, viewport, theme, alpha, hot }) {
|
|
2439
|
+
return /* @__PURE__ */ jsx2("div", { className: "gb-glass-planes", style: { opacity: alpha }, "aria-hidden": "true", children: plates.map((p) => {
|
|
2440
|
+
const points = p.points.map(([x, y]) => [x * viewport.zoom + viewport.pan.x, y * viewport.zoom + viewport.pan.y]);
|
|
2441
|
+
const left = Math.min(...points.map((p2) => p2[0])), top = Math.min(...points.map((p2) => p2[1]));
|
|
2442
|
+
const width = Math.max(...points.map((p2) => p2[0])) - left, height = Math.max(...points.map((p2) => p2[1])) - top;
|
|
2443
|
+
if (width <= 0 || height <= 0) return null;
|
|
2444
|
+
const local = points.map(([x, y]) => [x - left, y - top]);
|
|
2445
|
+
const clip = `polygon(${local.map(([x, y]) => `${100 * x / width}% ${100 * y / height}%`).join(",")})`;
|
|
2446
|
+
const c = plateColors(theme, p.color);
|
|
2447
|
+
const hue = mixHex(theme.canvas, p.color, 0.64);
|
|
2448
|
+
return /* @__PURE__ */ jsxs2(
|
|
2449
|
+
"div",
|
|
2450
|
+
{
|
|
2451
|
+
className: "gb-glass-plane",
|
|
2452
|
+
"data-layer": p.layer,
|
|
2453
|
+
style: { left, top, width, height, opacity: (p.alpha ?? 1) * (hot && hot !== p.layer ? 0.45 : 1) },
|
|
2454
|
+
children: [
|
|
2455
|
+
/* @__PURE__ */ jsx2("div", { className: "gb-glass-surface", style: {
|
|
2456
|
+
clipPath: clip,
|
|
2457
|
+
background: `linear-gradient(165deg, #ffffff26, #ffffff00 38%), linear-gradient(145deg, ${hue}6d, ${hue}${hot === p.layer ? "48" : "2d"} 55%, ${hue}5b)`
|
|
2458
|
+
} }),
|
|
2459
|
+
/* @__PURE__ */ jsxs2("svg", { width, height, className: "gb-glass-rim", children: [
|
|
2460
|
+
/* @__PURE__ */ jsx2("polygon", { points: local.map((p2) => p2.join(",")).join(" "), fill: "none", stroke: c.stroke, strokeOpacity: 0.8, strokeWidth: hot === p.layer ? 2.25 : 1.5 }),
|
|
2461
|
+
/* @__PURE__ */ jsx2("polyline", { points: local.slice(0, 3).map((p2) => p2.join(",")).join(" "), fill: "none", stroke: mixHex(p.color, "#ffffff", 0.72), strokeOpacity: 0.85, strokeWidth: 1.25 })
|
|
2462
|
+
] })
|
|
2463
|
+
]
|
|
2464
|
+
},
|
|
2465
|
+
p.layer
|
|
2466
|
+
);
|
|
2467
|
+
}) });
|
|
2468
|
+
}
|
|
2469
|
+
|
|
2418
2470
|
// src/react/EditPanel.tsx
|
|
2419
2471
|
import { useEffect as useEffect2, useId, useMemo as useMemo2, useRef as useRef2, useState as useState3 } from "react";
|
|
2420
|
-
import { Fragment as Fragment2, jsx as
|
|
2472
|
+
import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
2421
2473
|
var PICK_MAX = 8;
|
|
2422
2474
|
function NodeRef({ id, model, colorOf, sub }) {
|
|
2423
2475
|
const n = model.index.get(id);
|
|
2424
|
-
return /* @__PURE__ */
|
|
2425
|
-
/* @__PURE__ */
|
|
2426
|
-
/* @__PURE__ */
|
|
2427
|
-
/* @__PURE__ */
|
|
2428
|
-
sub && /* @__PURE__ */
|
|
2476
|
+
return /* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
2477
|
+
/* @__PURE__ */ jsx3("i", { className: "gb-dot", style: { background: colorOf(id) } }),
|
|
2478
|
+
/* @__PURE__ */ jsxs3("span", { className: "gb-ref-main", children: [
|
|
2479
|
+
/* @__PURE__ */ jsx3("span", { className: "gb-ref-label", children: n?.label ?? id }),
|
|
2480
|
+
sub && /* @__PURE__ */ jsx3("span", { className: "gb-ref-sub", children: sub })
|
|
2429
2481
|
] })
|
|
2430
2482
|
] });
|
|
2431
2483
|
}
|
|
@@ -2456,8 +2508,8 @@ function NodePicker({ model, value, onChange, exclude, empty, autoFocus, label,
|
|
|
2456
2508
|
}
|
|
2457
2509
|
});
|
|
2458
2510
|
const pathOf = (id) => idx.ancestorsOf(id).slice(0, 2).reverse().map((a) => model.index.get(a)?.label).filter(Boolean).join(" / ");
|
|
2459
|
-
return /* @__PURE__ */
|
|
2460
|
-
cur && !open ? /* @__PURE__ */
|
|
2511
|
+
return /* @__PURE__ */ jsxs3("div", { className: `gb-pick${open ? " is-open" : ""}`, children: [
|
|
2512
|
+
cur && !open ? /* @__PURE__ */ jsxs3(
|
|
2461
2513
|
"button",
|
|
2462
2514
|
{
|
|
2463
2515
|
ref: curRef,
|
|
@@ -2473,16 +2525,16 @@ function NodePicker({ model, value, onChange, exclude, empty, autoFocus, label,
|
|
|
2473
2525
|
}
|
|
2474
2526
|
},
|
|
2475
2527
|
children: [
|
|
2476
|
-
/* @__PURE__ */
|
|
2477
|
-
/* @__PURE__ */
|
|
2528
|
+
/* @__PURE__ */ jsx3(NodeRef, { id: cur.id, model, colorOf, sub: cur.id }),
|
|
2529
|
+
/* @__PURE__ */ jsx3("i", { className: "gb-pick-x", "aria-hidden": true, onClick: (e) => {
|
|
2478
2530
|
e.stopPropagation();
|
|
2479
2531
|
choose(null);
|
|
2480
|
-
}, children: /* @__PURE__ */
|
|
2532
|
+
}, children: /* @__PURE__ */ jsx3(Icon, { d: I.x, size: 12 }) })
|
|
2481
2533
|
]
|
|
2482
2534
|
}
|
|
2483
|
-
) : /* @__PURE__ */
|
|
2484
|
-
/* @__PURE__ */
|
|
2485
|
-
/* @__PURE__ */
|
|
2535
|
+
) : /* @__PURE__ */ jsxs3("span", { className: "gb-input gb-pick-field", children: [
|
|
2536
|
+
/* @__PURE__ */ jsx3(Icon, { d: I.search, size: 14 }),
|
|
2537
|
+
/* @__PURE__ */ jsx3(
|
|
2486
2538
|
"input",
|
|
2487
2539
|
{
|
|
2488
2540
|
id: inputId,
|
|
@@ -2516,7 +2568,7 @@ function NodePicker({ model, value, onChange, exclude, empty, autoFocus, label,
|
|
|
2516
2568
|
}
|
|
2517
2569
|
)
|
|
2518
2570
|
] }),
|
|
2519
|
-
open && hits.length > 0 && /* @__PURE__ */
|
|
2571
|
+
open && hits.length > 0 && /* @__PURE__ */ jsx3("ul", { className: "gb-pick-list", role: "listbox", onMouseDown: (e) => e.preventDefault(), children: hits.map((id, i) => /* @__PURE__ */ jsx3(
|
|
2520
2572
|
"li",
|
|
2521
2573
|
{
|
|
2522
2574
|
role: "option",
|
|
@@ -2524,7 +2576,7 @@ function NodePicker({ model, value, onChange, exclude, empty, autoFocus, label,
|
|
|
2524
2576
|
className: i === active ? "on" : "",
|
|
2525
2577
|
onMouseEnter: () => setActive(i),
|
|
2526
2578
|
onClick: () => choose(id),
|
|
2527
|
-
children: /* @__PURE__ */
|
|
2579
|
+
children: /* @__PURE__ */ jsx3(NodeRef, { id, model, colorOf, sub: pathOf(id) || id })
|
|
2528
2580
|
},
|
|
2529
2581
|
id
|
|
2530
2582
|
)) })
|
|
@@ -2549,7 +2601,7 @@ function readContent(text) {
|
|
|
2549
2601
|
}
|
|
2550
2602
|
function Shell({ title, onClose, onSubmit, foot, error, children }) {
|
|
2551
2603
|
const t = useStrings();
|
|
2552
|
-
return /* @__PURE__ */
|
|
2604
|
+
return /* @__PURE__ */ jsxs3(
|
|
2553
2605
|
"form",
|
|
2554
2606
|
{
|
|
2555
2607
|
className: "gb-detail gb-edit",
|
|
@@ -2561,19 +2613,19 @@ function Shell({ title, onClose, onSubmit, foot, error, children }) {
|
|
|
2561
2613
|
if (e.key === "Escape" && !e.defaultPrevented) onClose();
|
|
2562
2614
|
},
|
|
2563
2615
|
children: [
|
|
2564
|
-
/* @__PURE__ */
|
|
2565
|
-
/* @__PURE__ */
|
|
2566
|
-
/* @__PURE__ */
|
|
2616
|
+
/* @__PURE__ */ jsxs3("div", { className: "gb-dh", children: [
|
|
2617
|
+
/* @__PURE__ */ jsx3("span", { className: "gb-dh-title", children: title }),
|
|
2618
|
+
/* @__PURE__ */ jsx3("span", { className: "gb-dh-act", children: /* @__PURE__ */ jsx3("button", { type: "button", className: "gb-ibtn", onClick: onClose, "aria-label": t.close, title: t.close, children: /* @__PURE__ */ jsx3(Icon, { d: I.x, size: 15 }) }) })
|
|
2567
2619
|
] }),
|
|
2568
|
-
/* @__PURE__ */
|
|
2569
|
-
error && /* @__PURE__ */
|
|
2570
|
-
/* @__PURE__ */
|
|
2620
|
+
/* @__PURE__ */ jsx3("div", { className: "gb-db gb-form", children }),
|
|
2621
|
+
error && /* @__PURE__ */ jsx3("div", { className: "gb-edit-err", role: "alert", children: error }),
|
|
2622
|
+
/* @__PURE__ */ jsx3("div", { className: "gb-df", children: foot })
|
|
2571
2623
|
]
|
|
2572
2624
|
}
|
|
2573
2625
|
);
|
|
2574
2626
|
}
|
|
2575
2627
|
function EditPanel({ target, model, onSubmit, onCancel, onRetarget, renderEditor, colorOf = () => void 0 }) {
|
|
2576
|
-
return target.what === "node" ? /* @__PURE__ */
|
|
2628
|
+
return target.what === "node" ? /* @__PURE__ */ jsx3(
|
|
2577
2629
|
NodeForm,
|
|
2578
2630
|
{
|
|
2579
2631
|
target,
|
|
@@ -2585,7 +2637,7 @@ function EditPanel({ target, model, onSubmit, onCancel, onRetarget, renderEditor
|
|
|
2585
2637
|
colorOf
|
|
2586
2638
|
},
|
|
2587
2639
|
target.id ?? "+"
|
|
2588
|
-
) : /* @__PURE__ */
|
|
2640
|
+
) : /* @__PURE__ */ jsx3(EdgeForm, { source: target.source, model, onSubmit, onCancel, colorOf }, target.source ?? "+");
|
|
2589
2641
|
}
|
|
2590
2642
|
function useSubmit(onSubmit) {
|
|
2591
2643
|
const t = useStrings();
|
|
@@ -2610,7 +2662,11 @@ function NodeForm({ target, model, onSubmit, onCancel, onRetarget, renderEditor,
|
|
|
2610
2662
|
[node]
|
|
2611
2663
|
);
|
|
2612
2664
|
const [text, setText] = useState3(initial);
|
|
2613
|
-
const
|
|
2665
|
+
const initialBefore = useMemo2(() => {
|
|
2666
|
+
const siblings = model.nodes.filter((n) => (n.parent ?? null) === (node?.parent ?? target.parent ?? null)).sort((a, b) => (a.order ?? Infinity) - (b.order ?? Infinity));
|
|
2667
|
+
return node ? siblings[siblings.findIndex((n) => n.id === node.id) + 1]?.id ?? null : null;
|
|
2668
|
+
}, [model, node, target.parent]);
|
|
2669
|
+
const [before, setBefore] = useState3(initialBefore);
|
|
2614
2670
|
const [confirming, setConfirming] = useState3(false);
|
|
2615
2671
|
const idErr = creating && id ? checkEdit(model, { op: "addNode", id, set: {} }) : null;
|
|
2616
2672
|
const below = useMemo2(() => {
|
|
@@ -2634,9 +2690,8 @@ function NodeForm({ target, model, onSubmit, onCancel, onRetarget, renderEditor,
|
|
|
2634
2690
|
setError(t.badJson);
|
|
2635
2691
|
return;
|
|
2636
2692
|
}
|
|
2637
|
-
const order = parent && orderText.trim() ? Number(orderText) : null;
|
|
2638
2693
|
if (creating) {
|
|
2639
|
-
if (submit({ op: "addNode", id: id.trim(), set: { ...content, parent,
|
|
2694
|
+
if (submit({ op: "addNode", id: id.trim(), set: { ...content, parent, before } })) onCancel();
|
|
2640
2695
|
return;
|
|
2641
2696
|
}
|
|
2642
2697
|
const set = {};
|
|
@@ -2644,23 +2699,23 @@ function NodeForm({ target, model, onSubmit, onCancel, onRetarget, renderEditor,
|
|
|
2644
2699
|
if ((content.kind ?? void 0) !== node.kind) set.kind = content.kind;
|
|
2645
2700
|
if (pretty(content.data ?? {}) !== pretty(node.data ?? {})) set.data = content.data ?? {};
|
|
2646
2701
|
if (parent !== (node.parent ?? null)) set.parent = parent;
|
|
2647
|
-
if (
|
|
2702
|
+
if (before !== initialBefore || parent !== (node.parent ?? null)) set.before = before;
|
|
2648
2703
|
if (!Object.keys(set).length) {
|
|
2649
2704
|
onCancel();
|
|
2650
2705
|
return;
|
|
2651
2706
|
}
|
|
2652
2707
|
if (submit({ op: "updateNode", id: node.id, set })) onCancel();
|
|
2653
2708
|
};
|
|
2654
|
-
const foot = confirming && node ? /* @__PURE__ */
|
|
2655
|
-
/* @__PURE__ */
|
|
2656
|
-
/* @__PURE__ */
|
|
2657
|
-
/* @__PURE__ */
|
|
2658
|
-
/* @__PURE__ */
|
|
2709
|
+
const foot = confirming && node ? /* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
2710
|
+
/* @__PURE__ */ jsx3("span", { className: "gb-confirm", children: t.confirmRemove(edges.length) }),
|
|
2711
|
+
/* @__PURE__ */ jsxs3("span", { className: "gb-form-act", children: [
|
|
2712
|
+
/* @__PURE__ */ jsx3("button", { type: "button", className: "gb-btn", onClick: () => setConfirming(false), children: t.cancel }),
|
|
2713
|
+
/* @__PURE__ */ jsx3("button", { type: "button", className: "gb-btn gb-danger", onClick: () => {
|
|
2659
2714
|
if (submit({ op: "removeNode", id: node.id })) onCancel();
|
|
2660
2715
|
}, children: t.remove })
|
|
2661
2716
|
] })
|
|
2662
|
-
] }) : /* @__PURE__ */
|
|
2663
|
-
node ? /* @__PURE__ */
|
|
2717
|
+
] }) : /* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
2718
|
+
node ? /* @__PURE__ */ jsx3(
|
|
2664
2719
|
"button",
|
|
2665
2720
|
{
|
|
2666
2721
|
type: "button",
|
|
@@ -2670,17 +2725,17 @@ function NodeForm({ target, model, onSubmit, onCancel, onRetarget, renderEditor,
|
|
|
2670
2725
|
onClick: () => setConfirming(true),
|
|
2671
2726
|
children: t.remove
|
|
2672
2727
|
}
|
|
2673
|
-
) : /* @__PURE__ */
|
|
2674
|
-
/* @__PURE__ */
|
|
2675
|
-
/* @__PURE__ */
|
|
2676
|
-
/* @__PURE__ */
|
|
2728
|
+
) : /* @__PURE__ */ jsx3("span", {}),
|
|
2729
|
+
/* @__PURE__ */ jsxs3("span", { className: "gb-form-act", children: [
|
|
2730
|
+
/* @__PURE__ */ jsx3("button", { type: "button", className: "gb-btn", onClick: onCancel, children: t.cancel }),
|
|
2731
|
+
/* @__PURE__ */ jsx3("button", { type: "submit", className: "gb-btn gb-primary", disabled: creating && (!id.trim() || !!idErr), children: creating ? t.create : t.save })
|
|
2677
2732
|
] })
|
|
2678
2733
|
] });
|
|
2679
|
-
return /* @__PURE__ */
|
|
2680
|
-
/* @__PURE__ */
|
|
2681
|
-
/* @__PURE__ */
|
|
2682
|
-
creating ? /* @__PURE__ */
|
|
2683
|
-
/* @__PURE__ */
|
|
2734
|
+
return /* @__PURE__ */ jsxs3(Shell, { title: creating ? t.newNode : t.editNode, onClose: onCancel, onSubmit: save, foot, error, children: [
|
|
2735
|
+
/* @__PURE__ */ jsxs3("div", { className: "gb-fld", children: [
|
|
2736
|
+
/* @__PURE__ */ jsx3("label", { className: "gb-k", htmlFor: `${uid}-id`, children: t.id }),
|
|
2737
|
+
creating ? /* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
2738
|
+
/* @__PURE__ */ jsx3(
|
|
2684
2739
|
"input",
|
|
2685
2740
|
{
|
|
2686
2741
|
id: `${uid}-id`,
|
|
@@ -2691,18 +2746,21 @@ function NodeForm({ target, model, onSubmit, onCancel, onRetarget, renderEditor,
|
|
|
2691
2746
|
onChange: (e) => setId(e.target.value)
|
|
2692
2747
|
}
|
|
2693
2748
|
),
|
|
2694
|
-
/* @__PURE__ */
|
|
2695
|
-
] }) : /* @__PURE__ */
|
|
2749
|
+
/* @__PURE__ */ jsx3("small", { className: idErr ? "is-bad" : "", children: idErr ? t.error[idErr] : t.idHint })
|
|
2750
|
+
] }) : /* @__PURE__ */ jsx3("code", { className: "gb-id", children: node.id })
|
|
2696
2751
|
] }),
|
|
2697
|
-
/* @__PURE__ */
|
|
2698
|
-
/* @__PURE__ */
|
|
2699
|
-
/* @__PURE__ */
|
|
2752
|
+
/* @__PURE__ */ jsxs3("div", { className: "gb-fld", children: [
|
|
2753
|
+
/* @__PURE__ */ jsx3("label", { className: "gb-k", htmlFor: `${uid}-parent`, children: t.parent }),
|
|
2754
|
+
/* @__PURE__ */ jsx3(
|
|
2700
2755
|
NodePicker,
|
|
2701
2756
|
{
|
|
2702
2757
|
id: `${uid}-parent`,
|
|
2703
2758
|
model,
|
|
2704
2759
|
value: parent,
|
|
2705
|
-
onChange:
|
|
2760
|
+
onChange: (id2) => {
|
|
2761
|
+
setParent(id2);
|
|
2762
|
+
setBefore(null);
|
|
2763
|
+
},
|
|
2706
2764
|
empty: t.noParent,
|
|
2707
2765
|
label: t.parent,
|
|
2708
2766
|
exclude: below ? (x) => below.has(x) : void 0,
|
|
@@ -2710,30 +2768,20 @@ function NodeForm({ target, model, onSubmit, onCancel, onRetarget, renderEditor,
|
|
|
2710
2768
|
}
|
|
2711
2769
|
)
|
|
2712
2770
|
] }),
|
|
2713
|
-
/* @__PURE__ */
|
|
2714
|
-
/* @__PURE__ */
|
|
2715
|
-
/* @__PURE__ */
|
|
2716
|
-
"
|
|
2717
|
-
{
|
|
2718
|
-
|
|
2719
|
-
className: "gb-input",
|
|
2720
|
-
type: "number",
|
|
2721
|
-
min: "0",
|
|
2722
|
-
step: "any",
|
|
2723
|
-
disabled: !parent,
|
|
2724
|
-
placeholder: "Unordered",
|
|
2725
|
-
value: orderText,
|
|
2726
|
-
onChange: (e) => setOrderText(e.target.value)
|
|
2727
|
-
}
|
|
2728
|
-
)
|
|
2771
|
+
/* @__PURE__ */ jsxs3("div", { className: "gb-fld", children: [
|
|
2772
|
+
/* @__PURE__ */ jsx3("label", { className: "gb-k", htmlFor: `${uid}-before`, children: "Before" }),
|
|
2773
|
+
/* @__PURE__ */ jsxs3("select", { id: `${uid}-before`, className: "gb-input", value: before ?? "", onChange: (e) => setBefore(e.target.value || null), children: [
|
|
2774
|
+
/* @__PURE__ */ jsx3("option", { value: "", children: "Last" }),
|
|
2775
|
+
model.nodes.filter((n) => n.id !== node?.id && (n.parent ?? null) === parent).sort((a, b) => (a.order ?? Infinity) - (b.order ?? Infinity)).map((n) => /* @__PURE__ */ jsx3("option", { value: n.id, children: n.label }, n.id))
|
|
2776
|
+
] })
|
|
2729
2777
|
] }),
|
|
2730
|
-
/* @__PURE__ */
|
|
2731
|
-
/* @__PURE__ */
|
|
2778
|
+
/* @__PURE__ */ jsxs3("div", { className: "gb-fld gb-grow", children: [
|
|
2779
|
+
/* @__PURE__ */ jsxs3("label", { className: "gb-k", htmlFor: `${uid}-json`, children: [
|
|
2732
2780
|
t.content,
|
|
2733
2781
|
" ",
|
|
2734
|
-
/* @__PURE__ */
|
|
2782
|
+
/* @__PURE__ */ jsx3("em", { children: t.contentHint })
|
|
2735
2783
|
] }),
|
|
2736
|
-
renderEditor ? renderEditor({ value: text, onChange: setText }) : /* @__PURE__ */
|
|
2784
|
+
renderEditor ? renderEditor({ value: text, onChange: setText }) : /* @__PURE__ */ jsx3(
|
|
2737
2785
|
"textarea",
|
|
2738
2786
|
{
|
|
2739
2787
|
id: `${uid}-json`,
|
|
@@ -2745,19 +2793,19 @@ function NodeForm({ target, model, onSubmit, onCancel, onRetarget, renderEditor,
|
|
|
2745
2793
|
}
|
|
2746
2794
|
)
|
|
2747
2795
|
] }),
|
|
2748
|
-
node && /* @__PURE__ */
|
|
2749
|
-
/* @__PURE__ */
|
|
2796
|
+
node && /* @__PURE__ */ jsxs3("div", { className: "gb-fld", children: [
|
|
2797
|
+
/* @__PURE__ */ jsxs3("span", { className: "gb-k", children: [
|
|
2750
2798
|
t.relations,
|
|
2751
2799
|
" ",
|
|
2752
|
-
/* @__PURE__ */
|
|
2800
|
+
/* @__PURE__ */ jsx3("em", { children: edges.length || "" })
|
|
2753
2801
|
] }),
|
|
2754
|
-
/* @__PURE__ */
|
|
2802
|
+
/* @__PURE__ */ jsx3("ul", { className: "gb-rel", children: edges.map((e, i) => {
|
|
2755
2803
|
const out = e.source === node.id;
|
|
2756
|
-
return /* @__PURE__ */
|
|
2757
|
-
/* @__PURE__ */
|
|
2758
|
-
/* @__PURE__ */
|
|
2759
|
-
e.kind && /* @__PURE__ */
|
|
2760
|
-
/* @__PURE__ */
|
|
2804
|
+
return /* @__PURE__ */ jsxs3("li", { children: [
|
|
2805
|
+
/* @__PURE__ */ jsx3("span", { className: "gb-rel-dir", "aria-hidden": true, children: out ? "\u2192" : "\u2190" }),
|
|
2806
|
+
/* @__PURE__ */ jsx3(NodeRef, { id: out ? e.target : e.source, model, colorOf }),
|
|
2807
|
+
e.kind && /* @__PURE__ */ jsx3("span", { className: "gb-r-kind", children: e.kind }),
|
|
2808
|
+
/* @__PURE__ */ jsx3(
|
|
2761
2809
|
"button",
|
|
2762
2810
|
{
|
|
2763
2811
|
type: "button",
|
|
@@ -2765,13 +2813,13 @@ function NodeForm({ target, model, onSubmit, onCancel, onRetarget, renderEditor,
|
|
|
2765
2813
|
"aria-label": t.removeEdge,
|
|
2766
2814
|
title: t.removeEdge,
|
|
2767
2815
|
onClick: () => submit({ op: "removeEdge", edge: { source: e.source, target: e.target, kind: e.kind } }),
|
|
2768
|
-
children: /* @__PURE__ */
|
|
2816
|
+
children: /* @__PURE__ */ jsx3(Icon, { d: I.x, size: 13 })
|
|
2769
2817
|
}
|
|
2770
2818
|
)
|
|
2771
2819
|
] }, i);
|
|
2772
2820
|
}) }),
|
|
2773
|
-
/* @__PURE__ */
|
|
2774
|
-
/* @__PURE__ */
|
|
2821
|
+
/* @__PURE__ */ jsxs3("button", { type: "button", className: "gb-add", onClick: () => onRetarget({ what: "edge", source: node.id }), children: [
|
|
2822
|
+
/* @__PURE__ */ jsx3(Icon, { d: I.plus, size: 13 }),
|
|
2775
2823
|
t.addEdge
|
|
2776
2824
|
] })
|
|
2777
2825
|
] })
|
|
@@ -2793,21 +2841,21 @@ function EdgeForm({ source: src, model, onSubmit, onCancel, colorOf }) {
|
|
|
2793
2841
|
};
|
|
2794
2842
|
if (submit(op)) onCancel();
|
|
2795
2843
|
};
|
|
2796
|
-
const foot = /* @__PURE__ */
|
|
2797
|
-
/* @__PURE__ */
|
|
2798
|
-
/* @__PURE__ */
|
|
2799
|
-
/* @__PURE__ */
|
|
2800
|
-
/* @__PURE__ */
|
|
2844
|
+
const foot = /* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
2845
|
+
/* @__PURE__ */ jsx3("span", {}),
|
|
2846
|
+
/* @__PURE__ */ jsxs3("span", { className: "gb-form-act", children: [
|
|
2847
|
+
/* @__PURE__ */ jsx3("button", { type: "button", className: "gb-btn", onClick: onCancel, children: t.cancel }),
|
|
2848
|
+
/* @__PURE__ */ jsx3("button", { type: "submit", className: "gb-btn gb-primary", disabled: !source || !target, children: t.create })
|
|
2801
2849
|
] })
|
|
2802
2850
|
] });
|
|
2803
|
-
return /* @__PURE__ */
|
|
2804
|
-
/* @__PURE__ */
|
|
2805
|
-
/* @__PURE__ */
|
|
2806
|
-
/* @__PURE__ */
|
|
2851
|
+
return /* @__PURE__ */ jsxs3(Shell, { title: t.newEdge, onClose: onCancel, onSubmit: save, foot, error, children: [
|
|
2852
|
+
/* @__PURE__ */ jsxs3("div", { className: "gb-fld", children: [
|
|
2853
|
+
/* @__PURE__ */ jsx3("label", { className: "gb-k", htmlFor: `${uid}-s`, children: t.source }),
|
|
2854
|
+
/* @__PURE__ */ jsx3(NodePicker, { id: `${uid}-s`, model, value: source, onChange: setSource, autoFocus: !src, label: t.source, colorOf })
|
|
2807
2855
|
] }),
|
|
2808
|
-
/* @__PURE__ */
|
|
2809
|
-
/* @__PURE__ */
|
|
2810
|
-
/* @__PURE__ */
|
|
2856
|
+
/* @__PURE__ */ jsxs3("div", { className: "gb-fld", children: [
|
|
2857
|
+
/* @__PURE__ */ jsx3("label", { className: "gb-k", htmlFor: `${uid}-t`, children: t.target }),
|
|
2858
|
+
/* @__PURE__ */ jsx3(
|
|
2811
2859
|
NodePicker,
|
|
2812
2860
|
{
|
|
2813
2861
|
id: `${uid}-t`,
|
|
@@ -2821,14 +2869,14 @@ function EdgeForm({ source: src, model, onSubmit, onCancel, colorOf }) {
|
|
|
2821
2869
|
}
|
|
2822
2870
|
)
|
|
2823
2871
|
] }),
|
|
2824
|
-
/* @__PURE__ */
|
|
2825
|
-
/* @__PURE__ */
|
|
2826
|
-
/* @__PURE__ */
|
|
2827
|
-
/* @__PURE__ */
|
|
2872
|
+
/* @__PURE__ */ jsxs3("div", { className: "gb-fld", children: [
|
|
2873
|
+
/* @__PURE__ */ jsx3("label", { className: "gb-k", htmlFor: `${uid}-k`, children: t.kind }),
|
|
2874
|
+
/* @__PURE__ */ jsx3("input", { id: `${uid}-k`, className: "gb-input", value: kind, list: `${uid}-kinds`, spellCheck: false, onChange: (e) => setKind(e.target.value) }),
|
|
2875
|
+
/* @__PURE__ */ jsx3("datalist", { id: `${uid}-kinds`, children: kinds.map((k) => /* @__PURE__ */ jsx3("option", { value: k }, k)) })
|
|
2828
2876
|
] }),
|
|
2829
|
-
/* @__PURE__ */
|
|
2830
|
-
/* @__PURE__ */
|
|
2831
|
-
/* @__PURE__ */
|
|
2877
|
+
/* @__PURE__ */ jsxs3("div", { className: "gb-fld", children: [
|
|
2878
|
+
/* @__PURE__ */ jsx3("label", { className: "gb-k", htmlFor: `${uid}-l`, children: t.edgeLabel }),
|
|
2879
|
+
/* @__PURE__ */ jsx3("input", { id: `${uid}-l`, className: "gb-input", value: label, spellCheck: false, onChange: (e) => setLabel(e.target.value) })
|
|
2832
2880
|
] })
|
|
2833
2881
|
] });
|
|
2834
2882
|
}
|
|
@@ -2836,15 +2884,15 @@ function EdgeForm({ source: src, model, onSubmit, onCancel, colorOf }) {
|
|
|
2836
2884
|
// src/react/Legend.tsx
|
|
2837
2885
|
import { useCallback, useEffect as useEffect3, useLayoutEffect as useLayoutEffect3, useMemo as useMemo3, useRef as useRef3, useState as useState4 } from "react";
|
|
2838
2886
|
import { createPortal } from "react-dom";
|
|
2839
|
-
import { jsx as
|
|
2887
|
+
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
2840
2888
|
function applyLook(profile, look) {
|
|
2841
2889
|
if (!look || !(look.nodePalette || look.edgePalette || look.nodeSize || look.edgeWidth)) return profile;
|
|
2842
2890
|
return {
|
|
2843
2891
|
...profile,
|
|
2844
|
-
nodePalette:
|
|
2845
|
-
edgePalette:
|
|
2846
|
-
nodeSize:
|
|
2847
|
-
edgeWidth:
|
|
2892
|
+
nodePalette: kindTable(profile.nodePalette, look.nodePalette),
|
|
2893
|
+
edgePalette: kindTable(profile.edgePalette, look.edgePalette),
|
|
2894
|
+
nodeSize: kindTable(profile.nodeSize, look.nodeSize),
|
|
2895
|
+
edgeWidth: kindTable(profile.edgeWidth, look.edgeWidth)
|
|
2848
2896
|
};
|
|
2849
2897
|
}
|
|
2850
2898
|
var isEmptyLook = (l) => !l.skeleton && ![l.nodePalette, l.edgePalette, l.nodeSize, l.edgeWidth].some((m) => m && Object.keys(m).length);
|
|
@@ -2872,15 +2920,15 @@ function readMarks(c, cy, style, nodeKinds, edgeKinds) {
|
|
|
2872
2920
|
};
|
|
2873
2921
|
}
|
|
2874
2922
|
function tally(model, profile) {
|
|
2875
|
-
const nodes =
|
|
2876
|
-
const edges =
|
|
2923
|
+
const nodes = /* @__PURE__ */ Object.create(null);
|
|
2924
|
+
const edges = /* @__PURE__ */ Object.create(null);
|
|
2877
2925
|
let plain = 0;
|
|
2878
2926
|
for (const n of model.nodes) {
|
|
2879
2927
|
const hollow = !!n.flags?.some((f) => profile.placeholderFlags.includes(f));
|
|
2880
2928
|
if (!hollow && n.kind) nodes[n.kind] = (nodes[n.kind] ?? 0) + 1;
|
|
2881
2929
|
else plain++;
|
|
2882
2930
|
}
|
|
2883
|
-
for (const e of model.edges) if (e.kind &&
|
|
2931
|
+
for (const e of model.edges) if (e.kind && Object.hasOwn(profile.edgePalette, e.kind)) edges[e.kind] = (edges[e.kind] ?? 0) + 1;
|
|
2884
2932
|
return { nodes, edges, plain };
|
|
2885
2933
|
}
|
|
2886
2934
|
var SCALES = [0.5, 1, 2];
|
|
@@ -2911,7 +2959,7 @@ function Item(p) {
|
|
|
2911
2959
|
ctl.done(k, byKeyboard);
|
|
2912
2960
|
if (byKeyboard) btn.current?.focus({ preventScroll: true });
|
|
2913
2961
|
};
|
|
2914
|
-
return /* @__PURE__ */
|
|
2962
|
+
return /* @__PURE__ */ jsxs4(
|
|
2915
2963
|
"span",
|
|
2916
2964
|
{
|
|
2917
2965
|
ref: item,
|
|
@@ -2928,7 +2976,7 @@ function Item(p) {
|
|
|
2928
2976
|
if (!e.currentTarget.contains(e.relatedTarget) && !e.relatedTarget?.closest?.(".gb-lg-pop")) ctl.focus(k, false, false);
|
|
2929
2977
|
},
|
|
2930
2978
|
children: [
|
|
2931
|
-
/* @__PURE__ */
|
|
2979
|
+
/* @__PURE__ */ jsxs4(
|
|
2932
2980
|
"button",
|
|
2933
2981
|
{
|
|
2934
2982
|
ref: btn,
|
|
@@ -2942,12 +2990,12 @@ function Item(p) {
|
|
|
2942
2990
|
onFocus: (e) => ctl.focus(k, true, e.currentTarget.matches(":focus-visible")),
|
|
2943
2991
|
children: [
|
|
2944
2992
|
p.mark,
|
|
2945
|
-
p.label && /* @__PURE__ */
|
|
2946
|
-
p.count != null && /* @__PURE__ */
|
|
2993
|
+
p.label && /* @__PURE__ */ jsx4("span", { children: p.label }),
|
|
2994
|
+
p.count != null && /* @__PURE__ */ jsx4("b", { children: p.count })
|
|
2947
2995
|
]
|
|
2948
2996
|
}
|
|
2949
2997
|
),
|
|
2950
|
-
open && portalRoot && createPortal(/* @__PURE__ */
|
|
2998
|
+
open && portalRoot && createPortal(/* @__PURE__ */ jsxs4(
|
|
2951
2999
|
"div",
|
|
2952
3000
|
{
|
|
2953
3001
|
ref: panel,
|
|
@@ -2965,7 +3013,7 @@ function Item(p) {
|
|
|
2965
3013
|
}
|
|
2966
3014
|
},
|
|
2967
3015
|
children: [
|
|
2968
|
-
p.onToggle && /* @__PURE__ */
|
|
3016
|
+
p.onToggle && /* @__PURE__ */ jsx4(
|
|
2969
3017
|
"button",
|
|
2970
3018
|
{
|
|
2971
3019
|
type: "button",
|
|
@@ -2977,12 +3025,12 @@ function Item(p) {
|
|
|
2977
3025
|
p.onToggle();
|
|
2978
3026
|
finish(e.detail === 0);
|
|
2979
3027
|
},
|
|
2980
|
-
children: /* @__PURE__ */
|
|
3028
|
+
children: /* @__PURE__ */ jsx4(Eye, { off: p.off })
|
|
2981
3029
|
}
|
|
2982
3030
|
),
|
|
2983
|
-
/* @__PURE__ */
|
|
2984
|
-
/* @__PURE__ */
|
|
2985
|
-
/* @__PURE__ */
|
|
3031
|
+
/* @__PURE__ */ jsxs4("label", { className: "gb-lg-well", title: `${t.legendColor} \xB7 ${p.color}`, children: [
|
|
3032
|
+
/* @__PURE__ */ jsx4("i", { style: { background: p.color } }),
|
|
3033
|
+
/* @__PURE__ */ jsx4(
|
|
2986
3034
|
"input",
|
|
2987
3035
|
{
|
|
2988
3036
|
ref: well,
|
|
@@ -2994,8 +3042,8 @@ function Item(p) {
|
|
|
2994
3042
|
}
|
|
2995
3043
|
)
|
|
2996
3044
|
] }),
|
|
2997
|
-
p.onScale && /* @__PURE__ */
|
|
2998
|
-
p.onScale && /* @__PURE__ */
|
|
3045
|
+
p.onScale && /* @__PURE__ */ jsx4("i", { className: "gb-lg-sep" }),
|
|
3046
|
+
p.onScale && /* @__PURE__ */ jsx4("span", { className: "gb-lg-segm", role: "group", "aria-label": t.legendSize, children: SCALES.map((s) => /* @__PURE__ */ jsx4(
|
|
2999
3047
|
"button",
|
|
3000
3048
|
{
|
|
3001
3049
|
type: "button",
|
|
@@ -3003,7 +3051,7 @@ function Item(p) {
|
|
|
3003
3051
|
"aria-pressed": s === (p.scale ?? 1),
|
|
3004
3052
|
title: `${s}\xD7`,
|
|
3005
3053
|
onClick: () => p.onScale(s),
|
|
3006
|
-
children: /* @__PURE__ */
|
|
3054
|
+
children: /* @__PURE__ */ jsx4("svg", { viewBox: "0 0 16 10", width: 16, height: 10, children: p.glyph === "line" ? /* @__PURE__ */ jsx4("line", { x1: 2, y1: 5, x2: 14, y2: 5, stroke: "currentColor", strokeWidth: s * 1.6, strokeLinecap: "round" }) : /* @__PURE__ */ jsx4("circle", { cx: 8, cy: 5, r: 1.6 + s * 1.4, fill: "currentColor" }) })
|
|
3007
3055
|
},
|
|
3008
3056
|
s
|
|
3009
3057
|
)) })
|
|
@@ -3015,7 +3063,7 @@ function Item(p) {
|
|
|
3015
3063
|
);
|
|
3016
3064
|
}
|
|
3017
3065
|
function Eye({ off }) {
|
|
3018
|
-
return /* @__PURE__ */
|
|
3066
|
+
return /* @__PURE__ */ jsxs4(
|
|
3019
3067
|
"svg",
|
|
3020
3068
|
{
|
|
3021
3069
|
viewBox: "0 0 16 16",
|
|
@@ -3027,9 +3075,9 @@ function Eye({ off }) {
|
|
|
3027
3075
|
strokeLinecap: "round",
|
|
3028
3076
|
strokeLinejoin: "round",
|
|
3029
3077
|
children: [
|
|
3030
|
-
/* @__PURE__ */
|
|
3031
|
-
/* @__PURE__ */
|
|
3032
|
-
off && /* @__PURE__ */
|
|
3078
|
+
/* @__PURE__ */ jsx4("path", { d: "M1.5 8s2.4-4.5 6.5-4.5S14.5 8 14.5 8 12.1 12.5 8 12.5 1.5 8 1.5 8Z" }),
|
|
3079
|
+
/* @__PURE__ */ jsx4("circle", { cx: 8, cy: 8, r: 2 }),
|
|
3080
|
+
off && /* @__PURE__ */ jsx4("path", { d: "M2.5 2.5l11 11" })
|
|
3033
3081
|
]
|
|
3034
3082
|
}
|
|
3035
3083
|
);
|
|
@@ -3037,14 +3085,14 @@ function Eye({ off }) {
|
|
|
3037
3085
|
function NodeMark({ color, shape = "circle", ring, off, scale = 1 }) {
|
|
3038
3086
|
const paint = off ? { fill: "none", stroke: color, strokeWidth: 1.4 } : { fill: color, stroke: ring, strokeWidth: 1.2 };
|
|
3039
3087
|
const r = (off ? 4.8 : 5.5) * (1 + 0.2 * Math.log2(scale));
|
|
3040
|
-
return /* @__PURE__ */
|
|
3088
|
+
return /* @__PURE__ */ jsx4("svg", { className: "gb-lg-mark", viewBox: "0 0 14 14", width: 14, height: 14, children: shape === "hexagon" ? /* @__PURE__ */ jsx4("polygon", { points: [0, 1, 2, 3, 4, 5].map((i) => `${7 + r * Math.sin(i * Math.PI / 3)},${7 - r * Math.cos(i * Math.PI / 3)}`).join(" "), ...paint }) : shape === "diamond" ? /* @__PURE__ */ jsx4("polygon", { points: `7,${7 - r} ${7 + r},7 7,${7 + r} ${7 - r},7`, ...paint }) : shape === "rect" ? /* @__PURE__ */ jsx4("rect", { x: 7 - r * 0.85, y: 7 - r * 0.85, width: r * 1.7, height: r * 1.7, rx: 1.5, ...paint }) : /* @__PURE__ */ jsx4("circle", { cx: 7, cy: 7, r, ...paint }) });
|
|
3041
3089
|
}
|
|
3042
3090
|
var DASH = { dashed: "4 2.5", dotted: "0.1 3" };
|
|
3043
3091
|
function EdgeMark({ color, stroke, off, scale = 1 }) {
|
|
3044
3092
|
const sw = 1.8 * (1 + 0.3 * Math.log2(scale));
|
|
3045
3093
|
const x1 = stroke.tail === "triangle" ? 6 : 2, x2 = stroke.head === "triangle" ? 18 : 22;
|
|
3046
|
-
return /* @__PURE__ */
|
|
3047
|
-
/* @__PURE__ */
|
|
3094
|
+
return /* @__PURE__ */ jsxs4("svg", { className: "gb-lg-mark", viewBox: "0 0 24 12", width: 24, height: 12, opacity: off ? 0.35 : 1, children: [
|
|
3095
|
+
/* @__PURE__ */ jsx4(
|
|
3048
3096
|
"line",
|
|
3049
3097
|
{
|
|
3050
3098
|
x1,
|
|
@@ -3057,20 +3105,20 @@ function EdgeMark({ color, stroke, off, scale = 1 }) {
|
|
|
3057
3105
|
strokeDasharray: DASH[stroke.dash]
|
|
3058
3106
|
}
|
|
3059
3107
|
),
|
|
3060
|
-
stroke.head === "triangle" && /* @__PURE__ */
|
|
3061
|
-
stroke.tail === "triangle" && /* @__PURE__ */
|
|
3062
|
-
stroke.head === "tee" && /* @__PURE__ */
|
|
3063
|
-
stroke.tail === "tee" && /* @__PURE__ */
|
|
3108
|
+
stroke.head === "triangle" && /* @__PURE__ */ jsx4("polygon", { points: "17,2.5 23,6 17,9.5", fill: color }),
|
|
3109
|
+
stroke.tail === "triangle" && /* @__PURE__ */ jsx4("polygon", { points: "7,2.5 1,6 7,9.5", fill: color }),
|
|
3110
|
+
stroke.head === "tee" && /* @__PURE__ */ jsx4("path", { d: "M22,2.5 V9.5", stroke: color, strokeWidth: 1.8 }),
|
|
3111
|
+
stroke.tail === "tee" && /* @__PURE__ */ jsx4("path", { d: "M2,2.5 V9.5", stroke: color, strokeWidth: 1.8 })
|
|
3064
3112
|
] });
|
|
3065
3113
|
}
|
|
3066
3114
|
function SkeletonEdge({ theme }) {
|
|
3067
3115
|
const id = useMemo3(() => `gb-lg-contain-${Math.random().toString(36).slice(2)}`, []);
|
|
3068
|
-
return /* @__PURE__ */
|
|
3069
|
-
/* @__PURE__ */
|
|
3070
|
-
/* @__PURE__ */
|
|
3071
|
-
/* @__PURE__ */
|
|
3116
|
+
return /* @__PURE__ */ jsxs4("svg", { className: "gb-lg-mark", viewBox: "0 0 30 12", width: 30, height: 12, children: [
|
|
3117
|
+
/* @__PURE__ */ jsx4("defs", { children: /* @__PURE__ */ jsxs4("linearGradient", { id, children: [
|
|
3118
|
+
/* @__PURE__ */ jsx4("stop", { offset: "0", stopColor: skeletonColor(theme, 0) }),
|
|
3119
|
+
/* @__PURE__ */ jsx4("stop", { offset: "1", stopColor: skeletonColor(theme, 1) })
|
|
3072
3120
|
] }) }),
|
|
3073
|
-
/* @__PURE__ */
|
|
3121
|
+
/* @__PURE__ */ jsx4("polygon", { points: "1,5.25 29,3 29,9 1,6.75", fill: `url(#${id})` })
|
|
3074
3122
|
] });
|
|
3075
3123
|
}
|
|
3076
3124
|
function LegendFrame({ collapsed, children }) {
|
|
@@ -3109,7 +3157,7 @@ function LegendFrame({ collapsed, children }) {
|
|
|
3109
3157
|
ro.observe(el);
|
|
3110
3158
|
return () => ro.disconnect();
|
|
3111
3159
|
}, []);
|
|
3112
|
-
return /* @__PURE__ */
|
|
3160
|
+
return /* @__PURE__ */ jsx4("div", { className: "gb-legend", ref: root, children });
|
|
3113
3161
|
}
|
|
3114
3162
|
function Legend(p) {
|
|
3115
3163
|
const t = useStrings();
|
|
@@ -3202,7 +3250,7 @@ function Legend(p) {
|
|
|
3202
3250
|
const name = (k) => profile.kindLabels[k] ?? k;
|
|
3203
3251
|
const colorOfKind = (k) => profile.nodePalette[k] ?? theme.skeleton;
|
|
3204
3252
|
const shown = (c) => themeColor(theme, c);
|
|
3205
|
-
const content = p.collapsed ? /* @__PURE__ */
|
|
3253
|
+
const content = p.collapsed ? /* @__PURE__ */ jsx4(
|
|
3206
3254
|
"button",
|
|
3207
3255
|
{
|
|
3208
3256
|
type: "button",
|
|
@@ -3211,20 +3259,20 @@ function Legend(p) {
|
|
|
3211
3259
|
"aria-label": t.legend,
|
|
3212
3260
|
title: t.legend,
|
|
3213
3261
|
onClick: () => p.onCollapsed(false),
|
|
3214
|
-
children: /* @__PURE__ */
|
|
3262
|
+
children: /* @__PURE__ */ jsx4(Icon, { d: I.legend })
|
|
3215
3263
|
}
|
|
3216
|
-
) : /* @__PURE__ */
|
|
3217
|
-
/* @__PURE__ */
|
|
3218
|
-
p.caption && /* @__PURE__ */
|
|
3219
|
-
/* @__PURE__ */
|
|
3220
|
-
count.plain > 0 && /* @__PURE__ */
|
|
3264
|
+
) : /* @__PURE__ */ jsxs4("div", { className: "gb-lg", ref: rootRef, children: [
|
|
3265
|
+
/* @__PURE__ */ jsxs4("div", { className: "gb-lg-body", children: [
|
|
3266
|
+
p.caption && /* @__PURE__ */ jsx4("div", { className: "gb-lg-cap", children: p.caption }),
|
|
3267
|
+
/* @__PURE__ */ jsxs4("div", { className: "gb-lg-row", children: [
|
|
3268
|
+
count.plain > 0 && /* @__PURE__ */ jsx4(
|
|
3221
3269
|
Item,
|
|
3222
3270
|
{
|
|
3223
3271
|
...slot("n:"),
|
|
3224
3272
|
color: theme.skeleton,
|
|
3225
3273
|
onPick: setSkeleton,
|
|
3226
3274
|
title: t.legendPlain,
|
|
3227
|
-
mark: /* @__PURE__ */
|
|
3275
|
+
mark: /* @__PURE__ */ jsx4(NodeMark, { color: defaultNodeColor(theme, 0.3), ring: theme.canvas }),
|
|
3228
3276
|
label: t.legendPlainName,
|
|
3229
3277
|
count: count.plain
|
|
3230
3278
|
}
|
|
@@ -3232,7 +3280,7 @@ function Legend(p) {
|
|
|
3232
3280
|
nodeKinds.map((k) => {
|
|
3233
3281
|
const off = p.hidden.nodes.includes(k);
|
|
3234
3282
|
const scale = profile.nodeSize[k] ?? 1;
|
|
3235
|
-
return /* @__PURE__ */
|
|
3283
|
+
return /* @__PURE__ */ jsx4(
|
|
3236
3284
|
Item,
|
|
3237
3285
|
{
|
|
3238
3286
|
...slot(`n:${k}`),
|
|
@@ -3244,7 +3292,7 @@ function Legend(p) {
|
|
|
3244
3292
|
scale,
|
|
3245
3293
|
glyph: "dot",
|
|
3246
3294
|
onScale: (s) => set("nodeSize", k, s),
|
|
3247
|
-
mark: /* @__PURE__ */
|
|
3295
|
+
mark: /* @__PURE__ */ jsx4(NodeMark, { color: shown(colorOfKind(k)), shape: marks.shape(k), ring: theme.canvas, off, scale }),
|
|
3248
3296
|
label: name(k),
|
|
3249
3297
|
count: count.nodes[k]
|
|
3250
3298
|
},
|
|
@@ -3252,22 +3300,22 @@ function Legend(p) {
|
|
|
3252
3300
|
);
|
|
3253
3301
|
})
|
|
3254
3302
|
] }),
|
|
3255
|
-
/* @__PURE__ */
|
|
3256
|
-
/* @__PURE__ */
|
|
3303
|
+
/* @__PURE__ */ jsxs4("div", { className: "gb-lg-row", children: [
|
|
3304
|
+
/* @__PURE__ */ jsx4(
|
|
3257
3305
|
Item,
|
|
3258
3306
|
{
|
|
3259
3307
|
...slot("e:"),
|
|
3260
3308
|
color: theme.skeleton,
|
|
3261
3309
|
onPick: setSkeleton,
|
|
3262
3310
|
title: t.legendContains,
|
|
3263
|
-
mark: /* @__PURE__ */
|
|
3311
|
+
mark: /* @__PURE__ */ jsx4(SkeletonEdge, { theme }),
|
|
3264
3312
|
label: t.legendContainsName
|
|
3265
3313
|
}
|
|
3266
3314
|
),
|
|
3267
3315
|
edgeKinds.map((k) => {
|
|
3268
3316
|
const off = p.hidden.edges.includes(k);
|
|
3269
3317
|
const scale = profile.edgeWidth[k] ?? 1;
|
|
3270
|
-
return /* @__PURE__ */
|
|
3318
|
+
return /* @__PURE__ */ jsx4(
|
|
3271
3319
|
Item,
|
|
3272
3320
|
{
|
|
3273
3321
|
...slot(`e:${k}`),
|
|
@@ -3279,7 +3327,7 @@ function Legend(p) {
|
|
|
3279
3327
|
scale,
|
|
3280
3328
|
glyph: "line",
|
|
3281
3329
|
onScale: (s) => set("edgeWidth", k, s),
|
|
3282
|
-
mark: /* @__PURE__ */
|
|
3330
|
+
mark: /* @__PURE__ */ jsx4(EdgeMark, { color: shown(profile.edgePalette[k]), stroke: marks.stroke(k), off, scale }),
|
|
3283
3331
|
label: name(k),
|
|
3284
3332
|
count: count.edges[k]
|
|
3285
3333
|
},
|
|
@@ -3288,24 +3336,24 @@ function Legend(p) {
|
|
|
3288
3336
|
})
|
|
3289
3337
|
] }),
|
|
3290
3338
|
p.delta && /* Change legend: only a legend, not a filter. Marks match the text on the graph: strikethrough = removed, underline = added. */
|
|
3291
|
-
/* @__PURE__ */
|
|
3292
|
-
/* @__PURE__ */
|
|
3293
|
-
/* @__PURE__ */
|
|
3294
|
-
/* @__PURE__ */
|
|
3339
|
+
/* @__PURE__ */ jsx4("div", { className: "gb-lg-row gb-lg-diff", children: CHANGE_ORDER.filter((k) => p.delta.counts[k] > 0).map((k) => /* @__PURE__ */ jsxs4("span", { className: `gb-lg-chg${PAST_KINDS.has(k) ? " past" : ""}`, children: [
|
|
3340
|
+
/* @__PURE__ */ jsx4("i", { style: { boxShadow: `0 0 0 2px ${DIFF_COLORS[k]}b0, 0 0 0 5px ${DIFF_COLORS[k]}40` } }),
|
|
3341
|
+
/* @__PURE__ */ jsx4("span", { style: k === "added" ? { textDecoration: `underline 2px ${DIFF_COLORS[k]}`, textUnderlineOffset: 3 } : PAST_KINDS.has(k) ? { textDecoration: `line-through 2px ${DIFF_COLORS[k]}` } : void 0, children: t.change[k] }),
|
|
3342
|
+
/* @__PURE__ */ jsx4("b", { children: p.delta.counts[k] })
|
|
3295
3343
|
] }, k)) }),
|
|
3296
|
-
/* @__PURE__ */
|
|
3344
|
+
/* @__PURE__ */ jsx4("div", { className: "gb-lg-foot", children: isEmptyLook(look) && !p.hidden.nodes.length && !p.hidden.edges.length ? /* @__PURE__ */ jsx4("span", { children: t.legendHint }) : /* @__PURE__ */ jsx4("button", { type: "button", onClick: () => {
|
|
3297
3345
|
onLook({});
|
|
3298
3346
|
p.onShowAll();
|
|
3299
3347
|
}, children: t.legendReset }) })
|
|
3300
3348
|
] }),
|
|
3301
|
-
/* @__PURE__ */
|
|
3349
|
+
/* @__PURE__ */ jsx4("span", { className: "gb-lg-act", children: /* @__PURE__ */ jsx4("button", { type: "button", className: "gb-lg-btn", onClick: () => p.onCollapsed(true), "aria-expanded": true, "aria-label": t.legend, title: t.legend, children: /* @__PURE__ */ jsx4(Icon, { d: I.collapse, size: 13 }) }) })
|
|
3302
3350
|
] });
|
|
3303
|
-
return /* @__PURE__ */
|
|
3351
|
+
return /* @__PURE__ */ jsx4(LegendFrame, { collapsed: p.collapsed, children: content });
|
|
3304
3352
|
}
|
|
3305
3353
|
|
|
3306
3354
|
// src/react/DiffOverlay.tsx
|
|
3307
3355
|
import { useMemo as useMemo4 } from "react";
|
|
3308
|
-
import { Fragment as Fragment3, jsx as
|
|
3356
|
+
import { Fragment as Fragment3, jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
3309
3357
|
var DEFAULT_MAX = 600;
|
|
3310
3358
|
var PAD2 = 4;
|
|
3311
3359
|
var GLOW_PASSES = [[26, 0.05], [15, 0.13], [6, 0.55]];
|
|
@@ -3382,11 +3430,11 @@ function DiffOverlay(p) {
|
|
|
3382
3430
|
const t = `translate(${viewport.pan.x},${viewport.pan.y}) scale(${viewport.zoom})`;
|
|
3383
3431
|
const inv = 1 / Math.max(viewport.zoom, 0.02);
|
|
3384
3432
|
const dash = { strokeDasharray: `${5 * inv} ${4 * inv}` };
|
|
3385
|
-
return /* @__PURE__ */
|
|
3386
|
-
/* @__PURE__ */
|
|
3387
|
-
INKS.map((ink) => /* @__PURE__ */
|
|
3388
|
-
edgeGlow[ink] && GLOW_EDGE_PASSES.map(([w, o]) => /* @__PURE__ */
|
|
3389
|
-
nodeGlow.map((lv, i) => lv[ink] && GLOW_PASSES.map(([w, o]) => /* @__PURE__ */
|
|
3433
|
+
return /* @__PURE__ */ jsxs5(Fragment3, { children: [
|
|
3434
|
+
/* @__PURE__ */ jsx5("svg", { className: "gb-diff-under", "aria-hidden": true, children: /* @__PURE__ */ jsxs5("g", { transform: t, children: [
|
|
3435
|
+
INKS.map((ink) => /* @__PURE__ */ jsxs5("g", { className: `gb-glow gb-glow-${ink}`, children: [
|
|
3436
|
+
edgeGlow[ink] && GLOW_EDGE_PASSES.map(([w, o]) => /* @__PURE__ */ jsx5("path", { d: edgeGlow[ink], strokeWidth: w * inv, strokeOpacity: o }, `e${w}`)),
|
|
3437
|
+
nodeGlow.map((lv, i) => lv[ink] && GLOW_PASSES.map(([w, o]) => /* @__PURE__ */ jsx5(
|
|
3390
3438
|
"path",
|
|
3391
3439
|
{
|
|
3392
3440
|
d: lv[ink],
|
|
@@ -3396,14 +3444,14 @@ function DiffOverlay(p) {
|
|
|
3396
3444
|
`n${i}-${w}`
|
|
3397
3445
|
)))
|
|
3398
3446
|
] }, ink)),
|
|
3399
|
-
wireD && /* @__PURE__ */
|
|
3447
|
+
wireD && /* @__PURE__ */ jsx5("path", { className: "gb-pastwire", d: wireD, strokeWidth: 2 * inv, style: dash })
|
|
3400
3448
|
] }) }),
|
|
3401
|
-
truncated > 0 && /* @__PURE__ */
|
|
3449
|
+
truncated > 0 && /* @__PURE__ */ jsx5("div", { className: "gb-diff-trunc", children: str.diffTruncated(truncated) })
|
|
3402
3450
|
] });
|
|
3403
3451
|
}
|
|
3404
3452
|
|
|
3405
3453
|
// src/react/GraphCanvas.tsx
|
|
3406
|
-
import { jsx as
|
|
3454
|
+
import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
3407
3455
|
var TIGHTEN_MAX = 400;
|
|
3408
3456
|
var NODE_PITCH = 150;
|
|
3409
3457
|
var SEED_MAX = 60;
|
|
@@ -3745,7 +3793,7 @@ function Drawer({ children }) {
|
|
|
3745
3793
|
}, [open]);
|
|
3746
3794
|
const content = children || (gone ? null : last.current);
|
|
3747
3795
|
if (!content) return null;
|
|
3748
|
-
return /* @__PURE__ */
|
|
3796
|
+
return /* @__PURE__ */ jsx6("div", { className: `gb-drawer${open ? "" : " is-closing"}`, children: content });
|
|
3749
3797
|
}
|
|
3750
3798
|
var DRAWER_MS = 200;
|
|
3751
3799
|
function GraphCanvas(props) {
|
|
@@ -3925,7 +3973,7 @@ function GraphCanvas(props) {
|
|
|
3925
3973
|
() => pastRenderModel ? buildElements(pastRenderModel, profile, { past: true }) : null,
|
|
3926
3974
|
[pastRenderModel, profile]
|
|
3927
3975
|
);
|
|
3928
|
-
const issues = useMemo5(() => validateModel(
|
|
3976
|
+
const issues = useMemo5(() => props.issues ?? validateModel(editingModel, profile), [props.issues, editingModel, profile]);
|
|
3929
3977
|
const onIssuesRef = useRef4(onIssues);
|
|
3930
3978
|
onIssuesRef.current = onIssues;
|
|
3931
3979
|
useEffect4(() => {
|
|
@@ -5537,6 +5585,21 @@ ${lt}`;
|
|
|
5537
5585
|
setView({ query: "" });
|
|
5538
5586
|
}, [applyHover, flyTo, selectEle, setView]);
|
|
5539
5587
|
pickRef.current = pick;
|
|
5588
|
+
const [pendingIssue, setPendingIssue] = useState5(null);
|
|
5589
|
+
const pickIssue = useCallback2((id) => {
|
|
5590
|
+
if (!model.index.has(id) && editingModel.index.has(id)) {
|
|
5591
|
+
setPendingIssue(id);
|
|
5592
|
+
setView({ planes: false });
|
|
5593
|
+
} else pick(id);
|
|
5594
|
+
}, [model, editingModel, pick, setView]);
|
|
5595
|
+
useEffect4(() => {
|
|
5596
|
+
if (!pendingIssue || !model.index.has(pendingIssue)) return;
|
|
5597
|
+
const frame = requestAnimationFrame(() => {
|
|
5598
|
+
pickRef.current(pendingIssue);
|
|
5599
|
+
setPendingIssue(null);
|
|
5600
|
+
});
|
|
5601
|
+
return () => cancelAnimationFrame(frame);
|
|
5602
|
+
}, [model, pendingIssue]);
|
|
5540
5603
|
useEffect4(() => {
|
|
5541
5604
|
if (diff) return;
|
|
5542
5605
|
setSelected((s) => {
|
|
@@ -5573,7 +5636,7 @@ ${lt}`;
|
|
|
5573
5636
|
const startAdd = useCallback2((what) => {
|
|
5574
5637
|
setEditing(what === "node" ? { what, parent: selected?.id ?? null } : { what, source: selected?.id });
|
|
5575
5638
|
}, [selected]);
|
|
5576
|
-
const editPanel = editing && /* @__PURE__ */
|
|
5639
|
+
const editPanel = editing && /* @__PURE__ */ jsx6(
|
|
5577
5640
|
EditPanel,
|
|
5578
5641
|
{
|
|
5579
5642
|
target: editing,
|
|
@@ -5611,10 +5674,10 @@ ${lt}`;
|
|
|
5611
5674
|
return () => window.removeEventListener("keydown", onKey);
|
|
5612
5675
|
}, [compact, zoomBy, fit]);
|
|
5613
5676
|
if (model.nodes.length === 0 && model.errors.length === 0) {
|
|
5614
|
-
return /* @__PURE__ */
|
|
5615
|
-
/* @__PURE__ */
|
|
5616
|
-
/* @__PURE__ */
|
|
5617
|
-
editable && !editing && /* @__PURE__ */
|
|
5677
|
+
return /* @__PURE__ */ jsx6(StringsContext.Provider, { value: strings, children: /* @__PURE__ */ jsxs6("div", { className: `gb-root ${className ?? ""}`, style: rootStyle, children: [
|
|
5678
|
+
/* @__PURE__ */ jsxs6("div", { className: "gb-empty", children: [
|
|
5679
|
+
/* @__PURE__ */ jsx6("div", { children: emptyMessage ?? strings.empty }),
|
|
5680
|
+
editable && !editing && /* @__PURE__ */ jsx6("button", { className: "gb-link", onClick: () => startAdd("node"), children: strings.addNode })
|
|
5618
5681
|
] }),
|
|
5619
5682
|
editPanel
|
|
5620
5683
|
] }) });
|
|
@@ -5622,91 +5685,79 @@ ${lt}`;
|
|
|
5622
5685
|
const filtering = isFiltering(view);
|
|
5623
5686
|
const panes = !!diff;
|
|
5624
5687
|
const platesOn = !panes && plates.length > 0 && plateAlpha > 0.01;
|
|
5625
|
-
return /* @__PURE__ */
|
|
5626
|
-
/* @__PURE__ */
|
|
5627
|
-
|
|
5628
|
-
|
|
5629
|
-
|
|
5630
|
-
"
|
|
5688
|
+
return /* @__PURE__ */ jsx6(StringsContext.Provider, { value: strings, children: /* @__PURE__ */ jsxs6("div", { className: `gb-root ${className ?? ""}`, style: rootStyle, children: [
|
|
5689
|
+
/* @__PURE__ */ jsxs6("div", { className: "gb-stage", ref: stageRef, style: { background: theme.canvas }, children: [
|
|
5690
|
+
/* @__PURE__ */ jsxs6("div", { className: "gb-scene", children: [
|
|
5691
|
+
platesOn && /* @__PURE__ */ jsx6(GlassPlanes, { plates, viewport, theme, alpha: plateAlpha, hot: hotLayer }),
|
|
5692
|
+
panes ? (
|
|
5693
|
+
/* Left = before, right = now, sharing one set of coordinates and one viewport: "unchanged things are the same
|
|
5694
|
+
screen pixel in both columns" is the whole value of two columns. */
|
|
5695
|
+
/* @__PURE__ */ jsxs6("div", { className: "gb-panes", children: [
|
|
5696
|
+
/* @__PURE__ */ jsxs6("div", { className: "gb-pane", children: [
|
|
5697
|
+
!prog && /* @__PURE__ */ jsx6(
|
|
5698
|
+
DiffOverlay,
|
|
5699
|
+
{
|
|
5700
|
+
delta: diff,
|
|
5701
|
+
geom: pastGeom,
|
|
5702
|
+
viewport,
|
|
5703
|
+
only: diffOnly,
|
|
5704
|
+
side: "past",
|
|
5705
|
+
visible: filtering ? resolved.visible : null
|
|
5706
|
+
}
|
|
5707
|
+
),
|
|
5708
|
+
/* @__PURE__ */ jsx6("div", { ref: mirrorElRef, className: "gb-canvas" }),
|
|
5709
|
+
/* @__PURE__ */ jsx6("canvas", { ref: mirrorCanvasRef, className: "gb-labels" }),
|
|
5710
|
+
/* @__PURE__ */ jsxs6("div", { className: "gb-pane-tag", children: [
|
|
5711
|
+
diff.labels.before,
|
|
5712
|
+
" \xB7 ",
|
|
5713
|
+
strings.past
|
|
5714
|
+
] })
|
|
5715
|
+
] }),
|
|
5716
|
+
/* @__PURE__ */ jsxs6("div", { className: "gb-pane", children: [
|
|
5717
|
+
!prog && /* @__PURE__ */ jsx6(
|
|
5718
|
+
DiffOverlay,
|
|
5719
|
+
{
|
|
5720
|
+
delta: diff,
|
|
5721
|
+
geom: diffGeom,
|
|
5722
|
+
viewport,
|
|
5723
|
+
only: diffOnly,
|
|
5724
|
+
side: "now",
|
|
5725
|
+
visible: filtering ? resolved.visible : null
|
|
5726
|
+
}
|
|
5727
|
+
),
|
|
5728
|
+
/* @__PURE__ */ jsx6("div", { ref: containerRef, className: "gb-canvas" }),
|
|
5729
|
+
/* @__PURE__ */ jsx6("canvas", { ref: labelCanvasRef, className: "gb-labels" }),
|
|
5730
|
+
/* @__PURE__ */ jsxs6("div", { className: "gb-pane-tag gb-pane-now", children: [
|
|
5731
|
+
diff.labels.after,
|
|
5732
|
+
" \xB7 ",
|
|
5733
|
+
strings.now
|
|
5734
|
+
] })
|
|
5735
|
+
] }),
|
|
5736
|
+
/* @__PURE__ */ jsx6("div", { className: "gb-flow", "aria-hidden": true, children: /* @__PURE__ */ jsx6("svg", { viewBox: "-32 -25 64 50", children: /* @__PURE__ */ jsx6("path", { d: "M-31.84,-12.16 H7.52 V-24.32 L31.84,0 L7.52,24.32 V12.16 H-31.84 Z", fill: theme.canvas }) }) })
|
|
5737
|
+
] }, "panes")
|
|
5738
|
+
) : /* @__PURE__ */ jsx6("div", { ref: containerRef, className: "gb-canvas" }, "solo"),
|
|
5739
|
+
!panes && /* @__PURE__ */ jsx6("canvas", { ref: labelCanvasRef, className: "gb-labels" }),
|
|
5740
|
+
platesOn && /* @__PURE__ */ jsx6("svg", { className: "gb-plane-labels", style: { opacity: plateAlpha }, children: /* @__PURE__ */ jsx6("g", { transform: `translate(${viewport.pan.x},${viewport.pan.y}) scale(${viewport.zoom})`, children: plates.map((p) => /* @__PURE__ */ jsx6(
|
|
5741
|
+
"text",
|
|
5631
5742
|
{
|
|
5632
|
-
opacity:
|
|
5633
|
-
|
|
5634
|
-
|
|
5635
|
-
|
|
5636
|
-
|
|
5637
|
-
|
|
5743
|
+
opacity: p.alpha ?? 1,
|
|
5744
|
+
x: p.anchor[0],
|
|
5745
|
+
y: p.anchor[1],
|
|
5746
|
+
fontSize: 22 / viewport.zoom,
|
|
5747
|
+
fill: plateColors(theme, p.color).text,
|
|
5748
|
+
fontWeight: 700,
|
|
5749
|
+
stroke: theme.canvas,
|
|
5750
|
+
strokeWidth: 4 / viewport.zoom,
|
|
5751
|
+
paintOrder: "stroke",
|
|
5752
|
+
style: { userSelect: "none", pointerEvents: "auto", cursor: "default" },
|
|
5753
|
+
onMouseEnter: () => hoverLayer(p.layer),
|
|
5754
|
+
onMouseLeave: () => hoverLayer(null),
|
|
5755
|
+
children: p.label
|
|
5638
5756
|
},
|
|
5639
5757
|
p.layer
|
|
5640
|
-
)
|
|
5641
|
-
|
|
5642
|
-
|
|
5643
|
-
/* Left = before, right = now, sharing one set of coordinates and one viewport: "unchanged things are the same
|
|
5644
|
-
screen pixel in both columns" is the whole value of two columns. */
|
|
5645
|
-
/* @__PURE__ */ jsxs5("div", { className: "gb-panes", children: [
|
|
5646
|
-
/* @__PURE__ */ jsxs5("div", { className: "gb-pane", children: [
|
|
5647
|
-
!prog && /* @__PURE__ */ jsx5(
|
|
5648
|
-
DiffOverlay,
|
|
5649
|
-
{
|
|
5650
|
-
delta: diff,
|
|
5651
|
-
geom: pastGeom,
|
|
5652
|
-
viewport,
|
|
5653
|
-
only: diffOnly,
|
|
5654
|
-
side: "past",
|
|
5655
|
-
visible: filtering ? resolved.visible : null
|
|
5656
|
-
}
|
|
5657
|
-
),
|
|
5658
|
-
/* @__PURE__ */ jsx5("div", { ref: mirrorElRef, className: "gb-canvas" }),
|
|
5659
|
-
/* @__PURE__ */ jsx5("canvas", { ref: mirrorCanvasRef, className: "gb-labels" }),
|
|
5660
|
-
/* @__PURE__ */ jsxs5("div", { className: "gb-pane-tag", children: [
|
|
5661
|
-
diff.labels.before,
|
|
5662
|
-
" \xB7 ",
|
|
5663
|
-
strings.past
|
|
5664
|
-
] })
|
|
5665
|
-
] }),
|
|
5666
|
-
/* @__PURE__ */ jsxs5("div", { className: "gb-pane", children: [
|
|
5667
|
-
!prog && /* @__PURE__ */ jsx5(
|
|
5668
|
-
DiffOverlay,
|
|
5669
|
-
{
|
|
5670
|
-
delta: diff,
|
|
5671
|
-
geom: diffGeom,
|
|
5672
|
-
viewport,
|
|
5673
|
-
only: diffOnly,
|
|
5674
|
-
side: "now",
|
|
5675
|
-
visible: filtering ? resolved.visible : null
|
|
5676
|
-
}
|
|
5677
|
-
),
|
|
5678
|
-
/* @__PURE__ */ jsx5("div", { ref: containerRef, className: "gb-canvas" }),
|
|
5679
|
-
/* @__PURE__ */ jsx5("canvas", { ref: labelCanvasRef, className: "gb-labels" }),
|
|
5680
|
-
/* @__PURE__ */ jsxs5("div", { className: "gb-pane-tag gb-pane-now", children: [
|
|
5681
|
-
diff.labels.after,
|
|
5682
|
-
" \xB7 ",
|
|
5683
|
-
strings.now
|
|
5684
|
-
] })
|
|
5685
|
-
] }),
|
|
5686
|
-
/* @__PURE__ */ jsx5("div", { className: "gb-flow", "aria-hidden": true, children: /* @__PURE__ */ jsx5("svg", { viewBox: "-32 -25 64 50", children: /* @__PURE__ */ jsx5("path", { d: "M-31.84,-12.16 H7.52 V-24.32 L31.84,0 L7.52,24.32 V12.16 H-31.84 Z", fill: theme.canvas }) }) })
|
|
5687
|
-
] }, "panes")
|
|
5688
|
-
) : /* @__PURE__ */ jsx5("div", { ref: containerRef, className: "gb-canvas" }, "solo"),
|
|
5689
|
-
!panes && /* @__PURE__ */ jsx5("canvas", { ref: labelCanvasRef, className: "gb-labels" }),
|
|
5690
|
-
platesOn && /* @__PURE__ */ jsx5("svg", { className: "gb-plane-labels", style: { opacity: plateAlpha }, children: /* @__PURE__ */ jsx5("g", { transform: `translate(${viewport.pan.x},${viewport.pan.y}) scale(${viewport.zoom})`, children: plates.map((p) => /* @__PURE__ */ jsx5(
|
|
5691
|
-
"text",
|
|
5692
|
-
{
|
|
5693
|
-
opacity: p.alpha ?? 1,
|
|
5694
|
-
x: p.anchor[0],
|
|
5695
|
-
y: p.anchor[1],
|
|
5696
|
-
fontSize: 22 / viewport.zoom,
|
|
5697
|
-
fill: plateColors(theme, p.color).text,
|
|
5698
|
-
fontWeight: 700,
|
|
5699
|
-
stroke: theme.canvas,
|
|
5700
|
-
strokeWidth: 4 / viewport.zoom,
|
|
5701
|
-
paintOrder: "stroke",
|
|
5702
|
-
style: { userSelect: "none", pointerEvents: "auto", cursor: "default" },
|
|
5703
|
-
onMouseEnter: () => hoverLayer(p.layer),
|
|
5704
|
-
onMouseLeave: () => hoverLayer(null),
|
|
5705
|
-
children: p.label
|
|
5706
|
-
},
|
|
5707
|
-
p.layer
|
|
5708
|
-
)) }) }),
|
|
5709
|
-
!compact && /* @__PURE__ */ jsx5(
|
|
5758
|
+
)) }) })
|
|
5759
|
+
] }),
|
|
5760
|
+
!compact && /* @__PURE__ */ jsx6(
|
|
5710
5761
|
Toolbar,
|
|
5711
5762
|
{
|
|
5712
5763
|
view,
|
|
@@ -5729,58 +5780,60 @@ ${lt}`;
|
|
|
5729
5780
|
onForceLayers
|
|
5730
5781
|
}
|
|
5731
5782
|
),
|
|
5732
|
-
|
|
5733
|
-
|
|
5734
|
-
|
|
5735
|
-
!(legend && !compact) && note,
|
|
5736
|
-
|
|
5737
|
-
|
|
5738
|
-
|
|
5739
|
-
model.errors.
|
|
5740
|
-
|
|
5741
|
-
|
|
5783
|
+
/* @__PURE__ */ jsxs6("div", { className: "gb-footer", children: [
|
|
5784
|
+
(note || model.errors.length > 0 || legend && !compact) && /* Bottom left: the host's caption (if any) on top, the legend below. Top left is tools, bottom right is the camera. */
|
|
5785
|
+
/* @__PURE__ */ jsxs6("div", { className: "gb-bl", children: [
|
|
5786
|
+
(note && !(legend && !compact) || model.errors.length > 0) && /* @__PURE__ */ jsxs6("div", { className: "gb-note", children: [
|
|
5787
|
+
!(legend && !compact) && note,
|
|
5788
|
+
model.errors.length > 0 && // The names must appear on this line. Reporting only a number, "16 sources could not be parsed" sends people back to
|
|
5789
|
+
// try the files one by one, while locating them only takes printing the origin. The full list is in title.
|
|
5790
|
+
/* @__PURE__ */ jsx6("span", { className: "gb-warn", title: model.errors.map((e) => `${e.origin}: ${e.message}`).join("\n"), children: strings.parseErrors(
|
|
5791
|
+
model.errors.length,
|
|
5792
|
+
model.errors.slice(0, 2).map((e) => e.origin).join(", ") + (model.errors.length > 2 ? ", \u2026" : "")
|
|
5793
|
+
) })
|
|
5794
|
+
] }),
|
|
5795
|
+
legend && !compact && /* @__PURE__ */ jsx6(
|
|
5796
|
+
Legend,
|
|
5797
|
+
{
|
|
5798
|
+
model,
|
|
5799
|
+
profile: lookProfile,
|
|
5800
|
+
theme,
|
|
5801
|
+
look,
|
|
5802
|
+
onLook: setLook,
|
|
5803
|
+
cy: liveCy,
|
|
5804
|
+
delta: diff,
|
|
5805
|
+
hidden: { nodes: view.hiddenNodeKinds ?? [], edges: view.hiddenEdgeKinds ?? [] },
|
|
5806
|
+
onToggle: (which, kind) => {
|
|
5807
|
+
const key = which === "nodes" ? "hiddenNodeKinds" : "hiddenEdgeKinds";
|
|
5808
|
+
const cur = view[key] ?? [];
|
|
5809
|
+
setView({ [key]: cur.includes(kind) ? cur.filter((x) => x !== kind) : [...cur, kind] });
|
|
5810
|
+
},
|
|
5811
|
+
onEmphasis: setLegendEmphasis,
|
|
5812
|
+
onShowAll: () => setView({ hiddenNodeKinds: [], hiddenEdgeKinds: [] }),
|
|
5813
|
+
collapsed: legendCollapsed,
|
|
5814
|
+
onCollapsed: setLegendCollapsed,
|
|
5815
|
+
caption: note
|
|
5816
|
+
}
|
|
5817
|
+
)
|
|
5742
5818
|
] }),
|
|
5743
|
-
|
|
5744
|
-
|
|
5819
|
+
!compact && /* @__PURE__ */ jsx6(
|
|
5820
|
+
ZoomDock,
|
|
5745
5821
|
{
|
|
5746
|
-
|
|
5747
|
-
|
|
5748
|
-
|
|
5749
|
-
|
|
5750
|
-
|
|
5751
|
-
cy: liveCy,
|
|
5752
|
-
delta: diff,
|
|
5753
|
-
hidden: { nodes: view.hiddenNodeKinds ?? [], edges: view.hiddenEdgeKinds ?? [] },
|
|
5754
|
-
onToggle: (which, kind) => {
|
|
5755
|
-
const key = which === "nodes" ? "hiddenNodeKinds" : "hiddenEdgeKinds";
|
|
5756
|
-
const cur = view[key] ?? [];
|
|
5757
|
-
setView({ [key]: cur.includes(kind) ? cur.filter((x) => x !== kind) : [...cur, kind] });
|
|
5758
|
-
},
|
|
5759
|
-
onEmphasis: setLegendEmphasis,
|
|
5760
|
-
onShowAll: () => setView({ hiddenNodeKinds: [], hiddenEdgeKinds: [] }),
|
|
5761
|
-
collapsed: legendCollapsed,
|
|
5762
|
-
onCollapsed: setLegendCollapsed,
|
|
5763
|
-
caption: note
|
|
5822
|
+
zoom: controls.zoom,
|
|
5823
|
+
onZoom: zoomBy,
|
|
5824
|
+
onFit: fit,
|
|
5825
|
+
issues: showIssues ? issues : [],
|
|
5826
|
+
onPick: pickIssue
|
|
5764
5827
|
}
|
|
5765
5828
|
)
|
|
5766
5829
|
] }),
|
|
5767
|
-
|
|
5768
|
-
|
|
5769
|
-
{
|
|
5770
|
-
zoom: controls.zoom,
|
|
5771
|
-
onZoom: zoomBy,
|
|
5772
|
-
onFit: fit,
|
|
5773
|
-
issues: showIssues ? issues : [],
|
|
5774
|
-
onPick: pick
|
|
5775
|
-
}
|
|
5776
|
-
),
|
|
5777
|
-
prog && /* @__PURE__ */ jsx5("div", { className: "gb-mask", children: /* @__PURE__ */ jsxs5("div", { children: [
|
|
5778
|
-
/* @__PURE__ */ jsx5("span", { className: "gb-spin" }),
|
|
5830
|
+
prog && /* @__PURE__ */ jsx6("div", { className: "gb-mask", children: /* @__PURE__ */ jsxs6("div", { children: [
|
|
5831
|
+
/* @__PURE__ */ jsx6("span", { className: "gb-spin" }),
|
|
5779
5832
|
prog.total > 0 ? strings.layingOut(prog.done, prog.total) : strings.preparing
|
|
5780
5833
|
] }) }),
|
|
5781
|
-
compact && /* @__PURE__ */
|
|
5834
|
+
compact && /* @__PURE__ */ jsx6("div", { style: { position: "absolute", bottom: 4, left: 8, fontSize: 10.5, opacity: 0.6, pointerEvents: "none" }, children: strings.stats(stats.nodes, stats.edges) })
|
|
5782
5835
|
] }),
|
|
5783
|
-
/* @__PURE__ */
|
|
5836
|
+
/* @__PURE__ */ jsx6(Drawer, { children: editPanel || (detailPanel && selected ? /* @__PURE__ */ jsx6(
|
|
5784
5837
|
DetailPanel,
|
|
5785
5838
|
{
|
|
5786
5839
|
node: selected,
|