basalt-ui 2.28.0 → 2.29.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 (229) hide show
  1. package/CHANGELOG.md +461 -401
  2. package/MIGRATING.md +202 -12
  3. package/agent/skills/basalt-app/SKILL.md +3 -3
  4. package/agent/skills/basalt-charts/SKILL.md +1 -1
  5. package/agent/skills/basalt-design/SKILL.md +11 -5
  6. package/agent/skills/basalt-design/references/catalogue.md +3 -1
  7. package/agent/skills/basalt-design/references/recipes.md +1 -1
  8. package/agent/skills/basalt-design/references/states.md +1 -1
  9. package/configs/oxlint-plugin.js +2 -1
  10. package/configs/oxlint.json +1 -0
  11. package/dist/charts/ChartCard.d.ts +9 -5
  12. package/dist/charts/ChartCard.d.ts.map +1 -1
  13. package/dist/charts/ChartCard.js +68 -12
  14. package/dist/charts/Sparkline.d.ts +5 -0
  15. package/dist/charts/Sparkline.d.ts.map +1 -1
  16. package/dist/charts/Sparkline.js +53 -5
  17. package/dist/charts/chart-box.module.css +9 -2
  18. package/dist/charts/chart-card.module.css +16 -13
  19. package/dist/charts/chart-card.module.css.d.ts +2 -0
  20. package/dist/charts/compile.d.ts +1 -1
  21. package/dist/charts/compile.d.ts.map +1 -1
  22. package/dist/charts/compile.js +18 -9
  23. package/dist/charts/ref-label.d.ts +6 -0
  24. package/dist/charts/ref-label.d.ts.map +1 -1
  25. package/dist/charts/ref-label.js +19 -5
  26. package/dist/charts/sparkline.module.css +44 -0
  27. package/dist/charts/sparkline.module.css.d.ts +3 -0
  28. package/dist/charts/state.d.ts +1 -1
  29. package/dist/charts/state.d.ts.map +1 -1
  30. package/dist/charts/state.js +3 -3
  31. package/dist/cli/doctor-upgrade.d.ts +11 -0
  32. package/dist/cli/doctor-upgrade.d.ts.map +1 -1
  33. package/dist/cli/doctor-upgrade.js +54 -0
  34. package/dist/cli/doctor.d.ts.map +1 -1
  35. package/dist/cli/doctor.js +32 -0
  36. package/dist/cli/help.d.ts.map +1 -1
  37. package/dist/cli/help.js +8 -3
  38. package/dist/cli/index.d.ts +13 -13
  39. package/dist/cli/index.d.ts.map +1 -1
  40. package/dist/cli/index.js +36 -2
  41. package/dist/cli/init.d.ts +6 -0
  42. package/dist/cli/init.d.ts.map +1 -1
  43. package/dist/cli/init.js +118 -27
  44. package/dist/cli/router-wiring.d.ts +3 -0
  45. package/dist/cli/router-wiring.d.ts.map +1 -1
  46. package/dist/cli/router-wiring.js +2 -0
  47. package/dist/cli/shot/capture.d.ts +28 -1
  48. package/dist/cli/shot/capture.d.ts.map +1 -1
  49. package/dist/cli/shot/capture.js +77 -7
  50. package/dist/cli/shot/detect.d.ts +4 -1
  51. package/dist/cli/shot/detect.d.ts.map +1 -1
  52. package/dist/cli/shot/detect.js +38 -16
  53. package/dist/cli/shot/index.d.ts.map +1 -1
  54. package/dist/cli/shot/index.js +9 -2
  55. package/dist/cli/shot/measure.d.ts.map +1 -1
  56. package/dist/cli/shot/measure.js +11 -2
  57. package/dist/cli/shot/types.d.ts +4 -1
  58. package/dist/cli/shot/types.d.ts.map +1 -1
  59. package/dist/cli/sync.d.ts.map +1 -1
  60. package/dist/cli/sync.js +10 -2
  61. package/dist/common/could-not-load.d.ts +13 -0
  62. package/dist/common/could-not-load.d.ts.map +1 -0
  63. package/dist/common/could-not-load.js +14 -0
  64. package/dist/common/index.d.ts +1 -0
  65. package/dist/common/index.d.ts.map +1 -1
  66. package/dist/common/index.js +3 -0
  67. package/dist/common/props.d.ts +20 -0
  68. package/dist/common/props.d.ts.map +1 -1
  69. package/dist/common/props.js +13 -1
  70. package/dist/common/retry-button.module.css +7 -3
  71. package/dist/dashboard/bar-list.d.ts +4 -4
  72. package/dist/dashboard/bar-list.d.ts.map +1 -1
  73. package/dist/dashboard/bar-list.js +10 -7
  74. package/dist/dashboard/bar-list.module.css +21 -3
  75. package/dist/dashboard/board.d.ts +2 -2
  76. package/dist/dashboard/board.d.ts.map +1 -1
  77. package/dist/dashboard/board.js +31 -12
  78. package/dist/dashboard/board.module.css +19 -0
  79. package/dist/dashboard/board.module.css.d.ts +2 -0
  80. package/dist/dashboard/empty-state.d.ts +3 -3
  81. package/dist/dashboard/empty-state.d.ts.map +1 -1
  82. package/dist/dashboard/empty-state.js +4 -2
  83. package/dist/dashboard/event-list-model.d.ts +3 -0
  84. package/dist/dashboard/event-list-model.d.ts.map +1 -1
  85. package/dist/dashboard/event-list-model.js +5 -1
  86. package/dist/dashboard/event-list-rows.d.ts.map +1 -1
  87. package/dist/dashboard/event-list-rows.js +2 -6
  88. package/dist/dashboard/event-list-scroll.d.ts +32 -4
  89. package/dist/dashboard/event-list-scroll.d.ts.map +1 -1
  90. package/dist/dashboard/event-list-scroll.js +117 -4
  91. package/dist/dashboard/event-list-skeleton.d.ts.map +1 -1
  92. package/dist/dashboard/event-list-skeleton.js +2 -4
  93. package/dist/dashboard/event-list.d.ts +4 -4
  94. package/dist/dashboard/event-list.d.ts.map +1 -1
  95. package/dist/dashboard/event-list.js +53 -23
  96. package/dist/dashboard/event-list.module.css +90 -37
  97. package/dist/dashboard/event-list.module.css.d.ts +1 -0
  98. package/dist/dashboard/meter-model.d.ts +6 -3
  99. package/dist/dashboard/meter-model.d.ts.map +1 -1
  100. package/dist/dashboard/meter-model.js +9 -4
  101. package/dist/dashboard/meter-parts.d.ts +3 -0
  102. package/dist/dashboard/meter-parts.d.ts.map +1 -1
  103. package/dist/dashboard/meter-parts.js +32 -4
  104. package/dist/dashboard/meter.d.ts +3 -3
  105. package/dist/dashboard/meter.d.ts.map +1 -1
  106. package/dist/dashboard/meter.js +10 -2
  107. package/dist/dashboard/meter.module.css +18 -11
  108. package/dist/dashboard/meter.module.css.d.ts +0 -1
  109. package/dist/dashboard/page-summary.d.ts +3 -3
  110. package/dist/dashboard/page-summary.d.ts.map +1 -1
  111. package/dist/dashboard/page-summary.js +7 -2
  112. package/dist/dashboard/page-summary.module.css +5 -2
  113. package/dist/dashboard/query-state.d.ts +9 -8
  114. package/dist/dashboard/query-state.d.ts.map +1 -1
  115. package/dist/dashboard/query-state.js +28 -10
  116. package/dist/dashboard/section.d.ts +11 -3
  117. package/dist/dashboard/section.d.ts.map +1 -1
  118. package/dist/dashboard/section.js +34 -7
  119. package/dist/dashboard/settings-section.d.ts +4 -4
  120. package/dist/dashboard/settings-section.d.ts.map +1 -1
  121. package/dist/dashboard/settings-section.js +11 -7
  122. package/dist/dashboard/settings-section.module.css +6 -0
  123. package/dist/dashboard/settings-section.module.css.d.ts +1 -0
  124. package/dist/dashboard/stat-card.d.ts +3 -3
  125. package/dist/dashboard/stat-card.d.ts.map +1 -1
  126. package/dist/dashboard/stat-card.js +24 -8
  127. package/dist/dashboard/stat-card.module.css +11 -0
  128. package/dist/dashboard/stat-group.d.ts +2 -2
  129. package/dist/dashboard/stat-group.d.ts.map +1 -1
  130. package/dist/dashboard/stat-group.js +10 -3
  131. package/dist/dashboard/stat-strip.d.ts +5 -4
  132. package/dist/dashboard/stat-strip.d.ts.map +1 -1
  133. package/dist/dashboard/stat-strip.js +41 -31
  134. package/dist/dashboard/stat-strip.module.css +4 -5
  135. package/dist/dashboard/visual-slot.d.ts +4 -0
  136. package/dist/dashboard/visual-slot.d.ts.map +1 -1
  137. package/dist/dashboard/visual-slot.js +2 -0
  138. package/dist/dashboard/widget-header.d.ts +6 -6
  139. package/dist/dashboard/widget-header.d.ts.map +1 -1
  140. package/dist/dashboard/widget-header.js +4 -2
  141. package/dist/dashboard/widget-header.module.css +6 -25
  142. package/dist/format/shared.d.ts.map +1 -1
  143. package/dist/format/shared.js +24 -1
  144. package/dist/guard/index.d.ts +1 -1
  145. package/dist/guard/index.d.ts.map +1 -1
  146. package/dist/guard/index.js +2 -1
  147. package/dist/styles.css +23 -0
  148. package/dist/table/cell-kinds.d.ts +10 -7
  149. package/dist/table/cell-kinds.d.ts.map +1 -1
  150. package/dist/table/cell-kinds.js +18 -7
  151. package/dist/table/data-table-fold.d.ts +13 -5
  152. package/dist/table/data-table-fold.d.ts.map +1 -1
  153. package/dist/table/data-table-fold.js +48 -16
  154. package/dist/table/data-table.d.ts +2 -2
  155. package/dist/table/data-table.d.ts.map +1 -1
  156. package/dist/table/data-table.js +16 -9
  157. package/dist/table/data-table.module.css +74 -2
  158. package/dist/table/data-table.module.css.d.ts +4 -0
  159. package/dist/theme/controls.module.css +23 -2
  160. package/llms.txt +263 -2
  161. package/package.json +1 -1
  162. package/src/charts/ChartCard.tsx +98 -16
  163. package/src/charts/Sparkline.tsx +84 -5
  164. package/src/charts/chart-box.module.css +9 -2
  165. package/src/charts/chart-card.module.css +16 -13
  166. package/src/charts/chart-card.module.css.d.ts +2 -0
  167. package/src/charts/compile.ts +37 -15
  168. package/src/charts/ref-label.ts +36 -9
  169. package/src/charts/sparkline.module.css +44 -0
  170. package/src/charts/sparkline.module.css.d.ts +3 -0
  171. package/src/charts/state.tsx +4 -3
  172. package/src/cli/doctor-upgrade.ts +75 -0
  173. package/src/cli/doctor.ts +36 -0
  174. package/src/cli/help.ts +16 -6
  175. package/src/cli/index.ts +73 -67
  176. package/src/cli/init.ts +157 -36
  177. package/src/cli/router-wiring.ts +2 -2
  178. package/src/cli/shot/capture.ts +109 -10
  179. package/src/cli/shot/detect.ts +46 -22
  180. package/src/cli/shot/index.ts +8 -2
  181. package/src/cli/shot/measure.ts +11 -2
  182. package/src/cli/shot/types.ts +4 -1
  183. package/src/cli/sync.ts +12 -2
  184. package/src/common/could-not-load.ts +22 -0
  185. package/src/common/index.ts +1 -0
  186. package/src/common/props.ts +30 -0
  187. package/src/common/retry-button.module.css +7 -3
  188. package/src/dashboard/bar-list.module.css +21 -3
  189. package/src/dashboard/bar-list.tsx +46 -41
  190. package/src/dashboard/board.module.css +19 -0
  191. package/src/dashboard/board.module.css.d.ts +2 -0
  192. package/src/dashboard/board.tsx +69 -48
  193. package/src/dashboard/empty-state.tsx +5 -2
  194. package/src/dashboard/event-list-model.ts +13 -1
  195. package/src/dashboard/event-list-rows.tsx +3 -6
  196. package/src/dashboard/event-list-scroll.ts +154 -8
  197. package/src/dashboard/event-list-skeleton.tsx +5 -1
  198. package/src/dashboard/event-list.module.css +90 -37
  199. package/src/dashboard/event-list.module.css.d.ts +1 -0
  200. package/src/dashboard/event-list.tsx +92 -65
  201. package/src/dashboard/meter-model.ts +16 -7
  202. package/src/dashboard/meter-parts.tsx +45 -13
  203. package/src/dashboard/meter.module.css +18 -11
  204. package/src/dashboard/meter.module.css.d.ts +0 -1
  205. package/src/dashboard/meter.tsx +36 -18
  206. package/src/dashboard/page-summary.module.css +5 -2
  207. package/src/dashboard/page-summary.tsx +13 -6
  208. package/src/dashboard/query-state.tsx +54 -29
  209. package/src/dashboard/section.tsx +83 -41
  210. package/src/dashboard/settings-section.module.css +6 -0
  211. package/src/dashboard/settings-section.module.css.d.ts +1 -0
  212. package/src/dashboard/settings-section.tsx +11 -6
  213. package/src/dashboard/stat-card.module.css +11 -0
  214. package/src/dashboard/stat-card.tsx +31 -8
  215. package/src/dashboard/stat-group.tsx +22 -14
  216. package/src/dashboard/stat-strip.module.css +4 -5
  217. package/src/dashboard/stat-strip.tsx +29 -20
  218. package/src/dashboard/visual-slot.ts +5 -0
  219. package/src/dashboard/widget-header.module.css +6 -25
  220. package/src/dashboard/widget-header.tsx +8 -5
  221. package/src/format/shared.ts +30 -1
  222. package/src/guard/index.ts +5 -1
  223. package/src/styles.css +23 -0
  224. package/src/table/cell-kinds.tsx +42 -13
  225. package/src/table/data-table-fold.tsx +65 -12
  226. package/src/table/data-table.module.css +74 -2
  227. package/src/table/data-table.module.css.d.ts +4 -0
  228. package/src/table/data-table.tsx +34 -13
  229. package/src/theme/controls.module.css +23 -2
