@asanchez-sa/abby 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/badge/badge.d.ts +3 -2
- package/dist/components/badge/badge.js +27 -11
- package/dist/components/calendar/calendar.d.ts +26 -5
- package/dist/components/calendar/calendar.js +387 -72
- package/dist/components/chart/chart.d.ts +7 -0
- package/dist/components/chart/chart.js +7 -0
- package/dist/components/chart/parts/bar.d.ts +32 -0
- package/dist/components/chart/parts/bar.js +348 -0
- package/dist/components/chart/parts/categories.d.ts +32 -0
- package/dist/components/chart/parts/categories.js +212 -0
- package/dist/components/chart/parts/legend.d.ts +16 -0
- package/dist/components/chart/parts/legend.js +82 -0
- package/dist/components/chart/parts/line.d.ts +43 -0
- package/dist/components/chart/parts/line.js +266 -0
- package/dist/components/chart/parts/scale.js +96 -0
- package/dist/components/chart/parts/scatter.d.ts +67 -0
- package/dist/components/chart/parts/scatter.js +157 -0
- package/dist/components/chart/parts/surface.d.ts +26 -0
- package/dist/components/chart/parts/surface.js +76 -0
- package/dist/components/chart/parts/table.js +105 -0
- package/dist/components/chart/parts/types.d.ts +44 -0
- package/dist/components/chart/parts/types.js +12 -0
- package/dist/components/filter-chip/filter-chip.d.ts +36 -0
- package/dist/components/filter-chip/filter-chip.js +97 -0
- package/dist/components/graph/graph.d.ts +151 -0
- package/dist/components/graph/graph.js +959 -0
- package/dist/components/model-selector/model-selector.d.ts +38 -3
- package/dist/components/model-selector/model-selector.js +331 -73
- package/dist/components/number-input/number-input.d.ts +14 -3
- package/dist/components/number-input/number-input.js +193 -34
- package/dist/components/spinner/spinner.d.ts +7 -1
- package/dist/components/spinner/spinner.js +86 -26
- package/dist/components/toast/toast.d.ts +19 -2
- package/dist/components/toast/toast.js +211 -49
- package/dist/components/toggle/toggle.d.ts +18 -4
- package/dist/components/toggle/toggle.js +167 -32
- package/dist/components/week-strip/week-strip.d.ts +27 -5
- package/dist/components/week-strip/week-strip.js +288 -134
- package/dist/styles/components.css +66 -0
- package/package.json +5 -1
- package/skills/agent-ready-ui/SKILL.md +1 -1
- package/skills/blocks/SKILL.md +1 -1
- package/skills/compose-screens/SKILL.md +48 -5
- package/skills/compose-screens/references/calendar-week.md +77 -0
- package/skills/compose-screens/references/charts-and-maps.md +298 -0
- package/skills/compose-screens/references/filter-chips.md +61 -0
- package/skills/compose-screens/references/number-units.md +52 -0
- package/skills/note-editor/SKILL.md +1 -1
- package/skills/note-status/SKILL.md +1 -1
- package/skills/setup/SKILL.md +1 -1
- package/skills/theming/SKILL.md +1 -1
|
@@ -0,0 +1,959 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createChange, createController, definePrimitive, usePart, usePrimitive } from "../../core/ui-sdk.js";
|
|
3
|
+
import { usePrimitiveState } from "../../core/use-primitive-state.js";
|
|
4
|
+
import "../../behaviors/focus/index.js";
|
|
5
|
+
import { createRovingFocus, spatialMove } from "../../behaviors/focus/ui-sdk.js";
|
|
6
|
+
import "../../core/index.js";
|
|
7
|
+
import { cn, cnState } from "../../utilities/cn/index.js";
|
|
8
|
+
import { Icon } from "../icon/icon.js";
|
|
9
|
+
import { c } from "react/compiler-runtime";
|
|
10
|
+
import { createContext, use, useState } from "react";
|
|
11
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
+
import { Add01Icon, MinusSignIcon } from "@hugeicons/core-free-icons";
|
|
13
|
+
// src/components/graph/graph.tsx
|
|
14
|
+
const ZOOM_STEP = 1.25;
|
|
15
|
+
const ZOOM_MIN = .5;
|
|
16
|
+
const ZOOM_MAX = 2;
|
|
17
|
+
const clampZoom = (zoom) => Math.min(ZOOM_MAX, Math.max(ZOOM_MIN, zoom));
|
|
18
|
+
/** The nodes that count: the first of each id. */
|
|
19
|
+
function normalizeNodes(nodes) {
|
|
20
|
+
const seen = /* @__PURE__ */ new Set();
|
|
21
|
+
const result = [];
|
|
22
|
+
for (const node of nodes ?? []) {
|
|
23
|
+
if (seen.has(node.id)) continue;
|
|
24
|
+
seen.add(node.id);
|
|
25
|
+
result.push({
|
|
26
|
+
...node,
|
|
27
|
+
x: Number.isFinite(node.x) ? node.x : 0,
|
|
28
|
+
y: Number.isFinite(node.y) ? node.y : 0
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
/** The edges that count: those between two different nodes that exist. */
|
|
34
|
+
function normalizeEdges(edges, nodes) {
|
|
35
|
+
const ids = new Set(nodes.map((node) => node.id));
|
|
36
|
+
return (edges ?? []).filter((edge) => edge.from !== edge.to && ids.has(edge.from) && ids.has(edge.to));
|
|
37
|
+
}
|
|
38
|
+
const present = (on) => on ? "" : void 0;
|
|
39
|
+
/** The node that takes the tab stop: the selected one, else the current one, else the first. */
|
|
40
|
+
function stopOf(state) {
|
|
41
|
+
const { nodes } = state;
|
|
42
|
+
if (state.selected && nodes.some((node) => node.id === state.selected)) return state.selected;
|
|
43
|
+
return (nodes.find((node) => node.current) ?? nodes[0])?.id;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Not exported: its inferred type names ui-sdk types that aren't public, so
|
|
47
|
+
* the declaration build can't describe it from another module.
|
|
48
|
+
*/
|
|
49
|
+
const graph = definePrimitive({
|
|
50
|
+
name: "graph",
|
|
51
|
+
options: {
|
|
52
|
+
selected: "string",
|
|
53
|
+
defaultSelected: "string",
|
|
54
|
+
onSelectedChange: "callback",
|
|
55
|
+
nodes: "value",
|
|
56
|
+
edges: "value",
|
|
57
|
+
controller: "value"
|
|
58
|
+
},
|
|
59
|
+
controlled: ["selected"],
|
|
60
|
+
state: (options) => {
|
|
61
|
+
const nodes = normalizeNodes(options.nodes);
|
|
62
|
+
return {
|
|
63
|
+
selected: options.selected ?? options.defaultSelected ?? null,
|
|
64
|
+
focused: null,
|
|
65
|
+
zoom: 1,
|
|
66
|
+
nodes,
|
|
67
|
+
edges: normalizeEdges(options.edges, nodes)
|
|
68
|
+
};
|
|
69
|
+
},
|
|
70
|
+
sync: (options) => {
|
|
71
|
+
const nodes = normalizeNodes(options.nodes);
|
|
72
|
+
return {
|
|
73
|
+
...options.selected === void 0 ? {} : { selected: options.selected },
|
|
74
|
+
nodes,
|
|
75
|
+
edges: normalizeEdges(options.edges, nodes)
|
|
76
|
+
};
|
|
77
|
+
},
|
|
78
|
+
api: (context) => {
|
|
79
|
+
const { store } = context;
|
|
80
|
+
const change = createChange(context);
|
|
81
|
+
const select = (id, reason, event) => {
|
|
82
|
+
const state = store.get();
|
|
83
|
+
if (id !== null && !state.nodes.some((node) => node.id === id)) return false;
|
|
84
|
+
if (id === state.selected) return true;
|
|
85
|
+
return change("selected", id, {
|
|
86
|
+
reason,
|
|
87
|
+
event
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
const zoomBy = (factor) => {
|
|
91
|
+
const zoom = clampZoom(store.get().zoom * factor);
|
|
92
|
+
if (zoom === store.get().zoom) return false;
|
|
93
|
+
store.set({ zoom });
|
|
94
|
+
return true;
|
|
95
|
+
};
|
|
96
|
+
const roving = createRovingFocus(context, {
|
|
97
|
+
slot: "node",
|
|
98
|
+
key: "focused",
|
|
99
|
+
remember: false,
|
|
100
|
+
orientation: () => "both",
|
|
101
|
+
preferred: (item) => item.key === stopOf(store.get()),
|
|
102
|
+
claims: (state, item) => item.key === stopOf(state),
|
|
103
|
+
move: spatialMove()
|
|
104
|
+
});
|
|
105
|
+
return {
|
|
106
|
+
getSelected: () => store.get().selected,
|
|
107
|
+
setSelected: (id) => select(id, "imperative"),
|
|
108
|
+
getZoom: () => store.get().zoom,
|
|
109
|
+
zoomIn: () => zoomBy(ZOOM_STEP),
|
|
110
|
+
zoomOut: () => zoomBy(1 / ZOOM_STEP),
|
|
111
|
+
focus: (id) => roving.focus(id ?? stopOf(store.get())),
|
|
112
|
+
/** The nodes, with the names screen readers and agents hear. */
|
|
113
|
+
items: () => store.get().nodes.map((node) => ({
|
|
114
|
+
value: node.id,
|
|
115
|
+
label: node.name
|
|
116
|
+
})),
|
|
117
|
+
internal: {
|
|
118
|
+
roving,
|
|
119
|
+
select,
|
|
120
|
+
keydown(event) {
|
|
121
|
+
if (event.defaultPrevented || event.altKey || event.ctrlKey || event.metaKey) return;
|
|
122
|
+
if (event.key === "+" || event.key === "=") {
|
|
123
|
+
event.preventDefault();
|
|
124
|
+
zoomBy(ZOOM_STEP);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if (event.key === "-" || event.key === "_") {
|
|
128
|
+
event.preventDefault();
|
|
129
|
+
zoomBy(1 / ZOOM_STEP);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
const node = event.target?.closest("[data-slot=\"graph-node\"]");
|
|
133
|
+
if (node) roving.keydown(event, node);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
},
|
|
138
|
+
slots: (slot) => ({
|
|
139
|
+
root: slot({
|
|
140
|
+
role: "group",
|
|
141
|
+
keys: [
|
|
142
|
+
"ArrowLeft",
|
|
143
|
+
"ArrowRight",
|
|
144
|
+
"ArrowUp",
|
|
145
|
+
"ArrowDown",
|
|
146
|
+
"Home",
|
|
147
|
+
"End",
|
|
148
|
+
"+",
|
|
149
|
+
"-",
|
|
150
|
+
"=",
|
|
151
|
+
"_"
|
|
152
|
+
],
|
|
153
|
+
state: (state) => ({
|
|
154
|
+
selected: state.selected,
|
|
155
|
+
zoom: state.zoom
|
|
156
|
+
}),
|
|
157
|
+
on: { keydown: (event, { api }) => api.internal.keydown(event) }
|
|
158
|
+
}),
|
|
159
|
+
node: slot({
|
|
160
|
+
focus: "roving",
|
|
161
|
+
props: { value: "string" },
|
|
162
|
+
state: (state, { key }) => ({
|
|
163
|
+
id: key,
|
|
164
|
+
node: state.nodes.find((node) => node.id === key),
|
|
165
|
+
selected: state.selected === key
|
|
166
|
+
}),
|
|
167
|
+
attrs: (state, part) => ({
|
|
168
|
+
type: "button",
|
|
169
|
+
"aria-pressed": String(state.selected === part.key),
|
|
170
|
+
tabindex: part.api.internal.roving.tabIndex(state, part),
|
|
171
|
+
"data-id": part.key,
|
|
172
|
+
"data-selected": present(state.selected === part.key)
|
|
173
|
+
}),
|
|
174
|
+
press: ({ api, key }, event) => void api.internal.select(key, "item-press", event),
|
|
175
|
+
bind: (el, part) => part.api.internal.roving.bind(el, part)
|
|
176
|
+
}),
|
|
177
|
+
zoomIn: slot({
|
|
178
|
+
state: (state) => ({ disabled: state.zoom >= ZOOM_MAX }),
|
|
179
|
+
attrs: (state) => ({
|
|
180
|
+
type: "button",
|
|
181
|
+
"aria-disabled": state.zoom >= ZOOM_MAX ? "true" : void 0,
|
|
182
|
+
"data-disabled": present(state.zoom >= ZOOM_MAX)
|
|
183
|
+
}),
|
|
184
|
+
press: ({ api }) => void api.zoomIn()
|
|
185
|
+
}),
|
|
186
|
+
zoomOut: slot({
|
|
187
|
+
state: (state) => ({ disabled: state.zoom <= ZOOM_MIN }),
|
|
188
|
+
attrs: (state) => ({
|
|
189
|
+
type: "button",
|
|
190
|
+
"aria-disabled": state.zoom <= ZOOM_MIN ? "true" : void 0,
|
|
191
|
+
"data-disabled": present(state.zoom <= ZOOM_MIN)
|
|
192
|
+
}),
|
|
193
|
+
press: ({ api }) => void api.zoomOut()
|
|
194
|
+
})
|
|
195
|
+
}),
|
|
196
|
+
agent: {
|
|
197
|
+
actions: [
|
|
198
|
+
"setSelected",
|
|
199
|
+
"zoomIn",
|
|
200
|
+
"zoomOut"
|
|
201
|
+
],
|
|
202
|
+
items: (api) => api.items()
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
/** Drives a graph from anywhere: pass it as `controller`. */
|
|
206
|
+
function createGraphController() {
|
|
207
|
+
return createController();
|
|
208
|
+
}
|
|
209
|
+
const GraphContext = createContext(null);
|
|
210
|
+
function useGraphContext() {
|
|
211
|
+
const context = use(GraphContext);
|
|
212
|
+
if (!context) throw new Error("Graph parts must be used within a Graph.");
|
|
213
|
+
return context;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* The graph's state and the methods that change it, for a component inside
|
|
217
|
+
* `Graph`. It re-renders when the state changes.
|
|
218
|
+
*/
|
|
219
|
+
function useGraph() {
|
|
220
|
+
const $ = c(12);
|
|
221
|
+
const { handle } = useGraphContext();
|
|
222
|
+
const state = usePrimitiveState(handle);
|
|
223
|
+
let t0;
|
|
224
|
+
let t1;
|
|
225
|
+
if ($[0] !== handle.api) {
|
|
226
|
+
t0 = () => handle.api.zoomIn();
|
|
227
|
+
t1 = () => handle.api.zoomOut();
|
|
228
|
+
$[0] = handle.api;
|
|
229
|
+
$[1] = t0;
|
|
230
|
+
$[2] = t1;
|
|
231
|
+
} else {
|
|
232
|
+
t0 = $[1];
|
|
233
|
+
t1 = $[2];
|
|
234
|
+
}
|
|
235
|
+
let t2;
|
|
236
|
+
if ($[3] !== handle.api.focus || $[4] !== handle.api.setSelected || $[5] !== state.edges || $[6] !== state.nodes || $[7] !== state.selected || $[8] !== state.zoom || $[9] !== t0 || $[10] !== t1) {
|
|
237
|
+
t2 = {
|
|
238
|
+
selected: state.selected,
|
|
239
|
+
zoom: state.zoom,
|
|
240
|
+
nodes: state.nodes,
|
|
241
|
+
edges: state.edges,
|
|
242
|
+
setSelected: handle.api.setSelected,
|
|
243
|
+
zoomIn: t0,
|
|
244
|
+
zoomOut: t1,
|
|
245
|
+
focus: handle.api.focus
|
|
246
|
+
};
|
|
247
|
+
$[3] = handle.api.focus;
|
|
248
|
+
$[4] = handle.api.setSelected;
|
|
249
|
+
$[5] = state.edges;
|
|
250
|
+
$[6] = state.nodes;
|
|
251
|
+
$[7] = state.selected;
|
|
252
|
+
$[8] = state.zoom;
|
|
253
|
+
$[9] = t0;
|
|
254
|
+
$[10] = t1;
|
|
255
|
+
$[11] = t2;
|
|
256
|
+
} else t2 = $[11];
|
|
257
|
+
return t2;
|
|
258
|
+
}
|
|
259
|
+
/** Holds the same array while its content is the same, since an app passes new ones on every render. */
|
|
260
|
+
function useStable(value) {
|
|
261
|
+
const [held, setHeld] = useState(value);
|
|
262
|
+
const same = JSON.stringify(held) === JSON.stringify(value);
|
|
263
|
+
if (!same) setHeld(value);
|
|
264
|
+
return same ? held : value;
|
|
265
|
+
}
|
|
266
|
+
/** Without children it renders the canvas, the zoom buttons, the legend and the text list. */
|
|
267
|
+
function Graph(t0) {
|
|
268
|
+
const $ = c(29);
|
|
269
|
+
let children;
|
|
270
|
+
let className;
|
|
271
|
+
let controller;
|
|
272
|
+
let defaultSelected;
|
|
273
|
+
let edges;
|
|
274
|
+
let nodes;
|
|
275
|
+
let onSelectedChange;
|
|
276
|
+
let props;
|
|
277
|
+
let selected;
|
|
278
|
+
let t1;
|
|
279
|
+
if ($[0] !== t0) {
|
|
280
|
+
({selected, defaultSelected, onSelectedChange, nodes, edges, controller, label: t1, className, children, ...props} = t0);
|
|
281
|
+
$[0] = t0;
|
|
282
|
+
$[1] = children;
|
|
283
|
+
$[2] = className;
|
|
284
|
+
$[3] = controller;
|
|
285
|
+
$[4] = defaultSelected;
|
|
286
|
+
$[5] = edges;
|
|
287
|
+
$[6] = nodes;
|
|
288
|
+
$[7] = onSelectedChange;
|
|
289
|
+
$[8] = props;
|
|
290
|
+
$[9] = selected;
|
|
291
|
+
$[10] = t1;
|
|
292
|
+
} else {
|
|
293
|
+
children = $[1];
|
|
294
|
+
className = $[2];
|
|
295
|
+
controller = $[3];
|
|
296
|
+
defaultSelected = $[4];
|
|
297
|
+
edges = $[5];
|
|
298
|
+
nodes = $[6];
|
|
299
|
+
onSelectedChange = $[7];
|
|
300
|
+
props = $[8];
|
|
301
|
+
selected = $[9];
|
|
302
|
+
t1 = $[10];
|
|
303
|
+
}
|
|
304
|
+
const label = t1 === void 0 ? "Graph" : t1;
|
|
305
|
+
const t2 = useStable(nodes);
|
|
306
|
+
const t3 = useStable(edges);
|
|
307
|
+
let t4;
|
|
308
|
+
if ($[11] !== controller || $[12] !== defaultSelected || $[13] !== onSelectedChange || $[14] !== selected || $[15] !== t2 || $[16] !== t3) {
|
|
309
|
+
t4 = {
|
|
310
|
+
selected,
|
|
311
|
+
defaultSelected,
|
|
312
|
+
onSelectedChange,
|
|
313
|
+
nodes: t2,
|
|
314
|
+
edges: t3,
|
|
315
|
+
controller
|
|
316
|
+
};
|
|
317
|
+
$[11] = controller;
|
|
318
|
+
$[12] = defaultSelected;
|
|
319
|
+
$[13] = onSelectedChange;
|
|
320
|
+
$[14] = selected;
|
|
321
|
+
$[15] = t2;
|
|
322
|
+
$[16] = t3;
|
|
323
|
+
$[17] = t4;
|
|
324
|
+
} else t4 = $[17];
|
|
325
|
+
const handle = usePrimitive(graph, t4);
|
|
326
|
+
let t5;
|
|
327
|
+
if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
|
|
328
|
+
t5 = {};
|
|
329
|
+
$[18] = t5;
|
|
330
|
+
} else t5 = $[18];
|
|
331
|
+
const t6 = props["aria-labelledby"] ? void 0 : label;
|
|
332
|
+
let t7;
|
|
333
|
+
if ($[19] !== className) {
|
|
334
|
+
t7 = cnState("relative flex min-h-80 w-full min-w-0 flex-col text-sm", className);
|
|
335
|
+
$[19] = className;
|
|
336
|
+
$[20] = t7;
|
|
337
|
+
} else t7 = $[20];
|
|
338
|
+
let t8;
|
|
339
|
+
if ($[21] !== children || $[22] !== handle) {
|
|
340
|
+
t8 = (state) => /* @__PURE__ */ jsx(GraphContext, {
|
|
341
|
+
value: { handle },
|
|
342
|
+
children: typeof children === "function" ? children(state) : children ?? /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
343
|
+
/* @__PURE__ */ jsx(GraphCanvas, {}),
|
|
344
|
+
/* @__PURE__ */ jsx(GraphLegend, {}),
|
|
345
|
+
/* @__PURE__ */ jsx(GraphZoom, {}),
|
|
346
|
+
/* @__PURE__ */ jsx(GraphList, {})
|
|
347
|
+
] })
|
|
348
|
+
});
|
|
349
|
+
$[21] = children;
|
|
350
|
+
$[22] = handle;
|
|
351
|
+
$[23] = t8;
|
|
352
|
+
} else t8 = $[23];
|
|
353
|
+
let t9;
|
|
354
|
+
if ($[24] !== props || $[25] !== t6 || $[26] !== t7 || $[27] !== t8) {
|
|
355
|
+
t9 = {
|
|
356
|
+
"aria-label": t6,
|
|
357
|
+
className: t7,
|
|
358
|
+
children: t8,
|
|
359
|
+
...props
|
|
360
|
+
};
|
|
361
|
+
$[24] = props;
|
|
362
|
+
$[25] = t6;
|
|
363
|
+
$[26] = t7;
|
|
364
|
+
$[27] = t8;
|
|
365
|
+
$[28] = t9;
|
|
366
|
+
} else t9 = $[28];
|
|
367
|
+
return usePart(handle, "root", t5, t9, "div");
|
|
368
|
+
}
|
|
369
|
+
/** Space around the outermost nodes, in map units. */
|
|
370
|
+
const PAD = 24;
|
|
371
|
+
const NODE_WIDTH = 208;
|
|
372
|
+
const CURRENT_WIDTH = 240;
|
|
373
|
+
const NODE_HEIGHT = 72;
|
|
374
|
+
const widthOf = (node) => node.current ? CURRENT_WIDTH : NODE_WIDTH;
|
|
375
|
+
/** The box the nodes fill, in map units, with the offset that moves it to the origin. */
|
|
376
|
+
function boundsOf(nodes) {
|
|
377
|
+
if (nodes.length === 0) return {
|
|
378
|
+
width: 0,
|
|
379
|
+
height: 0,
|
|
380
|
+
left: 0,
|
|
381
|
+
top: 0
|
|
382
|
+
};
|
|
383
|
+
const left = Math.min(...nodes.map((node) => node.x - widthOf(node) / 2)) - PAD;
|
|
384
|
+
const right = Math.max(...nodes.map((node) => node.x + widthOf(node) / 2)) + PAD;
|
|
385
|
+
const top = Math.min(...nodes.map((node) => node.y - NODE_HEIGHT / 2)) - PAD;
|
|
386
|
+
const bottom = Math.max(...nodes.map((node) => node.y + NODE_HEIGHT / 2)) + PAD;
|
|
387
|
+
return {
|
|
388
|
+
width: right - left,
|
|
389
|
+
height: bottom - top,
|
|
390
|
+
left,
|
|
391
|
+
top
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
const edgeStroke = (edge) => {
|
|
395
|
+
if (edge.variant === "warning") return "stroke-warning";
|
|
396
|
+
return (edge.weight ?? 1.2) >= 1.2 ? "stroke-foreground/40 dark:stroke-foreground/25" : "stroke-foreground/20 dark:stroke-foreground/18";
|
|
397
|
+
};
|
|
398
|
+
const edgeDash = (variant) => variant === "warning" ? "5 4" : variant === "dashed" ? "3 3" : void 0;
|
|
399
|
+
const edgeLabelTone = (edge) => {
|
|
400
|
+
if (edge.variant === "warning") return "text-warning";
|
|
401
|
+
return (edge.weight ?? 1.2) >= 1.2 ? "text-muted-foreground" : "text-subtle";
|
|
402
|
+
};
|
|
403
|
+
const swatchClasses = {
|
|
404
|
+
"chart-1": "bg-chart-1",
|
|
405
|
+
"chart-2": "bg-chart-2",
|
|
406
|
+
"chart-3": "bg-chart-3",
|
|
407
|
+
"chart-4": "bg-chart-4",
|
|
408
|
+
"chart-5": "bg-chart-5"
|
|
409
|
+
};
|
|
410
|
+
/**
|
|
411
|
+
* The map: the lines and their labels under the nodes. It scrolls when the
|
|
412
|
+
* zoomed map is bigger than its box. The box takes its height from `className`.
|
|
413
|
+
*/
|
|
414
|
+
function GraphCanvas(t0) {
|
|
415
|
+
const $ = c(51);
|
|
416
|
+
const { className, children } = t0;
|
|
417
|
+
const { zoom, nodes, edges } = useGraph();
|
|
418
|
+
let t1;
|
|
419
|
+
if ($[0] !== nodes) {
|
|
420
|
+
t1 = boundsOf(nodes);
|
|
421
|
+
$[0] = nodes;
|
|
422
|
+
$[1] = t1;
|
|
423
|
+
} else t1 = $[1];
|
|
424
|
+
const bounds = t1;
|
|
425
|
+
let t2;
|
|
426
|
+
if ($[2] !== bounds.left || $[3] !== bounds.top) {
|
|
427
|
+
t2 = (node) => ({
|
|
428
|
+
x: node.x - bounds.left,
|
|
429
|
+
y: node.y - bounds.top
|
|
430
|
+
});
|
|
431
|
+
$[2] = bounds.left;
|
|
432
|
+
$[3] = bounds.top;
|
|
433
|
+
$[4] = t2;
|
|
434
|
+
} else t2 = $[4];
|
|
435
|
+
const at = t2;
|
|
436
|
+
let t10;
|
|
437
|
+
let t11;
|
|
438
|
+
let t12;
|
|
439
|
+
let t3;
|
|
440
|
+
let t4;
|
|
441
|
+
let t5;
|
|
442
|
+
let t6;
|
|
443
|
+
let t7;
|
|
444
|
+
let t8;
|
|
445
|
+
let t9;
|
|
446
|
+
if ($[5] !== at || $[6] !== bounds.height || $[7] !== bounds.width || $[8] !== className || $[9] !== edges || $[10] !== nodes || $[11] !== zoom) {
|
|
447
|
+
const byId = new Map(nodes.map(_temp));
|
|
448
|
+
t11 = "graph-canvas";
|
|
449
|
+
if ($[22] !== className) {
|
|
450
|
+
t12 = cn("relative min-h-0 flex-1 overflow-auto rounded-xl border bg-background no-scrollbar", className);
|
|
451
|
+
$[22] = className;
|
|
452
|
+
$[23] = t12;
|
|
453
|
+
} else t12 = $[23];
|
|
454
|
+
t9 = "relative mx-auto";
|
|
455
|
+
const t13 = bounds.width * zoom;
|
|
456
|
+
const t14 = bounds.height * zoom;
|
|
457
|
+
if ($[24] !== t13 || $[25] !== t14) {
|
|
458
|
+
t10 = {
|
|
459
|
+
width: t13,
|
|
460
|
+
height: t14
|
|
461
|
+
};
|
|
462
|
+
$[24] = t13;
|
|
463
|
+
$[25] = t14;
|
|
464
|
+
$[26] = t10;
|
|
465
|
+
} else t10 = $[26];
|
|
466
|
+
t3 = "graph-stage";
|
|
467
|
+
t4 = zoom;
|
|
468
|
+
t5 = "absolute left-0 top-0 origin-top-left transition-transform duration-popup ease-out motion-reduce:transition-none";
|
|
469
|
+
const t15 = `scale(${zoom})`;
|
|
470
|
+
if ($[27] !== bounds.height || $[28] !== bounds.width || $[29] !== t15) {
|
|
471
|
+
t6 = {
|
|
472
|
+
width: bounds.width,
|
|
473
|
+
height: bounds.height,
|
|
474
|
+
transform: t15
|
|
475
|
+
};
|
|
476
|
+
$[27] = bounds.height;
|
|
477
|
+
$[28] = bounds.width;
|
|
478
|
+
$[29] = t15;
|
|
479
|
+
$[30] = t6;
|
|
480
|
+
} else t6 = $[30];
|
|
481
|
+
t7 = /* @__PURE__ */ jsx("svg", {
|
|
482
|
+
"aria-hidden": "true",
|
|
483
|
+
width: bounds.width,
|
|
484
|
+
height: bounds.height,
|
|
485
|
+
viewBox: `0 0 ${bounds.width} ${bounds.height}`,
|
|
486
|
+
className: "absolute left-0 top-0",
|
|
487
|
+
children: edges.map((edge, index) => {
|
|
488
|
+
const [from, to] = [at(byId.get(edge.from)), at(byId.get(edge.to))];
|
|
489
|
+
return /* @__PURE__ */ jsx("path", {
|
|
490
|
+
"data-slot": "graph-edge",
|
|
491
|
+
"data-variant": edge.variant ?? "solid",
|
|
492
|
+
d: `M${from.x} ${from.y} L${to.x} ${to.y}`,
|
|
493
|
+
fill: "none",
|
|
494
|
+
strokeWidth: edge.weight ?? 1.2,
|
|
495
|
+
strokeDasharray: edgeDash(edge.variant),
|
|
496
|
+
className: edgeStroke(edge)
|
|
497
|
+
}, index);
|
|
498
|
+
})
|
|
499
|
+
});
|
|
500
|
+
t8 = edges.map((edge_0, index_0) => {
|
|
501
|
+
if (!edge_0.label) return null;
|
|
502
|
+
const [from_0, to_0] = [at(byId.get(edge_0.from)), at(byId.get(edge_0.to))];
|
|
503
|
+
return /* @__PURE__ */ jsx("span", {
|
|
504
|
+
"data-slot": "graph-edge-label",
|
|
505
|
+
"aria-hidden": "true",
|
|
506
|
+
className: cn("absolute -translate-x-1/2 -translate-y-1/2 rounded-sm bg-background px-1.5 py-0.5 text-footnote whitespace-nowrap select-none", edgeLabelTone(edge_0)),
|
|
507
|
+
style: {
|
|
508
|
+
left: (from_0.x + to_0.x) / 2,
|
|
509
|
+
top: (from_0.y + to_0.y) / 2
|
|
510
|
+
},
|
|
511
|
+
children: edge_0.label
|
|
512
|
+
}, index_0);
|
|
513
|
+
});
|
|
514
|
+
$[5] = at;
|
|
515
|
+
$[6] = bounds.height;
|
|
516
|
+
$[7] = bounds.width;
|
|
517
|
+
$[8] = className;
|
|
518
|
+
$[9] = edges;
|
|
519
|
+
$[10] = nodes;
|
|
520
|
+
$[11] = zoom;
|
|
521
|
+
$[12] = t10;
|
|
522
|
+
$[13] = t11;
|
|
523
|
+
$[14] = t12;
|
|
524
|
+
$[15] = t3;
|
|
525
|
+
$[16] = t4;
|
|
526
|
+
$[17] = t5;
|
|
527
|
+
$[18] = t6;
|
|
528
|
+
$[19] = t7;
|
|
529
|
+
$[20] = t8;
|
|
530
|
+
$[21] = t9;
|
|
531
|
+
} else {
|
|
532
|
+
t10 = $[12];
|
|
533
|
+
t11 = $[13];
|
|
534
|
+
t12 = $[14];
|
|
535
|
+
t3 = $[15];
|
|
536
|
+
t4 = $[16];
|
|
537
|
+
t5 = $[17];
|
|
538
|
+
t6 = $[18];
|
|
539
|
+
t7 = $[19];
|
|
540
|
+
t8 = $[20];
|
|
541
|
+
t9 = $[21];
|
|
542
|
+
}
|
|
543
|
+
let t13;
|
|
544
|
+
if ($[31] !== at || $[32] !== children || $[33] !== nodes) {
|
|
545
|
+
t13 = children ?? nodes.map((node_1) => /* @__PURE__ */ jsx(GraphNode, {
|
|
546
|
+
value: node_1.id,
|
|
547
|
+
style: {
|
|
548
|
+
left: at(node_1).x,
|
|
549
|
+
top: at(node_1).y
|
|
550
|
+
}
|
|
551
|
+
}, node_1.id));
|
|
552
|
+
$[31] = at;
|
|
553
|
+
$[32] = children;
|
|
554
|
+
$[33] = nodes;
|
|
555
|
+
$[34] = t13;
|
|
556
|
+
} else t13 = $[34];
|
|
557
|
+
let t14;
|
|
558
|
+
if ($[35] !== t13 || $[36] !== t3 || $[37] !== t4 || $[38] !== t5 || $[39] !== t6 || $[40] !== t7 || $[41] !== t8) {
|
|
559
|
+
t14 = /* @__PURE__ */ jsxs("div", {
|
|
560
|
+
"data-slot": t3,
|
|
561
|
+
"data-zoom": t4,
|
|
562
|
+
className: t5,
|
|
563
|
+
style: t6,
|
|
564
|
+
children: [
|
|
565
|
+
t7,
|
|
566
|
+
t8,
|
|
567
|
+
t13
|
|
568
|
+
]
|
|
569
|
+
});
|
|
570
|
+
$[35] = t13;
|
|
571
|
+
$[36] = t3;
|
|
572
|
+
$[37] = t4;
|
|
573
|
+
$[38] = t5;
|
|
574
|
+
$[39] = t6;
|
|
575
|
+
$[40] = t7;
|
|
576
|
+
$[41] = t8;
|
|
577
|
+
$[42] = t14;
|
|
578
|
+
} else t14 = $[42];
|
|
579
|
+
let t15;
|
|
580
|
+
if ($[43] !== t10 || $[44] !== t14 || $[45] !== t9) {
|
|
581
|
+
t15 = /* @__PURE__ */ jsx("div", {
|
|
582
|
+
className: t9,
|
|
583
|
+
style: t10,
|
|
584
|
+
children: t14
|
|
585
|
+
});
|
|
586
|
+
$[43] = t10;
|
|
587
|
+
$[44] = t14;
|
|
588
|
+
$[45] = t9;
|
|
589
|
+
$[46] = t15;
|
|
590
|
+
} else t15 = $[46];
|
|
591
|
+
let t16;
|
|
592
|
+
if ($[47] !== t11 || $[48] !== t12 || $[49] !== t15) {
|
|
593
|
+
t16 = /* @__PURE__ */ jsx("div", {
|
|
594
|
+
"data-slot": t11,
|
|
595
|
+
className: t12,
|
|
596
|
+
children: t15
|
|
597
|
+
});
|
|
598
|
+
$[47] = t11;
|
|
599
|
+
$[48] = t12;
|
|
600
|
+
$[49] = t15;
|
|
601
|
+
$[50] = t16;
|
|
602
|
+
} else t16 = $[50];
|
|
603
|
+
return t16;
|
|
604
|
+
}
|
|
605
|
+
function _temp(node_0) {
|
|
606
|
+
return [node_0.id, node_0];
|
|
607
|
+
}
|
|
608
|
+
/**
|
|
609
|
+
* One node, a button named by the node's name. Without children it draws the
|
|
610
|
+
* name and, under it, the swatch and `meta`. A `value` that isn't in `nodes`
|
|
611
|
+
* draws nothing, so an app's own list can lag a render behind.
|
|
612
|
+
*/
|
|
613
|
+
function GraphNode(props) {
|
|
614
|
+
const $ = c(3);
|
|
615
|
+
const { nodes } = useGraph();
|
|
616
|
+
let t0;
|
|
617
|
+
if ($[0] !== nodes || $[1] !== props) {
|
|
618
|
+
t0 = nodes.some((node) => node.id === props.value) ? /* @__PURE__ */ jsx(GraphNodeButton, { ...props }) : null;
|
|
619
|
+
$[0] = nodes;
|
|
620
|
+
$[1] = props;
|
|
621
|
+
$[2] = t0;
|
|
622
|
+
} else t0 = $[2];
|
|
623
|
+
return t0;
|
|
624
|
+
}
|
|
625
|
+
function GraphNodeButton(t0) {
|
|
626
|
+
const $ = c(15);
|
|
627
|
+
let children;
|
|
628
|
+
let className;
|
|
629
|
+
let props;
|
|
630
|
+
let value;
|
|
631
|
+
if ($[0] !== t0) {
|
|
632
|
+
({value, className, children, ...props} = t0);
|
|
633
|
+
$[0] = t0;
|
|
634
|
+
$[1] = children;
|
|
635
|
+
$[2] = className;
|
|
636
|
+
$[3] = props;
|
|
637
|
+
$[4] = value;
|
|
638
|
+
} else {
|
|
639
|
+
children = $[1];
|
|
640
|
+
className = $[2];
|
|
641
|
+
props = $[3];
|
|
642
|
+
value = $[4];
|
|
643
|
+
}
|
|
644
|
+
let t1;
|
|
645
|
+
if ($[5] !== value) {
|
|
646
|
+
t1 = { value };
|
|
647
|
+
$[5] = value;
|
|
648
|
+
$[6] = t1;
|
|
649
|
+
} else t1 = $[6];
|
|
650
|
+
let t2;
|
|
651
|
+
if ($[7] !== className) {
|
|
652
|
+
t2 = (state) => cn("absolute flex -translate-x-1/2 -translate-y-1/2 flex-col items-start gap-1 border bg-background px-3 py-2.5 text-start text-sm focus-ring", state.node.current ? "w-60 rounded-xl" : "w-52 rounded-lg", "border-input data-selected:border-foreground data-selected:shadow-sm", state.node.current && "border-foreground/60", typeof className === "function" ? className(state) : className);
|
|
653
|
+
$[7] = className;
|
|
654
|
+
$[8] = t2;
|
|
655
|
+
} else t2 = $[8];
|
|
656
|
+
let t3;
|
|
657
|
+
if ($[9] !== children) {
|
|
658
|
+
t3 = (state_0) => typeof children === "function" ? children(state_0) : children ?? /* @__PURE__ */ jsx(GraphNodeFace, { node: state_0.node });
|
|
659
|
+
$[9] = children;
|
|
660
|
+
$[10] = t3;
|
|
661
|
+
} else t3 = $[10];
|
|
662
|
+
let t4;
|
|
663
|
+
if ($[11] !== props || $[12] !== t2 || $[13] !== t3) {
|
|
664
|
+
t4 = {
|
|
665
|
+
className: t2,
|
|
666
|
+
children: t3,
|
|
667
|
+
...props
|
|
668
|
+
};
|
|
669
|
+
$[11] = props;
|
|
670
|
+
$[12] = t2;
|
|
671
|
+
$[13] = t3;
|
|
672
|
+
$[14] = t4;
|
|
673
|
+
} else t4 = $[14];
|
|
674
|
+
return usePart(graph, "node", t1, t4, "button");
|
|
675
|
+
}
|
|
676
|
+
function GraphNodeFace(t0) {
|
|
677
|
+
const $ = c(13);
|
|
678
|
+
const { node } = t0;
|
|
679
|
+
const t1 = node.current ? "text-label" : "text-sm";
|
|
680
|
+
const t2 = node.replaced ? "text-subtle line-through" : "text-foreground";
|
|
681
|
+
let t3;
|
|
682
|
+
if ($[0] !== t1 || $[1] !== t2) {
|
|
683
|
+
t3 = cn("text-pretty", t1, t2);
|
|
684
|
+
$[0] = t1;
|
|
685
|
+
$[1] = t2;
|
|
686
|
+
$[2] = t3;
|
|
687
|
+
} else t3 = $[2];
|
|
688
|
+
let t4;
|
|
689
|
+
if ($[3] !== node.name || $[4] !== t3) {
|
|
690
|
+
t4 = /* @__PURE__ */ jsx("span", {
|
|
691
|
+
className: t3,
|
|
692
|
+
children: node.name
|
|
693
|
+
});
|
|
694
|
+
$[3] = node.name;
|
|
695
|
+
$[4] = t3;
|
|
696
|
+
$[5] = t4;
|
|
697
|
+
} else t4 = $[5];
|
|
698
|
+
let t5;
|
|
699
|
+
if ($[6] !== node.color || $[7] !== node.meta || $[8] !== node.replaced) {
|
|
700
|
+
t5 = (node.meta || node.color) && /* @__PURE__ */ jsxs("span", {
|
|
701
|
+
"aria-hidden": "true",
|
|
702
|
+
className: "flex items-center gap-1.5 text-footnote",
|
|
703
|
+
children: [node.color && /* @__PURE__ */ jsx("span", {
|
|
704
|
+
"data-slot": "graph-node-swatch",
|
|
705
|
+
className: cn("size-1.5 shrink-0 rounded-xs", swatchClasses[node.color])
|
|
706
|
+
}), node.meta && /* @__PURE__ */ jsx("span", {
|
|
707
|
+
className: node.replaced ? "text-subtle" : "text-muted-foreground",
|
|
708
|
+
children: node.meta
|
|
709
|
+
})]
|
|
710
|
+
});
|
|
711
|
+
$[6] = node.color;
|
|
712
|
+
$[7] = node.meta;
|
|
713
|
+
$[8] = node.replaced;
|
|
714
|
+
$[9] = t5;
|
|
715
|
+
} else t5 = $[9];
|
|
716
|
+
let t6;
|
|
717
|
+
if ($[10] !== t4 || $[11] !== t5) {
|
|
718
|
+
t6 = /* @__PURE__ */ jsxs(Fragment$1, { children: [t4, t5] });
|
|
719
|
+
$[10] = t4;
|
|
720
|
+
$[11] = t5;
|
|
721
|
+
$[12] = t6;
|
|
722
|
+
} else t6 = $[12];
|
|
723
|
+
return t6;
|
|
724
|
+
}
|
|
725
|
+
const zoomButton = "flex size-7 items-center justify-center text-foreground select-none focus-ring-inset hover:bg-accent aria-disabled:opacity-50 aria-disabled:hover:bg-transparent motion-reduce:transition-none transition-colors";
|
|
726
|
+
/** The + and − buttons, stacked at the map's end corner. The keys + and − zoom too. */
|
|
727
|
+
function GraphZoom(t0) {
|
|
728
|
+
const $ = c(10);
|
|
729
|
+
const { className, zoomInLabel: t1, zoomOutLabel: t2 } = t0;
|
|
730
|
+
const zoomInLabel = t1 === void 0 ? "Zoom in" : t1;
|
|
731
|
+
const zoomOutLabel = t2 === void 0 ? "Zoom out" : t2;
|
|
732
|
+
let t3;
|
|
733
|
+
if ($[0] !== className) {
|
|
734
|
+
t3 = cn("absolute end-3 bottom-3 flex flex-col overflow-hidden rounded-lg border bg-background", className);
|
|
735
|
+
$[0] = className;
|
|
736
|
+
$[1] = t3;
|
|
737
|
+
} else t3 = $[1];
|
|
738
|
+
let t4;
|
|
739
|
+
if ($[2] !== zoomInLabel) {
|
|
740
|
+
t4 = /* @__PURE__ */ jsx(GraphZoomButton, {
|
|
741
|
+
part: "zoomIn",
|
|
742
|
+
label: zoomInLabel,
|
|
743
|
+
icon: Add01Icon,
|
|
744
|
+
divider: true
|
|
745
|
+
});
|
|
746
|
+
$[2] = zoomInLabel;
|
|
747
|
+
$[3] = t4;
|
|
748
|
+
} else t4 = $[3];
|
|
749
|
+
let t5;
|
|
750
|
+
if ($[4] !== zoomOutLabel) {
|
|
751
|
+
t5 = /* @__PURE__ */ jsx(GraphZoomButton, {
|
|
752
|
+
part: "zoomOut",
|
|
753
|
+
label: zoomOutLabel,
|
|
754
|
+
icon: MinusSignIcon
|
|
755
|
+
});
|
|
756
|
+
$[4] = zoomOutLabel;
|
|
757
|
+
$[5] = t5;
|
|
758
|
+
} else t5 = $[5];
|
|
759
|
+
let t6;
|
|
760
|
+
if ($[6] !== t3 || $[7] !== t4 || $[8] !== t5) {
|
|
761
|
+
t6 = /* @__PURE__ */ jsxs("div", {
|
|
762
|
+
"data-slot": "graph-zoom",
|
|
763
|
+
className: t3,
|
|
764
|
+
children: [t4, t5]
|
|
765
|
+
});
|
|
766
|
+
$[6] = t3;
|
|
767
|
+
$[7] = t4;
|
|
768
|
+
$[8] = t5;
|
|
769
|
+
$[9] = t6;
|
|
770
|
+
} else t6 = $[9];
|
|
771
|
+
return t6;
|
|
772
|
+
}
|
|
773
|
+
function GraphZoomButton(t0) {
|
|
774
|
+
const $ = c(9);
|
|
775
|
+
const { part, label, icon, divider } = t0;
|
|
776
|
+
let t1;
|
|
777
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
778
|
+
t1 = {};
|
|
779
|
+
$[0] = t1;
|
|
780
|
+
} else t1 = $[0];
|
|
781
|
+
const t2 = divider && "border-b";
|
|
782
|
+
let t3;
|
|
783
|
+
if ($[1] !== t2) {
|
|
784
|
+
t3 = cn(zoomButton, t2);
|
|
785
|
+
$[1] = t2;
|
|
786
|
+
$[2] = t3;
|
|
787
|
+
} else t3 = $[2];
|
|
788
|
+
let t4;
|
|
789
|
+
if ($[3] !== icon) {
|
|
790
|
+
t4 = /* @__PURE__ */ jsx(Icon, { icon });
|
|
791
|
+
$[3] = icon;
|
|
792
|
+
$[4] = t4;
|
|
793
|
+
} else t4 = $[4];
|
|
794
|
+
let t5;
|
|
795
|
+
if ($[5] !== label || $[6] !== t3 || $[7] !== t4) {
|
|
796
|
+
t5 = {
|
|
797
|
+
"aria-label": label,
|
|
798
|
+
className: t3,
|
|
799
|
+
children: t4
|
|
800
|
+
};
|
|
801
|
+
$[5] = label;
|
|
802
|
+
$[6] = t3;
|
|
803
|
+
$[7] = t4;
|
|
804
|
+
$[8] = t5;
|
|
805
|
+
} else t5 = $[8];
|
|
806
|
+
return usePart(graph, part, t1, t5, "button");
|
|
807
|
+
}
|
|
808
|
+
const legendLine = {
|
|
809
|
+
solid: {
|
|
810
|
+
stroke: "stroke-foreground/40 dark:stroke-foreground/25",
|
|
811
|
+
width: 1.2
|
|
812
|
+
},
|
|
813
|
+
dashed: {
|
|
814
|
+
stroke: "stroke-foreground/40 dark:stroke-foreground/25",
|
|
815
|
+
dash: "3 3",
|
|
816
|
+
width: 1.2
|
|
817
|
+
},
|
|
818
|
+
warning: {
|
|
819
|
+
stroke: "stroke-warning",
|
|
820
|
+
dash: "4 3",
|
|
821
|
+
width: 1.5
|
|
822
|
+
}
|
|
823
|
+
};
|
|
824
|
+
const legendLabels = {
|
|
825
|
+
solid: "Related",
|
|
826
|
+
dashed: "Weaker",
|
|
827
|
+
warning: "Conflicts"
|
|
828
|
+
};
|
|
829
|
+
/** Names each line style with a sample of it, at the map's start corner. */
|
|
830
|
+
function GraphLegend(t0) {
|
|
831
|
+
const $ = c(13);
|
|
832
|
+
const { className, variants: t1, labels, label: t2 } = t0;
|
|
833
|
+
let t3;
|
|
834
|
+
if ($[0] !== t1) {
|
|
835
|
+
t3 = t1 === void 0 ? [
|
|
836
|
+
"solid",
|
|
837
|
+
"dashed",
|
|
838
|
+
"warning"
|
|
839
|
+
] : t1;
|
|
840
|
+
$[0] = t1;
|
|
841
|
+
$[1] = t3;
|
|
842
|
+
} else t3 = $[1];
|
|
843
|
+
const variants = t3;
|
|
844
|
+
const label = t2 === void 0 ? "Legend" : t2;
|
|
845
|
+
let t4;
|
|
846
|
+
if ($[2] !== className) {
|
|
847
|
+
t4 = cn("absolute start-3 bottom-3 flex flex-wrap items-center gap-x-4 gap-y-1 text-footnote text-muted-foreground", className);
|
|
848
|
+
$[2] = className;
|
|
849
|
+
$[3] = t4;
|
|
850
|
+
} else t4 = $[3];
|
|
851
|
+
let t5;
|
|
852
|
+
if ($[4] !== labels || $[5] !== variants) {
|
|
853
|
+
let t6;
|
|
854
|
+
if ($[7] !== labels) {
|
|
855
|
+
t6 = (variant) => {
|
|
856
|
+
const line = legendLine[variant];
|
|
857
|
+
return /* @__PURE__ */ jsxs("li", {
|
|
858
|
+
className: "flex items-center gap-1.5",
|
|
859
|
+
children: [/* @__PURE__ */ jsx("svg", {
|
|
860
|
+
"aria-hidden": "true",
|
|
861
|
+
width: "20",
|
|
862
|
+
height: "2",
|
|
863
|
+
viewBox: "0 0 20 2",
|
|
864
|
+
className: "shrink-0",
|
|
865
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
866
|
+
d: "M0 1h20",
|
|
867
|
+
fill: "none",
|
|
868
|
+
strokeWidth: line.width,
|
|
869
|
+
strokeDasharray: line.dash,
|
|
870
|
+
className: line.stroke
|
|
871
|
+
})
|
|
872
|
+
}), labels?.[variant] ?? legendLabels[variant]]
|
|
873
|
+
}, variant);
|
|
874
|
+
};
|
|
875
|
+
$[7] = labels;
|
|
876
|
+
$[8] = t6;
|
|
877
|
+
} else t6 = $[8];
|
|
878
|
+
t5 = variants.map(t6);
|
|
879
|
+
$[4] = labels;
|
|
880
|
+
$[5] = variants;
|
|
881
|
+
$[6] = t5;
|
|
882
|
+
} else t5 = $[6];
|
|
883
|
+
let t6;
|
|
884
|
+
if ($[9] !== label || $[10] !== t4 || $[11] !== t5) {
|
|
885
|
+
t6 = /* @__PURE__ */ jsx("ul", {
|
|
886
|
+
"data-slot": "graph-legend",
|
|
887
|
+
"aria-label": label,
|
|
888
|
+
className: t4,
|
|
889
|
+
children: t5
|
|
890
|
+
});
|
|
891
|
+
$[9] = label;
|
|
892
|
+
$[10] = t4;
|
|
893
|
+
$[11] = t5;
|
|
894
|
+
$[12] = t6;
|
|
895
|
+
} else t6 = $[12];
|
|
896
|
+
return t6;
|
|
897
|
+
}
|
|
898
|
+
/**
|
|
899
|
+
* The same map as text, for people who read it with a screen reader: every
|
|
900
|
+
* node once, with its lines as "Contradicts: Other node". Hidden from sight.
|
|
901
|
+
*/
|
|
902
|
+
function GraphList(t0) {
|
|
903
|
+
const $ = c(14);
|
|
904
|
+
const { relatedLabel: t1, label: t2 } = t0;
|
|
905
|
+
const relatedLabel = t1 === void 0 ? "Related to" : t1;
|
|
906
|
+
const label = t2 === void 0 ? "Nodes and relations" : t2;
|
|
907
|
+
const { nodes, edges } = useGraph();
|
|
908
|
+
let t3;
|
|
909
|
+
if ($[0] !== nodes) {
|
|
910
|
+
t3 = new Map(nodes.map(_temp2));
|
|
911
|
+
$[0] = nodes;
|
|
912
|
+
$[1] = t3;
|
|
913
|
+
} else t3 = $[1];
|
|
914
|
+
const byId = t3;
|
|
915
|
+
let t4;
|
|
916
|
+
if ($[2] !== byId || $[3] !== edges || $[4] !== nodes || $[5] !== relatedLabel) {
|
|
917
|
+
let t5;
|
|
918
|
+
if ($[7] !== byId || $[8] !== edges || $[9] !== relatedLabel) {
|
|
919
|
+
t5 = (node_0) => {
|
|
920
|
+
const relations = edges.filter((edge) => edge.from === node_0.id || edge.to === node_0.id).map((edge_0) => {
|
|
921
|
+
const other = byId.get(edge_0.from === node_0.id ? edge_0.to : edge_0.from);
|
|
922
|
+
return `${edge_0.label ?? relatedLabel}: ${other.name}`;
|
|
923
|
+
});
|
|
924
|
+
return /* @__PURE__ */ jsx("li", { children: [
|
|
925
|
+
node_0.name,
|
|
926
|
+
node_0.meta,
|
|
927
|
+
...relations
|
|
928
|
+
].filter(Boolean).join(". ") }, node_0.id);
|
|
929
|
+
};
|
|
930
|
+
$[7] = byId;
|
|
931
|
+
$[8] = edges;
|
|
932
|
+
$[9] = relatedLabel;
|
|
933
|
+
$[10] = t5;
|
|
934
|
+
} else t5 = $[10];
|
|
935
|
+
t4 = nodes.map(t5);
|
|
936
|
+
$[2] = byId;
|
|
937
|
+
$[3] = edges;
|
|
938
|
+
$[4] = nodes;
|
|
939
|
+
$[5] = relatedLabel;
|
|
940
|
+
$[6] = t4;
|
|
941
|
+
} else t4 = $[6];
|
|
942
|
+
let t5;
|
|
943
|
+
if ($[11] !== label || $[12] !== t4) {
|
|
944
|
+
t5 = /* @__PURE__ */ jsx("ul", {
|
|
945
|
+
"data-slot": "graph-list",
|
|
946
|
+
"aria-label": label,
|
|
947
|
+
className: "sr-only",
|
|
948
|
+
children: t4
|
|
949
|
+
});
|
|
950
|
+
$[11] = label;
|
|
951
|
+
$[12] = t4;
|
|
952
|
+
$[13] = t5;
|
|
953
|
+
} else t5 = $[13];
|
|
954
|
+
return t5;
|
|
955
|
+
}
|
|
956
|
+
function _temp2(node) {
|
|
957
|
+
return [node.id, node];
|
|
958
|
+
}
|
|
959
|
+
export { Graph, GraphCanvas, GraphLegend, GraphList, GraphNode, GraphZoom, createGraphController, useGraph };
|