basalt-ui 2.2.0 → 2.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/CHANGELOG.md +14 -0
- package/MIGRATING.md +33 -12
- package/dist/charts/BandStrip.d.ts +7 -7
- package/dist/charts/BandStrip.d.ts.map +1 -1
- package/dist/charts/Bars.d.ts +4 -4
- package/dist/charts/Bars.d.ts.map +1 -1
- package/dist/charts/ChartCard.d.ts +10 -10
- package/dist/charts/ChartCard.d.ts.map +1 -1
- package/dist/charts/ChartCard.js +2 -1
- package/dist/charts/Donut.d.ts +5 -5
- package/dist/charts/Donut.d.ts.map +1 -1
- package/dist/charts/DualPanel.d.ts +9 -9
- package/dist/charts/DualPanel.d.ts.map +1 -1
- package/dist/charts/Heatmap.d.ts +15 -15
- package/dist/charts/Heatmap.d.ts.map +1 -1
- package/dist/charts/MirroredBars.d.ts +9 -9
- package/dist/charts/MirroredBars.d.ts.map +1 -1
- package/dist/charts/Sparkline.d.ts +6 -6
- package/dist/charts/Sparkline.d.ts.map +1 -1
- package/dist/charts/StackedArea.d.ts +2 -2
- package/dist/charts/StackedArea.d.ts.map +1 -1
- package/dist/charts/compile.d.ts +11 -1
- package/dist/charts/compile.d.ts.map +1 -1
- package/dist/charts/compile.js +51 -2
- package/dist/charts/index.d.ts +1 -0
- package/dist/charts/index.d.ts.map +1 -1
- package/dist/charts/index.js +3 -1
- package/dist/charts/types.d.ts +62 -60
- package/dist/charts/types.d.ts.map +1 -1
- package/llms.txt +2 -2
- package/package.json +1 -1
- package/src/charts/BandStrip.tsx +12 -10
- package/src/charts/Bars.tsx +4 -4
- package/src/charts/ChartCard.tsx +17 -11
- package/src/charts/Donut.tsx +5 -5
- package/src/charts/DualPanel.tsx +13 -6
- package/src/charts/Heatmap.tsx +12 -12
- package/src/charts/MirroredBars.tsx +8 -8
- package/src/charts/Sparkline.tsx +6 -6
- package/src/charts/StackedArea.tsx +2 -2
- package/src/charts/compile.ts +82 -1
- package/src/charts/index.ts +1 -0
- package/src/charts/types.ts +68 -56
package/dist/charts/compile.js
CHANGED
|
@@ -124,6 +124,54 @@ function areaGradient(index, color) {
|
|
|
124
124
|
]
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
|
+
const areaTint = (color) => `color-mix(in srgb, ${color} var(--vx-area-top), transparent)`;
|
|
128
|
+
function zoneAreaGradient(index, zones, values) {
|
|
129
|
+
let floor = 0;
|
|
130
|
+
let ceiling = 0;
|
|
131
|
+
for (const v of values) {
|
|
132
|
+
if (v === null || !Number.isFinite(v)) continue;
|
|
133
|
+
if (v < floor) floor = v;
|
|
134
|
+
if (v > ceiling) ceiling = v;
|
|
135
|
+
}
|
|
136
|
+
const span = ceiling - floor;
|
|
137
|
+
if (span <= 0) return null;
|
|
138
|
+
const offsetOf = (v) => (ceiling - Math.min(ceiling, Math.max(floor, v))) / span;
|
|
139
|
+
const reaching = zones.filter((z) => !Number.isNaN(z.from) && !Number.isNaN(z.to) && z.to > floor && z.from < ceiling).toSorted((p, q) => q.to - p.to);
|
|
140
|
+
let previous = 0;
|
|
141
|
+
const stops = reaching.flatMap(
|
|
142
|
+
(z) => [offsetOf(z.to), offsetOf(z.from)].map((raw) => {
|
|
143
|
+
previous = Math.max(previous, raw);
|
|
144
|
+
return { offset: previous, color: areaTint(z.fill) };
|
|
145
|
+
})
|
|
146
|
+
);
|
|
147
|
+
if (stops.length === 0) return null;
|
|
148
|
+
return { id: areaGradientId(index), x1: 0, y1: 0, x2: 0, y2: 1, stops };
|
|
149
|
+
}
|
|
150
|
+
let warnedLogZones = false;
|
|
151
|
+
function guardLogZones(onLog) {
|
|
152
|
+
if (!onLog) return false;
|
|
153
|
+
const message = "area: 'zones' cannot use a log axis; use area: true";
|
|
154
|
+
if (process.env.NODE_ENV !== "production") throw new Error(message);
|
|
155
|
+
if (!warnedLogZones) console.error(message);
|
|
156
|
+
warnedLogZones = true;
|
|
157
|
+
return true;
|
|
158
|
+
}
|
|
159
|
+
function seriesAreaGradient(s, index, input, axes) {
|
|
160
|
+
const plain = areaGradient(
|
|
161
|
+
index,
|
|
162
|
+
typeof s.area === "string" && s.area !== "zones" ? s.area : s.color
|
|
163
|
+
);
|
|
164
|
+
if (s.area !== "zones") return plain;
|
|
165
|
+
const side = axes.onRight(s) ? "right" : "left";
|
|
166
|
+
const axisConfig = side === "right" ? input.y2 : input.y;
|
|
167
|
+
if (guardLogZones(axisConfig?.scale === "log")) return plain;
|
|
168
|
+
const zones = (input.zones ?? []).filter((z) => axes.scaleId(z.axisSide) === axes.scaleId(side));
|
|
169
|
+
return zoneAreaGradient(
|
|
170
|
+
index,
|
|
171
|
+
zones,
|
|
172
|
+
input.data.map((d) => s.getValue(d))
|
|
173
|
+
) ?? plain;
|
|
174
|
+
}
|
|
127
175
|
const isBar = (s) => s.mark === "bar";
|
|
128
176
|
const STACK_POSITIVE_KEY = "__stack+";
|
|
129
177
|
const STACK_NEGATIVE_KEY = "__stack-";
|
|
@@ -337,7 +385,7 @@ function compileCartesian(input) {
|
|
|
337
385
|
const rows = rowsOf(input, visibleKeys);
|
|
338
386
|
const formatX = (v) => input.formatX ? input.formatX(v) : defaultFormatX(v);
|
|
339
387
|
const gradients = input.series.flatMap(
|
|
340
|
-
(s, i) => s.area ? [
|
|
388
|
+
(s, i) => s.area ? [seriesAreaGradient(s, i, input, axes)] : []
|
|
341
389
|
);
|
|
342
390
|
return {
|
|
343
391
|
chart: ({ width, height }) => {
|
|
@@ -387,5 +435,6 @@ export {
|
|
|
387
435
|
utcHeaderDate,
|
|
388
436
|
visibleSeries,
|
|
389
437
|
xGuide,
|
|
390
|
-
yGuide
|
|
438
|
+
yGuide,
|
|
439
|
+
zoneAreaGradient
|
|
391
440
|
};
|
package/dist/charts/index.d.ts
CHANGED
|
@@ -17,5 +17,6 @@ export { DualPanel, type DualPanelProps, type DualPanelLine, type DualPanelBar }
|
|
|
17
17
|
export { MirroredBars, type MirroredBarsProps, type MirroredBarsSeries, type MirroredBarPane, } from './MirroredBars.js';
|
|
18
18
|
export { ChartCard, type ChartCardProps, type ChartCardSlot } from './ChartCard.js';
|
|
19
19
|
export { chartCursor } from './cursor.js';
|
|
20
|
+
export { chartCurve, type CurveName } from './curves.js';
|
|
20
21
|
export type { AxisConfig, CartesianChartProps, ChartLegendConfig, ChartMarks, ChartSeries, ChartState, ChartTooltipConfig, ChartTooltipRow, ChartX, CursorResolution, PlotContext, RefLine, ResponsiveChartHeight, Threshold, XZoneSpec, ZoneSpec, } from './types.js';
|
|
21
22
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/charts/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,KAAK,EAAE,KAAK,UAAU,EAAE,MAAM,SAAS,CAAA;AAChD,OAAO,EAAE,IAAI,EAAE,KAAK,SAAS,EAAE,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAC1E,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,KAAK,eAAe,EAAE,MAAM,eAAe,CAAA;AACxF,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5D,OAAO,EACL,SAAS,EACT,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,QAAQ,EACb,KAAK,QAAQ,GACd,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,KAAK,EAAE,KAAK,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,SAAS,CAAA;AACjE,OAAO,EAAE,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,WAAW,CAAA;AACtD,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,KAAK,aAAa,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAA;AACnG,OAAO,EACL,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c,EAAE,KAAK,aAAa,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAA;AACnG,OAAO,EACL,YAAY,EACZ,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,eAAe,GACrB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAA;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,EAAE,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,UAAU,CAAA;AACrD,YAAY,EACV,UAAU,EACV,mBAAmB,EACnB,iBAAiB,EACjB,UAAU,EACV,WAAW,EACX,UAAU,EACV,kBAAkB,EAClB,eAAe,EACf,MAAM,EACN,gBAAgB,EAChB,WAAW,EACX,OAAO,EACP,qBAAqB,EACrB,SAAS,EACT,SAAS,EACT,QAAQ,GACT,MAAM,SAAS,CAAA"}
|
package/dist/charts/index.js
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
} from "./MirroredBars.js";
|
|
15
15
|
import { ChartCard } from "./ChartCard.js";
|
|
16
16
|
import { chartCursor } from "./cursor.js";
|
|
17
|
+
import { chartCurve } from "./curves.js";
|
|
17
18
|
export {
|
|
18
19
|
BandStrip,
|
|
19
20
|
Bars,
|
|
@@ -26,5 +27,6 @@ export {
|
|
|
26
27
|
MirroredBars,
|
|
27
28
|
Sparkline,
|
|
28
29
|
StackedArea,
|
|
29
|
-
chartCursor
|
|
30
|
+
chartCursor,
|
|
31
|
+
chartCurve
|
|
30
32
|
};
|
package/dist/charts/types.d.ts
CHANGED
|
@@ -22,40 +22,42 @@ export type ChartSeries<T> = {
|
|
|
22
22
|
* series whose `getValue` is always `null` is a legend-only entry (a zone or reference key). */
|
|
23
23
|
getValue: (d: T) => number | null;
|
|
24
24
|
/** The legend swatch shape. Default: the kind's own mark (`line` in `Lines`, `bar` in `Bars`). */
|
|
25
|
-
mark?: 'line' | 'bar' | 'area';
|
|
25
|
+
mark?: 'line' | 'bar' | 'area' | undefined;
|
|
26
26
|
/** Default `'solid'`; `'dashed'` is `VX.dashArray` on the line, the legend and the tooltip. */
|
|
27
|
-
dash?: 'solid' | 'dashed';
|
|
27
|
+
dash?: 'solid' | 'dashed' | undefined;
|
|
28
28
|
/** Interpolation between points. Default `'monotone'`. A piecewise-constant quantity (a price
|
|
29
29
|
* tier, a config value) is a step: a smoothed curve draws values that never existed. */
|
|
30
|
-
curve?: CurveName;
|
|
31
|
-
strokeWidth?: number;
|
|
30
|
+
curve?: CurveName | undefined;
|
|
31
|
+
strokeWidth?: number | undefined;
|
|
32
32
|
/** Dims the plotted stroke (a faint companion line). Strokes only. */
|
|
33
|
-
strokeOpacity?: number;
|
|
33
|
+
strokeOpacity?: number | undefined;
|
|
34
34
|
/** Bars and areas. */
|
|
35
|
-
fillOpacity?: number;
|
|
36
|
-
/** `Lines`: a soft gradient fill under the line — `true` in the series color,
|
|
37
|
-
|
|
35
|
+
fillOpacity?: number | undefined;
|
|
36
|
+
/** `Lines`: a soft gradient fill under the line — `true` in the series color, a color ref, or
|
|
37
|
+
* `'zones'`: a vertical gradient coloured by the chart's `zones` on this series' axis, hard stops
|
|
38
|
+
* at the zone boundaries (no zone in reach: the series color). Linear axes only. */
|
|
39
|
+
area?: boolean | 'zones' | (string & {}) | undefined;
|
|
38
40
|
/** Which y axis the series is measured against. `'right'` needs the chart's `y2`. */
|
|
39
|
-
axis?: 'left' | 'right';
|
|
41
|
+
axis?: 'left' | 'right' | undefined;
|
|
40
42
|
/** Legend grouping: series → overlay → reference. Default `'series'`. */
|
|
41
|
-
role?: 'series' | 'overlay' | 'reference';
|
|
43
|
+
role?: 'series' | 'overlay' | 'reference' | undefined;
|
|
42
44
|
/** `false` keeps it out of the legend (a companion line folded under `parent`). Default `true`. */
|
|
43
|
-
legend?: boolean;
|
|
45
|
+
legend?: boolean | undefined;
|
|
44
46
|
/** `false` draws and legends it but never lists it as a tooltip row. Default `true`. */
|
|
45
|
-
tooltip?: boolean;
|
|
47
|
+
tooltip?: boolean | undefined;
|
|
46
48
|
/** A companion (an MA line) names its parent, so a legend toggle and hover keep the pair. */
|
|
47
|
-
parent?: string;
|
|
49
|
+
parent?: string | undefined;
|
|
48
50
|
/** A short qualifier after the label in the legend and the tooltip row, in muted text. */
|
|
49
|
-
note?: string;
|
|
51
|
+
note?: string | undefined;
|
|
50
52
|
/** Per-series tooltip value format; receives the datum so a row can read more than the value. */
|
|
51
|
-
formatValue?: (v: number, d: T) => string;
|
|
53
|
+
formatValue?: ((v: number, d: T) => string) | undefined;
|
|
52
54
|
/** A marker at a point (a PR star, a status dot); `null` for none. */
|
|
53
|
-
getMarker?: (d: T) => {
|
|
54
|
-
color?: string;
|
|
55
|
-
r?: number;
|
|
56
|
-
fillOpacity?: number;
|
|
57
|
-
ring?: boolean;
|
|
58
|
-
} | null;
|
|
55
|
+
getMarker?: ((d: T) => {
|
|
56
|
+
color?: string | undefined;
|
|
57
|
+
r?: number | undefined;
|
|
58
|
+
fillOpacity?: number | undefined;
|
|
59
|
+
ring?: boolean | undefined;
|
|
60
|
+
} | null) | undefined;
|
|
59
61
|
};
|
|
60
62
|
/** One y axis. */
|
|
61
63
|
export type AxisConfig<T> = {
|
|
@@ -64,31 +66,31 @@ export type AxisConfig<T> = {
|
|
|
64
66
|
* reference-line bounds; a tuple fixes it; a function computes it from the data and the visible
|
|
65
67
|
* series (so a legend toggle can shrink a stacked domain).
|
|
66
68
|
*/
|
|
67
|
-
domain?: readonly [number, number] | 'auto' | ((data: readonly T[], visible: readonly ChartSeries<T>[]) => readonly [number, number]);
|
|
69
|
+
domain?: readonly [number, number] | 'auto' | ((data: readonly T[], visible: readonly ChartSeries<T>[]) => readonly [number, number]) | undefined;
|
|
68
70
|
/** When `'auto'`: the raw upper bound is at least this; padding applies after. */
|
|
69
|
-
autoMaxFloor?: number;
|
|
71
|
+
autoMaxFloor?: number | undefined;
|
|
70
72
|
/** When `'auto'`: the lower bound is at most this. Default `0` (a zero baseline); `Infinity` pads
|
|
71
73
|
* down from the data minimum instead. Ignored on a log axis. */
|
|
72
|
-
autoMinCeil?: number;
|
|
74
|
+
autoMinCeil?: number | undefined;
|
|
73
75
|
/** When `'auto'`: padding multiplier away from the data. Default `1.1`. */
|
|
74
|
-
autoPad?: number;
|
|
76
|
+
autoPad?: number | undefined;
|
|
75
77
|
/** A tick count, or the exact tick values. Default: one per ~48px of plot height, ≤ 5. */
|
|
76
|
-
ticks?: number | readonly number[];
|
|
78
|
+
ticks?: number | readonly number[] | undefined;
|
|
77
79
|
/** Tick and tooltip formatter. Default: compact numbers (`12.5k`). */
|
|
78
|
-
format?: (v: number) => string;
|
|
80
|
+
format?: ((v: number) => string) | undefined;
|
|
79
81
|
/** Horizontal grid rules. Default: on for `y`, off for `y2`. */
|
|
80
|
-
grid?: boolean;
|
|
82
|
+
grid?: boolean | undefined;
|
|
81
83
|
/** Round the domain outward to nice ticks. Default `false` (a fixed domain stays fixed). */
|
|
82
|
-
nice?: boolean;
|
|
84
|
+
nice?: boolean | undefined;
|
|
83
85
|
/** Default `'linear'`. A log axis floors at the smallest positive visible value. */
|
|
84
|
-
scale?: 'linear' | 'log';
|
|
86
|
+
scale?: 'linear' | 'log' | undefined;
|
|
85
87
|
};
|
|
86
88
|
/** A horizontal band on one y axis. `±Infinity` reaches the plot edge. */
|
|
87
89
|
export type ZoneSpec = {
|
|
88
90
|
from: number;
|
|
89
91
|
to: number;
|
|
90
92
|
fill: string;
|
|
91
|
-
axisSide?: 'left' | 'right';
|
|
93
|
+
axisSide?: 'left' | 'right' | undefined;
|
|
92
94
|
};
|
|
93
95
|
/**
|
|
94
96
|
* A vertical band between two x values. An omitted bound is the plot's own edge. `'edge'` widens a
|
|
@@ -96,17 +98,17 @@ export type ZoneSpec = {
|
|
|
96
98
|
* from one hour to another, both hours included).
|
|
97
99
|
*/
|
|
98
100
|
export type XZoneSpec<X extends ChartX = ChartX> = {
|
|
99
|
-
from?: X;
|
|
100
|
-
to?: X;
|
|
101
|
+
from?: X | undefined;
|
|
102
|
+
to?: X | undefined;
|
|
101
103
|
fill: string;
|
|
102
|
-
align?: 'center' | 'edge';
|
|
104
|
+
align?: 'center' | 'edge' | undefined;
|
|
103
105
|
};
|
|
104
106
|
/** A horizontal reference line — annotation only, no domain role beyond staying inside the plot. */
|
|
105
107
|
export type RefLine = {
|
|
106
108
|
value: number;
|
|
107
109
|
color: string;
|
|
108
|
-
dashed?: boolean;
|
|
109
|
-
axis?: 'left' | 'right';
|
|
110
|
+
dashed?: boolean | undefined;
|
|
111
|
+
axis?: 'left' | 'right' | undefined;
|
|
110
112
|
};
|
|
111
113
|
/** A fill between the line and a value, on one side of it, tracking the line. */
|
|
112
114
|
export type Threshold = {
|
|
@@ -126,41 +128,41 @@ export type ChartTooltipRow = {
|
|
|
126
128
|
export type ChartTooltipConfig<T, X extends ChartX = ChartX> = {
|
|
127
129
|
/** The tooltip title. Default: the x value through `formatX`'s long form (a date reads
|
|
128
130
|
* `Mon Sep 1 2026`). */
|
|
129
|
-
formatHeader?: (x: X, d: T) => string;
|
|
131
|
+
formatHeader?: ((x: X, d: T) => string) | undefined;
|
|
130
132
|
/** Rows after the per-series rows (a total, a zone badge, a context line). `visible`/`hidden` are
|
|
131
133
|
* the legend's split, so a row never names a series the plot no longer draws. */
|
|
132
|
-
rows?: (d: T, ctx: {
|
|
134
|
+
rows?: ((d: T, ctx: {
|
|
133
135
|
visible: readonly ChartSeries<T>[];
|
|
134
136
|
hidden: readonly ChartSeries<T>[];
|
|
135
|
-
}) => readonly ChartTooltipRow[];
|
|
137
|
+
}) => readonly ChartTooltipRow[]) | undefined;
|
|
136
138
|
/** Show this chart's tooltip while it FOLLOWS a sibling's cursor. Default `false`: only the chart
|
|
137
139
|
* under the pointer or keyboard focus shows a tooltip and a live region. */
|
|
138
|
-
onFollow?: boolean;
|
|
140
|
+
onFollow?: boolean | undefined;
|
|
139
141
|
};
|
|
140
142
|
export type ChartLegendConfig = {
|
|
141
143
|
/** Default `'bottom'`. `'header'` draws the legend at the top of the chart body, spaced as the
|
|
142
144
|
* enclosing `ChartCard`'s header legend row (in the chart's own markup, so it is in the server
|
|
143
145
|
* HTML and the header never grows); outside a card it is `'top'`. */
|
|
144
|
-
placement?: 'top' | 'bottom' | 'header';
|
|
146
|
+
placement?: 'top' | 'bottom' | 'header' | undefined;
|
|
145
147
|
/** Visually separate roles: series | overlay | reference. */
|
|
146
|
-
groups?: boolean;
|
|
148
|
+
groups?: boolean | undefined;
|
|
147
149
|
/** Clicking an entry hides that series. Default: on whenever there are two or more entries. */
|
|
148
|
-
toggle?: boolean;
|
|
150
|
+
toggle?: boolean | undefined;
|
|
149
151
|
};
|
|
150
152
|
/** A height per container class, `base` below `regular`. A plain number is fixed. */
|
|
151
153
|
export type ResponsiveChartHeight = {
|
|
152
154
|
base: number;
|
|
153
|
-
regular?: number;
|
|
154
|
-
wide?: number;
|
|
155
|
+
regular?: number | undefined;
|
|
156
|
+
wide?: number | undefined;
|
|
155
157
|
};
|
|
156
158
|
/** The three "nothing to draw" states, pending → error → empty. */
|
|
157
159
|
export type ChartState = {
|
|
158
|
-
pending?: boolean;
|
|
160
|
+
pending?: boolean | undefined;
|
|
159
161
|
/** Truthy = the query failed; an `Error`'s message is the label. */
|
|
160
162
|
error?: unknown;
|
|
161
163
|
/** `true`, or the empty label itself. The label is the one way to say WHY (`'No runs match the
|
|
162
164
|
* filter'` vs `'No runs yet'`): § 9 fixes the state shape, so there is no reason field. */
|
|
163
|
-
empty?: boolean | string;
|
|
165
|
+
empty?: boolean | string | undefined;
|
|
164
166
|
};
|
|
165
167
|
/** A row of `plot.rows(key)`: one per datum, `y: null` kept as a gap. */
|
|
166
168
|
export type PlotRow<T, X extends ChartX = ChartX> = {
|
|
@@ -200,27 +202,27 @@ export type CartesianChartProps<T, X extends ChartX = ChartX> = BasaltProps & {
|
|
|
200
202
|
series: readonly ChartSeries<T>[];
|
|
201
203
|
/** The plot's marks. Draw `plot.rows(key)` / `plot.visible`, never `series` directly. */
|
|
202
204
|
marks: (plot: PlotContext<T, X>) => ChartMarks;
|
|
203
|
-
y?: AxisConfig<T
|
|
205
|
+
y?: AxisConfig<T> | undefined;
|
|
204
206
|
/** A right axis; series with `axis: 'right'` and marks bound to `plot.y2` read it. */
|
|
205
|
-
y2?: AxisConfig<T
|
|
207
|
+
y2?: AxisConfig<T> | undefined;
|
|
206
208
|
/** A tick count, or the exact x tick values. Default: by container class. */
|
|
207
|
-
xTicks?: number | readonly X[];
|
|
209
|
+
xTicks?: number | readonly X[] | undefined;
|
|
208
210
|
/** Tick label for an x value. Default: `DD.MM` for dates, compact numbers, strings verbatim. */
|
|
209
|
-
formatX?: (x: X) => string;
|
|
210
|
-
zones?: readonly ZoneSpec[];
|
|
211
|
-
xZones?: readonly XZoneSpec<X>[];
|
|
212
|
-
refLines?: readonly RefLine[];
|
|
211
|
+
formatX?: ((x: X) => string) | undefined;
|
|
212
|
+
zones?: readonly ZoneSpec[] | undefined;
|
|
213
|
+
xZones?: readonly XZoneSpec<X>[] | undefined;
|
|
214
|
+
refLines?: readonly RefLine[] | undefined;
|
|
213
215
|
/** `false` hides the legend. */
|
|
214
|
-
legend?: ChartLegendConfig | false;
|
|
216
|
+
legend?: ChartLegendConfig | false | undefined;
|
|
215
217
|
/** Default: the height law (measured width × class ratio, 160–420px, ≤ 45vh on touch). */
|
|
216
|
-
height?: number | ResponsiveChartHeight;
|
|
217
|
-
state?: ChartState;
|
|
218
|
+
height?: number | ResponsiveChartHeight | undefined;
|
|
219
|
+
state?: ChartState | undefined;
|
|
218
220
|
/** Joins a named cursor group instead of the page-shared default. */
|
|
219
|
-
cursorGroup?: string;
|
|
221
|
+
cursorGroup?: string | undefined;
|
|
220
222
|
/** Default `'nearest'`. `'leading'` for a series keyed by a bucket's leading edge (a weekly
|
|
221
223
|
* value keyed by its Monday). */
|
|
222
|
-
cursorResolution?: CursorResolution;
|
|
223
|
-
tooltip?: ChartTooltipConfig<T, X> | false;
|
|
224
|
+
cursorResolution?: CursorResolution | undefined;
|
|
225
|
+
tooltip?: ChartTooltipConfig<T, X> | false | undefined;
|
|
224
226
|
};
|
|
225
227
|
/** The x channel of a `plot.rows()` row, as an accessor (a field name does not type-check against a
|
|
226
228
|
* generic `X`). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/charts/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEzC;8CAC8C;AAC9C,MAAM,MAAM,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,CAAA;AAE3C;;;GAGG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;IAC3B,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,6EAA6E;IAC7E,KAAK,EAAE,MAAM,CAAA;IACb;oGACgG;IAChG,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,MAAM,GAAG,IAAI,CAAA;IACjC,kGAAkG;IAClG,IAAI,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/charts/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,KAAK,EAAE,SAAS,E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CAAC,EAAE,CAAC,SAAS,MAAM,EAAE,KAAK,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,KAAG,CAAU,CAAA"}
|
package/llms.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# basalt-ui v2.
|
|
1
|
+
# basalt-ui v2.3.0
|
|
2
2
|
# Opinionated framework for Mantine-based React apps — theme, app shell, TanStack Charts, toolchain presets
|
|
3
3
|
#
|
|
4
4
|
# Entry points: use the exact import specifier below; do not guess.
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
# A subpath's `Install:` line is its required peers; `OptionalPeers:` are import()-only, install on use.
|
|
14
14
|
|
|
15
15
|
Package: basalt-ui
|
|
16
|
-
Version: 2.
|
|
16
|
+
Version: 2.3.0
|
|
17
17
|
|
|
18
18
|
## basalt-ui
|
|
19
19
|
Import: import { ... } from 'basalt-ui'
|
package/package.json
CHANGED
package/src/charts/BandStrip.tsx
CHANGED
|
@@ -39,7 +39,7 @@ export type BandStripSeries<T> = Pick<
|
|
|
39
39
|
* The tooltip row's value for a band in this state. `null` is an ABSENT reading and renders an
|
|
40
40
|
* em dash; omit the function when the state's name is the whole reading ("Not measured").
|
|
41
41
|
*/
|
|
42
|
-
formatValue?: (d: T) => string | null
|
|
42
|
+
formatValue?: ((d: T) => string | null) | undefined
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
/** One band: its state, and the two ways to qualify it. */
|
|
@@ -47,23 +47,25 @@ export type BandSpan = {
|
|
|
47
47
|
/** A `states` key: the band's legend entry, fill and tooltip row. */
|
|
48
48
|
state: string
|
|
49
49
|
/** Overrides the state's fill — an intensity ramp WITHIN a state. `alpha(VX.*, …)`, never a hex. */
|
|
50
|
-
fill?: string
|
|
50
|
+
fill?: string | undefined
|
|
51
51
|
/**
|
|
52
52
|
* A shorter, inset bar over the band, for a fact that must not be read off the fill ramp (a
|
|
53
53
|
* renegotiation, a restart). Its color is a `states` entry, so the legend names it.
|
|
54
54
|
*/
|
|
55
|
-
marker?:
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
55
|
+
marker?:
|
|
56
|
+
| {
|
|
57
|
+
/** Defaults to the band's own `state`. */
|
|
58
|
+
state?: string | undefined
|
|
59
|
+
/** Vertical inset from the band's top and bottom, in px. Default 6. */
|
|
60
|
+
inset?: number | undefined
|
|
61
|
+
}
|
|
62
|
+
| undefined
|
|
61
63
|
}
|
|
62
64
|
|
|
63
65
|
/** Collapse adjacent data where one band per datum would be thinner than `minBandPx`. */
|
|
64
66
|
export type BandFold<T> = {
|
|
65
67
|
/** Floor on a drawn band's px width. Default 3. */
|
|
66
|
-
minBandPx?: number
|
|
68
|
+
minBandPx?: number | undefined
|
|
67
69
|
/**
|
|
68
70
|
* The consumer's merge of a group of adjacent data into the datum drawn in its place — whether
|
|
69
71
|
* that is a max, a sum or a recomputed rate is a question about the measurement. Keep the first
|
|
@@ -79,7 +81,7 @@ export type BandStripProps<T, X extends ChartX = ChartX> = Omit<
|
|
|
79
81
|
states: readonly BandStripSeries<T>[]
|
|
80
82
|
/** Which state, fill and marker each datum has. Memoize it: a new function recompiles the chart. */
|
|
81
83
|
getBand: (d: T) => BandSpan
|
|
82
|
-
fold?: BandFold<T>
|
|
84
|
+
fold?: BandFold<T> | undefined
|
|
83
85
|
}
|
|
84
86
|
|
|
85
87
|
const DEFAULT_MIN_BAND_PX = 3
|
package/src/charts/Bars.tsx
CHANGED
|
@@ -27,7 +27,7 @@ export type BarsBar<T> = Pick<
|
|
|
27
27
|
'key' | 'label' | 'color' | 'getValue' | 'formatValue' | 'tooltip' | 'legend' | 'role' | 'note'
|
|
28
28
|
> & {
|
|
29
29
|
/** Default 0.85. */
|
|
30
|
-
fillOpacity?: number
|
|
30
|
+
fillOpacity?: number | undefined
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
/** A line overlay; `axis: 'right'` reads the chart's `y2`. */
|
|
@@ -54,11 +54,11 @@ export type BarsProps<T, X extends ChartX = ChartX> = Omit<
|
|
|
54
54
|
'marks' | 'series'
|
|
55
55
|
> & {
|
|
56
56
|
bars: readonly BarsBar<T>[]
|
|
57
|
-
lines?: readonly BarsLine<T>[]
|
|
57
|
+
lines?: readonly BarsLine<T>[] | undefined
|
|
58
58
|
/** Default `'stacked'`. `'normalized'` stacks each x to its share of the total. */
|
|
59
|
-
layout?: 'stacked' | 'grouped' | 'normalized'
|
|
59
|
+
layout?: 'stacked' | 'grouped' | 'normalized' | undefined
|
|
60
60
|
/** Per-bar opacity (a partial week, an estimate). Overrides the series' `fillOpacity`. */
|
|
61
|
-
barOpacity?: (d: T, key: string) => number
|
|
61
|
+
barOpacity?: ((d: T, key: string) => number) | undefined
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
const DEFAULT_BAR_OPACITY = 0.85
|
package/src/charts/ChartCard.tsx
CHANGED
|
@@ -92,32 +92,38 @@ export type ChartCardSlot = 'root' | 'header' | 'body'
|
|
|
92
92
|
|
|
93
93
|
export type ChartCardProps = BasaltProps &
|
|
94
94
|
SlotStylesProps<ChartCardSlot> & {
|
|
95
|
-
title?: string
|
|
95
|
+
title?: string | undefined
|
|
96
96
|
icon?: ReactNode
|
|
97
97
|
/** A muted line below the title row; does not by itself render the header. */
|
|
98
|
-
subtitle?: string
|
|
98
|
+
subtitle?: string | undefined
|
|
99
99
|
/** `WidgetHeader`'s info glyph beside the title. */
|
|
100
|
-
info?: string
|
|
100
|
+
info?: string | undefined
|
|
101
101
|
/** A pre-formatted metric value, with `delta` on the hero row. */
|
|
102
|
-
value?: string
|
|
103
|
-
delta?: number
|
|
104
|
-
deltaPeriod?: string
|
|
105
|
-
deltaPolarity?: DeltaPolarity
|
|
102
|
+
value?: string | undefined
|
|
103
|
+
delta?: number | undefined
|
|
104
|
+
deltaPeriod?: string | undefined
|
|
105
|
+
deltaPolarity?: DeltaPolarity | undefined
|
|
106
106
|
/** A mono count tag after the title. */
|
|
107
|
-
count?: number
|
|
107
|
+
count?: number | undefined
|
|
108
108
|
/** Right-aligned controls. */
|
|
109
109
|
actions?: ReactNode
|
|
110
110
|
/** A resolved state replaces `children` with its placeholder; the header stays. */
|
|
111
|
-
state?: ChartState
|
|
111
|
+
state?: ChartState | undefined
|
|
112
112
|
/** Body height while a placeholder shows. Default: the chart height law, i.e. exactly the box an
|
|
113
113
|
* unsized chart takes — pass the chart's own `height` when it states one, so a `<Suspense
|
|
114
114
|
* fallback={<ChartCard state={{ pending: true }} …/>}>` reserves the final size. */
|
|
115
|
-
placeholderHeight?: number | ResponsiveChartHeight
|
|
115
|
+
placeholderHeight?: number | ResponsiveChartHeight | undefined
|
|
116
116
|
/** A retry button or a "clear filters" link under the placeholder. */
|
|
117
117
|
stateAction?: ReactNode
|
|
118
118
|
children?: ReactNode
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
+
/** Drops explicit `undefined`s: `WidgetHeader` is exact-optional, this props type is not. */
|
|
122
|
+
const definedOnly = <T extends object>(o: T): { [K in keyof T]?: Exclude<T[K], undefined> } =>
|
|
123
|
+
Object.fromEntries(Object.entries(o).filter(([, v]) => v !== undefined)) as {
|
|
124
|
+
[K in keyof T]?: Exclude<T[K], undefined>
|
|
125
|
+
}
|
|
126
|
+
|
|
121
127
|
/** A header renders when one of these is set (a subtitle or delta alone does not). */
|
|
122
128
|
const HEADER_TRIGGERS = ['title', 'info', 'value', 'icon', 'count'] as const
|
|
123
129
|
|
|
@@ -150,7 +156,7 @@ export function ChartCard({
|
|
|
150
156
|
<div className={cx(classes.header, classNames?.header)}>
|
|
151
157
|
<WidgetHeader
|
|
152
158
|
tier="widget"
|
|
153
|
-
{...header}
|
|
159
|
+
{...definedOnly(header)}
|
|
154
160
|
title={header.title ?? ''}
|
|
155
161
|
{...(actions !== undefined && {
|
|
156
162
|
actions: <span data-basalt-tier="widget">{actions}</span>,
|
package/src/charts/Donut.tsx
CHANGED
|
@@ -34,13 +34,13 @@ export type DonutProps<K extends string = string> = BasaltProps & {
|
|
|
34
34
|
colorForKey: (key: K) => string
|
|
35
35
|
formatValue: (v: number) => string
|
|
36
36
|
/** Legend and tooltip label for a key. Default: the key. */
|
|
37
|
-
seriesLabel?: (key: K) => string
|
|
37
|
+
seriesLabel?: ((key: K) => string) | undefined
|
|
38
38
|
/** The ring's centre text, and the smaller line under it. */
|
|
39
|
-
centerLabel?: string
|
|
40
|
-
centerSubLabel?: string
|
|
39
|
+
centerLabel?: string | undefined
|
|
40
|
+
centerSubLabel?: string | undefined
|
|
41
41
|
/** Default 240. */
|
|
42
|
-
height?: number | ResponsiveChartHeight
|
|
43
|
-
state?: ChartState
|
|
42
|
+
height?: number | ResponsiveChartHeight | undefined
|
|
43
|
+
state?: ChartState | undefined
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
/** Slices kept before the rest fold into "Other". */
|
package/src/charts/DualPanel.tsx
CHANGED
|
@@ -64,12 +64,12 @@ export type DualPanelBar<T> = {
|
|
|
64
64
|
/** Tick and tooltip formatter. */
|
|
65
65
|
format: (v: number) => string
|
|
66
66
|
/** The tooltip row's value, for a unit or a decimal `format` cannot carry. */
|
|
67
|
-
formatValue?: (v: number, d: T) => string
|
|
67
|
+
formatValue?: ((v: number, d: T) => string) | undefined
|
|
68
68
|
/** Default `'auto'`: a symmetric `[-maxAbs, maxAbs]` from the data, rounded to nice ticks. A tuple
|
|
69
69
|
* is used verbatim. */
|
|
70
|
-
domain?: readonly [number, number] | 'auto'
|
|
70
|
+
domain?: readonly [number, number] | 'auto' | undefined
|
|
71
71
|
/** When `'auto'`: floors `maxAbs`, so a plateau does not amplify to fill the pane. */
|
|
72
|
-
maxAbsFloor?: number
|
|
72
|
+
maxAbsFloor?: number | undefined
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
export type DualPanelProps<T, X extends Date | number = Date | number> = Pick<
|
|
@@ -91,15 +91,22 @@ export type DualPanelProps<T, X extends Date | number = Date | number> = Pick<
|
|
|
91
91
|
series: readonly DualPanelLine<T>[]
|
|
92
92
|
/** Top pane y axis. Default domain `'auto'`: the visible lines' span plus 8%, rounded to nice
|
|
93
93
|
* ticks (not zero-based: the interesting range is often a narrow band far from zero). */
|
|
94
|
-
top?:
|
|
94
|
+
top?:
|
|
95
|
+
| {
|
|
96
|
+
domain?: readonly [number, number] | 'auto' | undefined
|
|
97
|
+
format?: ((v: number) => string) | undefined
|
|
98
|
+
}
|
|
99
|
+
| undefined
|
|
95
100
|
/**
|
|
96
101
|
* Shades the band between two top lines (by key), where both are visible. `aboveFill` colours the
|
|
97
102
|
* side where `to` runs above `from`; omitted, both sides take `fill`.
|
|
98
103
|
*/
|
|
99
|
-
fillBetween?:
|
|
104
|
+
fillBetween?:
|
|
105
|
+
| { from: string; to: string; fill: string; aboveFill?: string | undefined }
|
|
106
|
+
| undefined
|
|
100
107
|
bar: DualPanelBar<T>
|
|
101
108
|
/** The top pane's share of the chart height. Default 0.62. */
|
|
102
|
-
topFraction?: number
|
|
109
|
+
topFraction?: number | undefined
|
|
103
110
|
}
|
|
104
111
|
|
|
105
112
|
type FillRow<T, X> = { x: X; from: number; to: number; series: string; datum: T }
|
package/src/charts/Heatmap.tsx
CHANGED
|
@@ -38,28 +38,28 @@ export type HeatmapProps<T> = BasaltProps & {
|
|
|
38
38
|
/** The intensity; `null` is an absent cell (flat neutral), never a zero. */
|
|
39
39
|
getValue: (d: T) => number | null
|
|
40
40
|
/** Explicit band order. Default: first seen in `data`. */
|
|
41
|
-
rows?: readonly string[]
|
|
42
|
-
cols?: readonly string[]
|
|
41
|
+
rows?: readonly string[] | undefined
|
|
42
|
+
cols?: readonly string[] | undefined
|
|
43
43
|
/** The ink at full intensity, a `VX.*` ref or a series token. Default `VX.line`. */
|
|
44
|
-
color?: string
|
|
44
|
+
color?: string | undefined
|
|
45
45
|
/** The value range the color scale spans. Default `[0, max]` of the data. */
|
|
46
|
-
domain?: readonly [number, number]
|
|
46
|
+
domain?: readonly [number, number] | undefined
|
|
47
47
|
/** Tooltip, legend-end and `aria` value format. Default: the number as-is. */
|
|
48
|
-
formatValue?: (v: number) => string
|
|
48
|
+
formatValue?: ((v: number) => string) | undefined
|
|
49
49
|
/** Band tick and tooltip header labels. Default: the band key. */
|
|
50
|
-
formatRow?: (row: string) => string
|
|
51
|
-
formatCol?: (col: string) => string
|
|
50
|
+
formatRow?: ((row: string) => string) | undefined
|
|
51
|
+
formatCol?: ((col: string) => string) | undefined
|
|
52
52
|
/** `false` hides the gradient legend; `label` titles it. */
|
|
53
|
-
legend?: false | { label?: string }
|
|
53
|
+
legend?: false | { label?: string | undefined } | undefined
|
|
54
54
|
/** Rows after the value row, per cell (a sample count, a failure reason). Called with the datum. */
|
|
55
|
-
tooltip?: false | { rows?: (d: T) => readonly ChartTooltipRow[] }
|
|
55
|
+
tooltip?: (false | { rows?: ((d: T) => readonly ChartTooltipRow[]) | undefined }) | undefined
|
|
56
56
|
/** A fixed height, or one per container class. Default: by row count (160–420px). */
|
|
57
|
-
height?: number | ResponsiveChartHeight
|
|
57
|
+
height?: number | ResponsiveChartHeight | undefined
|
|
58
58
|
/** Fill the parent's height instead. Overrides `height`. CSS-owned like every other kind's box
|
|
59
59
|
* (`ChartBox`, no measuring, SSR-stable), so the parent needs a definite CSS height — a grid or
|
|
60
60
|
* flex stretch, `h-full`, an explicit height — which no kind can read off an auto-height parent. */
|
|
61
|
-
matchHeight?: boolean
|
|
62
|
-
state?: ChartState
|
|
61
|
+
matchHeight?: boolean | undefined
|
|
62
|
+
state?: ChartState | undefined
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
/** Intensity steps: quantized, so the gradient legend and the cells are the same ramp. */
|