@schemavaults/ui 0.108.0 → 0.109.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.
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 +285 -139
  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
@@ -1,9 +1,12 @@
1
1
  import { type VariantProps } from "class-variance-authority";
2
2
  import type { HTMLAttributes, KeyboardEvent, MouseEvent, ReactElement, ReactNode, Ref } from "react";
3
+ import { type ChartColorId, type ChartPaint } from "../../ui/chart-primitives/chart-colors";
4
+ import { type ChartWidth } from "../../ui/chart-primitives/use-chart-width";
3
5
  export declare const lineChartSizeIds: ["sm", "md", "lg", "xl"];
4
6
  export type LineChartSizeId = (typeof lineChartSizeIds)[number];
5
- export declare const lineChartColorIds: ["default", "primary", "positive", "warning", "destructive", "muted"];
6
- export type LineChartColorId = (typeof lineChartColorIds)[number];
7
+ /** Preset series colours; see `chartColorIds`. */
8
+ export declare const lineChartColorIds: ["chart-1", "chart-2", "chart-3", "chart-4", "chart-5", "chart-6", "chart-7", "chart-8", "other", "default", "brand", "primary", "positive", "warning", "destructive", "muted"];
9
+ export type LineChartColorId = ChartColorId;
7
10
  export declare const lineChartCurveIds: ["linear", "smooth"];
8
11
  export type LineChartCurveId = (typeof lineChartCurveIds)[number];
