basalt-ui 2.17.0 → 2.18.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 (69) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/MIGRATING.md +44 -12
  3. package/agent/skills/basalt-design/SKILL.md +1 -1
  4. package/dist/cli/help.d.ts +1 -0
  5. package/dist/cli/help.d.ts.map +1 -1
  6. package/dist/cli/help.js +8 -2
  7. package/dist/cli/shot/capture.d.ts +12 -1
  8. package/dist/cli/shot/capture.d.ts.map +1 -1
  9. package/dist/cli/shot/capture.js +72 -10
  10. package/dist/cli/shot/index.d.ts +10 -1
  11. package/dist/cli/shot/index.d.ts.map +1 -1
  12. package/dist/cli/shot/index.js +40 -5
  13. package/dist/cli/shot/real-data.d.ts +35 -0
  14. package/dist/cli/shot/real-data.d.ts.map +1 -0
  15. package/dist/cli/shot/real-data.js +120 -0
  16. package/dist/cli/shot/serve.d.ts +2 -2
  17. package/dist/cli/shot/serve.d.ts.map +1 -1
  18. package/dist/cli/shot/serve.js +16 -2
  19. package/dist/dashboard/bar-list.d.ts +29 -0
  20. package/dist/dashboard/bar-list.d.ts.map +1 -0
  21. package/dist/dashboard/bar-list.js +52 -0
  22. package/dist/dashboard/bar-list.module.css +73 -0
  23. package/dist/dashboard/bar-list.module.css.d.ts +16 -0
  24. package/dist/dashboard/index.d.ts +2 -0
  25. package/dist/dashboard/index.d.ts.map +1 -1
  26. package/dist/dashboard/index.js +4 -0
  27. package/dist/dashboard/meter-model.d.ts +78 -0
  28. package/dist/dashboard/meter-model.d.ts.map +1 -0
  29. package/dist/dashboard/meter-model.js +91 -0
  30. package/dist/dashboard/meter-parts.d.ts +42 -0
  31. package/dist/dashboard/meter-parts.d.ts.map +1 -0
  32. package/dist/dashboard/meter-parts.js +163 -0
  33. package/dist/dashboard/meter.d.ts +112 -0
  34. package/dist/dashboard/meter.d.ts.map +1 -0
  35. package/dist/dashboard/meter.js +43 -0
  36. package/dist/dashboard/meter.module.css +150 -0
  37. package/dist/dashboard/meter.module.css.d.ts +28 -0
  38. package/dist/dashboard/scale.d.ts +9 -0
  39. package/dist/dashboard/scale.d.ts.map +1 -0
  40. package/dist/dashboard/scale.js +10 -0
  41. package/dist/index.d.ts +1 -1
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/index.js +5 -1
  44. package/dist/tokens/derive.d.ts +11 -1
  45. package/dist/tokens/derive.d.ts.map +1 -1
  46. package/dist/tokens/derive.js +9 -24
  47. package/dist/tokens/status-text.d.ts +26 -0
  48. package/dist/tokens/status-text.d.ts.map +1 -0
  49. package/dist/tokens/status-text.js +68 -0
  50. package/llms.txt +32 -3
  51. package/package.json +1 -1
  52. package/src/cli/help.ts +22 -2
  53. package/src/cli/shot/capture.ts +98 -9
  54. package/src/cli/shot/index.ts +50 -4
  55. package/src/cli/shot/real-data.ts +165 -0
  56. package/src/cli/shot/serve.ts +28 -3
  57. package/src/dashboard/bar-list.module.css +73 -0
  58. package/src/dashboard/bar-list.module.css.d.ts +16 -0
  59. package/src/dashboard/bar-list.tsx +112 -0
  60. package/src/dashboard/index.ts +2 -0
  61. package/src/dashboard/meter-model.ts +161 -0
  62. package/src/dashboard/meter-parts.tsx +223 -0
  63. package/src/dashboard/meter.module.css +150 -0
  64. package/src/dashboard/meter.module.css.d.ts +28 -0
  65. package/src/dashboard/meter.tsx +162 -0
  66. package/src/dashboard/scale.ts +13 -0
  67. package/src/index.ts +4 -0
  68. package/src/tokens/derive.ts +19 -31
  69. package/src/tokens/status-text.ts +85 -0
