basalt-ui 2.25.0 → 2.26.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 (72) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/MIGRATING.md +152 -19
  3. package/configs/oxlint-basalt.json +1 -1
  4. package/configs/oxlint-plugin.js +3 -9
  5. package/configs/oxlint-plugin.test.ts +6 -0
  6. package/dist/charts/ChartCard.d.ts +5 -3
  7. package/dist/charts/ChartCard.d.ts.map +1 -1
  8. package/dist/charts/ChartCard.js +10 -2
  9. package/dist/charts/Sparkline.d.ts.map +1 -1
  10. package/dist/charts/Sparkline.js +65 -7
  11. package/dist/charts/chart-box.module.css +50 -7
  12. package/dist/charts/chart-box.module.css.d.ts +2 -0
  13. package/dist/charts/chart-card.module.css +34 -0
  14. package/dist/charts/chart-card.module.css.d.ts +2 -0
  15. package/dist/charts/chart-legend.module.css +5 -6
  16. package/dist/charts/compile.d.ts.map +1 -1
  17. package/dist/charts/compile.js +27 -1
  18. package/dist/charts/legend.d.ts.map +1 -1
  19. package/dist/charts/legend.js +42 -9
  20. package/dist/charts/sparkline.module.css +13 -9
  21. package/dist/charts/state.d.ts.map +1 -1
  22. package/dist/charts/state.js +6 -1
  23. package/dist/dashboard/meter-model.d.ts +2 -0
  24. package/dist/dashboard/meter-model.d.ts.map +1 -1
  25. package/dist/dashboard/meter-model.js +99 -7
  26. package/dist/dashboard/meter-parts.d.ts +4 -7
  27. package/dist/dashboard/meter-parts.d.ts.map +1 -1
  28. package/dist/dashboard/meter-parts.js +102 -78
  29. package/dist/dashboard/meter.d.ts +1 -1
  30. package/dist/dashboard/meter.d.ts.map +1 -1
  31. package/dist/dashboard/meter.js +10 -7
  32. package/dist/dashboard/meter.module.css +43 -12
  33. package/dist/dashboard/meter.module.css.d.ts +1 -2
  34. package/dist/dashboard/section.d.ts +1 -2
  35. package/dist/dashboard/section.d.ts.map +1 -1
  36. package/dist/dashboard/section.module.css +8 -7
  37. package/dist/dashboard/stat-card.module.css +17 -0
  38. package/dist/dashboard/stat-strip.d.ts +9 -1
  39. package/dist/dashboard/stat-strip.d.ts.map +1 -1
  40. package/dist/dashboard/stat-strip.js +32 -6
  41. package/dist/dashboard/stat-strip.module.css +38 -0
  42. package/dist/dashboard/stat-strip.module.css.d.ts +3 -0
  43. package/dist/dashboard/visual-slot.d.ts +4 -0
  44. package/dist/dashboard/visual-slot.d.ts.map +1 -1
  45. package/dist/dashboard/visual-slot.js +2 -0
  46. package/dist/dashboard/widget-header.module.css +9 -0
  47. package/llms.txt +2 -2
  48. package/package.json +1 -1
  49. package/src/charts/ChartCard.tsx +23 -4
  50. package/src/charts/Sparkline.tsx +105 -10
  51. package/src/charts/chart-box.module.css +50 -7
  52. package/src/charts/chart-box.module.css.d.ts +2 -0
  53. package/src/charts/chart-card.module.css +34 -0
  54. package/src/charts/chart-card.module.css.d.ts +2 -0
  55. package/src/charts/chart-legend.module.css +5 -6
  56. package/src/charts/compile.ts +40 -1
  57. package/src/charts/legend.tsx +64 -16
  58. package/src/charts/sparkline.module.css +13 -9
  59. package/src/charts/state.tsx +18 -1
  60. package/src/dashboard/meter-model.ts +147 -12
  61. package/src/dashboard/meter-parts.tsx +71 -50
  62. package/src/dashboard/meter.module.css +43 -12
  63. package/src/dashboard/meter.module.css.d.ts +1 -2
  64. package/src/dashboard/meter.tsx +22 -9
  65. package/src/dashboard/section.module.css +8 -7
  66. package/src/dashboard/section.tsx +1 -2
  67. package/src/dashboard/stat-card.module.css +17 -0
  68. package/src/dashboard/stat-strip.module.css +38 -0
  69. package/src/dashboard/stat-strip.module.css.d.ts +3 -0
  70. package/src/dashboard/stat-strip.tsx +49 -8
  71. package/src/dashboard/visual-slot.ts +5 -0
  72. package/src/dashboard/widget-header.module.css +9 -0
@@ -31,7 +31,13 @@
31
31
  text-overflow: ellipsis;