@@ -45,20 +45,24 @@
45
45
  * <UsageChart />
46
46
  * </Section>
47
47
  */
48
- import { useEffect, useId } from 'react'
48
+ import { Children, cloneElement, isValidElement, useContext, useEffect, useId } from 'react'
49
49
  import type { ReactNode } from 'react'
50
- import { cx } from '../common/props'
51
- import type { BasaltProps, SlotStylesProps } from '../common/props'
50
+ import { cx, splitDataAttributes } from '../common/props'
51
+ import type { BasaltProps, DataAttributes, SlotStylesProps } from '../common/props'
52
52
  import { BASALT_PREFIX } from '../common/errors'
53
53
  import { useValidateProps } from '../common/validate'
54
54
  import { CtlSlot } from '../theme'
55
55
  import { BarActionSlot } from '../controls/actions'
56
56
  import type { SectionActions } from '../controls/actions'
57
57
  import { useFilterSurface } from '../controls/filter-context'
58
- import { QueryState } from './query-state'
58
+ import { HostTitleContext } from '../common/could-not-load'
59
+ import { LoadingState, QueryState } from './query-state'
59
60
  import type { QueryEmptyCopy, QueryStateLike } from './query-state'
60
61
  import { usePersistedOrLocal } from '../state/persisted-or-local'
