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
@@ -10,8 +10,9 @@ export type MeterSegment = {
10
10
  label: string
11
11
  color?: string
12
12
  /**
13
- * `'muted'`: the part takes the one flat muted fill every muted part shares, a hairline seam
14
- * between neighbours (never a lightness step). A `color` wins.
13
+ * `'muted'`: the part takes the one flat muted fill every muted part shares, a visible 2px
14
+ * separator between neighbours (never a lightness step). A `color` wins. Give each categorical part its own
15
+ * series `color`; `muted` is for a tail "other" part, and a bar of only muted parts reads as one slab.
15
16
  */
16
17
  tone?: 'muted'
17
18
  forecast?: boolean
@@ -87,7 +88,7 @@ export type Part = {
87
88
  readonly size: number
88
89
  readonly color: string | undefined
89
90
  readonly forecast: boolean
90
- /** A muted part right after another muted part: a hairline seam keeps the shared fill apart. */
91
+ /** A categorical part right after another: a 2px separator (not a hairline) keeps neighbours, muted ones included, apart. */
91
92
  readonly seam: boolean
92
93
  readonly label: string
93
94
  /** The segment's own (normalised) amount, in the reading's units — what its caption states. */
@@ -205,11 +206,18 @@ export function normalizeSegments(segments: readonly MeterSegment[]): MeterSegme
205
206
  return segments.map((s) => ({ ...s, value: Number.isFinite(s.value) ? Math.max(0, s.value) : 0 }))
206
207
  }
207
208
 
209
+ const isMuted = (s: MeterSegment) => s.tone === 'muted' && s.color === undefined && !s.forecast
210
+
211
+ /** Three or more categorical parts that all take the one muted fill read as a single slab. */
212
+ export function allPartsMuted(segments: readonly MeterSegment[]): boolean {
213
+ const parts = segments.filter((s) => s.forecast !== true)
214
+ return parts.length >= 3 && parts.every(isMuted)
215
+ }
216
+
208
217
  /** Segment amounts (already normalised) accumulate from `min`; a part never passes the track end. */
209
218
  export function layoutSegments(segments: readonly MeterSegment[], span: number): Part[] {
210
219
  let cursor = 0
211
- const isMuted = (s: MeterSegment) => s.tone === 'muted' && s.color === undefined && !s.forecast
212
- let prevMuted = false
220
+ let prevCategorical = false
213
221
  return segments.map((s) => {
214
222
  const size = Math.max(0, Math.min(clamp01(s.value / span), 1 - cursor))
215
223
  const forecast = s.forecast === true
@@ -219,12 +227,13 @@ export function layoutSegments(segments: readonly MeterSegment[], span: number):
219
227
  size,
220
228
  color: forecast ? undefined : isMuted(s) ? mutedFill(MUTED_PART) : s.color,
221
229
  forecast,
222
- seam: isMuted(s) && prevMuted,
230
+ seam: !forecast && prevCategorical,
223
231
  label: s.label,
224
232
  amount: s.value,
225
233
  }
226
234
  cursor += size
227
- prevMuted = isMuted(s)
235
+ // A zero-size part has no visible edge: the next part has no neighbour to be separated from.
236
+ if (size > 0) prevCategorical = !forecast
228
237
  return part
229
238
  })
230
239
  }
@@ -3,7 +3,9 @@ import { Skeleton, VisuallyHidden } from '@mantine/core'
3
3
  import { useContext, useId, useRef, useState } from 'react'
4
4
  import type { CSSProperties, ReactNode, RefObject } from 'react'
5
5
  import { useIsomorphicLayoutEffect } from '../common/isomorphic-layout-effect'
6
+ import { splitEmptyCopy } from '../common/empty-copy'
6
7
  import { cx } from '../common/props'
