basalt-ui 2.21.0 → 2.23.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 (254) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/MIGRATING.md +452 -12
  3. package/agent/agents/basalt-design-reviewer.md +1 -1
  4. package/agent/rules/basalt-tokens.md +1 -1
  5. package/agent/skills/basalt-design/SKILL.md +1 -1
  6. package/agent/skills/basalt-design/references/anti-defaults.md +1 -1
  7. package/agent/skills/basalt-design/references/catalogue.md +1 -0
  8. package/dist/charts/BandStrip.d.ts.map +1 -1
  9. package/dist/charts/BandStrip.js +73 -3
  10. package/dist/charts/Bars.d.ts.map +1 -1
  11. package/dist/charts/Bars.js +6 -0
  12. package/dist/charts/CartesianChart.d.ts +10 -0
  13. package/dist/charts/CartesianChart.d.ts.map +1 -1
  14. package/dist/charts/CartesianChart.js +8 -5
  15. package/dist/charts/ChartCard.d.ts +12 -3
  16. package/dist/charts/ChartCard.d.ts.map +1 -1
  17. package/dist/charts/ChartCard.js +39 -8
  18. package/dist/charts/DualPanel.d.ts.map +1 -1
  19. package/dist/charts/DualPanel.js +5 -8
  20. package/dist/charts/Heatmap.d.ts +12 -1
  21. package/dist/charts/Heatmap.d.ts.map +1 -1
  22. package/dist/charts/Heatmap.js +34 -5
  23. package/dist/charts/Lines.d.ts +3 -0
  24. package/dist/charts/Lines.d.ts.map +1 -1
  25. package/dist/charts/Lines.js +29 -6
  26. package/dist/charts/MirroredBars.d.ts.map +1 -1
  27. package/dist/charts/MirroredBars.js +4 -6
  28. package/dist/charts/Sparkline.d.ts +14 -2
  29. package/dist/charts/Sparkline.d.ts.map +1 -1
  30. package/dist/charts/Sparkline.js +101 -22
  31. package/dist/charts/StackedArea.d.ts +4 -1
  32. package/dist/charts/StackedArea.d.ts.map +1 -1
  33. package/dist/charts/StackedArea.js +9 -3
  34. package/dist/charts/band-fold.d.ts +38 -1
  35. package/dist/charts/band-fold.d.ts.map +1 -1
  36. package/dist/charts/band-fold.js +18 -1
  37. package/dist/charts/chart-box.module.css +19 -0
  38. package/dist/charts/chart-card.module.css +25 -0
  39. package/dist/charts/chart-dates.d.ts +12 -0
  40. package/dist/charts/chart-dates.d.ts.map +1 -0
  41. package/dist/charts/chart-dates.js +16 -0
  42. package/dist/charts/chart-legend.module.css +7 -0
  43. package/dist/charts/compile.d.ts +25 -6
  44. package/dist/charts/compile.d.ts.map +1 -1
  45. package/dist/charts/compile.js +152 -72
  46. package/dist/charts/date-tick-format.d.ts +5 -5
  47. package/dist/charts/date-tick-format.d.ts.map +1 -1
  48. package/dist/charts/date-tick-format.js +3 -7
  49. package/dist/charts/labels.d.ts +21 -6
  50. package/dist/charts/labels.d.ts.map +1 -1
  51. package/dist/charts/labels.js +52 -17
  52. package/dist/charts/legend.d.ts +2 -0
  53. package/dist/charts/legend.d.ts.map +1 -1
  54. package/dist/charts/legend.js +7 -21
  55. package/dist/charts/marks.js +1 -1
  56. package/dist/charts/panel.d.ts +0 -6
  57. package/dist/charts/panel.d.ts.map +1 -1
  58. package/dist/charts/panel.js +1 -10
  59. package/dist/charts/ref-label.d.ts +43 -0
  60. package/dist/charts/ref-label.d.ts.map +1 -0
  61. package/dist/charts/ref-label.js +75 -0
  62. package/dist/charts/scales.d.ts +4 -1
  63. package/dist/charts/scales.d.ts.map +1 -1
  64. package/dist/charts/scales.js +14 -3
  65. package/dist/charts/sparkline.module.css +13 -17
  66. package/dist/charts/sparkline.module.css.d.ts +1 -2
  67. package/dist/charts/state.d.ts +2 -0
  68. package/dist/charts/state.d.ts.map +1 -1
  69. package/dist/charts/state.js +5 -2
  70. package/dist/charts/types.d.ts +18 -8
  71. package/dist/charts/types.d.ts.map +1 -1
  72. package/dist/cli/doctor-upgrade.d.ts +1 -0
  73. package/dist/cli/doctor-upgrade.d.ts.map +1 -1
  74. package/dist/cli/doctor-upgrade.js +1 -0
  75. package/dist/cli/init.d.ts +2 -0
  76. package/dist/cli/init.d.ts.map +1 -1
  77. package/dist/cli/init.js +68 -4
  78. package/dist/cli/shot/capture.d.ts +21 -2
  79. package/dist/cli/shot/capture.d.ts.map +1 -1
  80. package/dist/cli/shot/capture.js +202 -36
  81. package/dist/cli/shot/detect.d.ts.map +1 -1
  82. package/dist/cli/shot/detect.js +17 -1
  83. package/dist/cli/shot/playwright.d.ts +13 -2
  84. package/dist/cli/shot/playwright.d.ts.map +1 -1
  85. package/dist/cli/shot/playwright.js +5 -1
  86. package/dist/cli/shot/types.d.ts +4 -0
  87. package/dist/cli/shot/types.d.ts.map +1 -1
  88. package/dist/cli/shot/types.js +2 -0
  89. package/dist/cli/tokens-css.d.ts +5 -7
  90. package/dist/cli/tokens-css.d.ts.map +1 -1
  91. package/dist/cli/tokens-css.js +11 -12
  92. package/dist/controls/controls.module.css +11 -1
  93. package/dist/controls/filter-pill.d.ts.map +1 -1
  94. package/dist/controls/filter-pill.js +1 -0
  95. package/dist/controls/sync-button.d.ts.map +1 -1
  96. package/dist/controls/sync-button.js +22 -3
  97. package/dist/controls/sync-button.module.css +34 -2
  98. package/dist/controls/sync-button.module.css.d.ts +1 -0
  99. package/dist/dashboard/bar-list.d.ts +6 -1
  100. package/dist/dashboard/bar-list.d.ts.map +1 -1
  101. package/dist/dashboard/bar-list.js +15 -8
  102. package/dist/dashboard/bar-list.module.css +83 -0
  103. package/dist/dashboard/bar-list.module.css.d.ts +1 -0
  104. package/dist/dashboard/delta-badge.d.ts.map +1 -1
  105. package/dist/dashboard/delta-badge.js +2 -2
  106. package/dist/dashboard/index.d.ts +1 -0
  107. package/dist/dashboard/index.d.ts.map +1 -1
  108. package/dist/dashboard/index.js +2 -0
  109. package/dist/dashboard/meter-model.d.ts +84 -5
  110. package/dist/dashboard/meter-model.d.ts.map +1 -1
  111. package/dist/dashboard/meter-model.js +100 -15
  112. package/dist/dashboard/meter-parts.d.ts +9 -1
  113. package/dist/dashboard/meter-parts.d.ts.map +1 -1
  114. package/dist/dashboard/meter-parts.js +276 -74
  115. package/dist/dashboard/meter.d.ts +54 -65
  116. package/dist/dashboard/meter.d.ts.map +1 -1
  117. package/dist/dashboard/meter.js +21 -4
  118. package/dist/dashboard/meter.module.css +76 -0
  119. package/dist/dashboard/meter.module.css.d.ts +6 -0
  120. package/dist/dashboard/page-summary.d.ts +20 -0
  121. package/dist/dashboard/page-summary.d.ts.map +1 -0
  122. package/dist/dashboard/page-summary.js +28 -0
  123. package/dist/dashboard/page-summary.module.css +89 -0
  124. package/dist/dashboard/page-summary.module.css.d.ts +15 -0
  125. package/dist/dashboard/query-state.d.ts.map +1 -1
  126. package/dist/dashboard/query-state.js +1 -1
  127. package/dist/dashboard/section.d.ts +25 -2
  128. package/dist/dashboard/section.d.ts.map +1 -1
  129. package/dist/dashboard/section.js +10 -5
  130. package/dist/dashboard/section.module.css +23 -0
  131. package/dist/dashboard/section.module.css.d.ts +1 -0
  132. package/dist/dashboard/stat-card-parts.d.ts.map +1 -1
  133. package/dist/dashboard/stat-card-parts.js +1 -1
  134. package/dist/dashboard/stat-card.d.ts +4 -2
  135. package/dist/dashboard/stat-card.d.ts.map +1 -1
  136. package/dist/dashboard/stat-card.js +7 -5
  137. package/dist/dashboard/stat-card.module.css +36 -0
  138. package/dist/dashboard/stat-group.module.css +7 -0
  139. package/dist/dashboard/stat-strip.d.ts +22 -6
  140. package/dist/dashboard/stat-strip.d.ts.map +1 -1
  141. package/dist/dashboard/stat-strip.js +104 -60
  142. package/dist/dashboard/stat-strip.module.css +122 -53
  143. package/dist/dashboard/stat-strip.module.css.d.ts +4 -0
  144. package/dist/dashboard/visual-slot.d.ts +7 -1
  145. package/dist/dashboard/visual-slot.d.ts.map +1 -1
  146. package/dist/dashboard/visual-slot.js +3 -1
  147. package/dist/guard/index.d.ts.map +1 -1
  148. package/dist/guard/index.js +0 -5
  149. package/dist/guard/vx-names.d.ts.map +1 -1
  150. package/dist/guard/vx-names.js +2 -0
  151. package/dist/index.d.ts +1 -1
  152. package/dist/index.d.ts.map +1 -1
  153. package/dist/index.js +3 -1
  154. package/dist/styles.css +43 -4
  155. package/dist/theme/chrome-vars.d.ts +20 -5
  156. package/dist/theme/chrome-vars.d.ts.map +1 -1
  157. package/dist/theme/chrome-vars.js +46 -3
  158. package/dist/theme/controls.module.css +37 -0
  159. package/dist/theme/controls.module.css.d.ts +2 -0
  160. package/dist/theme/index.d.ts.map +1 -1
  161. package/dist/theme/index.js +18 -27
  162. package/dist/theme/status-verdict.d.ts.map +1 -1
  163. package/dist/theme/status-verdict.js +9 -1
  164. package/dist/tokens/core.d.ts +2 -1
  165. package/dist/tokens/core.d.ts.map +1 -1
  166. package/dist/tokens/core.js +6 -1
  167. package/dist/tokens/derive.d.ts +3 -1
  168. package/dist/tokens/derive.d.ts.map +1 -1
  169. package/dist/tokens/derive.js +16 -1
  170. package/dist/tokens/palette.d.ts +11 -10
  171. package/dist/tokens/palette.d.ts.map +1 -1
  172. package/dist/tokens/palette.js +11 -10
  173. package/dist/tokens/status-text.d.ts.map +1 -1
  174. package/dist/tokens/status-text.js +3 -1
  175. package/llms.txt +42 -22
  176. package/package.json +1 -1
  177. package/src/charts/BandStrip.tsx +83 -3
  178. package/src/charts/Bars.tsx +7 -0
  179. package/src/charts/CartesianChart.tsx +18 -3
  180. package/src/charts/ChartCard.tsx +54 -13
  181. package/src/charts/DualPanel.tsx +3 -6
  182. package/src/charts/Heatmap.tsx +54 -5
  183. package/src/charts/Lines.tsx +56 -10
  184. package/src/charts/MirroredBars.tsx +3 -5
  185. package/src/charts/Sparkline.tsx +135 -25
  186. package/src/charts/StackedArea.tsx +14 -4
  187. package/src/charts/band-fold.ts +50 -1
  188. package/src/charts/chart-box.module.css +19 -0
  189. package/src/charts/chart-card.module.css +25 -0
  190. package/src/charts/chart-dates.ts +30 -0
  191. package/src/charts/chart-legend.module.css +7 -0
  192. package/src/charts/compile.ts +253 -87
  193. package/src/charts/date-tick-format.ts +10 -13
  194. package/src/charts/labels.ts +81 -26
  195. package/src/charts/legend.tsx +10 -20
  196. package/src/charts/marks.ts +1 -1
  197. package/src/charts/panel.tsx +1 -16
  198. package/src/charts/ref-label.ts +131 -0
  199. package/src/charts/scales.ts +22 -2
  200. package/src/charts/sparkline.module.css +13 -17
  201. package/src/charts/sparkline.module.css.d.ts +1 -2
  202. package/src/charts/state.tsx +9 -4
  203. package/src/charts/types.ts +18 -8
  204. package/src/cli/doctor-upgrade.ts +1 -1
  205. package/src/cli/init.ts +100 -3
  206. package/src/cli/shot/capture.ts +266 -35
  207. package/src/cli/shot/detect.ts +18 -1
  208. package/src/cli/shot/playwright.ts +20 -4
  209. package/src/cli/shot/types.ts +5 -0
  210. package/src/cli/tokens-css.ts +18 -20
  211. package/src/controls/controls.module.css +11 -1
  212. package/src/controls/filter-pill.tsx +2 -0
  213. package/src/controls/sync-button.module.css +34 -2
  214. package/src/controls/sync-button.module.css.d.ts +1 -0
  215. package/src/controls/sync-button.tsx +40 -4
  216. package/src/dashboard/bar-list.module.css +83 -0
  217. package/src/dashboard/bar-list.module.css.d.ts +1 -0
  218. package/src/dashboard/bar-list.tsx +107 -69
  219. package/src/dashboard/delta-badge.tsx +6 -2
  220. package/src/dashboard/index.ts +1 -0
  221. package/src/dashboard/meter-model.ts +207 -24
  222. package/src/dashboard/meter-parts.tsx +349 -67
  223. package/src/dashboard/meter.module.css +76 -0
  224. package/src/dashboard/meter.module.css.d.ts +6 -0
  225. package/src/dashboard/meter.tsx +72 -18
  226. package/src/dashboard/page-summary.module.css +89 -0
  227. package/src/dashboard/page-summary.module.css.d.ts +15 -0
  228. package/src/dashboard/page-summary.tsx +95 -0
  229. package/src/dashboard/query-state.tsx +1 -1
  230. package/src/dashboard/section.module.css +23 -0
  231. package/src/dashboard/section.module.css.d.ts +1 -0
  232. package/src/dashboard/section.tsx +59 -11
  233. package/src/dashboard/stat-card-parts.tsx +5 -1
  234. package/src/dashboard/stat-card.module.css +36 -0
  235. package/src/dashboard/stat-card.tsx +12 -6
  236. package/src/dashboard/stat-group.module.css +7 -0
  237. package/src/dashboard/stat-strip.module.css +122 -53
  238. package/src/dashboard/stat-strip.module.css.d.ts +4 -0
  239. package/src/dashboard/stat-strip.tsx +176 -91
  240. package/src/dashboard/visual-slot.ts +12 -3
  241. package/src/guard/index.ts +0 -5
  242. package/src/guard/vx-names.ts +2 -0
  243. package/src/index.ts +2 -0
  244. package/src/styles.css +43 -4
  245. package/src/theme/__snapshots__/plain-theme.test.ts.snap +200 -68
  246. package/src/theme/chrome-vars.ts +77 -8
  247. package/src/theme/controls.module.css +37 -0
  248. package/src/theme/controls.module.css.d.ts +2 -0
  249. package/src/theme/index.ts +22 -32
  250. package/src/theme/status-verdict.tsx +5 -1
  251. package/src/tokens/core.ts +4 -1
  252. package/src/tokens/derive.ts +32 -3
  253. package/src/tokens/palette.ts +11 -10
  254. package/src/tokens/status-text.ts +2 -0