9
12
  export declare const lineChartVariants: (props?: ({
@@ -32,11 +35,15 @@ export interface LineChartSeries {
32
35
  label?: string;
33
36
  /** Points in plot order. */
34
37
  points: ReadonlyArray<LineChartPoint>;
35
- /** Preset color id from the chart palette. Ignored if `stroke` is provided. */
38
+ /**
39
+ * Preset color. Defaults to the series' palette slot: its position in
40
+ * `seriesOrder` when the chart has one, else in `series`. Ignored if
41
+ * `stroke` is provided.
42
+ */
36
43
  color?: LineChartColorId;
37
44
  /**
38
45
  * Override the stroke with a raw CSS color (e.g. `"#ff0080"` or
39
- * `"hsl(var(--chart-1))"`). Takes precedence over `color`.
46
+ * `"var(--chart-3)"`). Takes precedence over `color`.
40
47
  */
41
48
  stroke?: string;
42
49
  /** Fill the area between this series' line and the baseline. */
@@ -60,19 +67,48 @@ export interface LineChartValueLabelContext {
60
67
  value: number;
61
68
  index: number;
62
69
  }
70
+ export interface LineChartTooltipValue {
71
+ series: LineChartSeries;
72
+ /** The series' point at this x, if it has one. */
73
+ point: LineChartPoint | undefined;
74
+ /** `null` when the series has no finite value at this x. */
75
+ value: number | null;
76
+ /** `formatY(value)`, or `"—"` for no value. */
77
+ formattedValue: string;
78
+ paint: ChartPaint;
79
+ }
80
+ export interface LineChartTooltipContext {
81
+ /** The x the crosshair snapped to, in domain units (the index in categorical mode). */
82
+ x: number;
83
+ /** The x as the tooltip heading shows it. */
84
+ xLabel: string;
85
+ /** One entry per series, in series order. */
86
+ values: ReadonlyArray<LineChartTooltipValue>;
87
+ }
63
88
  export interface LineChartProps extends Omit<HTMLAttributes<HTMLDivElement>, "onClick">, VariantProps<typeof lineChartVariants> {
64
89
  /** Series to render, in order (later series are drawn on top). */
65
90
  series: ReadonlyArray<LineChartSeries>;
66
91
  /** Accessible label describing what the chart represents. */
67
92
  label: string;
68
93
  /**
69
- * Override the rendered canvas width in pixels (defaults are size-aware).
94
+ * Canvas width in pixels (defaults are size-aware), or `"auto"` to fill the
95
+ * container and redraw when it resizes. An `"auto"` chart renders an empty
96
+ * placeholder at its height until it has been measured, so the server
97
+ * render carries no pixel width and no tick labels.
70
98
  */
71
- width?: number;
99
+ width?: ChartWidth;
72
100
  /**
73
101
  * Override the rendered canvas height in pixels (defaults are size-aware).
102
+ * A legend, when shown, sits above this box.
74
103
  */
75
104
  height?: number;
105
+ /**
106
+ * Every series id the chart can show, in colour-slot order. Pass the full,
107
+ * unfiltered list and a series you filter out of `series` never repaints
108
+ * the others: colour follows the series, not its position. Ids missing
109
+ * from the list are painted `"other"`.
110
+ */
111
+ seriesOrder?: ReadonlyArray<string>;
76
112
  /** Lower bound of the y-axis. Defaults to the smallest value across series. */
77
113
  yMin?: number;
78
114
  /** Upper bound of the y-axis. Defaults to the largest value across series. */
@@ -89,7 +125,8 @@ export interface LineChartProps extends Omit<HTMLAttributes<HTMLDivElement>, "on
89
125
  showAxis?: boolean;
90
126
  /**
91
127
  * Number of evenly-spaced horizontal gridlines drawn across the value axis.
92
- * `0` disables gridlines. Defaults to `0`.
128
+ * `0` disables gridlines. Defaults to `0`. With y-axis labels shown, any
129
+ * non-zero count draws a hairline at each tick instead.
93
130
  */
94
131
  gridLineCount?: number;
95
132
  /**
@@ -98,34 +135,76 @@ export interface LineChartProps extends Omit<HTMLAttributes<HTMLDivElement>, "on
98
135
  * index. Pass `null` for an entry to skip it.
99
136
  */
100
137
  categories?: ReadonlyArray<string | null>;
138
+ /**
139
+ * Format an x value for the x-axis ticks and the tooltip heading (e.g. a
140
+ * timestamp as a time). Giving it turns the x-axis tick labels on unless
141
+ * `showXAxisLabels` is `false`; `xTickFormatter` wins for the ticks.
142
+ */
143
+ formatX?: (x: number) => string;
144
+ /**
145
+ * Format a y value for the y-axis ticks and the tooltip. Giving it turns
146
+ * the y-axis tick labels on unless `showYAxisLabels` is `false`;
147
+ * `yTickFormatter` wins for the ticks. Defaults to a thousands-separated
148
+ * number.
149
+ */
150
+ formatY?: (y: number) => string;
151
+ /** Replace the crosshair readout's content. */
152
+ formatTooltip?: (context: LineChartTooltipContext) => ReactNode;
153
+ /**
154
+ * Show the crosshair readout on hover and keyboard focus. Defaults to
155
+ * `true`.
156
+ */
157
+ showTooltip?: boolean;
158
+ /**
159
+ * Show a legend above the plot. Defaults to `true` for two or more series
160
+ * and `false` for one (its title already names it).
161
+ */
162
+ showLegend?: boolean;
101
163
  /**
102
164
  * Format an x-tick label from its numeric value. Used when explicit numeric
103
165
  * x-values are provided on points. Return `null` to skip the tick.
104
166
  */
105
167
  xTickFormatter?: (x: number, index: number) => string | null;
106
168
  /**
107
- * Number of evenly-spaced x-axis ticks to render when `xTickFormatter` is
108
- * provided. Defaults to `5`.
169
+ * About how many x-axis ticks to render in numeric mode. Defaults to `5`.
170
+ * Ignored when `xTickValues` is given. Labels that would overlap are
171
+ * dropped on a narrow chart.
109
172
  */
110
173
  xTickCount?: number;
174
+ /**
175
+ * Exact x positions for the numeric x-axis ticks (e.g. every whole hour of
176
+ * a time axis), formatted with `xTickFormatter` or `formatX`. Values
177
+ * outside the x domain are skipped.
178
+ */
179
+ xTickValues?: ReadonlyArray<number>;
180
+ /**
181
+ * Render numeric x-axis tick labels (formatted with `formatX`). Defaults to
182
+ * on when `formatX` or `xTickFormatter` is given.
183
+ */
184
+ showXAxisLabels?: boolean;
111
185
  /**
112
186
  * Format a y-axis tick label from its numeric value. When provided, tick
113
187
  * labels are rendered to the left of the y-axis and a left gutter is
114
- * reserved automatically. Return `null` to skip a tick. The default
115
- * formatter (when `showYAxisLabels` is `true` without a custom formatter)
116
- * renders the raw value.
188
+ * reserved automatically. Return `null` to skip a tick.
117
189
  */
118
190
  yTickFormatter?: (y: number, index: number) => string | null;
119
191
  /**
120
- * Number of evenly-spaced y-axis ticks. Ticks include both endpoints
121
- * (`yMin` and `yMax`). Defaults to `5`. Has no effect unless
122
- * `yTickFormatter` is provided or `showYAxisLabels` is `true`.
192
+ * About how many y-axis ticks to draw. Defaults to `5`. Has no effect
193
+ * unless y-axis labels are shown.
123
194
  */
124
195
  yTickCount?: number;
125
196
  /**
126
- * Render y-axis tick labels using a default raw-value formatter. Useful as
127
- * a one-line opt-in when you don't need a custom formatter. Defaults to
128
- * `false`. Ignored when `yTickFormatter` is provided.
197
+ * Place the y-axis ticks (and numeric x-axis ticks) on round values inside
198
+ * the domain (0, 100, 200 …) rather than evenly between its ends (13.7,
199
+ * 27.4 …). Only the ticks move; the lines are drawn the same either way.
200
+ * Defaults to on, except for an axis given an `xTickFormatter` /
201
+ * `yTickFormatter`, which keeps evenly spaced ticks that include both
202
+ * ends (as before). For a time axis, pass `xTickValues` on round times.
203
+ */
204
+ niceTicks?: boolean;
205
+ /**
206
+ * Render y-axis tick labels (formatted with `formatY`). Defaults to on when
207
+ * `formatY` or `yTickFormatter` is given.
129
208
  */
130
209
  showYAxisLabels?: boolean;
131
210
  /**
@@ -137,9 +216,14 @@ export interface LineChartProps extends Omit<HTMLAttributes<HTMLDivElement>, "on
137
216
  showValueLabels?: boolean;
138
217
  /**
139
218
  * Customize the value-label text. Return `null` to skip a point. Defaults
140
- * to the raw value (`String(value)`).
219
+ * to `formatY(value)`.
141
220
  */
142
221
  valueLabelFormatter?: (context: LineChartValueLabelContext) => string | null;
222
+ /**
223
+ * Hold the current render at reduced opacity while new data loads, rather
224
+ * than flashing a skeleton.
225
+ */
226
+ loading?: boolean;
143
227
  /**
144
228
  * Fallback handler invoked for any point that doesn't have its own series-
145
229
  * level `onPointClick`. Receives the clicked point and its series.
@@ -160,7 +244,7 @@ export interface LineChartProps extends Omit<HTMLAttributes<HTMLDivElement>, "on
160
244
  /** Optional ref forwarded to the wrapper element. */
161
245
  ref?: Ref<HTMLDivElement>;
162
246
  }
163
- declare function LineChart({ series, label, size, width, height, yMin, yMax, xMin, xMax, curve, showPoints, showAxis, gridLineCount, categories, xTickFormatter, xTickCount, yTickFormatter, yTickCount, showYAxisLabels, yTickLabelWidth, showValueLabels, valueLabelFormatter, onPointClick, children, className, overlayClassName, valueLabelClassName, categoryLabelClassName, yAxisLabelClassName, axisClassName, ref, ...props }: LineChartProps): ReactElement;
247
+ declare function LineChart({ series, label, size, width, height, seriesOrder, yMin, yMax, xMin, xMax, curve, showPoints, showAxis, gridLineCount, categories, formatX, formatY, formatTooltip, showTooltip, showLegend, xTickFormatter, xTickCount, xTickValues, showXAxisLabels, yTickFormatter, yTickCount, niceTicks, showYAxisLabels, yTickLabelWidth, showValueLabels, valueLabelFormatter, loading, onPointClick, children, className, style, overlayClassName, valueLabelClassName, categoryLabelClassName, yAxisLabelClassName, axisClassName, ref, ...props }: LineChartProps): ReactElement;
164
248
  declare namespace LineChart {
165
249
  var displayName: string;
166
250
  }