@mechane-ai/ui 0.2.1 → 0.3.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 +38 -13
- package/dist/ai.js +315 -0
- package/dist/assets/stylex.css +1533 -360
- package/dist/cartesian-Bwt6ZnF5.js +847 -0
- package/dist/chart-input-Bti0gyzz.js +173 -0
- package/dist/charts/cartesian.js +1 -0
- package/dist/charts/distribution.js +1 -0
- package/dist/charts/graph.js +1 -0
- package/dist/charts/matrix.js +1 -0
- package/dist/charts.js +98 -93
- package/dist/code-BJp-g4Fw.js +172 -0
- package/dist/collections.js +666 -0
- package/dist/content/code.js +1 -0
- package/dist/content/diff.js +101 -0
- package/dist/content/link.js +1 -0
- package/dist/content/tree.js +77 -0
- package/dist/content-link-52aZVX3X.js +26 -0
- package/dist/content.js +367 -0
- package/dist/distribution-CViLvcPP.js +609 -0
- package/dist/graph-DAfo72ZD.js +230 -0
- package/dist/index.js +1 -1
- package/dist/layout.js +201 -160
- package/dist/matrix-B9dybkce.js +785 -0
- package/dist/packages/ai/src/approval.d.ts +29 -0
- package/dist/packages/ai/src/conversation.d.ts +34 -0
- package/dist/packages/ai/src/index.d.ts +10 -0
- package/dist/packages/ai/src/message.d.ts +19 -0
- package/dist/packages/ai/src/prompt-input.d.ts +25 -0
- package/dist/packages/ai/src/sources.d.ts +17 -0
- package/dist/packages/charts/src/cartesian/categorical.d.ts +43 -0
- package/dist/packages/charts/src/cartesian/index.d.ts +8 -0
- package/dist/packages/charts/src/cartesian/sparkline.d.ts +11 -0
- package/dist/packages/charts/src/cartesian/time-series-data.d.ts +54 -0
- package/dist/packages/charts/src/cartesian/time-series-line.d.ts +9 -0
- package/dist/packages/charts/src/cartesian/time-series.d.ts +29 -0
- package/dist/packages/charts/src/chart-frame.d.ts +34 -0
- package/dist/packages/charts/src/chart-input.d.ts +10 -0
- package/dist/packages/charts/src/chart-theme.d.ts +48 -0
- package/dist/packages/charts/src/distribution/distribution-input.d.ts +14 -0
- package/dist/packages/charts/src/distribution/distribution-plot.d.ts +135 -0
- package/dist/packages/charts/src/distribution/ecdf.d.ts +23 -0
- package/dist/packages/charts/src/distribution/histogram.d.ts +26 -0
- package/dist/packages/charts/src/distribution/index.d.ts +8 -0
- package/dist/packages/charts/src/distribution/interval-plot.d.ts +24 -0
- package/dist/packages/charts/src/distribution/ranked-bars.d.ts +22 -0
- package/dist/packages/charts/src/graph/index.d.ts +2 -0
- package/dist/packages/charts/src/graph/relation-graph.d.ts +45 -0
- package/dist/packages/charts/src/index.d.ts +13 -0
- package/dist/packages/charts/src/matrix/color-legend.d.ts +7 -0
- package/dist/packages/charts/src/matrix/heatmap-scale.d.ts +8 -0
- package/dist/packages/charts/src/matrix/index.d.ts +9 -0
- package/dist/packages/charts/src/matrix/matrix.d.ts +34 -0
- package/dist/packages/charts/src/matrix/scatter-plot.d.ts +37 -0
- package/dist/packages/charts/src/matrix/token-heatmap.d.ts +20 -0
- package/dist/packages/charts/src/plot-width.d.ts +5 -0
- package/dist/packages/collections/src/calendar.d.ts +32 -0
- package/dist/packages/collections/src/collection-controls.d.ts +41 -0
- package/dist/packages/collections/src/command.d.ts +37 -0
- package/dist/packages/collections/src/data-table.d.ts +49 -0
- package/dist/packages/collections/src/date-range-picker.d.ts +16 -0
- package/dist/packages/collections/src/index.d.ts +13 -0
- package/dist/packages/content/src/code/code-block.d.ts +22 -0
- package/dist/packages/content/src/code/index.d.ts +2 -0
- package/dist/packages/content/src/code/use-highlighted-code.d.ts +9 -0
- package/dist/packages/content/src/content-link.d.ts +8 -0
- package/dist/packages/content/src/diff/diff-source.d.ts +32 -0
- package/dist/packages/content/src/diff/diff-viewer.d.ts +3 -0
- package/dist/packages/content/src/diff/index.d.ts +2 -0
- package/dist/packages/content/src/diff/pierre-diff.d.ts +14 -0
- package/dist/packages/content/src/index.d.ts +10 -0
- package/dist/packages/content/src/json-viewer.d.ts +11 -0
- package/dist/packages/content/src/link.d.ts +2 -0
- package/dist/packages/content/src/log-viewer.d.ts +9 -0
- package/dist/packages/content/src/markdown.d.ts +7 -0
- package/dist/packages/content/src/pierre-theme.d.ts +36 -0
- package/dist/packages/content/src/stack-trace.d.ts +16 -0
- package/dist/packages/content/src/tree/file-tree-types.d.ts +12 -0
- package/dist/packages/content/src/tree/file-tree.d.ts +3 -0
- package/dist/packages/content/src/tree/index.d.ts +2 -0
- package/dist/packages/content/src/tree/pierre-tree.d.ts +3 -0
- package/dist/packages/core/src/alert-dialog.d.ts +18 -0
- package/dist/packages/core/src/combobox.d.ts +81 -0
- package/dist/{control-state.d.ts → packages/core/src/control-state.d.ts} +18 -2
- package/dist/{copy-value.d.ts → packages/core/src/copy-value.d.ts} +2 -1
- package/dist/packages/core/src/details-controls.d.ts +23 -0
- package/dist/packages/core/src/disclosure.d.ts +33 -0
- package/dist/packages/core/src/field-styles.d.ts +66 -0
- package/dist/packages/core/src/form-controls.d.ts +81 -0
- package/dist/{forms.d.ts → packages/core/src/forms.d.ts} +1 -1
- package/dist/packages/core/src/index.d.ts +32 -0
- package/dist/packages/core/src/menu.d.ts +51 -0
- package/dist/packages/core/src/navigation.d.ts +24 -0
- package/dist/packages/core/src/popover.d.ts +24 -0
- package/dist/packages/core/src/popup-styles.d.ts +84 -0
- package/dist/packages/core/src/preview.d.ts +17 -0
- package/dist/packages/core/src/progress.d.ts +10 -0
- package/dist/packages/core/src/selection-styles.d.ts +110 -0
- package/dist/packages/core/src/selection.d.ts +57 -0
- package/dist/packages/core/src/skeleton.d.ts +18 -0
- package/dist/packages/core/src/theme.d.ts +16 -0
- package/dist/packages/core/src/toast.d.ts +28 -0
- package/dist/{tokens.stylex.d.ts → packages/core/src/tokens.stylex.d.ts} +60 -0
- package/dist/packages/core/src/trace.d.ts +35 -0
- package/dist/{layout → packages/layout/src}/index.d.ts +2 -0
- package/dist/{layout → packages/layout/src}/page-toolbar.d.ts +1 -1
- package/dist/packages/layout/src/resizable.d.ts +27 -0
- package/dist/{layout → packages/layout/src}/sidebar.d.ts +1 -1
- package/dist/pierre-diff-D3m4JCu0.js +66 -0
- package/dist/pierre-theme-CPlfl-AA.js +96 -0
- package/dist/pierre-tree-BaEkz16y.js +105 -0
- package/dist/plot-width--OgdohB5.js +18 -0
- package/dist/src-E7YRJBMO.js +2821 -0
- package/dist/tokens.js +118 -64
- package/package.json +67 -10
- package/{src → packages/core/src}/tokens.stylex.ts +64 -0
- package/dist/charts/index.d.ts +0 -2
- package/dist/index.d.ts +0 -16
- package/dist/src-Czfi0YQa.js +0 -1319
- /package/dist/{charts → packages/charts/src}/waterfall.d.ts +0 -0
- /package/dist/{inspector.d.ts → packages/collections/src/inspector.d.ts} +0 -0
- /package/dist/{list-footer.d.ts → packages/collections/src/list-footer.d.ts} +0 -0
- /package/dist/{table.d.ts → packages/collections/src/table.d.ts} +0 -0
- /package/dist/{accessibility.d.ts → packages/core/src/accessibility.d.ts} +0 -0
- /package/dist/{actions.d.ts → packages/core/src/actions.d.ts} +0 -0
- /package/dist/{dialog.d.ts → packages/core/src/dialog.d.ts} +0 -0
- /package/dist/{drawer.d.ts → packages/core/src/drawer.d.ts} +0 -0
- /package/dist/{loading.d.ts → packages/core/src/loading.d.ts} +0 -0
- /package/dist/{metrics.d.ts → packages/core/src/metrics.d.ts} +0 -0
- /package/dist/{overlay-styles.d.ts → packages/core/src/overlay-styles.d.ts} +0 -0
- /package/dist/{select.d.ts → packages/core/src/select.d.ts} +0 -0
- /package/dist/{skip-link.d.ts → packages/core/src/skip-link.d.ts} +0 -0
- /package/dist/{style-composition.d.ts → packages/core/src/style-composition.d.ts} +0 -0
- /package/dist/{surfaces.d.ts → packages/core/src/surfaces.d.ts} +0 -0
- /package/dist/{tabs.d.ts → packages/core/src/tabs.d.ts} +0 -0
- /package/dist/{text.d.ts → packages/core/src/text.d.ts} +0 -0
- /package/dist/{tooltip.d.ts → packages/core/src/tooltip.d.ts} +0 -0
- /package/dist/{layout → packages/layout/src}/app-shell.d.ts +0 -0
- /package/dist/{layout → packages/layout/src}/detail-page.d.ts +0 -0
- /package/dist/{layout → packages/layout/src}/frame.stylex.d.ts +0 -0
|
@@ -0,0 +1,847 @@
|
|
|
1
|
+
import { colors as e } from "./tokens.js";
|
|
2
|
+
import { a as t, c as n, i as r, l as i, n as a, o, r as s, s as c, t as l } from "./chart-input-Bti0gyzz.js";
|
|
3
|
+
import { t as u } from "./plot-width--OgdohB5.js";
|
|
4
|
+
import * as d from "@stylexjs/stylex";
|
|
5
|
+
import { useEffect as f, useId as p, useMemo as m, useRef as h, useState as g } from "react";
|
|
6
|
+
import { Fragment as _, jsx as v, jsxs as y } from "react/jsx-runtime";
|
|
7
|
+
import { scaleBand as b, scaleLinear as x } from "@visx/scale";
|
|
8
|
+
import { AreaClosed as S, Bar as C, LinePath as w } from "@visx/shape";
|
|
9
|
+
import { Treemap as T, hierarchy as E } from "@visx/hierarchy";
|
|
10
|
+
// packages/charts/src/cartesian/time-series-data.ts
|
|
11
|
+
var D = {
|
|
12
|
+
series: 12,
|
|
13
|
+
pointsPerSeries: 2e3,
|
|
14
|
+
markers: 200,
|
|
15
|
+
panels: 12
|
|
16
|
+
}, O = .01, k = [
|
|
17
|
+
"series1",
|
|
18
|
+
"series2",
|
|
19
|
+
"series3",
|
|
20
|
+
"series4",
|
|
21
|
+
"series5",
|
|
22
|
+
"series6"
|
|
23
|
+
];
|
|
24
|
+
function A({ series: e, isStacked: t, markers: n }) {
|
|
25
|
+
let r = e[0]?.points.map((e) => e.timestamp) ?? [];
|
|
26
|
+
if (e.length > D.series || r.length > D.pointsPerSeries || n.length > D.markers) return `Choose a window with at most ${D.series} series, ${D.pointsPerSeries} observations per series, and ${D.markers} markers.`;
|
|
27
|
+
if (!a(e) || !a(n)) return "Series and markers require unique identifiers.";
|
|
28
|
+
for (let n of e) {
|
|
29
|
+
if (n.points.length !== r.length) return "Every series must supply the same observation timestamps.";
|
|
30
|
+
let e = N({
|
|
31
|
+
points: n.points,
|
|
32
|
+
timestamps: r,
|
|
33
|
+
isStacked: t
|
|
34
|
+
});
|
|
35
|
+
if (e !== void 0) return e;
|
|
36
|
+
}
|
|
37
|
+
for (let t of n) {
|
|
38
|
+
if (!r.includes(t.timestamp)) return "Every marker must align with an observation timestamp.";
|
|
39
|
+
if (t.kind === "point") {
|
|
40
|
+
let n = e.find((e) => e.id === t.seriesId)?.points.find((e) => e.timestamp === t.timestamp);
|
|
41
|
+
if (n === void 0 || n.value !== t.value) return "Point markers must reference the recorded series value.";
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
let i = e.flatMap((e) => e.points.flatMap((e) => e.value === null ? [] : [e.value])), o = Math.max(0, ...i) - Math.min(0, ...i), s = (r.at(-1) ?? 0) - (r[0] ?? 0);
|
|
45
|
+
if (!Number.isFinite(o) || !Number.isFinite(s)) return "The elapsed-time and value ranges must be finite.";
|
|
46
|
+
if (t && r.some((t, n) => !Number.isFinite(e.reduce((e, t) => e + (t.points[n]?.value ?? 0), 0)))) return "Stacked observation totals must be finite.";
|
|
47
|
+
}
|
|
48
|
+
function j({ series: e, markers: t, timestampUnit: n, isStacked: r }) {
|
|
49
|
+
return JSON.stringify([
|
|
50
|
+
n,
|
|
51
|
+
r,
|
|
52
|
+
e.map((e) => [
|
|
53
|
+
e.id,
|
|
54
|
+
e.label,
|
|
55
|
+
e.tone,
|
|
56
|
+
e.points.map((e) => [e.timestamp, e.value])
|
|
57
|
+
]),
|
|
58
|
+
t.map((e) => [
|
|
59
|
+
e.id,
|
|
60
|
+
e.kind,
|
|
61
|
+
e.timestamp,
|
|
62
|
+
e.label,
|
|
63
|
+
e.seriesId,
|
|
64
|
+
e.value
|
|
65
|
+
])
|
|
66
|
+
]);
|
|
67
|
+
}
|
|
68
|
+
function M(e, t, n = !1) {
|
|
69
|
+
if (e !== t) return [e, t];
|
|
70
|
+
let r = Math.max(1, Math.abs(e) * O), i = n ? 0 : e - r, a = t + r;
|
|
71
|
+
return [Number.isFinite(i) ? i : e, Number.isFinite(a) ? a : t];
|
|
72
|
+
}
|
|
73
|
+
function ee(e, t) {
|
|
74
|
+
let n = e.filter((e) => e.tone === void 0);
|
|
75
|
+
return e.map((r, i) => {
|
|
76
|
+
let a = n.findIndex((e) => e.id === r.id), o = r.tone ?? k[a % k.length] ?? "series1", s = r.points.map((n, r) => {
|
|
77
|
+
let a = t ? e.slice(0, i).reduce((e, t) => e + (t.points[r]?.value ?? 0), 0) : 0;
|
|
78
|
+
return {
|
|
79
|
+
...n,
|
|
80
|
+
base: a
|
|
81
|
+
};
|
|
82
|
+
});
|
|
83
|
+
return {
|
|
84
|
+
id: r.id,
|
|
85
|
+
label: r.label,
|
|
86
|
+
tone: o,
|
|
87
|
+
points: s
|
|
88
|
+
};
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
function N({ points: e, timestamps: t, isStacked: n }) {
|
|
92
|
+
for (let [r, i] of e.entries()) {
|
|
93
|
+
let a = e[r - 1], o = a !== void 0 && i.timestamp <= a.timestamp;
|
|
94
|
+
if (!Number.isFinite(i.timestamp) || i.timestamp !== t[r] || o) return "Observation timestamps must be finite, aligned, and strictly increasing.";
|
|
95
|
+
if (i.value !== null && !Number.isFinite(i.value)) return "Observations must be finite numbers or explicit missing values.";
|
|
96
|
+
if (n && (i.value === null || i.value < 0)) return "Stacked observations must be present and nonnegative.";
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
// packages/charts/src/cartesian/time-series-line.tsx
|
|
100
|
+
function te({ series: e, x: t, y: r, inspectedTimestamp: a, pointRadius: o = 3 }) {
|
|
101
|
+
return /* @__PURE__ */ y(_, { children: [/* @__PURE__ */ v(w, {
|
|
102
|
+
data: [...e.points],
|
|
103
|
+
defined: (e) => e.value !== null,
|
|
104
|
+
x: (e) => t(e.timestamp),
|
|
105
|
+
y: (e) => r((e.value ?? 0) + e.base),
|
|
106
|
+
stroke: i[e.tone],
|
|
107
|
+
...d.props(n.mark)
|
|
108
|
+
}), e.points.filter((t, n) => {
|
|
109
|
+
if (t.value === null) return !1;
|
|
110
|
+
let r = e.points[n - 1]?.value === null || e.points[n + 1]?.value === null;
|
|
111
|
+
return e.points.length === 1 || r || t.timestamp === a;
|
|
112
|
+
}).map((n) => /* @__PURE__ */ v("circle", {
|
|
113
|
+
cx: t(n.timestamp),
|
|
114
|
+
cy: r((n.value ?? 0) + n.base),
|
|
115
|
+
r: o,
|
|
116
|
+
fill: i[e.tone]
|
|
117
|
+
}, n.timestamp))] });
|
|
118
|
+
}
|
|
119
|
+
// packages/charts/src/cartesian/time-series.tsx
|
|
120
|
+
var ne = { plot: {
|
|
121
|
+
k7Eaqz: "xeuugli",
|
|
122
|
+
kInvED: "x1hl8ikr",
|
|
123
|
+
kZs9gx: "x1m2ab5f",
|
|
124
|
+
k7shQP: "x9v5kkp",
|
|
125
|
+
kPJHz1: "xnktsf1",
|
|
126
|
+
$$css: !0
|
|
127
|
+
} };
|
|
128
|
+
function re(e) {
|
|
129
|
+
return /* @__PURE__ */ v(I, {
|
|
130
|
+
...e,
|
|
131
|
+
kind: "line",
|
|
132
|
+
stacked: !1
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
function P({ stacked: e = !1, ...t }) {
|
|
136
|
+
return /* @__PURE__ */ v(I, {
|
|
137
|
+
...t,
|
|
138
|
+
kind: "area",
|
|
139
|
+
stacked: e
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
function F({ charts: e, ...t }) {
|
|
143
|
+
let n = h(null), [r, i] = g(), s = JSON.stringify(e.map((e) => [
|
|
144
|
+
e.id,
|
|
145
|
+
e.title,
|
|
146
|
+
j({
|
|
147
|
+
series: e.series,
|
|
148
|
+
markers: e.markers ?? [],
|
|
149
|
+
timestampUnit: t.timestampUnit,
|
|
150
|
+
isStacked: !1
|
|
151
|
+
})
|
|
152
|
+
])), c = JSON.stringify(e[0]?.series[0]?.points.map((e) => e.timestamp) ?? []), u = e.every((e) => JSON.stringify(e.series[0]?.points.map((e) => e.timestamp) ?? []) === c);
|
|
153
|
+
if (r !== void 0 && r.signature !== s && i(void 0), f(() => {
|
|
154
|
+
function e(e) {
|
|
155
|
+
e.target instanceof Node && n.current?.contains(e.target) !== !0 && i(void 0);
|
|
156
|
+
}
|
|
157
|
+
return document.addEventListener("pointerdown", e), () => document.removeEventListener("pointerdown", e);
|
|
158
|
+
}, []), !u || !a(e)) return /* @__PURE__ */ v(l, {
|
|
159
|
+
title: "Small multiples",
|
|
160
|
+
message: "Charts need unique identifiers and aligned observation timestamps."
|
|
161
|
+
});
|
|
162
|
+
if (e.length > D.panels) return /* @__PURE__ */ v(l, {
|
|
163
|
+
title: "Small multiples",
|
|
164
|
+
message: `Choose at most ${D.panels} panels.`
|
|
165
|
+
});
|
|
166
|
+
if (e.length === 0) return /* @__PURE__ */ v(o, {
|
|
167
|
+
title: "Small multiples",
|
|
168
|
+
children: /* @__PURE__ */ v("p", {
|
|
169
|
+
className: "xv9cywu",
|
|
170
|
+
children: "No charts"
|
|
171
|
+
})
|
|
172
|
+
});
|
|
173
|
+
let d = {
|
|
174
|
+
value: r?.signature === s ? r : void 0,
|
|
175
|
+
onChange: (e) => i(e === void 0 ? void 0 : {
|
|
176
|
+
...e,
|
|
177
|
+
signature: s
|
|
178
|
+
})
|
|
179
|
+
}, p = Math.max(52, ...e.flatMap((e) => e.series.flatMap((t) => t.points.flatMap((t) => t.value === null || !Number.isFinite(t.value) ? [] : [e.formatValue(t.value).length * 7 + 12]))));
|
|
180
|
+
return /* @__PURE__ */ v("div", {
|
|
181
|
+
ref: n,
|
|
182
|
+
className: "xrvj5dj x179h1ev",
|
|
183
|
+
children: e.map((e) => /* @__PURE__ */ v(I, {
|
|
184
|
+
...t,
|
|
185
|
+
title: e.title,
|
|
186
|
+
description: e.description,
|
|
187
|
+
series: e.series,
|
|
188
|
+
formatValue: e.formatValue,
|
|
189
|
+
markers: e.markers,
|
|
190
|
+
kind: "line",
|
|
191
|
+
stacked: !1,
|
|
192
|
+
sharedInspection: d,
|
|
193
|
+
axisWidth: p
|
|
194
|
+
}, e.id))
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
function I({ title: t, description: a, series: s, timestampUnit: b, formatTimestamp: C, formatValue: w, markers: T = [], height: E = 180, actions: D, kind: O, stacked: k, sharedInspection: N, axisWidth: re }) {
|
|
198
|
+
let P = !Number.isFinite(E) || E < 48 ? "Chart height must be at least 48 pixels." : A({
|
|
199
|
+
series: s,
|
|
200
|
+
isStacked: k,
|
|
201
|
+
markers: T
|
|
202
|
+
}), F = m(() => P === void 0 ? ee(s, k) : [], [
|
|
203
|
+
s,
|
|
204
|
+
k,
|
|
205
|
+
P
|
|
206
|
+
]), I = F[0]?.points ?? [], { ref: ie, width: L, element: R } = u(), z = h(null), [B, V] = g(), H = j({
|
|
207
|
+
series: s,
|
|
208
|
+
markers: T,
|
|
209
|
+
timestampUnit: b,
|
|
210
|
+
isStacked: k
|
|
211
|
+
}), U = N === void 0 ? B?.signature === H ? B : void 0 : N.value, W = p();
|
|
212
|
+
B !== void 0 && (B.signature !== H || P !== void 0) && V(void 0);
|
|
213
|
+
let G = N !== void 0;
|
|
214
|
+
if (f(() => {
|
|
215
|
+
if (G) return;
|
|
216
|
+
function e(e) {
|
|
217
|
+
e.target instanceof Node && z.current?.contains(e.target) !== !0 && V(void 0);
|
|
218
|
+
}
|
|
219
|
+
return document.addEventListener("pointerdown", e), () => document.removeEventListener("pointerdown", e);
|
|
220
|
+
}, [G]), P !== void 0) return /* @__PURE__ */ v(l, {
|
|
221
|
+
title: t,
|
|
222
|
+
description: a,
|
|
223
|
+
message: P
|
|
224
|
+
});
|
|
225
|
+
if (I.length === 0) return /* @__PURE__ */ v(o, {
|
|
226
|
+
title: t,
|
|
227
|
+
description: a,
|
|
228
|
+
actions: D,
|
|
229
|
+
children: /* @__PURE__ */ v("p", {
|
|
230
|
+
className: "xv9cywu",
|
|
231
|
+
children: "No observations"
|
|
232
|
+
})
|
|
233
|
+
});
|
|
234
|
+
let K = E - 28, q = I[0]?.timestamp ?? 0, J = I.at(-1)?.timestamp ?? q, Y = F.flatMap((e) => e.points.flatMap((e) => e.value === null ? [] : [e.value + e.base])), ae = O === "area" ? Math.min(0, ...Y) : Math.min(...Y), oe = O === "area" ? Math.max(0, ...Y) : Math.max(...Y), se = Y.length === 0 ? 0 : ae, ce = Y.length === 0 ? 1 : oe, X = x({
|
|
235
|
+
domain: [...M(se, ce, O === "area")],
|
|
236
|
+
range: [K, 12]
|
|
237
|
+
}), le = X.ticks(3), Z = re ?? Math.max(52, ...le.map((e) => w(e).length * 7 + 12)), Q = Math.max(Z + 1, L - 16), $ = x({
|
|
238
|
+
domain: [...M(q, J)],
|
|
239
|
+
range: [Z, Q]
|
|
240
|
+
});
|
|
241
|
+
function ue(e) {
|
|
242
|
+
let t = R?.getBoundingClientRect();
|
|
243
|
+
if (t === void 0) return;
|
|
244
|
+
let n = $.invert(e - t.left), r = I.find((e, t) => {
|
|
245
|
+
let r = I[t + 1];
|
|
246
|
+
return r === void 0 || n <= e.timestamp + (r.timestamp - e.timestamp) / 2;
|
|
247
|
+
});
|
|
248
|
+
r !== void 0 && de({
|
|
249
|
+
signature: H,
|
|
250
|
+
timestamp: r.timestamp,
|
|
251
|
+
source: "pointer"
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
function de(e) {
|
|
255
|
+
N === void 0 ? V(e) : N.onChange(e);
|
|
256
|
+
}
|
|
257
|
+
function fe(e) {
|
|
258
|
+
let t = I.findIndex((e) => e.timestamp === U?.timestamp), n = {
|
|
259
|
+
ArrowRight: Math.min(I.length - 1, t + 1),
|
|
260
|
+
ArrowLeft: Math.max(0, t - 1),
|
|
261
|
+
Home: 0,
|
|
262
|
+
End: I.length - 1
|
|
263
|
+
};
|
|
264
|
+
switch (e.key) {
|
|
265
|
+
case "Escape":
|
|
266
|
+
e.preventDefault(), de(void 0);
|
|
267
|
+
break;
|
|
268
|
+
case "ArrowRight":
|
|
269
|
+
case "ArrowLeft":
|
|
270
|
+
case "Home":
|
|
271
|
+
case "End": {
|
|
272
|
+
e.preventDefault();
|
|
273
|
+
let t = I[n[e.key]];
|
|
274
|
+
t !== void 0 && de({
|
|
275
|
+
signature: H,
|
|
276
|
+
timestamp: t.timestamp,
|
|
277
|
+
source: "keyboard"
|
|
278
|
+
});
|
|
279
|
+
break;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
return /* @__PURE__ */ v("div", {
|
|
284
|
+
ref: z,
|
|
285
|
+
className: "xeuugli",
|
|
286
|
+
children: /* @__PURE__ */ y(o, {
|
|
287
|
+
title: t,
|
|
288
|
+
description: a,
|
|
289
|
+
actions: D,
|
|
290
|
+
children: [/* @__PURE__ */ y("div", {
|
|
291
|
+
className: "xrvj5dj xtmze7h",
|
|
292
|
+
children: [
|
|
293
|
+
/* @__PURE__ */ v(c, { items: F.map(({ id: e, label: t, tone: n }) => ({
|
|
294
|
+
id: e,
|
|
295
|
+
label: t,
|
|
296
|
+
tone: n
|
|
297
|
+
})) }),
|
|
298
|
+
/* @__PURE__ */ v("div", {
|
|
299
|
+
ref: ie,
|
|
300
|
+
...d.props(n.plot),
|
|
301
|
+
children: /* @__PURE__ */ y("svg", {
|
|
302
|
+
role: "img",
|
|
303
|
+
"aria-label": `${t}. Use arrow keys to inspect observations.`,
|
|
304
|
+
"aria-describedby": W,
|
|
305
|
+
tabIndex: 0,
|
|
306
|
+
viewBox: `0 0 ${L} ${E}`,
|
|
307
|
+
height: E,
|
|
308
|
+
onKeyDown: fe,
|
|
309
|
+
onPointerMove: (e) => {
|
|
310
|
+
e.pointerType === "mouse" && ue(e.clientX);
|
|
311
|
+
},
|
|
312
|
+
onPointerDown: (e) => ue(e.clientX),
|
|
313
|
+
...d.props(n.svg, ne.plot),
|
|
314
|
+
children: [
|
|
315
|
+
le.map((e) => /* @__PURE__ */ y("g", { children: [/* @__PURE__ */ v("line", {
|
|
316
|
+
x1: Z,
|
|
317
|
+
x2: Q,
|
|
318
|
+
y1: X(e),
|
|
319
|
+
y2: X(e),
|
|
320
|
+
...d.props(n.grid)
|
|
321
|
+
}), /* @__PURE__ */ v("text", {
|
|
322
|
+
x: Z - 8,
|
|
323
|
+
y: X(e),
|
|
324
|
+
textAnchor: "end",
|
|
325
|
+
dominantBaseline: "middle",
|
|
326
|
+
...d.props(n.label),
|
|
327
|
+
children: w(e)
|
|
328
|
+
})] }, e)),
|
|
329
|
+
F.map((e) => /* @__PURE__ */ y("g", { children: [O === "area" && /* @__PURE__ */ v(S, {
|
|
330
|
+
data: [...e.points],
|
|
331
|
+
defined: (e) => e.value !== null,
|
|
332
|
+
x: (e) => $(e.timestamp),
|
|
333
|
+
y0: (e) => X(e.base),
|
|
334
|
+
y1: (e) => X((e.value ?? 0) + e.base),
|
|
335
|
+
yScale: X,
|
|
336
|
+
fill: i[e.tone],
|
|
337
|
+
fillOpacity: k ? .65 : .15
|
|
338
|
+
}), /* @__PURE__ */ v(te, {
|
|
339
|
+
series: e,
|
|
340
|
+
x: $,
|
|
341
|
+
y: X,
|
|
342
|
+
inspectedTimestamp: U?.timestamp
|
|
343
|
+
})] }, e.id)),
|
|
344
|
+
T.map((t) => /* @__PURE__ */ y("g", { children: [t.kind === "time" ? /* @__PURE__ */ v("line", {
|
|
345
|
+
x1: $(t.timestamp),
|
|
346
|
+
x2: $(t.timestamp),
|
|
347
|
+
y1: 12,
|
|
348
|
+
y2: K,
|
|
349
|
+
className: "x1ce36ez x1ntoi03 x13efnbd"
|
|
350
|
+
}) : /* @__PURE__ */ v("circle", {
|
|
351
|
+
cx: $(t.timestamp),
|
|
352
|
+
cy: X(t.value + (F.find((e) => e.id === t.seriesId)?.points.find((e) => e.timestamp === t.timestamp)?.base ?? 0)),
|
|
353
|
+
r: 4,
|
|
354
|
+
fill: e.surface,
|
|
355
|
+
...d.props(n.selected)
|
|
356
|
+
}), /* @__PURE__ */ v("title", { children: t.kind === "point" ? `${t.label}: ${w(t.value)}` : t.label })] }, t.id)),
|
|
357
|
+
U !== void 0 && /* @__PURE__ */ v("line", {
|
|
358
|
+
x1: $(U.timestamp),
|
|
359
|
+
x2: $(U.timestamp),
|
|
360
|
+
y1: 12,
|
|
361
|
+
y2: K,
|
|
362
|
+
className: "x1ce36ez x1ntoi03 x13efnbd"
|
|
363
|
+
}),
|
|
364
|
+
/* @__PURE__ */ v("text", {
|
|
365
|
+
x: Z,
|
|
366
|
+
y: E - 4,
|
|
367
|
+
...d.props(n.label),
|
|
368
|
+
children: C(q)
|
|
369
|
+
}),
|
|
370
|
+
J !== q && /* @__PURE__ */ v("text", {
|
|
371
|
+
x: Q,
|
|
372
|
+
y: E - 4,
|
|
373
|
+
textAnchor: "end",
|
|
374
|
+
...d.props(n.label),
|
|
375
|
+
children: C(J)
|
|
376
|
+
})
|
|
377
|
+
]
|
|
378
|
+
})
|
|
379
|
+
}),
|
|
380
|
+
/* @__PURE__ */ v("div", {
|
|
381
|
+
id: W,
|
|
382
|
+
"aria-live": U?.source === "keyboard" ? "polite" : "off",
|
|
383
|
+
className: "xrvj5dj xzwl0l2 x15kvu8p xmkeg23 x1y0btm7 x1yww3zy x1m7rfvg xut3y95 x21xpn4",
|
|
384
|
+
children: U === void 0 ? /* @__PURE__ */ v("span", {
|
|
385
|
+
className: "xv9cywu",
|
|
386
|
+
children: "Point, tap, or use the arrow keys to inspect values."
|
|
387
|
+
}) : /* @__PURE__ */ y(_, { children: [
|
|
388
|
+
/* @__PURE__ */ v("span", { children: C(U.timestamp) }),
|
|
389
|
+
/* @__PURE__ */ v("dl", {
|
|
390
|
+
className: "x78zum5 x1a02dak xtmze7h x1ghz6dp",
|
|
391
|
+
children: F.map((e) => {
|
|
392
|
+
let t = e.points.find((e) => e.timestamp === U.timestamp);
|
|
393
|
+
return /* @__PURE__ */ y("div", {
|
|
394
|
+
className: "x78zum5 xzwl0l2 x1ghz6dp xss6m8b",
|
|
395
|
+
children: [/* @__PURE__ */ v("dt", { children: e.label }), /* @__PURE__ */ v("dd", {
|
|
396
|
+
className: "x1ghz6dp xgl13c",
|
|
397
|
+
children: t?.value === null || t === void 0 ? "Unavailable" : w(t.value)
|
|
398
|
+
})]
|
|
399
|
+
}, e.id);
|
|
400
|
+
})
|
|
401
|
+
}),
|
|
402
|
+
T.filter((e) => e.timestamp === U.timestamp).map((e) => /* @__PURE__ */ v("span", { children: e.label }, e.id))
|
|
403
|
+
] })
|
|
404
|
+
}),
|
|
405
|
+
T.length > 0 && /* @__PURE__ */ v("ul", {
|
|
406
|
+
className: "x78zum5 x1a02dak xtmze7h x1ghz6dp x1717udv xe8uvvx xut3y95 xv9cywu",
|
|
407
|
+
children: T.map((e) => /* @__PURE__ */ y("li", { children: [
|
|
408
|
+
C(e.timestamp),
|
|
409
|
+
" · ",
|
|
410
|
+
e.label,
|
|
411
|
+
e.kind === "point" && ` · ${w(e.value)}`
|
|
412
|
+
] }, e.id))
|
|
413
|
+
})
|
|
414
|
+
]
|
|
415
|
+
}), /* @__PURE__ */ v(r, { children: /* @__PURE__ */ y("table", {
|
|
416
|
+
className: "xh8yej3 x1mwwwfo xut3y95 x1yc453h xss6m8b",
|
|
417
|
+
children: [
|
|
418
|
+
/* @__PURE__ */ y("caption", { children: [t, " observations"] }),
|
|
419
|
+
/* @__PURE__ */ v("thead", { children: /* @__PURE__ */ y("tr", { children: [/* @__PURE__ */ y("th", {
|
|
420
|
+
className: "x15kvu8p x1yc453h xso031l x1q0q8m5 x7a6td9 xo1l8bm",
|
|
421
|
+
children: [
|
|
422
|
+
"Time (",
|
|
423
|
+
b,
|
|
424
|
+
")"
|
|
425
|
+
]
|
|
426
|
+
}), F.map((e) => /* @__PURE__ */ v("th", {
|
|
427
|
+
scope: "col",
|
|
428
|
+
className: "x15kvu8p x1yc453h xso031l x1q0q8m5 x7a6td9 xo1l8bm",
|
|
429
|
+
children: e.label
|
|
430
|
+
}, e.id))] }) }),
|
|
431
|
+
/* @__PURE__ */ v("tbody", { children: I.map((e, t) => /* @__PURE__ */ y("tr", { children: [/* @__PURE__ */ v("th", {
|
|
432
|
+
scope: "row",
|
|
433
|
+
className: "x15kvu8p x1yc453h xso031l x1q0q8m5 x7a6td9 xo1l8bm",
|
|
434
|
+
children: C(e.timestamp)
|
|
435
|
+
}), F.map((e) => /* @__PURE__ */ v("td", {
|
|
436
|
+
className: "x15kvu8p x1yc453h xso031l x1q0q8m5 x7a6td9 xo1l8bm",
|
|
437
|
+
children: e.points[t]?.value === null || e.points[t]?.value === void 0 ? "Unavailable" : w(e.points[t].value)
|
|
438
|
+
}, e.id))] }, e.timestamp)) })
|
|
439
|
+
]
|
|
440
|
+
}) })]
|
|
441
|
+
})
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
// packages/charts/src/cartesian/sparkline.tsx
|
|
445
|
+
function ie({ title: e, summary: t, unit: n, timestampUnit: r, series: i, valueDomain: a }) {
|
|
446
|
+
let o = p(), s = p(), c = L({
|
|
447
|
+
title: e,
|
|
448
|
+
summary: t,
|
|
449
|
+
unit: n,
|
|
450
|
+
series: i,
|
|
451
|
+
valueDomain: a
|
|
452
|
+
}), l = i.points.some((e) => e.value !== null);
|
|
453
|
+
if (c !== void 0 || !l) return /* @__PURE__ */ v("span", {
|
|
454
|
+
role: "img",
|
|
455
|
+
"aria-label": `${e}. ${c ?? "No recorded values. Missing observations remain unavailable."}`,
|
|
456
|
+
title: c ?? "No recorded values",
|
|
457
|
+
className: "x2pejg6 x10w6t97 x2lah0s xxymvpz x3nfvp2 x6s0dn4 xl56j7k xv9cywu xoedhln xut3y95",
|
|
458
|
+
children: c === void 0 ? "No data" : "Invalid trend"
|
|
459
|
+
});
|
|
460
|
+
let u = i.points[0]?.timestamp ?? 0, d = i.points.at(-1)?.timestamp ?? u, f = x({
|
|
461
|
+
domain: [...M(u, d)],
|
|
462
|
+
range: [3, 125]
|
|
463
|
+
}), m = x({
|
|
464
|
+
domain: [...a],
|
|
465
|
+
range: [29, 3]
|
|
466
|
+
}), h = ee([i], !1)[0];
|
|
467
|
+
return /* @__PURE__ */ y("svg", {
|
|
468
|
+
role: "img",
|
|
469
|
+
"aria-labelledby": o,
|
|
470
|
+
"aria-describedby": s,
|
|
471
|
+
focusable: "false",
|
|
472
|
+
viewBox: "0 0 128 32",
|
|
473
|
+
width: 128,
|
|
474
|
+
height: 32,
|
|
475
|
+
className: "x1rg5ohu x2pejg6 x10w6t97 x2lah0s xxymvpz",
|
|
476
|
+
children: [
|
|
477
|
+
/* @__PURE__ */ v("title", {
|
|
478
|
+
id: o,
|
|
479
|
+
children: e
|
|
480
|
+
}),
|
|
481
|
+
/* @__PURE__ */ y("desc", {
|
|
482
|
+
id: s,
|
|
483
|
+
children: [
|
|
484
|
+
t,
|
|
485
|
+
" Values in ",
|
|
486
|
+
n,
|
|
487
|
+
"; timestamps in ",
|
|
488
|
+
r,
|
|
489
|
+
". Displayed value domain: ",
|
|
490
|
+
a[0],
|
|
491
|
+
" to",
|
|
492
|
+
" ",
|
|
493
|
+
a[1],
|
|
494
|
+
" ",
|
|
495
|
+
n,
|
|
496
|
+
"."
|
|
497
|
+
]
|
|
498
|
+
}),
|
|
499
|
+
h !== void 0 && /* @__PURE__ */ v(te, {
|
|
500
|
+
series: h,
|
|
501
|
+
x: f,
|
|
502
|
+
y: m,
|
|
503
|
+
pointRadius: 2
|
|
504
|
+
})
|
|
505
|
+
]
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
function L({ title: e, summary: t, unit: n, series: r, valueDomain: i }) {
|
|
509
|
+
if (e.trim() === "" || t.trim() === "" || n.trim() === "") return "A trend requires a title, a readable summary, and a value unit.";
|
|
510
|
+
if (!s(i)) return "The displayed value domain must have finite, increasing bounds.";
|
|
511
|
+
let a = A({
|
|
512
|
+
series: [r],
|
|
513
|
+
isStacked: !1,
|
|
514
|
+
markers: []
|
|
515
|
+
});
|
|
516
|
+
if (a !== void 0) return a;
|
|
517
|
+
if (r.points.some((e) => e.value !== null && (e.value < i[0] || e.value > i[1]))) return "Every recorded value must be inside the declared value domain.";
|
|
518
|
+
}
|
|
519
|
+
// packages/charts/src/cartesian/categorical.tsx
|
|
520
|
+
var R = {
|
|
521
|
+
items: 200,
|
|
522
|
+
series: 12
|
|
523
|
+
}, z = [
|
|
524
|
+
"series1",
|
|
525
|
+
"series2",
|
|
526
|
+
"series3",
|
|
527
|
+
"series4",
|
|
528
|
+
"series5",
|
|
529
|
+
"series6"
|
|
530
|
+
], B = {
|
|
531
|
+
kzqmXN: "x5lhr3w",
|
|
532
|
+
kZKoxP: "x5yr21d",
|
|
533
|
+
$$css: !0
|
|
534
|
+
}, V = {
|
|
535
|
+
kzqmXN: "x1xc55vz",
|
|
536
|
+
kZKoxP: "xdk7pt",
|
|
537
|
+
kmuXW: "x2lah0s",
|
|
538
|
+
$$css: !0
|
|
539
|
+
}, H = {
|
|
540
|
+
segment: (e, t) => [
|
|
541
|
+
B,
|
|
542
|
+
{
|
|
543
|
+
kWkggS: t == null ? t : "xl8spv7",
|
|
544
|
+
$$css: !0
|
|
545
|
+
},
|
|
546
|
+
{
|
|
547
|
+
"--x-width": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(`${e}%`),
|
|
548
|
+
"--x-backgroundColor": t ?? void 0
|
|
549
|
+
}
|
|
550
|
+
],
|
|
551
|
+
swatch: (e) => [
|
|
552
|
+
V,
|
|
553
|
+
{
|
|
554
|
+
kWkggS: e == null ? e : "xl8spv7",
|
|
555
|
+
$$css: !0
|
|
556
|
+
},
|
|
557
|
+
{ "--x-backgroundColor": e ?? void 0 }
|
|
558
|
+
],
|
|
559
|
+
plot: {
|
|
560
|
+
kqGvvJ: "xedx3ju",
|
|
561
|
+
$$css: !0
|
|
562
|
+
},
|
|
563
|
+
treeRect: {
|
|
564
|
+
kjVXCG: "x7x9j5w",
|
|
565
|
+
kfJifR: "xnpr05h",
|
|
566
|
+
$$css: !0
|
|
567
|
+
}
|
|
568
|
+
};
|
|
569
|
+
function U(e, t) {
|
|
570
|
+
return e ?? z[t % z.length] ?? "series1";
|
|
571
|
+
}
|
|
572
|
+
function W(e) {
|
|
573
|
+
if (e.length > R.items) return `Choose a window with at most ${R.items} items.`;
|
|
574
|
+
if (!a(e)) return "Every breakdown item needs a unique identifier.";
|
|
575
|
+
if (e.some((e) => e.value !== null && (!Number.isFinite(e.value) || e.value < 0))) return "Breakdown values must be finite and nonnegative, or explicitly missing.";
|
|
576
|
+
if (!Number.isFinite(e.reduce((e, t) => e + (t.value ?? 0), 0))) return "The sum of recorded values must be finite.";
|
|
577
|
+
}
|
|
578
|
+
function G({ items: e, selection: n }) {
|
|
579
|
+
return /* @__PURE__ */ v("ul", {
|
|
580
|
+
className: "xrvj5dj x1ghz6dp x1717udv xe8uvvx",
|
|
581
|
+
children: e.map((e) => /* @__PURE__ */ v("li", { children: /* @__PURE__ */ y(t, {
|
|
582
|
+
label: `${e.label}: ${e.valueLabel}`,
|
|
583
|
+
selected: n?.selectedId === e.id,
|
|
584
|
+
onSelect: n === void 0 ? void 0 : () => n.onSelect(e.id),
|
|
585
|
+
children: [/* @__PURE__ */ y("span", {
|
|
586
|
+
className: "x78zum5 x6s0dn4 xf0fr40 xeuugli",
|
|
587
|
+
children: [/* @__PURE__ */ v("span", {
|
|
588
|
+
"aria-hidden": !0,
|
|
589
|
+
...d.props(H.swatch(i[e.tone]))
|
|
590
|
+
}), e.label]
|
|
591
|
+
}), /* @__PURE__ */ v("span", {
|
|
592
|
+
className: "xv9cywu xp4054r",
|
|
593
|
+
children: e.valueLabel
|
|
594
|
+
})]
|
|
595
|
+
}) }, e.id))
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
function K({ title: e, description: t, items: n, total: r, formatValue: a, selection: s }) {
|
|
599
|
+
let c = W(n), u = n.reduce((e, t) => e + (t.value ?? 0), 0), f = 2 ** -52 * Math.max(u, r, 1) * n.length;
|
|
600
|
+
return c === void 0 ? !Number.isFinite(r) || r < 0 || u - r > f ? /* @__PURE__ */ v(l, {
|
|
601
|
+
title: e,
|
|
602
|
+
description: t,
|
|
603
|
+
message: "The total must be finite and at least the sum of recorded values."
|
|
604
|
+
}) : /* @__PURE__ */ v(o, {
|
|
605
|
+
title: e,
|
|
606
|
+
description: t,
|
|
607
|
+
children: n.length === 0 ? /* @__PURE__ */ v("p", {
|
|
608
|
+
className: "xv9cywu x1ghz6dp xut3y95",
|
|
609
|
+
children: "No values"
|
|
610
|
+
}) : /* @__PURE__ */ y(_, { children: [
|
|
611
|
+
/* @__PURE__ */ v("div", {
|
|
612
|
+
"aria-hidden": !0,
|
|
613
|
+
className: "x78zum5 x170jfvy xb3r6kr x1m7rfvg xmkeg23 x1y0btm7 x1yww3zy xegg4c4",
|
|
614
|
+
children: n.map((e, t) => e.value === null ? null : /* @__PURE__ */ v("span", { ...d.props(H.segment(r === 0 ? 0 : e.value / r * 100, i[U(e.tone, t)])) }, e.id))
|
|
615
|
+
}),
|
|
616
|
+
/* @__PURE__ */ v(G, {
|
|
617
|
+
items: n.map((e, t) => ({
|
|
618
|
+
id: e.id,
|
|
619
|
+
label: e.label,
|
|
620
|
+
valueLabel: e.value === null ? "Unavailable" : a(e.value),
|
|
621
|
+
tone: U(e.tone, t)
|
|
622
|
+
})),
|
|
623
|
+
selection: s
|
|
624
|
+
}),
|
|
625
|
+
r - u > f && /* @__PURE__ */ y("p", {
|
|
626
|
+
className: "xv9cywu x1ghz6dp xut3y95",
|
|
627
|
+
children: [
|
|
628
|
+
"Unassigned portion: ",
|
|
629
|
+
a(r - u),
|
|
630
|
+
" of ",
|
|
631
|
+
a(r)
|
|
632
|
+
]
|
|
633
|
+
})
|
|
634
|
+
] })
|
|
635
|
+
}) : /* @__PURE__ */ v(l, {
|
|
636
|
+
title: e,
|
|
637
|
+
description: t,
|
|
638
|
+
message: c
|
|
639
|
+
});
|
|
640
|
+
}
|
|
641
|
+
function q({ title: e, description: t, items: r, formatValue: a, selection: s, height: c = 180 }) {
|
|
642
|
+
let f = W(r), p = r.reduce((e, t) => e + (t.value ?? 0), 0), { ref: m, width: h } = u();
|
|
643
|
+
if (f !== void 0 || !Number.isFinite(c) || c < 48) return /* @__PURE__ */ v(l, {
|
|
644
|
+
title: e,
|
|
645
|
+
description: t,
|
|
646
|
+
message: f ?? "Chart height must be at least 48 pixels."
|
|
647
|
+
});
|
|
648
|
+
let g = r.flatMap((e, t) => e.value === null || e.value === 0 ? [] : [{
|
|
649
|
+
id: e.id,
|
|
650
|
+
label: e.label,
|
|
651
|
+
value: e.value,
|
|
652
|
+
tone: U(e.tone, t)
|
|
653
|
+
}]), _ = E({
|
|
654
|
+
id: "root",
|
|
655
|
+
label: e,
|
|
656
|
+
value: 0,
|
|
657
|
+
tone: "neutral",
|
|
658
|
+
children: g
|
|
659
|
+
}, (e) => e.children === void 0 ? void 0 : [...e.children]).sum((e) => e.value);
|
|
660
|
+
return /* @__PURE__ */ y(o, {
|
|
661
|
+
title: e,
|
|
662
|
+
description: t,
|
|
663
|
+
children: [
|
|
664
|
+
/* @__PURE__ */ v("div", {
|
|
665
|
+
ref: m,
|
|
666
|
+
...d.props(n.plot),
|
|
667
|
+
children: p === 0 ? /* @__PURE__ */ v("p", {
|
|
668
|
+
className: "xv9cywu x1ghz6dp xut3y95",
|
|
669
|
+
children: "No positive values to size the areas"
|
|
670
|
+
}) : /* @__PURE__ */ v("svg", {
|
|
671
|
+
role: "img",
|
|
672
|
+
"aria-label": `${e}. Areas compare recorded values.`,
|
|
673
|
+
viewBox: `0 0 ${h} ${c}`,
|
|
674
|
+
height: c,
|
|
675
|
+
...d.props(n.svg),
|
|
676
|
+
children: /* @__PURE__ */ v(T, {
|
|
677
|
+
root: _,
|
|
678
|
+
size: [h, c],
|
|
679
|
+
paddingInner: 2,
|
|
680
|
+
children: (e) => e.leaves().map((e) => {
|
|
681
|
+
let t = e.x1 - e.x0 > 96 && e.y1 - e.y0 > 40;
|
|
682
|
+
return /* @__PURE__ */ y("g", { children: [
|
|
683
|
+
/* @__PURE__ */ v("rect", {
|
|
684
|
+
x: e.x0,
|
|
685
|
+
y: e.y0,
|
|
686
|
+
width: e.x1 - e.x0,
|
|
687
|
+
height: e.y1 - e.y0,
|
|
688
|
+
fill: i[e.data.tone],
|
|
689
|
+
fillOpacity: .18,
|
|
690
|
+
...d.props(H.treeRect, s?.selectedId === e.data.id && n.selected)
|
|
691
|
+
}),
|
|
692
|
+
/* @__PURE__ */ y("title", { children: [
|
|
693
|
+
e.data.label,
|
|
694
|
+
": ",
|
|
695
|
+
a(e.data.value)
|
|
696
|
+
] }),
|
|
697
|
+
t && /* @__PURE__ */ y("svg", {
|
|
698
|
+
x: e.x0,
|
|
699
|
+
y: e.y0,
|
|
700
|
+
width: e.x1 - e.x0,
|
|
701
|
+
height: e.y1 - e.y0,
|
|
702
|
+
overflow: "hidden",
|
|
703
|
+
children: [/* @__PURE__ */ v("text", {
|
|
704
|
+
x: 8,
|
|
705
|
+
y: 18,
|
|
706
|
+
className: "x49x0gd xoedhln xut3y95",
|
|
707
|
+
children: e.data.label.slice(0, Math.floor((e.x1 - e.x0 - 16) / 7))
|
|
708
|
+
}), a(e.data.value).length * 12 < e.x1 - e.x0 - 16 && /* @__PURE__ */ v("text", {
|
|
709
|
+
x: 8,
|
|
710
|
+
y: 34,
|
|
711
|
+
className: "x49x0gd xoedhln xut3y95",
|
|
712
|
+
children: a(e.data.value)
|
|
713
|
+
})]
|
|
714
|
+
})
|
|
715
|
+
] }, e.data.id);
|
|
716
|
+
})
|
|
717
|
+
})
|
|
718
|
+
})
|
|
719
|
+
}),
|
|
720
|
+
/* @__PURE__ */ v(G, {
|
|
721
|
+
items: r.map((e, t) => ({
|
|
722
|
+
id: e.id,
|
|
723
|
+
label: e.label,
|
|
724
|
+
valueLabel: e.value === null ? "Unavailable" : a(e.value),
|
|
725
|
+
tone: U(e.tone, t)
|
|
726
|
+
})),
|
|
727
|
+
selection: s
|
|
728
|
+
}),
|
|
729
|
+
r.some((e) => e.value === null) && /* @__PURE__ */ v("p", {
|
|
730
|
+
className: "xv9cywu x1ghz6dp xut3y95",
|
|
731
|
+
children: "Unavailable values have no area."
|
|
732
|
+
})
|
|
733
|
+
]
|
|
734
|
+
});
|
|
735
|
+
}
|
|
736
|
+
function J({ categories: e, series: t, domain: n, mode: r }) {
|
|
737
|
+
if (e.length > R.items || t.length > R.series) return `Choose a window with at most ${R.items} categories and ${R.series} series.`;
|
|
738
|
+
if (!s(n) || n[0] > 0 || n[1] < 0) return "The bar domain must be finite, increasing, and include zero.";
|
|
739
|
+
if (!a(e) || !a(t)) return "Bar categories and series require unique identifiers.";
|
|
740
|
+
for (let i of t) {
|
|
741
|
+
if (i.values.length !== e.length) return "Every series requires one explicit value per category.";
|
|
742
|
+
for (let e of i.values) {
|
|
743
|
+
if (e !== null && (!Number.isFinite(e) || e < n[0] || e > n[1])) return "Bar values must be finite and within the supplied domain.";
|
|
744
|
+
if (r === "stacked" && (e === null || e < 0)) return "Stacked bars require present nonnegative values.";
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
if (r === "stacked" && e.some((e, r) => t.reduce((e, t) => e + (t.values[r] ?? 0), 0) > n[1])) return "Stacked bar totals must fit the supplied domain.";
|
|
748
|
+
}
|
|
749
|
+
function Y({ title: e, description: t, categories: r, series: a, domain: s, mode: f = "grouped", formatValue: p, selection: m, height: h = 200 }) {
|
|
750
|
+
let g = J({
|
|
751
|
+
categories: r,
|
|
752
|
+
series: a,
|
|
753
|
+
domain: s,
|
|
754
|
+
mode: f
|
|
755
|
+
}), { ref: _, width: S } = u();
|
|
756
|
+
if (g !== void 0 || !Number.isFinite(h) || h < 48) return /* @__PURE__ */ v(l, {
|
|
757
|
+
title: e,
|
|
758
|
+
description: t,
|
|
759
|
+
message: g ?? "Chart height must be at least 48 pixels."
|
|
760
|
+
});
|
|
761
|
+
let w = h - 28, T = x({
|
|
762
|
+
domain: [...s],
|
|
763
|
+
range: [w, 12]
|
|
764
|
+
}), E = Math.max(52, ...T.ticks(3).map((e) => p(e).length * 7 + 12)), D = Math.max(E + 1, S - 16), O = b({
|
|
765
|
+
domain: r.map((e) => e.id),
|
|
766
|
+
range: [E, D],
|
|
767
|
+
padding: .3
|
|
768
|
+
}), k = b({
|
|
769
|
+
domain: a.map((e) => e.id),
|
|
770
|
+
range: [0, O.bandwidth()],
|
|
771
|
+
padding: .08
|
|
772
|
+
}), A = Math.max(1, Math.ceil(56 / O.step())), j = Math.max(1, Math.floor(O.step() * A / 12) - 1), M = a.map((e, t) => ({
|
|
773
|
+
id: e.id,
|
|
774
|
+
label: e.label,
|
|
775
|
+
tone: U(e.tone, t)
|
|
776
|
+
}));
|
|
777
|
+
return /* @__PURE__ */ y(o, {
|
|
778
|
+
title: e,
|
|
779
|
+
description: t,
|
|
780
|
+
children: [
|
|
781
|
+
/* @__PURE__ */ v(c, { items: M }),
|
|
782
|
+
/* @__PURE__ */ v("div", {
|
|
783
|
+
ref: _,
|
|
784
|
+
...d.props(n.plot, H.plot),
|
|
785
|
+
children: r.length === 0 || a.length === 0 ? /* @__PURE__ */ v("p", {
|
|
786
|
+
className: "xv9cywu x1ghz6dp xut3y95",
|
|
787
|
+
children: "No categories"
|
|
788
|
+
}) : /* @__PURE__ */ y("svg", {
|
|
789
|
+
role: "img",
|
|
790
|
+
"aria-label": e,
|
|
791
|
+
viewBox: `0 0 ${S} ${h}`,
|
|
792
|
+
height: h,
|
|
793
|
+
...d.props(n.svg),
|
|
794
|
+
children: [T.ticks(3).map((e) => /* @__PURE__ */ y("g", { children: [/* @__PURE__ */ v("line", {
|
|
795
|
+
x1: E,
|
|
796
|
+
x2: D,
|
|
797
|
+
y1: T(e),
|
|
798
|
+
y2: T(e),
|
|
799
|
+
...d.props(n.grid)
|
|
800
|
+
}), /* @__PURE__ */ v("text", {
|
|
801
|
+
x: E - 8,
|
|
802
|
+
y: T(e),
|
|
803
|
+
textAnchor: "end",
|
|
804
|
+
dominantBaseline: "middle",
|
|
805
|
+
...d.props(n.label),
|
|
806
|
+
children: p(e)
|
|
807
|
+
})] }, e)), r.map((e, t) => /* @__PURE__ */ y("g", { children: [a.map((r, o) => {
|
|
808
|
+
let s = r.values[t];
|
|
809
|
+
if (s == null) return null;
|
|
810
|
+
let c = f === "stacked" ? a.slice(0, o).reduce((e, n) => e + (n.values[t] ?? 0), 0) : 0, l = T(c), u = T(c + s);
|
|
811
|
+
return /* @__PURE__ */ v(C, {
|
|
812
|
+
x: (O(e.id) ?? E) + (f === "stacked" ? 0 : k(r.id) ?? 0),
|
|
813
|
+
y: Math.min(l, u),
|
|
814
|
+
width: f === "stacked" ? O.bandwidth() : k.bandwidth(),
|
|
815
|
+
height: Math.max(+(s === 0), Math.abs(u - l)),
|
|
816
|
+
fill: i[U(r.tone, o)],
|
|
817
|
+
...d.props(m?.selectedId === e.id && n.selected),
|
|
818
|
+
children: /* @__PURE__ */ y("title", { children: [
|
|
819
|
+
e.label,
|
|
820
|
+
" · ",
|
|
821
|
+
r.label,
|
|
822
|
+
": ",
|
|
823
|
+
p(s)
|
|
824
|
+
] })
|
|
825
|
+
}, r.id);
|
|
826
|
+
}), t % A === 0 && /* @__PURE__ */ v("text", {
|
|
827
|
+
x: (O(e.id) ?? E) + O.bandwidth() / 2,
|
|
828
|
+
y: h - 4,
|
|
829
|
+
textAnchor: "middle",
|
|
830
|
+
...d.props(n.label),
|
|
831
|
+
children: e.label.length > j ? `${e.label.slice(0, j)}…` : e.label
|
|
832
|
+
})] }, e.id))]
|
|
833
|
+
})
|
|
834
|
+
}),
|
|
835
|
+
/* @__PURE__ */ v(G, {
|
|
836
|
+
items: r.map((e, t) => ({
|
|
837
|
+
id: e.id,
|
|
838
|
+
label: e.label,
|
|
839
|
+
valueLabel: a.map((e) => `${e.label}: ${e.values[t] === null || e.values[t] === void 0 ? "Unavailable" : p(e.values[t])}`).join(" · "),
|
|
840
|
+
tone: "neutral"
|
|
841
|
+
})),
|
|
842
|
+
selection: m
|
|
843
|
+
})
|
|
844
|
+
]
|
|
845
|
+
});
|
|
846
|
+
}
|
|
847
|
+
export { P as a, D as c, ie as i, K as n, re as o, q as r, F as s, Y as t };
|