basalt-ui 2.18.0 → 2.19.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 (76) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/MIGRATING.md +76 -12
  3. package/agent/agents/basalt-design-reviewer.md +2 -2
  4. package/dist/commands/notifications/center.d.ts.map +1 -1
  5. package/dist/commands/notifications/center.js +18 -26
  6. package/dist/content/callout.d.ts +1 -1
  7. package/dist/content/callout.d.ts.map +1 -1
  8. package/dist/content/callout.js +10 -1
  9. package/dist/content/callout.module.css +15 -3
  10. package/dist/content/callout.module.css.d.ts +1 -0
  11. package/dist/dashboard/bar-list.d.ts.map +1 -1
  12. package/dist/dashboard/bar-list.js +31 -18
  13. package/dist/dashboard/bar-list.module.css +33 -15
  14. package/dist/dashboard/bar-list.module.css.d.ts +1 -0
  15. package/dist/dashboard/meter-model.d.ts +49 -1
  16. package/dist/dashboard/meter-model.d.ts.map +1 -1
  17. package/dist/dashboard/meter-model.js +47 -3
  18. package/dist/dashboard/meter-parts.d.ts.map +1 -1
  19. package/dist/dashboard/meter-parts.js +143 -9
  20. package/dist/dashboard/meter.d.ts +16 -5
  21. package/dist/dashboard/meter.d.ts.map +1 -1
  22. package/dist/dashboard/meter.module.css +127 -9
  23. package/dist/dashboard/meter.module.css.d.ts +11 -0
  24. package/dist/dashboard/stat-card-parts.d.ts +3 -1
  25. package/dist/dashboard/stat-card-parts.d.ts.map +1 -1
  26. package/dist/dashboard/stat-card-parts.js +18 -3
  27. package/dist/dashboard/stat-card.d.ts +6 -5
  28. package/dist/dashboard/stat-card.d.ts.map +1 -1
  29. package/dist/dashboard/stat-card.js +48 -77
  30. package/dist/dashboard/stat-card.module.css +27 -7
  31. package/dist/dashboard/widget-header.d.ts.map +1 -1
  32. package/dist/dashboard/widget-header.js +2 -1
  33. package/dist/dashboard/widget-header.module.css +28 -1
  34. package/dist/theme/chrome-vars.d.ts +29 -17
  35. package/dist/theme/chrome-vars.d.ts.map +1 -1
  36. package/dist/theme/chrome-vars.js +18 -8
  37. package/dist/theme/index.d.ts.map +1 -1
  38. package/dist/theme/index.js +9 -5
  39. package/dist/theme/status-dot.d.ts +6 -0
  40. package/dist/theme/status-dot.d.ts.map +1 -0
  41. package/dist/theme/status-dot.js +9 -0
  42. package/dist/theme/status-dot.module.css +9 -0
  43. package/dist/theme/status-dot.module.css.d.ts +8 -0
  44. package/dist/theme/status-verdict.d.ts +9 -0
  45. package/dist/theme/status-verdict.d.ts.map +1 -0
  46. package/dist/theme/status-verdict.js +13 -0
  47. package/dist/theme/status-verdict.module.css +23 -0
  48. package/dist/theme/status-verdict.module.css.d.ts +9 -0
  49. package/llms.txt +2 -2
  50. package/package.json +1 -1
  51. package/src/commands/notifications/center.tsx +29 -32
  52. package/src/content/callout.module.css +15 -3
  53. package/src/content/callout.module.css.d.ts +1 -0
  54. package/src/content/callout.tsx +15 -2
  55. package/src/dashboard/bar-list.module.css +33 -15
  56. package/src/dashboard/bar-list.module.css.d.ts +1 -0
  57. package/src/dashboard/bar-list.tsx +29 -16
  58. package/src/dashboard/meter-model.ts +97 -4
  59. package/src/dashboard/meter-parts.tsx +195 -11
  60. package/src/dashboard/meter.module.css +127 -9
  61. package/src/dashboard/meter.module.css.d.ts +11 -0
  62. package/src/dashboard/meter.tsx +16 -5
  63. package/src/dashboard/stat-card-parts.tsx +22 -2
  64. package/src/dashboard/stat-card.module.css +27 -7
  65. package/src/dashboard/stat-card.tsx +18 -52
  66. package/src/dashboard/widget-header.module.css +28 -1
  67. package/src/dashboard/widget-header.tsx +4 -1
  68. package/src/theme/__snapshots__/plain-theme.test.ts.snap +88 -16
  69. package/src/theme/chrome-vars.ts +48 -23
  70. package/src/theme/index.ts +10 -6
  71. package/src/theme/status-dot.module.css +9 -0
  72. package/src/theme/status-dot.module.css.d.ts +8 -0
  73. package/src/theme/status-dot.tsx +19 -0
  74. package/src/theme/status-verdict.module.css +23 -0
  75. package/src/theme/status-verdict.module.css.d.ts +9 -0
  76. package/src/theme/status-verdict.tsx +27 -0
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Meter's pure model: everything the component shows, computed from numbers (no DOM, no React runtime).
3
+ * Internal — `meter.tsx` and `meter-parts.tsx` render what this returns.
4
+ */
5
+ import type { ReactNode } from 'react';
1
6
  export type MeterSegment = {
2
7
  value: number;
3
8
  label: string;
@@ -10,13 +15,35 @@ export type MeterZone = {
10
15
  label: string;
11
16
  color?: string;
12
17
  };
13
- /** A fill on the track, as fractions (0–1) of the span. */
18
+ /** A fill on the track, as fractions (0–1) of the span, with the segment it was laid out from. */
14
19
  export type Part = {
15
20
  readonly start: number;
16
21
  readonly size: number;
17
22
  readonly color: string | undefined;
18
23
  readonly forecast: boolean;
24
+ readonly label: string;
25
+ /** The segment's own (normalised) amount, in the reading's units — what its caption states. */
26
+ readonly amount: number;
27
+ };
28
+ /** One categorical part's caption: its position key, name, formatted amount and fill colour (`undefined` = neutral). */
29
+ export type PartCaption = {
30
+ key: string;
31
+ label: string;
32
+ text: string;
33
+ color: string | undefined;
34
+ };
35
+ /** One zone's name on the band: where its band starts (percent) and whether it holds the reading. */
36
+ export type ZoneLabel = {
37
+ key: string;
38
+ label: string;
39
+ startPct: number;
40
+ holding: boolean;
19
41
  };
42
+ /**
43
+ * What the caption row says. `reading`: the formatted reading; `parts`: categorical segments name
44
+ * every part instead; `forecast`: committed/forecast keeps the reading plus the forecast caption.
45
+ */
46
+ export type CaptionMode = 'reading' | 'parts' | 'forecast';
20
47
  type Format = (value: number) => string;
21
48
  export declare const isReading: (n: number | null | undefined) => n is number;
22
49
  /** The track's span. A track that ends at or before its start falls back to 1 and is `valid: false`. */
@@ -40,6 +67,19 @@ export declare function normalizeSegments(segments: readonly MeterSegment[]): Me
40
67
  export declare function layoutSegments(segments: readonly MeterSegment[], span: number): Part[];
41
68
  /** `from` is inclusive; a value on the last band's `to` belongs to that band. */
42
69
  export declare function findHoldingZone(zones: readonly MeterZone[], value: number): MeterZone | undefined;
70
+ /** Sub-pixel rounding in measured boxes: two labels touching within this do not collide. */
71
+ export declare const LABEL_SUBPIXEL = 0.5;
72
+ /** A measured label box on one axis (any shared origin), in CSS pixels. */
73
+ export type LabelBox = {
74
+ left: number;
75
+ right: number;
76
+ };
77
+ /**
78
+ * Whether every zone name fits on the band: inside `[0, rowWidth]` and clear of every other name
79
+ * (pairwise, so a long name cannot hide behind a short one between it and a distant neighbour).
80
+ * Boxes are relative to the row's own start edge.
81
+ */
82
+ export declare function zoneLabelsFit(boxes: readonly LabelBox[], rowWidth: number): boolean;
43
83
  /** A zone band as left edge + width in percent, clipped to the track. */
44
84
  export declare function zoneBand(zone: MeterZone, min: number, span: number): {
45
85
  start: number;
@@ -63,14 +103,22 @@ export type BarModel = {
63
103
  /** Percent where the first forecast part starts; absent when the forecast opens the track. */
64
104
  boundaryPct: number | undefined;
65
105
  forecastText: string | null;
106
+ captionMode: CaptionMode;
107
+ /** Only in `parts` mode: one caption per part, in order. Empty otherwise. */
108
+ partCaptions: readonly PartCaption[];
109
+ /** Only on a zoned track: every zone's name, in zone order. Empty otherwise. */
110
+ zoneLabels: readonly ZoneLabel[];
66
111
  markerPct: number | undefined;
67
112
  targetPct: number | undefined;
113
+ /** The default start caption (the zone is named on the band, so it is the bare reading); `startCaption` decides whether it shows. */
68
114
  startText: string;
69
115
  endText: string | null;
70
116
  describedByText: string | null;
71
117
  };
72
118
  /** Segments are amounts accumulated from `min`, so the reading is `min` plus their sum. */
73
119
  export declare const segmentReading: (segments: readonly MeterSegment[], min: number) => number;
120
+ /** The start caption: the consumer's override, else the model's default — absent in `parts` mode. */
121
+ export declare function startCaptionText(model: BarModel, override: ReactNode | undefined): ReactNode;
74
122
  export declare function modelBar(input: BarInput): BarModel;
75
123
  /** The ring's one arc, as a fraction of the circumference. */
76
124
  export declare const ringFraction: (reading: number, min: number, max: number) => number;
@@ -1 +1 @@
1
- {"version":3,"file":"meter-model.d.ts","sourceRoot":"","sources":["../../src/dashboard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MAAM,GAAG,IAAI,CAAA;CAC/B,CAAA;AAeD,2FAA2F;AAC3F,eAAO,MAAM,cAAc,GAAI,UAAU,SAAS,YAAY,EAAE,EAAE,KAAK,MAAM,KAAG,MAC/B,CAAA;AA0BjD,qGAAqG;AACrG,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,CAG5F;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,QAAQ,CAoDlD;AAED,8DAA8D;AAC9D,eAAO,MAAM,YAAY,GAAI,SAAS,MAAM,EAAE,KAAK,MAAM,EAAE,KAAK,MAAM,KAAG,MACvB,CAAA"}
@@ -20,7 +20,14 @@ function layoutSegments(segments, span) {
20
20
  return segments.map((s) => {
21
21
  const size = Math.max(0, Math.min(clamp01(s.value / span), 1 - cursor));
22
22
  const forecast = s.forecast === true;
23
- const part = { start: cursor, size, color: forecast ? void 0 : s.color, forecast };
23
+ const part = {
24
+ start: cursor,
25
+ size,
26
+ color: forecast ? void 0 : s.color,
27
+ forecast,
28
+ label: s.label,
29
+ amount: s.value
30
+ };
24
31
  cursor += size;
25
32
  return part;
26
33
  });
@@ -29,6 +36,13 @@ function findHoldingZone(zones, value) {
29
36
  const end = Math.max(...zones.map((z) => z.to));
30
37
  return zones.find((z) => value >= z.from && (value < z.to || value === z.to && z.to === end));
31
38
  }
39
+ const LABEL_SUBPIXEL = 0.5;
40
+ function zoneLabelsFit(boxes, rowWidth) {
41
+ const sorted = boxes.toSorted((a, b) => a.left - b.left);
42
+ return sorted.every(
43
+ (a, i) => a.left >= -LABEL_SUBPIXEL && a.right <= rowWidth + LABEL_SUBPIXEL && sorted.slice(i + 1).every((b) => a.right <= b.left + LABEL_SUBPIXEL)
44
+ );
45
+ }
32
46
  function zoneBand(zone, min, span) {
33
47
  const lo = clamp01((zone.from - min) / span);
34
48
  const hi = clamp01((zone.to - min) / span);
@@ -47,6 +61,23 @@ function fillParts(input, span, zoned) {
47
61
  return layoutSegments([input.color === void 0 ? fill : { ...fill, color: input.color }], span);
48
62
  }
49
63
  const segmentReading = (segments, min) => segments.reduce((sum, s) => sum + s.value, min);
64
+ function partCaptionsOf(parts, format) {
65
+ return parts.map((p, i) => ({
66
+ key: String(i),
67
+ label: p.label,
68
+ text: format(p.amount),
69
+ color: p.color
70
+ }));
71
+ }
72
+ function captionModeOf(segments, zoned, firstForecast) {
73
+ if (zoned) return "reading";
74
+ if (segments === void 0 || segments.length === 0) return "reading";
75
+ return firstForecast < 0 ? "parts" : "forecast";
76
+ }
77
+ function startCaptionText(model, override) {
78
+ if (override !== void 0) return override;
79
+ return model.captionMode === "parts" ? null : model.startText;
80
+ }
50
81
  function modelBar(input) {
51
82
  const { reading, min, max, format, segments, zones, target } = input;
52
83
  const { span } = spanOf(min, max);
@@ -55,6 +86,8 @@ function modelBar(input) {
55
86
  const parts = fillParts(input, span, zoned);
56
87
  const firstForecast = parts.findIndex((p) => p.forecast);
57
88
  const forecastLabels = segments?.filter((s) => s.forecast === true).map((s) => `${s.label} ${format(s.value)}`) ?? [];
89
+ const captionMode = captionModeOf(segments, zoned, firstForecast);
90
+ const partCaptions = captionMode === "parts" ? partCaptionsOf(parts, format) : [];
58
91
  const zoneText = !zoned ? [] : [
59
92
  ...zones.map((z) => `${z.label} ${format(z.from)} to ${format(z.to)}`),
60
93
  holding === void 0 ? `${format(reading)} is outside every zone` : `${format(reading)} is in ${holding.label}`
@@ -69,15 +102,24 @@ function modelBar(input) {
69
102
  parts,
70
103
  boundaryPct: firstForecast > 0 ? toPct(parts[firstForecast]?.start ?? 0) : void 0,
71
104
  forecastText: forecastLabels.length === 0 ? null : input.forecastCaption ?? `Forecast: ${forecastLabels.join(", ")}`,
105
+ captionMode,
106
+ partCaptions,
107
+ zoneLabels: !zoned ? [] : zones.map((z, i) => ({
108
+ key: String(i),
109
+ label: z.label,
110
+ startPct: zoneBand(z, min, span).start,
111
+ holding: z === holding
112
+ })),
72
113
  markerPct: zoned ? toPct((reading - min) / span) : void 0,
73
114
  targetPct: target === void 0 ? void 0 : toPct((target - min) / span),
74
- startText: holding === void 0 ? format(reading) : `${holding.label} \xB7 ${format(reading)}`,
115
+ startText: format(reading),
75
116
  endText: endCaptionText(reading, target, format),
76
117
  describedByText: describedBy.length > 0 ? describedBy.join("; ") : null
77
118
  };
78
119
  }
79
120
  const ringFraction = (reading, min, max) => clamp01((reading - min) / spanOf(min, max).span);
80
121
  export {
122
+ LABEL_SUBPIXEL,
81
123
  ariaValues,
82
124
  findHoldingZone,
83
125
  isReading,
@@ -87,5 +129,7 @@ export {
87
129
  ringFraction,
88
130
  segmentReading,
89
131
  spanOf,
90
- zoneBand
132
+ startCaptionText,
133
+ zoneBand,
134
+ zoneLabelsFit
91
135
  };
@@ -1 +1 @@
1
- {"version":3,"file":"meter-parts.d.ts","sourceRoot":"","sources":["../../src/dashboard/meter-parts.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAGrD,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAQ,MAAM,eAAe,CAAA;AAIlE,MAAM,MAAM,KAAK,GAAG;IAAE,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,KAAK,EAAE,aAAa,GAAG,SAAS,CAAA;CAAE,CAAA;AAkCvF,wBAAgB,YAAY,CAAC,EAC3B,KAAK,EACL,IAAI,EACJ,KAAK,GACN,EAAE;IACD,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,OAAO,CAAA;IACb,KAAK,EAAE,KAAK,CAAA;CACb,+BAcA;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,+BAgB7F;AAED,wBAAgB,SAAS,CAAC,KA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isuallyHidden } from "@mantine/core";
3
- import { useId } from "react";
3
+ import { useId, useRef, useState } from "react";
4
+ import { useIsomorphicLayoutEffect } from "../common/isomorphic-layout-effect.js";
4
5
  import { cx } from "../common/props.js";
5
- import { ariaValues, modelBar, ringFraction, zoneBand } from "./meter-model.js";
6
+ import {
7
+ ariaValues,
8
+ modelBar,
9
+ ringFraction,
10
+ startCaptionText,
11
+ zoneBand,
12
+ zoneLabelsFit
13
+ } from "./meter-model.js";
6
14
  import classes from "./meter.module.css";
7
15
  import { toPct } from "./scale.js";
16
+ function rootProps(shell) {
17
+ return {
18
+ className: cx(classes.root, shell.className),
19
+ style: shell.style,
20
+ "data-basalt-meter": ""
21
+ };
22
+ }
8
23
  const RING_VIEWBOX = 36;
9
24
  const RING_STROKE = 4;
10
25
  const RING_RADIUS = (RING_VIEWBOX - RING_STROKE) / 2;
@@ -41,7 +56,7 @@ function MeterLoading({
41
56
  ring,
42
57
  shell
43
58
  }) {
44
- return /* @__PURE__ */ jsxs("div", { className: cx(classes.root, shell.className), style: shell.style, "aria-busy": "true", children: [
59
+ return /* @__PURE__ */ jsxs("div", { ...rootProps(shell), "aria-busy": "true", children: [
45
60
  /* @__PURE__ */ jsx(VisuallyHidden, { children: `Loading ${label}` }),
46
61
  ring ? /* @__PURE__ */ jsx(Skeleton, { className: classes.skeletonRing, circle: true }) : /* @__PURE__ */ jsxs(Fragment, { children: [
47
62
  /* @__PURE__ */ jsx(Skeleton, { className: classes.skeletonTrack }),
@@ -51,14 +66,14 @@ function MeterLoading({
51
66
  }
52
67
  function MeterEmpty(props) {
53
68
  const { label, text, ring, shell } = props;
54
- return /* @__PURE__ */ jsxs("output", { className: cx(classes.root, shell.className), style: shell.style, "aria-label": label, children: [
69
+ return /* @__PURE__ */ jsxs("output", { ...rootProps(shell), "aria-label": label, children: [
55
70
  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
71
  /* @__PURE__ */ jsx("span", { className: classes.empty, children: text })
57
72
  ] });
58
73
  }
59
74
  function MeterRing(props) {
60
75
  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(
76
+ return /* @__PURE__ */ jsx("div", { ...rootProps(shell), children: /* @__PURE__ */ jsxs(
62
77
  "span",
63
78
  {
64
79
  className: classes.ringBox,
@@ -88,15 +103,117 @@ function zoneStyle(zone, index, count, min, span) {
88
103
  background: zone.color ?? `color-mix(in srgb, var(--vx-line) ${strength}%, transparent)`
89
104
  };
90
105
  }
106
+ const labelsKey = (labels) => labels.map((l) => l.label + (l.holding ? "*" : "")).join("\0");
107
+ function useZoneLabelLayout(rowRef, key) {
108
+ const [fits, setFits] = useState(true);
109
+ useIsomorphicLayoutEffect(() => {
110
+ const row = rowRef.current;
111
+ if (!row) return;
112
+ const measure = () => {
113
+ const origin = row.getBoundingClientRect();
114
+ const boxes = [...row.children].map((c) => {
115
+ const r = c.getBoundingClientRect();
116
+ return { left: r.left - origin.left, right: r.right - origin.left };
117
+ });
118
+ setFits(zoneLabelsFit(boxes, origin.width));
119
+ };
120
+ measure();
121
+ const observer = typeof ResizeObserver === "undefined" ? void 0 : new ResizeObserver(measure);
122
+ observer?.observe(row);
123
+ const fonts = typeof document === "undefined" ? void 0 : document.fonts;
124
+ let live = true;
125
+ void fonts?.ready?.then(() => live && measure());
126
+ fonts?.addEventListener?.("loadingdone", measure);
127
+ return () => {
128
+ live = false;
129
+ observer?.disconnect();
130
+ fonts?.removeEventListener?.("loadingdone", measure);
131
+ };
132
+ }, [rowRef, key]);
133
+ return fits;
134
+ }
135
+ function ZoneReading({ pct, children }) {
136
+ const rowRef = useRef(null);
137
+ const textRef = useRef(null);
138
+ const [start, setStart] = useState();
139
+ useIsomorphicLayoutEffect(() => {
140
+ const row = rowRef.current;
141
+ const text = textRef.current;
142
+ if (!row || !text) return;
143
+ const measure = () => {
144
+ const centre = row.clientWidth * pct / 100;
145
+ setStart(
146
+ Math.max(0, Math.min(centre - text.offsetWidth / 2, row.clientWidth - text.offsetWidth))
147
+ );
148
+ };
149
+ measure();
150
+ if (typeof ResizeObserver === "undefined") return;
151
+ const observer = new ResizeObserver(measure);
152
+ observer.observe(row);
153
+ observer.observe(text);
154
+ return () => observer.disconnect();
155
+ }, [pct]);
156
+ return /* @__PURE__ */ jsx("div", { ref: rowRef, className: classes.zoneReadingRow, "data-meter-reading-row": true, children: /* @__PURE__ */ jsx(
157
+ "span",
158
+ {
159
+ ref: textRef,
160
+ className: classes.zoneReading,
161
+ "data-measured": start === void 0 ? void 0 : "",
162
+ style: { insetInlineStart: start === void 0 ? `${pct}%` : `${start}px` },
163
+ children
164
+ }
165
+ ) });
166
+ }
167
+ function ZoneName({ label, ...rest }) {
168
+ return /* @__PURE__ */ jsx(
169
+ "span",
170
+ {
171
+ ...rest,
172
+ className: cx(rest.className, label.holding && classes.zoneLabelHolding),
173
+ "data-meter-zone-label": label.label,
174
+ "data-holding": label.holding || void 0,
175
+ children: label.label
176
+ }
177
+ );
178
+ }
179
+ function ZoneLabels({ labels }) {
180
+ const rowRef = useRef(null);
181
+ const fits = useZoneLabelLayout(rowRef, labelsKey(labels));
182
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
183
+ /* @__PURE__ */ jsx(
184
+ "div",
185
+ {
186
+ ref: rowRef,
187
+ className: classes.zoneBand,
188
+ "data-meter-zone-band": true,
189
+ "data-collapsed": fits ? void 0 : "",
190
+ "aria-hidden": true,
191
+ children: labels.map((l) => /* @__PURE__ */ jsx(
192
+ ZoneName,
193
+ {
194
+ label: l,
195
+ className: classes.zoneLabel,
196
+ style: { insetInlineStart: `${l.startPct}%` }
197
+ },
198
+ l.key
199
+ ))
200
+ }
201
+ ),
202
+ !fits && /* @__PURE__ */ jsx("div", { className: classes.zoneList, "data-meter-zone-list": true, "aria-hidden": true, children: labels.map((l) => /* @__PURE__ */ jsx(ZoneName, { label: l, className: classes.zoneListItem }, l.key)) })
203
+ ] });
204
+ }
91
205
  function MeterBar(props) {
92
206
  const { label, reading, min, max, format, zones, shell } = props;
93
207
  const describedId = useId();
94
208
  const model = modelBar(props);
95
- const start = props.startCaption === void 0 ? model.startText : props.startCaption;
209
+ const start = startCaptionText(model, props.startCaption);
96
210
  const end = props.endCaption === void 0 ? model.endText : props.endCaption;
97
- const hasCaptions = start !== null || end !== null || model.forecastText !== null;
211
+ const anchored = model.markerPct !== void 0 && start !== null;
212
+ const hasCaptions = start !== null && !anchored || end !== null || model.forecastText !== null;
213
+ const hasParts = model.partCaptions.length > 0;
98
214
  const describedBy = model.describedByText === null ? {} : { "aria-describedby": describedId };
99
- return /* @__PURE__ */ jsxs("div", { className: cx(classes.root, shell.className), style: shell.style, children: [
215
+ const root = rootProps(shell);
216
+ return /* @__PURE__ */ jsxs("div", { ...root, className: cx(root.className, model.zoneLabels.length > 0 && classes.zoned), children: [
100
217
  /* @__PURE__ */ jsxs(
101
218
  "div",
102
219
  {
@@ -131,9 +248,26 @@ function MeterBar(props) {
131
248
  ]
132
249
  }
133
250
  ),
251
+ model.zoneLabels.length > 0 && /* @__PURE__ */ jsx(ZoneLabels, { labels: model.zoneLabels }),
252
+ anchored && /* @__PURE__ */ jsx(ZoneReading, { pct: model.markerPct ?? 0, children: start }),
134
253
  model.describedByText !== null && /* @__PURE__ */ jsx(VisuallyHidden, { id: describedId, children: model.describedByText }),
254
+ hasParts && // The explicit role is deliberate: `list-style: none` makes Safari/VoiceOver drop the implicit one.
255
+ // oxlint-disable-next-line jsx-a11y/no-redundant-roles
256
+ /* @__PURE__ */ jsx("ul", { className: classes.partCaptions, role: "list", "data-meter-parts": true, children: model.partCaptions.map((c) => /* @__PURE__ */ jsxs("li", { className: classes.partCaption, children: [
257
+ /* @__PURE__ */ jsx(
258
+ "span",
259
+ {
260
+ className: classes.swatch,
261
+ style: { background: c.color ?? "var(--vx-line)" },
262
+ "aria-hidden": true
263
+ }
264
+ ),
265
+ c.label,
266
+ " ",
267
+ c.text
268
+ ] }, c.key)) }),
135
269
  hasCaptions && /* @__PURE__ */ jsxs("div", { className: classes.captions, "data-meter-captions": true, children: [
136
- start !== null && /* @__PURE__ */ jsx("span", { className: classes.caption, children: start }),
270
+ start !== null && !anchored && /* @__PURE__ */ jsx("span", { className: classes.caption, children: start }),
137
271
  model.forecastText !== null && /* @__PURE__ */ jsx("span", { className: classes.caption, children: model.forecastText }),
138
272
  end !== null && /* @__PURE__ */ jsx("span", { className: classes.captionEnd, children: end })
139
273
  ] })
@@ -11,15 +11,26 @@
11
11
  * track end; the caption still states the real value.
12
12
  *
13
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.
14
+ * passes a status colour) and the reading becomes a MARKER on the track, not a fill. Each zone is
15
+ * named under the band at its start, the one holding the value (`from` inclusive) in ink and a
16
+ * heavier weight; names that would collide wrap as a list instead. The fit is measured in the
17
+ * browser, so server markup shows the band and the list may appear after mount. Use it for a
18
+ * reading judged against ranges.
19
+ *
20
+ * Every state (bar, ring, empty, loading) carries `data-basalt-meter` on its root. That attribute is
21
+ * the contract with `StatCard`: a Meter passed as its `sparkline` visual makes the slot size to content
22
+ * and keep the card's inline inset (both placements) instead of the sparkline's fixed height and bleed.
23
+ *
24
+ * Categorical `segments` (no `forecast` part) are captioned one per part — swatch, name, value — under
25
+ * the track and the default start caption is dropped (an explicit `startCaption` still shows);
26
+ * committed/forecast keeps the reading plus the forecast caption.
16
27
  *
17
28
  * @example
18
29
  * import { Meter } from 'basalt-ui'
19
30
  *
20
31
  * // Spend against a budget: past the target the end caption states the overage.
21
32
  * <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".
33
+ * // Training load as a zone band with a marker: the zones are named under the band, "Optimal" in ink.
23
34
  * <Meter
24
35
  * label="Training load"
25
36
  * max={1000}
@@ -60,7 +71,7 @@ type BarCommon = Common & {
60
71
  shape?: 'bar';
61
72
  /** Target position; draws a tick and states it in the end caption (with the overage past it). */
62
73
  target?: number;
63
- /** Start caption (default: the formatted reading, or `Zone · reading`). `null` drops it. */
74
+ /** Start caption (default: the formatted reading). `null` drops it. */
64
75
  startCaption?: ReactNode;
65
76
  /** End caption (default: `Target <target>`). `null` drops it. */
66
77
  endCaption?: ReactNode;
@@ -91,7 +102,7 @@ export type MeterProps = (BarCommon & {
91
102
  value?: number | null | undefined;
92
103
  /**
93
104
  * 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.
105
+ * and each band is named under the track, the one that holds it in ink.
95
106
  */
96
107
  zones: readonly MeterZone[];
97
108
  segments?: never;
@@ -1 +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,EAA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AG;IACX,+EAA+E;IAC/E,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;IACjC,sEAAsE;IACtE,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,KAAK,CAAA;IAChB,KAAK,CAAC,EAAE,KAAK,CAAA;CACd,CAAC,GACF,CAAC,SAAS,GAAG;IACX,wGAAwG;IACxG,QAAQ,EAAE,SAAS,YAAY,EAAE,CAAA;IACjC,mFAAmF;IACnF,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,KAAK,CAAC,EAAE,KAAK,CAAA;CACd,CAAC,GACF,CAAC,SAAS,GAAG;IACX,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;IACjC;;;OAGG;IACH,KAAK,EAAE,SAAS,SAAS,EAAE,CAAA;IAC3B,QAAQ,CAAC,EAAE,KAAK,CAAA;IAChB,KAAK,CAAC,EAAE,KAAK,CAAA;CACd,CAAC,GACF,CAAC,MAAM,GAAG;IACR,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;IACjC,2CAA2C;IAC3C,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,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"}
@@ -11,6 +11,10 @@
11
11
  min-width: 0;
12
12
  }
13
13
 
14
+ .root.zoned {
15
+ position: relative;
16
+ }
17
+
14
18
  .track {
15
19
  position: relative;
16
20
  display: flex;
@@ -41,6 +45,86 @@
41
45
  inset-block: 0;
42
46
  }
43
47
 
48
+ /*
49
+ * Zone names under the band: absolutely placed at each band start so they stay on the band. When
50
+ * they would collide the band collapses (hidden but still laid out, so it can be re-measured) and the
51
+ * same names wrap as a list. The holding zone is ink, the rest muted.
52
+ */
53
+ .zoneBand {
54
+ position: relative;
55
+ /* Labels are absolutely placed, so the row needs its own line height. */
56
+ height: 1.25em;
57
+ font-family: var(--basalt-font-mono);
58
+ font-size: var(--vx-text-micro);
59
+ color: var(--vx-muted);
60
+ }
61
+
62
+ /*
63
+ * Hidden but laid out, so a resize can measure it again. Absolute against `.root.zoned`, which has
64
+ * no inline padding, so `inset-inline: 0` gives the band the same width as when it was in flow.
65
+ */
66
+ .zoneBand[data-collapsed] {
67
+ position: absolute;
68
+ top: 0;
69
+ inset-inline: 0;
70
+ visibility: hidden;
71
+ pointer-events: none;
72
+ }
73
+
74
+ .zoneLabel {
75
+ position: absolute;
76
+ top: 0;
77
+ white-space: nowrap;
78
+ }
79
+
80
+ .zoneLabelHolding {
81
+ font-weight: 500;
82
+ color: var(--vx-ink);
83
+ }
84
+
85
+ .zoneList {
86
+ display: flex;
87
+ flex-wrap: wrap;
88
+ gap: var(--vx-space-stack-xs) var(--vx-space-stack-sm);
89
+ font-family: var(--basalt-font-mono);
90
+ font-size: var(--vx-text-micro);
91
+ color: var(--vx-muted);
92
+ }
93
+
94
+ .zoneListItem {
95
+ min-width: 0;
96
+ overflow-wrap: anywhere;
97
+ }
98
+
99
+ /* The reading under the band, centred on the marker. Clipped so it never widens the row before the first measure. */
100
+ .zoneReadingRow {
101
+ --basalt-reading-dir: 1;
102
+ position: relative;
103
+ height: 1.25em;
104
+ overflow: clip;
105
+ font-family: var(--basalt-font-mono);
106
+ font-size: var(--vx-text-micro);
107
+ }
108
+
109
+ .zoneReadingRow:dir(rtl) {
110
+ --basalt-reading-dir: -1;
111
+ }
112
+
113
+ /* Before the first measure the start edge sits AT the marker, so the label shifts back half its width
114
+ * along the inline axis (the physical `translate` flips sign in RTL). Measured, the start edge is exact. */
115
+ .zoneReading {
116
+ position: absolute;
117
+ top: 0;
118
+ translate: calc(-50% * var(--basalt-reading-dir)) 0;
119
+ white-space: nowrap;
120
+ font-weight: 500;
121
+ color: var(--vx-ink);
122
+ }
123
+
124
+ .zoneReading[data-measured] {
125
+ translate: none;
126
+ }
127
+
44
128
  /* The reading on a zone track: a notch standing proud of the bands, in ink. */
45
129
  .marker {
46
130
  position: absolute;
@@ -48,7 +132,7 @@
48
132
  bottom: -3px;
49
133
  width: 3px;
50
134
  margin-inline-start: -1.5px;
51
- border-radius: 1px;
135
+ border-radius: var(--vx-radius-fine);
52
136
  background: var(--vx-ink);
53
137
  }
54
138
 
@@ -58,7 +142,7 @@
58
142
  bottom: -2px;
59
143
  width: 2px;
60
144
  margin-inline-start: -1px;
61
- border-radius: 1px;
145
+ border-radius: var(--vx-radius-fine);
62
146
  background: var(--vx-ink);
63
147
  }
64
148
 
@@ -69,6 +153,7 @@
69
153
 
70
154
  .captions {
71
155
  display: flex;
156
+ flex-wrap: wrap;
72
157
  align-items: baseline;
73
158
  justify-content: space-between;
74
159
  gap: var(--vx-space-control-gap, 0.375rem);
@@ -77,18 +162,46 @@
77
162
  color: var(--vx-muted);
78
163
  }
79
164
 
165
+ /* Captions never truncate: the row wraps, and a caption wider than the row wraps inside itself. */
80
166
  .caption {
81
- white-space: nowrap;
167
+ min-width: 0;
168
+ overflow-wrap: anywhere;
82
169
  }
83
170
 
171
+ /* Alone in the row, or wrapped onto its own line, the end caption still sits at the end. */
84
172
  .captionEnd {
85
173
  composes: caption;
174
+ margin-inline-start: auto;
86
175
  text-align: end;
87
176
  }
88
177
 
89
- /* Alone in the row, the end caption still sits at the end. */
90
- .captionEnd:first-child {
91
- margin-inline-start: auto;
178
+ /* Categorical segments: one caption per part under the track, wrapping at narrow widths. */
179
+ .partCaptions {
180
+ display: flex;
181
+ flex-wrap: wrap;
182
+ gap: var(--vx-space-stack-xs, 0.25rem) var(--vx-space-stack-sm);
183
+ margin: 0;
184
+ padding: 0;
185
+ list-style: none;
186
+ font-family: var(--basalt-font-mono);
187
+ font-size: var(--vx-text-micro);
188
+ color: var(--vx-muted);
189
+ }
190
+
191
+ .partCaption {
192
+ display: inline-flex;
193
+ align-items: baseline;
194
+ gap: var(--vx-space-control-gap, 0.375rem);
195
+ min-width: 0;
196
+ overflow-wrap: anywhere;
197
+ }
198
+
199
+ /* A shape cue beside the name, so the part never reads by colour alone. */
200
+ .swatch {
201
+ flex: none;
202
+ width: 0.5rem;
203
+ height: 0.5rem;
204
+ border-radius: var(--vx-radius-fine);
92
205
  }
93
206
 
94
207
  .empty {
@@ -114,8 +227,13 @@
114
227
  align-items: center;
115
228
  justify-content: center;
116
229
  align-self: flex-start;
117
- width: 5rem;
118
- height: 5rem;
230
+ box-sizing: border-box;
231
+ /* 80px, growing (still square) when the value is wider than the ring's inner circle. */
232
+ min-width: 5rem;
233
+ width: max-content;
234
+ aspect-ratio: 1;
235
+ /* 12px at the default step: keeps the value inside the ring's stroke. */
236
+ padding: calc(1.5 * var(--vx-space-stack-sm, 0.5rem));
119
237
  }
120
238
 
121
239
  .ring {
@@ -139,7 +257,7 @@
139
257
  .ringValue {
140
258
  position: relative;
141
259
  font-family: var(--basalt-font-mono);
142
- font-size: var(--vx-text-md);
260
+ font-size: var(--vx-text-kpi);
143
261
  font-weight: 500;
144
262
  color: var(--vx-ink);
145
263
  }