@mechane-ai/elements 0.42.0 → 0.44.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/README.md +32 -32
- package/dist/ai.js +1 -1
- package/dist/catalog.json +89 -1
- package/dist/{categorical-values-B6lGI7BH.js → categorical-values-ByvFLaNE.js} +3 -3
- package/dist/{chart-frame-D0enjyj9.js → chart-frame-Bcd9Tpt5.js} +75 -23
- package/dist/{chart-input-D4_Awave.js → chart-input-B6_HXFDP.js} +2 -2
- package/dist/{chart-navigation-D4-pdgpj.js → chart-navigation-BAbb5PV9.js} +56 -32
- package/dist/charts/cartesian.js +1701 -551
- package/dist/charts/distribution.js +41 -28
- package/dist/charts/graph.js +443 -76
- package/dist/charts/hierarchy.js +5 -5
- package/dist/charts/matrix.js +232 -63
- package/dist/charts/timeline.js +2 -2
- package/dist/charts.js +2 -2
- package/dist/collections.js +2 -2
- package/dist/{constants.stylex-BILvnwUk.js → constants.stylex-CaVa9yGN.js} +9 -9
- package/dist/content/tree.js +1 -1
- package/dist/feedback.js +1 -1
- package/dist/label-spacing-BncjePGb.js +6 -0
- package/dist/packages/charts/src/cartesian/bar-chart.d.ts +15 -3
- package/dist/packages/charts/src/cartesian/bar-data.d.ts +43 -0
- package/dist/packages/charts/src/cartesian/bar-overlays.d.ts +32 -0
- package/dist/packages/charts/src/cartesian/bridge-chart.d.ts +29 -0
- package/dist/packages/charts/src/cartesian/bridge-data.d.ts +40 -0
- package/dist/packages/charts/src/cartesian/index.d.ts +7 -2
- package/dist/packages/charts/src/cartesian/reference-lines.d.ts +34 -0
- package/dist/packages/charts/src/cartesian/sparkline.d.ts +10 -1
- package/dist/packages/charts/src/cartesian/time-series-bands.d.ts +66 -0
- package/dist/packages/charts/src/cartesian/time-series-data.d.ts +11 -1
- package/dist/packages/charts/src/cartesian/time-series-overlays.d.ts +35 -0
- package/dist/packages/charts/src/cartesian/time-series.d.ts +6 -1
- package/dist/packages/charts/src/chart-inspection.d.ts +3 -1
- package/dist/packages/charts/src/chart-navigation.d.ts +3 -1
- package/dist/packages/charts/src/chart-series-marker.d.ts +8 -1
- package/dist/packages/charts/src/chart-surface.d.ts +2 -0
- package/dist/packages/charts/src/chart-theme.d.ts +29 -2
- package/dist/packages/charts/src/distribution/distribution-plot.d.ts +3 -1
- package/dist/packages/charts/src/graph/flow-diagram.d.ts +26 -0
- package/dist/packages/charts/src/graph/flow-layout.d.ts +70 -0
- package/dist/packages/charts/src/graph/index.d.ts +2 -0
- package/dist/packages/charts/src/index.d.ts +1 -1
- package/dist/packages/charts/src/label-spacing.d.ts +15 -0
- package/dist/packages/charts/src/matrix/matrix-cells.d.ts +4 -0
- package/dist/packages/charts/src/matrix/matrix-strip.d.ts +20 -0
- package/dist/packages/charts/src/matrix/matrix-types.d.ts +21 -0
- package/dist/packages/charts/src/matrix/matrix.d.ts +8 -19
- package/dist/{plot-width-BQQS-mw9.js → plot-width-8cXdAjoD.js} +31 -2
- package/dist/{src-BpvnBWrF.js → src-CDp1JtwC.js} +1 -1
- package/dist/styles2.css +141 -18
- package/dist/tokens.js +1 -1
- package/package.json +1 -1
- package/packages/foundations/src/constants.stylex.ts +9 -9
- package/packages/foundations/src/tokens.stylex.ts +9 -9
- package/recipes/allocation-report.tsx +115 -0
package/dist/charts/graph.js
CHANGED
|
@@ -1,18 +1,385 @@
|
|
|
1
|
-
import { c as e } from "../src-
|
|
2
|
-
import { a as t, n, t as r } from "../chart-navigation-
|
|
3
|
-
import { i, n as a } from "../chart-frame-
|
|
4
|
-
import { n as o, t as s } from "../chart-input-
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
1
|
+
import { c as e } from "../src-CDp1JtwC.js";
|
|
2
|
+
import { a as t, n, t as r } from "../chart-navigation-BAbb5PV9.js";
|
|
3
|
+
import { i, n as a } from "../chart-frame-Bcd9Tpt5.js";
|
|
4
|
+
import { n as o, t as s } from "../chart-input-B6_HXFDP.js";
|
|
5
|
+
import { n as c, t as l } from "../plot-width-8cXdAjoD.js";
|
|
6
|
+
import { t as u } from "../label-spacing-BncjePGb.js";
|
|
7
|
+
import { r as d } from "../categorical-values-ByvFLaNE.js";
|
|
8
|
+
import * as f from "@stylexjs/stylex";
|
|
9
|
+
import { Button as p } from "@ui-sdk/react/button";
|
|
10
|
+
import { useId as m } from "react";
|
|
11
|
+
import { Fragment as h, jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
12
|
+
var v = 16, y = 2, b = .5;
|
|
13
|
+
function x({ nodes: e, links: t, columns: n }) {
|
|
14
|
+
return new Map(e.map((e) => {
|
|
15
|
+
let r = t.filter((t) => t.targetId === e.id).map((e) => (n.get(e.sourceId) ?? 0) + 1);
|
|
16
|
+
return [e.id, Math.max(0, ...r)];
|
|
17
|
+
}));
|
|
18
|
+
}
|
|
19
|
+
function S({ nodes: e, links: t }) {
|
|
20
|
+
let n = new Map(e.map((e) => [e.id, 0]));
|
|
21
|
+
for (let r of e) n = x({
|
|
22
|
+
nodes: e,
|
|
23
|
+
links: t,
|
|
24
|
+
columns: n
|
|
25
|
+
});
|
|
26
|
+
let r = x({
|
|
27
|
+
nodes: e,
|
|
28
|
+
links: t,
|
|
29
|
+
columns: n
|
|
30
|
+
});
|
|
31
|
+
return e.every((e) => r.get(e.id) === n.get(e.id)) ? n : void 0;
|
|
32
|
+
}
|
|
33
|
+
function C(e) {
|
|
34
|
+
return e.reduce((e, t) => e + t, 0);
|
|
35
|
+
}
|
|
36
|
+
function w(e) {
|
|
37
|
+
return e.value ?? 0;
|
|
38
|
+
}
|
|
39
|
+
function T(e) {
|
|
40
|
+
return e.map((t, n) => C(e.slice(0, n)));
|
|
41
|
+
}
|
|
42
|
+
function E({ nodes: e, links: t, left: n, right: r, top: i, bottom: a }) {
|
|
43
|
+
let o = S({
|
|
44
|
+
nodes: e,
|
|
45
|
+
links: t
|
|
46
|
+
}) ?? /* @__PURE__ */ new Map(), s = Math.max(1, ...[...o.values()].map((e) => e + 1)), c = Array.from({ length: s }, (t, n) => e.filter((e) => o.get(e.id) === n)), l = e.map((e) => {
|
|
47
|
+
let n = t.filter((t) => t.targetId === e.id), r = t.filter((t) => t.sourceId === e.id), i = [...n, ...r].some((e) => e.value === null);
|
|
48
|
+
return {
|
|
49
|
+
id: e.id,
|
|
50
|
+
inflow: C(n.map(w)),
|
|
51
|
+
outflow: C(r.map(w)),
|
|
52
|
+
hasUnavailable: i
|
|
53
|
+
};
|
|
54
|
+
}), u = new Map(l.map((e) => [e.id, e]));
|
|
55
|
+
function f(e) {
|
|
56
|
+
let t = u.get(e.id);
|
|
57
|
+
return Math.max(t?.inflow ?? 0, t?.outflow ?? 0);
|
|
58
|
+
}
|
|
59
|
+
let p = a - i, m = Math.min(...c.map((e) => {
|
|
60
|
+
let t = C(e.map(f)), n = p - Math.max(0, e.length - 1) * v - e.length * y;
|
|
61
|
+
return t === 0 ? Infinity : Math.max(0, n) / t;
|
|
62
|
+
})), h = Number.isFinite(m) ? m : 0, g = s === 1 ? 0 : (r - n - 12) / (s - 1), _ = c.flatMap((t, r) => {
|
|
63
|
+
let a = t.map((e) => Math.max(y, f(e) * h)), o = C(a) + Math.max(0, t.length - 1) * v, s = i + (p - o) * b, c = T(a.map((e) => e + v));
|
|
64
|
+
return t.map((t, i) => {
|
|
65
|
+
let o = u.get(t.id);
|
|
66
|
+
return {
|
|
67
|
+
node: t,
|
|
68
|
+
tone: d(t.tone, e.indexOf(t)),
|
|
69
|
+
column: r,
|
|
70
|
+
x: n + r * g,
|
|
71
|
+
y: s + (c[i] ?? 0),
|
|
72
|
+
height: a[i] ?? y,
|
|
73
|
+
inflow: o?.inflow ?? 0,
|
|
74
|
+
outflow: o?.outflow ?? 0,
|
|
75
|
+
hasUnavailable: o?.hasUnavailable ?? !1
|
|
76
|
+
};
|
|
77
|
+
});
|
|
78
|
+
}), x = new Map(_.map((e) => [e.node.id, e]));
|
|
79
|
+
function E(e) {
|
|
80
|
+
let t = x.get(e);
|
|
81
|
+
return t === void 0 ? 0 : t.y + t.height * b;
|
|
82
|
+
}
|
|
83
|
+
function D(e, t) {
|
|
84
|
+
let n = e.toSorted((e, n) => E(t(e)) - E(t(n))), r = T(n.map((e) => w(e) * h));
|
|
85
|
+
return new Map(n.map((e, t) => [e.id, r[t] ?? 0]));
|
|
86
|
+
}
|
|
87
|
+
let O = new Map(_.map((e) => [e.node.id, D(t.filter((t) => t.sourceId === e.node.id), (e) => e.targetId)])), k = new Map(_.map((e) => [e.node.id, D(t.filter((t) => t.targetId === e.node.id), (e) => e.sourceId)]));
|
|
88
|
+
return {
|
|
89
|
+
nodes: _,
|
|
90
|
+
links: t.flatMap((e) => {
|
|
91
|
+
let t = x.get(e.sourceId), n = x.get(e.targetId);
|
|
92
|
+
if (t === void 0 || n === void 0) return [];
|
|
93
|
+
let r = O.get(t.node.id)?.get(e.id) ?? 0, i = k.get(n.node.id)?.get(e.id) ?? 0;
|
|
94
|
+
return [{
|
|
95
|
+
link: e,
|
|
96
|
+
tone: e.tone ?? n.tone,
|
|
97
|
+
source: t,
|
|
98
|
+
target: n,
|
|
99
|
+
sourceY: t.y + r,
|
|
100
|
+
targetY: n.y + i,
|
|
101
|
+
width: w(e) * h
|
|
102
|
+
}];
|
|
103
|
+
}),
|
|
104
|
+
columnCount: s
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
function D(e) {
|
|
108
|
+
let t = e.source.x + 12, n = e.target.x, r = (t + n) * b, { sourceY: i, targetY: a, width: o } = e;
|
|
109
|
+
return [
|
|
110
|
+
`M${t},${i}`,
|
|
111
|
+
`C${r},${i} ${r},${a} ${n},${a}`,
|
|
112
|
+
`L${n},${a + o}`,
|
|
113
|
+
`C${r},${a + o} ${r},${i + o} ${t},${i + o}`,
|
|
114
|
+
"Z"
|
|
115
|
+
].join(" ");
|
|
116
|
+
}
|
|
117
|
+
function O(e) {
|
|
118
|
+
let t = e.source.x + 12, n = e.target.x, r = (t + n) * b, i = e.sourceY + e.width * b, a = e.targetY + e.width * b;
|
|
119
|
+
return `M${t},${i} C${r},${i} ${r},${a} ${n},${a}`;
|
|
120
|
+
}
|
|
121
|
+
// packages/charts/src/graph/flow-diagram.tsx
|
|
122
|
+
var k = {
|
|
123
|
+
kVYP8I: "x14kjgpu",
|
|
124
|
+
$$css: !0
|
|
125
|
+
}, A = {
|
|
126
|
+
kDwRjp: "xbh8q5q",
|
|
127
|
+
kfJifR: "xhr4kjn",
|
|
128
|
+
kREpy8: "x13efnbd",
|
|
129
|
+
$$css: !0
|
|
130
|
+
}, j = {
|
|
131
|
+
ribbon: (e) => [
|
|
132
|
+
k,
|
|
133
|
+
{
|
|
134
|
+
kDwRjp: e == null ? e : "x19zyb68",
|
|
135
|
+
$$css: !0
|
|
136
|
+
},
|
|
137
|
+
{ "--x-fill": e ?? void 0 }
|
|
138
|
+
],
|
|
139
|
+
thread: (e) => [
|
|
140
|
+
A,
|
|
141
|
+
{
|
|
142
|
+
kjVXCG: e == null ? e : "x6mkzkt",
|
|
143
|
+
$$css: !0
|
|
144
|
+
},
|
|
145
|
+
{ "--x-stroke": e ?? void 0 }
|
|
146
|
+
],
|
|
147
|
+
unavailable: {
|
|
148
|
+
k5rJSQ: "x15lqr97",
|
|
149
|
+
$$css: !0
|
|
150
|
+
},
|
|
151
|
+
node: (e) => [{
|
|
152
|
+
kDwRjp: e == null ? e : "x19zyb68",
|
|
153
|
+
$$css: !0
|
|
154
|
+
}, { "--x-fill": e ?? void 0 }],
|
|
155
|
+
lit: {
|
|
156
|
+
kVYP8I: "xif5ylx",
|
|
157
|
+
$$css: !0
|
|
158
|
+
},
|
|
159
|
+
dim: {
|
|
160
|
+
kSiTet: "xz5rk10",
|
|
161
|
+
$$css: !0
|
|
162
|
+
},
|
|
163
|
+
transition: {
|
|
164
|
+
k1ekBW: "x19991ni",
|
|
165
|
+
kIyJzY: "xtitasy x12w9bfk",
|
|
166
|
+
kAMwcw: "x1faw7qm",
|
|
167
|
+
$$css: !0
|
|
168
|
+
},
|
|
169
|
+
selected: {
|
|
170
|
+
kjVXCG: "x17y187c",
|
|
171
|
+
kfJifR: "xvlca1e",
|
|
172
|
+
kREpy8: "x13efnbd",
|
|
173
|
+
$$css: !0
|
|
174
|
+
},
|
|
175
|
+
interactive: {
|
|
176
|
+
kkrTdU: "x1ypdohk",
|
|
177
|
+
$$css: !0
|
|
178
|
+
}
|
|
179
|
+
}, M = 64, N = 256, P = 8, F = 8, I = 16, L = 6.5, R = 22, z = 180, B = 48, V = 240, H = 96;
|
|
180
|
+
function U({ nodes: e, links: t }) {
|
|
181
|
+
if (e.length > 64 || t.length > 256) return "This flow exceeds the render limit of 64 nodes or 256 links. Supply a smaller, labelled grouping.";
|
|
182
|
+
if (!o([...e, ...t])) return "Flow nodes and links require distinct, unique identifiers.";
|
|
183
|
+
let n = new Set(e.map((e) => e.id));
|
|
184
|
+
for (let e of t) {
|
|
185
|
+
if (!(n.has(e.sourceId) && n.has(e.targetId) && e.sourceId !== e.targetId)) return "Every flow link must join two different supplied nodes.";
|
|
186
|
+
if (e.value !== null && (!Number.isFinite(e.value) || e.value < 0)) return "Flow amounts must be finite and nonnegative, or explicitly unavailable.";
|
|
187
|
+
}
|
|
188
|
+
return S({
|
|
189
|
+
nodes: e,
|
|
190
|
+
links: t
|
|
191
|
+
}) === void 0 ? "Flow links must not form a cycle." : void 0;
|
|
192
|
+
}
|
|
193
|
+
function W(e) {
|
|
194
|
+
return e.length > R ? `${e.slice(0, 21)}…` : e;
|
|
195
|
+
}
|
|
196
|
+
function G(e) {
|
|
197
|
+
return Math.max(e.inflow, e.outflow);
|
|
198
|
+
}
|
|
199
|
+
function K({ placed: e, formatValue: t }) {
|
|
200
|
+
let n = e.inflow > 0 && e.outflow > 0 && e.inflow !== e.outflow ? `in ${t(e.inflow)}, out ${t(e.outflow)}` : t(G(e));
|
|
201
|
+
return e.hasUnavailable ? `${n}, with an unavailable amount` : n;
|
|
202
|
+
}
|
|
203
|
+
function ee({ placed: e, formatValue: t }) {
|
|
204
|
+
let n = e.link.value === null ? "Unavailable" : t(e.link.value);
|
|
205
|
+
return `${e.source.node.label} → ${e.target.node.label}: ${n}`;
|
|
206
|
+
}
|
|
207
|
+
function q({ nodes: e, links: t, formatValue: n }) {
|
|
208
|
+
let r = e.map((e) => {
|
|
209
|
+
let r = t.filter((t) => t.targetId === e.id).reduce((e, t) => e + (t.value ?? 0), 0), i = t.filter((t) => t.sourceId === e.id).reduce((e, t) => e + (t.value ?? 0), 0), a = Math.max(r, i);
|
|
210
|
+
return W(e.label).length + n(a).length + 1;
|
|
211
|
+
});
|
|
212
|
+
return Math.min(z, Math.max(0, ...r) * L + F);
|
|
213
|
+
}
|
|
214
|
+
function J({ title: o, description: c, report: u, nodes: d, links: p, formatValue: m, selection: h, height: v, emptyLabel: y = "No flows" }) {
|
|
215
|
+
let { ref: b, width: x } = l(), C = U({
|
|
216
|
+
nodes: d,
|
|
217
|
+
links: p
|
|
218
|
+
}), w = (C === void 0 ? S({
|
|
219
|
+
nodes: d,
|
|
220
|
+
links: p
|
|
221
|
+
}) : void 0) ?? /* @__PURE__ */ new Map(), T = Math.max(0, ...w.values()), k = Array.from({ length: T + 1 }, (e, t) => d.filter((e) => w.get(e.id) === t).length), A = v ?? Math.max(V, Math.max(...k) * B), M = T === 0 ? [] : d.filter((e) => w.get(e.id) === 0), N = d.filter((e) => w.get(e.id) === T), F = q({
|
|
222
|
+
nodes: M,
|
|
223
|
+
links: p,
|
|
224
|
+
formatValue: m
|
|
225
|
+
}), I = q({
|
|
226
|
+
nodes: N,
|
|
227
|
+
links: p,
|
|
228
|
+
formatValue: m
|
|
229
|
+
}), L = E({
|
|
230
|
+
nodes: C === void 0 ? d : [],
|
|
231
|
+
links: C === void 0 ? p : [],
|
|
232
|
+
left: F,
|
|
233
|
+
right: Math.max(F + 12, x - I),
|
|
234
|
+
top: P,
|
|
235
|
+
bottom: A - P
|
|
236
|
+
}), R = L.nodes.flatMap((e) => [{
|
|
237
|
+
id: e.node.id,
|
|
238
|
+
label: `${e.node.label}: ${K({
|
|
239
|
+
placed: e,
|
|
240
|
+
formatValue: m
|
|
241
|
+
})}`
|
|
242
|
+
}, ...L.links.filter((t) => t.source.node.id === e.node.id).map((e) => ({
|
|
243
|
+
id: e.link.id,
|
|
244
|
+
label: ee({
|
|
245
|
+
placed: e,
|
|
246
|
+
formatValue: m
|
|
247
|
+
})
|
|
248
|
+
}))]), z = r({
|
|
249
|
+
title: o,
|
|
250
|
+
selection: h,
|
|
251
|
+
items: R
|
|
252
|
+
});
|
|
253
|
+
if (C !== void 0) return /* @__PURE__ */ g(s, {
|
|
254
|
+
title: o,
|
|
255
|
+
description: c,
|
|
256
|
+
report: u,
|
|
257
|
+
message: C
|
|
258
|
+
});
|
|
259
|
+
if (!Number.isFinite(A) || A < H) return /* @__PURE__ */ g(s, {
|
|
260
|
+
title: o,
|
|
261
|
+
description: c,
|
|
262
|
+
report: u,
|
|
263
|
+
message: `Flow height must be at least ${H} pixels.`
|
|
264
|
+
});
|
|
265
|
+
let W = z.label === void 0 ? void 0 : z.activeId, G = L.links.find((e) => e.link.id === W), J = L.nodes.find((e) => e.node.id === W);
|
|
266
|
+
function Y(e) {
|
|
267
|
+
return G === void 0 ? J !== void 0 && [e.source.node.id, e.target.node.id].includes(J.node.id) : G.link.id === e.link.id;
|
|
268
|
+
}
|
|
269
|
+
function X(e) {
|
|
270
|
+
return G === void 0 ? J === void 0 || J.node.id === e.node.id || L.links.some((t) => Y(t) && [t.source.node.id, t.target.node.id].includes(e.node.id)) : [G.source.node.id, G.target.node.id].includes(e.node.id);
|
|
271
|
+
}
|
|
272
|
+
let Z = W !== void 0;
|
|
273
|
+
function Q(e) {
|
|
274
|
+
return {
|
|
275
|
+
onPointerEnter: () => z.inspect(e),
|
|
276
|
+
onClick: () => h?.onSelect(e)
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
return /* @__PURE__ */ _(a, {
|
|
280
|
+
title: o,
|
|
281
|
+
description: c,
|
|
282
|
+
report: u,
|
|
283
|
+
footer: /* @__PURE__ */ g(i, {
|
|
284
|
+
id: z.id,
|
|
285
|
+
children: z.label ?? "\xA0"
|
|
286
|
+
}),
|
|
287
|
+
children: [/* @__PURE__ */ g(t, {
|
|
288
|
+
label: `${o} flows`,
|
|
289
|
+
columns: [{
|
|
290
|
+
id: "item",
|
|
291
|
+
label: "Item"
|
|
292
|
+
}, {
|
|
293
|
+
id: "amount",
|
|
294
|
+
label: "Amount"
|
|
295
|
+
}],
|
|
296
|
+
rows: [...L.nodes.map((e) => ({
|
|
297
|
+
id: `node:${e.node.id}`,
|
|
298
|
+
values: [e.node.label, K({
|
|
299
|
+
placed: e,
|
|
300
|
+
formatValue: m
|
|
301
|
+
})]
|
|
302
|
+
})), ...L.links.map((e) => ({
|
|
303
|
+
id: `link:${e.link.id}`,
|
|
304
|
+
values: [`${e.source.node.label} → ${e.target.node.label}`, e.link.value === null ? "Unavailable" : m(e.link.value)]
|
|
305
|
+
}))]
|
|
306
|
+
}), /* @__PURE__ */ g("div", {
|
|
307
|
+
ref: b,
|
|
308
|
+
children: d.length === 0 ? /* @__PURE__ */ g("p", {
|
|
309
|
+
className: "x1ghz6dp x153jb6y xy8obcc",
|
|
310
|
+
children: y
|
|
311
|
+
}) : /* @__PURE__ */ g(n, {
|
|
312
|
+
...z.props,
|
|
313
|
+
className: "xeuugli x1we84gm x1t137rt x13qnu6 x19rmrnh x9v5kkp x7s97pk",
|
|
314
|
+
children: /* @__PURE__ */ _("svg", {
|
|
315
|
+
"aria-hidden": !0,
|
|
316
|
+
viewBox: `0 0 ${x} ${A}`,
|
|
317
|
+
height: A,
|
|
318
|
+
className: "x1lliihq xh8yej3 x1rea2x4",
|
|
319
|
+
children: [
|
|
320
|
+
/* @__PURE__ */ g("g", { children: L.links.map((t) => {
|
|
321
|
+
let n = e[t.tone], r = Y(t), i = t.width > 0, a = h?.selectedId === t.link.id;
|
|
322
|
+
return /* @__PURE__ */ g("path", {
|
|
323
|
+
d: i ? D(t) : O(t),
|
|
324
|
+
...Q(t.link.id),
|
|
325
|
+
...f.props(i ? j.ribbon(n) : j.thread(n), t.link.value === null && j.unavailable, j.transition, r && i && j.lit, Z && !r && j.dim, a && j.selected, h !== void 0 && j.interactive)
|
|
326
|
+
}, t.link.id);
|
|
327
|
+
}) }),
|
|
328
|
+
L.nodes.map((t) => /* @__PURE__ */ g("rect", {
|
|
329
|
+
x: t.x,
|
|
330
|
+
y: t.y,
|
|
331
|
+
width: 12,
|
|
332
|
+
height: t.height,
|
|
333
|
+
...Q(t.node.id),
|
|
334
|
+
...f.props(j.node(e[t.tone]), j.transition, Z && !X(t) && j.dim, h?.selectedId === t.node.id && j.selected, h !== void 0 && j.interactive)
|
|
335
|
+
}, t.node.id)),
|
|
336
|
+
/* @__PURE__ */ g(te, {
|
|
337
|
+
nodes: L.nodes,
|
|
338
|
+
columnCount: L.columnCount,
|
|
339
|
+
top: P,
|
|
340
|
+
bottom: A - P,
|
|
341
|
+
formatValue: m,
|
|
342
|
+
isLit: (e) => !Z || X(e)
|
|
343
|
+
})
|
|
344
|
+
]
|
|
345
|
+
})
|
|
346
|
+
})
|
|
347
|
+
})]
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
function te({ nodes: e, columnCount: t, top: n, bottom: r, formatValue: i, isLit: a }) {
|
|
351
|
+
let o = Array.from({ length: t }, (t, n) => e.filter((e) => e.column === n));
|
|
352
|
+
return /* @__PURE__ */ g("g", { children: o.map((e, o) => {
|
|
353
|
+
let s = o === 0 && t > 1, l = u({
|
|
354
|
+
positions: e.map((e) => e.y + e.height / 2),
|
|
355
|
+
gap: I,
|
|
356
|
+
start: n,
|
|
357
|
+
end: r
|
|
358
|
+
});
|
|
359
|
+
return e.map((e, t) => /* @__PURE__ */ _("text", {
|
|
360
|
+
x: s ? e.x - F : e.x + 12 + F,
|
|
361
|
+
y: l[t] ?? e.y,
|
|
362
|
+
textAnchor: s ? "end" : "start",
|
|
363
|
+
dominantBaseline: "middle",
|
|
364
|
+
...f.props(c.label, c.haloLabel, j.transition, !a(e) && j.dim),
|
|
365
|
+
children: [
|
|
366
|
+
/* @__PURE__ */ g("tspan", {
|
|
367
|
+
...f.props(c.strongLabel),
|
|
368
|
+
children: W(e.node.label)
|
|
369
|
+
}),
|
|
370
|
+
" ",
|
|
371
|
+
i(G(e))
|
|
372
|
+
]
|
|
373
|
+
}, e.node.id));
|
|
374
|
+
}) });
|
|
375
|
+
}
|
|
9
376
|
// packages/charts/src/graph/relation-graph.tsx
|
|
10
|
-
var
|
|
377
|
+
var Y = {
|
|
11
378
|
kVAEAm: "x1n2onr6",
|
|
12
379
|
$$css: !0
|
|
13
|
-
},
|
|
380
|
+
}, X = {
|
|
14
381
|
canvas: (e, t) => [
|
|
15
|
-
|
|
382
|
+
Y,
|
|
16
383
|
{
|
|
17
384
|
kzqmXN: e == null ? e : "x5lhr3w",
|
|
18
385
|
kZKoxP: t == null ? t : "x16ye13r",
|
|
@@ -82,131 +449,131 @@ var m = {
|
|
|
82
449
|
kInvED: "x2ssjo2",
|
|
83
450
|
$$css: !0
|
|
84
451
|
}
|
|
85
|
-
},
|
|
86
|
-
function
|
|
87
|
-
let
|
|
452
|
+
}, Z = 256, Q = 1024, ne = 256, $ = 8192;
|
|
453
|
+
function re({ title: o, report: c, description: l, nodes: u, edges: d, groups: v = [], width: y, height: b, selection: x, emptyLabel: S }) {
|
|
454
|
+
let C = r({
|
|
88
455
|
title: o,
|
|
89
|
-
selection:
|
|
90
|
-
items:
|
|
456
|
+
selection: x,
|
|
457
|
+
items: u.map((e) => ({
|
|
91
458
|
id: e.id,
|
|
92
459
|
label: [e.label, e.description].filter((e) => e !== void 0).join(", ")
|
|
93
460
|
}))
|
|
94
|
-
}),
|
|
95
|
-
nodes:
|
|
96
|
-
edges:
|
|
97
|
-
groups:
|
|
98
|
-
width:
|
|
99
|
-
height:
|
|
461
|
+
}), w = m(), T = ie({
|
|
462
|
+
nodes: u,
|
|
463
|
+
edges: d,
|
|
464
|
+
groups: v,
|
|
465
|
+
width: y,
|
|
466
|
+
height: b
|
|
100
467
|
});
|
|
101
|
-
if (
|
|
468
|
+
if (T !== null) return /* @__PURE__ */ g(s, {
|
|
102
469
|
title: o,
|
|
103
|
-
report:
|
|
104
|
-
description:
|
|
105
|
-
message:
|
|
470
|
+
report: c,
|
|
471
|
+
description: l,
|
|
472
|
+
message: T
|
|
106
473
|
});
|
|
107
|
-
let
|
|
108
|
-
return
|
|
474
|
+
let E = new Map(u.map((e) => [e.id, e])), D = ae(d, E), O = u.length > 0;
|
|
475
|
+
return D === null ? /* @__PURE__ */ g(s, {
|
|
109
476
|
title: o,
|
|
110
|
-
report:
|
|
111
|
-
description:
|
|
477
|
+
report: c,
|
|
478
|
+
description: l,
|
|
112
479
|
message: "Every relationship must refer to two supplied nodes."
|
|
113
|
-
}) : /* @__PURE__ */
|
|
480
|
+
}) : /* @__PURE__ */ _(a, {
|
|
114
481
|
title: o,
|
|
115
|
-
report:
|
|
116
|
-
description:
|
|
117
|
-
footer: /* @__PURE__ */
|
|
118
|
-
id:
|
|
119
|
-
children:
|
|
482
|
+
report: c,
|
|
483
|
+
description: l,
|
|
484
|
+
footer: /* @__PURE__ */ g(i, {
|
|
485
|
+
id: C.id,
|
|
486
|
+
children: C.label ?? "\xA0"
|
|
120
487
|
}),
|
|
121
|
-
children: [
|
|
122
|
-
...
|
|
488
|
+
children: [O ? /* @__PURE__ */ g(n, {
|
|
489
|
+
...C.props,
|
|
123
490
|
className: "xysyzu8 xzuc9lq xeuugli x1t137rt xmkeg23 x1y0btm7 x1ey3b81 x13qnu6 x19rmrnh x9v5kkp x1bqaal",
|
|
124
|
-
children: /* @__PURE__ */
|
|
125
|
-
...
|
|
126
|
-
children: [/* @__PURE__ */
|
|
127
|
-
width:
|
|
128
|
-
height:
|
|
491
|
+
children: /* @__PURE__ */ _("div", {
|
|
492
|
+
...f.props(X.canvas(y, b)),
|
|
493
|
+
children: [/* @__PURE__ */ _("svg", {
|
|
494
|
+
width: y,
|
|
495
|
+
height: b,
|
|
129
496
|
"aria-hidden": !0,
|
|
130
497
|
className: "x10l6tqk x10a8y8t x1lliihq",
|
|
131
498
|
children: [
|
|
132
|
-
/* @__PURE__ */
|
|
133
|
-
id:
|
|
499
|
+
/* @__PURE__ */ g("defs", { children: /* @__PURE__ */ g("marker", {
|
|
500
|
+
id: w,
|
|
134
501
|
markerWidth: 8,
|
|
135
502
|
markerHeight: 8,
|
|
136
503
|
refX: 7,
|
|
137
504
|
refY: 4,
|
|
138
505
|
orient: "auto",
|
|
139
506
|
markerUnits: "userSpaceOnUse",
|
|
140
|
-
children: /* @__PURE__ */
|
|
507
|
+
children: /* @__PURE__ */ g("path", {
|
|
141
508
|
d: "M0,0 L8,4 L0,8 Z",
|
|
142
509
|
className: "x8futc7"
|
|
143
510
|
})
|
|
144
511
|
}) }),
|
|
145
|
-
|
|
512
|
+
v.map((e) => /* @__PURE__ */ _("g", { children: [/* @__PURE__ */ g("rect", {
|
|
146
513
|
x: e.x,
|
|
147
514
|
y: e.y,
|
|
148
515
|
width: e.width,
|
|
149
516
|
height: e.height,
|
|
150
517
|
className: "x2wnxhi x13hfdr1 xnpr05h"
|
|
151
|
-
}), /* @__PURE__ */
|
|
518
|
+
}), /* @__PURE__ */ g("svg", {
|
|
152
519
|
x: e.x,
|
|
153
520
|
y: e.y,
|
|
154
521
|
width: e.width,
|
|
155
522
|
height: e.height,
|
|
156
523
|
overflow: "hidden",
|
|
157
|
-
children: /* @__PURE__ */
|
|
524
|
+
children: /* @__PURE__ */ g("text", {
|
|
158
525
|
x: 12,
|
|
159
526
|
y: 20,
|
|
160
527
|
className: "x1q7gtio x1hz01jw xy8obcc",
|
|
161
528
|
children: e.label
|
|
162
529
|
})
|
|
163
530
|
})] }, e.id)),
|
|
164
|
-
|
|
531
|
+
D.map(({ edge: e, source: t, target: n }) => {
|
|
165
532
|
let r = t.x < n.x, i = t.x + (r ? t.width : 0), a = n.x + (r ? 0 : n.width), o = t.y + t.height / 2, s = n.y + n.height / 2, c = (i + a) / 2, l = t.x + t.width / 2, u = t.id === n.id ? `M${l - 12},${t.y} C${l - 48},${t.y - 36} ${l + 48},${t.y - 36} ${l + 12},${t.y}` : `M${i},${o} C${c},${o} ${c},${s} ${a},${s}`;
|
|
166
|
-
return /* @__PURE__ */
|
|
533
|
+
return /* @__PURE__ */ g("path", {
|
|
167
534
|
d: u,
|
|
168
|
-
markerEnd: e.direction === "directed" ? `url(#${
|
|
535
|
+
markerEnd: e.direction === "directed" ? `url(#${w})` : void 0,
|
|
169
536
|
className: "xbh8q5q x1crw9hw xhr4kjn",
|
|
170
|
-
children: /* @__PURE__ */
|
|
537
|
+
children: /* @__PURE__ */ g("title", { children: e.label })
|
|
171
538
|
}, e.id);
|
|
172
539
|
})
|
|
173
540
|
]
|
|
174
|
-
}),
|
|
175
|
-
let n =
|
|
176
|
-
...
|
|
541
|
+
}), u.map((t) => {
|
|
542
|
+
let n = C.label !== void 0 && C.activeId === t.id, r = [
|
|
543
|
+
...v.filter((e) => e.nodeIds.includes(t.id)).map((e) => e.label),
|
|
177
544
|
t.label,
|
|
178
545
|
t.description
|
|
179
|
-
].filter((e) => e !== void 0).join(", "), i =
|
|
546
|
+
].filter((e) => e !== void 0).join(", "), i = f.props(X.node, X.position(t.x, t.y), X.size(t.width, t.height), X.tone(e[t.tone]), x !== void 0 && X.action, (x?.selectedId === t.id || n) && X.selected), a = /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g("span", {
|
|
180
547
|
className: "xtqrqnz x1778rvt xk4h15q xb3r6kr xlyipyv xuxw1ft",
|
|
181
548
|
children: t.label
|
|
182
|
-
}), t.description !== void 0 && t.height >= 56 && /* @__PURE__ */
|
|
549
|
+
}), t.description !== void 0 && t.height >= 56 && /* @__PURE__ */ g("span", {
|
|
183
550
|
className: "xy8obcc xas2l8k x153jb6y xb3r6kr xlyipyv xuxw1ft",
|
|
184
551
|
children: t.description
|
|
185
552
|
})] });
|
|
186
|
-
return
|
|
187
|
-
onPointerEnter: () =>
|
|
553
|
+
return x === void 0 ? /* @__PURE__ */ g("div", {
|
|
554
|
+
onPointerEnter: () => C.inspect(t.id),
|
|
188
555
|
role: "group",
|
|
189
556
|
"aria-label": r,
|
|
190
557
|
title: r,
|
|
191
558
|
...i,
|
|
192
559
|
children: a
|
|
193
|
-
}, t.id) : /* @__PURE__ */
|
|
560
|
+
}, t.id) : /* @__PURE__ */ g(p, {
|
|
194
561
|
type: "button",
|
|
195
562
|
tabIndex: -1,
|
|
196
|
-
onPointerEnter: () =>
|
|
563
|
+
onPointerEnter: () => C.inspect(t.id),
|
|
197
564
|
"aria-label": r,
|
|
198
565
|
title: r,
|
|
199
|
-
"aria-pressed":
|
|
200
|
-
onClick: () =>
|
|
566
|
+
"aria-pressed": x.selectedId === t.id,
|
|
567
|
+
onClick: () => x.onSelect(t.id),
|
|
201
568
|
...i,
|
|
202
569
|
children: a
|
|
203
570
|
}, t.id);
|
|
204
571
|
})]
|
|
205
572
|
})
|
|
206
|
-
}) : /* @__PURE__ */
|
|
573
|
+
}) : /* @__PURE__ */ g("p", {
|
|
207
574
|
className: "x1ghz6dp x153jb6y",
|
|
208
|
-
children:
|
|
209
|
-
}), /* @__PURE__ */
|
|
575
|
+
children: S
|
|
576
|
+
}), /* @__PURE__ */ g(t, {
|
|
210
577
|
label: `${o} graph data`,
|
|
211
578
|
columns: [{
|
|
212
579
|
id: "kind",
|
|
@@ -216,15 +583,15 @@ function b({ title: o, report: m, description: g, nodes: _, edges: v, groups: y
|
|
|
216
583
|
label: "Description"
|
|
217
584
|
}],
|
|
218
585
|
rows: [
|
|
219
|
-
...
|
|
586
|
+
...u.map((e) => ({
|
|
220
587
|
id: `node:${e.id}`,
|
|
221
588
|
values: ["Node", [e.label, e.description].filter((e) => e !== void 0).join(", ")]
|
|
222
589
|
})),
|
|
223
|
-
...
|
|
590
|
+
...v.map((e) => ({
|
|
224
591
|
id: `group:${e.id}`,
|
|
225
|
-
values: ["Group", `${e.label}: ${e.nodeIds.map((e) =>
|
|
592
|
+
values: ["Group", `${e.label}: ${e.nodeIds.map((e) => E.get(e)?.label).join(", ")}`]
|
|
226
593
|
})),
|
|
227
|
-
...
|
|
594
|
+
...D.map(({ edge: e, source: t, target: n }) => ({
|
|
228
595
|
id: `edge:${e.id}`,
|
|
229
596
|
values: ["Relationship", `${t.label + (e.direction === "directed" ? " → " : " ↔ ") + n.label}: ${e.label}`]
|
|
230
597
|
}))
|
|
@@ -232,9 +599,9 @@ function b({ title: o, report: m, description: g, nodes: _, edges: v, groups: y
|
|
|
232
599
|
})]
|
|
233
600
|
});
|
|
234
601
|
}
|
|
235
|
-
function
|
|
236
|
-
if (!Number.isFinite(r) || r <= 0 || r > 8192 || !Number.isFinite(i) || i <= 0 || i > 8192) return `Graph dimensions must be finite, positive, and at most ${
|
|
237
|
-
if (e.length > 256 || t.length > 1024 || n.length > 256) return `This graph exceeds the render limit of 256 nodes, ${
|
|
602
|
+
function ie({ nodes: e, edges: t, groups: n, width: r, height: i }) {
|
|
603
|
+
if (!Number.isFinite(r) || r <= 0 || r > 8192 || !Number.isFinite(i) || i <= 0 || i > 8192) return `Graph dimensions must be finite, positive, and at most ${$} pixels.`;
|
|
604
|
+
if (e.length > 256 || t.length > 1024 || n.length > 256) return `This graph exceeds the render limit of 256 nodes, ${Q} relationships, or 256 groups. Supply a smaller, labelled neighborhood.`;
|
|
238
605
|
let a = new Set(e.map((e) => e.id));
|
|
239
606
|
return !o(e) || !o(t) || !o(n) ? "Graph nodes, relationships, and groups must have unique identifiers." : [...e, ...n].some((e) => {
|
|
240
607
|
if (!Number.isFinite(e.width) || !Number.isFinite(e.height) || e.width <= 0 || e.height <= 0) return !0;
|
|
@@ -247,7 +614,7 @@ function x({ nodes: e, edges: t, groups: n, width: r, height: i }) {
|
|
|
247
614
|
return i || a;
|
|
248
615
|
})) ? "A group box must contain the node boxes assigned to it." : null;
|
|
249
616
|
}
|
|
250
|
-
function
|
|
617
|
+
function ae(e, t) {
|
|
251
618
|
let n = [];
|
|
252
619
|
for (let r of e) {
|
|
253
620
|
let e = t.get(r.sourceId), i = t.get(r.targetId);
|
|
@@ -260,4 +627,4 @@ function S(e, t) {
|
|
|
260
627
|
}
|
|
261
628
|
return n;
|
|
262
629
|
}
|
|
263
|
-
export {
|
|
630
|
+
export { J as FlowDiagram, N as MAX_FLOW_LINKS, M as MAX_FLOW_NODES, $ as MAX_RELATION_DIMENSION, Q as MAX_RELATION_EDGES, ne as MAX_RELATION_GROUPS, Z as MAX_RELATION_NODES, re as RelationGraph };
|
package/dist/charts/hierarchy.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { c as e } from "../src-
|
|
2
|
-
import { i as t, r as n, t as r } from "../categorical-values-
|
|
3
|
-
import { n as i } from "../chart-frame-
|
|
4
|
-
import { t as a } from "../chart-input-
|
|
5
|
-
import { n as o, t as s } from "../plot-width-
|
|
1
|
+
import { c as e } from "../src-CDp1JtwC.js";
|
|
2
|
+
import { i as t, r as n, t as r } from "../categorical-values-ByvFLaNE.js";
|
|
3
|
+
import { n as i } from "../chart-frame-Bcd9Tpt5.js";
|
|
4
|
+
import { t as a } from "../chart-input-B6_HXFDP.js";
|
|
5
|
+
import { n as o, t as s } from "../plot-width-8cXdAjoD.js";
|
|
6
6
|
import * as c from "@stylexjs/stylex";
|
|
7
7
|
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
8
8
|
import { Treemap as d, hierarchy as f } from "@visx/hierarchy";
|