basalt-ui 2.21.0 → 2.22.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 (226) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/MIGRATING.md +277 -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 +27 -3
  10. package/dist/charts/Bars.d.ts.map +1 -1
  11. package/dist/charts/Bars.js +5 -0
  12. package/dist/charts/CartesianChart.d.ts +8 -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 +29 -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 +7 -1
  29. package/dist/charts/Sparkline.d.ts.map +1 -1
  30. package/dist/charts/Sparkline.js +39 -14
  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 +20 -1
  35. package/dist/charts/band-fold.d.ts.map +1 -1
  36. package/dist/charts/band-fold.js +9 -0
  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-legend.module.css +7 -0
  40. package/dist/charts/compile.d.ts +17 -6
  41. package/dist/charts/compile.d.ts.map +1 -1
  42. package/dist/charts/compile.js +145 -74
  43. package/dist/charts/labels.d.ts +15 -4
  44. package/dist/charts/labels.d.ts.map +1 -1
  45. package/dist/charts/labels.js +34 -10
  46. package/dist/charts/legend.d.ts +2 -0
  47. package/dist/charts/legend.d.ts.map +1 -1
  48. package/dist/charts/legend.js +7 -21
  49. package/dist/charts/marks.js +1 -1
  50. package/dist/charts/panel.d.ts +0 -6
  51. package/dist/charts/panel.d.ts.map +1 -1
  52. package/dist/charts/panel.js +1 -10
  53. package/dist/charts/ref-label.d.ts +26 -0
  54. package/dist/charts/ref-label.d.ts.map +1 -0
  55. package/dist/charts/ref-label.js +63 -0
  56. package/dist/charts/scales.d.ts +4 -1
  57. package/dist/charts/scales.d.ts.map +1 -1
  58. package/dist/charts/scales.js +14 -3
  59. package/dist/charts/sparkline.module.css +10 -11
  60. package/dist/charts/sparkline.module.css.d.ts +1 -2
  61. package/dist/charts/state.d.ts +2 -0
  62. package/dist/charts/state.d.ts.map +1 -1
  63. package/dist/charts/state.js +2 -1
  64. package/dist/charts/types.d.ts +14 -5
  65. package/dist/charts/types.d.ts.map +1 -1
  66. package/dist/cli/doctor-upgrade.d.ts +1 -0
  67. package/dist/cli/doctor-upgrade.d.ts.map +1 -1
  68. package/dist/cli/doctor-upgrade.js +1 -0
  69. package/dist/cli/init.d.ts +2 -0
  70. package/dist/cli/init.d.ts.map +1 -1
  71. package/dist/cli/init.js +68 -4
  72. package/dist/cli/shot/capture.d.ts +21 -2
  73. package/dist/cli/shot/capture.d.ts.map +1 -1
  74. package/dist/cli/shot/capture.js +194 -32
  75. package/dist/cli/shot/detect.d.ts.map +1 -1
  76. package/dist/cli/shot/detect.js +14 -1
  77. package/dist/cli/shot/playwright.d.ts +5 -2
  78. package/dist/cli/shot/playwright.d.ts.map +1 -1
  79. package/dist/cli/shot/types.d.ts +2 -0
  80. package/dist/cli/shot/types.d.ts.map +1 -1
  81. package/dist/cli/shot/types.js +2 -0
  82. package/dist/controls/controls.module.css +11 -1
  83. package/dist/controls/filter-pill.d.ts.map +1 -1
  84. package/dist/controls/filter-pill.js +1 -0
  85. package/dist/controls/sync-button.d.ts.map +1 -1
  86. package/dist/controls/sync-button.js +22 -3
  87. package/dist/controls/sync-button.module.css +34 -2
  88. package/dist/controls/sync-button.module.css.d.ts +1 -0
  89. package/dist/dashboard/bar-list.d.ts.map +1 -1
  90. package/dist/dashboard/bar-list.js +7 -8
  91. package/dist/dashboard/bar-list.module.css +53 -0
  92. package/dist/dashboard/bar-list.module.css.d.ts +1 -0
  93. package/dist/dashboard/index.d.ts +1 -0
  94. package/dist/dashboard/index.d.ts.map +1 -1
  95. package/dist/dashboard/index.js +2 -0
  96. package/dist/dashboard/meter-model.d.ts +77 -3
  97. package/dist/dashboard/meter-model.d.ts.map +1 -1
  98. package/dist/dashboard/meter-model.js +88 -15
  99. package/dist/dashboard/meter-parts.d.ts +8 -0
  100. package/dist/dashboard/meter-parts.d.ts.map +1 -1
  101. package/dist/dashboard/meter-parts.js +238 -71
  102. package/dist/dashboard/meter.d.ts +43 -60
  103. package/dist/dashboard/meter.d.ts.map +1 -1
  104. package/dist/dashboard/meter.js +20 -3
  105. package/dist/dashboard/meter.module.css +61 -0
  106. package/dist/dashboard/meter.module.css.d.ts +5 -0
  107. package/dist/dashboard/page-summary.d.ts +20 -0
  108. package/dist/dashboard/page-summary.d.ts.map +1 -0
  109. package/dist/dashboard/page-summary.js +28 -0
  110. package/dist/dashboard/page-summary.module.css +89 -0
  111. package/dist/dashboard/page-summary.module.css.d.ts +15 -0
  112. package/dist/dashboard/section.d.ts +25 -2
  113. package/dist/dashboard/section.d.ts.map +1 -1
  114. package/dist/dashboard/section.js +10 -5
  115. package/dist/dashboard/section.module.css +23 -0
  116. package/dist/dashboard/section.module.css.d.ts +1 -0
  117. package/dist/dashboard/stat-card-parts.d.ts.map +1 -1
  118. package/dist/dashboard/stat-card-parts.js +1 -1
  119. package/dist/dashboard/stat-card.d.ts +4 -2
  120. package/dist/dashboard/stat-card.d.ts.map +1 -1
  121. package/dist/dashboard/stat-card.js +7 -5
  122. package/dist/dashboard/stat-card.module.css +17 -0
  123. package/dist/dashboard/stat-strip.d.ts +7 -1
  124. package/dist/dashboard/stat-strip.d.ts.map +1 -1
  125. package/dist/dashboard/stat-strip.js +74 -46
  126. package/dist/dashboard/stat-strip.module.css +67 -20
  127. package/dist/dashboard/stat-strip.module.css.d.ts +4 -0
  128. package/dist/dashboard/visual-slot.d.ts +7 -1
  129. package/dist/dashboard/visual-slot.d.ts.map +1 -1
  130. package/dist/dashboard/visual-slot.js +3 -1
  131. package/dist/guard/vx-names.d.ts.map +1 -1
  132. package/dist/guard/vx-names.js +2 -0
  133. package/dist/index.d.ts +1 -1
  134. package/dist/index.d.ts.map +1 -1
  135. package/dist/index.js +3 -1
  136. package/dist/styles.css +34 -2
  137. package/dist/theme/chrome-vars.d.ts +20 -5
  138. package/dist/theme/chrome-vars.d.ts.map +1 -1
  139. package/dist/theme/chrome-vars.js +46 -3
  140. package/dist/theme/controls.module.css +23 -0
  141. package/dist/theme/controls.module.css.d.ts +1 -0
  142. package/dist/theme/index.d.ts.map +1 -1
  143. package/dist/theme/index.js +8 -20
  144. package/dist/tokens/core.d.ts +2 -1
  145. package/dist/tokens/core.d.ts.map +1 -1
  146. package/dist/tokens/core.js +6 -1
  147. package/dist/tokens/derive.d.ts +3 -1
  148. package/dist/tokens/derive.d.ts.map +1 -1
  149. package/dist/tokens/derive.js +16 -1
  150. package/dist/tokens/palette.d.ts +4 -0
  151. package/dist/tokens/palette.d.ts.map +1 -1
  152. package/dist/tokens/palette.js +4 -0
  153. package/dist/tokens/status-text.d.ts.map +1 -1
  154. package/dist/tokens/status-text.js +3 -1
  155. package/llms.txt +38 -20
  156. package/package.json +1 -1
  157. package/src/charts/BandStrip.tsx +33 -3
  158. package/src/charts/Bars.tsx +6 -0
  159. package/src/charts/CartesianChart.tsx +16 -3
  160. package/src/charts/ChartCard.tsx +34 -6
  161. package/src/charts/DualPanel.tsx +3 -6
  162. package/src/charts/Heatmap.tsx +54 -5
  163. package/src/charts/Lines.tsx +56 -10
  164. package/src/charts/MirroredBars.tsx +3 -5
  165. package/src/charts/Sparkline.tsx +50 -13
  166. package/src/charts/StackedArea.tsx +14 -4
  167. package/src/charts/band-fold.ts +31 -1
  168. package/src/charts/chart-box.module.css +19 -0
  169. package/src/charts/chart-card.module.css +25 -0
  170. package/src/charts/chart-legend.module.css +7 -0
  171. package/src/charts/compile.ts +210 -85
  172. package/src/charts/labels.ts +48 -14
  173. package/src/charts/legend.tsx +10 -20
  174. package/src/charts/marks.ts +1 -1
  175. package/src/charts/panel.tsx +1 -16
  176. package/src/charts/ref-label.ts +104 -0
  177. package/src/charts/scales.ts +22 -2
  178. package/src/charts/sparkline.module.css +10 -11
  179. package/src/charts/sparkline.module.css.d.ts +1 -2
  180. package/src/charts/state.tsx +3 -1
  181. package/src/charts/types.ts +14 -5
  182. package/src/cli/doctor-upgrade.ts +1 -1
  183. package/src/cli/init.ts +100 -3
  184. package/src/cli/shot/capture.ts +251 -32
  185. package/src/cli/shot/detect.ts +18 -1
  186. package/src/cli/shot/playwright.ts +2 -2
  187. package/src/cli/shot/types.ts +3 -0
  188. package/src/controls/controls.module.css +11 -1
  189. package/src/controls/filter-pill.tsx +2 -0
  190. package/src/controls/sync-button.module.css +34 -2
  191. package/src/controls/sync-button.module.css.d.ts +1 -0
  192. package/src/controls/sync-button.tsx +40 -4
  193. package/src/dashboard/bar-list.module.css +53 -0
  194. package/src/dashboard/bar-list.module.css.d.ts +1 -0
  195. package/src/dashboard/bar-list.tsx +78 -69
  196. package/src/dashboard/index.ts +1 -0
  197. package/src/dashboard/meter-model.ts +186 -20
  198. package/src/dashboard/meter-parts.tsx +285 -64
  199. package/src/dashboard/meter.module.css +61 -0
  200. package/src/dashboard/meter.module.css.d.ts +5 -0
  201. package/src/dashboard/meter.tsx +60 -10
  202. package/src/dashboard/page-summary.module.css +89 -0
  203. package/src/dashboard/page-summary.module.css.d.ts +15 -0
  204. package/src/dashboard/page-summary.tsx +95 -0
  205. package/src/dashboard/section.module.css +23 -0
  206. package/src/dashboard/section.module.css.d.ts +1 -0
  207. package/src/dashboard/section.tsx +59 -11
  208. package/src/dashboard/stat-card-parts.tsx +5 -1
  209. package/src/dashboard/stat-card.module.css +17 -0
  210. package/src/dashboard/stat-card.tsx +12 -6
  211. package/src/dashboard/stat-strip.module.css +67 -20
  212. package/src/dashboard/stat-strip.module.css.d.ts +4 -0
  213. package/src/dashboard/stat-strip.tsx +118 -72
  214. package/src/dashboard/visual-slot.ts +12 -3
  215. package/src/guard/vx-names.ts +2 -0
  216. package/src/index.ts +2 -0
  217. package/src/styles.css +34 -2
  218. package/src/theme/__snapshots__/plain-theme.test.ts.snap +186 -60
  219. package/src/theme/chrome-vars.ts +77 -8
  220. package/src/theme/controls.module.css +23 -0
  221. package/src/theme/controls.module.css.d.ts +1 -0
  222. package/src/theme/index.ts +12 -25
  223. package/src/tokens/core.ts +4 -1
  224. package/src/tokens/derive.ts +32 -3
  225. package/src/tokens/palette.ts +4 -0
  226. package/src/tokens/status-text.ts +2 -0