61
62
  import { PAGE_BAR_HEIGHT_VAR, useInPageBarShell } from '../shell'
63
+ import { BarList } from './bar-list'
64
+ import { EventList } from './event-list'
65
+ import { Meter } from './meter'
62
66
  import { WidgetHeader } from './widget-header'
63
67
  import type { WidgetHeaderProps } from './widget-header'
64
68
  import classes from './section.module.css'
@@ -95,6 +99,7 @@ type SectionBaseProps = Omit<
95
99
  'tier' | 'classNames' | 'actions' | 'title' | HeaderOnlyKey
96
100
  > &
97
101
  BasaltProps &
102
+ DataAttributes &
98
103
  SlotStylesProps<SectionSlot> & {
99
104
  /**
100
105
  * Header actions as typed data (law C15), projected through the SAME row `PageBar` uses — one
@@ -118,6 +123,14 @@ type SectionBaseProps = Omit<
118
123
  * without `query`.
119
124
  */
120
125
  empty?: QueryEmptyCopy
126
+ /**
127
+ * The loaded body's height in px. While `query` is pending the loading skeleton fills it, so
128
+ * the section does not jump when the data lands. Declared, not measured: a first load has no
129
+ * previous body to measure. Omitted, a body that is one `BarList`, `EventList` or `Meter`
130
+ * loads as that figure's own skeleton (set its `loadingRows` to the loaded count); any other
131
+ * body gets the three-bar default. Ignored without `query`.
132
+ */
133
+ loadingHeight?: number
121
134
  /** Rendered in the header row, in its own `CtlSlot` — hidden while the section is collapsed. */
122
135
  tabs?: ReactNode
123
136
  /** Renders a chevron toggle in the header; the header stays drawn when closed, only `children`
@@ -199,6 +212,18 @@ function ChevronToggle({
199
212
  )
200
213
  }
201
214
 
215
+ /**
216
+ * A body that is ONE figure with a row-shaped loading state loads as that figure, so the skeleton has
217
+ * the loaded footprint (rows, track) rather than a guess. Anything else has no shape to borrow.
218
+ */
219
+ function figureLoading(children: ReactNode): ReactNode {
220
+ const only = Children.toArray(children)
221
+ const [child] = only
222
+ if (only.length !== 1 || !isValidElement<{ loading?: boolean }>(child)) return null
223
+ if (child.type !== BarList && child.type !== EventList && child.type !== Meter) return null
224
+ return cloneElement(child, { loading: true })
225
+ }
226
+
202
227
  const ANCHOR_CLEARANCE = 'var(--vx-space-sticky-header-clearance)'
203
228
 
204
229
  /** The `scroll-margin-top` of an anchored Section; the bar term only exists without a shell. */
@@ -211,6 +236,7 @@ export function Section({
211
236
  actions,
212
237
  query,
213
238
  empty,
239
+ loadingHeight,
214
240
  tabs,
215
241
  collapsible = false,
216
242
  persistKey,
@@ -224,9 +250,11 @@ export function Section({
224
250
  style,
225
251
  classNames,
226
252
  'aria-label': ariaLabel,
227
- ...headerProps
253
+ ...headerAndData
228
254
  }: SectionProps) {
255
+ const { data, rest: headerProps } = splitDataAttributes(headerAndData)
229
256
  const { title } = headerProps
257
+ const outerTitle = useContext(HostTitleContext)
230
258
  const untitled = title === undefined
231
259
 
232
260
  // A `persistKey` with nothing to fold writes a localStorage key nobody ever reads back — the
@@ -297,42 +325,56 @@ export function Section({
297
325
  </>
298
326
  ) : undefined
299
327
 
328
+ const figure = query !== undefined && loadingHeight === undefined ? figureLoading(children) : null
329
+
300
330
  return (
301
- <div
302
- className={cx(classes.root, classNames?.root, className)}
303
- data-tier={tier}
304
- {...(untitled && ariaLabel !== undefined && { role: 'group', 'aria-label': ariaLabel })}
305
- {...(id !== undefined && { id })}
306
- {...(rootStyle !== undefined && { style: rootStyle })}
307
- >
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
- )}
321
- {summary !== undefined && <div className={classes.summary}>{summary}</div>}
322
- {(open || untitled) && (
323
- <div id={bodyId} className={cx(classes.body, classNames?.body)}>
324
- {query === undefined ? (
325
- children
326
- ) : (
327
- // `tier="section"` is the compact one: a bare spinner rather than a 64px centred
328
- // block, and the error alert without the page-level stack around it. A Section IS the
329
- // region, so the state belongs inside its body, never around its header.
330
- <QueryState query={query} tier="section" {...(empty !== undefined && { empty })}>
331
- {children}
332
- </QueryState>
333
- )}
334
- </div>
335
- )}
336
- </div>
331
+ <HostTitleContext value={title ?? outerTitle}>
332
+ <div
333
+ {...data}
334
+ className={cx(classes.root, classNames?.root, className)}
335
+ data-tier={tier}
336
+ {...(untitled && ariaLabel !== undefined && { role: 'group', 'aria-label': ariaLabel })}
337
+ {...(id !== undefined && { id })}
338
+ {...(rootStyle !== undefined && { style: rootStyle })}
339
+ >
340
+ {untitled ? (
341
+ <div className={cx(classes.tabsRow, classNames?.header)} data-basalt-hit-scope>
342
+ {headerActions}
343
+ </div>
344
+ ) : (
345
+ <WidgetHeader
346
+ tier={tier}
347
+ {...(headerProps as Pick<WidgetHeaderProps, HeaderOnlyKey>)}
348
+ title={title}
349
+ {...(classNames?.header !== undefined && { className: classNames.header })}
350
+ {...(headerActions !== undefined && { actions: headerActions })}
351
+ />
352
+ )}
353
+ {summary !== undefined && <div className={classes.summary}>{summary}</div>}
354
+ {(open || untitled) && (
355
+ <div id={bodyId} className={cx(classes.body, classNames?.body)}>
356
+ {query === undefined ? (
357
+ children
358
+ ) : (
359
+ // `tier="section"` is the compact one: a bare spinner rather than a 64px centred
360
+ // block, and the error alert without the page-level stack around it. A Section IS the
361
+ // region, so the state belongs inside its body, never around its header.
362
+ <QueryState
363
+ query={query}
364
+ tier="section"
365
+ {...(empty !== undefined && { empty })}
366
+ {...(loadingHeight !== undefined
367
+ ? {
368
+ loading: <LoadingState tier="section" style={{ minHeight: loadingHeight }} />,
369
+ }
370
+ : figure !== null && { loading: figure })}
371
+ >
372
+ {children}
373
+ </QueryState>
374
+ )}
375
+ </div>
376
+ )}
377
+ </div>
378
+ </HostTitleContext>
337
379
  )
338
380
  }
@@ -46,3 +46,9 @@
46
46
  gap: var(--vx-space-stack-xs);
47
47
  }
48
48
  }
