basalt-ui 2.23.0 → 2.25.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 +63 -0
- package/MIGRATING.md +264 -12
- package/agent/agents/basalt-design-reviewer.md +2 -2
- package/agent/skills/basalt-design/SKILL.md +1 -1
- package/agent/skills/basalt-design/references/catalogue.md +22 -19
- package/agent/skills/basalt-design/references/states.md +39 -0
- package/dist/charts/Bars.d.ts.map +1 -1
- package/dist/charts/Bars.js +21 -3
- package/dist/charts/CartesianChart.d.ts +2 -0
- package/dist/charts/CartesianChart.d.ts.map +1 -1
- package/dist/charts/CartesianChart.js +7 -3
- package/dist/charts/ChartCard.d.ts +6 -2
- package/dist/charts/ChartCard.d.ts.map +1 -1
- package/dist/charts/ChartCard.js +1 -1
- package/dist/charts/Sparkline.d.ts.map +1 -1
- package/dist/charts/Sparkline.js +32 -6
- package/dist/charts/StackedArea.d.ts.map +1 -1
- package/dist/charts/StackedArea.js +5 -1
- package/dist/charts/chart-legend.module.css +16 -0
- package/dist/charts/compile.d.ts +4 -0
- package/dist/charts/compile.d.ts.map +1 -1
- package/dist/charts/compile.js +65 -3
- package/dist/charts/legend.d.ts +0 -6
- package/dist/charts/legend.d.ts.map +1 -1
- package/dist/charts/legend.js +87 -35
- package/dist/charts/sparkline.module.css +59 -6
- package/dist/charts/sparkline.module.css.d.ts +1 -0
- package/dist/charts/state.d.ts +3 -1
- package/dist/charts/state.d.ts.map +1 -1
- package/dist/charts/state.js +10 -2
- package/dist/charts/types.d.ts +11 -0
- package/dist/charts/types.d.ts.map +1 -1
- package/dist/cli/shot/detect.d.ts.map +1 -1
- package/dist/cli/shot/detect.js +25 -36
- package/dist/cli/shot/measure.js +19 -23
- package/dist/dashboard/bar-list.d.ts.map +1 -1
- package/dist/dashboard/bar-list.js +16 -2
- package/dist/dashboard/bar-list.module.css +10 -17
- package/dist/dashboard/bar-list.module.css.d.ts +1 -0
- package/dist/dashboard/empty-state.d.ts.map +1 -1
- package/dist/dashboard/meter-model.d.ts +30 -1
- package/dist/dashboard/meter-model.d.ts.map +1 -1
- package/dist/dashboard/meter-model.js +74 -5
- package/dist/dashboard/meter-parts.d.ts +8 -1
- package/dist/dashboard/meter-parts.d.ts.map +1 -1
- package/dist/dashboard/meter-parts.js +64 -21
- package/dist/dashboard/meter.d.ts +8 -1
- package/dist/dashboard/meter.d.ts.map +1 -1
- package/dist/dashboard/meter.js +14 -3
- package/dist/dashboard/meter.module.css +42 -2
- package/dist/dashboard/meter.module.css.d.ts +4 -0
- package/dist/dashboard/query-state.d.ts +7 -3
- package/dist/dashboard/query-state.d.ts.map +1 -1
- package/dist/dashboard/query-state.js +14 -6
- package/dist/dashboard/section.d.ts +2 -1
- package/dist/dashboard/section.d.ts.map +1 -1
- package/dist/dashboard/section.module.css +12 -0
- package/dist/dashboard/settings-section.d.ts +1 -1
- package/dist/dashboard/settings-section.d.ts.map +1 -1
- package/dist/dashboard/settings-section.js +3 -3
- package/dist/dashboard/stat-card.module.css +24 -10
- package/dist/dashboard/stat-group.module.css +8 -0
- package/dist/dashboard/stat-strip.d.ts +3 -2
- package/dist/dashboard/stat-strip.d.ts.map +1 -1
- package/dist/dashboard/stat-strip.js +83 -73
- package/dist/dashboard/stat-strip.module.css +24 -39
- package/dist/dashboard/stat-strip.module.css.d.ts +1 -0
- package/dist/dashboard/widget-header.d.ts.map +1 -1
- package/dist/dashboard/widget-header.js +19 -1
- package/dist/dashboard/widget-header.module.css +6 -0
- package/dist/guard/index.d.ts +2 -2
- package/dist/guard/index.d.ts.map +1 -1
- package/dist/guard/index.js +1 -12
- package/dist/table/data-table.js +1 -1
- package/dist/theme/controls.module.css +7 -2
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +7 -5
- package/dist/tokens/palette.d.ts +2 -2
- package/dist/tokens/palette.d.ts.map +1 -1
- package/dist/tokens/palette.js +2 -2
- package/llms.txt +4 -3
- package/package.json +1 -1
- package/src/charts/Bars.tsx +36 -4
- package/src/charts/CartesianChart.tsx +9 -3
- package/src/charts/ChartCard.tsx +7 -3
- package/src/charts/Sparkline.tsx +66 -21
- package/src/charts/StackedArea.tsx +12 -1
- package/src/charts/chart-legend.module.css +16 -0
- package/src/charts/compile.ts +104 -2
- package/src/charts/legend.tsx +70 -3
- package/src/charts/sparkline.module.css +59 -6
- package/src/charts/sparkline.module.css.d.ts +1 -0
- package/src/charts/state.tsx +16 -7
- package/src/charts/types.ts +9 -0
- package/src/cli/shot/detect.ts +26 -40
- package/src/cli/shot/measure.ts +27 -27
- package/src/dashboard/bar-list.module.css +10 -17
- package/src/dashboard/bar-list.module.css.d.ts +1 -0
- package/src/dashboard/bar-list.tsx +14 -2
- package/src/dashboard/empty-state.tsx +4 -2
- package/src/dashboard/meter-model.ts +124 -7
- package/src/dashboard/meter-parts.tsx +127 -31
- package/src/dashboard/meter.module.css +42 -2
- package/src/dashboard/meter.module.css.d.ts +4 -0
- package/src/dashboard/meter.tsx +22 -3
- package/src/dashboard/query-state.tsx +19 -8
- package/src/dashboard/section.module.css +12 -0
- package/src/dashboard/section.tsx +2 -1
- package/src/dashboard/settings-section.tsx +4 -4
- package/src/dashboard/stat-card.module.css +24 -10
- package/src/dashboard/stat-group.module.css +8 -0
- package/src/dashboard/stat-strip.module.css +24 -39
- package/src/dashboard/stat-strip.module.css.d.ts +1 -0
- package/src/dashboard/stat-strip.tsx +63 -43
- package/src/dashboard/widget-header.module.css +6 -0
- package/src/dashboard/widget-header.tsx +28 -1
- package/src/guard/index.ts +3 -14
- package/src/table/data-table.tsx +1 -1
- package/src/theme/__snapshots__/plain-theme.test.ts.snap +6 -6
- package/src/theme/controls.module.css +7 -2
- package/src/theme/index.ts +7 -5
- package/src/tokens/palette.ts +2 -2
|
@@ -7,8 +7,9 @@ import { cx } from '../common/props'
|
|
|
7
7
|
import {
|
|
8
8
|
ariaValues,
|
|
9
9
|
modelBar,
|
|
10
|
+
partColumns,
|
|
10
11
|
partsFitUnder,
|
|
11
|
-
|
|
12
|
+
placeCaptionRow,
|
|
12
13
|
placeRowLabels,
|
|
13
14
|
ringFraction,
|
|
14
15
|
ringMarks,
|
|
@@ -126,13 +127,31 @@ const glueUnits = (text: ReactNode): ReactNode =>
|
|
|
126
127
|
const glue = (text: ReactNode): ReactNode =>
|
|
127
128
|
typeof text === 'string' ? String(glueUnits(text)).replace(SHORT_LAST_WORD, '$1\u00a0$2') : text
|
|
128
129
|
|
|
130
|
+
/**
|
|
131
|
+
* One caption-height line, so a placeholder row stands where the loaded Meter's caption, figure or
|
|
132
|
+
* zone-name row will (a zoned track's rows are `1.25em`, as its label rows). Not announced; the root carries the state.
|
|
133
|
+
*/
|
|
134
|
+
function Line({ zoned, children }: { zoned: boolean; children?: ReactNode }) {
|
|
135
|
+
return (
|
|
136
|
+
<div className={cx(classes.line, zoned && classes.lineZoned)} data-meter-line aria-hidden>
|
|
137
|
+
{children}
|
|
138
|
+
</div>
|
|
139
|
+
)
|
|
140
|
+
}
|
|
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
|
+
*/
|
|
129
146
|
export function MeterLoading({
|
|
130
147
|
label,
|
|
131
148
|
ring,
|
|
149
|
+
zoned,
|
|
132
150
|
shell,
|
|
133
151
|
}: {
|
|
134
152
|
label: string
|
|
135
153
|
ring: boolean
|
|
154
|
+
zoned: boolean
|
|
136
155
|
shell: Shell
|
|
137
156
|
}) {
|
|
138
157
|
return (
|
|
@@ -142,8 +161,15 @@ export function MeterLoading({
|
|
|
142
161
|
<Skeleton className={classes.skeletonRing} circle />
|
|
143
162
|
) : (
|
|
144
163
|
<>
|
|
164
|
+
{zoned && (
|
|
165
|
+
<Line zoned={zoned}>
|
|
166
|
+
<Skeleton className={classes.skeletonCaption} radius="sm" />
|
|
167
|
+
</Line>
|
|
168
|
+
)}
|
|
145
169
|
<Skeleton className={classes.skeletonTrack} />
|
|
146
|
-
<
|
|
170
|
+
<Line zoned={zoned}>
|
|
171
|
+
<Skeleton className={classes.skeletonCaption} radius="sm" />
|
|
172
|
+
</Line>
|
|
147
173
|
</>
|
|
148
174
|
)}
|
|
149
175
|
</div>
|
|
@@ -156,11 +182,13 @@ export function MeterEmpty(props: {
|
|
|
156
182
|
label: string
|
|
157
183
|
text: string | undefined
|
|
158
184
|
ring: boolean
|
|
185
|
+
zoned: boolean
|
|
159
186
|
shell: Shell
|
|
160
187
|
}) {
|
|
161
|
-
const { label, text, ring, shell } = props
|
|
162
|
-
// The ring has a reading slot (its centre), so the dash sits there as the reading
|
|
163
|
-
//
|
|
188
|
+
const { label, text, ring, zoned, shell } = props
|
|
189
|
+
// The ring has a reading slot (its centre), so the dash sits there as the reading. A bar states its
|
|
190
|
+
// gap once, and only if the host says so (`text`): otherwise the caption rows a loaded Meter would
|
|
191
|
+
// have stay blank, so the muted track keeps the loaded height without a dash under it.
|
|
164
192
|
return (
|
|
165
193
|
<output {...rootProps(shell)} aria-label={label}>
|
|
166
194
|
{ring ? (
|
|
@@ -169,12 +197,22 @@ export function MeterEmpty(props: {
|
|
|
169
197
|
<span className={classes.ringValue}>{EMPTY_READING}</span>
|
|
170
198
|
</span>
|
|
171
199
|
) : (
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
200
|
+
<>
|
|
201
|
+
{zoned && !shell.row && <Line zoned />}
|
|
202
|
+
<div className={classes.trackBox}>
|
|
203
|
+
<div className={classes.track} data-meter-track />
|
|
204
|
+
</div>
|
|
205
|
+
</>
|
|
175
206
|
)}
|
|
176
|
-
{
|
|
177
|
-
<span className={classes.empty}>{text
|
|
207
|
+
{text !== undefined ? (
|
|
208
|
+
<span className={classes.empty}>{text}</span>
|
|
209
|
+
) : (
|
|
210
|
+
!ring && (
|
|
211
|
+
<>
|
|
212
|
+
<VisuallyHidden className={classes.summary}>No reading</VisuallyHidden>
|
|
213
|
+
{!shell.row && <Line zoned={zoned} />}
|
|
214
|
+
</>
|
|
215
|
+
)
|
|
178
216
|
)}
|
|
179
217
|
</output>
|
|
180
218
|
)
|
|
@@ -450,19 +488,33 @@ function LabelRow({ zones, ticks }: { zones: readonly ZoneLabel[]; ticks: readon
|
|
|
450
488
|
}
|
|
451
489
|
|
|
452
490
|
/** One caption of the marks row, in flow order: its anchor (`pct`, or the row's `edge`) when it has one. */
|
|
453
|
-
type CaptionItem = {
|
|
491
|
+
type CaptionItem = {
|
|
492
|
+
key: string
|
|
493
|
+
node: ReactNode
|
|
494
|
+
pct?: number
|
|
495
|
+
edge?: 'end'
|
|
496
|
+
end?: boolean
|
|
497
|
+
/** The default target figure: one line, never wrapped. */
|
|
498
|
+
target?: boolean
|
|
499
|
+
align?: 'start' | 'center' | 'end'
|
|
500
|
+
/** Drop rank when the row is too narrow (lowest first); none never drops. */
|
|
501
|
+
drop?: number
|
|
502
|
+
}
|
|
454
503
|
|
|
455
504
|
/** The measurement shared by the marks row and the part list: natural widths, row width, gap step. */
|
|
456
505
|
function measureItems(row: HTMLElement) {
|
|
457
506
|
const kids = [...row.children] as HTMLElement[]
|
|
458
507
|
const widths = kids.map((kid) => {
|
|
459
508
|
// In the flow a caption may shrink and wrap inside itself; its anchored width is its one-line one.
|
|
460
|
-
const { whiteSpace, flex } = kid.style
|
|
509
|
+
const { whiteSpace, flex, width: inline } = kid.style
|
|
461
510
|
kid.style.whiteSpace = 'nowrap'
|
|
462
511
|
kid.style.flex = 'none'
|
|
512
|
+
// A grid cell would clamp the box to its column; the natural width is what is measured.
|
|
513
|
+
kid.style.width = 'max-content'
|
|
463
514
|
const width = kid.offsetWidth
|
|
464
515
|
kid.style.whiteSpace = whiteSpace
|
|
465
516
|
kid.style.flex = flex
|
|
517
|
+
kid.style.width = inline
|
|
466
518
|
return width
|
|
467
519
|
})
|
|
468
520
|
return { widths, rowWidth: row.clientWidth, gap: columnGapOf(row) }
|
|
@@ -502,17 +554,24 @@ function useMeasured(
|
|
|
502
554
|
}, [rowRef, key])
|
|
503
555
|
}
|
|
504
556
|
|
|
505
|
-
|
|
506
|
-
|
|
557
|
+
type CaptionPlacement = { starts: (number | undefined)[]; dropped: boolean[] }
|
|
558
|
+
const samePlacement = (a: CaptionPlacement | null, b: CaptionPlacement | null) =>
|
|
559
|
+
a === b ||
|
|
560
|
+
(a !== null &&
|
|
561
|
+
b !== null &&
|
|
562
|
+
a.starts.length === b.starts.length &&
|
|
563
|
+
a.starts.every((v, i) => v === b.starts[i] && a.dropped[i] === b.dropped[i]))
|
|
507
564
|
|
|
508
565
|
/**
|
|
509
566
|
* The captions under the track. A caption that names a mark (the forecast boundary, the target) sits
|
|
510
|
-
* AT that mark, centred and clamped inside the track
|
|
511
|
-
*
|
|
567
|
+
* AT that mark, centred and clamped inside the track (the reading ends at its fill end), when every
|
|
568
|
+
* caption fits with a gap step between them. A row that is too narrow drops its droppable captions
|
|
569
|
+
* (`drop` rank, lowest first) before anything wraps; they stay in the described-by text. Only when
|
|
570
|
+
* even the rest do not fit (and in server markup) the row flows and wraps: start, forecast, end.
|
|
512
571
|
*/
|
|
513
572
|
function CaptionRow({ items }: { items: readonly CaptionItem[] }) {
|
|
514
573
|
const rowRef = useRef<HTMLDivElement>(null)
|
|
515
|
-
const [
|
|
574
|
+
const [placed, setPlaced] = useState<CaptionPlacement | null>(null)
|
|
516
575
|
useMeasured(
|
|
517
576
|
rowRef,
|
|
518
577
|
(row) => {
|
|
@@ -521,26 +580,36 @@ function CaptionRow({ items }: { items: readonly CaptionItem[] }) {
|
|
|
521
580
|
width: widths[i] ?? 0,
|
|
522
581
|
...(item.pct !== undefined && { pct: item.pct }),
|
|
523
582
|
...(item.edge !== undefined && { edge: item.edge }),
|
|
583
|
+
...(item.align !== undefined && { align: item.align }),
|
|
584
|
+
...(item.drop !== undefined && { drop: item.drop }),
|
|
524
585
|
}))
|
|
525
|
-
const next =
|
|
526
|
-
|
|
586
|
+
const next = placeCaptionRow(marks, rowWidth, gap)
|
|
587
|
+
setPlaced((prev) => (samePlacement(prev, next) ? prev : next))
|
|
527
588
|
},
|
|
528
589
|
items
|
|
529
|
-
.map(
|
|
590
|
+
.map(
|
|
591
|
+
(i) =>
|
|
592
|
+
`${i.key}@${i.pct ?? i.edge ?? ''}${i.align ?? ''}${i.drop ?? ''}:${typeof i.node === 'string' ? i.node : ''}`,
|
|
593
|
+
)
|
|
530
594
|
.join('\u0000'),
|
|
531
595
|
)
|
|
532
596
|
return (
|
|
533
597
|
<div
|
|
534
598
|
ref={rowRef}
|
|
535
|
-
className={cx(classes.captions,
|
|
599
|
+
className={cx(classes.captions, placed !== null && classes.captionsAnchored)}
|
|
536
600
|
data-meter-captions
|
|
537
|
-
data-anchored={
|
|
601
|
+
data-anchored={placed === null ? undefined : ''}
|
|
538
602
|
>
|
|
539
603
|
{items.map((item, i) => (
|
|
540
604
|
<span
|
|
541
605
|
key={item.key}
|
|
542
|
-
className={
|
|
543
|
-
|
|
606
|
+
className={
|
|
607
|
+
item.target ? classes.captionTarget : item.end ? classes.captionEnd : classes.caption
|
|
608
|
+
}
|
|
609
|
+
data-hidden={placed?.dropped[i] ? '' : undefined}
|
|
610
|
+
{...(placed?.starts[i] !== undefined && {
|
|
611
|
+
style: { insetInlineStart: `${placed.starts[i]}px` },
|
|
612
|
+
})}
|
|
544
613
|
>
|
|
545
614
|
{item.node}
|
|
546
615
|
</span>
|
|
@@ -551,13 +620,15 @@ function CaptionRow({ items }: { items: readonly CaptionItem[] }) {
|
|
|
551
620
|
|
|
552
621
|
/**
|
|
553
622
|
* Categorical part captions (swatch, name, value): each under its own segment when every one fits
|
|
554
|
-
* there on one line, else a
|
|
555
|
-
*
|
|
623
|
+
* there on one line, else a grid from the track's start: one row when every entry fits it, else
|
|
624
|
+
* the most columns that fit with no lone entry on the last row. An entry stays on one line unless
|
|
625
|
+
* it is wider than the row itself.
|
|
556
626
|
*/
|
|
557
627
|
function PartCaptions({ captions }: { captions: readonly PartCaption[] }) {
|
|
558
628
|
const rowRef = useRef<HTMLUListElement>(null)
|
|
559
629
|
const [under, setUnder] = useState(false)
|
|
560
630
|
const [overwide, setOverwide] = useState(false)
|
|
631
|
+
const [cols, setCols] = useState(0)
|
|
561
632
|
useMeasured(
|
|
562
633
|
rowRef,
|
|
563
634
|
(row) => {
|
|
@@ -569,6 +640,7 @@ function PartCaptions({ captions }: { captions: readonly PartCaption[] }) {
|
|
|
569
640
|
gap,
|
|
570
641
|
)
|
|
571
642
|
setUnder(fits)
|
|
643
|
+
setCols(fits ? 0 : partColumns(widths, rowWidth, gap))
|
|
572
644
|
},
|
|
573
645
|
captions.map((c) => `${c.label} ${c.text}@${c.startPct}`).join('\u0000'),
|
|
574
646
|
)
|
|
@@ -579,7 +651,11 @@ function PartCaptions({ captions }: { captions: readonly PartCaption[] }) {
|
|
|
579
651
|
classes.partCaptions,
|
|
580
652
|
under && classes.partCaptionsUnder,
|
|
581
653
|
overwide && classes.partCaptionsWrap,
|
|
654
|
+
cols > 0 && classes.partCaptionsGrid,
|
|
582
655
|
)}
|
|
656
|
+
style={
|
|
657
|
+
cols > 0 ? { gridTemplateColumns: `repeat(${cols}, minmax(0, max-content))` } : undefined
|
|
658
|
+
}
|
|
583
659
|
// The explicit role is deliberate: `list-style: none` makes Safari/VoiceOver drop the implicit one.
|
|
584
660
|
// oxlint-disable-next-line jsx-a11y/no-redundant-roles
|
|
585
661
|
role="list"
|
|
@@ -623,6 +699,7 @@ export function MeterBar(props: {
|
|
|
623
699
|
forecastCaption: string | undefined
|
|
624
700
|
startCaption: ReactNode
|
|
625
701
|
endCaption: ReactNode
|
|
702
|
+
readingAt: 'fill' | 'start' | undefined
|
|
626
703
|
shell: Shell
|
|
627
704
|
}) {
|
|
628
705
|
const { label, min, max, format, zones, shell } = props
|
|
@@ -675,6 +752,11 @@ export function MeterBar(props: {
|
|
|
675
752
|
...labelled,
|
|
676
753
|
]
|
|
677
754
|
const zoneLabels = compact ? [] : model.zoneLabels
|
|
755
|
+
// On a zoned track the zone names own the row below; the figures at its two ends sit above the
|
|
756
|
+
// track, where nothing else competes for them. Every other tick label stays with the names.
|
|
757
|
+
const isEnd = (t: TickMark) => t.pct <= 0 || t.pct >= 100
|
|
758
|
+
const aboveTicks = zoneLabels.length > 0 ? tickLabels.filter(isEnd) : tickLabels
|
|
759
|
+
const belowTicks = zoneLabels.length > 0 ? tickLabels.filter((t) => !isEnd(t)) : []
|
|
678
760
|
const describedBy =
|
|
679
761
|
model.describedByText === null ? {} : ({ 'aria-describedby': describedId } as const)
|
|
680
762
|
|
|
@@ -687,13 +769,27 @@ export function MeterBar(props: {
|
|
|
687
769
|
? []
|
|
688
770
|
: [
|
|
689
771
|
...(start !== null && !anchored
|
|
690
|
-
? [
|
|
772
|
+
? [
|
|
773
|
+
{
|
|
774
|
+
key: 'start',
|
|
775
|
+
node: glue(start),
|
|
776
|
+
// The reading sits at its fill's end (clamped inside the track); `readingAt="start"` keeps the old start edge.
|
|
777
|
+
...(props.readingAt !== 'start' &&
|
|
778
|
+
model.fillEndPct !== undefined && {
|
|
779
|
+
pct: model.fillEndPct,
|
|
780
|
+
align: 'end' as const,
|
|
781
|
+
}),
|
|
782
|
+
} satisfies CaptionItem,
|
|
783
|
+
]
|
|
691
784
|
: []),
|
|
692
785
|
...(model.forecastText !== null
|
|
693
786
|
? [
|
|
694
787
|
{
|
|
695
788
|
key: 'forecast',
|
|
696
789
|
node: glue(model.forecastText),
|
|
790
|
+
drop: 2,
|
|
791
|
+
// The reading ends at the boundary, the forecast begins there.
|
|
792
|
+
...(props.readingAt !== 'start' && start !== null && { align: 'start' as const }),
|
|
697
793
|
...(model.boundaryPct !== undefined && { pct: model.boundaryPct }),
|
|
698
794
|
} satisfies CaptionItem,
|
|
699
795
|
]
|
|
@@ -708,6 +804,7 @@ export function MeterBar(props: {
|
|
|
708
804
|
key: `tick${t.key}`,
|
|
709
805
|
node: glue(t.caption),
|
|
710
806
|
pct: t.pct,
|
|
807
|
+
drop: 1,
|
|
711
808
|
} satisfies CaptionItem,
|
|
712
809
|
],
|
|
713
810
|
)),
|
|
@@ -717,6 +814,7 @@ export function MeterBar(props: {
|
|
|
717
814
|
key: 'end',
|
|
718
815
|
node: glue(end),
|
|
719
816
|
end: true,
|
|
817
|
+
...(targetHere && { target: true }),
|
|
720
818
|
...(targetHere && model.targetPct !== undefined
|
|
721
819
|
? { pct: model.targetPct }
|
|
722
820
|
: { edge: 'end' as const }),
|
|
@@ -728,9 +826,7 @@ export function MeterBar(props: {
|
|
|
728
826
|
const root = rootProps(shell)
|
|
729
827
|
return (
|
|
730
828
|
<div {...root} className={root.className}>
|
|
731
|
-
{
|
|
732
|
-
<LabelRow zones={zoneLabels} ticks={tickLabels} />
|
|
733
|
-
)}
|
|
829
|
+
{aboveTicks.length > 0 && <LabelRow zones={[]} ticks={aboveTicks} />}
|
|
734
830
|
<div
|
|
735
831
|
className={cx(classes.trackBox, trackHidden && classes.trackHidden)}
|
|
736
832
|
data-meter-track-hidden={trackHidden ? '' : undefined}
|
|
@@ -781,7 +877,7 @@ export function MeterBar(props: {
|
|
|
781
877
|
))}
|
|
782
878
|
<Tick kind="target" className={classes.tick} pct={model.targetPct} />
|
|
783
879
|
</div>
|
|
784
|
-
{zoneLabels.length > 0 && <LabelRow zones={zoneLabels} ticks={
|
|
880
|
+
{zoneLabels.length > 0 && <LabelRow zones={zoneLabels} ticks={belowTicks} />}
|
|
785
881
|
{anchored && <ZoneReading pct={model.markerPct ?? 0}>{start}</ZoneReading>}
|
|
786
882
|
{model.describedByText !== null && (
|
|
787
883
|
<VisuallyHidden id={describedId} className={classes.summary}>
|
|
@@ -206,6 +206,14 @@
|
|
|
206
206
|
white-space: nowrap;
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
+
/* `text-wrap` sets the same longhand as `white-space: nowrap`: `.caption`'s `balance`, declared below,
|
|
210
|
+
* would win on source order and let a caption placed at its measured width wrap on a sub-pixel
|
|
211
|
+
* difference. One class more outranks it. */
|
|
212
|
+
.captionsAnchored > :is(.caption) {
|
|
213
|
+
white-space: nowrap;
|
|
214
|
+
text-wrap: nowrap;
|
|
215
|
+
}
|
|
216
|
+
|
|
209
217
|
/* Captions never truncate: the row wraps, and a caption wider than the row wraps inside itself. */
|
|
210
218
|
.caption {
|
|
211
219
|
min-width: 0;
|
|
@@ -220,6 +228,19 @@
|
|
|
220
228
|
text-align: end;
|
|
221
229
|
}
|
|
222
230
|
|
|
231
|
+
/* The target figure is one line: it never wraps (the row drops other captions first). A consumer's
|
|
232
|
+
* own end caption is prose and may still wrap. */
|
|
233
|
+
.captionTarget {
|
|
234
|
+
composes: captionEnd;
|
|
235
|
+
flex: none;
|
|
236
|
+
white-space: nowrap;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/* A caption the row has no room for: still laid out (so a resize can measure it again), not shown. */
|
|
240
|
+
.captionsAnchored > [data-hidden] {
|
|
241
|
+
visibility: hidden;
|
|
242
|
+
}
|
|
243
|
+
|
|
223
244
|
/* The visually-hidden summary and loading text are still text: they read the caption size, not the
|
|
224
245
|
* body size they would inherit. */
|
|
225
246
|
.root .summary {
|
|
@@ -250,6 +271,12 @@
|
|
|
250
271
|
white-space: nowrap;
|
|
251
272
|
}
|
|
252
273
|
|
|
274
|
+
/* Not every entry fits one row: a grid with the measured column count, never one entry alone. */
|
|
275
|
+
.partCaptionsGrid {
|
|
276
|
+
display: grid;
|
|
277
|
+
justify-content: start;
|
|
278
|
+
}
|
|
279
|
+
|
|
253
280
|
/* Only an entry wider than the whole row may break (measured), so nothing overflows the card. */
|
|
254
281
|
.partCaptionsWrap > .partCaption {
|
|
255
282
|
flex: 0 1 auto;
|
|
@@ -285,7 +312,20 @@
|
|
|
285
312
|
color: var(--vx-muted);
|
|
286
313
|
}
|
|
287
314
|
|
|
288
|
-
/*
|
|
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. */
|
|
317
|
+
.line {
|
|
318
|
+
display: flex;
|
|
319
|
+
align-items: center;
|
|
320
|
+
height: 1lh;
|
|
321
|
+
font-size: var(--basalt-meter-caption);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
.lineZoned {
|
|
325
|
+
height: 1.25em;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/* The skeleton holds the loaded footprint: figure row (zoned), track, caption / zone-name row. */
|
|
289
329
|
.skeletonTrack {
|
|
290
330
|
height: 0.375rem;
|
|
291
331
|
}
|
|
@@ -370,6 +410,6 @@
|
|
|
370
410
|
height: 1lh;
|
|
371
411
|
}
|
|
372
412
|
|
|
373
|
-
.row .
|
|
413
|
+
.row .line {
|
|
374
414
|
display: none;
|
|
375
415
|
}
|
|
@@ -23,13 +23,17 @@ declare const classes: {
|
|
|
23
23
|
readonly captions: string
|
|
24
24
|
readonly caption: string
|
|
25
25
|
readonly captionEnd: string
|
|
26
|
+
readonly captionTarget: string
|
|
26
27
|
readonly captionsAnchored: string
|
|
27
28
|
readonly partCaptions: string
|
|
28
29
|
readonly partCaption: string
|
|
29
30
|
readonly partCaptionsUnder: string
|
|
30
31
|
readonly partCaptionsWrap: string
|
|
32
|
+
readonly partCaptionsGrid: string
|
|
31
33
|
readonly swatch: string
|
|
32
34
|
readonly empty: string
|
|
35
|
+
readonly line: string
|
|
36
|
+
readonly lineZoned: string
|
|
33
37
|
readonly skeletonTrack: string
|
|
34
38
|
readonly skeletonCaption: string
|
|
35
39
|
readonly ringBox: string
|
package/src/dashboard/meter.tsx
CHANGED
|
@@ -72,7 +72,7 @@ type Common = BasaltProps & {
|
|
|
72
72
|
format?: (value: number) => string
|
|
73
73
|
/** Renders a skeleton with the meter's footprint. */
|
|
74
74
|
loading?: boolean
|
|
75
|
-
/** Muted line shown when there is no reading; none by default (the
|
|
75
|
+
/** Muted line shown when there is no reading; none by default (the muted track stands alone, caption rows blank). */
|
|
76
76
|
emptyText?: string
|
|
77
77
|
}
|
|
78
78
|
|
|
@@ -122,6 +122,12 @@ type BarCommon = Common & {
|
|
|
122
122
|
* to print it inside a host. A `stops` track prints it only when `true`.
|
|
123
123
|
*/
|
|
124
124
|
reading?: boolean
|
|
125
|
+
/**
|
|
126
|
+
* Where the reading caption sits under a plain or segmented bar. `'fill'` (default): at the end of
|
|
127
|
+
* the fill, clamped inside the track (at the start when the fill is too short to hold it).
|
|
128
|
+
* `'start'`: at the track's start, as before 2.24.
|
|
129
|
+
*/
|
|
130
|
+
readingAt?: 'fill' | 'start'
|
|
125
131
|
}
|
|
126
132
|
|
|
127
133
|
/**
|
|
@@ -192,6 +198,7 @@ export type MeterProps =
|
|
|
192
198
|
startCaption?: never
|
|
193
199
|
endCaption?: never
|
|
194
200
|
reading?: never
|
|
201
|
+
readingAt?: never
|
|
195
202
|
stops?: never
|
|
196
203
|
track?: never
|
|
197
204
|
})
|
|
@@ -221,12 +228,23 @@ export function Meter(props: MeterProps) {
|
|
|
221
228
|
const hostTone = useContext(VisualSlotContext)?.tone
|
|
222
229
|
const hostColor = hostTone === undefined ? undefined : VX.status[hostTone]
|
|
223
230
|
|
|
224
|
-
if (props.loading === true)
|
|
231
|
+
if (props.loading === true)
|
|
232
|
+
return (
|
|
233
|
+
<MeterLoading label={label} ring={ring} zoned={props.zones !== undefined} shell={shell} />
|
|
234
|
+
)
|
|
225
235
|
|
|
226
236
|
const segments = props.segments === undefined ? undefined : normalizeSegments(props.segments)
|
|
227
237
|
const reading = segments === undefined ? props.value : segmentReading(segments, min)
|
|
228
238
|
if (!isReading(reading) || segments?.length === 0) {
|
|
229
|
-
return
|
|
239
|
+
return (
|
|
240
|
+
<MeterEmpty
|
|
241
|
+
label={label}
|
|
242
|
+
text={props.emptyText}
|
|
243
|
+
ring={ring}
|
|
244
|
+
zoned={props.zones !== undefined}
|
|
245
|
+
shell={shell}
|
|
246
|
+
/>
|
|
247
|
+
)
|
|
230
248
|
}
|
|
231
249
|
|
|
232
250
|
if (props.shape === 'ring') {
|
|
@@ -256,6 +274,7 @@ export function Meter(props: MeterProps) {
|
|
|
256
274
|
forecastCaption={props.segments === undefined ? undefined : props.forecastCaption}
|
|
257
275
|
startCaption={props.startCaption}
|
|
258
276
|
endCaption={props.endCaption}
|
|
277
|
+
readingAt={props.readingAt}
|
|
259
278
|
/>
|
|
260
279
|
)
|
|
261
280
|
}
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* the re-derivation this exists to delete. `LoadingState` / `ErrorState` ship alongside as the
|
|
15
15
|
* escape hatch for a page that must place its branches in different DOM positions.
|
|
16
16
|
*/
|
|
17
|
-
import { Center, Group, Loader, Stack, Text } from '@mantine/core'
|
|
17
|
+
import { Center, Group, Loader, Skeleton, Stack, Text, VisuallyHidden } from '@mantine/core'
|
|
18
18
|
import type { CSSProperties, ReactNode } from 'react'
|
|
19
19
|
import { toErrorMessage } from '../common/errors'
|
|
20
20
|
import { cx } from '../common/props'
|
|
@@ -60,11 +60,15 @@ export type QueryEmptyCopy = {
|
|
|
60
60
|
export type LoadingStateProps = BasaltProps & {
|
|
61
61
|
/** How loud this state is. Default `'page'`. */
|
|
62
62
|
tier?: QueryStateTier
|
|
63
|
-
/** Accessible name for the
|
|
63
|
+
/** Accessible name for the loading state. Say what is loading. */
|
|
64
64
|
label?: string
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
/**
|
|
67
|
+
/**
|
|
68
|
+
* `tier="page"` centres a neutral spinner in a generous block (a route body whose shape is unknown);
|
|
69
|
+
* `'section'` is a neutral skeleton, never an accent spinner. A card region that knows its loaded
|
|
70
|
+
* shape passes `loading` to `QueryState` instead.
|
|
71
|
+
*/
|
|
68
72
|
export function LoadingState({
|
|
69
73
|
tier,
|
|
70
74
|
label = 'Loading',
|
|
@@ -74,12 +78,19 @@ export function LoadingState({
|
|
|
74
78
|
const resolved = tier ?? 'page'
|
|
75
79
|
if (resolved === 'section') {
|
|
76
80
|
return (
|
|
77
|
-
<
|
|
78
|
-
|
|
81
|
+
<Stack
|
|
82
|
+
component="output"
|
|
83
|
+
gap="xs"
|
|
79
84
|
aria-label={label}
|
|
85
|
+
aria-busy="true"
|
|
80
86
|
{...(className !== undefined && { className })}
|
|
81
87
|
{...(style !== undefined && { style })}
|
|
82
|
-
|
|
88
|
+
>
|
|
89
|
+
<VisuallyHidden>{label}</VisuallyHidden>
|
|
90
|
+
<Skeleton height={14} width="40%" />
|
|
91
|
+
<Skeleton height={14} />
|
|
92
|
+
<Skeleton height={14} width="75%" />
|
|
93
|
+
</Stack>
|
|
83
94
|
)
|
|
84
95
|
}
|
|
85
96
|
// Same page-level vertical inset `EmptyState`'s `'page'` variant uses (`empty-state.tsx`'s
|
|
@@ -90,7 +101,7 @@ export function LoadingState({
|
|
|
90
101
|
{...(className !== undefined && { className })}
|
|
91
102
|
style={{ paddingBlock: 'calc(var(--vx-space-stack-xs, 0.25rem) * 16)', ...style }}
|
|
92
103
|
>
|
|
93
|
-
<Loader size="sm" aria-label={label} />
|
|
104
|
+
<Loader size="sm" color={VX.muted} aria-label={label} />
|
|
94
105
|
</Center>
|
|
95
106
|
)
|
|
96
107
|
}
|
|
@@ -246,7 +257,7 @@ export type QueryStateProps<TData> = BasaltProps &
|
|
|
246
257
|
errorAction?: ReactNode
|
|
247
258
|
/** How loud every branch is. Default `'page'`. */
|
|
248
259
|
tier?: QueryStateTier
|
|
249
|
-
/** Replace the default
|
|
260
|
+
/** Replace the default loading state (e.g. with a skeleton in the region's loaded shape). */
|
|
250
261
|
loading?: ReactNode
|
|
251
262
|
}
|
|
252
263
|
|
|
@@ -75,6 +75,18 @@
|
|
|
75
75
|
gap: var(--mantine-spacing-xs, 0.625rem);
|
|
76
76
|
}
|
|
77
77
|
|
|
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.
|
|
85
|
+
*/
|
|
86
|
+
.summary > :global(.mantine-Text-root) {
|
|
87
|
+
font-size: var(--vx-text-micro);
|
|
88
|
+
}
|
|
89
|
+
|
|
78
90
|
/*
|
|
79
91
|
* The collapse chevron — a plain control, not a Mantine ActionIcon, so it sits directly in the header
|
|
80
92
|
* row (its own CtlSlot fragment would nest a theme provider around one glyph). It is sized to the
|
|
@@ -137,7 +137,8 @@ type SectionBaseProps = Omit<
|
|
|
137
137
|
defaultOpen?: boolean
|
|
138
138
|
/** Rendered directly under the header and ALWAYS visible, collapsed or not: a collapsed section
|
|
139
139
|
* still states its headline figures, which is what makes collapsing it a real option. Keep it to
|
|
140
|
-
* one row — the body is what `children` is for.
|
|
140
|
+
* one row — the body is what `children` is for. Section owns the summary text size (11 px, the
|
|
141
|
+
* chart-text step): a `size` prop on a bare `Text` here is ignored — wrap it to opt out. */
|
|
141
142
|
summary?: ReactNode
|
|
142
143
|
/** Turns the root into a scroll anchor (`id` + `scroll-margin-top`). Inside `BasaltShell` the
|
|
143
144
|
* offset is the clearance token; without a shell it also clears `PageBar`, which assumes the
|
|
@@ -40,7 +40,7 @@ import classes from './settings-section.module.css'
|
|
|
40
40
|
|
|
41
41
|
const eyebrowStyle = {
|
|
42
42
|
fontFamily: 'var(--basalt-font-mono)',
|
|
43
|
-
fontSize: VX.text.
|
|
43
|
+
fontSize: VX.text.xs,
|
|
44
44
|
fontWeight: 500,
|
|
45
45
|
letterSpacing: '0.06em',
|
|
46
46
|
textTransform: 'uppercase' as const,
|
|
@@ -102,7 +102,7 @@ export type SettingsRowProps = BasaltProps &
|
|
|
102
102
|
SlotStylesProps<SettingsRowSlot> & {
|
|
103
103
|
/** 13px ink label on the left. */
|
|
104
104
|
label: string
|
|
105
|
-
/** Optional
|
|
105
|
+
/** Optional 12px muted description under the label. */
|
|
106
106
|
description?: string
|
|
107
107
|
/** Right-aligned control (input/switch/button). */
|
|
108
108
|
control?: ReactNode
|
|
@@ -125,9 +125,9 @@ export function SettingsRow({
|
|
|
125
125
|
{...(style !== undefined && { style })}
|
|
126
126
|
>
|
|
127
127
|
<Stack gap={2} {...(classNames?.label !== undefined && { className: classNames.label })}>
|
|
128
|
-
<span style={{ fontSize: VX.text.
|
|
128
|
+
<span style={{ fontSize: VX.text.sm, color: VX.ink }}>{label}</span>
|
|
129
129
|
{description && (
|
|
130
|
-
<span style={{ fontSize: VX.text.
|
|
130
|
+
<span style={{ fontSize: VX.text.xs, color: VX.muted }}>{description}</span>
|
|
131
131
|
)}
|
|
132
132
|
</Stack>
|
|
133
133
|
<div className={cx(classes.control, classNames?.control)}>{control ?? children}</div>
|