@@ -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. */
@@ -94,14 +97,25 @@ type BarCommon = Common & {
94
97
  tone?: 'muted' | 'ink'
95
98
  /**
96
99
  * `'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.
100
+ * zone and tick captions). Categorical `segments` keep their per-part captions (swatch, name, value)
101
+ * so the parts stay named. The label stays as `aria-label`; the described-by text keeps the rest.
102
+ * Put the value beside it in your own layout.
99
103
  */
100
104
  size?: 'row'
101
- /** Start caption (default: the formatted reading). `null` drops it. */
105
+ /** Start caption (default: the formatted reading). `null` drops it; zone labels stay. */
102
106
  startCaption?: ReactNode
103
- /** End caption (default: `Target <target>`). `null` drops it. */
107
+ /**
108
+ * End caption (default: `Target <target>`, drawn at the target's tick rather than the track end
109
+ * when it fits). `null` drops it; zone labels stay.
110
+ */
104
111
  endCaption?: ReactNode
112
+ /**
113
+ * The reading printed at the marker of a zoned bar. Default `true`, and `false` inside a basalt host
114
+ * (`StatCard`, a strip cell's `visual`) that already states the value. Pass `false` when YOUR
115
+ * headline states it: the marker stays and keeps its `aria-valuenow` / `aria-valuetext`. Pass `true`
116
+ * to print it inside a host. A `stops` track prints it only when `true`.
117
+ */
118
+ reading?: boolean
105
119
  }