49
+
50
+ /* DangerZone's ring colour: the status token mixed into the panel surface — one formula in both
51
+ * schemes, never an alpha over whatever sits behind it. The component layers it on `shadow-card`. */
52
+ .danger {
53
+ --danger-ring: color-mix(in srgb, var(--vx-status-bad) 40%, var(--vx-surface-panel));
54
+ }
@@ -7,5 +7,6 @@ declare const classes: {
7
7
  readonly rows: string
8
8
  readonly row: string
9
9
  readonly control: string
10
+ readonly danger: string
10
11
  }
11
12
  export default classes
@@ -33,9 +33,9 @@ import type { ReactNode } from 'react'
33
33
  import { WidgetHeader } from './widget-header'
34
34
  import type { WidgetHeaderTitleProps } from './widget-header'
35
35
  import { CtlSlot } from '../theme'
36
- import { alpha, VX } from '../tokens'
37
- import { cx } from '../common/props'
38
- import type { BasaltProps, SlotStylesProps } from '../common/props'
36
+ import { VX } from '../tokens'
37
+ import { cx, pickDataAttributes } from '../common/props'
38
+ import type { BasaltProps, DataAttributes, SlotStylesProps } from '../common/props'
39
39
  import classes from './settings-section.module.css'
40
40
 
