basalt-ui 2.21.0 → 2.22.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 +33 -0
- package/MIGRATING.md +277 -12
- package/agent/agents/basalt-design-reviewer.md +1 -1
- package/agent/rules/basalt-tokens.md +1 -1
- package/agent/skills/basalt-design/SKILL.md +1 -1
- package/agent/skills/basalt-design/references/anti-defaults.md +1 -1
- package/agent/skills/basalt-design/references/catalogue.md +1 -0
- package/dist/charts/BandStrip.d.ts.map +1 -1
- package/dist/charts/BandStrip.js +27 -3
- package/dist/charts/Bars.d.ts.map +1 -1
- package/dist/charts/Bars.js +5 -0
- package/dist/charts/CartesianChart.d.ts +8 -0
- package/dist/charts/CartesianChart.d.ts.map +1 -1
- package/dist/charts/CartesianChart.js +8 -5
- package/dist/charts/ChartCard.d.ts +12 -3
- package/dist/charts/ChartCard.d.ts.map +1 -1
- package/dist/charts/ChartCard.js +29 -8
- package/dist/charts/DualPanel.d.ts.map +1 -1
- package/dist/charts/DualPanel.js +5 -8
- package/dist/charts/Heatmap.d.ts +12 -1
- package/dist/charts/Heatmap.d.ts.map +1 -1
- package/dist/charts/Heatmap.js +34 -5
- package/dist/charts/Lines.d.ts +3 -0
- package/dist/charts/Lines.d.ts.map +1 -1
- package/dist/charts/Lines.js +29 -6
- package/dist/charts/MirroredBars.d.ts.map +1 -1
- package/dist/charts/MirroredBars.js +4 -6
- package/dist/charts/Sparkline.d.ts +7 -1
- package/dist/charts/Sparkline.d.ts.map +1 -1
- package/dist/charts/Sparkline.js +39 -14
- package/dist/charts/StackedArea.d.ts +4 -1
- package/dist/charts/StackedArea.d.ts.map +1 -1
- package/dist/charts/StackedArea.js +9 -3
- package/dist/charts/band-fold.d.ts +20 -1
- package/dist/charts/band-fold.d.ts.map +1 -1
- package/dist/charts/band-fold.js +9 -0
- package/dist/charts/chart-box.module.css +19 -0
- package/dist/charts/chart-card.module.css +25 -0
- package/dist/charts/chart-legend.module.css +7 -0
- package/dist/charts/compile.d.ts +17 -6
- package/dist/charts/compile.d.ts.map +1 -1
- package/dist/charts/compile.js +145 -74
- package/dist/charts/labels.d.ts +15 -4
- package/dist/charts/labels.d.ts.map +1 -1
- package/dist/charts/labels.js +34 -10
- package/dist/charts/legend.d.ts +2 -0
- package/dist/charts/legend.d.ts.map +1 -1
- package/dist/charts/legend.js +7 -21
- package/dist/charts/marks.js +1 -1
- package/dist/charts/panel.d.ts +0 -6
- package/dist/charts/panel.d.ts.map +1 -1
- package/dist/charts/panel.js +1 -10
- package/dist/charts/ref-label.d.ts +26 -0
- package/dist/charts/ref-label.d.ts.map +1 -0
- package/dist/charts/ref-label.js +63 -0
- package/dist/charts/scales.d.ts +4 -1
- package/dist/charts/scales.d.ts.map +1 -1
- package/dist/charts/scales.js +14 -3
- package/dist/charts/sparkline.module.css +10 -11
- package/dist/charts/sparkline.module.css.d.ts +1 -2
- package/dist/charts/state.d.ts +2 -0
- package/dist/charts/state.d.ts.map +1 -1
- package/dist/charts/state.js +2 -1
- package/dist/charts/types.d.ts +14 -5
- package/dist/charts/types.d.ts.map +1 -1
- package/dist/cli/doctor-upgrade.d.ts +1 -0
- package/dist/cli/doctor-upgrade.d.ts.map +1 -1
- package/dist/cli/doctor-upgrade.js +1 -0
- package/dist/cli/init.d.ts +2 -0
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +68 -4
- package/dist/cli/shot/capture.d.ts +21 -2
- package/dist/cli/shot/capture.d.ts.map +1 -1
- package/dist/cli/shot/capture.js +194 -32
- package/dist/cli/shot/detect.d.ts.map +1 -1
- package/dist/cli/shot/detect.js +14 -1
- package/dist/cli/shot/playwright.d.ts +5 -2
- package/dist/cli/shot/playwright.d.ts.map +1 -1
- package/dist/cli/shot/types.d.ts +2 -0
- package/dist/cli/shot/types.d.ts.map +1 -1
- package/dist/cli/shot/types.js +2 -0
- package/dist/controls/controls.module.css +11 -1
- package/dist/controls/filter-pill.d.ts.map +1 -1
- package/dist/controls/filter-pill.js +1 -0
- package/dist/controls/sync-button.d.ts.map +1 -1
- package/dist/controls/sync-button.js +22 -3
- package/dist/controls/sync-button.module.css +34 -2
- package/dist/controls/sync-button.module.css.d.ts +1 -0
- package/dist/dashboard/bar-list.d.ts.map +1 -1
- package/dist/dashboard/bar-list.js +7 -8
- package/dist/dashboard/bar-list.module.css +53 -0
- package/dist/dashboard/bar-list.module.css.d.ts +1 -0
- package/dist/dashboard/index.d.ts +1 -0
- package/dist/dashboard/index.d.ts.map +1 -1
- package/dist/dashboard/index.js +2 -0
- package/dist/dashboard/meter-model.d.ts +77 -3
- package/dist/dashboard/meter-model.d.ts.map +1 -1
- package/dist/dashboard/meter-model.js +88 -15
- package/dist/dashboard/meter-parts.d.ts +8 -0
- package/dist/dashboard/meter-parts.d.ts.map +1 -1
- package/dist/dashboard/meter-parts.js +238 -71
- package/dist/dashboard/meter.d.ts +43 -60
- package/dist/dashboard/meter.d.ts.map +1 -1
- package/dist/dashboard/meter.js +20 -3
- package/dist/dashboard/meter.module.css +61 -0
- package/dist/dashboard/meter.module.css.d.ts +5 -0
- package/dist/dashboard/page-summary.d.ts +20 -0
- package/dist/dashboard/page-summary.d.ts.map +1 -0
- package/dist/dashboard/page-summary.js +28 -0
- package/dist/dashboard/page-summary.module.css +89 -0
- package/dist/dashboard/page-summary.module.css.d.ts +15 -0
- package/dist/dashboard/section.d.ts +25 -2
- package/dist/dashboard/section.d.ts.map +1 -1
- package/dist/dashboard/section.js +10 -5
- package/dist/dashboard/section.module.css +23 -0
- package/dist/dashboard/section.module.css.d.ts +1 -0
- package/dist/dashboard/stat-card-parts.d.ts.map +1 -1
- package/dist/dashboard/stat-card-parts.js +1 -1
- package/dist/dashboard/stat-card.d.ts +4 -2
- package/dist/dashboard/stat-card.d.ts.map +1 -1
- package/dist/dashboard/stat-card.js +7 -5
- package/dist/dashboard/stat-card.module.css +17 -0
- package/dist/dashboard/stat-strip.d.ts +7 -1
- package/dist/dashboard/stat-strip.d.ts.map +1 -1
- package/dist/dashboard/stat-strip.js +74 -46
- package/dist/dashboard/stat-strip.module.css +67 -20
- package/dist/dashboard/stat-strip.module.css.d.ts +4 -0
- package/dist/dashboard/visual-slot.d.ts +7 -1
- package/dist/dashboard/visual-slot.d.ts.map +1 -1
- package/dist/dashboard/visual-slot.js +3 -1
- package/dist/guard/vx-names.d.ts.map +1 -1
- package/dist/guard/vx-names.js +2 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/styles.css +34 -2
- package/dist/theme/chrome-vars.d.ts +20 -5
- package/dist/theme/chrome-vars.d.ts.map +1 -1
- package/dist/theme/chrome-vars.js +46 -3
- package/dist/theme/controls.module.css +23 -0
- package/dist/theme/controls.module.css.d.ts +1 -0
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +8 -20
- package/dist/tokens/core.d.ts +2 -1
- package/dist/tokens/core.d.ts.map +1 -1
- package/dist/tokens/core.js +6 -1
- package/dist/tokens/derive.d.ts +3 -1
- package/dist/tokens/derive.d.ts.map +1 -1
- package/dist/tokens/derive.js +16 -1
- package/dist/tokens/palette.d.ts +4 -0
- package/dist/tokens/palette.d.ts.map +1 -1
- package/dist/tokens/palette.js +4 -0
- package/dist/tokens/status-text.d.ts.map +1 -1
- package/dist/tokens/status-text.js +3 -1
- package/llms.txt +38 -20
- package/package.json +1 -1
- package/src/charts/BandStrip.tsx +33 -3
- package/src/charts/Bars.tsx +6 -0
- package/src/charts/CartesianChart.tsx +16 -3
- package/src/charts/ChartCard.tsx +34 -6
- package/src/charts/DualPanel.tsx +3 -6
- package/src/charts/Heatmap.tsx +54 -5
- package/src/charts/Lines.tsx +56 -10
- package/src/charts/MirroredBars.tsx +3 -5
- package/src/charts/Sparkline.tsx +50 -13
- package/src/charts/StackedArea.tsx +14 -4
- package/src/charts/band-fold.ts +31 -1
- package/src/charts/chart-box.module.css +19 -0
- package/src/charts/chart-card.module.css +25 -0
- package/src/charts/chart-legend.module.css +7 -0
- package/src/charts/compile.ts +210 -85
- package/src/charts/labels.ts +48 -14
- package/src/charts/legend.tsx +10 -20
- package/src/charts/marks.ts +1 -1
- package/src/charts/panel.tsx +1 -16
- package/src/charts/ref-label.ts +104 -0
- package/src/charts/scales.ts +22 -2
- package/src/charts/sparkline.module.css +10 -11
- package/src/charts/sparkline.module.css.d.ts +1 -2
- package/src/charts/state.tsx +3 -1
- package/src/charts/types.ts +14 -5
- package/src/cli/doctor-upgrade.ts +1 -1
- package/src/cli/init.ts +100 -3
- package/src/cli/shot/capture.ts +251 -32
- package/src/cli/shot/detect.ts +18 -1
- package/src/cli/shot/playwright.ts +2 -2
- package/src/cli/shot/types.ts +3 -0
- package/src/controls/controls.module.css +11 -1
- package/src/controls/filter-pill.tsx +2 -0
- package/src/controls/sync-button.module.css +34 -2
- package/src/controls/sync-button.module.css.d.ts +1 -0
- package/src/controls/sync-button.tsx +40 -4
- package/src/dashboard/bar-list.module.css +53 -0
- package/src/dashboard/bar-list.module.css.d.ts +1 -0
- package/src/dashboard/bar-list.tsx +78 -69
- package/src/dashboard/index.ts +1 -0
- package/src/dashboard/meter-model.ts +186 -20
- package/src/dashboard/meter-parts.tsx +285 -64
- package/src/dashboard/meter.module.css +61 -0
- package/src/dashboard/meter.module.css.d.ts +5 -0
- package/src/dashboard/meter.tsx +60 -10
- package/src/dashboard/page-summary.module.css +89 -0
- package/src/dashboard/page-summary.module.css.d.ts +15 -0
- package/src/dashboard/page-summary.tsx +95 -0
- package/src/dashboard/section.module.css +23 -0
- package/src/dashboard/section.module.css.d.ts +1 -0
- package/src/dashboard/section.tsx +59 -11
- package/src/dashboard/stat-card-parts.tsx +5 -1
- package/src/dashboard/stat-card.module.css +17 -0
- package/src/dashboard/stat-card.tsx +12 -6
- package/src/dashboard/stat-strip.module.css +67 -20
- package/src/dashboard/stat-strip.module.css.d.ts +4 -0
- package/src/dashboard/stat-strip.tsx +118 -72
- package/src/dashboard/visual-slot.ts +12 -3
- package/src/guard/vx-names.ts +2 -0
- package/src/index.ts +2 -0
- package/src/styles.css +34 -2
- package/src/theme/__snapshots__/plain-theme.test.ts.snap +186 -60
- package/src/theme/chrome-vars.ts +77 -8
- package/src/theme/controls.module.css +23 -0
- package/src/theme/controls.module.css.d.ts +1 -0
- package/src/theme/index.ts +12 -25
- package/src/tokens/core.ts +4 -1
- package/src/tokens/derive.ts +32 -3
- package/src/tokens/palette.ts +4 -0
- package/src/tokens/status-text.ts +2 -0
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
* pushes a page's own actions into the kebab. The age and the error live in the tooltip; the
|
|
14
14
|
* accessible name is `label`.
|
|
15
15
|
* - `scope: 'page'` → `PageBar.sync` (the page's own data). The labelled `Button` with the age
|
|
16
|
-
* inline beside it on desktop
|
|
17
|
-
* mount, never a `visibleFrom` twin (law C9).
|
|
16
|
+
* inline beside it on desktop; below `sm` the label and the long age go and the glyph keeps a
|
|
17
|
+
* SHORT age (`2m`) beside it — CSS only, one mount, never a `visibleFrom` twin (law C9).
|
|
18
18
|
*
|
|
19
19
|
* Because the label is hidden rather than unmounted below `sm`, the accessible name comes from
|
|
20
20
|
* `aria-label` in BOTH forms: `display: none` text is out of the accessibility tree, so a page
|
|
@@ -26,6 +26,7 @@ import type { ReactNode } from 'react'
|
|
|
26
26
|
import { cx } from '../common/props'
|
|
27
27
|
import type { BasaltProps } from '../common/props'
|
|
28
28
|
import { relativeTime } from '../format'
|
|
29
|
+
import { numberFormat } from '../format/shared'
|
|
29
30
|
import { IconSlot } from '../theme/icon-slot'
|
|
30
31
|
import { RefreshGlyph } from './glyphs'
|
|
31
32
|
import classes from './sync-button.module.css'
|
|
@@ -69,15 +70,43 @@ function toMillis(at: number | Date | null | undefined): number | undefined {
|
|
|
69
70
|
* string (`now`, `1 min. ago`, …), so it is stable across calls within a bucket and a tick only
|
|
70
71
|
* re-renders when the label changes. With no timestamp there is no subscription and no timer.
|
|
71
72
|
*/
|
|
72
|
-
function useRelativeAge(
|
|
73
|
+
function useRelativeAge(
|
|
74
|
+
at: number | Date | null | undefined,
|
|
75
|
+
format: (timestamp: number) => string = (timestamp) =>
|
|
76
|
+
relativeTime(timestamp, { style: 'short' }),
|
|
77
|
+
): string | undefined {
|
|
73
78
|
const timestamp = toMillis(at)
|
|
74
79
|
return useSyncExternalStore(
|
|
75
80
|
timestamp === undefined ? subscribeNever : subscribeAgeTick,
|
|
76
|
-
() => (timestamp === undefined ? undefined :
|
|
81
|
+
() => (timestamp === undefined ? undefined : format(timestamp)),
|
|
77
82
|
() => undefined,
|
|
78
83
|
)
|
|
79
84
|
}
|
|
80
85
|
|
|
86
|
+
const COMPACT_UNITS = [
|
|
87
|
+
{ unit: 'day', seconds: 86_400 },
|
|
88
|
+
{ unit: 'hour', seconds: 3_600 },
|
|
89
|
+
{ unit: 'minute', seconds: 60 },
|
|
90
|
+
] as const
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* The phone form's age: one number and a NARROW locale unit (`2m`, `3h`, `2d` in English, `2 Min.`
|
|
94
|
+
* in German), small enough to ride beside the glyph in the button at 390. `Intl.NumberFormat`'s
|
|
95
|
+
* unit style honours the `BasaltProvider` / `defineFormat` locale like every other format here.
|
|
96
|
+
* Under a minute it is the locale's own "now", the same bucket the long age uses, so the two never
|
|
97
|
+
* disagree about whether a sync just landed.
|
|
98
|
+
*/
|
|
99
|
+
function compactAge(timestamp: number): string {
|
|
100
|
+
const seconds = Math.max(0, (Date.now() - timestamp) / 1000)
|
|
101
|
+
const step = COMPACT_UNITS.find((u) => seconds >= u.seconds)
|
|
102
|
+
if (step === undefined) return relativeTime(timestamp, { style: 'short' })
|
|
103
|
+
return numberFormat(undefined, {
|
|
104
|
+
style: 'unit',
|
|
105
|
+
unit: step.unit,
|
|
106
|
+
unitDisplay: 'narrow',
|
|
107
|
+
}).format(Math.floor(seconds / step.seconds))
|
|
108
|
+
}
|
|
109
|
+
|
|
81
110
|
const subscribeNever = (): (() => void) => () => {}
|
|
82
111
|
|
|
83
112
|
function subscribeAgeTick(onTick: () => void): () => void {
|
|
@@ -108,6 +137,7 @@ export function SyncButton({
|
|
|
108
137
|
style,
|
|
109
138
|
}: SyncButtonProps): ReactNode {
|
|
110
139
|
const age = useRelativeAge(lastCompletedAt)
|
|
140
|
+
const shortAge = useRelativeAge(lastCompletedAt, compactAge)
|
|
111
141
|
// Wherever the label is not painted — every `global` mount, and a `page` mount below `sm` — the
|
|
112
142
|
// tooltip is where the age lives; an `error` outranks it everywhere. ONE tooltip, one mount.
|
|
113
143
|
const tooltip = error ?? age
|
|
@@ -158,6 +188,7 @@ export function SyncButton({
|
|
|
158
188
|
<Button
|
|
159
189
|
variant="default"
|
|
160
190
|
className={cx(classes.pageButton, className)}
|
|
191
|
+
{...(age !== undefined && { 'data-with-age': true })}
|
|
161
192
|
{...(style !== undefined && { style })}
|
|
162
193
|
leftSection={
|
|
163
194
|
<IconSlot>
|
|
@@ -168,6 +199,11 @@ export function SyncButton({
|
|
|
168
199
|
>
|
|
169
200
|
<span className={classes.label}>{label}</span>
|
|
170
201
|
{age !== undefined && <span className={classes.age}>{age}</span>}
|
|
202
|
+
{shortAge !== undefined && (
|
|
203
|
+
<span className={classes.ageCompact} data-sync-age="compact">
|
|
204
|
+
{shortAge}
|
|
205
|
+
</span>
|
|
206
|
+
)}
|
|
171
207
|
</Button>
|
|
172
208
|
)}
|
|
173
209
|
</Tooltip>
|
|
@@ -5,6 +5,19 @@
|
|
|
5
5
|
* row never wraps: the label truncates, the value is nowrap.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
/*
|
|
9
|
+
* The width container the wide layout keys on (a container cannot restyle its own grid), in every
|
|
10
|
+
* state. It is named `basalt-card` because the theme guard permits only the declared names; that
|
|
11
|
+
* shadows an enclosing card's container for the list's descendants only, and the query below measures
|
|
12
|
+
* the LIST's own inline size, not the card's. `inline-size: 100%` keeps it from collapsing to zero in
|
|
13
|
+
* a flex row or an auto track (size containment ignores content width).
|
|
14
|
+
*/
|
|
15
|
+
.frame {
|
|
16
|
+
container: basalt-card / inline-size;
|
|
17
|
+
inline-size: 100%;
|
|
18
|
+
min-width: 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
8
21
|
.root {
|
|
9
22
|
display: grid;
|
|
10
23
|
grid-template-columns: minmax(0, 1fr) auto;
|
|
@@ -164,3 +177,43 @@
|
|
|
164
177
|
text-overflow: ellipsis;
|
|
165
178
|
white-space: nowrap;
|
|
166
179
|
}
|
|
180
|
+
|
|
181
|
+
/*
|
|
182
|
+
* Wide (a container of 480px or more): one row, `[label][value][secondary][track]`. The label column fits the
|
|
183
|
+
* longest label (capped at 40% or 14rem, the rest truncates with its `title`), value and secondary are right-
|
|
184
|
+
* aligned and shared by every row, and the track takes the remaining width on the one scale — a
|
|
185
|
+
* full-scale bar ends at the track end, never under a value. Compact keeps the stacked thin layout.
|
|
186
|
+
*/
|
|
187
|
+
@container basalt-card (width >= 480px) {
|
|
188
|
+
.root[data-variant='thin'] {
|
|
189
|
+
grid-template-columns: fit-content(min(40%, 14rem)) auto minmax(0, 1fr);
|
|
190
|
+
column-gap: var(--vx-space-stack-md, 0.75rem);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.root[data-variant='thin'][data-secondary] {
|
|
194
|
+
grid-template-columns: fit-content(min(40%, 14rem)) auto fit-content(30%) minmax(0, 1fr);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.root[data-variant='thin'] .row {
|
|
198
|
+
grid-template-rows: auto;
|
|
199
|
+
align-items: center;
|
|
200
|
+
padding-block: 0;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
.root[data-variant='thin'] .track {
|
|
204
|
+
grid-column: auto;
|
|
205
|
+
align-self: center;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.root[data-variant='thin'] .label {
|
|
209
|
+
display: block;
|
|
210
|
+
white-space: nowrap;
|
|
211
|
+
text-overflow: ellipsis;
|
|
212
|
+
-webkit-line-clamp: unset;
|
|
213
|
+
line-clamp: unset;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.root[data-variant='thin'] .secondary {
|
|
217
|
+
text-align: end;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
@@ -12,7 +12,10 @@
|
|
|
12
12
|
* thin bar with the value right-aligned on the label line; `variant="inline"` is the older heavy track
|
|
13
13
|
* with the label inside it.
|
|
14
14
|
*
|
|
15
|
-
* Thin rows sit flush: no inline inset on the label or the rail.
|
|
15
|
+
* Thin rows sit flush: no inline inset on the label or the rail. In a container wider than the compact
|
|
16
|
+
* class (480px) a thin row reads `[label][value][secondary][track]` — the label column fits the longest
|
|
17
|
+
* label, the value and secondary columns are right-aligned and shared, and the track takes the rest on
|
|
18
|
+
* the one scale, so a name stays beside its value and a full-scale bar ends at the track end.
|
|
16
19
|
*
|
|
17
20
|
* Colour law: bars are neutral. `accentLeader` (opt-in) lets the top row take the accent — the
|
|
18
21
|
* leader bar, and nothing else. Each value is rendered as text, never only a bar length.
|
|
@@ -103,19 +106,23 @@ export function BarList({
|
|
|
103
106
|
}: BarListProps) {
|
|
104
107
|
if (loading) {
|
|
105
108
|
return (
|
|
106
|
-
<div className={cx(classes.
|
|
107
|
-
<
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
109
|
+
<div className={cx(classes.frame, className)} style={style}>
|
|
110
|
+
<div className={classes.root} aria-busy="true">
|
|
111
|
+
<VisuallyHidden>{`Loading ${label}`}</VisuallyHidden>
|
|
112
|
+
{Array.from({ length: loadingRows }, (_, i) => (
|
|
113
|
+
<Skeleton key={i} className={classes.skeletonRow} data-bar-skeleton />
|
|
114
|
+
))}
|
|
115
|
+
</div>
|
|
111
116
|
</div>
|
|
112
117
|
)
|
|
113
118
|
}
|
|
114
119
|
if (items.length === 0) {
|
|
115
120
|
return (
|
|
116
|
-
<
|
|
117
|
-
<
|
|
118
|
-
|
|
121
|
+
<div className={cx(classes.frame, className)} style={style}>
|
|
122
|
+
<output className={classes.root} aria-label={label}>
|
|
123
|
+
<span className={classes.empty}>{emptyText}</span>
|
|
124
|
+
</output>
|
|
125
|
+
</div>
|
|
119
126
|
)
|
|
120
127
|
}
|
|
121
128
|
|
|
@@ -128,69 +135,71 @@ export function BarList({
|
|
|
128
135
|
const thin = variant === 'thin'
|
|
129
136
|
const hasSecondary = items.some((i) => hasContent(i.secondary))
|
|
130
137
|
return (
|
|
131
|
-
// The
|
|
132
|
-
<
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
{item.label}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
{
|
|
156
|
-
|
|
157
|
-
className={cx(classes.bar, isLeader && classes.leader)}
|
|
158
|
-
style={{ width: `${barPercent(item.value, rowScale)}%` }}
|
|
159
|
-
data-bar-fill=""
|
|
160
|
-
data-bar-leader={isLeader ? '' : undefined}
|
|
161
|
-
aria-hidden
|
|
162
|
-
/>
|
|
163
|
-
{item.tick !== undefined && (
|
|
164
|
-
// theme-allow hidden-inline-style — the position is the row's data (a % of its scale)
|
|
138
|
+
// The frame is the width container the wide layout keys on (a container cannot restyle its own grid).
|
|
139
|
+
<div className={cx(classes.frame, className)} style={style}>
|
|
140
|
+
{/* The explicit role is deliberate: `list-style: none` makes Safari/VoiceOver drop the implicit one. */}
|
|
141
|
+
<ul
|
|
142
|
+
className={classes.root}
|
|
143
|
+
// oxlint-disable-next-line jsx-a11y/no-redundant-roles
|
|
144
|
+
role="list"
|
|
145
|
+
aria-label={label}
|
|
146
|
+
data-secondary={hasSecondary ? '' : undefined}
|
|
147
|
+
data-variant={variant}
|
|
148
|
+
>
|
|
149
|
+
{items.map((item, i) => {
|
|
150
|
+
const isLeader = accentLeader && i === 0
|
|
151
|
+
const rowScale = item.max ?? scale
|
|
152
|
+
const labelNode = (
|
|
153
|
+
<span className={classes.label} title={item.label}>
|
|
154
|
+
{item.label}
|
|
155
|
+
</span>
|
|
156
|
+
)
|
|
157
|
+
const tickName =
|
|
158
|
+
item.tick === undefined
|
|
159
|
+
? ''
|
|
160
|
+
: `${item.tickLabel ?? 'Threshold'} ${format(item.tick, 'value')}`
|
|
161
|
+
const track = (
|
|
162
|
+
<span className={classes.track} data-bar-track>
|
|
163
|
+
{/* theme-allow hidden-inline-style — the width is the row's data (a % of its scale), not styling */}
|
|
165
164
|
<span
|
|
166
|
-
className={classes.
|
|
167
|
-
style={{
|
|
168
|
-
data-bar-
|
|
165
|
+
className={cx(classes.bar, isLeader && classes.leader)}
|
|
166
|
+
style={{ width: `${barPercent(item.value, rowScale)}%` }}
|
|
167
|
+
data-bar-fill=""
|
|
168
|
+
data-bar-leader={isLeader ? '' : undefined}
|
|
169
169
|
aria-hidden
|
|
170
170
|
/>
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
{
|
|
183
|
-
? item.max === undefined
|
|
184
|
-
? format(item.value, 'value')
|
|
185
|
-
: `${format(item.value, 'value')} / ${format(item.max, 'max')}`
|
|
186
|
-
: '—'}
|
|
171
|
+
{item.tick !== undefined && (
|
|
172
|
+
// theme-allow hidden-inline-style — the position is the row's data (a % of its scale)
|
|
173
|
+
<span
|
|
174
|
+
className={classes.tick}
|
|
175
|
+
style={{ insetInlineStart: `${barPercent(item.tick, rowScale)}%` }}
|
|
176
|
+
data-bar-tick=""
|
|
177
|
+
aria-hidden
|
|
178
|
+
/>
|
|
179
|
+
)}
|
|
180
|
+
{!thin && labelNode}
|
|
181
|
+
{/* Inside the track so it is never the row's last child (the value/secondary inset). */}
|
|
182
|
+
{item.tick !== undefined && <VisuallyHidden>{tickName}</VisuallyHidden>}
|
|
187
183
|
</span>
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
{
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
184
|
+
)
|
|
185
|
+
return (
|
|
186
|
+
<li key={item.key ?? `${item.label}-${i}`} className={classes.row}>
|
|
187
|
+
{thin && labelNode}
|
|
188
|
+
{!thin && track}
|
|
189
|
+
<span className={classes.value}>
|
|
190
|
+
{Number.isFinite(item.value)
|
|
191
|
+
? item.max === undefined
|
|
192
|
+
? format(item.value, 'value')
|
|
193
|
+
: `${format(item.value, 'value')} / ${format(item.max, 'max')}`
|
|
194
|
+
: '—'}
|
|
195
|
+
</span>
|
|
196
|
+
{/* Kept empty on a row without one: the secondary column is shared, so every row has the cell. */}
|
|
197
|
+
{hasSecondary && <span className={classes.secondary}>{item.secondary}</span>}
|
|
198
|
+
{thin && track}
|
|
199
|
+
</li>
|
|
200
|
+
)
|
|
201
|
+
})}
|
|
202
|
+
</ul>
|
|
203
|
+
</div>
|
|
195
204
|
)
|
|
196
205
|
}
|
package/src/dashboard/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { WidgetHeader } from './widget-header'
|
|
2
2
|
export { DeltaBadge } from './delta-badge'
|
|
3
3
|
export { Section } from './section'
|
|
4
|
+
export { PageSummary, type PageSummaryProps } from './page-summary'
|
|
4
5
|
export { StatCard, type StatCardBreakdownRow, type StatCardSparklineSize } from './stat-card'
|
|
5
6
|
export { StatGroup } from './stat-group'
|
|
6
7
|
export type { StatStripCell, StatStripRow } from './stat-strip'
|