106
120
 
107
121
  /**
@@ -109,7 +123,9 @@ type BarCommon = Common & {
109
123
  * - Bar `value` (+ `target`, `color`): one reading on a neutral track.
110
124
  * - Bar `segments`: ordered parts that sum to the reading (committed/forecast, part of a whole).
111
125
  * - 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.
126
+ * - Bar `value` + `stops`: the reading is a marker on one gradient track.
127
+ * - Ring (`shape: 'ring'`) `value` (+ `color`, `target`, `ticks`): one headline ratio; no captions,
128
+ * segments or zones.
113
129
  */
114
130
  export type MeterProps =
115
131
  | (BarCommon & {
@@ -117,6 +133,17 @@ export type MeterProps =
117
133
  value?: number | null | undefined
118
134
  /** A status colour, for a verdict only. Omit for the neutral fill. */
119
135
  color?: string
136
+ /**
137
+ * `false` draws no track for a value with nothing to compare against (no `target`, no `ticks`):
138
+ * the track stays in the accessibility tree and the captions remain. A `target` or `ticks` keep it.
139
+ */
140
+ track?: boolean
141
+ /**
142
+ * Draws the track as ONE gradient through these colours (the consumer's: tokens or its own
143
+ * values, `at` in the reading's units) and the reading as a marker on it. Not a zone: no names,
144
+ * and no labels unless `ticks` are given. Use it for a scale whose hue IS the quantity.
145
+ */
146
+ stops?: readonly { at: number; color: string }[]
120
147
  segments?: never
121
148
  zones?: never
122
149
  })
