@praxical/ui 0.0.0-stage → 0.10.1

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.
Files changed (86) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +23 -2
  3. package/dist/activity-calendar.d.ts +13 -0
  4. package/dist/activity-calendar.js +7 -0
  5. package/dist/activity-heatmap.d.ts +14 -0
  6. package/dist/activity-heatmap.js +13 -0
  7. package/dist/chart-data.d.ts +9 -0
  8. package/dist/chart-data.js +9 -0
  9. package/dist/charts.d.ts +56 -0
  10. package/dist/charts.js +424 -0
  11. package/dist/chunk-7RMPDKZV.js +541 -0
  12. package/dist/chunk-7RTW3X7C.js +142 -0
  13. package/dist/chunk-EBF2F3LN.js +1523 -0
  14. package/dist/chunk-FCYIZANU.js +385 -0
  15. package/dist/chunk-HMO4VQZN.js +58 -0
  16. package/dist/chunk-II677WPC.js +177 -0
  17. package/dist/chunk-KZHUBPY6.js +102 -0
  18. package/dist/chunk-OLGZOPLD.js +166 -0
  19. package/dist/chunk-PDSV773E.js +52 -0
  20. package/dist/chunk-Q4ARHP76.js +457 -0
  21. package/dist/chunk-U5W7O3QV.js +22 -0
  22. package/dist/chunk-V6MXR4P2.js +275 -0
  23. package/dist/chunk-VZZDLRM5.js +152 -0
  24. package/dist/chunk-WEM2UQPR.js +110 -0
  25. package/dist/chunk-XFNDEA5M.js +104 -0
  26. package/dist/chunk-YKFAA7GU.js +72 -0
  27. package/dist/code-value.d.ts +13 -0
  28. package/dist/code-value.js +10 -0
  29. package/dist/code.d.ts +36 -0
  30. package/dist/code.js +198 -0
  31. package/dist/collection.d.ts +21 -0
  32. package/dist/collection.js +48 -0
  33. package/dist/content.d.ts +42 -0
  34. package/dist/content.js +122 -0
  35. package/dist/display.d.ts +58 -0
  36. package/dist/display.js +27 -0
  37. package/dist/feedback.d.ts +34 -0
  38. package/dist/feedback.js +184 -0
  39. package/dist/file-tree.d.ts +17 -0
  40. package/dist/file-tree.js +11 -0
  41. package/dist/forms.d.ts +69 -0
  42. package/dist/forms.js +273 -0
  43. package/dist/git-graph.d.ts +8 -0
  44. package/dist/git-graph.js +15 -0
  45. package/dist/git-layout.d.ts +24 -0
  46. package/dist/git-layout.js +7 -0
  47. package/dist/image-viewer.d.ts +18 -0
  48. package/dist/image-viewer.js +11 -0
  49. package/dist/index.d.ts +363 -0
  50. package/dist/index.js +98 -0
  51. package/dist/inputs.d.ts +112 -0
  52. package/dist/inputs.js +938 -0
  53. package/dist/layout.d.ts +56 -0
  54. package/dist/layout.js +180 -0
  55. package/dist/map-frame.d.ts +37 -0
  56. package/dist/map-frame.js +13 -0
  57. package/dist/media.d.ts +40 -0
  58. package/dist/media.js +19 -0
  59. package/dist/network-layout.d.ts +94 -0
  60. package/dist/network-layout.js +19 -0
  61. package/dist/network.d.ts +111 -0
  62. package/dist/network.js +354 -0
  63. package/dist/overlays.d.ts +95 -0
  64. package/dist/overlays.js +25 -0
  65. package/dist/patterns.d.ts +117 -0
  66. package/dist/patterns.js +387 -0
  67. package/dist/power-layout.d.ts +91 -0
  68. package/dist/power-layout.js +13 -0
  69. package/dist/power.d.ts +91 -0
  70. package/dist/power.js +353 -0
  71. package/dist/signal-context.d.ts +11 -0
  72. package/dist/signal-context.js +15 -0
  73. package/dist/strings-es-419.d.ts +13 -0
  74. package/dist/strings-es-419.js +357 -0
  75. package/dist/strings-fr.d.ts +15 -0
  76. package/dist/strings-fr.js +359 -0
  77. package/dist/strings-ja.d.ts +16 -0
  78. package/dist/strings-ja.js +357 -0
  79. package/dist/strings-pt-BR.d.ts +13 -0
  80. package/dist/strings-pt-BR.js +357 -0
  81. package/dist/strings.d.ts +394 -0
  82. package/dist/strings.js +15 -0
  83. package/dist/styles.css +2 -0
  84. package/dist/tab-bar.d.ts +20 -0
  85. package/dist/tab-bar.js +114 -0
  86. package/package.json +154 -3
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Praxical
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,24 @@
1
- # Temporary Holding Version
1
+ # @praxical/ui
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ React components for [Praxical Signal](https://gitgud.io/praxical/signal), an MIT-licensed UI system: controls, panes, data tables, technical charts, messaging and composition, built on Base UI.
4
+
5
+ ```sh
6
+ npm install --save-exact @praxical/ui@0.10.1 @praxical/tokens@0.10.1
7
+ ```
8
+
9
+ Install `@praxical/tokens` at the same version, import the stylesheets once at your application root and wrap components in `SignalProvider`:
10
+
11
+ ```tsx
12
+ import "@praxical/tokens/fonts.css";
13
+ import "@praxical/tokens/tokens.css";
14
+ import "@praxical/ui/styles.css";
15
+ import { SignalProvider, Button } from "@praxical/ui";
16
+
17
+ export const App = () => (
18
+ <SignalProvider appearance="system" palette="sapphire">
19
+ <Button variant="primary">Save</Button>
20
+ </SignalProvider>
21
+ );
22
+ ```
23
+
24
+ React and React DOM (`>=19.2.0 <20`) are peers; Recharts (`>=3.10.1 <4`) is needed only for `@praxical/ui/charts`. ESM only, with TypeScript declarations. See [installation and API](https://gitgud.io/praxical/signal/-/blob/master/docs/USAGE.md), [migration](https://gitgud.io/praxical/signal/-/blob/master/docs/MIGRATION.md) and the [changelog](https://gitgud.io/praxical/signal/-/blob/master/CHANGELOG.md).
@@ -0,0 +1,13 @@
1
+ export interface ActivityDay {
2
+ date: string;
3
+ value: number;
4
+ weekday: number;
5
+ week: number;
6
+ month: number;
7
+ monthWeek: number;
8
+ }
9
+ /** Calendar positions include real civil dates only. Leading/trailing slots stay empty. */
10
+ export declare function activityCalendar(year: number, values: readonly {
11
+ date: string;
12
+ value: number;
13
+ }[], through?: string): ActivityDay[];
@@ -0,0 +1,7 @@
1
+ 'use client';
2
+ import {
3
+ activityCalendar
4
+ } from "./chunk-PDSV773E.js";
5
+ export {
6
+ activityCalendar
7
+ };
@@ -0,0 +1,14 @@
1
+ import { type ActivityDay } from "./activity-calendar.js";
2
+ export { activityCalendar, type ActivityDay } from "./activity-calendar.js";
3
+ /** Annual contribution view; narrow containers reflow to labeled calendar months. */
4
+ export declare function ActivityHeatmap({ year, values, through, label, onSelect, locale, }: {
5
+ year: number;
6
+ values: readonly {
7
+ date: string;
8
+ value: number;
9
+ }[];
10
+ through?: string;
11
+ label: string;
12
+ locale?: string;
13
+ onSelect?: (day: ActivityDay) => void;
14
+ }): import("react").JSX.Element;
@@ -0,0 +1,13 @@
1
+ 'use client';
2
+ import {
3
+ ActivityHeatmap
4
+ } from "./chunk-KZHUBPY6.js";
5
+ import {
6
+ activityCalendar
7
+ } from "./chunk-PDSV773E.js";
8
+ import "./chunk-U5W7O3QV.js";
9
+ import "./chunk-FCYIZANU.js";
10
+ export {
11
+ ActivityHeatmap,
12
+ activityCalendar
13
+ };
@@ -0,0 +1,9 @@
1
+ export interface DailyPoint {
2
+ day: string;
3
+ [key: string]: string | number | null | undefined;
4
+ }
5
+ /** Strict UTC calendar dates, sorted and padded with unknown observations. Never infer a zero. */
6
+ export declare function normalizeDailyData(data: readonly DailyPoint[], keys: readonly string[]): DailyPoint[];
7
+ /** Evenly spaced value-axis ticks on round steps (1, 2, 2.5 or 5 × 10ⁿ): at
8
+ * most four intervals, zero always a tick, the domain the first and last. */
9
+ export declare function chartTicks(values: readonly number[]): number[];
@@ -0,0 +1,9 @@
1
+ 'use client';
2
+ import {
3
+ chartTicks,
4
+ normalizeDailyData
5
+ } from "./chunk-HMO4VQZN.js";
6
+ export {
7
+ chartTicks,
8
+ normalizeDailyData
9
+ };
@@ -0,0 +1,56 @@
1
+ import { type DailyPoint } from "./chart-data.js";
2
+ export { normalizeDailyData } from "./chart-data.js";
3
+ export type { DailyPoint } from "./chart-data.js";
4
+ export interface ChartSeries {
5
+ key: string;
6
+ label: string;
7
+ color?: string;
8
+ dash?: string;
9
+ format?: (value: number) => string;
10
+ }
11
+ export interface TechnicalLineChartProps {
12
+ data: readonly DailyPoint[];
13
+ series: readonly ChartSeries[];
14
+ label: string;
15
+ monetary?: boolean;
16
+ interpolation?: "linear" | "monotone";
17
+ /** Show a key of the series between the caption and the plot. */
18
+ legend?: boolean;
19
+ }
20
+ /** A daily UTC instrument: missing dates become gaps, negative values remain below zero. */
21
+ export declare function TechnicalLineChart({ data, series, label, monetary, interpolation, legend, }: TechnicalLineChartProps): import("react").JSX.Element;
22
+ /** Compatible Store call signature. Exact data disclosure now always accompanies the plot. */
23
+ export declare function MetricChart<T extends {
24
+ day: string;
25
+ }>({ data, dataKey, label, color, formatValue, monetary, }: {
26
+ data: T[];
27
+ dataKey: keyof T & string;
28
+ label: string;
29
+ color?: string;
30
+ formatValue?: (value: number) => string;
31
+ monetary?: boolean;
32
+ dailyTable?: boolean;
33
+ }): import("react").JSX.Element;
34
+ export interface BarDatum {
35
+ label: string;
36
+ value: number | null;
37
+ }
38
+ /** A category comparison. Bars are square, one colour, on the same quiet grid
39
+ * as the line chart; a null value is a visible gap, not a zero. */
40
+ export declare function BarChart({ data, label, format, color, horizontal, }: {
41
+ data: readonly BarDatum[];
42
+ label: string;
43
+ format?: (value: number) => string;
44
+ color?: string;
45
+ horizontal?: boolean;
46
+ }): import("react").JSX.Element;
47
+ /** A small inline trend for a stat tile or a table cell. Missing values are
48
+ * gaps; the last observation carries a hollow marker. */
49
+ export declare function Sparkline({ data, label, width, height, color, format, }: {
50
+ data: readonly (number | null)[];
51
+ label: string;
52
+ width?: number;
53
+ height?: number;
54
+ color?: string;
55
+ format?: (value: number) => string;
56
+ }): import("react").JSX.Element;
package/dist/charts.js ADDED
@@ -0,0 +1,424 @@
1
+ 'use client';
2
+ "use client";
3
+ import {
4
+ chartTicks,
5
+ normalizeDailyData
6
+ } from "./chunk-HMO4VQZN.js";
7
+ import {
8
+ useSignalLocale,
9
+ useSignalStrings
10
+ } from "./chunk-U5W7O3QV.js";
11
+ import "./chunk-FCYIZANU.js";
12
+
13
+ // packages/ui/src/charts.tsx
14
+ import { useId } from "react";
15
+ import {
16
+ CartesianGrid,
17
+ Line,
18
+ LineChart,
19
+ ReferenceLine,
20
+ ResponsiveContainer,
21
+ Tooltip,
22
+ XAxis,
23
+ YAxis
24
+ } from "recharts";
25
+ import { Bar, BarChart as RechartsBarChart, Text } from "recharts";
26
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
27
+ var colors = [
28
+ "var(--signal-chart-primary)",
29
+ "var(--signal-chart-secondary)",
30
+ "var(--signal-chart-success)"
31
+ ];
32
+ var seriesColor = (s, i) => s.color ?? colors[i % 3];
33
+ var seriesDash = (s, i) => s.dash ?? (i ? ["", "6 3", "2 3"][i % 3] : void 0);
34
+ function useNumberFormat() {
35
+ const formatter = new Intl.NumberFormat(useSignalLocale());
36
+ return (value) => formatter.format(value);
37
+ }
38
+ function TechnicalLineChart({
39
+ data,
40
+ series,
41
+ label,
42
+ monetary = false,
43
+ interpolation = "linear",
44
+ legend = false
45
+ }) {
46
+ const strings = useSignalStrings(), count = useNumberFormat();
47
+ const id = useId();
48
+ const points = normalizeDailyData(
49
+ data,
50
+ series.map((s) => s.key)
51
+ );
52
+ const measured = points.flatMap(
53
+ (p) => series.map((s) => p[s.key]).filter((v) => typeof v === "number")
54
+ );
55
+ const ticks = chartTicks(measured);
56
+ const plotClass = `signal-chart${monetary ? " signal-chart-money" : ""}`;
57
+ return /* @__PURE__ */ jsxs(
58
+ "div",
59
+ {
60
+ className: "signal-chart-group",
61
+ role: "group",
62
+ "aria-label": strings.chart.dailyGroup(label),
63
+ children: [
64
+ /* @__PURE__ */ jsx("p", { className: "signal-muted signal-chart-help", "aria-hidden": "true", children: strings.chart.dailyCaption(label) }),
65
+ /* @__PURE__ */ jsx("span", { id, className: "signal-sr-only", children: strings.chart.dailyHelp(label) }),
66
+ legend && /* @__PURE__ */ jsx("ul", { className: "signal-chart-key", children: series.map((s, i) => /* @__PURE__ */ jsxs("li", { children: [
67
+ /* @__PURE__ */ jsx("svg", { width: 16, height: 2, "aria-hidden": "true", children: /* @__PURE__ */ jsx(
68
+ "line",
69
+ {
70
+ x2: 16,
71
+ y1: 1,
72
+ y2: 1,
73
+ stroke: seriesColor(s, i),
74
+ strokeWidth: 2,
75
+ strokeDasharray: seriesDash(s, i)
76
+ }
77
+ ) }),
78
+ s.label
79
+ ] }, s.key)) }),
80
+ measured.length ? /* @__PURE__ */ jsx("div", { className: plotClass, children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", minWidth: 0, children: /* @__PURE__ */ jsxs(
81
+ LineChart,
82
+ {
83
+ data: points,
84
+ margin: { top: 16, right: 12, bottom: 4, left: 0 },
85
+ accessibilityLayer: true,
86
+ "aria-label": strings.chart.dailyPlot(label),
87
+ "aria-describedby": id,
88
+ children: [
89
+ /* @__PURE__ */ jsx(
90
+ CartesianGrid,
91
+ {
92
+ vertical: false,
93
+ stroke: "var(--signal-line)",
94
+ strokeOpacity: 0.7,
95
+ strokeDasharray: "2 6"
96
+ }
97
+ ),
98
+ /* @__PURE__ */ jsx(
99
+ XAxis,
100
+ {
101
+ dataKey: "day",
102
+ padding: { left: 8, right: 8 },
103
+ tickFormatter: (value) => String(value).slice(5),
104
+ minTickGap: 32,
105
+ tickMargin: 12,
106
+ tickLine: false,
107
+ axisLine: false,
108
+ height: 36,
109
+ stroke: "var(--signal-muted)"
110
+ }
111
+ ),
112
+ /* @__PURE__ */ jsx(
113
+ YAxis,
114
+ {
115
+ width: monetary ? 84 : 46,
116
+ tickMargin: 8,
117
+ tickLine: false,
118
+ axisLine: false,
119
+ stroke: "var(--signal-muted)",
120
+ tickFormatter: series[0]?.format ?? count,
121
+ domain: [ticks[0], ticks.at(-1)],
122
+ ticks,
123
+ interval: 0
124
+ }
125
+ ),
126
+ /* @__PURE__ */ jsx(ReferenceLine, { y: 0, stroke: "var(--signal-line)" }),
127
+ /* @__PURE__ */ jsx(
128
+ Tooltip,
129
+ {
130
+ filterNull: false,
131
+ isAnimationActive: false,
132
+ cursor: {
133
+ stroke: "var(--signal-line-strong)",
134
+ strokeWidth: 1,
135
+ strokeDasharray: "3 4"
136
+ },
137
+ content: ({ active, payload, label: day }) => active && payload?.length ? /* @__PURE__ */ jsxs("div", { className: "signal-chart-tooltip", children: [
138
+ /* @__PURE__ */ jsx("span", { children: strings.chart.tooltipDay(String(day)) }),
139
+ series.map((s, i) => {
140
+ const point = payload.find((p) => p.dataKey === s.key);
141
+ return /* @__PURE__ */ jsxs("strong", { children: [
142
+ /* @__PURE__ */ jsx(
143
+ "i",
144
+ {
145
+ style: { background: s.color ?? colors[i % 3] }
146
+ }
147
+ ),
148
+ s.label,
149
+ /* @__PURE__ */ jsx("b", { children: point?.value == null ? strings.chart.notRecorded : (s.format ?? count)(Number(point.value)) })
150
+ ] }, s.key);
151
+ })
152
+ ] }) : null
153
+ }
154
+ ),
155
+ series.map((s, i) => /* @__PURE__ */ jsx(
156
+ Line,
157
+ {
158
+ type: interpolation,
159
+ dataKey: s.key,
160
+ name: s.label,
161
+ stroke: seriesColor(s, i),
162
+ strokeDasharray: seriesDash(s, i),
163
+ strokeWidth: 2,
164
+ connectNulls: false,
165
+ isAnimationActive: false,
166
+ dot: ({ cx, cy, payload, index }) => payload[s.key] == null || cx == null || cy == null || points.length > 31 && (points[index - 1]?.[s.key] != null || points[index + 1]?.[s.key] != null) ? /* @__PURE__ */ jsx("g", {}, index) : /* @__PURE__ */ jsx(
167
+ "rect",
168
+ {
169
+ x: cx - 2,
170
+ y: cy - 2,
171
+ width: 4,
172
+ height: 4,
173
+ fill: "var(--signal-surface)",
174
+ stroke: s.color ?? colors[i % 3],
175
+ strokeWidth: 1.5
176
+ },
177
+ index
178
+ ),
179
+ activeDot: ({ cx, cy }) => cx == null || cy == null ? /* @__PURE__ */ jsx("g", {}) : /* @__PURE__ */ jsx(
180
+ "rect",
181
+ {
182
+ x: cx - 4,
183
+ y: cy - 4,
184
+ width: 8,
185
+ height: 8,
186
+ fill: "var(--signal-surface)",
187
+ stroke: s.color ?? colors[i % 3],
188
+ strokeWidth: 2
189
+ }
190
+ )
191
+ },
192
+ s.key
193
+ ))
194
+ ]
195
+ }
196
+ ) }) }) : /* @__PURE__ */ jsx("div", { className: `${plotClass} signal-chart-empty`, children: /* @__PURE__ */ jsx("p", { className: "signal-muted", children: strings.chart.noMeasurements }) }),
197
+ /* @__PURE__ */ jsxs("details", { className: "signal-chart-table", children: [
198
+ /* @__PURE__ */ jsx("summary", { children: strings.chart.viewDaily }),
199
+ /* @__PURE__ */ jsx(
200
+ "div",
201
+ {
202
+ className: "signal-table-scroll",
203
+ tabIndex: 0,
204
+ role: "region",
205
+ "aria-label": strings.chart.dataRegion(label),
206
+ children: /* @__PURE__ */ jsxs("table", { className: "signal-table", children: [
207
+ /* @__PURE__ */ jsx("caption", { children: strings.chart.dataCaption(label) }),
208
+ /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
209
+ /* @__PURE__ */ jsx("th", { scope: "col", children: strings.chart.dateHeader }),
210
+ series.map((s) => /* @__PURE__ */ jsx("th", { scope: "col", children: s.label }, s.key))
211
+ ] }) }),
212
+ /* @__PURE__ */ jsx("tbody", { children: points.map((p) => /* @__PURE__ */ jsxs("tr", { children: [
213
+ /* @__PURE__ */ jsx("th", { scope: "row", children: p.day }),
214
+ series.map((s) => /* @__PURE__ */ jsx("td", { children: p[s.key] == null ? strings.chart.notRecorded : (s.format ?? count)(Number(p[s.key])) }, s.key))
215
+ ] }, p.day)) })
216
+ ] })
217
+ }
218
+ )
219
+ ] })
220
+ ]
221
+ }
222
+ );
223
+ }
224
+ function MetricChart({
225
+ data,
226
+ dataKey,
227
+ label,
228
+ color,
229
+ formatValue,
230
+ monetary = false
231
+ }) {
232
+ const count = useNumberFormat();
233
+ return /* @__PURE__ */ jsx(
234
+ TechnicalLineChart,
235
+ {
236
+ data: data.map((p) => ({
237
+ day: p.day,
238
+ value: typeof p[dataKey] === "number" ? p[dataKey] : null
239
+ })),
240
+ series: [{ key: "value", label, color, format: formatValue ?? count }],
241
+ label,
242
+ monetary
243
+ }
244
+ );
245
+ }
246
+ function CategoryTick({
247
+ x,
248
+ y,
249
+ width = 0,
250
+ visibleTicksCount = 1,
251
+ payload,
252
+ side
253
+ }) {
254
+ return /* @__PURE__ */ jsx(
255
+ Text,
256
+ {
257
+ x,
258
+ y,
259
+ width: Math.max(0, side ? width - 8 : width / Math.max(1, visibleTicksCount) - 8),
260
+ textAnchor: side ? "end" : "middle",
261
+ verticalAnchor: side ? "middle" : "start",
262
+ fill: "var(--signal-muted)",
263
+ children: String(payload?.value ?? "")
264
+ }
265
+ );
266
+ }
267
+ function BarChart({
268
+ data,
269
+ label,
270
+ format,
271
+ color = "var(--signal-chart-primary)",
272
+ horizontal = false
273
+ }) {
274
+ const strings = useSignalStrings();
275
+ const count = useNumberFormat();
276
+ const value = format ?? count;
277
+ const id = useId();
278
+ const measured = data.map((d) => d.value).filter((v) => typeof v === "number" && Number.isFinite(v));
279
+ const ticks = chartTicks(measured);
280
+ const domain = [ticks[0], ticks.at(-1)];
281
+ return /* @__PURE__ */ jsxs("figure", { className: "signal-chart-figure", children: [
282
+ /* @__PURE__ */ jsx("figcaption", { id: `${id}-label`, className: "signal-muted signal-chart-help", children: label }),
283
+ /* @__PURE__ */ jsx(
284
+ "div",
285
+ {
286
+ className: `signal-chart${measured.length ? "" : " signal-chart-empty"}`,
287
+ role: "img",
288
+ "aria-labelledby": `${id}-label`,
289
+ "aria-describedby": `${id}-table`,
290
+ children: !measured.length ? /* @__PURE__ */ jsx("p", { className: "signal-muted", children: strings.chart.noMeasurements }) : /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", minWidth: 0, children: /* @__PURE__ */ jsxs(
291
+ RechartsBarChart,
292
+ {
293
+ data,
294
+ layout: horizontal ? "vertical" : "horizontal",
295
+ margin: { top: 8, right: horizontal ? 24 : 8, bottom: 0, left: 0 },
296
+ barCategoryGap: "28%",
297
+ children: [
298
+ /* @__PURE__ */ jsx(
299
+ CartesianGrid,
300
+ {
301
+ vertical: horizontal,
302
+ horizontal: !horizontal,
303
+ stroke: "var(--signal-line)",
304
+ strokeOpacity: 0.7,
305
+ strokeDasharray: "2 6"
306
+ }
307
+ ),
308
+ horizontal ? /* @__PURE__ */ jsxs(Fragment, { children: [
309
+ /* @__PURE__ */ jsx(XAxis, { type: "number", domain, ticks, interval: 0, tickLine: false, axisLine: false, tickFormatter: value, stroke: "var(--signal-muted)" }),
310
+ /* @__PURE__ */ jsx(YAxis, { type: "category", dataKey: "label", tickLine: false, axisLine: false, width: 96, interval: 0, tick: /* @__PURE__ */ jsx(CategoryTick, { side: true }) })
311
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
312
+ /* @__PURE__ */ jsx(XAxis, { dataKey: "label", tickLine: false, axisLine: false, interval: 0, tick: /* @__PURE__ */ jsx(CategoryTick, {}), height: 40 }),
313
+ /* @__PURE__ */ jsx(YAxis, { domain, ticks, interval: 0, tickLine: false, axisLine: false, tickFormatter: value, width: 44, stroke: "var(--signal-muted)" })
314
+ ] }),
315
+ /* @__PURE__ */ jsx(
316
+ Tooltip,
317
+ {
318
+ cursor: { fill: "var(--signal-wash-subtle)" },
319
+ content: ({ active, payload }) => active && payload?.length ? /* @__PURE__ */ jsx("div", { className: "signal-chart-tooltip", children: /* @__PURE__ */ jsxs("strong", { children: [
320
+ String(payload[0].payload.label),
321
+ /* @__PURE__ */ jsx("b", { children: payload[0].value == null ? strings.chart.notRecorded : value(Number(payload[0].value)) })
322
+ ] }) }) : null
323
+ }
324
+ ),
325
+ /* @__PURE__ */ jsx(
326
+ Bar,
327
+ {
328
+ dataKey: "value",
329
+ fill: color,
330
+ radius: 0,
331
+ isAnimationActive: false,
332
+ maxBarSize: 48
333
+ }
334
+ )
335
+ ]
336
+ }
337
+ ) })
338
+ }
339
+ ),
340
+ /* @__PURE__ */ jsxs("details", { className: "signal-chart-table", children: [
341
+ /* @__PURE__ */ jsx("summary", { children: strings.chart.viewValues }),
342
+ /* @__PURE__ */ jsxs("table", { className: "signal-table", id: `${id}-table`, children: [
343
+ /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
344
+ /* @__PURE__ */ jsx("th", { scope: "col", children: strings.chart.category }),
345
+ /* @__PURE__ */ jsx("th", { scope: "col", style: { textAlign: "right" }, children: label })
346
+ ] }) }),
347
+ /* @__PURE__ */ jsx("tbody", { children: data.map((d) => /* @__PURE__ */ jsxs("tr", { children: [
348
+ /* @__PURE__ */ jsx("td", { children: d.label }),
349
+ /* @__PURE__ */ jsx("td", { style: { textAlign: "right" }, children: d.value == null ? strings.chart.notRecorded : value(d.value) })
350
+ ] }, d.label)) })
351
+ ] })
352
+ ] })
353
+ ] });
354
+ }
355
+ function Sparkline({
356
+ data,
357
+ label,
358
+ width = 120,
359
+ height = 32,
360
+ color = "var(--signal-chart-primary)",
361
+ format
362
+ }) {
363
+ const strings = useSignalStrings();
364
+ const count = useNumberFormat();
365
+ const value = format ?? count;
366
+ const values = data.filter((v) => v != null);
367
+ const min = Math.min(0, ...values), max = Math.max(1, ...values), span = max - min || 1;
368
+ const pad = 3;
369
+ const x = (i) => pad + i * (width - pad * 2) / Math.max(1, data.length - 1);
370
+ const y = (v) => height - pad - (v - min) * (height - pad * 2) / span;
371
+ const segments = [];
372
+ let current = [];
373
+ data.forEach((v, i) => {
374
+ if (v == null) {
375
+ if (current.length) segments.push(current.join(" "));
376
+ current = [];
377
+ } else current.push(`${x(i).toFixed(1)},${y(v).toFixed(1)}`);
378
+ });
379
+ if (current.length) segments.push(current.join(" "));
380
+ const lastIndex = data.length - 1 - [...data].reverse().findIndex((v) => v != null);
381
+ const last = data[lastIndex];
382
+ const summary = values.length ? strings.chart.sparkline(
383
+ label,
384
+ values.length,
385
+ value(values[values.length - 1])
386
+ ) : strings.chart.sparklineEmpty(label);
387
+ return /* @__PURE__ */ jsxs(
388
+ "svg",
389
+ {
390
+ className: "signal-sparkline",
391
+ width,
392
+ height,
393
+ viewBox: `0 0 ${width} ${height}`,
394
+ role: "img",
395
+ "aria-label": summary,
396
+ children: [
397
+ /* @__PURE__ */ jsx("title", { children: summary }),
398
+ min < 0 && /* @__PURE__ */ jsx("line", { x1: 0, x2: width, y1: y(0), y2: y(0), stroke: "var(--signal-line)" }),
399
+ segments.map(
400
+ (points, i) => points.includes(" ") ? /* @__PURE__ */ jsx("polyline", { points, fill: "none", stroke: color, strokeWidth: 1.5 }, i) : /* @__PURE__ */ jsx("rect", { x: Number(points.split(",")[0]) - 2, y: Number(points.split(",")[1]) - 2, width: 4, height: 4, fill: color }, i)
401
+ ),
402
+ last != null && /* @__PURE__ */ jsx(
403
+ "rect",
404
+ {
405
+ x: x(lastIndex) - 2.5,
406
+ y: y(last) - 2.5,
407
+ width: 5,
408
+ height: 5,
409
+ fill: "var(--signal-surface)",
410
+ stroke: color,
411
+ strokeWidth: 1.5
412
+ }
413
+ )
414
+ ]
415
+ }
416
+ );
417
+ }
418
+ export {
419
+ BarChart,
420
+ MetricChart,
421
+ Sparkline,
422
+ TechnicalLineChart,
423
+ normalizeDailyData
424
+ };