basalt-ui 2.25.0 → 2.27.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.
- package/CHANGELOG.md +57 -0
- package/MIGRATING.md +227 -19
- package/configs/oxlint-basalt.json +1 -1
- package/configs/oxlint-plugin.js +3 -9
- package/configs/oxlint-plugin.test.ts +6 -0
- package/dist/charts/Bars.d.ts.map +1 -1
- package/dist/charts/Bars.js +37 -1
- package/dist/charts/ChartCard.d.ts +13 -5
- package/dist/charts/ChartCard.d.ts.map +1 -1
- package/dist/charts/ChartCard.js +12 -2
- package/dist/charts/Sparkline.d.ts.map +1 -1
- package/dist/charts/Sparkline.js +106 -10
- package/dist/charts/chart-box.module.css +123 -5
- package/dist/charts/chart-box.module.css.d.ts +3 -0
- package/dist/charts/chart-card.module.css +34 -0
- package/dist/charts/chart-card.module.css.d.ts +2 -0
- package/dist/charts/chart-legend.module.css +1 -16
- package/dist/charts/compile.d.ts +20 -0
- package/dist/charts/compile.d.ts.map +1 -1
- package/dist/charts/compile.js +99 -3
- package/dist/charts/legend.d.ts.map +1 -1
- package/dist/charts/legend.js +54 -71
- package/dist/charts/sparkline.module.css +13 -9
- package/dist/charts/state.d.ts +7 -0
- package/dist/charts/state.d.ts.map +1 -1
- package/dist/charts/state.js +17 -1
- package/dist/cli/shot/capture.d.ts +32 -3
- package/dist/cli/shot/capture.d.ts.map +1 -1
- package/dist/cli/shot/capture.js +17 -7
- package/dist/dashboard/meter-model.d.ts +19 -3
- package/dist/dashboard/meter-model.d.ts.map +1 -1
- package/dist/dashboard/meter-model.js +155 -13
- package/dist/dashboard/meter-parts.d.ts +4 -7
- package/dist/dashboard/meter-parts.d.ts.map +1 -1
- package/dist/dashboard/meter-parts.js +130 -90
- package/dist/dashboard/meter.d.ts +1 -1
- package/dist/dashboard/meter.d.ts.map +1 -1
- package/dist/dashboard/meter.js +10 -7
- package/dist/dashboard/meter.module.css +55 -13
- package/dist/dashboard/meter.module.css.d.ts +1 -2
- package/dist/dashboard/section.d.ts +1 -2
- package/dist/dashboard/section.d.ts.map +1 -1
- package/dist/dashboard/section.module.css +8 -7
- package/dist/dashboard/stat-card.module.css +17 -0
- package/dist/dashboard/stat-strip.d.ts +9 -1
- package/dist/dashboard/stat-strip.d.ts.map +1 -1
- package/dist/dashboard/stat-strip.js +121 -27
- package/dist/dashboard/stat-strip.module.css +51 -3
- package/dist/dashboard/stat-strip.module.css.d.ts +4 -0
- package/dist/dashboard/visual-slot.d.ts +4 -0
- package/dist/dashboard/visual-slot.d.ts.map +1 -1
- package/dist/dashboard/visual-slot.js +2 -0
- package/dist/dashboard/widget-header.module.css +9 -0
- package/llms.txt +3 -2
- package/package.json +1 -1
- package/src/charts/Bars.tsx +50 -2
- package/src/charts/ChartCard.tsx +32 -5
- package/src/charts/Sparkline.tsx +166 -13
- package/src/charts/chart-box.module.css +123 -5
- package/src/charts/chart-box.module.css.d.ts +3 -0
- package/src/charts/chart-card.module.css +34 -0
- package/src/charts/chart-card.module.css.d.ts +2 -0
- package/src/charts/chart-legend.module.css +1 -16
- package/src/charts/compile.ts +153 -3
- package/src/charts/legend.tsx +33 -49
- package/src/charts/sparkline.module.css +13 -9
- package/src/charts/state.tsx +43 -1
- package/src/cli/shot/capture.ts +25 -9
- package/src/dashboard/meter-model.ts +248 -22
- package/src/dashboard/meter-parts.tsx +124 -69
- package/src/dashboard/meter.module.css +55 -13
- package/src/dashboard/meter.module.css.d.ts +1 -2
- package/src/dashboard/meter.tsx +22 -9
- package/src/dashboard/section.module.css +8 -7
- package/src/dashboard/section.tsx +1 -2
- package/src/dashboard/stat-card.module.css +17 -0
- package/src/dashboard/stat-strip.module.css +51 -3
- package/src/dashboard/stat-strip.module.css.d.ts +4 -0
- package/src/dashboard/stat-strip.tsx +162 -33
- package/src/dashboard/visual-slot.ts +5 -0
- package/src/dashboard/widget-header.module.css +9 -0
|
@@ -66,11 +66,22 @@
|
|
|
66
66
|
* every cell of a row (one caption line; a reserved qualifier line in a narrow cell when any cell has
|
|
67
67
|
* a qualifier), so a row shares one caption top and one value baseline. Below the value each cell
|
|
68
68
|
* stacks its own parts and ends at its last one. */
|
|
69
|
-
|
|
69
|
+
/* The HEAD (caption line, qualifier, value row) is one block with its own height: a longer qualifier
|
|
70
|
+
* pushes only its own value down. A visual cell whose head is shorter than a sibling's visual offset
|
|
71
|
+
* grows its head's min-height (`alignVisuals`), so the drawn visuals of a row share one top. */
|
|
72
|
+
.head {
|
|
73
|
+
display: flex;
|
|
74
|
+
flex-direction: column;
|
|
75
|
+
min-width: 0;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.content > *,
|
|
79
|
+
.head > * {
|
|
70
80
|
min-width: 0;
|
|
71
81
|
}
|
|
72
82
|
|
|
73
|
-
.content > :not(.
|
|
83
|
+
.content > :not(.head),
|
|
84
|
+
.head > :not(.captionLine) {
|
|
74
85
|
margin-block-start: var(--vx-space-stack-sm);
|
|
75
86
|
}
|
|
76
87
|
|
|
@@ -223,6 +234,44 @@
|
|
|
223
234
|
min-width: 0;
|
|
224
235
|
}
|
|
225
236
|
|
|
237
|
+
/* Loading keeps the slot's or footer's own box (the consumer's visual or footer, laid out as loaded) and
|
|
238
|
+
* hides it under a skeleton, so the cell has its loaded height. A `Meter` inside draws its own loading
|
|
239
|
+
* rows and so stays visible; any other visual is covered by the one skeleton bar. */
|
|
240
|
+
.hold {
|
|
241
|
+
position: relative;
|
|
242
|
+
visibility: hidden;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.hold [data-basalt-meter],
|
|
246
|
+
.holdSkeleton {
|
|
247
|
+
visibility: visible;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.holdSkeleton {
|
|
251
|
+
position: absolute;
|
|
252
|
+
inset-block: 0.25rem;
|
|
253
|
+
inset-inline-start: 0;
|
|
254
|
+
width: 55%;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/* The hero's bar: the value row's first line, as the plain skeleton. */
|
|
258
|
+
.holdHero {
|
|
259
|
+
composes: holdSkeleton;
|
|
260
|
+
inset-block: 0 auto;
|
|
261
|
+
width: 45%;
|
|
262
|
+
height: calc(var(--vx-text-kpi) * 1.25);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
.visual.hold > .holdSkeleton {
|
|
266
|
+
inset-block-start: max(0px, calc(var(--basalt-spark-readout-h) - var(--vx-space-stack-sm)));
|
|
267
|
+
inset-block-end: 0;
|
|
268
|
+
width: 100%;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
.hold:has([data-basalt-meter]) > .holdSkeleton {
|
|
272
|
+
display: none;
|
|
273
|
+
}
|
|
274
|
+
|
|
226
275
|
/* A Sparkline's hover readout takes this line above its plot (`charts/sparkline.module.css`). The
|
|
227
276
|
* cell's own stack gap already sits above it; the slot reserves the rest, so the chip never covers
|
|
228
277
|
* the value. */
|
|
@@ -234,7 +283,6 @@
|
|
|
234
283
|
.visual:has([data-basalt-sparkline], [data-basalt-chart]) {
|
|
235
284
|
padding-top: max(0px, calc(var(--basalt-spark-readout-h) - var(--vx-space-stack-sm)));
|
|
236
285
|
}
|
|
237
|
-
|
|
238
286
|
/* The state copy keeps the cell's inset on every side: the article ends at its own last track, so the
|
|
239
287
|
* foot inset (carried by the row-high slot, further down) cannot reach it. */
|
|
240
288
|
.content[data-strip-has-state] {
|
|
@@ -10,6 +10,7 @@ declare const classes: {
|
|
|
10
10
|
readonly content: string
|
|
11
11
|
readonly action: string
|
|
12
12
|
readonly captionLine: string
|
|
13
|
+
readonly head: string
|
|
13
14
|
readonly captionMain: string
|
|
14
15
|
readonly lead: string
|
|
15
16
|
readonly caption: string
|
|
@@ -21,6 +22,9 @@ declare const classes: {
|
|
|
21
22
|
readonly skeletonValue: string
|
|
22
23
|
readonly skeletonRow: string
|
|
23
24
|
readonly visual: string
|
|
25
|
+
readonly hold: string
|
|
26
|
+
readonly holdSkeleton: string
|
|
27
|
+
readonly holdHero: string
|
|
24
28
|
readonly visualStack: string
|
|
25
29
|
readonly reason: string
|
|
26
30
|
readonly error: string
|
|
@@ -8,6 +8,9 @@
|
|
|
8
8
|
* `tone` inks the VALUE only, for a verdict; a null reading is `—`. A cell may carry BOTH: the hero
|
|
9
9
|
* (e.g. VO2max) with `rows` under it; omit `value` to render the rows alone.
|
|
10
10
|
*
|
|
11
|
+
* `loading` keeps the loaded shape: the value bar, the visual slot and the footer line at their loaded
|
|
12
|
+
* height (the visual and footer are laid out hidden under a skeleton).
|
|
13
|
+
*
|
|
11
14
|
* `state` replaces the readings (hero, visual, rows, footer) with the cell's empty or error body, at
|
|
12
15
|
* the cell's size. Empty: the reason, muted, in the value's place (`—` only when no reason is given). Error: the shared error
|
|
13
16
|
* anatomy compact — status dot, the words `Could not load`, the message, the shared Retry. The caption stays.
|
|
@@ -38,9 +41,10 @@
|
|
|
38
41
|
* weights are not supported. `stale` dims a cell while placeholder data shows.
|
|
39
42
|
*/
|
|
40
43
|
import { Card, Skeleton } from '@mantine/core'
|
|
41
|
-
import { useId } from 'react'
|
|
44
|
+
import { useId, useRef } from 'react'
|
|
42
45
|
import type { CSSProperties, ReactNode } from 'react'
|
|
43
46
|
import { toErrorMessage } from '../common/errors'
|
|
47
|
+
import { useIsomorphicLayoutEffect } from '../common/isomorphic-layout-effect'
|
|
44
48
|
import { cx } from '../common/props'
|
|
45
49
|
import type { BasaltProps, Tone } from '../common/props'
|
|
46
50
|
import { RetryButton } from '../common/retry-button'
|
|
@@ -48,7 +52,7 @@ import { StatusDot } from '../theme/status-dot'
|
|
|
48
52
|
import { VX } from '../tokens'
|
|
49
53
|
import { InfoGlyph } from './widget-header'
|
|
50
54
|
import classes from './stat-strip.module.css'
|
|
51
|
-
import { HOSTED, VisualSlotContext } from './visual-slot'
|
|
55
|
+
import { HOSTED, HOSTED_LOADING, VisualSlotContext } from './visual-slot'
|
|
52
56
|
|
|
53
57
|
/** The URL shot states an anchor can declare itself absent in (`data-shot-absent`). */
|
|
54
58
|
type StatStripShotState = 'empty' | 'loading' | 'error'
|
|
@@ -109,7 +113,12 @@ export type StatStripCell = {
|
|
|
109
113
|
rows?: readonly StatStripRow[]
|
|
110
114
|
/** Inks the value only — set it when the reading is a verdict. */
|
|
111
115
|
tone?: Tone
|
|
112
|
-
/**
|
|
116
|
+
/**
|
|
117
|
+
* Skeleton in place of the readings, in the loaded shape: the value bar, the `visual` slot and the
|
|
118
|
+
* `footer` line keep the height they have loaded. Pass the same `visual` and `footer` as at rest
|
|
119
|
+
* (empty data is fine): the slot is measured, never shown — a `Meter` in it draws its own loading
|
|
120
|
+
* rows, any other visual is covered by one skeleton.
|
|
121
|
+
*/
|
|
113
122
|
loading?: boolean
|
|
114
123
|
/** Dims the cell while placeholder data shows. */
|
|
115
124
|
stale?: boolean
|
|
@@ -126,6 +135,9 @@ export type StatStripFooterEntry = {
|
|
|
126
135
|
* every width, as a sibling AFTER the article (outside its `aria-labelledby` region). For a key that
|
|
127
136
|
* names no cell it takes the full width under the grid. */
|
|
128
137
|
under?: string
|
|
138
|
+
/** The shot states this entry is absent in; replaces the strip's `shotAbsent` (an entry production
|
|
139
|
+
* omits where the strip itself shows, e.g. a fact that needs data the empty state lacks). */
|
|
140
|
+
shotAbsent?: readonly StatStripShotState[]
|
|
129
141
|
}
|
|
130
142
|
|
|
131
143
|
export type StatStripProps = BasaltProps & {
|
|
@@ -189,7 +201,7 @@ function FooterCell({
|
|
|
189
201
|
className={under ? classes.underCell : classes.footerCell}
|
|
190
202
|
data-strip-footer-cell={entry.key}
|
|
191
203
|
data-shot={`strip-footer-${entry.key}`}
|
|
192
|
-
{...absentAttr(shotAbsent)}
|
|
204
|
+
{...absentAttr(entry.shotAbsent ?? shotAbsent)}
|
|
193
205
|
{...(under && { 'data-under': entry.under })}
|
|
194
206
|
>
|
|
195
207
|
{entry.content}
|
|
@@ -210,16 +222,41 @@ function StripCell({
|
|
|
210
222
|
const { rows, loading } = cell
|
|
211
223
|
const state = loading ? undefined : cell.state
|
|
212
224
|
const hasHero = cell.value !== undefined || rows === undefined
|
|
213
|
-
// The cell's verdict colours a plain Meter in its visual too (a hero host only).
|
|
214
|
-
|
|
225
|
+
// The cell's verdict colours a plain Meter in its visual too (a hero host only). While loading, a
|
|
226
|
+
// Meter in the slot draws its own loading state (the loaded rows, text painted as skeleton).
|
|
227
|
+
const hostSlot = !hasHero
|
|
228
|
+
? loading
|
|
229
|
+
? HOSTED_LOADING
|
|
230
|
+
: null
|
|
231
|
+
: cell.tone === undefined
|
|
232
|
+
? loading
|
|
233
|
+
? HOSTED_LOADING
|
|
234
|
+
: HOSTED
|
|
235
|
+
: { tone: cell.tone, ...(loading && { loading }) }
|
|
215
236
|
// A footer rides with what it captions: it follows the cell's last part, whatever a sibling holds.
|
|
237
|
+
// Loading keeps its box (so a wrapping footer keeps its lines) and lays a skeleton over it.
|
|
216
238
|
const footerEl = cell.footer !== undefined && (
|
|
217
|
-
<div
|
|
239
|
+
<div
|
|
240
|
+
className={cx(classes.footer, loading && classes.hold)}
|
|
241
|
+
data-strip-footer
|
|
242
|
+
{...(loading && { 'aria-hidden': true, inert: true })}
|
|
243
|
+
>
|
|
218
244
|
{cell.footer}
|
|
245
|
+
{loading && <Skeleton className={classes.holdSkeleton} radius="sm" />}
|
|
219
246
|
</div>
|
|
220
247
|
)
|
|
248
|
+
// A delta can wrap under the value in a narrow cell: with one, loading lays out the loaded value row
|
|
249
|
+
// (hidden) under the skeleton bar, so the cell has the lines the loaded one has.
|
|
221
250
|
const heroEl = loading ? (
|
|
222
|
-
|
|
251
|
+
cell.delta === undefined ? (
|
|
252
|
+
<Skeleton className={classes.skeletonValue} radius="sm" />
|
|
253
|
+
) : (
|
|
254
|
+
<div className={cx(classes.valueRow, classes.hold)} aria-hidden inert>
|
|
255
|
+
<span className={classes.value}>{cell.value ?? EMPTY}</span>
|
|
256
|
+
{cell.delta}
|
|
257
|
+
<Skeleton className={classes.holdHero} radius="sm" />
|
|
258
|
+
</div>
|
|
259
|
+
)
|
|
223
260
|
) : (
|
|
224
261
|
<div className={classes.valueRow}>
|
|
225
262
|
<span
|
|
@@ -249,35 +286,42 @@ function StripCell({
|
|
|
249
286
|
{...(state === undefined && rows !== undefined && { 'data-strip-has-rows': '' })}
|
|
250
287
|
{...(cell.stale && { 'data-stale': 'true' })}
|
|
251
288
|
>
|
|
252
|
-
<div className={classes.
|
|
253
|
-
<div className={classes.
|
|
254
|
-
{
|
|
255
|
-
|
|
256
|
-
<span
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
289
|
+
<div className={classes.head} data-strip-head>
|
|
290
|
+
<div className={classes.captionLine}>
|
|
291
|
+
<div className={classes.captionMain}>
|
|
292
|
+
{/* The caption and its info glyph are one unit: the qualifier wraps whole, never between them. */}
|
|
293
|
+
<span className={classes.lead}>
|
|
294
|
+
<span
|
|
295
|
+
className={classes.caption}
|
|
296
|
+
id={captionId}
|
|
297
|
+
title={cell.caption}
|
|
298
|
+
data-strip-caption
|
|
299
|
+
>
|
|
300
|
+
{cell.caption}
|
|
301
|
+
</span>
|
|
302
|
+
{cell.info !== undefined && <InfoGlyph text={cell.info} />}
|
|
303
|
+
</span>
|
|
304
|
+
{cell.qualifier !== undefined && (
|
|
305
|
+
<span className={classes.qualifier}>{cell.qualifier}</span>
|
|
306
|
+
)}
|
|
307
|
+
</div>
|
|
308
|
+
{cell.action !== undefined && (
|
|
309
|
+
<span className={classes.action} data-strip-action>
|
|
310
|
+
{cell.action}
|
|
263
311
|
</span>
|
|
264
|
-
{cell.info !== undefined && <InfoGlyph text={cell.info} />}
|
|
265
|
-
</span>
|
|
266
|
-
{cell.qualifier !== undefined && (
|
|
267
|
-
<span className={classes.qualifier}>{cell.qualifier}</span>
|
|
268
312
|
)}
|
|
269
313
|
</div>
|
|
270
|
-
{
|
|
271
|
-
|
|
272
|
-
{cell.action}
|
|
273
|
-
</span>
|
|
274
|
-
)}
|
|
314
|
+
{state !== undefined && <CellState state={state} />}
|
|
315
|
+
{state === undefined && hasHero && heroEl}
|
|
275
316
|
</div>
|
|
276
|
-
{state !== undefined && <CellState state={state} />}
|
|
277
|
-
{state === undefined && hasHero && heroEl}
|
|
278
317
|
{state === undefined && cell.visual !== undefined && (
|
|
279
|
-
<div
|
|
318
|
+
<div
|
|
319
|
+
className={cx(classes.visual, loading && classes.hold)}
|
|
320
|
+
data-strip-visual
|
|
321
|
+
{...(loading && { 'aria-hidden': true, inert: true })}
|
|
322
|
+
>
|
|
280
323
|
<VisualSlotContext.Provider value={hostSlot}>{cell.visual}</VisualSlotContext.Provider>
|
|
324
|
+
{loading && <Skeleton className={classes.holdSkeleton} radius="sm" />}
|
|
281
325
|
</div>
|
|
282
326
|
)}
|
|
283
327
|
{state === undefined &&
|
|
@@ -293,7 +337,11 @@ function StripCell({
|
|
|
293
337
|
{rows.map((row) => (
|
|
294
338
|
<li key={row.key} className={classes.row} data-strip-row={row.key}>
|
|
295
339
|
<span className={classes.rowLabel}>{row.label}</span>
|
|
296
|
-
<span className={classes.visual}>
|
|
340
|
+
<span className={classes.visual}>
|
|
341
|
+
<VisualSlotContext.Provider value={HOSTED}>
|
|
342
|
+
{row.visual}
|
|
343
|
+
</VisualSlotContext.Provider>
|
|
344
|
+
</span>
|
|
297
345
|
<span className={classes.rowValue}>
|
|
298
346
|
{row.hideValue ? null : (row.value ?? EMPTY)}
|
|
299
347
|
</span>
|
|
@@ -311,6 +359,46 @@ function StripCell({
|
|
|
311
359
|
)
|
|
312
360
|
}
|
|
313
361
|
|
|
362
|
+
/**
|
|
363
|
+
* One anatomy, a shared visual line: the cells of a row put the top of their drawn mark (Meter track, plot) on one line.
|
|
364
|
+
* Each cell's head (caption line, qualifier, value row) keeps its own height, so a longer qualifier
|
|
365
|
+
* pushes only its own value down; a visual cell whose head is shorter than a sibling's visual offset
|
|
366
|
+
* grows ITS head's min-height by the difference. Cells without a visual are untouched, so a footer
|
|
367
|
+
* still hugs its value and no sibling is stretched.
|
|
368
|
+
*/
|
|
369
|
+
const DRAWN_MARK = '[data-meter-track], [data-basalt-sparkline], [data-basalt-chart]'
|
|
370
|
+
|
|
371
|
+
function alignVisuals(root: HTMLElement): void {
|
|
372
|
+
const rows = new Map<number, { head: HTMLElement; natural: number; offset: number }[]>()
|
|
373
|
+
for (const head of root.querySelectorAll<HTMLElement>('[data-strip-head]')) {
|
|
374
|
+
const article = head.parentElement
|
|
375
|
+
const visual = article?.querySelector<HTMLElement>('[data-strip-visual]')
|
|
376
|
+
// The shared line is the top of the drawn MARK (Meter track, sparkline or chart plot): a Meter's
|
|
377
|
+
// caption or tick-label row above its track sits above that line.
|
|
378
|
+
const plot = visual?.querySelector(DRAWN_MARK) ?? visual?.firstElementChild
|
|
379
|
+
const last = head.lastElementChild
|
|
380
|
+
if (!article || !plot || !last) continue
|
|
381
|
+
const { top, bottom } = head.getBoundingClientRect()
|
|
382
|
+
const articleTop = article.getBoundingClientRect().top
|
|
383
|
+
// The head's own height (its content, bottom of the last part) without any min-height we set.
|
|
384
|
+
const natural = last.getBoundingClientRect().bottom - top
|
|
385
|
+
const grown = bottom - top - natural
|
|
386
|
+
const key = Math.round(articleTop)
|
|
387
|
+
rows.set(key, [
|
|
388
|
+
...(rows.get(key) ?? []),
|
|
389
|
+
{ head, natural, offset: plot.getBoundingClientRect().top - articleTop - Math.max(grown, 0) },
|
|
390
|
+
])
|
|
391
|
+
}
|
|
392
|
+
for (const cells of rows.values()) {
|
|
393
|
+
const target = cells.length < 2 ? 0 : Math.max(...cells.map((c) => c.offset))
|
|
394
|
+
for (const { head, natural, offset } of cells) {
|
|
395
|
+
const grow = target - offset
|
|
396
|
+
const next = grow > 0.5 ? `${natural + grow}px` : ''
|
|
397
|
+
if (head.style.minHeight !== next) head.style.minHeight = next
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
|
|
314
402
|
export function StatStrip({
|
|
315
403
|
label,
|
|
316
404
|
cells,
|
|
@@ -328,6 +416,47 @@ export function StatStrip({
|
|
|
328
416
|
const rest = footer?.filter((entry) => entry.under === undefined || !keys.has(entry.under)) ?? []
|
|
329
417
|
const hasQualifier = cells.some((cell) => cell.qualifier !== undefined)
|
|
330
418
|
const hasAction = cells.some((cell) => cell.action !== undefined)
|
|
419
|
+
const gridRef = useRef<HTMLDivElement>(null)
|
|
420
|
+
const observerRef = useRef<ResizeObserver | null>(null)
|
|
421
|
+
const watched = useRef('')
|
|
422
|
+
// Mount-only: one observer; a resize or a late font re-levels in the next frame (a write inside the
|
|
423
|
+
// callback would resize the observed grid in the same frame).
|
|
424
|
+
useIsomorphicLayoutEffect(() => {
|
|
425
|
+
const grid = gridRef.current
|
|
426
|
+
if (!grid || typeof ResizeObserver === 'undefined') return
|
|
427
|
+
let frame = 0
|
|
428
|
+
let live = true
|
|
429
|
+
const schedule = () => {
|
|
430
|
+
cancelAnimationFrame(frame)
|
|
431
|
+
frame = requestAnimationFrame(() => alignVisuals(grid))
|
|
432
|
+
}
|
|
433
|
+
const observer = new ResizeObserver(schedule)
|
|
434
|
+
observerRef.current = observer
|
|
435
|
+
void document.fonts?.ready?.then(() => {
|
|
436
|
+
if (live) schedule()
|
|
437
|
+
})
|
|
438
|
+
return () => {
|
|
439
|
+
live = false
|
|
440
|
+
cancelAnimationFrame(frame)
|
|
441
|
+
observer.disconnect()
|
|
442
|
+
observerRef.current = null
|
|
443
|
+
watched.current = ''
|
|
444
|
+
}
|
|
445
|
+
}, [])
|
|
446
|
+
// Re-level when the cells change, and watch the heads that now exist: a head that rewraps without
|
|
447
|
+
// changing the grid's height re-levels too.
|
|
448
|
+
useIsomorphicLayoutEffect(() => {
|
|
449
|
+
const grid = gridRef.current
|
|
450
|
+
if (!grid) return
|
|
451
|
+
alignVisuals(grid)
|
|
452
|
+
const observer = observerRef.current
|
|
453
|
+
const key = cells.map((cell) => cell.key).join('|')
|
|
454
|
+
if (!observer || watched.current === key) return
|
|
455
|
+
watched.current = key
|
|
456
|
+
observer.disconnect()
|
|
457
|
+
observer.observe(grid)
|
|
458
|
+
for (const head of grid.querySelectorAll('[data-strip-head]')) observer.observe(head)
|
|
459
|
+
}, [cells, footer])
|
|
331
460
|
return (
|
|
332
461
|
<div className={cx(classes.container, className)} style={style}>
|
|
333
462
|
<Card>
|
|
@@ -344,7 +473,7 @@ export function StatStrip({
|
|
|
344
473
|
} as CSSProperties
|
|
345
474
|
}
|
|
346
475
|
>
|
|
347
|
-
<div className={classes.cells}>
|
|
476
|
+
<div ref={gridRef} className={classes.cells}>
|
|
348
477
|
{cells.map((cell) => (
|
|
349
478
|
<StripCell
|
|
350
479
|
key={cell.key}
|
|
@@ -9,9 +9,14 @@ import type { Tone } from '../common/props'
|
|
|
9
9
|
|
|
10
10
|
export interface VisualSlot {
|
|
11
11
|
readonly tone?: Tone
|
|
12
|
+
/** The host is loading: a `Meter` in the slot draws its loading state without its own `loading`. */
|
|
13
|
+
readonly loading?: boolean
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
/** A host with no verdict of its own: one shared object, so a provider never re-renders its readers. */
|
|
15
17
|
export const HOSTED: VisualSlot = {}
|
|
16
18
|
|
|
19
|
+
/** `HOSTED` while the host loads. */
|
|
20
|
+
export const HOSTED_LOADING: VisualSlot = { loading: true }
|
|
21
|
+
|
|
17
22
|
export const VisualSlotContext = createContext<VisualSlot | null>(null)
|
|
@@ -221,6 +221,15 @@
|
|
|
221
221
|
min-width: 0;
|
|
222
222
|
}
|
|
223
223
|
|
|
224
|
+
/* A `widget` tier (ChartCard) caption in `actions` — `<Text size="xs">`, 12 — joins the chart text
|
|
225
|
+
* step beside the plot's ticks and legend (argo's strength cards: title 13 + caption 12 + ticks 11
|
|
226
|
+
* + section title 15 was four sizes). The cap is the `--text-fz` variable `Text` reads, pinned
|
|
227
|
+
* `!important` over the inline value its `size` prop writes; other sizes (`md` figures, `sm`) are
|
|
228
|
+
* not touched, and a `Text` sized by a consumer class never reads the variable. */
|
|
229
|
+
.root[data-tier='widget'] .actions :global(.mantine-Text-root[style*='--mantine-font-size-xs']) {
|
|
230
|
+
--text-fz: var(--vx-text-micro) !important;
|
|
231
|
+
}
|
|
232
|
+
|
|
224
233
|
/* Directly under the title row, 4px off it — 1px put it inside the title's own line box, so a
|
|
225
234
|
* section with both read as a two-line heading rather than a heading plus a note. */
|
|
226
235
|
.subtitle {
|