@schemavaults/ui 0.108.0 → 0.109.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 (67) hide show
  1. package/dist/components/hooks/index.d.ts +2 -0
  2. package/dist/components/hooks/index.js +1 -0
  3. package/dist/components/hooks/index.js.map +1 -1
  4. package/dist/components/hooks/use-measured-width.d.ts +33 -0
  5. package/dist/components/hooks/use-measured-width.js +61 -0
  6. package/dist/components/hooks/use-measured-width.js.map +1 -0
  7. package/dist/components/ui/bar-chart/bar-chart.d.ts +71 -13
  8. package/dist/components/ui/bar-chart/bar-chart.js +263 -96
  9. package/dist/components/ui/bar-chart/bar-chart.js.map +1 -1
  10. package/dist/components/ui/bar-list/bar-list.d.ts +63 -0
  11. package/dist/components/ui/bar-list/bar-list.js +39 -0
  12. package/dist/components/ui/bar-list/bar-list.js.map +1 -0
  13. package/dist/components/ui/bar-list/index.d.ts +2 -0
  14. package/dist/components/ui/bar-list/index.js +2 -0
  15. package/dist/components/ui/bar-list/index.js.map +1 -0
  16. package/dist/components/ui/chart-primitives/chart-colors.d.ts +69 -0
  17. package/dist/components/ui/chart-primitives/chart-colors.js +201 -0
  18. package/dist/components/ui/chart-primitives/chart-colors.js.map +1 -0
  19. package/dist/components/ui/chart-primitives/chart-data-table.d.ts +20 -0
  20. package/dist/components/ui/chart-primitives/chart-data-table.js +11 -0
  21. package/dist/components/ui/chart-primitives/chart-data-table.js.map +1 -0
  22. package/dist/components/ui/chart-primitives/chart-format.d.ts +12 -0
  23. package/dist/components/ui/chart-primitives/chart-format.js +40 -0
  24. package/dist/components/ui/chart-primitives/chart-format.js.map +1 -0
  25. package/dist/components/ui/chart-primitives/chart-legend.d.ts +20 -0
  26. package/dist/components/ui/chart-primitives/chart-legend.js +22 -0
  27. package/dist/components/ui/chart-primitives/chart-legend.js.map +1 -0
  28. package/dist/components/ui/chart-primitives/chart-scale.d.ts +59 -0
  29. package/dist/components/ui/chart-primitives/chart-scale.js +178 -0
  30. package/dist/components/ui/chart-primitives/chart-scale.js.map +1 -0
  31. package/dist/components/ui/chart-primitives/chart-tooltip.d.ts +67 -0
  32. package/dist/components/ui/chart-primitives/chart-tooltip.js +57 -0
  33. package/dist/components/ui/chart-primitives/chart-tooltip.js.map +1 -0
  34. package/dist/components/ui/chart-primitives/index.d.ts +12 -0
  35. package/dist/components/ui/chart-primitives/index.js +7 -0
  36. package/dist/components/ui/chart-primitives/index.js.map +1 -0
  37. package/dist/components/ui/chart-primitives/responsive-chart.d.ts +26 -0
  38. package/dist/components/ui/chart-primitives/responsive-chart.js +25 -0
  39. package/dist/components/ui/chart-primitives/responsive-chart.js.map +1 -0
  40. package/dist/components/ui/chart-primitives/use-chart-width.d.ts +30 -0
  41. package/dist/components/ui/chart-primitives/use-chart-width.js +56 -0
  42. package/dist/components/ui/chart-primitives/use-chart-width.js.map +1 -0
  43. package/dist/components/ui/histogram/bin-values.d.ts +53 -0
  44. package/dist/components/ui/histogram/bin-values.js +137 -0
  45. package/dist/components/ui/histogram/bin-values.js.map +1 -0
  46. package/dist/components/ui/histogram/histogram.d.ts +76 -0
  47. package/dist/components/ui/histogram/histogram.js +149 -0
  48. package/dist/components/ui/histogram/histogram.js.map +1 -0
  49. package/dist/components/ui/histogram/index.d.ts +4 -0
  50. package/dist/components/ui/histogram/index.js +3 -0
  51. package/dist/components/ui/histogram/index.js.map +1 -0
  52. package/dist/components/ui/index.d.ts +6 -0
  53. package/dist/components/ui/index.js +3 -0
  54. package/dist/components/ui/index.js.map +1 -1
  55. package/dist/components/ui/line-chart/line-chart.d.ts +104 -20
  56. package/dist/components/ui/line-chart/line-chart.js +290 -151
  57. package/dist/components/ui/line-chart/line-chart.js.map +1 -1
  58. package/dist/components/ui/pie-chart/pie-chart.d.ts +35 -7
  59. package/dist/components/ui/pie-chart/pie-chart.js +200 -88
  60. package/dist/components/ui/pie-chart/pie-chart.js.map +1 -1
  61. package/dist/components/ui/scatter-plot/scatter-plot.d.ts +123 -21
  62. package/dist/components/ui/scatter-plot/scatter-plot.js +507 -243
  63. package/dist/components/ui/scatter-plot/scatter-plot.js.map +1 -1
  64. package/dist/components/ui/sparkline/sparkline.d.ts +15 -5
  65. package/dist/components/ui/sparkline/sparkline.js +21 -37
  66. package/dist/components/ui/sparkline/sparkline.js.map +1 -1
  67. package/package.json +3 -2
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bar-list.js","sourceRoot":"","sources":["../../../../src/components/ui/bar-list/bar-list.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAIb,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,EACL,eAAe,EACf,qBAAqB,GAGtB,MAAM,+CAA+C,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAoDlF,SAAS,aAAa,CAAC,KAAa;IAClC,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AACzD,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,OAAO,CAAC,EACf,KAAK,EACL,KAAK,EACL,KAAK,GAAG,SAAS,EACjB,IAAI,EACJ,GAAG,EACH,WAAW,GAAG,iBAAiB,EAC/B,QAAQ,EACR,WAAW,GAAG,EAAE,EAChB,YAAY,GAAG,SAAS,EACxB,cAAc,EACd,OAAO,GAAG,KAAK,EACf,SAAS,EACT,GAAG,EACH,GAAG,KAAK,EACK;IACb,MAAM,MAAM,GAAa,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IACxE,MAAM,QAAQ,GACZ,GAAG,KAAK,SAAS,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC;QAClD,CAAC,CAAC,GAAG;QACL,CAAC,CAAC,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A6C,YAC1D,IAAI,CAAC,UAAU,IAAI,WAAW,CAAC,KAAK,CAAC,GACjC,IACF,EACP,gBAAM,SAAS,EAAC,gCAAgC,aAC9C,eAAM,SAAS,EAAC,0BAA0B,YACxC,4BACY,cAAc,EACxB,SAAS,EAAE,EAAE,CACX,2BAA2B,EAC3B,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,CAC7B,EACD,KAAK,EAAE;4CACL,KAAK,EAAE,GAAG,OAAO,GAAG;4CACpB,GAAG,qBAAqB,CAAC,KAAK,CAAC;yCAChC,GACD,GACG,EACN,IAAI,CAAC,MAAM,KAAK,SAAS,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,CACnD,eAAM,SAAS,EAAC,qDAAqD,YAClE,IAAI,CAAC,MAAM,GACP,CACR,CAAC,CAAC,CAAC,IAAI,IACH,IACN,CACJ,CAAC;gBACF,OAAO,CACL,0BAA4B,eAAe,YACxC,QAAQ,CAAC,CAAC,CAAC,CACV,iBACE,IAAI,EAAC,QAAQ,kBACC,QAAQ,EACtB,OAAO,EAAE,GAAS,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,EACnC,SAAS,EAAE,EAAE,CACX,yKAAyK,EACzK,QAAQ,IAAI,UAAU,CACvB,YAEA,OAAO,GACD,CACV,CAAC,CAAC,CAAC,CACF,cAAK,SAAS,EAAC,wCAAwC,YACpD,OAAO,GACJ,CACP,IAjBM,IAAI,CAAC,EAAE,CAkBX,CACN,CAAC;YACJ,CAAC,CAAC,GACC,CACN,GACG,CACP,CAAC;AACJ,CAAC;AACD,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC;AAEhC,OAAO,EAAE,OAAO,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./bar-list";
2
+ export type * from "./bar-list";
@@ -0,0 +1,2 @@
1
+ export * from "./bar-list";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/ui/bar-list/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
@@ -0,0 +1,69 @@
1
+ import type { CSSProperties } from "react";
2
+ /**
3
+ * The categorical chart palette from `@schemavaults/theme` (0.29.0+):
4
+ * `--chart-1` … `--chart-8` for series in slot order, and `--chart-other`
5
+ * for the de-emphasis grey.
6
+ *
7
+ * Every reference carries the light-mode value as its `var()` fallback, so a
8
+ * chart still draws the right hues against an older `globals.css` that does
9
+ * not define the tokens yet (it just keeps the light steps in dark mode).
10
+ *
11
+ * Slots are assigned in order and never cycled: a series past the last slot
12
+ * is painted `"other"`. Colour follows the series id, not its position, when
13
+ * a chart is given its full `seriesOrder`.
14
+ */
15
+ export declare const chartSeriesColorIds: ["chart-1", "chart-2", "chart-3", "chart-4", "chart-5", "chart-6", "chart-7", "chart-8"];
16
+ export type ChartSeriesColorId = (typeof chartSeriesColorIds)[number];
17
+ /**
18
+ * Every preset a chart mark can be painted with:
19
+ * - `chart-1` … `chart-8`: the categorical series slots (identity)
20
+ * - `other`: the de-emphasis grey for folded tails and overflow buckets
21
+ * - `default`: slot 1, the colour a single-series chart uses
22
+ * - `brand`: the SchemaVaults brand blue, as an explicit choice
23
+ * - `positive`, `warning`, `destructive`: status colours, for series that
24
+ * mean good or bad (pair them with a label; never rely on hue alone)
25
+ * - `primary`, `muted`: theme ink
26
+ */
27
+ export declare const chartColorIds: ["chart-1", "chart-2", "chart-3", "chart-4", "chart-5", "chart-6", "chart-7", "chart-8", "other", "default", "brand", "primary", "positive", "warning", "destructive", "muted"];
28
+ export type ChartColorId = (typeof chartColorIds)[number];
29
+ /** The palette's size; a ninth series folds into `"other"`. */
30
+ export declare const CHART_SERIES_SLOT_COUNT: number;
31
+ /** The series colours as CSS values, for custom charts and legends. */
32
+ export declare const CHART_SERIES_COLORS: readonly string[];
33
+ /** The de-emphasis grey as a CSS value. */
34
+ export declare const CHART_OTHER_COLOR: string;
35
+ export interface ChartColorClasses {
36
+ /** SVG fill (`fill-*`). */
37
+ fill: string;
38
+ /** SVG stroke (`stroke-*`). */
39
+ stroke: string;
40
+ /** HTML background (`bg-*`), for legend swatches and tooltip keys. */
41
+ bg: string;
42
+ /** Text colour (`text-*`), for `currentColor` gradients. Never for labels. */
43
+ text: string;
44
+ }
45
+ /** The Tailwind classes that paint a preset colour onto a mark or swatch. */
46
+ export declare function getChartColorClasses(colorId: ChartColorId): ChartColorClasses;
47
+ /**
48
+ * The preset for the series in position `index` (0-based) when it names no
49
+ * colour of its own: slot `index + 1`, or `"other"` once the palette (or
50
+ * `maxSlots`, for charts that may colour fewer series) is used up.
51
+ */
52
+ export declare function getChartSeriesColorId(index: number, maxSlots?: number): ChartColorId;
53
+ /**
54
+ * Colour follows the entity: maps each id to the slot of its position in
55
+ * `seriesIds`, the full, unfiltered list of everything the chart can show.
56
+ * Filtering a series out of the chart then never repaints the others, and
57
+ * an id the list does not know is painted `"other"`.
58
+ */
59
+ export declare function createChartColorScale(seriesIds: readonly string[], maxSlots?: number): (id: string) => ChartColorId;
60
+ /** How a mark is painted: a preset through classes, or a raw CSS colour. */
61
+ export interface ChartPaint {
62
+ colorId: ChartColorId;
63
+ /** A raw CSS colour that overrides the preset. */
64
+ value?: string;
65
+ }
66
+ /** The class that paints `part` of a mark, or `undefined` when a raw colour wins. */
67
+ export declare function chartPaintClass(paint: ChartPaint, part: keyof ChartColorClasses): string | undefined;
68
+ /** Inline style for an HTML swatch of `paint` (legend, tooltip key). */
69
+ export declare function chartPaintSwatchStyle(paint: ChartPaint): CSSProperties | undefined;
@@ -0,0 +1,201 @@
1
+ /**
2
+ * The categorical chart palette from `@schemavaults/theme` (0.29.0+):
3
+ * `--chart-1` … `--chart-8` for series in slot order, and `--chart-other`
4
+ * for the de-emphasis grey.
5
+ *
6
+ * Every reference carries the light-mode value as its `var()` fallback, so a
7
+ * chart still draws the right hues against an older `globals.css` that does
8
+ * not define the tokens yet (it just keeps the light steps in dark mode).
9
+ *
10
+ * Slots are assigned in order and never cycled: a series past the last slot
11
+ * is painted `"other"`. Colour follows the series id, not its position, when
12
+ * a chart is given its full `seriesOrder`.
13
+ */
14
+ export const chartSeriesColorIds = [
15
+ "chart-1",
16
+ "chart-2",
17
+ "chart-3",
18
+ "chart-4",
19
+ "chart-5",
20
+ "chart-6",
21
+ "chart-7",
22
+ "chart-8",
23
+ ];
24
+ /**
25
+ * Every preset a chart mark can be painted with:
26
+ * - `chart-1` … `chart-8`: the categorical series slots (identity)
27
+ * - `other`: the de-emphasis grey for folded tails and overflow buckets
28
+ * - `default`: slot 1, the colour a single-series chart uses
29
+ * - `brand`: the SchemaVaults brand blue, as an explicit choice
30
+ * - `positive`, `warning`, `destructive`: status colours, for series that
31
+ * mean good or bad (pair them with a label; never rely on hue alone)
32
+ * - `primary`, `muted`: theme ink
33
+ */
34
+ export const chartColorIds = [
35
+ ...chartSeriesColorIds,
36
+ "other",
37
+ "default",
38
+ "brand",
39
+ "primary",
40
+ "positive",
41
+ "warning",
42
+ "destructive",
43
+ "muted",
44
+ ];
45
+ /** The palette's size; a ninth series folds into `"other"`. */
46
+ export const CHART_SERIES_SLOT_COUNT = chartSeriesColorIds.length;
47
+ /** The series colours as CSS values, for custom charts and legends. */
48
+ export const CHART_SERIES_COLORS = [
49
+ "var(--chart-1, #2a78d6)",
50
+ "var(--chart-2, #eb6834)",
51
+ "var(--chart-3, #1baf7a)",
52
+ "var(--chart-4, #eda100)",
53
+ "var(--chart-5, #e87ba4)",
54
+ "var(--chart-6, #008300)",
55
+ "var(--chart-7, #4a3aa7)",
56
+ "var(--chart-8, #e34948)",
57
+ ];
58
+ /** The de-emphasis grey as a CSS value. */
59
+ export const CHART_OTHER_COLOR = "var(--chart-other, #898781)";
60
+ // Written out in full so Tailwind finds every class when it scans the
61
+ // package; the arbitrary values keep working against a theme that predates
62
+ // the chart tokens.
63
+ const CHART_COLOR_CLASSES = {
64
+ "chart-1": {
65
+ fill: "fill-[color:var(--chart-1,#2a78d6)]",
66
+ stroke: "stroke-[color:var(--chart-1,#2a78d6)]",
67
+ bg: "bg-[color:var(--chart-1,#2a78d6)]",
68
+ text: "text-[color:var(--chart-1,#2a78d6)]",
69
+ },
70
+ "chart-2": {
71
+ fill: "fill-[color:var(--chart-2,#eb6834)]",
72
+ stroke: "stroke-[color:var(--chart-2,#eb6834)]",
73
+ bg: "bg-[color:var(--chart-2,#eb6834)]",
74
+ text: "text-[color:var(--chart-2,#eb6834)]",
75
+ },
76
+ "chart-3": {
77
+ fill: "fill-[color:var(--chart-3,#1baf7a)]",
78
+ stroke: "stroke-[color:var(--chart-3,#1baf7a)]",
79
+ bg: "bg-[color:var(--chart-3,#1baf7a)]",
80
+ text: "text-[color:var(--chart-3,#1baf7a)]",
81
+ },
82
+ "chart-4": {
83
+ fill: "fill-[color:var(--chart-4,#eda100)]",
84
+ stroke: "stroke-[color:var(--chart-4,#eda100)]",
85
+ bg: "bg-[color:var(--chart-4,#eda100)]",
86
+ text: "text-[color:var(--chart-4,#eda100)]",
87
+ },
88
+ "chart-5": {
89
+ fill: "fill-[color:var(--chart-5,#e87ba4)]",
90
+ stroke: "stroke-[color:var(--chart-5,#e87ba4)]",
91
+ bg: "bg-[color:var(--chart-5,#e87ba4)]",
92
+ text: "text-[color:var(--chart-5,#e87ba4)]",
93
+ },
94
+ "chart-6": {
95
+ fill: "fill-[color:var(--chart-6,#008300)]",
96
+ stroke: "stroke-[color:var(--chart-6,#008300)]",
97
+ bg: "bg-[color:var(--chart-6,#008300)]",
98
+ text: "text-[color:var(--chart-6,#008300)]",
99
+ },
100
+ "chart-7": {
101
+ fill: "fill-[color:var(--chart-7,#4a3aa7)]",
102
+ stroke: "stroke-[color:var(--chart-7,#4a3aa7)]",
103
+ bg: "bg-[color:var(--chart-7,#4a3aa7)]",
104
+ text: "text-[color:var(--chart-7,#4a3aa7)]",
105
+ },
106
+ "chart-8": {
107
+ fill: "fill-[color:var(--chart-8,#e34948)]",
108
+ stroke: "stroke-[color:var(--chart-8,#e34948)]",
109
+ bg: "bg-[color:var(--chart-8,#e34948)]",
110
+ text: "text-[color:var(--chart-8,#e34948)]",
111
+ },
112
+ other: {
113
+ fill: "fill-[color:var(--chart-other,#898781)]",
114
+ stroke: "stroke-[color:var(--chart-other,#898781)]",
115
+ bg: "bg-[color:var(--chart-other,#898781)]",
116
+ text: "text-[color:var(--chart-other,#898781)]",
117
+ },
118
+ default: {
119
+ fill: "fill-[color:var(--chart-1,#2a78d6)]",
120
+ stroke: "stroke-[color:var(--chart-1,#2a78d6)]",
121
+ bg: "bg-[color:var(--chart-1,#2a78d6)]",
122
+ text: "text-[color:var(--chart-1,#2a78d6)]",
123
+ },
124
+ brand: {
125
+ fill: "fill-schemavaults-brand-blue",
126
+ stroke: "stroke-schemavaults-brand-blue",
127
+ bg: "bg-schemavaults-brand-blue",
128
+ text: "text-schemavaults-brand-blue",
129
+ },
130
+ primary: {
131
+ fill: "fill-primary",
132
+ stroke: "stroke-primary",
133
+ bg: "bg-primary",
134
+ text: "text-primary",
135
+ },
136
+ positive: {
137
+ fill: "fill-emerald-500 dark:fill-emerald-400",
138
+ stroke: "stroke-emerald-500 dark:stroke-emerald-400",
139
+ bg: "bg-emerald-500 dark:bg-emerald-400",
140
+ text: "text-emerald-500 dark:text-emerald-400",
141
+ },
142
+ warning: {
143
+ fill: "fill-warning",
144
+ stroke: "stroke-warning",
145
+ bg: "bg-warning",
146
+ text: "text-warning",
147
+ },
148
+ destructive: {
149
+ fill: "fill-destructive",
150
+ stroke: "stroke-destructive",
151
+ bg: "bg-destructive",
152
+ text: "text-destructive",
153
+ },
154
+ muted: {
155
+ fill: "fill-muted-foreground",
156
+ stroke: "stroke-muted-foreground",
157
+ bg: "bg-muted-foreground",
158
+ text: "text-muted-foreground",
159
+ },
160
+ };
161
+ /** The Tailwind classes that paint a preset colour onto a mark or swatch. */
162
+ export function getChartColorClasses(colorId) {
163
+ return CHART_COLOR_CLASSES[colorId];
164
+ }
165
+ /**
166
+ * The preset for the series in position `index` (0-based) when it names no
167
+ * colour of its own: slot `index + 1`, or `"other"` once the palette (or
168
+ * `maxSlots`, for charts that may colour fewer series) is used up.
169
+ */
170
+ export function getChartSeriesColorId(index, maxSlots = CHART_SERIES_SLOT_COUNT) {
171
+ const slots = Math.max(0, Math.min(maxSlots, CHART_SERIES_SLOT_COUNT));
172
+ if (!Number.isInteger(index) || index < 0 || index >= slots)
173
+ return "other";
174
+ return chartSeriesColorIds[index];
175
+ }
176
+ /**
177
+ * Colour follows the entity: maps each id to the slot of its position in
178
+ * `seriesIds`, the full, unfiltered list of everything the chart can show.
179
+ * Filtering a series out of the chart then never repaints the others, and
180
+ * an id the list does not know is painted `"other"`.
181
+ */
182
+ export function createChartColorScale(seriesIds, maxSlots = CHART_SERIES_SLOT_COUNT) {
183
+ const slotById = new Map();
184
+ for (const id of seriesIds) {
185
+ if (!slotById.has(id))
186
+ slotById.set(id, slotById.size);
187
+ }
188
+ return (id) => {
189
+ const slot = slotById.get(id);
190
+ return slot === undefined ? "other" : getChartSeriesColorId(slot, maxSlots);
191
+ };
192
+ }
193
+ /** The class that paints `part` of a mark, or `undefined` when a raw colour wins. */
194
+ export function chartPaintClass(paint, part) {
195
+ return paint.value ? undefined : CHART_COLOR_CLASSES[paint.colorId][part];
196
+ }
197
+ /** Inline style for an HTML swatch of `paint` (legend, tooltip key). */
198
+ export function chartPaintSwatchStyle(paint) {
199
+ return paint.value ? { backgroundColor: paint.value } : undefined;
200
+ }
201
+ //# sourceMappingURL=chart-colors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chart-colors.js","sourceRoot":"","sources":["../../../../src/components/ui/chart-primitives/chart-colors.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;CACkB,CAAC;AAG9B;;;;;;;;;GASG;AACH,MAAM,CAA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;AASD,qFAAqF;AACrF,MAAM,UAAU,eAAe,CAC7B,KAAiB,EACjB,IAA6B;IAE7B,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,mBAAmB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC;AAC5E,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,qBAAqB,CACnC,KAAiB;IAEjB,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AACpE,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { ReactElement, ReactNode } from "react";
2
+ export interface ChartDataTableRow {
3
+ key: string;
4
+ /** The first cell becomes the row header. */
5
+ cells: ReadonlyArray<ReactNode>;
6
+ }
7
+ export interface ChartDataTableProps {
8
+ caption: ReactNode;
9
+ columns: ReadonlyArray<ReactNode>;
10
+ rows: ReadonlyArray<ChartDataTableRow>;
11
+ }
12
+ /**
13
+ * The table view of a chart, visually hidden: every value a chart draws is
14
+ * reachable without the chart, so hover is never the only way to read it.
15
+ */
16
+ declare function ChartDataTable({ caption, columns, rows, }: ChartDataTableProps): ReactElement;
17
+ declare namespace ChartDataTable {
18
+ var displayName: string;
19
+ }
20
+ export { ChartDataTable };
@@ -0,0 +1,11 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * The table view of a chart, visually hidden: every value a chart draws is
4
+ * reachable without the chart, so hover is never the only way to read it.
5
+ */
6
+ function ChartDataTable({ caption, columns, rows, }) {
7
+ return (_jsxs("table", { "data-slot": "chart-data-table", className: "sr-only", children: [_jsx("caption", { children: caption }), _jsx("thead", { children: _jsx("tr", { children: columns.map((column, index) => (_jsx("th", { scope: "col", children: column }, index))) }) }), _jsx("tbody", { children: rows.map((row) => (_jsx("tr", { children: row.cells.map((cell, index) => index === 0 ? (_jsx("th", { scope: "row", children: cell }, index)) : (_jsx("td", { children: cell }, index))) }, row.key))) })] }));
8
+ }
9
+ ChartDataTable.displayName = "ChartDataTable";
10
+ export { ChartDataTable };
11
+ //# sourceMappingURL=chart-data-table.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chart-data-table.js","sourceRoot":"","sources":["../../../../src/components/ui/chart-primitives/chart-data-table.tsx"],"names":[],"mappings":";AAcA;;;GAGG;AACH,SAAS,cAAc,CAAC,EACtB,OAAO,EACP,OAAO,EACP,IAAI,GACgB;IACpB,OAAO,CACL,8BAAiB,kBAAkB,EAAC,SAAS,EAAC,SAAS,aACrD,4BAAU,OAAO,GAAW,EAC5B,0BACE,uBACG,OAAO,CAAC,GAAG,CACV,CAAC,MAAiB,EAAE,KAAa,EAAgB,EAAE,CAAC,CAClD,aAAgB,KAAK,EAAC,KAAK,YACxB,MAAM,IADA,KAAK,CAET,CACN,CACF,GACE,GACC,EACR,0BACG,IAAI,CAAC,GAAG,CACP,CAAC,GAAsB,EAAgB,EAAE,CAAC,CACxC,uBACG,GAAG,CAAC,KAAK,CAAC,GAAG,CACZ,CAAC,IAAe,EAAE,KAAa,EAAgB,EAAE,CAC/C,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CACZ,aAAgB,KAAK,EAAC,KAAK,YACxB,IAAI,IADE,KAAK,CAET,CACN,CAAC,CAAC,CAAC,CACF,uBAAiB,IAAI,IAAZ,KAAK,CAAa,CAC5B,CACJ,IAVM,GAAG,CAAC,GAAG,CAWX,CACN,CACF,GACK,IACF,CACT,CAAC;AACJ,CAAC;AACD,cAAc,CAAC,WAAW,GAAG,gBAAgB,CAAC;AAE9C,OAAO,EAAE,cAAc,EAAE,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Default number formatting for chart ticks and readouts: thousands
3
+ * separators and no float noise (`12,500`, `0.35`, `1.5`).
4
+ *
5
+ * The locale is pinned so the server render and the browser agree (a
6
+ * locale-dependent default would be a hydration mismatch); pass a chart's
7
+ * `formatX` / `formatY` / `formatValue` for units or another locale.
8
+ */
9
+ /** A readout value: up to two decimals, more for values under 1. */
10
+ export declare function formatChartNumber(value: number): string;
11
+ /** A tick label, with only as many decimals as the tick `step` needs. */
12
+ export declare function formatChartTick(value: number, step: number): string;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Default number formatting for chart ticks and readouts: thousands
3
+ * separators and no float noise (`12,500`, `0.35`, `1.5`).
4
+ *
5
+ * The locale is pinned so the server render and the browser agree (a
6
+ * locale-dependent default would be a hydration mismatch); pass a chart's
7
+ * `formatX` / `formatY` / `formatValue` for units or another locale.
8
+ */
9
+ const FORMATTERS = new Map();
10
+ function numberFormat(maximumFractionDigits) {
11
+ const digits = Math.max(0, Math.min(20, Math.round(maximumFractionDigits)));
12
+ let formatter = FORMATTERS.get(digits);
13
+ if (!formatter) {
14
+ formatter = new Intl.NumberFormat("en-US", {
15
+ maximumFractionDigits: digits,
16
+ });
17
+ FORMATTERS.set(digits, formatter);
18
+ }
19
+ return formatter;
20
+ }
21
+ /** A readout value: up to two decimals, more for values under 1. */
22
+ export function formatChartNumber(value) {
23
+ if (!Number.isFinite(value))
24
+ return "—";
25
+ const magnitude = Math.abs(value);
26
+ const digits = magnitude === 0 || magnitude >= 1
27
+ ? 2
28
+ : Math.min(6, 1 - Math.floor(Math.log10(magnitude)));
29
+ return numberFormat(digits).format(value);
30
+ }
31
+ /** A tick label, with only as many decimals as the tick `step` needs. */
32
+ export function formatChartTick(value, step) {
33
+ if (!Number.isFinite(value))
34
+ return "";
35
+ const digits = Number.isFinite(step) && step > 0 && step < 1
36
+ ? Math.min(6, Math.ceil(-Math.log10(step) - 1e-9))
37
+ : 0;
38
+ return numberFormat(digits).format(value);
39
+ }
40
+ //# sourceMappingURL=chart-format.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chart-format.js","sourceRoot":"","sources":["../../../../src/components/ui/chart-primitives/chart-format.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;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MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC;QAC3C,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;QAClD,CAAC,CAAC,CAAC,CAAC;IACR,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC5C,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { ReactElement, ReactNode } from "react";
2
+ import { type ChartPaint } from "./chart-colors";
3
+ /** The swatch mirrors the mark: a line for lines, a square for bars, the marker shape for points. */
4
+ export type ChartLegendSwatch = "line" | "square" | "circle" | "triangle" | "diamond";
5
+ export interface ChartLegendItem {
6
+ id: string;
7
+ label: ReactNode;
8
+ paint: ChartPaint;
9
+ swatch: ChartLegendSwatch;
10
+ }
11
+ export interface ChartLegendProps {
12
+ items: ReadonlyArray<ChartLegendItem>;
13
+ className?: string;
14
+ }
15
+ /** A wrapping row of series keys for a chart with two or more series. */
16
+ declare function ChartLegend({ items, className }: ChartLegendProps): ReactElement;
17
+ declare namespace ChartLegend {
18
+ var displayName: string;
19
+ }
20
+ export { ChartLegend };
@@ -0,0 +1,22 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { cn } from "../../../lib/utils";
4
+ import { chartPaintClass, chartPaintSwatchStyle, } from "./chart-colors";
5
+ const MARKER_PATHS = {
6
+ circle: "M1 5a4 4 0 1 0 8 0a4 4 0 1 0 -8 0Z",
7
+ triangle: "M5 0.2L9.6 8.8H0.4Z",
8
+ diamond: "M5 0L10 5L5 10L0 5Z",
9
+ };
10
+ function Swatch({ swatch, paint, }) {
11
+ if (swatch === "line" || swatch === "square") {
12
+ return (_jsx("span", { "aria-hidden": "true", className: cn("inline-block shrink-0", swatch === "line" ? "h-0.5 w-4 rounded-full" : "size-2.5 rounded-[2px]", chartPaintClass(paint, "bg")), style: chartPaintSwatchStyle(paint) }));
13
+ }
14
+ return (_jsx("svg", { "aria-hidden": "true", width: 10, height: 10, viewBox: "0 0 10 10", className: "shrink-0", children: _jsx("path", { d: MARKER_PATHS[swatch], fill: paint.value, className: chartPaintClass(paint, "fill") }) }));
15
+ }
16
+ /** A wrapping row of series keys for a chart with two or more series. */
17
+ function ChartLegend({ items, className }) {
18
+ return (_jsx("ul", { "aria-label": "Legend", "data-slot": "chart-legend", className: cn("flex flex-row flex-wrap gap-x-4 gap-y-1 text-xs text-muted-foreground", className), children: items.map((item) => (_jsxs("li", { className: "flex min-w-0 items-center gap-1.5", children: [_jsx(Swatch, { swatch: item.swatch, paint: item.paint }), _jsx("span", { className: "truncate", children: item.label })] }, item.id))) }));
19
+ }
20
+ ChartLegend.displayName = "ChartLegend";
21
+ export { ChartLegend };
22
+ //# sourceMappingURL=chart-legend.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chart-legend.js","sourceRoot":"","sources":["../../../../src/components/ui/chart-primitives/chart-legend.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAIb,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEjC,OAAO,EACL,eAAe,EACf,qBAAqB,GAEtB,MAAM,gBAAgB,CAAC;AAsBxB,MAAM,YAAY,GAAsD;IACtE,MAAM,EAAE,oCAAoC;IAC5C,QAAQ,EAAE,qBAAqB;IAC/B,OAAO,EAAE,qBAAqB;CAC/B,CAAC;AAEF,SAAS,MAAM,CAAC,EACd,MAAM,EACN,KAAK,GAIN;IACC,IAAI,MAAM,KAAK,MAAM,IAAI,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC7C,OAAO,CACL,8BACc,MAAM,EAClB,SAAS,EAAE,EAAE,CACX,uBAAuB,EACvB,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,wBAAwB,EACvE,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,CAC7B,EACD,KAAK,EAAE,qBAAqB,CAAC,KAAK,CAAC,GACnC,CACH,CAAC;IACJ,CAAC;IACD,OAAO,CACL,6BACc,MAAM,EAClB,KAAK,EAAE,EAAE,EACT,MAAM,EAAE,EAAE,EACV,OAAO,EAAC,WAAW,EACnB,SAAS,EAAC,UAAU,YAEpB,eACE,CAAC,EAAE,YAAY,CAAC,MAAM,CAAC,EACvB,IAAI,EAAE,KAAK,CAAC,KAAK,EACjB,SAAS,EAAE,eAAe,CAAC,KAAK,EAAE,MAAM,CAAC,GACzC,GACE,CACP,CAAC;AACJ,CAAC;AAED,yEAAyE;AACzE,SAAS,WAAW,CAAC,EAAE,KAAK,EAAE,SAAS,EAAoB;IACzD,OAAO,CACL,2BACa,QAAQ,eACT,cAAc,EACxB,SAAS,EAAE,EAAE,CACX,uEAAuE,EACvE,SAAS,CACV,YAEA,KAAK,CAAC,GAAG,CACR,CAAC,IAAqB,EAAgB,EAAE,CAAC,CACvC,cAAkB,SAAS,EAAC,mCAAmC,aAC7D,KAAC,MAAM,IAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,GAAI,EAClD,eAAM,SAAS,EAAC,UAAU,YAAE,IAAI,CAAC,KAAK,GAAQ,KAFvC,IAAI,CAAC,EAAE,CAGX,CACN,CACF,GACE,CACN,CAAC;AACJ,CAAC;AACD,WAAW,CAAC,WAAW,GAAG,aAAa,CAAC;AAExC,OAAO,EAAE,WAAW,EAAE,CAAC"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Framework-free geometry and tick helpers shared by the chart components.
3
+ */
4
+ /**
5
+ * The smallest "nice" step (1, 2 or 5 × 10^k) that is at least `rawStep`,
6
+ * never below `minStep` (1 for whole-number data such as counts).
7
+ */
8
+ export declare function niceStep(rawStep: number, minStep?: number): number;
9
+ /** Rounds away float drift (0.1 + 0.2) so tick labels stay clean. */
10
+ export declare function cleanNumber(value: number): number;
11
+ export interface NiceAxis {
12
+ ticks: number[];
13
+ /** The last tick: the top of the scale. */
14
+ top: number;
15
+ step: number;
16
+ }
17
+ /**
18
+ * A zero-based value axis: nice ticks from 0 up to the first tick at or
19
+ * above `max`, with about `target` intervals.
20
+ */
21
+ export declare function niceAxis(max: number, target?: number, minStep?: number): NiceAxis;
22
+ /**
23
+ * Log-scale ticks at whole decades covering `[min, max]`. The bottom decade
24
+ * is the one holding the smallest positive value, so zeros and negatives
25
+ * (which a log scale cannot place) sit on the bottom line.
26
+ */
27
+ export declare function logDecadeTicks(min: number, max: number): number[];
28
+ /** Evenly spaced indices (always the first and last) so at most `maxLabels` labels render. */
29
+ export declare function thinIndices(count: number, maxLabels: number): number[];
30
+ /** Index of the value in ascending `sorted` closest to `target`; -1 when empty. */
31
+ export declare function nearestSortedIndex(sorted: readonly number[], target: number): number;
32
+ export type BarFreeEnd = "top" | "right";
33
+ /**
34
+ * SVG path of a bar with its free end rounded (`radius`, clamped to the
35
+ * bar's size) and a square end on the baseline: the top for columns, the
36
+ * right for horizontal bars.
37
+ */
38
+ export declare function roundedBarPath(x: number, y: number, width: number, height: number, radius: number, freeEnd?: BarFreeEnd): string;
39
+ /**
40
+ * The 1, 2 or 5 × 10^k step that splits `span` into the count of intervals
41
+ * closest to `count` (d3's rounding), rather than the next one up.
42
+ */
43
+ export declare function closestNiceStep(span: number, count: number): number;
44
+ /**
45
+ * Round tick values inside `[min, max]` (the domain itself is left alone),
46
+ * about `count` intervals apart and at least `minStep` (1 for indices).
47
+ */
48
+ export declare function niceTicksWithin(min: number, max: number, count: number, minStep?: number): number[];
49
+ /** Rough width of a tick label: SVG text can't be measured before it renders. */
50
+ export declare function estimateLabelWidth(text: string, fontPx: number): number;
51
+ /**
52
+ * Drops axis labels that would overlap their neighbour at `fontPx`, keeping
53
+ * the first and (when it fits) the last, so ticks thin out on a narrow chart
54
+ * instead of running together.
55
+ */
56
+ export declare function thinLabels<T extends {
57
+ x: number;
58
+ text: string;
59
+ }>(labels: ReadonlyArray<T>, fontPx: number, minGap?: number): T[];