8
+ import type { DataAttributes } from '../common/props'
7
9
  import {
8
10
  ariaValues,
9
11
  modelBar,
@@ -30,6 +32,7 @@ import type {
30
32
  ZoneLabel,
31
33
  } from './meter-model'
32
34
  import classes from './meter.module.css'
35
+ import { EmptyState } from './empty-state'
33
36
  import { VisualSlotContext } from './visual-slot'
34
37
  import { toPct } from './scale'
35
38
 
@@ -38,6 +41,8 @@ export type Shell = {
38
41
  style: CSSProperties | undefined
39
42
  /** `size="row"`: one text line tall, no caption rows. */
40
43
  row: boolean
44
+ /** The consumer's `data-*` (`data-shot`), on the root of every state. */
45
+ data: DataAttributes
41
46
  }
42
47
 
43
48
  /**
@@ -46,6 +51,7 @@ export type Shell = {
46
51
  */
47
52
  function rootProps(shell: Shell) {
48
53
  return {
54
+ ...shell.data,
49
55
  className: cx(classes.root, shell.row && classes.row, shell.className),
50
56
  style: shell.style,
51
57
  'data-basalt-meter': '',
@@ -160,6 +166,21 @@ export function MeterEmpty(props: {
160
166
  shell: Shell
161
167
  }) {
162
168
  const { label, text, ring, zoned, shell } = props
169
+ // A host that states its gap (non-blank `text`) gets the one empty box `BarList` and `EventList` draw: no
170
+ // track, no ring, the same `EmptyState` tile.
171
+ if (text !== undefined && text.trim() !== '') {
172
+ const copy = splitEmptyCopy(text)
173
+ return (
174
+ // oxlint-disable-next-line jsx-a11y/prefer-tag-over-role -- a polite live region named by the Meter's label; `<output>` cannot hold the tile's block content
175
+ <div {...rootProps(shell)} role="status" aria-label={label}>
176
+ <EmptyState
177
+ tier="section"
178
+ title={copy.title}
179
+ {...(copy.description !== undefined && { description: copy.description })}
180
+ />
181
+ </div>
182
+ )
183
+ }
163
184
  // The ring has a reading slot (its centre), so the dash sits there as the reading. A bar states its
164
185
  // gap once, and only if the host says so (`text`): otherwise the caption rows a loaded Meter would
165
186
  // have stay blank, so the muted track keeps the loaded height without a dash under it.
@@ -178,15 +199,11 @@ export function MeterEmpty(props: {
178
199
  </div>
179
200
  </>
180
201
  )}
181
- {text !== undefined ? (
182
- <span className={classes.empty}>{text}</span>
183
- ) : (
184
- !ring && (
185
- <>
186
- <VisuallyHidden className={classes.summary}>No reading</VisuallyHidden>
187
- {!shell.row && <Line zoned={zoned} />}
188
- </>
189
- )
202
+ {!ring && (
203
+ <>
204
+ <VisuallyHidden className={classes.summary}>No reading</VisuallyHidden>
205
+ {!shell.row && <Line zoned={zoned} />}
206
+ </>
190
207
  )}
191
208
  </output>
192
209
  )
@@ -798,7 +815,11 @@ export function MeterBar(props: {
798
815
  {
799
816
  key: 'start',
800
817
  node: glue(start),
801
- ...(readingInRow && model.markerPct !== undefined && { pct: model.markerPct }),
818
+ // `readingAt="start"` labels the track's start edge ("60-day low"), not the reading: it stays
819
+ // at the edge instead of sitting centred under the reading tick as if it were its caption.
820
+ ...(readingInRow &&
821
+ props.readingAt !== 'start' &&
822
+ model.markerPct !== undefined && { pct: model.markerPct }),
802
823
  // The reading sits at its fill's end (clamped inside the track); `readingAt="start"` keeps the old start edge.
803
824
  ...(props.readingAt !== 'start' &&
804
825
  !readingInRow &&
@@ -815,8 +836,9 @@ export function MeterBar(props: {
815
836
  key: 'forecast',
816
837
  node: glue(model.forecastText),
817
838
  drop: 2,
818
- // The reading ends at the boundary, the forecast ends where its fill does.
819
- // If that collides, it falls back to starting at the boundary before it drops.
839
+ // The reading ends at the boundary, the forecast ends where its fill does (a tick
840
+ // marks that end). If that would cover the reading, it falls back to starting at the
841
+ // boundary before it drops.
820
842
  ...(props.readingAt !== 'start' && model.forecastEndPct !== undefined
821
843
  ? {
822
844
  pct: model.forecastEndPct,
@@ -930,6 +952,16 @@ export function MeterBar(props: {
930
952
  <>
931
953
  <Tick kind="marker" className={classes.marker} pct={model.markerPct} />
932
954
  <Tick kind="boundary" className={classes.boundaryTick} pct={model.boundaryPct} />
955
+ {/* At the track end the track itself marks the forecast end. */}
956
+ <Tick
957
+ kind="forecastEnd"
958
+ className={classes.boundaryTick}
959
+ pct={
960
+ model.forecastEndPct !== undefined && model.forecastEndPct < 100
961
+ ? model.forecastEndPct
962
+ : undefined
963
+ }
964
+ />
933
965
  {model.ticks.map((t) => (
934
966
  <Tick key={t.key} kind="tick" className={classes.tick} pct={t.pct} />
935
967
  ))}
@@ -965,7 +997,7 @@ function tickPosition(kind: TickKind, pct: number): CSSProperties {
965
997
  return { insetInlineStart: `calc(100% - ${TICK_WIDTH})`, marginInlineStart: 0 }
966
998
  }
967
999
 
968
- type TickKind = 'marker' | 'boundary' | 'target' | 'tick'
1000
+ type TickKind = 'marker' | 'boundary' | 'forecastEnd' | 'target' | 'tick'
969
1001
 
970
1002
  function Tick({
971
1003
  kind,
@@ -14,6 +14,12 @@
14
14
  --basalt-meter-caption: var(--vx-text-micro);
15
15
  }
16
16
 
17
+ /* A bar fills its container's width: as a flex item (a StatCard visual, a strip cell) it would
18
+ * otherwise size to its captions and stop part-way across the card. */
19
+ .root:has(> .trackBox) {
20
+ inline-size: 100%;
21
+ }
22
+
17
23
  .track {
18
24
  position: relative;
19
25
  display: flex;
@@ -62,10 +68,10 @@
62
68
  background: color-mix(in srgb, var(--vx-muted) 65%, transparent);
63
69
  }
64
70
 
65
- /* Muted parts share one flat fill: a track-coloured hairline at the shared edge tells them apart. */
71
+ /* Adjacent categorical parts (muted ones share one fill): a track-coloured gap, not a hairline, tells them apart. */
66
72
  .fill[data-meter-seam] {
67
73
  box-sizing: border-box;
68
- border-inline-start: 1px solid var(--vx-surface-subtle);
74
+ border-inline-start: 2px solid var(--vx-surface-subtle);
69
75
  }
70
76
 
71
77
  /* The committed/forecast pair: the same neutral at two strengths. Flat, never hatched. */
@@ -168,7 +174,11 @@
168
174
  translate: none;
169
175
  }
170
176
 
171
- /* The reading on a zone track: a notch standing proud of the bands, in ink. */
177
+ /*
178
+ * The reading on a zone track: a notch standing proud of the bands. A panel core in an ink ring, so
179
+ * one of the two always contrasts with the fill under it: the core on an ink fill, the ring on a
180
+ * light one (an ink core on an ink track vanished).
181
+ */
172
182
  .marker {
173
183
  position: absolute;
174
184
  top: -3px;
@@ -176,7 +186,8 @@
176
186
  width: 3px;
177
187
  margin-inline-start: -1.5px;
178
188
  border-radius: var(--vx-radius-fine);
179
- background: var(--vx-ink);
189
+ background: var(--vx-surface-panel);
190
+ box-shadow: 0 0 0 1.5px var(--vx-ink);
180
191
  }
181
192
 
182
193
  .tick {
@@ -187,8 +198,9 @@
187
198
  margin-inline-start: -1px;
188
199
  border-radius: var(--vx-radius-fine);
189
200
  background: var(--vx-ink);
190
- /* A track-coloured halo keeps an ink tick readable on a fill that is itself near-ink (dark). */
191
- box-shadow: 0 0 0 1px var(--vx-surface-subtle);
201
+ /* A panel-coloured 2px halo (the opposite pole of ink in both schemes) keeps the tick readable on
202
+ * a fill that is itself near-ink: `tone="ink"`, or --vx-line in dark. */
203
+ box-shadow: 0 0 0 2px var(--vx-surface-panel);
192
204
  }
193
205
 
194
206
  .boundaryTick {
@@ -324,11 +336,6 @@
324
336
  border-radius: var(--vx-radius-fine);
325
337
  }
326
338
 
327
- .empty {
328
- font-size: var(--basalt-meter-caption);
329
- color: var(--vx-muted);
330
- }
331
-
332
339
  /* One caption-height line: a blank caption row of an empty Meter, so it stands at the loaded height. */
333
340
  .line {
334
341
  display: flex;
@@ -31,7 +31,6 @@ declare const classes: {
31
31
  readonly partCaptionsWrap: string
32
32
  readonly partCaptionsGrid: string
33
33
  readonly swatch: string
34
- readonly empty: string
35
34
  readonly line: string
36
35
  readonly lineZoned: string
37
36
  readonly hold: string
@@ -24,7 +24,16 @@
24
24
  *
25
25
  * Categorical `segments` (no `forecast` part) are captioned one per part — swatch, name, value — under
26
26
  * the track and the default start caption is dropped (an explicit `startCaption` still shows);
27
- * committed/forecast keeps the reading plus the forecast caption.
27
+ * committed/forecast keeps the reading plus the forecast caption. The reading is captioned at the
28
+ * committed fill's end and the forecast at the forecast's end, which a tick marks (none when it
29
+ * reaches the track end); the forecast caption drops before it ever sits under the boundary tick.
30
+ * Adjacent categorical parts are separated by a 2px separator, muted ones included; give each part its own
31
+ * series colour (`tone="muted"` is for a tail "other" part — a bar of only muted parts warns once in
32
+ * development).
33
+ *
34
+ * Captions keep at least a gap step between them at any width: at
35
+ * narrow widths the lower-priority ones drop first (tick captions, then the forecast), and what is
36
+ * dropped stays in the described-by text. A bar fills its container's width.
28
37
  *
29
38
  * @example
30
39
  * import { Meter } from 'basalt-ui'
@@ -53,28 +62,31 @@
53
62
  */
54
63
  import { useContext } from 'react'
55
64
  import type { ReactNode } from 'react'
56
- import type { BasaltProps } from '../common/props'
65
+ import { pickDataAttributes } from '../common/props'
66
+ import type { BasaltProps, DataAttributes } from '../common/props'
57
67
  import { VX } from '../tokens'
58
- import { isReading, normalizeSegments, segmentReading, spanOf } from './meter-model'
68
+ import { reportOnce } from '../common/validate'
69
+ import { allPartsMuted, isReading, normalizeSegments, segmentReading, spanOf } from './meter-model'
59
70
  import type { MeterSegment, MeterTick, MeterZone } from './meter-model'
60
71
  import { MeterBar, MeterEmpty, MeterRing, MeterRingLoading } from './meter-parts'
61
72
  import { asText } from './scale'
62
73
  import { VisualSlotContext } from './visual-slot'
63
74
 
64
- type Common = BasaltProps & {
65
- /** Accessible name (`aria-label`). Required: a meter without one is announced as a bare number. */
66
- label: string
67
- /** Track start. Default 0. */
68
- min?: number
69
- /** Track end. Default 100. */
70
- max?: number
71
- /** Formats values in captions and the accessible text. Default: the number as written. */
72
- format?: (value: number) => string
73
- /** Renders a skeleton with the meter's footprint. */
74
- loading?: boolean
75
- /** Muted line shown when there is no reading; none by default (the muted track stands alone, caption rows blank). */
76
- emptyText?: string
77
- }
75
+ type Common = BasaltProps &
76
+ DataAttributes & {
77
+ /** Accessible name (`aria-label`). Required: a meter without one is announced as a bare number. */
78
+ label: string
79
+ /** Track start. Default 0. */
80
+ min?: number
81
+ /** Track end. Default 100. */
82
+ max?: number
83
+ /** Formats values in captions and the accessible text. Default: the number as written. */
84
+ format?: (value: number) => string
85
+ /** Renders a skeleton with the meter's footprint. */
86
+ loading?: boolean
87
+ /** The empty box shown when there is no reading (the same `EmptyState` tile `BarList` and `EventList` draw, no track; the first sentence is its title, the rest its muted line). None by default: the muted track stands alone, caption rows blank. */
88
+ emptyText?: string
89
+ }
78
90
 
79
91
  type BarCommon = Common & {
80
92
  shape?: 'bar'
@@ -222,7 +234,7 @@ function barTone(tone: 'muted' | 'ink' | undefined, plain: boolean): 'muted' | u
222
234
  export function Meter(props: MeterProps) {
223
235
  const { label, min = 0, max = 100, format = asText, className, style } = props
224
236
  const row = props.size === 'row'
225
- const shell = { className, style, row }
237
+ const shell = { className, style, row, data: pickDataAttributes(props) }
226
238
  const ring = props.shape === 'ring'
227
239
  warnInvalidTrack(min, max)
228
240
  const host = useContext(VisualSlotContext)
@@ -238,6 +250,12 @@ export function Meter(props: MeterProps) {
238
250
  props.segments === undefined || (loading && props.segments.length === 0)
239
251
  ? undefined
240
252
  : normalizeSegments(props.segments)
253
+ if (segments !== undefined && allPartsMuted(segments)) {
254
+ reportOnce(
255
+ 'Meter',
256
+ '[basalt] Meter: every segment is tone="muted", so the parts read as one slab; give each part its own series colour (muted is for a tail "other" part)',
257
+ )
258
+ }
241
259
  const placeholder =
242
260
  props.zones !== undefined && props.zones.length > 0 ? min + spanOf(min, max).span / 2 : min
243
261
  const reading = loading
@@ -9,11 +9,14 @@
9
9
  min-width: 0;
10
10
  }
11
11
 
12
+ /* The aside sits right after the sentence it dates and wraps under it when the line is full — never
13
+ * pinned to the far edge, where it read as belonging to nothing. */
12
14
  .top {
13
15
  display: flex;
16
+ flex-wrap: wrap;
14
17
  align-items: baseline;
15
- justify-content: space-between;
16
- gap: var(--vx-space-stack-md);
18
+ column-gap: var(--vx-space-stack-md);
19
+ row-gap: var(--vx-space-stack-xs);
17
20
  min-width: 0;
18
21
  }
19
22
 
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * PageSummary — a page's opening (docs/waves/design-parity/SPEC.md § 6.9): one headline sentence
3
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
4
+ * after the headline (beside it, wrapping under it when the line is full). It renders an `h2` at the `h1` type step (head face, −0.02em): the page's own
5
5
  * h1 is the shell breadcrumb's / `PageTitle`'s, and a second one would split the outline. The facts
6
6
  * are the proportional sans at `xs`, muted, `·`-separated — a time fact may take mono itself, the line does
7
7
  * not (D33).
@@ -32,8 +32,8 @@
32
32
  */
33
33
  import { Skeleton } from '@mantine/core'
34
34
  import type { ReactNode } from 'react'
35
- import { cx } from '../common/props'
36
- import type { BasaltProps } from '../common/props'
35
+ import { cx, pickDataAttributes } from '../common/props'
36
+ import type { BasaltProps, DataAttributes } from '../common/props'
37
37
  import classes from './page-summary.module.css'
38
38
 
39
39
  type Fact = ReactNode | null | false | undefined
@@ -43,7 +43,7 @@ type PageSummaryContent = {
43
43
  sentence: ReactNode
44
44
  /** Short facts under the headline, e.g. `['3 need you', oldest && `oldest ${oldest}`]`. */
45
45
  facts?: readonly Fact[]
46
- /** Right of the headline: a date or a freshness word. */
46
+ /** After the headline: a date or a freshness word. */
47
47
  aside?: ReactNode
48
48
  loading?: false
49
49
  }
@@ -51,7 +51,9 @@ type PageSummaryContent = {
51
51
  /** While the sentence's data loads: a skeleton of the same shape, no content props needed. */
52
52
  type PageSummaryLoading = Partial<Omit<PageSummaryContent, 'loading'>> & { loading: true }
53
53
 
54
- export type PageSummaryProps = BasaltProps & (PageSummaryContent | PageSummaryLoading)
54
+ export type PageSummaryProps = BasaltProps &
55
+ DataAttributes &
56
+ (PageSummaryContent | PageSummaryLoading)
55
57
 
56
58
  const NO_FACTS: readonly Fact[] = []
57
59
 
@@ -60,7 +62,12 @@ const isShown = (fact: Fact): boolean =>
60
62
 
61
63
  export function PageSummary(props: PageSummaryProps) {
62
64
  const { className, style } = props
63
- const common = { className: cx(classes.root, className), 'data-page-summary': '', style }
65
+ const common = {
66
+ ...pickDataAttributes(props),
67
+ className: cx(classes.root, className),
68
+ 'data-page-summary': '',
69
+ style,
70
+ }
64
71
 
65
72
  if (props.loading === true) {
66
73
  return (
@@ -15,11 +15,13 @@
15
15
  * escape hatch for a page that must place its branches in different DOM positions.
16
16
  */
17
17
  import { Center, Group, Loader, Skeleton, Stack, Text, VisuallyHidden } from '@mantine/core'
18
+ import { useContext } from 'react'
18
19
  import type { CSSProperties, ReactNode } from 'react'
19
20
  import { toErrorMessage } from '../common/errors'
20
- import { cx } from '../common/props'
21
+ import { couldNotLoad, HostTitleContext } from '../common/could-not-load'
22
+ import { cx, pickDataAttributes } from '../common/props'
21
23
  import { RetryButton } from '../common/retry-button'
22
- import type { BasaltProps, SlotStylesProps } from '../common/props'
24
+ import type { BasaltProps, DataAttributes, SlotStylesProps } from '../common/props'
23
25
  import { VX } from '../tokens'
24
26
  import { StatusDot } from '../theme/status-dot'
25
27
  import { EmptyState } from './empty-state'
@@ -57,12 +59,13 @@ export type QueryEmptyCopy = {
57
59
 
58
60
  // ── LoadingState ──────────────────────────────────────────────────────────────────────────────────
59
61
 
60
- export type LoadingStateProps = BasaltProps & {
61
- /** How loud this state is. Default `'page'`. */
62
- tier?: QueryStateTier
63
- /** Accessible name for the loading state. Say what is loading. */
64
- label?: string
65
- }
62
+ export type LoadingStateProps = BasaltProps &
63
+ DataAttributes & {
64
+ /** How loud this state is. Default `'page'`. */
65
+ tier?: QueryStateTier
66
+ /** Accessible name for the loading state. Say what is loading. */
67
+ label?: string
68
+ }
66
69
 
67
70
  /**
68
71
  * `tier="page"` centres a neutral spinner in a generous block (a route body whose shape is unknown);
@@ -74,11 +77,14 @@ export function LoadingState({
74
77
  label = 'Loading',
75
78
  className,
76
79
  style,
80
+ ...rest
77
81
  }: LoadingStateProps): ReactNode {
78
82
  const resolved = tier ?? 'page'
83
+ const data = pickDataAttributes(rest)
79
84
  if (resolved === 'section') {
80
85
  return (
81
86
  <Stack
87
+ {...data}
82
88
  component="output"
83
89
  gap="xs"
84
90
  aria-label={label}
@@ -98,6 +104,7 @@ export function LoadingState({
98
104
  // renders at today's 64px at level 0 and tracks every other density level with it.
99
105
  return (
100
106
  <Center
107
+ {...data}
101
108
  {...(className !== undefined && { className })}
102
109
  style={{ paddingBlock: 'calc(var(--vx-space-stack-xs, 0.25rem) * 16)', ...style }}
103
110
  >
@@ -108,21 +115,22 @@ export function LoadingState({
108
115
 
109
116
  // ── ErrorState ────────────────────────────────────────────────────────────────────────────────────
110
117
 
111
- export type ErrorStateProps = BasaltProps & {
112
- /** Whatever was thrown — the raw Eden/fetch envelope is fine, it gets decoded. */
113
- error: unknown
114
- /** Alert heading. Say what failed, e.g. `Could not load images`. */
115
- title?: string
116
- /** Shown only when the server body carries no readable message. */
117
- fallback?: string
118
- onRetry?: () => void
119
- /** Disables the retry button while a refetch is in flight. */
120
- retrying?: boolean
121
- /** How loud this state is. Default `'page'`. */
122
- tier?: QueryStateTier
123
- /** Extra controls beside Retry (e.g. a "Back to shares" link). */
124
- action?: ReactNode
125
- }
118
+ export type ErrorStateProps = BasaltProps &
119
+ DataAttributes & {
120
+ /** Whatever was thrown — the raw Eden/fetch envelope is fine, it gets decoded. */
121
+ error: unknown
122
+ /** Alert heading. Say what failed, e.g. `Could not load images`. */
123
+ title?: string
124
+ /** Shown only when the server body carries no readable message. */
125
+ fallback?: string
126
+ onRetry?: () => void
127
+ /** Disables the retry button while a refetch is in flight. */
128
+ retrying?: boolean
129
+ /** How loud this state is. Default `'page'`. */
130
+ tier?: QueryStateTier
131
+ /** Extra controls beside Retry (e.g. a "Back to shares" link). */
132
+ action?: ReactNode
133
+ }
126
134
 
127
135
  /**
128
136
  * The error branch: the REAL server message (via `toErrorMessage`) plus a retry. Usable on its own,
@@ -130,7 +138,7 @@ export type ErrorStateProps = BasaltProps & {
130
138
  */
131
139
  export function ErrorState({
132
140
  error,
133
- title = 'Could not load',
141
+ title: titleProp,
134
142
  fallback = 'The request failed.',
135
143
  onRetry,
136
144
  retrying = false,
@@ -138,7 +146,11 @@ export function ErrorState({
138
146
  action,
139
147
  className,
140
148
  style,
149
+ ...rest
141
150
  }: ErrorStateProps): ReactNode {
151
+ const data = pickDataAttributes(rest)
152
+ const hostTitle = useContext(HostTitleContext)
153
+ const title = titleProp ?? couldNotLoad(hostTitle)
142
154
  const resolved = tier ?? 'page'
143
155
  // D28: a status dot + a word + the message + the retry, on the neutral surface — never a
144
156
  // red-tinted filled panel (SPEC § 6.12).
@@ -146,6 +158,7 @@ export function ErrorState({
146
158
  <Stack
147
159
  gap="xs"
148
160
  role="alert"
161
+ {...(resolved === 'section' && data)}
149
162
  {...(resolved === 'section' && className !== undefined && { className })}
150
163
  {...(resolved === 'section' && style !== undefined && { style })}
151
164
  >
@@ -170,6 +183,7 @@ export function ErrorState({
170
183
  return (
171
184
  <Stack
172
185
  py="md"
186
+ {...data}
173
187
  {...(className !== undefined && { className })}
174
188
  {...(style !== undefined && { style })}
175
189
  >
@@ -241,6 +255,7 @@ export function resolveQueryBranch<TData>(
241
255
  export type QueryStateSlot = 'root'
242
256
 
243
257
  export type QueryStateProps<TData> = BasaltProps &
258
+ DataAttributes &
244
259
  SlotStylesProps<QueryStateSlot> & {
245
260
  query: QueryStateLike<TData>
246
261
  /** A render function gets `data` narrowed to non-undefined; a plain node also works. */
@@ -249,7 +264,8 @@ export type QueryStateProps<TData> = BasaltProps &
249
264
  empty?: QueryEmptyCopy
250
265
  /** Override the default `[]` / `{ data: [] }` emptiness test — `() => false` disables it. */
251
266
  isEmpty?: (data: TData) => boolean
252
- /** Alert heading on the error branch — say what failed. */
267
+ /** Alert heading on the error branch — say what failed. Omitted inside a titled `Section`, it
268
+ * names that section ("Could not load practice record"); elsewhere it is "Could not load". */
253
269
  errorTitle?: string
254
270
  /** Shown only when the server body carries no readable message. */
255
271
  errorFallback?: string
@@ -285,7 +301,7 @@ export function QueryState<TData>({
285
301
  children,
286
302
  empty,
287
303
  isEmpty,
288
- errorTitle = 'Could not load',
304
+ errorTitle,
289
305
  errorFallback = 'The request failed.',
290
306
  errorAction,
291
307
  tier,
@@ -293,8 +309,12 @@ export function QueryState<TData>({
293
309
  className,
294
310
  style,
295
311
  classNames,
312
+ ...rest
296
313
  }: QueryStateProps<TData>): ReactNode {
297
314
  assertQueryStateLike('QueryState', query)
315
+ // The live branch's root carries the consumer's `data-*`. The READY branch renders `children`
316
+ // alone and has no root of its own, so an anchor there belongs on the host (`Section`, a card).
317
+ const dataAttrs = pickDataAttributes(rest)
298
318
  const resolvedTier = tier ?? 'page'
299
319
  // One class for every branch — see {@link QueryStateSlot}. `cx` returns `''` when both are
300
320
  // absent, and an empty `className` on a branch that previously carried none would be a DOM diff,
@@ -307,8 +327,9 @@ export function QueryState<TData>({
307
327
  if (isError && data === undefined) {
308
328
  return (
309
329
  <ErrorState
330
+ {...dataAttrs}
310
331
  error={error}
311
- title={errorTitle}
332
+ {...(errorTitle !== undefined && { title: errorTitle })}
312
333
  fallback={errorFallback}
313
334
  onRetry={retry}
314
335
  retrying={retrying}
@@ -322,10 +343,11 @@ export function QueryState<TData>({
322
343
 
323
344
  if (data === undefined) {
324
345
  if (fetchStatus === 'idle' && !isError)
325
- return empty ? renderEmpty(empty, resolvedTier, rootClassName, style) : null
346
+ return empty ? renderEmpty(empty, resolvedTier, rootClassName, style, dataAttrs) : null
326
347
  return (
327
348
  loading ?? (
328
349
  <LoadingState
350
+ {...dataAttrs}
329
351
  tier={resolvedTier}
330
352
  {...(rootClassName !== undefined && { className: rootClassName })}
331
353
  {...(style !== undefined && { style })}
@@ -337,7 +359,7 @@ export function QueryState<TData>({
337
359
  const emptyNow = isEmpty ? isEmpty(data) : defaultIsEmpty(data)
338
360
  const body = emptyNow
339
361
  ? empty
340
- ? renderEmpty(empty, resolvedTier, rootClassName, style)
362
+ ? renderEmpty(empty, resolvedTier, rootClassName, style, dataAttrs)
341
363
  : null
342
364
  : typeof children === 'function'
343
365
  ? children(data)
@@ -347,6 +369,7 @@ export function QueryState<TData>({
347
369
 
348
370
  return (
349
371
  <Stack
372
+ {...dataAttrs}
350
373
  gap="sm"
351
374
  {...(rootClassName !== undefined && { className: rootClassName })}
352
375
  {...(style !== undefined && { style })}
@@ -369,9 +392,11 @@ function renderEmpty(
369
392
  tier: QueryStateTier,
370
393
  className?: string,
371
394
  style?: CSSProperties,
395
+ data?: DataAttributes,
372
396
  ): ReactNode {
373
397
  return (
374
398
  <EmptyState
399
+ {...data}
375
400
  title={empty.title}
376
401
  tier={tier}
377
402
  {...(empty.description !== undefined && { description: empty.description })}