@@ -0,0 +1,163 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { Skeleton, VisuallyHidden } from "@mantine/core";
3
+ import { useId } from "react";
4
+ import { cx } from "../common/props.js";
5
+ import { ariaValues, modelBar, ringFraction, zoneBand } from "./meter-model.js";
6
+ import classes from "./meter.module.css";
7
+ import { toPct } from "./scale.js";
8
+ const RING_VIEWBOX = 36;
9
+ const RING_STROKE = 4;
10
+ const RING_RADIUS = (RING_VIEWBOX - RING_STROKE) / 2;
11
+ const RING_LENGTH = 2 * Math.PI * RING_RADIUS;
12
+ const RING_CENTER = RING_VIEWBOX / 2;
13
+ function RingSvg({ fraction, color }) {
14
+ return /* @__PURE__ */ jsxs("svg", { className: classes.ring, viewBox: `0 0 ${RING_VIEWBOX} ${RING_VIEWBOX}`, "aria-hidden": true, children: [
15
+ /* @__PURE__ */ jsx(
16
+ "circle",
17
+ {
18
+ className: classes.ringTrack,
19
+ cx: RING_CENTER,
20
+ cy: RING_CENTER,
21
+ r: RING_RADIUS,
22
+ strokeWidth: RING_STROKE
23
+ }
24
+ ),
25
+ fraction !== void 0 && /* @__PURE__ */ jsx(
26
+ "circle",
27
+ {
28
+ className: classes.ringArc,
29
+ cx: RING_CENTER,
30
+ cy: RING_CENTER,
31
+ r: RING_RADIUS,
32
+ strokeWidth: RING_STROKE,
33
+ strokeDasharray: `${fraction * RING_LENGTH} ${RING_LENGTH}`,
34
+ ...color !== void 0 && { style: { stroke: color } }
35
+ }
36
+ )
37
+ ] });
38
+ }
39
+ function MeterLoading({
40
+ label,
41
+ ring,
42
+ shell
43
+ }) {
44
+ return /* @__PURE__ */ jsxs("div", { className: cx(classes.root, shell.className), style: shell.style, "aria-busy": "true", children: [
45
+ /* @__PURE__ */ jsx(VisuallyHidden, { children: `Loading ${label}` }),
46
+ ring ? /* @__PURE__ */ jsx(Skeleton, { className: classes.skeletonRing, circle: true }) : /* @__PURE__ */ jsxs(Fragment, { children: [
47
+ /* @__PURE__ */ jsx(Skeleton, { className: classes.skeletonTrack }),
48
+ /* @__PURE__ */ jsx(Skeleton, { className: classes.skeletonCaption, radius: "sm" })
49
+ ] })
50
+ ] });
51
+ }
52
+ function MeterEmpty(props) {
53
+ const { label, text, ring, shell } = props;
54
+ return /* @__PURE__ */ jsxs("output", { className: cx(classes.root, shell.className), style: shell.style, "aria-label": label, children: [
55
+ ring ? /* @__PURE__ */ jsx("span", { className: classes.ringBox, children: /* @__PURE__ */ jsx(RingSvg, {}) }) : /* @__PURE__ */ jsx("div", { className: classes.trackBox, children: /* @__PURE__ */ jsx("div", { className: classes.track, "data-meter-track": true }) }),
56
+ /* @__PURE__ */ jsx("span", { className: classes.empty, children: text })
57
+ ] });
58
+ }
59
+ function MeterRing(props) {
60
+ const { label, reading, min, max, color, format, shell } = props;
61
+ return /* @__PURE__ */ jsx("div", { className: cx(classes.root, shell.className), style: shell.style, children: /* @__PURE__ */ jsxs(
62
+ "span",
63
+ {
64
+ className: classes.ringBox,
65
+ "aria-label": label,
66
+ ...ariaValues(reading, min, max, format),
67
+ children: [
68
+ /* @__PURE__ */ jsx(RingSvg, { fraction: ringFraction(reading, min, max), color }),
69
+ /* @__PURE__ */ jsx("span", { className: classes.ringValue, children: format(reading) })
70
+ ]
71
+ }
72
+ ) });
73
+ }
74
+ function fillStyle(p) {
75
+ return { width: `${toPct(p.size)}%`, ...p.color !== void 0 && { background: p.color } };
76
+ }
77
+ const ZONE_STRENGTH_MIN = 15;
78
+ const ZONE_STRENGTH_STEP = 45;
79
+ const ZONE_STRENGTH_SOLO = 40;
80
+ const ZONE_GAP = "1px";
81
+ function zoneStyle(zone, index, count, min, span) {
82
+ const band = zoneBand(zone, min, span);
83
+ const gap = index > 0;
84
+ const strength = count > 1 ? ZONE_STRENGTH_MIN + index / (count - 1) * ZONE_STRENGTH_STEP : ZONE_STRENGTH_SOLO;
85
+ return {
86
+ insetInlineStart: gap ? `calc(${band.start}% + ${ZONE_GAP})` : `${band.start}%`,
87
+ width: gap ? `calc(${band.width}% - ${ZONE_GAP})` : `${band.width}%`,
88
+ background: zone.color ?? `color-mix(in srgb, var(--vx-line) ${strength}%, transparent)`
89
+ };
90
+ }
91
+ function MeterBar(props) {
92
+ const { label, reading, min, max, format, zones, shell } = props;
93
+ const describedId = useId();
94
+ const model = modelBar(props);
95
+ const start = props.startCaption === void 0 ? model.startText : props.startCaption;
96
+ const end = props.endCaption === void 0 ? model.endText : props.endCaption;
97
+ const hasCaptions = start !== null || end !== null || model.forecastText !== null;
98
+ const describedBy = model.describedByText === null ? {} : { "aria-describedby": describedId };
99
+ return /* @__PURE__ */ jsxs("div", { className: cx(classes.root, shell.className), style: shell.style, children: [
100
+ /* @__PURE__ */ jsxs(
101
+ "div",
102
+ {
103
+ className: classes.trackBox,
104
+ "aria-label": label,
105
+ ...ariaValues(reading, min, max, format),
106
+ ...describedBy,
107
+ children: [
108
+ /* @__PURE__ */ jsxs("div", { className: classes.track, "data-meter-track": true, children: [
109
+ model.markerPct !== void 0 && zones?.map((z, i) => /* @__PURE__ */ jsx(
110
+ "div",
111
+ {
112
+ className: classes.zone,
113
+ "data-meter-zone": z.label,
114
+ style: zoneStyle(z, i, zones.length, min, model.span)
115
+ },
116
+ i
117
+ )),
118
+ model.parts.map((p, i) => /* @__PURE__ */ jsx(
119
+ "div",
120
+ {
121
+ className: cx(classes.fill, p.forecast && classes.forecastFill),
122
+ "data-meter-fill": p.forecast ? "forecast" : "committed",
123
+ style: fillStyle(p)
124
+ },
125
+ i
126
+ ))
127
+ ] }),
128
+ /* @__PURE__ */ jsx(Tick, { kind: "marker", className: classes.marker, pct: model.markerPct }),
129
+ /* @__PURE__ */ jsx(Tick, { kind: "boundary", className: classes.boundaryTick, pct: model.boundaryPct }),
130
+ /* @__PURE__ */ jsx(Tick, { kind: "target", className: classes.tick, pct: model.targetPct })
131
+ ]
132
+ }
133
+ ),
134
+ model.describedByText !== null && /* @__PURE__ */ jsx(VisuallyHidden, { id: describedId, children: model.describedByText }),
135
+ hasCaptions && /* @__PURE__ */ jsxs("div", { className: classes.captions, "data-meter-captions": true, children: [
136
+ start !== null && /* @__PURE__ */ jsx("span", { className: classes.caption, children: start }),
137
+ model.forecastText !== null && /* @__PURE__ */ jsx("span", { className: classes.caption, children: model.forecastText }),
138
+ end !== null && /* @__PURE__ */ jsx("span", { className: classes.captionEnd, children: end })
139
+ ] })
140
+ ] });
141
+ }
142
+ function Tick({
143
+ kind,
144
+ className,
145
+ pct
146
+ }) {
147
+ if (pct === void 0) return null;
148
+ return /* @__PURE__ */ jsx(
149
+ "div",
150
+ {
151
+ className,
152
+ "data-meter-tick": kind,
153
+ style: { insetInlineStart: `${pct}%` },
154
+ "aria-hidden": true
155
+ }
156
+ );
157
+ }
158
+ export {
159
+ MeterBar,
160
+ MeterEmpty,
161
+ MeterLoading,
162
+ MeterRing
163
+ };
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Meter — one bounded quantity on a track: progress to a target, a committed/forecast split, a
3
+ * part-of-a-whole strip (`segments`), or a single headline ratio as a `ring`. Choose it for "how far
4
+ * along is this against a limit"; choose `BarList` for a ranking and a chart for a trend. An HTML/CSS
5
+ * primitive, not a chart kind (no scale, axis or tooltip).
6
+ *
7
+ * Colour law: the fill is neutral (`VX.line`). `color` is for a VERDICT only (over budget, below
8
+ * target) and is a status colour the consumer passes; categorical `segments` take the consumer's
9
+ * series colours. Committed vs forecast is the same neutral at two strengths — never colour alone: a
10
+ * tick marks the boundary and a caption names the forecast. A value past `max` clamps the fill at the
11
+ * track end; the caption still states the real value.
12
+ *
13
+ * `zones` (bar only) draws the track as contiguous bands (neutral at stepped strengths unless a zone
14
+ * passes a status colour) and the reading becomes a MARKER on the track, not a fill; the caption names
15
+ * the zone that holds the value (`from` inclusive). Use it for a reading judged against ranges.
16
+ *
17
+ * @example
18
+ * import { Meter } from 'basalt-ui'
19
+ *
20
+ * // Spend against a budget: past the target the end caption states the overage.
21
+ * <Meter label="Monthly spend" value={512} max={600} target={450} color="var(--vx-status-bad)" format={usd} />
22
+ * // Training load as a zone band with a marker: caption reads "Optimal · 612".
23
+ * <Meter
24
+ * label="Training load"
25
+ * max={1000}
26
+ * value={612}
27
+ * zones={[
28
+ * { from: 0, to: 300, label: 'Low' },
29
+ * { from: 300, to: 750, label: 'Optimal' },
30
+ * { from: 750, to: 1000, label: 'High' },
31
+ * ]}
32
+ * />
33
+ * // A readiness score on its 0–100 scale (its contributors: <BarList max={100} … secondary="Good" />).
34
+ * <Meter label="Recovery" value={72} max={100} />
35
+ * <Meter
36
+ * label="Course progress"
37
+ * max={120}
38
+ * segments={[{ value: 70, label: 'Done' }, { value: 25, label: 'Planned', forecast: true }]}
39
+ * />
40
+ * <Meter shape="ring" label="Cache hit rate" value={87} max={100} format={(v) => `${v}%`} />
41
+ */
42
+ import type { ReactNode } from 'react';
43
+ import type { BasaltProps } from '../common/props.js';
44
+ import type { MeterSegment, MeterZone } from './meter-model.js';
45
+ type Common = BasaltProps & {
46
+ /** Accessible name (`aria-label`). Required: a meter without one is announced as a bare number. */
47
+ label: string;
48
+ /** Track start. Default 0. */
49
+ min?: number;
50
+ /** Track end. Default 100. */
51
+ max?: number;
52
+ /** Formats values in captions and the accessible text. Default: the number as written. */
53
+ format?: (value: number) => string;
54
+ /** Renders a skeleton with the meter's footprint. */
55
+ loading?: boolean;
56
+ /** Muted line shown when there is no reading. The track stays so the footprint holds. */
57
+ emptyText?: string;
58
+ };
59
+ type BarCommon = Common & {
60
+ shape?: 'bar';
61
+ /** Target position; draws a tick and states it in the end caption (with the overage past it). */
62
+ target?: number;
63
+ /** Start caption (default: the formatted reading, or `Zone · reading`). `null` drops it. */
64
+ startCaption?: ReactNode;
65
+ /** End caption (default: `Target <target>`). `null` drops it. */
66
+ endCaption?: ReactNode;
67
+ };
68
+ /**
69
+ * One of four forms; mixing them is a compile error.
70
+ * - Bar `value` (+ `target`, `color`): one reading on a neutral track.
71
+ * - Bar `segments`: ordered parts that sum to the reading (committed/forecast, part of a whole).
72
+ * - Bar `value` + `zones`: the reading is a marker against contiguous bands.
73
+ * - Ring (`shape: 'ring'`) `value` (+ `color`): one headline ratio; no target, captions, segments or zones.
74
+ */
75
+ export type MeterProps = (BarCommon & {
76
+ /** The reading. `null`/`undefined` (or non-finite) renders the empty state. */
77
+ value?: number | null | undefined;
78
+ /** A status colour, for a verdict only. Omit for the neutral fill. */
79
+ color?: string;
80
+ segments?: never;
81
+ zones?: never;
82
+ }) | (BarCommon & {
83
+ /** Ordered parts, accumulated from `min`; their sum is the reading. `forecast` parts render lighter. */
84
+ segments: readonly MeterSegment[];
85
+ /** Names the forecast beside the boundary tick (default: `Forecast: <labels>`). */
86
+ forecastCaption?: string;
87
+ value?: never;
88
+ color?: never;
89
+ zones?: never;
90
+ }) | (BarCommon & {
91
+ value?: number | null | undefined;
92
+ /**
93
+ * Contiguous bands drawn as the track, positioned from each `from`. The reading becomes a marker
94
+ * and the caption names the band that holds it.
95
+ */
96
+ zones: readonly MeterZone[];
97
+ segments?: never;
98
+ color?: never;
99
+ }) | (Common & {
100
+ shape: 'ring';
101
+ value?: number | null | undefined;
102
+ /** A status colour, for a verdict only. */
103
+ color?: string;
104
+ segments?: never;
105
+ zones?: never;
106
+ target?: never;
107
+ startCaption?: never;
108
+ endCaption?: never;
109
+ });
110
+ export declare function Meter(props: MeterProps): import("react").JSX.Element;
111
+ export {};
112
+ //# sourceMappingURL=meter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"meter.d.ts","sourceRoot":"","sources":["../../src/dashboard/meter.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAElD,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAI5D,KAAK,MAAM,GAAG,WAAW,GAAG;IAC1B,mGAAmG;IACnG,KAAK,EAAE,MAAM,CAAA;IACb,8BAA8B;IAC9B,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,8BAA8B;IAC9B,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,0FAA0F;IAC1F,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAA;IAClC,qDAAqD;IACrD,OAAO,CAAC,EAAE,O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E,KAAK,CAAA;IAChB,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,MAAM,CAAC,EAAE,KAAK,CAAA;IACd,YAAY,CAAC,EAAE,KAAK,CAAA;IACpB,UAAU,CAAC,EAAE,KAAK,CAAA;CACnB,CAAC,CAAA;AAYN,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,+BA+BtC"}
@@ -0,0 +1,43 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { isReading, normalizeSegments, segmentReading, spanOf } from "./meter-model.js";
3
+ import { MeterBar, MeterEmpty, MeterLoading, MeterRing } from "./meter-parts.js";
4
+ import { asText } from "./scale.js";
5
+ let warnedTrack = false;
6
+ function warnInvalidTrack(min, max) {
7
+ if (warnedTrack || spanOf(min, max).valid || process.env.NODE_ENV === "production") return;
8
+ warnedTrack = true;
9
+ console.warn(
10
+ `[basalt] Meter: max (${max}) must be greater than min (${min}); drawing an empty track`
11
+ );
12
+ }
13
+ function Meter(props) {
14
+ const { label, min = 0, max = 100, format = asText, className, style } = props;
15
+ const shell = { className, style };
16
+ const ring = props.shape === "ring";
17
+ warnInvalidTrack(min, max);
18
+ if (props.loading === true) return /* @__PURE__ */ jsx(MeterLoading, { label, ring, shell });
19
+ const segments = props.segments === void 0 ? void 0 : normalizeSegments(props.segments);
20
+ const reading = segments === void 0 ? props.value : segmentReading(segments, min);
21
+ if (!isReading(reading) || segments?.length === 0) {
22
+ return /* @__PURE__ */ jsx(MeterEmpty, { label, text: props.emptyText ?? "No data", ring, shell });
23
+ }
24
+ if (props.shape === "ring") {
25
+ return /* @__PURE__ */ jsx(MeterRing, { ...{ label, reading, min, max, format, shell }, color: props.color });
26
+ }
27
+ return /* @__PURE__ */ jsx(
28
+ MeterBar,
29
+ {
30
+ ...{ label, reading, min, max, format, shell },
31
+ color: props.color,
32
+ segments,
33
+ zones: props.zones,
34
+ target: isReading(props.target) ? props.target : void 0,
35
+ forecastCaption: props.segments === void 0 ? void 0 : props.forecastCaption,
36
+ startCaption: props.startCaption,
37
+ endCaption: props.endCaption
38
+ }
39
+ );
40
+ }
41
+ export {
42
+ Meter
43
+ };
@@ -0,0 +1,150 @@
1
+ /*
2
+ * Meter — one neutral track, ordered fills, optional target tick (docs/waves/design-parity/SPEC.md
3
+ * § 6.3). Flat fills, no hatching. Bar height 6 is the measured reference; the radius is the `fine`
4
+ * step so the track follows the radius knob.
5
+ */
6
+
7
+ .root {
8
+ display: flex;
9
+ flex-direction: column;
10
+ gap: var(--vx-space-stack-xs, 0.25rem);
11
+ min-width: 0;
12
+ }
13
+
14
+ .track {
15
+ position: relative;
16
+ display: flex;
17
+ height: 0.375rem;
18
+ overflow: hidden;
19
+ border-radius: var(--vx-radius-fine);
20
+ background: var(--vx-surface-subtle);
21
+ }
22
+
23
+ /* The tick is drawn OVER the fills and outside the clipped track, so it can stand 2px proud of it. */
24
+ .trackBox {
25
+ position: relative;
26
+ }
27
+
28
+ .fill {
29
+ flex: none;
30
+ height: 100%;
31
+ background: var(--vx-line);
32
+ }
33
+
34
+ /* The committed/forecast pair: the same neutral at two strengths. Flat, never hatched. */
35
+ .forecastFill {
36
+ background: color-mix(in srgb, var(--vx-line) 45%, transparent);
37
+ }
38
+
39
+ .zone {
40
+ position: absolute;
41
+ inset-block: 0;
42
+ }
43
+
44
+ /* The reading on a zone track: a notch standing proud of the bands, in ink. */
45
+ .marker {
46
+ position: absolute;
47
+ top: -3px;
48
+ bottom: -3px;
49
+ width: 3px;
50
+ margin-inline-start: -1.5px;
51
+ border-radius: 1px;
52
+ background: var(--vx-ink);
53
+ }
54
+
55
+ .tick {
56
+ position: absolute;
57
+ top: -2px;
58
+ bottom: -2px;
59
+ width: 2px;
60
+ margin-inline-start: -1px;
61
+ border-radius: 1px;
62
+ background: var(--vx-ink);
63
+ }
64
+
65
+ .boundaryTick {
66
+ composes: tick;
67
+ background: var(--vx-muted);
68
+ }
69
+
70
+ .captions {
71
+ display: flex;
72
+ align-items: baseline;
73
+ justify-content: space-between;
74
+ gap: var(--vx-space-control-gap, 0.375rem);
75
+ font-family: var(--basalt-font-mono);
76
+ font-size: var(--vx-text-micro);
77
+ color: var(--vx-muted);
78
+ }
79
+
80
+ .caption {
81
+ white-space: nowrap;
82
+ }
83
+
84
+ .captionEnd {
85
+ composes: caption;
86
+ text-align: end;
87
+ }
88
+
89
+ /* Alone in the row, the end caption still sits at the end. */
90
+ .captionEnd:first-child {
91
+ margin-inline-start: auto;
92
+ }
93
+
94
+ .empty {
95
+ font-size: var(--vx-text-sm);
96
+ color: var(--vx-muted);
97
+ }
98
+
99
+ /* The skeleton holds the track + one caption line: 6 + 4 + a micro line. */
100
+ .skeletonTrack {
101
+ height: 0.375rem;
102
+ }
103
+
104
+ .skeletonCaption {
105
+ width: 40%;
106
+ height: 0.75rem;
107
+ }
108
+
109
+ /* ── ring ────────────────────────────────────────────────────────────────────────────────────── */
110
+
111
+ .ringBox {
112
+ position: relative;
113
+ display: inline-flex;
114
+ align-items: center;
115
+ justify-content: center;
116
+ align-self: flex-start;
117
+ width: 5rem;
118
+ height: 5rem;
119
+ }
120
+
121
+ .ring {
122
+ position: absolute;
123
+ inset: 0;
124
+ width: 100%;
125
+ height: 100%;
126
+ transform: rotate(-90deg);
127
+ }
128
+
129
+ .ringTrack {
130
+ fill: none;
131
+ stroke: var(--vx-surface-subtle);
132
+ }
133
+
134
+ .ringArc {
135
+ fill: none;
136
+ stroke: var(--vx-line);
137
+ }
138
+
139
+ .ringValue {
140
+ position: relative;
141
+ font-family: var(--basalt-font-mono);
142
+ font-size: var(--vx-text-md);
143
+ font-weight: 500;
144
+ color: var(--vx-ink);
145
+ }
146
+
147
+ .skeletonRing {
148
+ width: 5rem;
149
+ height: 5rem;
150
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Typed CSS-module declaration (the S4 CSS-modules path). Named string props — not an index
3
+ * signature — so dot access stays verbatim under the package's strict flags.
4
+ */
5
+ declare const classes: {
6
+ readonly root: string
7
+ readonly track: string
8
+ readonly trackBox: string
9
+ readonly fill: string
10
+ readonly forecastFill: string
11
+ readonly zone: string
12
+ readonly marker: string
13
+ readonly tick: string
14
+ readonly boundaryTick: string
15
+ readonly captions: string
16
+ readonly caption: string
17
+ readonly captionEnd: string
18
+ readonly empty: string
19
+ readonly skeletonTrack: string
20
+ readonly skeletonCaption: string
21
+ readonly ringBox: string
22
+ readonly ring: string
23
+ readonly ringTrack: string
24
+ readonly ringArc: string
25
+ readonly ringValue: string
26
+ readonly skeletonRing: string
27
+ }
28
+ export default classes
@@ -0,0 +1,9 @@
1
+ /** Shared by `Meter` and `BarList`: the one place a value becomes a track percentage. Internal. */
2
+ /** Clamps to 0–1; a non-finite fraction is 0. */
3
+ export declare const clamp01: (n: number) => number;
4
+ /** A 0–1 fraction as a percent, rounded so float noise never reaches the DOM. */
5
+ export declare const toPct: (n: number) => number;
6
+ /** A value on a track that ends at `scale`; a non-finite value or an empty scale draws nothing. */
7
+ export declare const barPercent: (value: number, scale: number) => number;
8
+ export declare const asText: (n: number) => string;
9
+ //# sourceMappingURL=scale.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scale.d.ts","sourceRoot":"","sources":["../../src/dashboard/scale.ts"],"names":[],"mappings":"AAAA,mGAAmG;AAEnG,iDAAiD;AACjD,eAAO,MAAM,OAAO,GAAI,GAAG,MAAM,KAAG,MAAgE,CAAA;AAEpG,iFAAiF;AACjF,eAAO,MAAM,KAAK,GAAI,GAAG,MAAM,KAAG,MAA8C,CAAA;AAEhF,mGAAmG;AACnG,eAAO,MAAM,UAAU,GAAI,OAAO,MAAM,EAAE,OAAO,MAAM,KAAG,MACgC,CAAA;AAE1F,eAAO,MAAM,MAAM,GAAI,GAAG,MAAM,KAAG,MAAmB,CAAA"}
@@ -0,0 +1,10 @@
1
+ const clamp01 = (n) => Number.isFinite(n) ? Math.min(1, Math.max(0, n)) : 0;
2
+ const toPct = (n) => Math.round(clamp01(n) * 1e4) / 100;
3
+ const barPercent = (value, scale) => Number.isFinite(value) && Number.isFinite(scale) && scale > 0 ? toPct(value / scale) : 0;
4
+ const asText = (n) => String(n);
5
+ export {
6
+ asText,
7
+ barPercent,
8
+ clamp01,
9
+ toPct
10
+ };
package/dist/index.d.ts CHANGED
@@ -13,7 +13,7 @@ export { scrollParentOf, useCoarsePointer, type Tone } from './common/index.js';
13
13
  export { createBasaltTheme } from './theme/index.js';
14
14
  export { ThemeToggle } from './theme/theme-toggle.js';
15
15
  export { BasaltShell, PageBar, PageAside, useSizeClass, PageTitle, type ShellBaseProps, type SidebarBlock, type SettingsMenuItem, } from './shell/index.js';
16
- export { WidgetHeader, DeltaBadge, Section, StatCard, type StatCardBreakdownRow, type StatCardSparklineSize, StatGroup, EmptyState, SettingsSection, SettingsRow, DangerZone, } from './dashboard/index.js';
16
+ export { WidgetHeader, DeltaBadge, Section, StatCard, type StatCardBreakdownRow, type StatCardSparklineSize, StatGroup, EmptyState, SettingsSection, SettingsRow, DangerZone, Meter, type MeterProps, BarList, type BarListProps, } from './dashboard/index.js';
17
17
  export { unwrap } from './unwrap.js';
18
18
  export type { BasaltRegister, SeriesKey } from './register.js';
19
19
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,cAAc,EAAE,KAAK,mBAAmB,EAAE,MAAM,YAAY,CAAA;AACrE,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,GACzB,MAAM,0BAA0B,CAAA;AACjC,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AACnG,OAAO,EACL,SAAS,EACT,QAAQ,EACR,SAAS,EACT,UAAU,EACV,YAAY,EACZ,KAAK,SAAS,GACf,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,c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E,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,EACL,WAAW,EACX,OAAO,EACP,SAAS,EACT,YAAY,EACZ,SAAS,EACT,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,gBAAgB,GACtB,MAAM,SAAS,CAAA;AAChB,OAAO,EACL,YAAY,EACZ,UAAU,EACV,OAAO,EACP,QAAQ,EACR,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,SAAS,EACT,UAAU,EACV,eAAe,EACf,WAAW,EACX,UAAU,EACV,KAAK,EACL,KAAK,UAAU,EACf,OAAO,EACP,KAAK,YAAY,GAClB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAMjC,YAAY,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA"}
package/dist/index.js CHANGED
@@ -29,15 +29,19 @@ import {
29
29
  EmptyState,
30
30
  SettingsSection,
31
31
  SettingsRow,
32
- DangerZone
32
+ DangerZone,
33
+ Meter,
34
+ BarList
33
35
  } from "./dashboard/index.js";
34
36
  import { unwrap } from "./unwrap.js";
35
37
  export {
38
+ BarList,
36
39
  BasaltProvider,
37
40
  BasaltShell,
38
41
  DangerZone,
39
42
  DeltaBadge,
40
43
  EmptyState,
44
+ Meter,
41
45
  PageAside,
42
46
  PageBar,
43
47
  PageTitle,
@@ -80,9 +80,19 @@ export type DerivedPalette = {
80
80
  ink: Record<InkKey, ColorPair>;
81
81
  status: Record<StatusKey, ColorPair>;
82
82
  };
83
+ /** The accepted `lightLevel` / `darkLevel` range; `deriveTokens` clamps to it. */
84
+ export declare const DERIVE_LEVEL_RANGE: {
85
+ readonly min: -5;
86
+ readonly max: 5;
87
+ };
83
88
  /** Derive the full palette from a seed accent + neutral family + surface levels.
84
89
  * Public level-based entry: maps the -5..5 sliders onto `DeriveParams` (vibrancy x0.72 center,
85
- * surface +2 baseline) and delegates to `deriveTokensRaw`. */
90
+ * surface +2 baseline) and delegates to `deriveTokensRaw`.
91
+ *
92
+ * `lightLevel` / `darkLevel` are clamped to {@link DERIVE_LEVEL_RANGE} (non-finite → 0).
93
+ * @throws Error when no status tone clears 4.5:1 on every text surface — unreachable for clamped
94
+ * levels (the test grid proves it); only a raw shift outside the slider range gets there.
95
+ */
86
96
  export declare function deriveTokens(config: DeriveConfig): DerivedPalette;
87
97
  /** Derivation core over continuous params — see `DeriveParams` for the calibration contract. */
88
98
  export declare function deriveTokensRaw(config: Pick<DeriveConfig, 'accent' | 'neutral'>, params: DeriveParams): DerivedPalette;
@@ -1 +1 @@
1
- {"version":3,"file":"derive.d.ts","sourceRoot":"","sources":["../../src/tokens/derive.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAEvC,MAAM,MAAM,YAAY,GAAG;IACzB;;;;;;;;OAQG;IACH,MAAM,EAAE,MAAM,CAAA;IACd,sEAAsE;IACtE,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,CAAA;IAC/C;kGAC8F;IAC9F,UAAU,EAAE,MAAM,CAAA;IAClB;mDAC+C;IAC/C,SAAS,EAAE,MAAM,CAAA;IACjB;;;;;;OAMG;IACH,QAAQ,EAAE,MAAM,CAAA;IAChB;;;;;;OAMG;IACH,gBAAgB,EAAE,MAAM,CAAA;CACzB,CAAA;AAED,8FAA8F;AAC9F,eAAO,MAAM,qBAAqB,EAAE,YAOnC,CAAA;AAID;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,YAAY,CAEjF;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAEnE;AAuHD,MAAM,MAAM,UAAU,GAClB,MAAM,GACN,KAAK,GACL,MAAM,GACN,OAAO,GACP,QAAQ,GACR,QAAQ,GACR,MAAM,GACN,MAAM,GACN,OAAO,GACP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A6F;IAC7F,UAAU,EAAE,MAAM,CAAA;IAClB,0EAA0E;IAC1E,eAAe,EAAE,MAAM,CAAA;IACvB,6EAA6E;IAC7E,iBAAiB,EAAE,MAAM,CAAA;IACzB,4EAA4E;IAC5E,gBAAgB,EAAE,MAAM,CAAA;CACzB,CAAA;AAED;8BAC8B;AAC9B,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,SAAS,CAAA;IACjB,WAAW,EAAE,SAAS,CAAA;IACtB,UAAU,EAAE,SAAS,CAAA;IACrB,eAAe,EAAE,SAAS,CAAA;IAC1B,QAAQ,EAAE,SAAS,CAAA;IACnB,IAAI,EAAE,MAAM,CAAC,UAAU,EAAE,SAAS,CAAC,CAAA;IACnC,OAAO,EAAE,MAAM,CAAC,UAAU,EAAE,SAAS,CAAC,CAAA;IACtC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;IAC9B,MAAM,EAAE,MAAM,CAAC,SAAS,EAAE,SAAS,CAAC,CAAA;CACrC,CAAA;AAED,kFAAkF;AAClF,eAAO,MAAM,kBAAkB;;;CAA+B,CAAA;AAM9D;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,cAAc,CAUjE;AAED,gGAAgG;AAChG,wBAAgB,eAAe,CAC7B,MAAM,EAAE,IAAI,CAAC,YAAY,EAAE,QAAQ,GAAG,SAAS,CAAC,EAChD,MAAM,EAAE,YAAY,GACnB,cAAc,CAgGhB"}
@@ -1,4 +1,5 @@
1
1
  import { contrastRatio, hctToHex, hexToHct, yToTone } from "./hct.js";
2
+ import { deriveStatusHexes } from "./status-text.js";
2
3
  const DEFAULT_DERIVE_CONFIG = {
3
4
  accent: "#0077bd",
4
5
  neutral: "zinc",
@@ -132,19 +133,17 @@ const INK_TONE = {
132
133
  light: { ink: 15.16, ink2: 27.09, muted: 34.88, faint: 44.5 },
133
134
  dark: { ink: 90.94, ink2: 88.12, muted: 84.91, faint: 66.24 }
134
135
  };
135
- const STATUS_HUE = { good: 151.975, warn: 76.64, bad: 29.905 };
136
- const STATUS_STOP = {
137
- good: { light: { tone: 45.75, chroma: 37.75 }, dark: { tone: 70.23, chroma: 53.23 } },
138
- warn: { light: { tone: 46, chroma: 61.12 }, dark: { tone: 72.34, chroma: 62.55 } },
139
- bad: { light: { tone: 43.86, chroma: 54.46 }, dark: { tone: 66.5, chroma: 53.79 } }
140
- };
136
+ const DERIVE_LEVEL_RANGE = { min: -5, max: 5 };
137
+ function clampLevel(level) {
138
+ return Number.isFinite(level) ? clamp(level, DERIVE_LEVEL_RANGE.min, DERIVE_LEVEL_RANGE.max) : 0;
139
+ }
141
140
  function deriveTokens(config) {
142
141
  assertValidAccentHex(config.accent);
143
142
  return deriveTokensRaw(config, {
144
143
  chromaMult: vibrancyChromaMult(config.vibrancy),
145
144
  accentToneShift: config.accentBrightness * ACCENT_BRIGHTNESS_TONE_STEP,
146
- lightSurfaceShift: SURFACE_LEVEL_TONE_STEP * config.lightLevel + SURFACE_BASELINE_TONE_SHIFT,
147
- darkSurfaceShift: SURFACE_LEVEL_TONE_STEP * config.darkLevel + SURFACE_BASELINE_TONE_SHIFT
145
+ lightSurfaceShift: SURFACE_LEVEL_TONE_STEP * clampLevel(config.lightLevel) + SURFACE_BASELINE_TONE_SHIFT,
146
+ darkSurfaceShift: SURFACE_LEVEL_TONE_STEP * clampLevel(config.darkLevel) + SURFACE_BASELINE_TONE_SHIFT
148
147
  });
149
148
  }
150
149
  function deriveTokensRaw(config, params) {
@@ -215,22 +214,7 @@ function deriveTokensRaw(config, params) {
215
214
  dark: hctToHex({ hue: neutral.hue, chroma: neutral.chroma, tone: INK_TONE.dark[key] })
216
215
  };
217
216
  }
218
- const status = {};
219
- for (const key of Object.keys(STATUS_HUE)) {
220
- const hue = STATUS_HUE[key];
221
- status[key] = {
222
- light: hctToHex({
223
- hue,
224
- chroma: STATUS_STOP[key].light.chroma,
225
- tone: STATUS_STOP[key].light.tone
226
- }),
227
- dark: hctToHex({
228
- hue,
229
- chroma: STATUS_STOP[key].dark.chroma,
230
- tone: STATUS_STOP[key].dark.tone
231
- })
232
- };
233
- }
217
+ const status = deriveStatusHexes(surface);
234
218
  return {
235
219
  accent: { light: accentFill, dark: accentInkDark },
236
220
  accentHover: { light: accentFillHover, dark: accentHoverDark },
@@ -245,6 +229,7 @@ function deriveTokensRaw(config, params) {
245
229
  }
246
230
  export {
247
231
  DEFAULT_DERIVE_CONFIG,
232
+ DERIVE_LEVEL_RANGE,
248
233
  deriveTokens,
249
234
  deriveTokensRaw,
250
235
  isDefaultDeriveConfig,