@@ -7,6 +7,7 @@ declare const classes: {
7
7
  readonly summary: string
8
8
  readonly track: string
9
9
  readonly trackBox: string
10
+ readonly trackHidden: string
10
11
  readonly fill: string
11
12
  readonly forecastFill: string
12
13
  readonly zone: string
@@ -22,8 +23,11 @@ declare const classes: {
22
23
  readonly captions: string
23
24
  readonly caption: string
24
25
  readonly captionEnd: string
26
+ readonly captionsAnchored: string
25
27
  readonly partCaptions: string
26
28
  readonly partCaption: string
29
+ readonly partCaptionsUnder: string
30
+ readonly partCaptionsWrap: string
27
31
  readonly swatch: string
28
32
  readonly empty: string
29
33
  readonly skeletonTrack: string
@@ -32,6 +36,8 @@ declare const classes: {
32
36
  readonly ring: string
33
37
  readonly ringTrack: string
34
38
  readonly ringArc: string
39
+ readonly ringTick: string
40
+ readonly ringTickHalo: string
35
41
  readonly ringValue: string
36
42
  readonly skeletonRing: string
37
43
  readonly row: string
@@ -51,12 +51,15 @@
51
51
  * />
52
52
  * <Meter shape="ring" label="Cache hit rate" value={87} max={100} format={(v) => `${v}%`} />
53
53
  */
54
+ import { useContext } from 'react'
54
55
  import type { ReactNode } from 'react'
55
56
  import type { BasaltProps } from '../common/props'
57
+ import { VX } from '../tokens'
56
58
  import { isReading, normalizeSegments, segmentReading, spanOf } from './meter-model'
57
59
  import type { MeterSegment, MeterTick, MeterZone } from './meter-model'
58
60
  import { MeterBar, MeterEmpty, MeterLoading, MeterRing } from './meter-parts'
59
61
  import { asText } from './scale'
62
+ import { VisualSlotContext } from './visual-slot'
60
63
 
61
64
  type Common = BasaltProps & {
62
65
  /** Accessible name (`aria-label`). Required: a meter without one is announced as a bare number. */
@@ -69,7 +72,7 @@ type Common = BasaltProps & {
69
72
  format?: (value: number) => string
70
73
  /** Renders a skeleton with the meter's footprint. */
71
74
  loading?: boolean
72
- /** Muted line shown when there is no reading. The track stays so the footprint holds. */
75
+ /** Muted line shown when there is no reading; none by default (the reading is `—`). The track stays so the footprint holds. */
73
76
  emptyText?: string
74
77
  }
75
78
 
@@ -79,10 +82,13 @@ type BarCommon = Common & {
79
82
  target?: number
80
83
  /**
81
84
  * More marks on the track (cut-offs, a window mean). Each is drawn at `at`; a `label` is captioned
82
- * above the track, or on a zoned Meter in the zone-name row (the end ticks at the row's ends). A
83
- * caption that would collide with another hides. A tick outside `[min, max]` is dropped, not
84
- * clamped. All are listed in the accessible description. Works with `value`, `zones`, `segments`
85
- * and `target`.
85
+ * above the track, or on a zoned Meter in the zone-name row (the end ticks at the row's ends); a
86
+ * `caption` sits under the track, centred on the mark and clamped inside it. A label that would
87
+ * collide with another hides. A tick outside `[min, max]` is dropped, not clamped. All are listed
88
+ * in the accessible description. Works with `value`, `zones`, `segments` and `target`.
89
+ *
90
+ * Given `ticks` (or a `target`), a plain or segmented bar also labels where its track starts: the
91
+ * start figure `format(min)`, above the track. `startCaption={null}` drops it.
86
92
  */
87
93
  ticks?: readonly MeterTick[]
88
94
  /**
@@ -94,14 +100,28 @@ type BarCommon = Common & {
94
100
  tone?: 'muted' | 'ink'
95
101
  /**
96
102
  * `'row'`: in-line use — a track one text line tall and no caption rows (reading, target, forecast,
97
- * part, zone and tick captions). The label stays as `aria-label`; the described-by text keeps the
98
- * rest. Put the value beside it in your own layout.
103
+ * zone and tick captions). Categorical `segments` keep their per-part captions (swatch, name, value)
104
+ * so the parts stay named. The label stays as `aria-label`; the described-by text keeps the rest.
105
+ * Put the value beside it in your own layout.
99
106
  */
100
107
  size?: 'row'
101
- /** Start caption (default: the formatted reading). `null` drops it. */
108
+ /**
109
+ * Start caption (default: the formatted reading). `null` drops it, and the start figure that
110
+ * `ticks`/`target` add above the track; zone labels stay.
111
+ */
102
112
  startCaption?: ReactNode
103
- /** End caption (default: `Target <target>`). `null` drops it. */
113
+ /**
114
+ * End caption (default: `Target <target>` with the Meter's `format`, drawn at the target's tick
115
+ * rather than the track end when it fits). `null` drops it; zone labels stay.
116
+ */
104
117
  endCaption?: ReactNode
118
+ /**
119
+ * The reading printed at the marker of a zoned bar. Default `true`, and `false` inside a basalt host
120
+ * (`StatCard`, a strip cell's `visual`) that already states the value. Pass `false` when YOUR
121
+ * headline states it: the marker stays and keeps its `aria-valuenow` / `aria-valuetext`. Pass `true`
122
+ * to print it inside a host. A `stops` track prints it only when `true`.
123
+ */
124
+ reading?: boolean
105
125
  }
106
126
 
107
127
  /**
@@ -109,7 +129,9 @@ type BarCommon = Common & {
109
129
  * - Bar `value` (+ `target`, `color`): one reading on a neutral track.
110
130
  * - Bar `segments`: ordered parts that sum to the reading (committed/forecast, part of a whole).
111
131
  * - Bar `value` + `zones`: the reading is a marker against contiguous bands.
112
- * - Ring (`shape: 'ring'`) `value` (+ `color`): one headline ratio; no target, captions, segments or zones.
132
+ * - Bar `value` + `stops`: the reading is a marker on one gradient track.
133
+ * - Ring (`shape: 'ring'`) `value` (+ `color`, `target`, `ticks`): one headline ratio; no captions,
134
+ * segments or zones.
113
135
  */
114
136
  export type MeterProps =
115
137
  | (BarCommon & {
@@ -117,6 +139,17 @@ export type MeterProps =
117
139
  value?: number | null | undefined
118
140
  /** A status colour, for a verdict only. Omit for the neutral fill. */
119
141
  color?: string
142
+ /**
143
+ * `false` draws no track for a value with nothing to compare against (no `target`, no `ticks`):
144
+ * the track stays in the accessibility tree and the captions remain. A `target` or `ticks` keep it.
145
+ */
146
+ track?: boolean
147
+ /**
148
+ * Draws the track as ONE gradient through these colours (the consumer's: tokens or its own
149
+ * values, `at` in the reading's units) and the reading as a marker on it. Not a zone: no names,
150
+ * and no labels unless `ticks` are given. Use it for a scale whose hue IS the quantity.
151
+ */
152
+ stops?: readonly { at: number; color: string }[]
120
153
  segments?: never
121
154
  zones?: never
122
155
  })
@@ -128,6 +161,8 @@ export type MeterProps =
128
161
  value?: never
129
162
  color?: never
130
163
  zones?: never
164
+ stops?: never
165
+ track?: never
131
166
  })
132
167
  | (BarCommon & {
133
168
  value?: number | null | undefined
@@ -138,20 +173,27 @@ export type MeterProps =
138
173
  zones: readonly MeterZone[]
139
174
  segments?: never
140
175
  color?: never
176
+ stops?: never
177
+ track?: never
141
178
  })
142
179
  | (Common & {
143
180
  shape: 'ring'
144
181
  value?: number | null | undefined
145
182
  /** A status colour, for a verdict only. */
146
183
  color?: string
184
+ /** A short radial mark at this value (a limit to compare the arc against); the value stays centred. */
185
+ target?: number
186
+ /** More radial marks, each at its `at`; a `label` is for the accessible text only. */
187
+ ticks?: readonly MeterTick[]
147
188
  segments?: never
148
189
  zones?: never
149
- target?: never
150
- ticks?: never
151
190
  tone?: never
152
191
  size?: never
153
192
  startCaption?: never
154
193
  endCaption?: never
194
+ reading?: never
195
+ stops?: never
196
+ track?: never
155
197
  })
156
198
 
157
199
  let warnedTrack = false
@@ -176,29 +218,41 @@ export function Meter(props: MeterProps) {
176
218
  const shell = { className, style, row }
177
219
  const ring = props.shape === 'ring'
178
220
  warnInvalidTrack(min, max)
221
+ const hostTone = useContext(VisualSlotContext)?.tone
222
+ const hostColor = hostTone === undefined ? undefined : VX.status[hostTone]
179
223
 
180
224
  if (props.loading === true) return <MeterLoading label={label} ring={ring} shell={shell} />
181
225
 
182
226
  const segments = props.segments === undefined ? undefined : normalizeSegments(props.segments)
183
227
  const reading = segments === undefined ? props.value : segmentReading(segments, min)
184
228
  if (!isReading(reading) || segments?.length === 0) {
185
- return (
186
- <MeterEmpty label={label} text={props.emptyText ?? 'No data'} ring={ring} shell={shell} />
187
- )
229
+ return <MeterEmpty label={label} text={props.emptyText} ring={ring} shell={shell} />
188
230
  }
189
231
 
190
232
  if (props.shape === 'ring') {
191
- return <MeterRing {...{ label, reading, min, max, format, shell }} color={props.color} />
233
+ return (
234
+ <MeterRing
235
+ {...{ label, reading, min, max, format, shell }}
236
+ color={props.color ?? hostColor}
237
+ target={isReading(props.target) ? props.target : undefined}
238
+ ticks={props.ticks}
239
+ />
240
+ )
192
241
  }
242
+ const plain =
243
+ props.segments === undefined && props.zones === undefined && props.stops === undefined
193
244
  return (
194
245
  <MeterBar
195
246
  {...{ label, reading, min, max, format, shell }}
196
- color={props.color}
247
+ color={props.color ?? (props.tone === undefined && plain ? hostColor : undefined)}
197
248
  segments={segments}
198
249
  zones={props.zones}
250
+ stops={props.stops}
251
+ track={props.track}
252
+ markerReading={props.reading}
199
253
  target={isReading(props.target) ? props.target : undefined}
200
254
  ticks={props.ticks}
201
- tone={barTone(props.tone, props.segments === undefined && props.zones === undefined)}
255
+ tone={barTone(props.tone, plain)}
202
256
  forecastCaption={props.segments === undefined ? undefined : props.forecastCaption}
203
257
  startCaption={props.startCaption}
204
258
  endCaption={props.endCaption}
@@ -0,0 +1,89 @@
1
+ /*
2
+ * PageSummary (SPEC § 6.9). A page's opening: headline, then one facts line. No surface of its own —
3
+ * it sits on the page background above the first Section.
4
+ */
5
+ .root {
6
+ display: flex;
7
+ flex-direction: column;
8
+ gap: var(--vx-space-stack-xs);
9
+ min-width: 0;
10
+ }
11
+
12
+ .top {
13
+ display: flex;
14
+ align-items: baseline;
15
+ justify-content: space-between;
16
+ gap: var(--vx-space-stack-md);
17
+ min-width: 0;
18
+ }
19
+
20
+ /* `h1` step, head face, tight tracking (SPEC row "Page headline"). Sans with lining figures: the
21
+ * sentence carries the live number, and D33 keeps figures proportional. */
22
+ .sentence {
23
+ margin: 0;
24
+ min-width: 0;
25
+ font-family: var(--basalt-font-head);
26
+ font-size: var(--vx-text-h1);
27
+ font-weight: 550;
28
+ font-stretch: 88%;
29
+ letter-spacing: -0.02em;
30
+ line-height: 1.2;
31
+ color: var(--vx-ink);
32
+ text-wrap: balance;
33
+ }
34
+
35
+ .aside {
36
+ flex: none;
37
+ font-size: var(--vx-text-xs);
38
+ color: var(--vx-muted);
39
+ white-space: nowrap;
40
+ }
41
+
42
+ /*
43
+ * The facts line: sans `xs`, muted, `·`-separated. A wrapping flex list, `--facts-gap` between facts.
44
+ * Each fact draws its own dot one gap to its inline-start, centred in it, and the list clips inline overflow: the fact
45
+ * that opens a line starts at the list's left edge, so its dot lands outside the clip and a wrapped
46
+ * line never leads with `·` (argo UPSTREAM § Wave 26). Clip, not hidden — the block axis stays free.
47
+ */
48
+ .facts {
49
+ --facts-gap: var(--vx-space-stack-md);
50
+
51
+ display: flex;
52
+ flex-wrap: wrap;
53
+ column-gap: var(--facts-gap);
54
+ row-gap: 0;
55
+ margin: 0;
56
+ overflow-x: clip;
57
+ font-size: var(--vx-text-xs);
58
+ line-height: 1.4;
59
+ color: var(--vx-muted);
60
+ }
61
+
62
+ .fact {
63
+ position: relative;
64
+ min-width: 0;
65
+ }
66
+
67
+ .fact::before {
68
+ content: '·';
69
+ position: absolute;
70
+ inset-inline-start: calc(-1 * var(--facts-gap));
71
+ width: var(--facts-gap);
72
+ text-align: center;
73
+ color: var(--vx-faint);
74
+ }
75
+
76
+ /* The list clips inline overflow, so a focus ring on a link inside a fact is drawn inward: an
77
+ * outset ring would be cut at the list's edges. */
78
+ .fact :where(a, button, [tabindex]):focus-visible {
79
+ outline-offset: -2px;
80
+ }
81
+
82
+ /* Skeleton: the headline bar is one h1 line, the facts bar one xs line. */
83
+ .sentenceSkeleton {
84
+ height: calc(var(--vx-text-h1) * 1.2);
85
+ }
86
+
87
+ .factsSkeleton {
88
+ height: calc(var(--vx-text-xs) * 1.4);
89
+ }
@@ -0,0 +1,15 @@
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 top: string
8
+ readonly sentence: string
9
+ readonly aside: string
10
+ readonly facts: string
11
+ readonly fact: string
12
+ readonly sentenceSkeleton: string
13
+ readonly factsSkeleton: string
14
+ }
15
+ export default classes
@@ -0,0 +1,95 @@
1
+ /**
2
+ * PageSummary — a page's opening (docs/waves/design-parity/SPEC.md § 6.9): one headline sentence
3
+ * that carries at least one live number, an optional facts line under it, and an optional `aside`
4
+ * right of the headline. It renders an `h2` at the `h1` type step (head face, −0.02em): the page's own
5
+ * h1 is the shell breadcrumb's / `PageTitle`'s, and a second one would split the outline. The facts
6
+ * are the proportional sans at `xs`, muted, `·`-separated — a time fact may take mono itself, the line does
7
+ * not (D33).
8
+ *
9
+ * The sentence MUST state a live fact — "12 open, 3 need you", never "Overview of your tickets".
10
+ * A sentence without a number is the page restating its own name, which the breadcrumb already does.
11
+ * That is the reviewer's rule too: a page summary without a number is a defect.
12
+ *
13
+ * `null` / `false` / `undefined` / `''` facts drop, so conditional facts pass inline. A facts line
14
+ * that wraps never opens a line with `·`: each fact owns its separator as a pseudo-element in the gap
15
+ * before it (logical, so RTL mirrors), and the list clips inline overflow, so the dot of the fact that starts a line falls
16
+ * outside the clip.
17
+ *
18
+ * `loading` renders a skeleton of the same shape — the headline bar, plus a facts bar when `facts`
19
+ * is passed — so the page does not jump when the numbers arrive.
20
+ *
21
+ * @example
22
+ * import { PageSummary } from 'basalt-ui'
23
+ *
24
+ * <PageSummary
25
+ * sentence={`${open} open, ${needYou} need you`}
26
+ * facts={[oldest && `oldest ${oldest}`, `${runs} runs today`]}
27
+ * aside="Today"
28
+ * />
29
+ *
30
+ * @example
31
+ * <PageSummary loading facts={[]} />
32
+ */
33
+ import { Skeleton } from '@mantine/core'
34
+ import type { ReactNode } from 'react'
35
+ import { cx } from '../common/props'
36
+ import type { BasaltProps } from '../common/props'
37
+ import classes from './page-summary.module.css'
38
+
39
+ type Fact = ReactNode | null | false | undefined
40
+
41
+ type PageSummaryContent = {
42
+ /** The headline sentence. It must state a live number — never describe the page. */
43
+ sentence: ReactNode
44
+ /** Short facts under the headline, e.g. `['3 need you', oldest && `oldest ${oldest}`]`. */
45
+ facts?: readonly Fact[]
46
+ /** Right of the headline: a date or a freshness word. */
47
+ aside?: ReactNode
48
+ loading?: false
49
+ }
50
+
51
+ /** While the sentence's data loads: a skeleton of the same shape, no content props needed. */
52
+ type PageSummaryLoading = Partial<Omit<PageSummaryContent, 'loading'>> & { loading: true }
53
+
54
+ export type PageSummaryProps = BasaltProps & (PageSummaryContent | PageSummaryLoading)
55
+
56
+ const NO_FACTS: readonly Fact[] = []
57
+
58
+ const isShown = (fact: Fact): boolean =>
59
+ fact !== null && fact !== false && fact !== undefined && fact !== ''
60
+
61
+ export function PageSummary(props: PageSummaryProps) {
62
+ const { className, style } = props
63
+ const common = { className: cx(classes.root, className), 'data-page-summary': '', style }
64
+
65
+ if (props.loading === true) {
66
+ return (
67
+ <div {...common} aria-busy="true">
68
+ <Skeleton className={classes.sentenceSkeleton} width="55%" radius="sm" />
69
+ {props.facts !== undefined && (
70
+ <Skeleton className={classes.factsSkeleton} width="35%" radius="sm" />
71
+ )}
72
+ </div>
73
+ )
74
+ }
75
+
76
+ const { sentence, facts = NO_FACTS, aside } = props
77
+ const shown = facts.filter(isShown)
78
+ return (
79
+ <div {...common}>
80
+ <div className={classes.top}>
81
+ <h2 className={classes.sentence}>{sentence}</h2>
82
+ {aside !== undefined && <span className={classes.aside}>{aside}</span>}
83
+ </div>
84
+ {shown.length > 0 && (
85
+ <p className={classes.facts} data-page-summary-facts>
86
+ {shown.map((fact, i) => (
87
+ <span key={i} className={classes.fact} data-page-summary-fact>
88
+ {fact}
89
+ </span>
90
+ ))}
91
+ </p>
92
+ )}
93
+ </div>
94
+ )
95
+ }
@@ -119,7 +119,7 @@ export type ErrorStateProps = BasaltProps & {
119
119
  */
120
120
  export function ErrorState({
121
121
  error,
122
- title = 'Something went wrong',
122
+ title = 'Could not load',
123
123
  fallback = 'The request failed.',
124
124
  onRetry,
125
125
  retrying = false,
@@ -41,6 +41,29 @@
41
41
  gap: 0;
42
42
  }
43
43
 
44
+ /*
45
+ * Three type sizes in one section, not four (argo calendar next-days counted group head 11 + row
46
+ * title 13 + meta 12 + section title 15). The `group` tier is the one head this package draws below
47
+ * the section title, and it was on `micro` (11) — a step of its own. It joins the `xs` (12) step the
48
+ * rows' meta already uses; the head stays a mono UPPERCASE caption, which is the one place D33 keeps
49
+ * mono, so only its size moves and the rank is still carried by case, face and tracking. Section
50
+ * title (15), row title (13) and meta + group head (12) are then the whole ladder.
51
+ */
52
+ .root[data-tier='group'] [data-widget-title] {
53
+ font-size: var(--vx-text-xs);
54
+ }
55
+
56
+ /*
57
+ * The untitled header: `tabs` (and `actions`) alone, one control row at the `ctl` height, so the
58
+ * row costs what the controls cost and nothing for a heading that is not there.
59
+ */
60
+ .tabsRow {
61
+ display: flex;
62
+ align-items: center;
63
+ gap: var(--vx-space-control-gap);
64
+ min-width: 0;
65
+ }
66
+
44
67
  /*
45
68
  * `summary` — the always-visible row under the header. No border, no background (the Section owns
46
69
  * neither); it is a plain flow row, so a consumer's `Group` of stats or one line of `Text` lands
@@ -6,6 +6,7 @@ declare const classes: {
6
6
  readonly root: string
7
7
  readonly body: string
8
8
  readonly summary: string
9
+ readonly tabsRow: string
9
10
  readonly chevron: string
10
11
  }
11
12
  export default classes
@@ -75,7 +75,25 @@ export type SectionSlot = 'root' | 'header' | 'body'
75
75
  // intersecting the two would let a caller write `classNames={{ metric: … }}` on a `Section` and get
76
76
  // silence. Section's three slots are its whole styling contract; the header's own slots are reached
77
77
  // on a `WidgetHeader`.
78
- export type SectionProps = Omit<WidgetHeaderProps, 'tier' | 'classNames' | 'actions'> &
78
+ /** The props only a drawn heading can carry; an untitled `Section` forbids each (`?: never`). */
79
+ type HeaderOnlyKey =
80
+ | 'icon'
81
+ | 'subtitle'
82
+ | 'info'
83
+ | 'value'
84
+ | 'unit'
85
+ | 'delta'
86
+ | 'deltaPeriod'
87
+ | 'deltaPolarity'
88
+ | 'deltaFormat'
89
+ | 'deltaGlyph'
90
+ | 'sparkline'
91
+ | 'count'
92
+
93
+ type SectionBaseProps = Omit<
94
+ WidgetHeaderProps,
95
+ 'tier' | 'classNames' | 'actions' | 'title' | HeaderOnlyKey
96
+ > &
79
97
  BasaltProps &
80
98
  SlotStylesProps<SectionSlot> & {
81
99
  /**
@@ -128,6 +146,24 @@ export type SectionProps = Omit<WidgetHeaderProps, 'tier' | 'classNames' | 'acti
128
146
  children: ReactNode
129
147
  }
130
148
 
149
+ /**
150
+ * A Section names itself with `title` — or, with no title, by its `tabs` alone (argo's m365 phone
151
+ * pane switch: a heading restating the open pane's name beside the tabs that already say it). The
152
+ * header row then collapses to the tabs (and `actions`): no heading, no fold, and none of the
153
+ * heading-only props (`count`, `info`, `subtitle`, `icon`, the hero metric) — each is a type error.
154
+ *
155
+ * Naming: a `ViewTabs` in `tabs` already names its own tablist, so the section adds no second name
156
+ * and no `group` role. Pass `aria-label` only when the tabs are not self-naming — it then makes the
157
+ * root a labelled `group`.
158
+ */
159
+ export type SectionProps = SectionBaseProps &
160
+ (
161
+ | (Pick<WidgetHeaderProps, HeaderOnlyKey> & { title: string; 'aria-label'?: never })
162
+ | ({ title?: undefined; tabs: ReactNode; 'aria-label'?: string } & {
163
+ [K in HeaderOnlyKey]?: never
164
+ })
165
+ )
166
+
131
167
  function ChevronToggle({
132
168
  open,
133
169
  onToggle,
@@ -187,9 +223,11 @@ export function Section({
187
223
  className,
188
224
  style,
189
225
  classNames,
226
+ 'aria-label': ariaLabel,
190
227
  ...headerProps
191
228
  }: SectionProps) {
192
229
  const { title } = headerProps
230
+ const untitled = title === undefined
193
231
 
194
232
  // A `persistKey` with nothing to fold writes a localStorage key nobody ever reads back — the
195
233
  // shape a consumer lands on after deleting `collapsible` and leaving the key behind. It renders
@@ -242,16 +280,18 @@ export function Section({
242
280
  const rootStyle =
243
281
  anchorStyle === undefined && style === undefined ? undefined : { ...anchorStyle, ...style }
244
282
 
283
+ // An untitled section has nothing to fold behind: the tabs ARE the header.
284
+ const foldable = collapsible && !untitled
245
285
  const headerActions =
246
- tabs !== undefined || actions !== undefined || collapsible ? (
286
+ tabs !== undefined || actions !== undefined || foldable ? (
247
287
  <>
248
- {tabs !== undefined && open && <CtlSlot>{tabs}</CtlSlot>}
288
+ {tabs !== undefined && (open || untitled) && <CtlSlot>{tabs}</CtlSlot>}
249
289
  {actions !== undefined && (
250
290
  <CtlSlot>
251
291
  <BarActionSlot actions={actions} />
252
292
  </CtlSlot>
253
293
  )}
254
- {collapsible && (
294
+ {foldable && (
255
295
  <ChevronToggle open={open} onToggle={() => setOpen(!open)} controls={bodyId} />
256
296
  )}
257
297
  </>
@@ -261,17 +301,25 @@ export function Section({
261
301
  <div
262
302
  className={cx(classes.root, classNames?.root, className)}
263
303
  data-tier={tier}
304
+ {...(untitled && ariaLabel !== undefined && { role: 'group', 'aria-label': ariaLabel })}
264
305
  {...(id !== undefined && { id })}
265
306
  {...(rootStyle !== undefined && { style: rootStyle })}
266
307
  >
267
- <WidgetHeader
268
- tier={tier}
269
- {...headerProps}
270
- {...(classNames?.header !== undefined && { className: classNames.header })}
271
- {...(headerActions !== undefined && { actions: headerActions })}
272
- />
308
+ {untitled ? (
309
+ <div className={cx(classes.tabsRow, classNames?.header)} data-basalt-hit-scope>
310
+ {headerActions}
311
+ </div>
312
+ ) : (
313
+ <WidgetHeader
314
+ tier={tier}
315
+ {...(headerProps as Pick<WidgetHeaderProps, HeaderOnlyKey>)}
316
+ title={title}
317
+ {...(classNames?.header !== undefined && { className: classNames.header })}
318
+ {...(headerActions !== undefined && { actions: headerActions })}
319
+ />
320
+ )}
273
321
  {summary !== undefined && <div className={classes.summary}>{summary}</div>}
274
- {open && (
322
+ {(open || untitled) && (
275
323
  <div id={bodyId} className={cx(classes.body, classNames?.body)}>
276
324
  {query === undefined ? (
277
325
  children
@@ -55,7 +55,11 @@ export function CaptionRow({ title, icon, info, qualifier, tone, actions }: Capt
55
55
  />
56
56
  )}
57
57
  </div>
58
- {qualifier !== undefined && <span className={classes.qualifier}>{qualifier}</span>}
58
+ {qualifier !== undefined && (
59
+ <span className={classes.qualifier} title={qualifier} data-stat-qualifier>
60
+ {qualifier}
61
+ </span>
62
+ )}
59
63
  </div>
60
64
  {/* `tier="widget"`: the caption row is 24px (`--vx-space-control-height-widget`), so a card
61
65
  with a kebab is the same height as one without (`theme/ctl-theme.tsx`). */}
@@ -96,6 +96,42 @@
96
96
  min-width: 0;
97
97
  }
98
98
 
99
+ /* A card too narrow to share its caption row (a two-column phone cell, ~170px): the qualifier is ALWAYS
100
+ * on its own line under the caption, and a card with one (or a StatGroup row-mate's) reserves that line, so the values of one StatGroup
101
+ * row share a baseline whether or not a sibling has a qualifier. The caption keeps the whole first
102
+ * line (it truncates, with its `title`, only when it alone does not fit); the qualifier is one line
103
+ * too (it truncates with its `title` only when it alone does not fit THAT line). */
104
+ @container basalt-card (max-width: 239.9px) {
105
+ .captionMain:has(> .qualifier) {
106
+ --basalt-stat-qualifier-reserve: 1;
107
+ }
108
+
109
+ .captionMain {
110
+ /* 1 when this card has a qualifier or a StatGroup sibling does (`stat-group.module.css`), else 0:
111
+ * a card nobody shares a row with a qualifier to reserves nothing. */
112
+ --basalt-stat-qualifier-h: calc(
113
+ var(--vx-text-micro) * 1.4 * var(--basalt-stat-qualifier-reserve, 0)
114
+ );
115
+ align-content: flex-start;
116
+ min-height: calc(
117
+ var(--vx-space-control-height-widget, 1.5rem) * var(--mantine-scale, 1) +
118
+ var(--basalt-stat-qualifier-h)
119
+ );
120
+ }
121
+
122
+ .lead {
123
+ min-height: calc(var(--vx-space-control-height-widget, 1.5rem) * var(--mantine-scale, 1));
124
+ }
125
+
126
+ .qualifier {
127
+ flex: 0 0 100%;
128
+ overflow: hidden;
129
+ text-overflow: ellipsis;
130
+ white-space: nowrap;
131
+ line-height: 1.4;
132
+ }
133
+ }
134
+
99
135
  /* Law C15: the shared hit overlay; `--vx-hit-gap` caps the expansion at the control gap. */
100
136
  .actions {
101
137
  --vx-hit-gap: var(--vx-space-control-gap);