@@ -128,6 +155,8 @@ export type MeterProps =
128
155
  value?: never
129
156
  color?: never
130
157
  zones?: never
158
+ stops?: never
159
+ track?: never
131
160
  })
132
161
  | (BarCommon & {
133
162
  value?: number | null | undefined
@@ -138,20 +167,27 @@ export type MeterProps =
138
167
  zones: readonly MeterZone[]
139
168
  segments?: never
140
169
  color?: never
170
+ stops?: never
171
+ track?: never
141
172
  })
142
173
  | (Common & {
143
174
  shape: 'ring'
144
175
  value?: number | null | undefined
145
176
  /** A status colour, for a verdict only. */
146
177
  color?: string
178
+ /** A short radial mark at this value (a limit to compare the arc against); the value stays centred. */
179
+ target?: number
180
+ /** More radial marks, each at its `at`; a `label` is for the accessible text only. */
181
+ ticks?: readonly MeterTick[]
147
182
  segments?: never
148
183
  zones?: never
149
- target?: never
150
- ticks?: never
151
184
  tone?: never
152
185
  size?: never
153
186
  startCaption?: never
154
187
  endCaption?: never
188
+ reading?: never
189
+ stops?: never
190
+ track?: never
155
191
  })
156
192
 
157
193
  let warnedTrack = false
@@ -176,6 +212,8 @@ export function Meter(props: MeterProps) {
176
212
  const shell = { className, style, row }
177
213
  const ring = props.shape === 'ring'
178
214
  warnInvalidTrack(min, max)
215
+ const hostTone = useContext(VisualSlotContext)?.tone
216
+ const hostColor = hostTone === undefined ? undefined : VX.status[hostTone]
179
217
 
180
218
  if (props.loading === true) return <MeterLoading label={label} ring={ring} shell={shell} />
181
219
 
@@ -188,17 +226,29 @@ export function Meter(props: MeterProps) {
188
226
  }
189
227
 
190
228
  if (props.shape === 'ring') {
191
- return <MeterRing {...{ label, reading, min, max, format, shell }} color={props.color} />
229
+ return (
230
+ <MeterRing
231
+ {...{ label, reading, min, max, format, shell }}
232
+ color={props.color ?? hostColor}
233
+ target={isReading(props.target) ? props.target : undefined}
234
+ ticks={props.ticks}
235
+ />
236
+ )
192
237
  }
238
+ const plain =
239
+ props.segments === undefined && props.zones === undefined && props.stops === undefined
193
240
  return (
194
241
  <MeterBar
195
242
  {...{ label, reading, min, max, format, shell }}
196
- color={props.color}
243
+ color={props.color ?? (props.tone === undefined && plain ? hostColor : undefined)}
197
244
  segments={segments}
198
245
  zones={props.zones}
246
+ stops={props.stops}
247
+ track={props.track}
248
+ markerReading={props.reading}
199
249
  target={isReading(props.target) ? props.target : undefined}
200
250
  ticks={props.ticks}
201
- tone={barTone(props.tone, props.segments === undefined && props.zones === undefined)}
251
+ tone={barTone(props.tone, plain)}
202
252
  forecastCaption={props.segments === undefined ? undefined : props.forecastCaption}
203
253
  startCaption={props.startCaption}
204
254
  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
+ }
@@ -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}>
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,23 @@
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) never wraps the
100
+ * qualifier under the caption: that second line pushed the value below its row neighbours'. The
101
+ * caption row stays one line; the qualifier truncates (full text in its `title`). */
102
+ @container basalt-card (max-width: 239.9px) {
103
+ .captionMain {
104
+ flex-wrap: nowrap;
105
+ }
106
+
107
+ .qualifier {
108
+ flex: 0 1 auto;
109
+ overflow: hidden;
110
+ text-overflow: ellipsis;
111
+ white-space: nowrap;
112
+ text-align: end;
113
+ }
114
+ }
115
+
99
116
  /* Law C15: the shared hit overlay; `--vx-hit-gap` caps the expansion at the control gap. */