32
32
  white-space: nowrap;
33
33
  pointer-events: none;
34
- background: var(--vx-tooltip-bg);
34
+ /* Opaque in both schemes: `--vx-tooltip-bg` is translucent in dark, and a footer under the chip
35
+ * would ghost through it, so the tint is layered over the elevated surface. */
36
+ background: linear-gradient(
37
+ var(--basalt-tooltip-surface, var(--vx-tooltip-bg)),
38
+ var(--basalt-tooltip-surface, var(--vx-tooltip-bg))
39
+ )
40
+ var(--vx-surface-elevated);
35
41
  border: 1px solid var(--vx-tooltip-border);
36
42
  border-radius: var(--vx-radius-ctrl);
37
43
  }
@@ -54,19 +60,17 @@
54
60
  white-space: pre;
55
61
  }
56
62
 
57
- /* A readout that overflows its box first drops the air round its separator and its padding. */
63
+ /* A readout that overflows its box first shrinks its padding. The separator and the air round it
64
+ * never drop. */
58
65
  .readout[data-tight] {
59
66
  padding-inline: 2px;
60
67
  }
61
68
 
62
- .readout[data-tight] .sep {
63
- letter-spacing: -0.15em;
64
- word-spacing: -0.25em;
65
- }
66
-
67
69
  /* A readout that still overflows stacks (set in `Sparkline.tsx`): the date on its own line, wrapped
68
- * not clipped. It sits INSIDE the plot's top band (the lift-0 placement), hosted or bare: a hosted
69
- * chip grown past the host's one reserved line would cover the figure's delta or qualifier above. */
70
+ * not clipped. It sits INSIDE the plot (the lift-0 placement), hosted or bare: a hosted chip grown
71
+ * past the host's one reserved line would cover the figure's delta or qualifier above. A hosted
72
+ * line's chip is then placed by `Sparkline.tsx` where the plotted line is not (`top`/`margin-left`
73
+ * inline); `top: 0` is the fallback. */
70
74
  .readout[data-stacked] {
71
75
  block-size: auto;
72
76
  max-height: none;
@@ -7,6 +7,7 @@ import { toErrorMessage } from '../common/errors'
7
7
  import { RetryButton } from '../common/retry-button'
8
8
  import { VX } from '../tokens'
9
9
  import { ChartBox, growClass, stateClass } from './box'
10
+ import boxClasses from './chart-box.module.css'
10
11
  import type { ChartBoxHeight } from './box'
11
12
  import type { ChartState } from './types'
12
13
 
@@ -37,6 +38,20 @@ const pendingStyle: CSSProperties = {
37
38
  background: `linear-gradient(90deg, transparent, ${VX.surface.subtle}, transparent)`,
38
39
  }
39
40
 
41
+ /** Bar ghost heights (% of the plot) of a pending plot: a mild rise, not data. */
42
+ const GHOST_BARS = [38, 52, 44, 66, 58, 74, 62, 48] as const
43
+
44
+ /** The loaded shape of a plot, drawn in neutral tone (`chart-box.module.css` `.ghost`). */
45
+ function PlotGhost(): ReactElement {
46
+ return (
47
+ <div aria-hidden="true" data-basalt-plot-ghost="" className={boxClasses.ghost}>
48
+ {GHOST_BARS.map((h, i) => (
49
+ <span key={i} className={boxClasses.ghostBar} style={{ height: `${h}%` }} />
50
+ ))}
51
+ </div>
52
+ )
53
+ }
54
+
40
55
  // The error idiom (D28, SPEC § 6.12): a status dot + a word + the message + the action, on the
41
56
  // neutral surface. The dot is drawn from `--vx-*` tokens here — `src/charts/**` stays Mantine-free and `theme/status-dot` sits in the
42
57
  // Mantine-coupled theme layer.
@@ -111,7 +126,9 @@ export function ChartPlaceholder(props: {
111
126
  )
112
127
  if (kind === 'pending')
113
128
  return fit(
114
- <output aria-label="Loading chart" aria-busy="true" className={stateClass} style={style} />,
129
+ <output aria-label="Loading chart" aria-busy="true" className={stateClass} style={style}>
130
+ {!props.compact && <PlotGhost />}
131
+ </output>,
115
132
  )
116
133
  const label =
117
134
  kind === 'error'
@@ -277,18 +277,32 @@ export function placeRowLabels(
277
277
  labels: readonly RowLabel[],
278
278
  rowWidth: number,
279
279
  gap = 0,
280
+ ): RowPlacement {
281
+ const first = placeOnce(labels, rowWidth, gap, false)
282
+ // One register: once any name falls back to its `short`, every other name that has one follows
283
+ // (the holding name, which never shortens, is the one exception). The row is placed again with
284
+ // those names in their `short` box, so every shift is computed against the box that renders.
285
+ return first.short.some(Boolean) ? placeOnce(labels, rowWidth, gap, true) : first
286
+ }
287
+
288
+ function placeOnce(
289
+ labels: readonly RowLabel[],
290
+ rowWidth: number,
291
+ gap: number,
292
+ registerShort: boolean,
280
293
  ): RowPlacement {
281
294
  const shown = labels.map(() => false)
282
295
  const short = labels.map(() => false)
283
296
  const shift = labels.map(() => 0)
284
- const kept: { box: LabelBox; tick: boolean }[] = []
297
+ const kept: { box: LabelBox; tick: boolean; i: number }[] = []
285
298
  const rank = (l: RowLabel) => (l.holding ? 0 : l.span ? 3 : l.end ? 2 : 1)
286
299
  const order = labels
287
300
  .map((_, i) => i)
288
301
  .toSorted((a, b) => rank(labels[a] as RowLabel) - rank(labels[b] as RowLabel))
289
302
  // The gap step applies when either label of a pair is a tick; zone names keep to "not touching".
290
- const clears = (b: LabelBox, tick: boolean) =>
291
- !kept.some(({ box: k, tick: kTick }) => {
303
+ const clears = (b: LabelBox, tick: boolean, self = -1) =>
304
+ !kept.some(({ box: k, tick: kTick, i: ki }) => {
305
+ if (ki === self) return false
292
306
  const pad = tick || kTick ? gap : 0
293
307
  return b.left < k.right + pad - LABEL_SUBPIXEL && k.left < b.right + pad - LABEL_SUBPIXEL
294
308
  })
@@ -304,7 +318,7 @@ export function placeRowLabels(
304
318
  box = { left, right: left + width }
305
319
  if (!clears(box, false)) continue
306
320
  shown[i] = true
307
- kept.push({ box, tick: false })
321
+ kept.push({ box, tick: false, i })
308
322
  continue
309
323
  }
310
324
  const fits = (b: LabelBox) =>
@@ -313,19 +327,132 @@ export function placeRowLabels(
313
327
  (span === undefined ||
314
328
  (b.left >= span.left - LABEL_SUBPIXEL && b.right <= span.right + LABEL_SUBPIXEL)) &&
315
329
  clears(b, tick)
316
- const useShort = !fits(box) && label.short !== undefined && fits(label.short)
330
+ const useShort =
331
+ label.short !== undefined && (registerShort ? true : !fits(box)) && fits(label.short)
332
+ if (registerShort && label.short !== undefined && !useShort) continue
317
333
  if (useShort) box = label.short as LabelBox
318
334
  else if (!fits(box)) continue
319
335
  shown[i] = true
320
336
  short[i] = useShort
321
- kept.push({ box, tick })
337
+ kept.push({ box, tick, i })
322
338
  }
323
- // One register: once any name falls back to its `short`, every other shown name that has one
324
- // follows (the holding name, which never shortens, is the one exception). A shorter box only
325
- // clears more, so the placement above stays valid.
326
- if (short.some(Boolean)) {
327
- for (const [i, label] of labels.entries()) {
328
- if (shown[i] && !label.holding && label.short !== undefined) short[i] = true
339
+ // A name that did not fit inside its own span borrows room from the row: the zone names beside it
340
+ // slide inside THEIR spans, away from it, and it takes the gap, staying centred in its span. Full
341
+ // name first, then `short`; holding names and ticks never move.
342
+ for (const [i, label] of labels.entries()) {
343
+ if (label.span === undefined || label.holding || (shown[i] && !short[i])) continue
344
+ const { span } = label
345
+ const centre = (b: LabelBox) => (b.left + b.right) / 2
346
+ const others = kept.filter((k) => k.i !== i)
347
+ const movable = (k: (typeof kept)[number]) => !k.tick && !labels[k.i]?.holding
348
+ const fixed = others.filter((k) => !movable(k))
349
+ const slidable = others.filter(movable)
350
+ const base = registerShort && label.short ? label.short : label.box
351
+ const mid = centre(base)
352
+ // Only a name that sits in the row and clears every tick: a tick keeps its place over a name.
353
+ const touches = (a: LabelBox, b: LabelBox) =>
354
+ a.left < b.right + gap - LABEL_SUBPIXEL && b.left < a.right + gap - LABEL_SUBPIXEL
355
+ if (
356
+ base.left < -LABEL_SUBPIXEL ||
357
+ base.right > rowWidth + LABEL_SUBPIXEL ||
358
+ others.some((k) => k.tick && touches(base, k.box)) ||
359
+ fixed.some((f) => f.box.left < mid && f.box.right > mid)
360
+ )
361
+ continue
362
+ const rightOf = slidable
363
+ .filter((k) => centre(k.box) > mid)
364
+ .toSorted((a, b) => b.box.left - a.box.left)
365
+ const leftOf = slidable
366
+ .filter((k) => centre(k.box) < mid)
367
+ .toSorted((a, b) => a.box.left - b.box.left)
368
+ const place = (b: LabelBox, lo: number, hi: number): LabelBox => {
369
+ const left = Math.max(lo, Math.min(b.left, hi - (b.right - b.left)))
370
+ return { left, right: left + (b.right - b.left) }
371
+ }
372
+ // Slide only the sides the name needs: none, then the right, the left, both.
373
+ const attempt = (right: boolean, left: boolean) => {
374
+ const slides = new Map<number, number>()
375
+ let hi = rowWidth
376
+ for (const k of rightOf) {
377
+ const w = k.box.right - k.box.left
378
+ const stop = right
379
+ ? Math.min(
380
+ (labels[k.i]?.span?.right ?? rowWidth) + LABEL_SUBPIXEL,
381
+ hi,
382
+ ...fixed
383
+ .filter((f) => f.box.left >= k.box.left)
384
+ .map((f) => f.box.left - (f.tick ? gap : 0)),
385
+ )
386
+ : k.box.left + w
387
+ const at = Math.max(k.box.left, stop - w)
388
+ slides.set(k.i, at - k.box.left)
389
+ hi = at
390
+ }
391
+ let lo = 0
392
+ for (const k of leftOf) {
393
+ const w = k.box.right - k.box.left
394
+ const stop = left
395
+ ? Math.max(
396
+ (labels[k.i]?.span?.left ?? 0) - LABEL_SUBPIXEL,
397
+ lo,
398
+ ...fixed
399
+ .filter((f) => f.box.right <= k.box.right)
400
+ .map((f) => f.box.right + (f.tick ? gap : 0)),
401
+ )
402
+ : k.box.left
403
+ const at = Math.min(k.box.left, stop)
404
+ slides.set(k.i, at - k.box.left)
405
+ lo = at + w
406
+ }
407
+ // The gap this name may take: after the nearest left neighbour and fixed label, before the right.
408
+ const gapLo = Math.max(
409
+ lo,
410
+ ...fixed.filter((f) => f.box.right <= mid).map((f) => f.box.right + (f.tick ? gap : 0)),
411
+ 0,
412
+ )
413
+ const gapHi = Math.min(
414
+ hi,
415
+ ...fixed.filter((f) => f.box.left >= mid).map((f) => f.box.left - (f.tick ? gap : 0)),
416
+ rowWidth,
417
+ )
418
+ return { slides, gapLo, gapHi }
419
+ }
420
+ const tries = [
421
+ attempt(false, false),
422
+ attempt(true, false),
423
+ attempt(false, true),
424
+ attempt(true, true),
425
+ ]
426
+ const names =
427
+ registerShort && label.short
428
+ ? [label.short]
429
+ : shown[i]
430
+ ? [label.box]
431
+ : label.short
432
+ ? [label.box, label.short]
433
+ : [label.box]
434
+ for (const box of names) {
435
+ const w = box.right - box.left
436
+ const fit = tries.find(({ gapLo, gapHi }) => {
437
+ if (gapHi - gapLo + LABEL_SUBPIXEL < w) return false
438
+ const c = centre(place(box, gapLo, gapHi))
439
+ return c >= span.left && c <= span.right
440
+ })
441
+ if (fit === undefined) continue
442
+ const placed = place(box, fit.gapLo, fit.gapHi)
443
+ for (const k of kept) {
444
+ const by = fit.slides.get(k.i) ?? 0
445
+ if (by === 0) continue
446
+ k.box = { left: k.box.left + by, right: k.box.right + by }
447
+ shift[k.i] = (shift[k.i] ?? 0) + by
448
+ }
449
+ const own = kept.findIndex((k) => k.i === i)
450
+ if (own >= 0) kept.splice(own, 1)
451
+ kept.push({ box: placed, tick: false, i })
452
+ shift[i] = placed.left - box.left
453
+ shown[i] = true
454
+ short[i] = box !== label.box
455
+ break
329
456
  }
330
457
  }
331
458
  return { shown, short, shift }
@@ -361,6 +488,8 @@ export type BarModel = {
361
488
  parts: readonly Part[]
362
489
  /** Percent where the first forecast part starts; absent when the forecast opens the track. */
363
490
  boundaryPct: number | undefined
491
+ /** Where the forecast part ends (clamped to the track): the forecast caption ends here. */
492
+ forecastEndPct: number | undefined
364
493
  forecastText: string | null
365
494
  captionMode: CaptionMode
366
495
  /** Only in `parts` mode: one caption per part, in order. Empty otherwise. */
@@ -463,6 +592,12 @@ export function modelBar(input: BarInput): BarModel {
463
592
  span,
464
593
  parts,
465
594
  boundaryPct: firstForecast > 0 ? toPct(parts[firstForecast]?.start ?? 0) : undefined,
595
+ forecastEndPct:
596
+ firstForecast > 0
597
+ ? toPct(
598
+ parts.filter((p) => p.forecast).reduce((end, p) => Math.max(end, p.start + p.size), 0),
599
+ )
600
+ : undefined,
466
601
  forecastText:
467
602
  forecastLabels.length === 0
468
603
  ? null
@@ -139,39 +139,12 @@ function Line({ zoned, children }: { zoned: boolean; children?: ReactNode }) {
139
139
  )
140
140
  }
141
141
 
142
- /**
143
- * The loaded Meter's footprint at its loaded height: a zoned track keeps the figure row above and the
144
- * zone-name row below, a plain bar the caption row below, so the card does not jump when data lands.
145
- */
146
- export function MeterLoading({
147
- label,
148
- ring,
149
- zoned,
150
- shell,
151
- }: {
152
- label: string
153
- ring: boolean
154
- zoned: boolean
155
- shell: Shell
156
- }) {
142
+ /** The ring's loading state: one skeleton disc at the ring's size. A bar loads through `MeterBar`. */
143
+ export function MeterRingLoading({ label, shell }: { label: string; shell: Shell }) {
157
144
  return (
158
145
  <div {...rootProps(shell)} aria-busy="true">
159
146
  <VisuallyHidden className={classes.summary}>{`Loading ${label}`}</VisuallyHidden>
160
- {ring ? (
161
- <Skeleton className={classes.skeletonRing} circle />
162
- ) : (
163
- <>
164
- {zoned && (
165
- <Line zoned={zoned}>
166
- <Skeleton className={classes.skeletonCaption} radius="sm" />
167
- </Line>
168
- )}
169
- <Skeleton className={classes.skeletonTrack} />
170
- <Line zoned={zoned}>
171
- <Skeleton className={classes.skeletonCaption} radius="sm" />
172
- </Line>
173
- </>
174
- )}
147
+ <Skeleton className={classes.skeletonRing} circle />
175
148
  </div>
176
149
  )
177
150
  }
@@ -499,6 +472,8 @@ type CaptionItem = {
499
472
  align?: 'start' | 'center' | 'end'
500
473
  /** Drop rank when the row is too narrow (lowest first); none never drops. */
501
474
  drop?: number
475
+ /** Tried when the primary anchor drops the caption; the caption drops only if this fails too. */
476
+ alt?: { pct: number; align?: 'start' | 'center' | 'end' }
502
477
  }
503
478
 
504
479
  /** The measurement shared by the marks row and the part list: natural widths, row width, gap step. */
@@ -583,13 +558,23 @@ function CaptionRow({ items }: { items: readonly CaptionItem[] }) {
583
558
  ...(item.align !== undefined && { align: item.align }),
584
559
  ...(item.drop !== undefined && { drop: item.drop }),
585
560
  }))
586
- const next = placeCaptionRow(marks, rowWidth, gap)
561
+ let next = placeCaptionRow(marks, rowWidth, gap)
562
+ // A caption that dropped at its preferred anchor gets its fallback before it is given up.
563
+ items.forEach((item, i) => {
564
+ if (item.alt === undefined || !next?.dropped[i]) return
565
+ const retry = placeCaptionRow(
566
+ marks.map((m, j) => (j === i ? { ...m, ...item.alt } : m)),
567
+ rowWidth,
568
+ gap,
569
+ )
570
+ if (retry !== null && !retry.dropped[i]) next = retry
571
+ })
587
572
  setPlaced((prev) => (samePlacement(prev, next) ? prev : next))
588
573
  },
589
574
  items
590
575
  .map(
591
576
  (i) =>
592
- `${i.key}@${i.pct ?? i.edge ?? ''}${i.align ?? ''}${i.drop ?? ''}:${typeof i.node === 'string' ? i.node : ''}`,
577
+ `${i.key}@${i.pct ?? i.edge ?? ''}${i.align ?? ''}${i.drop ?? ''}${i.alt?.pct ?? ''}:${typeof i.node === 'string' ? i.node : ''}`,
593
578
  )
594
579
  .join('\u0000'),
595
580
  )
@@ -700,9 +685,12 @@ export function MeterBar(props: {
700
685
  startCaption: ReactNode
701
686
  endCaption: ReactNode
702
687
  readingAt: 'fill' | 'start' | undefined
688
+ /** The loaded structure with its text painted as skeleton: the footprint IS the loaded one. */
689
+ loading?: boolean
703
690
  shell: Shell
704
691
  }) {
705
692
  const { label, min, max, format, zones, shell } = props
693
+ const loading = props.loading === true
706
694
  const describedId = useId()
707
695
  const model = modelBar(props)
708
696
  const compact = shell.row
@@ -788,9 +776,20 @@ export function MeterBar(props: {
788
776
  key: 'forecast',
789
777
  node: glue(model.forecastText),
790
778
  drop: 2,
791
- // The reading ends at the boundary, the forecast begins there.
792
- ...(props.readingAt !== 'start' && start !== null && { align: 'start' as const }),
793
- ...(model.boundaryPct !== undefined && { pct: model.boundaryPct }),
779
+ // The reading ends at the boundary, the forecast ends where its fill does.
780
+ // If that collides, it falls back to starting at the boundary before it drops.
781
+ ...(props.readingAt !== 'start' && model.forecastEndPct !== undefined
782
+ ? {
783
+ pct: model.forecastEndPct,
784
+ align: 'end' as const,
785
+ ...(model.boundaryPct !== undefined && {
786
+ alt: {
787
+ pct: model.boundaryPct,
788
+ ...(start !== null && { align: 'start' as const }),
789
+ },
790
+ }),
791
+ }
792
+ : model.boundaryPct !== undefined && { pct: model.boundaryPct }),
794
793
  } satisfies CaptionItem,
795
794
  ]
796
795
  : []),
@@ -824,15 +823,32 @@ export function MeterBar(props: {
824
823
  ]
825
824
 
826
825
  const root = rootProps(shell)
826
+ // Loading is the loaded tree: every caption row stands where it will, its text is painted as
827
+ // skeleton (CSS) and hidden from assistive tech; the root announces the state once.
828
+ const quiet = (node: ReactNode) =>
829
+ loading ? (
830
+ <div className={classes.hold} aria-hidden>
831
+ {node}
832
+ </div>
833
+ ) : (
834
+ node
835
+ )
827
836
  return (
828
- <div {...root} className={root.className}>
837
+ <div
838
+ {...root}
839
+ className={root.className}
840
+ {...(loading && { 'aria-busy': 'true', 'data-meter-loading': '' })}
841
+ >
842
+ {loading && <VisuallyHidden className={classes.summary}>{`Loading ${label}`}</VisuallyHidden>}
829
843
  {aboveTicks.length > 0 && <LabelRow zones={[]} ticks={aboveTicks} />}
830
844
  <div
831
845
  className={cx(classes.trackBox, trackHidden && classes.trackHidden)}
832
846
  data-meter-track-hidden={trackHidden ? '' : undefined}
833
- aria-label={label}
834
- {...ariaValues(props.reading, min, max, format)}
835
- {...describedBy}
847
+ {...(!loading && {
848
+ 'aria-label': label,
849
+ ...ariaValues(props.reading, min, max, format),
850
+ ...describedBy,
851
+ })}
836
852
  >
837
853
  <div
838
854
  className={classes.track}
@@ -845,6 +861,7 @@ export function MeterBar(props: {
845
861
  >
846
862
  {zones?.map(
847
863
  (z, i) =>
864
+ !loading &&
848
865
  model.markerPct !== undefined && (
849
866
  <div
850
867
  key={i}
@@ -857,7 +874,7 @@ export function MeterBar(props: {
857
874
  />
858
875
  ),
859
876
  )}
860
- {model.parts.map((p, i) => (
877
+ {(loading ? [] : model.parts).map((p, i) => (
861
878
  <div
862
879
  key={i}
863
880
  className={cx(classes.fill, p.forecast && classes.forecastFill)}
@@ -870,22 +887,26 @@ export function MeterBar(props: {
870
887
  />
871
888
  ))}
872
889
  </div>
873
- <Tick kind="marker" className={classes.marker} pct={model.markerPct} />
874
- <Tick kind="boundary" className={classes.boundaryTick} pct={model.boundaryPct} />
875
- {model.ticks.map((t) => (
876
- <Tick key={t.key} kind="tick" className={classes.tick} pct={t.pct} />
877
- ))}
878
- <Tick kind="target" className={classes.tick} pct={model.targetPct} />
890
+ {!loading && (
891
+ <>
892
+ <Tick kind="marker" className={classes.marker} pct={model.markerPct} />
893
+ <Tick kind="boundary" className={classes.boundaryTick} pct={model.boundaryPct} />
894
+ {model.ticks.map((t) => (
895
+ <Tick key={t.key} kind="tick" className={classes.tick} pct={t.pct} />
896
+ ))}
897
+ <Tick kind="target" className={classes.tick} pct={model.targetPct} />
898
+ </>
899
+ )}
879
900
  </div>
880
901
  {zoneLabels.length > 0 && <LabelRow zones={zoneLabels} ticks={belowTicks} />}
881
- {anchored && <ZoneReading pct={model.markerPct ?? 0}>{start}</ZoneReading>}
882
- {model.describedByText !== null && (
902
+ {anchored && quiet(<ZoneReading pct={model.markerPct ?? 0}>{start}</ZoneReading>)}
903
+ {!loading && model.describedByText !== null && (
883
904
  <VisuallyHidden id={describedId} className={classes.summary}>
884
905
  {model.describedByText}
885
906
  </VisuallyHidden>
886
907
  )}
887
- {hasParts && <PartCaptions captions={model.partCaptions} />}
888
- {items.length > 0 && <CaptionRow items={items} />}
908
+ {hasParts && quiet(<PartCaptions captions={model.partCaptions} />)}
909
+ {items.length > 0 && quiet(<CaptionRow items={items} />)}
889
910
  </div>
890
911
  )
891
912
  }
@@ -312,8 +312,7 @@
312
312
  color: var(--vx-muted);
313
313
  }
314
314
 
315
- /* One caption-height line: a blank caption row (empty) or the home of a skeleton line (loading), so
316
- * both stand at the loaded Meter's height. */
315
+ /* One caption-height line: a blank caption row of an empty Meter, so it stands at the loaded height. */
317
316
  .line {
318
317
  display: flex;
319
318
  align-items: center;
@@ -325,14 +324,50 @@
325
324
  height: 1.25em;
326
325
  }
327
326
 
328
- /* The skeleton holds the loaded footprint: figure row (zoned), track, caption / zone-name row. */
329
- .skeletonTrack {
330
- height: 0.375rem;
327
+ /* Loading is the loaded tree (`MeterBar` with `loading`): every row stands where it will and the
328
+ * height is the loaded one. Text is painted as skeleton in place: transparent ink on a pulsing pill
329
+ * the width of the caption, the track a pulsing bar. A caption the layout dropped stays hidden. */
330
+ .hold {
331
+ display: contents;
332
+ }
333
+
334
+ [data-meter-loading] {
335
+ --basalt-meter-skeleton: color-mix(in srgb, var(--vx-muted) 28%, transparent);
336
+ }
337
+
338
+ [data-meter-loading]
339
+ :is(.rowLabel, .caption, .captionEnd, .captionTarget, .zoneReading, .partCaption) {
340
+ color: transparent;
341
+ background: var(--basalt-meter-skeleton);
342
+ border-radius: var(--vx-radius-fine);
343
+ animation: meterPulse 1500ms linear infinite;
344
+ }
345
+
346
+ [data-meter-loading] .swatch {
347
+ visibility: hidden;
331
348
  }
332
349
 
333
- .skeletonCaption {
334
- width: 40%;
335
- height: 0.75rem;
350
+ [data-meter-loading] .track {
351
+ background: var(--basalt-meter-skeleton);
352
+ animation: meterPulse 1500ms linear infinite;
353
+ }
354
+
355
+ @keyframes meterPulse {
356
+ 0%,
357
+ 100% {
358
+ opacity: 0.4;
359
+ }
360
+
361
+ 50% {
362
+ opacity: 1;
363
+ }
364
+ }
365
+
366
+ @media (prefers-reduced-motion: reduce) {
367
+ [data-meter-loading]
368
+ :is(.rowLabel, .caption, .captionEnd, .captionTarget, .zoneReading, .partCaption, .track) {
369
+ animation: none;
370
+ }
336
371
  }
337
372
 
338
373
  /* ── ring ────────────────────────────────────────────────────────────────────────────────────── */
@@ -406,10 +441,6 @@
406
441
  height: 1lh;
407
442
  }
408
443
 
409
- .row .skeletonTrack {
410
- height: 1lh;
411
- }
412
-
413
444
  .row .line {
414
445
  display: none;
415
446
  }
@@ -34,8 +34,7 @@ declare const classes: {
34
34
  readonly empty: string
35
35
  readonly line: string
36
36
  readonly lineZoned: string
37
- readonly skeletonTrack: string
38
- readonly skeletonCaption: string
37
+ readonly hold: string
39
38
  readonly ringBox: string
40
39
  readonly ring: string
41
40
  readonly ringTrack: string
@@ -57,7 +57,7 @@ import type { BasaltProps } from '../common/props'
57
57
  import { VX } from '../tokens'
58
58
  import { isReading, normalizeSegments, segmentReading, spanOf } from './meter-model'
59
59
  import type { MeterSegment, MeterTick, MeterZone } from './meter-model'
60
- import { MeterBar, MeterEmpty, MeterLoading, MeterRing } from './meter-parts'
60
+ import { MeterBar, MeterEmpty, MeterRing, MeterRingLoading } from './meter-parts'
61
61
  import { asText } from './scale'
62
62
  import { VisualSlotContext } from './visual-slot'
63
63
 
@@ -162,7 +162,7 @@ export type MeterProps =
162
162
  | (BarCommon & {
163
163
  /** Ordered parts, accumulated from `min`; their sum is the reading. `forecast` parts render lighter. */
164
164
  segments: readonly MeterSegment[]
165
- /** Names the forecast beside the boundary tick (default: `Forecast: <labels>`). */
165
+ /** Names the forecast, ending where its fill ends (default: `Forecast: <labels>`). */
166
166
  forecastCaption?: string
167
167
  value?: never
168
168
  color?: never
@@ -225,16 +225,28 @@ export function Meter(props: MeterProps) {
225
225
  const shell = { className, style, row }
226
226
  const ring = props.shape === 'ring'
227
227
  warnInvalidTrack(min, max)
228
- const hostTone = useContext(VisualSlotContext)?.tone
228
+ const host = useContext(VisualSlotContext)
229
+ const hostTone = host?.tone
229
230
  const hostColor = hostTone === undefined ? undefined : VX.status[hostTone]
230
231
 
231
- if (props.loading === true)
232
- return (
233
- <MeterLoading label={label} ring={ring} zoned={props.zones !== undefined} shell={shell} />
234
- )
232
+ const loading = props.loading === true || host?.loading === true
233
+ if (loading && ring) return <MeterRingLoading label={label} shell={shell} />
235
234
 
236
- const segments = props.segments === undefined ? undefined : normalizeSegments(props.segments)
237
- const reading = segments === undefined ? props.value : segmentReading(segments, min)
235
+ // A loading bar is the loaded bar on a placeholder reading (its captions painted as skeleton), so
236
+ // it has the loaded rows and height: zoned bars mid-track, plain bars at the start.
237
+ const segments =
238
+ props.segments === undefined || (loading && props.segments.length === 0)
239
+ ? undefined
240
+ : normalizeSegments(props.segments)
241
+ const placeholder =
242
+ props.zones !== undefined && props.zones.length > 0 ? min + spanOf(min, max).span / 2 : min
243
+ const reading = loading
244
+ ? segments === undefined
245
+ ? placeholder
246
+ : segmentReading(segments, min)
247
+ : segments === undefined
248
+ ? props.value
249
+ : segmentReading(segments, min)
238
250
  if (!isReading(reading) || segments?.length === 0) {
239
251
  return (
240
252
  <MeterEmpty
@@ -275,6 +287,7 @@ export function Meter(props: MeterProps) {
275
287
  startCaption={props.startCaption}
276
288
  endCaption={props.endCaption}
277
289
  readingAt={props.readingAt}
290
+ loading={loading}
278
291
  />
279
292
  )
280
293
  }
@@ -76,15 +76,16 @@
76
76
  }
77
77
 
78
78
  /*
79
- * A bare `<Text size="xs">` summary line (argo's strength diagnostics shell: title 15 + chart-card
80
- * title 13 + summary 12 + chart ticks and legend 11 = four sizes) joins the chart text step, so the
81
- * shell stays at three: 15, 13, 11. Mantine's `Text` writes `--text-fz` inline from its `size` prop,
82
- * so no inherited custom property can reach it: this rule sets `font-size` itself, and the inline
83
- * `--text-fz` is then unused. Only a direct `Text` child is capped; a `Group` of stats keeps
84
- * the sizes its own parts ask for.
79
+ * A `Text` summary line (argo's strength diagnostics shell: title 15 + chart-card title 13 + summary
80
+ * 12 + chart ticks and legend 11 = four sizes) joins the chart text step, so the shell stays at
81
+ * three: 15, 13, 11. The cap is the `--text-fz` variable Mantine's `Text` reads for its font size,
82
+ * pinned `!important` so it outranks the inline value a `size` prop writes; a `Text` sized by the
83
+ * consumer's own CLASS sets `font-size` directly, never reads the variable, and keeps that size
84
+ * (argo's reading backlog `.facts`, 13). Only a direct `Text` child is capped; a `Group` of stats
85
+ * keeps the sizes its own parts ask for.
85
86
  */
86
87
  .summary > :global(.mantine-Text-root) {
87
- font-size: var(--vx-text-micro);
88
+ --text-fz: var(--vx-text-micro) !important;
88
89
  }
89
90
 
90
91
  /*