41
41
  const eyebrowStyle = {
@@ -59,6 +59,7 @@ export type SettingsSectionSlot = 'root' | 'header' | 'body'
59
59
  * slices.
60
60
  */
61
61
  export type SettingsSectionProps = BasaltProps &
62
+ DataAttributes &
62
63
  SlotStylesProps<SettingsSectionSlot> &
63
64
  WidgetHeaderTitleProps & {
64
65
  /** Header-right slot — wrapped in `CtlSlot` (C1/C5). */
@@ -77,9 +78,10 @@ export function SettingsSection({
77
78
  className,
78
79
  style,
79
80
  classNames,
81
+ ...rest
80
82
  }: SettingsSectionProps) {
81
83
  return (
82
- <Card className={cx(classNames?.root, className)} style={style}>
84
+ <Card {...pickDataAttributes(rest)} className={cx(classNames?.root, className)} style={style}>
83
85
  <div className={cx(classes.header, classNames?.header)}>
84
86
  <WidgetHeader
85
87
  tier="section"
@@ -152,12 +154,15 @@ export function DangerZone({
152
154
  className,
153
155
  style,
154
156
  classNames,
157
+ ...rest
155
158
  }: DangerZoneProps) {
156
159
  return (
157
160
  <Card
158
- className={cx(classNames?.root, className)}
161
+ {...pickDataAttributes(rest)}
162
+ className={cx(classes.danger, classNames?.root, className)}
159
163
  style={{
160
- boxShadow: `${VX.shadowCard}, 0 0 0 1px ${alpha(VX.status.bad, 0.25)}`,
164
+ // The card's depth plus ONE edge in the class's scheme-independent ring colour.
165
+ boxShadow: `${VX.shadowCard}, 0 0 0 1px var(--danger-ring)`,
161
166
  ...style,
162
167
  }}
163
168
  >
@@ -437,6 +437,17 @@
437
437
  padding-top: var(--basalt-spark-readout-reserve);
438
438
  }
439
439
 
440
+ /* A sparkline that states its window has a caption line under its plot: the slot grows by it rather than
441
+ * letting the caption run into the footer. */
442
+ .sparklineBleed:has([data-basalt-sparkline-caption]) {
443
+ height: auto;
444
+ }
445
+
446
+ /* The slot bleeds past the card's inset, the plot with it; the caption is text and takes the inset back. */
447
+ .sparklineBleed [data-basalt-sparkline-caption] {
448
+ padding-inline: var(--vx-space-card-inset-x, 1rem);
449
+ }
450
+
440
451
  /* A Meter in the visual slot is a block, not a chart: it sizes to its content and keeps the card's
441
452
  * inline inset instead of the sparkline's fixed 22px and side bleed. */
442
453
  .sparklineBleed:has(> [data-basalt-meter]) {
@@ -107,14 +107,16 @@ import type {
107
107
  WidgetHeaderTitleProps,
108
108
  } from './widget-header'
109
109
  import { DeltaBadge } from './delta-badge'
110
- import { cx } from '../common/props'
111
- import type { BasaltProps, SlotStylesProps, Tone } from '../common/props'
110
+ import { cx, pickDataAttributes } from '../common/props'
111
+ import type { BasaltProps, DataAttributes, SlotStylesProps, Tone } from '../common/props'
112
112
  import { splitEmptyCopy } from '../common/empty-copy'
113
113
  import { EmptyState } from './empty-state'
114
+ import { couldNotLoad, HostTitleContext } from '../common/could-not-load'
114
115
  import { ErrorState, QueryState, resolveQueryBranch } from './query-state'
115
116
  import type { QueryBranch, QueryStateLike } from './query-state'
116
117
  import classes from './stat-card.module.css'
117
- import { HOSTED, VisualSlotContext } from './visual-slot'
118
+ import { HOSTED, HOSTED_COMPACT, VisualSlotContext } from './visual-slot'
119
+ import type { VisualSlot } from './visual-slot'
118
120
 
119
121
  /**
120
122
  * The boxes `StatCard` paints, and the whole styling seam it offers (`common/props.ts`).
@@ -210,6 +212,7 @@ function useSlotWidth(active: boolean): {
210
212
  * three slices.
211
213
  */
212
214
  export type StatCardProps = BasaltProps &
215
+ DataAttributes &
213
216
  SlotStylesProps<StatCardSlot> &
214
217
  Omit<WidgetHeaderTitleProps, 'subtitle'> &
215
218
  Omit<WidgetHeaderMetricProps, 'value'> &
@@ -313,8 +316,10 @@ function renderValueBody({
313
316
  figure,
314
317
  emptyText,
315
318
  hasDelta,
319
+ label,
316
320
  }: {
317
321
  hasDelta: boolean
322
+ label: string | undefined
318
323
  pending: boolean
319
324
  resolved: QueryBranch<unknown> | undefined
320
325
  figure: ReactNode
@@ -333,7 +338,7 @@ function renderValueBody({
333
338
  return (
334
339
  <ErrorState
335
340
  error={resolved.error}
336
- title="Could not load"
341
+ title={couldNotLoad(label)}
337
342
  tier="section"
338
343
  onRetry={() => void resolved.query.refetch()}
339
344
  retrying={resolved.query.fetchStatus === 'fetching'}
@@ -390,6 +395,18 @@ function renderFooterNode({
390
395
  )
391
396
  }
392
397
 
398
+ /** One shared slot object per tone and size, so a provider never re-renders its readers (`visual-slot.ts`). */
399
+ const toneSlots = new Map<string, VisualSlot>()
400
+ function slotFor(tone: Tone | undefined, compact: boolean): VisualSlot {
401
+ if (tone === undefined) return compact ? HOSTED_COMPACT : HOSTED
402
+ const key = `${tone}:${compact}`
403
+ const known = toneSlots.get(key)
404
+ if (known !== undefined) return known
405
+ const slot: VisualSlot = compact ? { tone, compact: true } : { tone }
406
+ toneSlots.set(key, slot)
407
+ return slot
408
+ }
409
+
393
410
  export function StatCard({
394
411
  title,
395
412
  icon,
@@ -414,6 +431,7 @@ export function StatCard({
414
431
  className,
415
432
  style,
416
433
  classNames,
434
+ ...rest
417
435
  }: StatCardProps) {
418
436
  const isRender = typeof sparkline === 'function'
419
437
  const bleeds = sparklinePlacement === 'bleed'
@@ -449,13 +467,16 @@ export function StatCard({
449
467
  query === undefined ? (
450
468
  breakdownRows
451
469
  ) : (
452
- <QueryState query={query} tier="section">
453
- {breakdownRows}
454
- </QueryState>
470
+ <HostTitleContext value={title}>
471
+ <QueryState query={query} tier="section">
472
+ {breakdownRows}
473
+ </QueryState>
474
+ </HostTitleContext>
455
475
  )
456
476
 
457
477
  // Built ONLY when ready: the render prop must not run in a pending / failed / empty branch, where
458
478
  // the last measured width is stale.
479
+ const hostSlot = slotFor(tone, !bleeds)
459
480
  const sparklineSlot: ReactNode =
460
481
  !ready || sparkline === undefined ? null : (
461
482
  <div
@@ -468,7 +489,7 @@ export function StatCard({
468
489
  >
469
490
  {/* A measured slot renders nothing on the first commit (width 0) — an SVG at width 0 is a
470
491
  visible 0-width box that then jumps, which is worse than one frame of nothing. */}
471
- <VisualSlotContext.Provider value={tone === undefined ? HOSTED : { tone }}>
492
+ <VisualSlotContext.Provider value={hostSlot}>
472
493
  {isRender ? measured.width > 0 && sparkline(measured) : sparkline}
473
494
  </VisualSlotContext.Provider>
474
495
  </div>
@@ -498,6 +519,7 @@ export function StatCard({
498
519
  figure,
499
520
  emptyText,
500
521
  hasDelta: delta !== undefined,
522
+ label: title,
501
523
  })
502
524
 
503
525
  const breakdownCount = breakdown?.length ?? 0
@@ -516,6 +538,7 @@ export function StatCard({
516
538
 
517
539
  return (
518
540
  <Card
541
+ {...pickDataAttributes(rest)}
519
542
  className={cx(classNames?.root, className)}
520
543
  style={{
521
544
  // The inset is the theme's (`card-inset.module.css`: the `cardInsetY`/`cardInsetX` tokens, 12/16
@@ -33,8 +33,8 @@
33
33
  * </StatGroup>
34
34
  */
35
35
  import type { CSSProperties, ReactNode } from 'react'
36
- import { cx } from '../common/props'
37
- import type { BasaltProps } from '../common/props'
36
+ import { cx, pickDataAttributes } from '../common/props'
37
+ import type { BasaltProps, DataAttributes } from '../common/props'
38
38
  import { StatStrip } from './stat-strip'
39
39
  import type { StatStripProps } from './stat-strip'
40
40
  import classes from './stat-group.module.css'
@@ -42,16 +42,17 @@ import classes from './stat-group.module.css'
42
42
  /** The desktop KPI column count. */
43
43
  export type StatGroupCols = 2 | 3 | 4 | 5
44
44
 
45
- export type StatGridProps = BasaltProps & {
46
- variant?: 'grid'
47
- /** The DESKTOP column count (`lg` and up). Default `4`. `sm` gets `min(cols, 3)` — except `4`, which gets 2 rather than an orphan row. A phone gets 2.
48
- * Never a responsive object — the law is basalt's, see the module docblock. */
49
- cols?: StatGroupCols
50
- /** Swap the column gap for a hairline rail between cells. Default `false`. */
51
- divided?: boolean
52
- /** The KPI cells — normally `StatCard`s. */
53
- children: ReactNode
54
- }
45
+ export type StatGridProps = BasaltProps &
46
+ DataAttributes & {
47
+ variant?: 'grid'
48
+ /** The DESKTOP column count (`lg` and up). Default `4`. `sm` gets `min(cols, 3)` — except `4`, which gets 2 rather than an orphan row. A phone gets 2.
49
+ * Never a responsive object — the law is basalt's, see the module docblock. */
50
+ cols?: StatGroupCols
51
+ /** Swap the column gap for a hairline rail between cells. Default `false`. */
52
+ divided?: boolean
53
+ /** The KPI cells — normally `StatCard`s. */
54
+ children: ReactNode
55
+ }
55
56
 
56
57
  /** `variant="strip"`: one joined surface of typed `cells` split by hairlines, plus an optional
57
58
  * `footer` row — see `StatStripProps`. `cols` here may be 6 (the strip's desktop count). */
@@ -65,7 +66,14 @@ export function StatGroup(props: StatGroupProps) {
65
66
  return <StatGrid {...props} />
66
67
  }
67
68
 
68
- function StatGrid({ cols = 4, divided = false, children, className, style }: StatGridProps) {
69
+ function StatGrid({
70
+ cols = 4,
71
+ divided = false,
72
+ children,
73
+ className,
74
+ style,
75
+ ...rest
76
+ }: StatGridProps) {
69
77
  // `4 -> 2`, not `4 -> 3`. `min(cols, 3)` is the general rule and it is right for 2, 3 and 5, but
70
78
  // FOUR is the default and the overwhelmingly common count, and three columns leave a four-KPI row
71
79
  // as 3 + 1 — one orphan cell against two thirds of empty track. MEASURED on the playground
@@ -82,7 +90,7 @@ function StatGrid({ cols = 4, divided = false, children, className, style }: Sta
82
90
  // sized is the whole point. `container-type: inline-size` contains the inline axis only, so the
83
91
  // wrapper's block size still comes from the grid: no percentage height resolves differently,
84
92
  // and there is no paint containment, so nothing inside is clipped.
85
- <div className={cx(classes.container, className)} style={style}>
93
+ <div {...pickDataAttributes(rest)} className={cx(classes.container, className)} style={style}>
86
94
  <div
87
95
  className={classes.root}
88
96
  data-cols={cols}
@@ -36,9 +36,6 @@
36
36
  min-width: 0;
37
37
  container-type: inline-size;
38
38
  container-name: basalt-card;
39
- /* The foot inset lives HERE, on the row-high slot, so a cell that ends early keeps the strip's
40
- * surface under it. */
41
- padding-block-end: var(--vx-space-stack-md);
42
39
  box-shadow:
43
40
  -1px 0 0 var(--vx-divider),
44
41
  0 -1px 0 var(--vx-divider);
@@ -50,7 +47,7 @@
50
47
  flex-direction: column;
51
48
  align-self: start;
52
49
  min-width: 0;
53
- padding: var(--vx-space-stack-md) var(--vx-space-stack-md) 0;
50
+ padding: var(--vx-space-stack-md);
54
51
  }
55
52
 
56
53
  /* Forced colors drop box-shadows, so the hairlines come back as CanvasText borders. Every cell takes
@@ -166,6 +163,8 @@
166
163
  * it, whether it sat beside the caption or wrapped under it, so values share a baseline. */
167
164
  @container basalt-card (max-width: 239.9px) {
168
165
  .qualifier {
166
+ /* Always on its own line under the caption: whether it fits beside it must not vary cell to cell. */
167
+ flex-basis: 100%;
169
168
  line-height: 1.25;
170
169
  }
171
170
 
@@ -390,7 +389,7 @@
390
389
  .underCell {
391
390
  min-width: 0;
392
391
  font-size: var(--vx-text-sm);
393
- margin: var(--vx-space-stack-md) var(--vx-space-stack-md) 0;
392
+ margin: var(--vx-space-stack-md);
394
393
  padding-block-start: var(--vx-space-stack-sm);
395
394
  border-block-start: 1px solid var(--vx-divider);
396
395
  }
@@ -45,14 +45,15 @@ import { useId, useRef } from 'react'
45
45
  import type { CSSProperties, ReactNode } from 'react'
46
46
  import { toErrorMessage } from '../common/errors'
47
47
  import { useIsomorphicLayoutEffect } from '../common/isomorphic-layout-effect'
48
- import { cx } from '../common/props'
49
- import type { BasaltProps, Tone } from '../common/props'
48
+ import { cx, pickDataAttributes } from '../common/props'
49
+ import type { BasaltProps, DataAttributes, Tone } from '../common/props'
50
50
  import { RetryButton } from '../common/retry-button'
51
51
  import { StatusDot } from '../theme/status-dot'
52
52
  import { VX } from '../tokens'
53
53
  import { InfoGlyph } from './widget-header'
54
54
  import classes from './stat-strip.module.css'
55
- import { HOSTED, HOSTED_LOADING, VisualSlotContext } from './visual-slot'
55
+ import { couldNotLoad } from '../common/could-not-load'
56
+ import { HOSTED, HOSTED_LOADING, HOSTED_COMPACT, VisualSlotContext } from './visual-slot'
56
57
 
57
58
  /** The URL shot states an anchor can declare itself absent in (`data-shot-absent`). */
58
59
  type StatStripShotState = 'empty' | 'loading' | 'error'
@@ -140,21 +141,23 @@ export type StatStripFooterEntry = {
140
141
  shotAbsent?: readonly StatStripShotState[]
141
142
  }
142
143
 
143
- export type StatStripProps = BasaltProps & {
144
- /** The strip's accessible name. */
145
- label: string
146
- cells: readonly StatStripCell[]
147
- /** Wider cells under the cells. */
148
- footer?: readonly StatStripFooterEntry[]
149
- /** The DESKTOP column count. Default: the cell count, capped at 6. */
150
- cols?: 2 | 3 | 4 | 5 | 6
151
- /** The shot states the page hides the whole strip in (`data-shot-absent` on every derived anchor). */
152
- shotAbsent?: readonly StatStripShotState[]
153
- }
144
+ export type StatStripProps = BasaltProps &
145
+ DataAttributes & {
146
+ /** The strip's accessible name. */
147
+ label: string
148
+ cells: readonly StatStripCell[]
149
+ /** Wider cells under the cells. */
150
+ footer?: readonly StatStripFooterEntry[]
151
+ /** The DESKTOP column count. Default: the cell count, capped at 6. A lone cell takes the whole strip
152
+ * whatever `cols` says. */
153
+ cols?: 2 | 3 | 4 | 5 | 6
154
+ /** The shot states the page hides the whole strip in (`data-shot-absent` on every derived anchor). */
155
+ shotAbsent?: readonly StatStripShotState[]
156
+ }
154
157
 
155
158
  const EMPTY = '—'
156
159
 
157
- function CellState({ state }: { state: StatStripCellState }) {
160
+ function CellState({ state, caption }: { state: StatStripCellState; caption: string }) {
158
161
  if (state.kind === 'empty') {
159
162
  // A stated reason IS the gap: it takes the value's place, so no bare dash sits above it.
160
163
  if (state.reason !== undefined) {
@@ -177,7 +180,7 @@ function CellState({ state }: { state: StatStripCellState }) {
177
180
  <div className={classes.error} role="alert" data-strip-state="error">
178
181
  <span className={classes.errorHead}>
179
182
  <StatusDot color={VX.status.bad} />
180
- Could not load
183
+ {couldNotLoad(caption)}
181
184
  </span>
182
185
  <p className={classes.reason}>{message}</p>
183
186
  {state.onRetry !== undefined && (
@@ -311,7 +314,7 @@ function StripCell({
311
314
  </span>
312
315
  )}
313
316
  </div>
314
- {state !== undefined && <CellState state={state} />}
317
+ {state !== undefined && <CellState state={state} caption={cell.caption} />}
315
318
  {state === undefined && hasHero && heroEl}
316
319
  </div>
317
320
  {state === undefined && cell.visual !== undefined && (
@@ -338,7 +341,7 @@ function StripCell({
338
341
  <li key={row.key} className={classes.row} data-strip-row={row.key}>
339
342
  <span className={classes.rowLabel}>{row.label}</span>
340
343
  <span className={classes.visual}>
341
- <VisualSlotContext.Provider value={HOSTED}>
344
+ <VisualSlotContext.Provider value={HOSTED_COMPACT}>
342
345
  {row.visual}
343
346
  </VisualSlotContext.Provider>
344
347
  </span>
@@ -407,8 +410,10 @@ export function StatStrip({
407
410
  shotAbsent,
408
411
  className,
409
412
  style,
413
+ ...domProps
410
414
  }: StatStripProps) {
411
- const desktop = cols ?? Math.min(Math.max(cells.length, 2), 6)
415
+ // A lone cell is the whole strip: a stated `cols` would leave it one track of an empty grid.
416
+ const desktop = cells.length === 1 ? 1 : (cols ?? Math.min(Math.max(cells.length, 2), 6))
412
417
  // `StatGroup`'s rule: four is 2 + 2 below the full count, never 3 + 1.
413
418
  const mid = desktop === 4 ? 2 : Math.min(desktop, 3)
414
419
  const keys = new Set(cells.map((cell) => cell.key))
@@ -458,7 +463,11 @@ export function StatStrip({
458
463
  for (const head of grid.querySelectorAll('[data-strip-head]')) observer.observe(head)
459
464
  }, [cells, footer])
460
465
  return (
461
- <div className={cx(classes.container, className)} style={style}>
466
+ <div
467
+ {...pickDataAttributes(domProps)}
468
+ className={cx(classes.container, className)}
469
+ style={style}
470
+ >
462
471
  <Card>
463
472
  <Card.Section
464
473
  component="section"
@@ -11,6 +11,8 @@ export interface VisualSlot {
11
11
  readonly tone?: Tone
12
12
  /** The host is loading: a `Meter` in the slot draws its loading state without its own `loading`. */
13
13
  readonly loading?: boolean
14
+ /** A slot with no room for a caption (a multi-row cell's row, a `right`-placed sparkline): its `Sparkline` states no window of its own. */
15
+ readonly compact?: true
14
16
  }
15
17
 
16
18
  /** A host with no verdict of its own: one shared object, so a provider never re-renders its readers. */
@@ -19,4 +21,7 @@ export const HOSTED: VisualSlot = {}
19
21
  /** `HOSTED` while the host loads. */
20
22
  export const HOSTED_LOADING: VisualSlot = { loading: true }
21
23
 
24
+ /** A slot too small for a caption under its visual. */
25
+ export const HOSTED_COMPACT: VisualSlot = { compact: true }
26
+
22
27
  export const VisualSlotContext = createContext<VisualSlot | null>(null)