100
117
  .actions {
101
118
  --vx-hit-gap: var(--vx-space-control-gap);
@@ -112,7 +112,7 @@ import type { BasaltProps, SlotStylesProps, Tone } from '../common/props'
112
112
  import { ErrorState, QueryState, resolveQueryBranch } from './query-state'
113
113
  import type { QueryBranch, QueryStateLike } from './query-state'
114
114
  import classes from './stat-card.module.css'
115
- import { VisualSlotContext } from './visual-slot'
115
+ import { HOSTED, VisualSlotContext } from './visual-slot'
116
116
 
117
117
  /**
118
118
  * The boxes `StatCard` paints, and the whole styling seam it offers (`common/props.ts`).
@@ -217,8 +217,10 @@ export type StatCardProps = BasaltProps &
217
217
  value: string
218
218
  /**
219
219
  * Right-aligned on the caption row, `micro` muted: the period, target or source the figure is
220
- * measured over (`30 days`, `target 99.9%`). Wraps under the caption when the card is too narrow
221
- * for both. Not a restatement of the caption.
220
+ * measured over (`30 days`, `target 99.9%`). Wraps under the caption when the card is too
221
+ * narrow for both. Only in a card narrower than 240px does it truncate instead (the full text
222
+ * is its `title`); between 240px and the width it fits, a long one still wraps and moves the
223
+ * value down a line. Not a restatement of the caption.
222
224
  */
223
225
  qualifier?: string
224
226
  /**
@@ -326,7 +328,7 @@ function renderValueBody({
326
328
  return (
327
329
  <ErrorState
328
330
  error={resolved.error}
329
- title="Could not load this figure"
331
+ title="Could not load"
330
332
  tier="section"
331
333
  onRetry={() => void resolved.query.refetch()}
332
334
  retrying={resolved.query.fetchStatus === 'fetching'}
@@ -358,12 +360,16 @@ function renderVisualNode({
358
360
  function renderFooterNode({
359
361
  subtitle,
360
362
  pending,
363
+ ready,
361
364
  }: {
362
365
  subtitle: string | undefined
363
366
  pending: boolean
367
+ ready: boolean
364
368
  }): ReactNode {
365
369
  if (subtitle === undefined) return null
366
370
  if (pending) return <FooterSkeleton />
371
+ // The footer captions the visual; with no figure drawn (empty, failed) it would caption nothing.
372
+ if (!ready) return null
367
373
  return (
368
374
  <p className={classes.footer} title={subtitle}>
369
375
  {subtitle}
@@ -449,7 +455,7 @@ export function StatCard({
449
455
  >
450
456
  {/* A measured slot renders nothing on the first commit (width 0) — an SVG at width 0 is a
451
457
  visible 0-width box that then jumps, which is worse than one frame of nothing. */}
452
- <VisualSlotContext.Provider value>
458
+ <VisualSlotContext.Provider value={tone === undefined ? HOSTED : { tone }}>
453
459
  {isRender ? measured.width > 0 && sparkline(measured) : sparkline}
454
460
  </VisualSlotContext.Provider>
455
461
  </div>
@@ -487,7 +493,7 @@ export function StatCard({
487
493
 
488
494
  const hasBleedVisual = sparkline !== undefined && bleeds
489
495
  const visualNode = renderVisualNode({ show: hasBleedVisual, pending, slot: sparklineSlot })
490
- const footerNode = renderFooterNode({ subtitle, pending })
496
+ const footerNode = renderFooterNode({ subtitle, pending, ready })
491
497
 
492
498
  return (
493
499
  <Card