basalt-ui 2.28.0 → 2.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +461 -401
- package/MIGRATING.md +202 -12
- package/agent/skills/basalt-app/SKILL.md +3 -3
- package/agent/skills/basalt-charts/SKILL.md +1 -1
- package/agent/skills/basalt-design/SKILL.md +11 -5
- package/agent/skills/basalt-design/references/catalogue.md +3 -1
- package/agent/skills/basalt-design/references/recipes.md +1 -1
- package/agent/skills/basalt-design/references/states.md +1 -1
- package/configs/oxlint-plugin.js +2 -1
- package/configs/oxlint.json +1 -0
- package/dist/charts/ChartCard.d.ts +9 -5
- package/dist/charts/ChartCard.d.ts.map +1 -1
- package/dist/charts/ChartCard.js +68 -12
- package/dist/charts/Sparkline.d.ts +5 -0
- package/dist/charts/Sparkline.d.ts.map +1 -1
- package/dist/charts/Sparkline.js +53 -5
- package/dist/charts/chart-box.module.css +9 -2
- package/dist/charts/chart-card.module.css +16 -13
- package/dist/charts/chart-card.module.css.d.ts +2 -0
- package/dist/charts/compile.d.ts +1 -1
- package/dist/charts/compile.d.ts.map +1 -1
- package/dist/charts/compile.js +18 -9
- package/dist/charts/ref-label.d.ts +6 -0
- package/dist/charts/ref-label.d.ts.map +1 -1
- package/dist/charts/ref-label.js +19 -5
- package/dist/charts/sparkline.module.css +44 -0
- package/dist/charts/sparkline.module.css.d.ts +3 -0
- package/dist/charts/state.d.ts +1 -1
- package/dist/charts/state.d.ts.map +1 -1
- package/dist/charts/state.js +3 -3
- package/dist/cli/doctor-upgrade.d.ts +11 -0
- package/dist/cli/doctor-upgrade.d.ts.map +1 -1
- package/dist/cli/doctor-upgrade.js +54 -0
- package/dist/cli/doctor.d.ts.map +1 -1
- package/dist/cli/doctor.js +32 -0
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +8 -3
- package/dist/cli/index.d.ts +13 -13
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +36 -2
- package/dist/cli/init.d.ts +6 -0
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +118 -27
- package/dist/cli/router-wiring.d.ts +3 -0
- package/dist/cli/router-wiring.d.ts.map +1 -1
- package/dist/cli/router-wiring.js +2 -0
- package/dist/cli/shot/capture.d.ts +28 -1
- package/dist/cli/shot/capture.d.ts.map +1 -1
- package/dist/cli/shot/capture.js +77 -7
- package/dist/cli/shot/detect.d.ts +4 -1
- package/dist/cli/shot/detect.d.ts.map +1 -1
- package/dist/cli/shot/detect.js +38 -16
- package/dist/cli/shot/index.d.ts.map +1 -1
- package/dist/cli/shot/index.js +9 -2
- package/dist/cli/shot/measure.d.ts.map +1 -1
- package/dist/cli/shot/measure.js +11 -2
- package/dist/cli/shot/types.d.ts +4 -1
- package/dist/cli/shot/types.d.ts.map +1 -1
- package/dist/cli/sync.d.ts.map +1 -1
- package/dist/cli/sync.js +10 -2
- package/dist/common/could-not-load.d.ts +13 -0
- package/dist/common/could-not-load.d.ts.map +1 -0
- package/dist/common/could-not-load.js +14 -0
- package/dist/common/index.d.ts +1 -0
- package/dist/common/index.d.ts.map +1 -1
- package/dist/common/index.js +3 -0
- package/dist/common/props.d.ts +20 -0
- package/dist/common/props.d.ts.map +1 -1
- package/dist/common/props.js +13 -1
- package/dist/common/retry-button.module.css +7 -3
- package/dist/dashboard/bar-list.d.ts +4 -4
- package/dist/dashboard/bar-list.d.ts.map +1 -1
- package/dist/dashboard/bar-list.js +10 -7
- package/dist/dashboard/bar-list.module.css +21 -3
- package/dist/dashboard/board.d.ts +2 -2
- package/dist/dashboard/board.d.ts.map +1 -1
- package/dist/dashboard/board.js +31 -12
- package/dist/dashboard/board.module.css +19 -0
- package/dist/dashboard/board.module.css.d.ts +2 -0
- package/dist/dashboard/empty-state.d.ts +3 -3
- package/dist/dashboard/empty-state.d.ts.map +1 -1
- package/dist/dashboard/empty-state.js +4 -2
- package/dist/dashboard/event-list-model.d.ts +3 -0
- package/dist/dashboard/event-list-model.d.ts.map +1 -1
- package/dist/dashboard/event-list-model.js +5 -1
- package/dist/dashboard/event-list-rows.d.ts.map +1 -1
- package/dist/dashboard/event-list-rows.js +2 -6
- package/dist/dashboard/event-list-scroll.d.ts +32 -4
- package/dist/dashboard/event-list-scroll.d.ts.map +1 -1
- package/dist/dashboard/event-list-scroll.js +117 -4
- package/dist/dashboard/event-list-skeleton.d.ts.map +1 -1
- package/dist/dashboard/event-list-skeleton.js +2 -4
- package/dist/dashboard/event-list.d.ts +4 -4
- package/dist/dashboard/event-list.d.ts.map +1 -1
- package/dist/dashboard/event-list.js +53 -23
- package/dist/dashboard/event-list.module.css +90 -37
- package/dist/dashboard/event-list.module.css.d.ts +1 -0
- package/dist/dashboard/meter-model.d.ts +6 -3
- package/dist/dashboard/meter-model.d.ts.map +1 -1
- package/dist/dashboard/meter-model.js +9 -4
- package/dist/dashboard/meter-parts.d.ts +3 -0
- package/dist/dashboard/meter-parts.d.ts.map +1 -1
- package/dist/dashboard/meter-parts.js +32 -4
- package/dist/dashboard/meter.d.ts +3 -3
- package/dist/dashboard/meter.d.ts.map +1 -1
- package/dist/dashboard/meter.js +10 -2
- package/dist/dashboard/meter.module.css +18 -11
- package/dist/dashboard/meter.module.css.d.ts +0 -1
- package/dist/dashboard/page-summary.d.ts +3 -3
- package/dist/dashboard/page-summary.d.ts.map +1 -1
- package/dist/dashboard/page-summary.js +7 -2
- package/dist/dashboard/page-summary.module.css +5 -2
- package/dist/dashboard/query-state.d.ts +9 -8
- package/dist/dashboard/query-state.d.ts.map +1 -1
- package/dist/dashboard/query-state.js +28 -10
- package/dist/dashboard/section.d.ts +11 -3
- package/dist/dashboard/section.d.ts.map +1 -1
- package/dist/dashboard/section.js +34 -7
- package/dist/dashboard/settings-section.d.ts +4 -4
- package/dist/dashboard/settings-section.d.ts.map +1 -1
- package/dist/dashboard/settings-section.js +11 -7
- package/dist/dashboard/settings-section.module.css +6 -0
- package/dist/dashboard/settings-section.module.css.d.ts +1 -0
- package/dist/dashboard/stat-card.d.ts +3 -3
- package/dist/dashboard/stat-card.d.ts.map +1 -1
- package/dist/dashboard/stat-card.js +24 -8
- package/dist/dashboard/stat-card.module.css +11 -0
- package/dist/dashboard/stat-group.d.ts +2 -2
- package/dist/dashboard/stat-group.d.ts.map +1 -1
- package/dist/dashboard/stat-group.js +10 -3
- package/dist/dashboard/stat-strip.d.ts +5 -4
- package/dist/dashboard/stat-strip.d.ts.map +1 -1
- package/dist/dashboard/stat-strip.js +41 -31
- package/dist/dashboard/stat-strip.module.css +4 -5
- 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.d.ts +6 -6
- package/dist/dashboard/widget-header.d.ts.map +1 -1
- package/dist/dashboard/widget-header.js +4 -2
- package/dist/dashboard/widget-header.module.css +6 -25
- package/dist/format/shared.d.ts.map +1 -1
- package/dist/format/shared.js +24 -1
- package/dist/guard/index.d.ts +1 -1
- package/dist/guard/index.d.ts.map +1 -1
- package/dist/guard/index.js +2 -1
- package/dist/styles.css +23 -0
- package/dist/table/cell-kinds.d.ts +10 -7
- package/dist/table/cell-kinds.d.ts.map +1 -1
- package/dist/table/cell-kinds.js +18 -7
- package/dist/table/data-table-fold.d.ts +13 -5
- package/dist/table/data-table-fold.d.ts.map +1 -1
- package/dist/table/data-table-fold.js +48 -16
- package/dist/table/data-table.d.ts +2 -2
- package/dist/table/data-table.d.ts.map +1 -1
- package/dist/table/data-table.js +16 -9
- package/dist/table/data-table.module.css +74 -2
- package/dist/table/data-table.module.css.d.ts +4 -0
- package/dist/theme/controls.module.css +23 -2
- package/llms.txt +263 -2
- package/package.json +1 -1
- package/src/charts/ChartCard.tsx +98 -16
- package/src/charts/Sparkline.tsx +84 -5
- package/src/charts/chart-box.module.css +9 -2
- package/src/charts/chart-card.module.css +16 -13
- package/src/charts/chart-card.module.css.d.ts +2 -0
- package/src/charts/compile.ts +37 -15
- package/src/charts/ref-label.ts +36 -9
- package/src/charts/sparkline.module.css +44 -0
- package/src/charts/sparkline.module.css.d.ts +3 -0
- package/src/charts/state.tsx +4 -3
- package/src/cli/doctor-upgrade.ts +75 -0
- package/src/cli/doctor.ts +36 -0
- package/src/cli/help.ts +16 -6
- package/src/cli/index.ts +73 -67
- package/src/cli/init.ts +157 -36
- package/src/cli/router-wiring.ts +2 -2
- package/src/cli/shot/capture.ts +109 -10
- package/src/cli/shot/detect.ts +46 -22
- package/src/cli/shot/index.ts +8 -2
- package/src/cli/shot/measure.ts +11 -2
- package/src/cli/shot/types.ts +4 -1
- package/src/cli/sync.ts +12 -2
- package/src/common/could-not-load.ts +22 -0
- package/src/common/index.ts +1 -0
- package/src/common/props.ts +30 -0
- package/src/common/retry-button.module.css +7 -3
- package/src/dashboard/bar-list.module.css +21 -3
- package/src/dashboard/bar-list.tsx +46 -41
- package/src/dashboard/board.module.css +19 -0
- package/src/dashboard/board.module.css.d.ts +2 -0
- package/src/dashboard/board.tsx +69 -48
- package/src/dashboard/empty-state.tsx +5 -2
- package/src/dashboard/event-list-model.ts +13 -1
- package/src/dashboard/event-list-rows.tsx +3 -6
- package/src/dashboard/event-list-scroll.ts +154 -8
- package/src/dashboard/event-list-skeleton.tsx +5 -1
- package/src/dashboard/event-list.module.css +90 -37
- package/src/dashboard/event-list.module.css.d.ts +1 -0
- package/src/dashboard/event-list.tsx +92 -65
- package/src/dashboard/meter-model.ts +16 -7
- package/src/dashboard/meter-parts.tsx +45 -13
- package/src/dashboard/meter.module.css +18 -11
- package/src/dashboard/meter.module.css.d.ts +0 -1
- package/src/dashboard/meter.tsx +36 -18
- package/src/dashboard/page-summary.module.css +5 -2
- package/src/dashboard/page-summary.tsx +13 -6
- package/src/dashboard/query-state.tsx +54 -29
- package/src/dashboard/section.tsx +83 -41
- package/src/dashboard/settings-section.module.css +6 -0
- package/src/dashboard/settings-section.module.css.d.ts +1 -0
- package/src/dashboard/settings-section.tsx +11 -6
- package/src/dashboard/stat-card.module.css +11 -0
- package/src/dashboard/stat-card.tsx +31 -8
- package/src/dashboard/stat-group.tsx +22 -14
- package/src/dashboard/stat-strip.module.css +4 -5
- package/src/dashboard/stat-strip.tsx +29 -20
- package/src/dashboard/visual-slot.ts +5 -0
- package/src/dashboard/widget-header.module.css +6 -25
- package/src/dashboard/widget-header.tsx +8 -5
- package/src/format/shared.ts +30 -1
- package/src/guard/index.ts +5 -1
- package/src/styles.css +23 -0
- package/src/table/cell-kinds.tsx +42 -13
- package/src/table/data-table-fold.tsx +65 -12
- package/src/table/data-table.module.css +74 -2
- package/src/table/data-table.module.css.d.ts +4 -0
- package/src/table/data-table.tsx +34 -13
- package/src/theme/controls.module.css +23 -2
|
@@ -45,20 +45,24 @@
|
|
|
45
45
|
* <UsageChart />
|
|
46
46
|
* </Section>
|
|
47
47
|
*/
|
|
48
|
-
import { useEffect, useId } from 'react'
|
|
48
|
+
import { Children, cloneElement, isValidElement, useContext, useEffect, useId } from 'react'
|
|
49
49
|
import type { ReactNode } from 'react'
|
|
50
|
-
import { cx } from '../common/props'
|
|
51
|
-
import type { BasaltProps, SlotStylesProps } from '../common/props'
|
|
50
|
+
import { cx, splitDataAttributes } from '../common/props'
|
|
51
|
+
import type { BasaltProps, DataAttributes, SlotStylesProps } from '../common/props'
|
|
52
52
|
import { BASALT_PREFIX } from '../common/errors'
|
|
53
53
|
import { useValidateProps } from '../common/validate'
|
|
54
54
|
import { CtlSlot } from '../theme'
|
|
55
55
|
import { BarActionSlot } from '../controls/actions'
|
|
56
56
|
import type { SectionActions } from '../controls/actions'
|
|
57
57
|
import { useFilterSurface } from '../controls/filter-context'
|
|
58
|
-
import {
|
|
58
|
+
import { HostTitleContext } from '../common/could-not-load'
|
|
59
|
+
import { LoadingState, QueryState } from './query-state'
|
|
59
60
|
import type { QueryEmptyCopy, QueryStateLike } from './query-state'
|
|
60
61
|
import { usePersistedOrLocal } from '../state/persisted-or-local'
|
|
61
62
|
import { PAGE_BAR_HEIGHT_VAR, useInPageBarShell } from '../shell'
|
|
63
|
+
import { BarList } from './bar-list'
|
|
64
|
+
import { EventList } from './event-list'
|
|
65
|
+
import { Meter } from './meter'
|
|
62
66
|
import { WidgetHeader } from './widget-header'
|
|
63
67
|
import type { WidgetHeaderProps } from './widget-header'
|
|
64
68
|
import classes from './section.module.css'
|
|
@@ -95,6 +99,7 @@ type SectionBaseProps = Omit<
|
|
|
95
99
|
'tier' | 'classNames' | 'actions' | 'title' | HeaderOnlyKey
|
|
96
100
|
> &
|
|
97
101
|
BasaltProps &
|
|
102
|
+
DataAttributes &
|
|
98
103
|
SlotStylesProps<SectionSlot> & {
|
|
99
104
|
/**
|
|
100
105
|
* Header actions as typed data (law C15), projected through the SAME row `PageBar` uses — one
|
|
@@ -118,6 +123,14 @@ type SectionBaseProps = Omit<
|
|
|
118
123
|
* without `query`.
|
|
119
124
|
*/
|
|
120
125
|
empty?: QueryEmptyCopy
|
|
126
|
+
/**
|
|
127
|
+
* The loaded body's height in px. While `query` is pending the loading skeleton fills it, so
|
|
128
|
+
* the section does not jump when the data lands. Declared, not measured: a first load has no
|
|
129
|
+
* previous body to measure. Omitted, a body that is one `BarList`, `EventList` or `Meter`
|
|
130
|
+
* loads as that figure's own skeleton (set its `loadingRows` to the loaded count); any other
|
|
131
|
+
* body gets the three-bar default. Ignored without `query`.
|
|
132
|
+
*/
|
|
133
|
+
loadingHeight?: number
|
|
121
134
|
/** Rendered in the header row, in its own `CtlSlot` — hidden while the section is collapsed. */
|
|
122
135
|
tabs?: ReactNode
|
|
123
136
|
/** Renders a chevron toggle in the header; the header stays drawn when closed, only `children`
|
|
@@ -199,6 +212,18 @@ function ChevronToggle({
|
|
|
199
212
|
)
|
|
200
213
|
}
|
|
201
214
|
|
|
215
|
+
/**
|
|
216
|
+
* A body that is ONE figure with a row-shaped loading state loads as that figure, so the skeleton has
|
|
217
|
+
* the loaded footprint (rows, track) rather than a guess. Anything else has no shape to borrow.
|
|
218
|
+
*/
|
|
219
|
+
function figureLoading(children: ReactNode): ReactNode {
|
|
220
|
+
const only = Children.toArray(children)
|
|
221
|
+
const [child] = only
|
|
222
|
+
if (only.length !== 1 || !isValidElement<{ loading?: boolean }>(child)) return null
|
|
223
|
+
if (child.type !== BarList && child.type !== EventList && child.type !== Meter) return null
|
|
224
|
+
return cloneElement(child, { loading: true })
|
|
225
|
+
}
|
|
226
|
+
|
|
202
227
|
const ANCHOR_CLEARANCE = 'var(--vx-space-sticky-header-clearance)'
|
|
203
228
|
|
|
204
229
|
/** The `scroll-margin-top` of an anchored Section; the bar term only exists without a shell. */
|
|
@@ -211,6 +236,7 @@ export function Section({
|
|
|
211
236
|
actions,
|
|
212
237
|
query,
|
|
213
238
|
empty,
|
|
239
|
+
loadingHeight,
|
|
214
240
|
tabs,
|
|
215
241
|
collapsible = false,
|
|
216
242
|
persistKey,
|
|
@@ -224,9 +250,11 @@ export function Section({
|
|
|
224
250
|
style,
|
|
225
251
|
classNames,
|
|
226
252
|
'aria-label': ariaLabel,
|
|
227
|
-
...
|
|
253
|
+
...headerAndData
|
|
228
254
|
}: SectionProps) {
|
|
255
|
+
const { data, rest: headerProps } = splitDataAttributes(headerAndData)
|
|
229
256
|
const { title } = headerProps
|
|
257
|
+
const outerTitle = useContext(HostTitleContext)
|
|
230
258
|
const untitled = title === undefined
|
|
231
259
|
|
|
232
260
|
// A `persistKey` with nothing to fold writes a localStorage key nobody ever reads back — the
|
|
@@ -297,42 +325,56 @@ export function Section({
|
|
|
297
325
|
</>
|
|
298
326
|
) : undefined
|
|
299
327
|
|
|
328
|
+
const figure = query !== undefined && loadingHeight === undefined ? figureLoading(children) : null
|
|
329
|
+
|
|
300
330
|
return (
|
|
301
|
-
<
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
<div
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
331
|
+
<HostTitleContext value={title ?? outerTitle}>
|
|
332
|
+
<div
|
|
333
|
+
{...data}
|
|
334
|
+
className={cx(classes.root, classNames?.root, className)}
|
|
335
|
+
data-tier={tier}
|
|
336
|
+
{...(untitled && ariaLabel !== undefined && { role: 'group', 'aria-label': ariaLabel })}
|
|
337
|
+
{...(id !== undefined && { id })}
|
|
338
|
+
{...(rootStyle !== undefined && { style: rootStyle })}
|
|
339
|
+
>
|
|
340
|
+
{untitled ? (
|
|
341
|
+
<div className={cx(classes.tabsRow, classNames?.header)} data-basalt-hit-scope>
|
|
342
|
+
{headerActions}
|
|
343
|
+
</div>
|
|
344
|
+
) : (
|
|
345
|
+
<WidgetHeader
|
|
346
|
+
tier={tier}
|
|
347
|
+
{...(headerProps as Pick<WidgetHeaderProps, HeaderOnlyKey>)}
|
|
348
|
+
title={title}
|
|
349
|
+
{...(classNames?.header !== undefined && { className: classNames.header })}
|
|
350
|
+
{...(headerActions !== undefined && { actions: headerActions })}
|
|
351
|
+
/>
|
|
352
|
+
)}
|
|
353
|
+
{summary !== undefined && <div className={classes.summary}>{summary}</div>}
|
|
354
|
+
{(open || untitled) && (
|
|
355
|
+
<div id={bodyId} className={cx(classes.body, classNames?.body)}>
|
|
356
|
+
{query === undefined ? (
|
|
357
|
+
children
|
|
358
|
+
) : (
|
|
359
|
+
// `tier="section"` is the compact one: a bare spinner rather than a 64px centred
|
|
360
|
+
// block, and the error alert without the page-level stack around it. A Section IS the
|
|
361
|
+
// region, so the state belongs inside its body, never around its header.
|
|
362
|
+
<QueryState
|
|
363
|
+
query={query}
|
|
364
|
+
tier="section"
|
|
365
|
+
{...(empty !== undefined && { empty })}
|
|
366
|
+
{...(loadingHeight !== undefined
|
|
367
|
+
? {
|
|
368
|
+
loading: <LoadingState tier="section" style={{ minHeight: loadingHeight }} />,
|
|
369
|
+
}
|
|
370
|
+
: figure !== null && { loading: figure })}
|
|
371
|
+
>
|
|
372
|
+
{children}
|
|
373
|
+
</QueryState>
|
|
374
|
+
)}
|
|
375
|
+
</div>
|
|
376
|
+
)}
|
|
377
|
+
</div>
|
|
378
|
+
</HostTitleContext>
|
|
337
379
|
)
|
|
338
380
|
}
|
|
@@ -46,3 +46,9 @@
|
|
|
46
46
|
gap: var(--vx-space-stack-xs);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
+
|
|
50
|
+
/* DangerZone's ring colour: the status token mixed into the panel surface — one formula in both
|
|
51
|
+
* schemes, never an alpha over whatever sits behind it. The component layers it on `shadow-card`. */
|
|
52
|
+
.danger {
|
|
53
|
+
--danger-ring: color-mix(in srgb, var(--vx-status-bad) 40%, var(--vx-surface-panel));
|
|
54
|
+
}
|
|
@@ -33,9 +33,9 @@ import type { ReactNode } from 'react'
|
|
|
33
33
|
import { WidgetHeader } from './widget-header'
|
|
34
34
|
import type { WidgetHeaderTitleProps } from './widget-header'
|
|
35
35
|
import { CtlSlot } from '../theme'
|
|
36
|
-
import {
|
|
37
|
-
import { cx } from '../common/props'
|
|
38
|
-
import type { BasaltProps, SlotStylesProps } from '../common/props'
|
|
36
|
+
import { VX } from '../tokens'
|
|
37
|
+
import { cx, pickDataAttributes } from '../common/props'
|
|
38
|
+
import type { BasaltProps, DataAttributes, SlotStylesProps } from '../common/props'
|
|
39
39
|
import classes from './settings-section.module.css'
|
|
40
40
|
|
|
41
41
|
const eyebrowStyle = {
|
|
@@ -59,6 +59,7 @@ export type SettingsSectionSlot = 'root' | 'header' | 'body'
|
|
|
59
59
|
* slices.
|
|
60
60
|
*/
|
|
61
61
|
export type SettingsSectionProps = BasaltProps &
|
|
62
|
+
DataAttributes &
|
|
62
63
|
SlotStylesProps<SettingsSectionSlot> &
|
|
63
64
|
WidgetHeaderTitleProps & {
|
|
64
65
|
/** Header-right slot — wrapped in `CtlSlot` (C1/C5). */
|
|
@@ -77,9 +78,10 @@ export function SettingsSection({
|
|
|
77
78
|
className,
|
|
78
79
|
style,
|
|
79
80
|
classNames,
|
|
81
|
+
...rest
|
|
80
82
|
}: SettingsSectionProps) {
|
|
81
83
|
return (
|
|
82
|
-
<Card className={cx(classNames?.root, className)} style={style}>
|
|
84
|
+
<Card {...pickDataAttributes(rest)} className={cx(classNames?.root, className)} style={style}>
|
|
83
85
|
<div className={cx(classes.header, classNames?.header)}>
|
|
84
86
|
<WidgetHeader
|
|
85
87
|
tier="section"
|
|
@@ -152,12 +154,15 @@ export function DangerZone({
|
|
|
152
154
|
className,
|
|
153
155
|
style,
|
|
154
156
|
classNames,
|
|
157
|
+
...rest
|
|
155
158
|
}: DangerZoneProps) {
|
|
156
159
|
return (
|
|
157
160
|
<Card
|
|
158
|
-
|
|
161
|
+
{...pickDataAttributes(rest)}
|
|
162
|
+
className={cx(classes.danger, classNames?.root, className)}
|
|
159
163
|
style={{
|
|
160
|
-
|
|
164
|
+
// The card's depth plus ONE edge in the class's scheme-independent ring colour.
|
|
165
|
+
boxShadow: `${VX.shadowCard}, 0 0 0 1px var(--danger-ring)`,
|
|
161
166
|
...style,
|
|
162
167
|
}}
|
|
163
168
|
>
|
|
@@ -437,6 +437,17 @@
|
|
|
437
437
|
padding-top: var(--basalt-spark-readout-reserve);
|
|
438
438
|
}
|
|
439
439
|
|
|
440
|
+
/* A sparkline that states its window has a caption line under its plot: the slot grows by it rather than
|
|
441
|
+
* letting the caption run into the footer. */
|
|
442
|
+
.sparklineBleed:has([data-basalt-sparkline-caption]) {
|
|
443
|
+
height: auto;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
/* The slot bleeds past the card's inset, the plot with it; the caption is text and takes the inset back. */
|
|
447
|
+
.sparklineBleed [data-basalt-sparkline-caption] {
|
|
448
|
+
padding-inline: var(--vx-space-card-inset-x, 1rem);
|
|
449
|
+
}
|
|
450
|
+
|
|
440
451
|
/* A Meter in the visual slot is a block, not a chart: it sizes to its content and keeps the card's
|
|
441
452
|
* inline inset instead of the sparkline's fixed 22px and side bleed. */
|
|
442
453
|
.sparklineBleed:has(> [data-basalt-meter]) {
|
|
@@ -107,14 +107,16 @@ import type {
|
|
|
107
107
|
WidgetHeaderTitleProps,
|
|
108
108
|
} from './widget-header'
|
|
109
109
|
import { DeltaBadge } from './delta-badge'
|
|
110
|
-
import { cx } from '../common/props'
|
|
111
|
-
import type { BasaltProps, SlotStylesProps, Tone } from '../common/props'
|
|
110
|
+
import { cx, pickDataAttributes } from '../common/props'
|
|
111
|
+
import type { BasaltProps, DataAttributes, SlotStylesProps, Tone } from '../common/props'
|
|
112
112
|
import { splitEmptyCopy } from '../common/empty-copy'
|
|
113
113
|
import { EmptyState } from './empty-state'
|
|
114
|
+
import { couldNotLoad, HostTitleContext } from '../common/could-not-load'
|
|
114
115
|
import { ErrorState, QueryState, resolveQueryBranch } from './query-state'
|
|
115
116
|
import type { QueryBranch, QueryStateLike } from './query-state'
|
|
116
117
|
import classes from './stat-card.module.css'
|
|
117
|
-
import { HOSTED, VisualSlotContext } from './visual-slot'
|
|
118
|
+
import { HOSTED, HOSTED_COMPACT, VisualSlotContext } from './visual-slot'
|
|
119
|
+
import type { VisualSlot } from './visual-slot'
|
|
118
120
|
|
|
119
121
|
/**
|
|
120
122
|
* The boxes `StatCard` paints, and the whole styling seam it offers (`common/props.ts`).
|
|
@@ -210,6 +212,7 @@ function useSlotWidth(active: boolean): {
|
|
|
210
212
|
* three slices.
|
|
211
213
|
*/
|
|
212
214
|
export type StatCardProps = BasaltProps &
|
|
215
|
+
DataAttributes &
|
|
213
216
|
SlotStylesProps<StatCardSlot> &
|
|
214
217
|
Omit<WidgetHeaderTitleProps, 'subtitle'> &
|
|
215
218
|
Omit<WidgetHeaderMetricProps, 'value'> &
|
|
@@ -313,8 +316,10 @@ function renderValueBody({
|
|
|
313
316
|
figure,
|
|
314
317
|
emptyText,
|
|
315
318
|
hasDelta,
|
|
319
|
+
label,
|
|
316
320
|
}: {
|
|
317
321
|
hasDelta: boolean
|
|
322
|
+
label: string | undefined
|
|
318
323
|
pending: boolean
|
|
319
324
|
resolved: QueryBranch<unknown> | undefined
|
|
320
325
|
figure: ReactNode
|
|
@@ -333,7 +338,7 @@ function renderValueBody({
|
|
|
333
338
|
return (
|
|
334
339
|
<ErrorState
|
|
335
340
|
error={resolved.error}
|
|
336
|
-
title=
|
|
341
|
+
title={couldNotLoad(label)}
|
|
337
342
|
tier="section"
|
|
338
343
|
onRetry={() => void resolved.query.refetch()}
|
|
339
344
|
retrying={resolved.query.fetchStatus === 'fetching'}
|
|
@@ -390,6 +395,18 @@ function renderFooterNode({
|
|
|
390
395
|
)
|
|
391
396
|
}
|
|
392
397
|
|
|
398
|
+
/** One shared slot object per tone and size, so a provider never re-renders its readers (`visual-slot.ts`). */
|
|
399
|
+
const toneSlots = new Map<string, VisualSlot>()
|
|
400
|
+
function slotFor(tone: Tone | undefined, compact: boolean): VisualSlot {
|
|
401
|
+
if (tone === undefined) return compact ? HOSTED_COMPACT : HOSTED
|
|
402
|
+
const key = `${tone}:${compact}`
|
|
403
|
+
const known = toneSlots.get(key)
|
|
404
|
+
if (known !== undefined) return known
|
|
405
|
+
const slot: VisualSlot = compact ? { tone, compact: true } : { tone }
|
|
406
|
+
toneSlots.set(key, slot)
|
|
407
|
+
return slot
|
|
408
|
+
}
|
|
409
|
+
|
|
393
410
|
export function StatCard({
|
|
394
411
|
title,
|
|
395
412
|
icon,
|
|
@@ -414,6 +431,7 @@ export function StatCard({
|
|
|
414
431
|
className,
|
|
415
432
|
style,
|
|
416
433
|
classNames,
|
|
434
|
+
...rest
|
|
417
435
|
}: StatCardProps) {
|
|
418
436
|
const isRender = typeof sparkline === 'function'
|
|
419
437
|
const bleeds = sparklinePlacement === 'bleed'
|
|
@@ -449,13 +467,16 @@ export function StatCard({
|
|
|
449
467
|
query === undefined ? (
|
|
450
468
|
breakdownRows
|
|
451
469
|
) : (
|
|
452
|
-
<
|
|
453
|
-
{
|
|
454
|
-
|
|
470
|
+
<HostTitleContext value={title}>
|
|
471
|
+
<QueryState query={query} tier="section">
|
|
472
|
+
{breakdownRows}
|
|
473
|
+
</QueryState>
|
|
474
|
+
</HostTitleContext>
|
|
455
475
|
)
|
|
456
476
|
|
|
457
477
|
// Built ONLY when ready: the render prop must not run in a pending / failed / empty branch, where
|
|
458
478
|
// the last measured width is stale.
|
|
479
|
+
const hostSlot = slotFor(tone, !bleeds)
|
|
459
480
|
const sparklineSlot: ReactNode =
|
|
460
481
|
!ready || sparkline === undefined ? null : (
|
|
461
482
|
<div
|
|
@@ -468,7 +489,7 @@ export function StatCard({
|
|
|
468
489
|
>
|
|
469
490
|
{/* A measured slot renders nothing on the first commit (width 0) — an SVG at width 0 is a
|
|
470
491
|
visible 0-width box that then jumps, which is worse than one frame of nothing. */}
|
|
471
|
-
<VisualSlotContext.Provider value={
|
|
492
|
+
<VisualSlotContext.Provider value={hostSlot}>
|
|
472
493
|
{isRender ? measured.width > 0 && sparkline(measured) : sparkline}
|
|
473
494
|
</VisualSlotContext.Provider>
|
|
474
495
|
</div>
|
|
@@ -498,6 +519,7 @@ export function StatCard({
|
|
|
498
519
|
figure,
|
|
499
520
|
emptyText,
|
|
500
521
|
hasDelta: delta !== undefined,
|
|
522
|
+
label: title,
|
|
501
523
|
})
|
|
502
524
|
|
|
503
525
|
const breakdownCount = breakdown?.length ?? 0
|
|
@@ -516,6 +538,7 @@ export function StatCard({
|
|
|
516
538
|
|
|
517
539
|
return (
|
|
518
540
|
<Card
|
|
541
|
+
{...pickDataAttributes(rest)}
|
|
519
542
|
className={cx(classNames?.root, className)}
|
|
520
543
|
style={{
|
|
521
544
|
// The inset is the theme's (`card-inset.module.css`: the `cardInsetY`/`cardInsetX` tokens, 12/16
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
* </StatGroup>
|
|
34
34
|
*/
|
|
35
35
|
import type { CSSProperties, ReactNode } from 'react'
|
|
36
|
-
import { cx } from '../common/props'
|
|
37
|
-
import type { BasaltProps } from '../common/props'
|
|
36
|
+
import { cx, pickDataAttributes } from '../common/props'
|
|
37
|
+
import type { BasaltProps, DataAttributes } from '../common/props'
|
|
38
38
|
import { StatStrip } from './stat-strip'
|
|
39
39
|
import type { StatStripProps } from './stat-strip'
|
|
40
40
|
import classes from './stat-group.module.css'
|
|
@@ -42,16 +42,17 @@ import classes from './stat-group.module.css'
|
|
|
42
42
|
/** The desktop KPI column count. */
|
|
43
43
|
export type StatGroupCols = 2 | 3 | 4 | 5
|
|
44
44
|
|
|
45
|
-
export type StatGridProps = BasaltProps &
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
45
|
+
export type StatGridProps = BasaltProps &
|
|
46
|
+
DataAttributes & {
|
|
47
|
+
variant?: 'grid'
|
|
48
|
+
/** The DESKTOP column count (`lg` and up). Default `4`. `sm` gets `min(cols, 3)` — except `4`, which gets 2 rather than an orphan row. A phone gets 2.
|
|
49
|
+
* Never a responsive object — the law is basalt's, see the module docblock. */
|
|
50
|
+
cols?: StatGroupCols
|
|
51
|
+
/** Swap the column gap for a hairline rail between cells. Default `false`. */
|
|
52
|
+
divided?: boolean
|
|
53
|
+
/** The KPI cells — normally `StatCard`s. */
|
|
54
|
+
children: ReactNode
|
|
55
|
+
}
|
|
55
56
|
|
|
56
57
|
/** `variant="strip"`: one joined surface of typed `cells` split by hairlines, plus an optional
|
|
57
58
|
* `footer` row — see `StatStripProps`. `cols` here may be 6 (the strip's desktop count). */
|
|
@@ -65,7 +66,14 @@ export function StatGroup(props: StatGroupProps) {
|
|
|
65
66
|
return <StatGrid {...props} />
|
|
66
67
|
}
|
|
67
68
|
|
|
68
|
-
function StatGrid({
|
|
69
|
+
function StatGrid({
|
|
70
|
+
cols = 4,
|
|
71
|
+
divided = false,
|
|
72
|
+
children,
|
|
73
|
+
className,
|
|
74
|
+
style,
|
|
75
|
+
...rest
|
|
76
|
+
}: StatGridProps) {
|
|
69
77
|
// `4 -> 2`, not `4 -> 3`. `min(cols, 3)` is the general rule and it is right for 2, 3 and 5, but
|
|
70
78
|
// FOUR is the default and the overwhelmingly common count, and three columns leave a four-KPI row
|
|
71
79
|
// as 3 + 1 — one orphan cell against two thirds of empty track. MEASURED on the playground
|
|
@@ -82,7 +90,7 @@ function StatGrid({ cols = 4, divided = false, children, className, style }: Sta
|
|
|
82
90
|
// sized is the whole point. `container-type: inline-size` contains the inline axis only, so the
|
|
83
91
|
// wrapper's block size still comes from the grid: no percentage height resolves differently,
|
|
84
92
|
// and there is no paint containment, so nothing inside is clipped.
|
|
85
|
-
<div className={cx(classes.container, className)} style={style}>
|
|
93
|
+
<div {...pickDataAttributes(rest)} className={cx(classes.container, className)} style={style}>
|
|
86
94
|
<div
|
|
87
95
|
className={classes.root}
|
|
88
96
|
data-cols={cols}
|
|
@@ -36,9 +36,6 @@
|
|
|
36
36
|
min-width: 0;
|
|
37
37
|
container-type: inline-size;
|
|
38
38
|
container-name: basalt-card;
|
|
39
|
-
/* The foot inset lives HERE, on the row-high slot, so a cell that ends early keeps the strip's
|
|
40
|
-
* surface under it. */
|
|
41
|
-
padding-block-end: var(--vx-space-stack-md);
|
|
42
39
|
box-shadow:
|
|
43
40
|
-1px 0 0 var(--vx-divider),
|
|
44
41
|
0 -1px 0 var(--vx-divider);
|
|
@@ -50,7 +47,7 @@
|
|
|
50
47
|
flex-direction: column;
|
|
51
48
|
align-self: start;
|
|
52
49
|
min-width: 0;
|
|
53
|
-
padding: var(--vx-space-stack-md)
|
|
50
|
+
padding: var(--vx-space-stack-md);
|
|
54
51
|
}
|
|
55
52
|
|
|
56
53
|
/* Forced colors drop box-shadows, so the hairlines come back as CanvasText borders. Every cell takes
|
|
@@ -166,6 +163,8 @@
|
|
|
166
163
|
* it, whether it sat beside the caption or wrapped under it, so values share a baseline. */
|
|
167
164
|
@container basalt-card (max-width: 239.9px) {
|
|
168
165
|
.qualifier {
|
|
166
|
+
/* Always on its own line under the caption: whether it fits beside it must not vary cell to cell. */
|
|
167
|
+
flex-basis: 100%;
|
|
169
168
|
line-height: 1.25;
|
|
170
169
|
}
|
|
171
170
|
|
|
@@ -390,7 +389,7 @@
|
|
|
390
389
|
.underCell {
|
|
391
390
|
min-width: 0;
|
|
392
391
|
font-size: var(--vx-text-sm);
|
|
393
|
-
margin: var(--vx-space-stack-md)
|
|
392
|
+
margin: var(--vx-space-stack-md);
|
|
394
393
|
padding-block-start: var(--vx-space-stack-sm);
|
|
395
394
|
border-block-start: 1px solid var(--vx-divider);
|
|
396
395
|
}
|
|
@@ -45,14 +45,15 @@ import { useId, useRef } from 'react'
|
|
|
45
45
|
import type { CSSProperties, ReactNode } from 'react'
|
|
46
46
|
import { toErrorMessage } from '../common/errors'
|
|
47
47
|
import { useIsomorphicLayoutEffect } from '../common/isomorphic-layout-effect'
|
|
48
|
-
import { cx } from '../common/props'
|
|
49
|
-
import type { BasaltProps, Tone } from '../common/props'
|
|
48
|
+
import { cx, pickDataAttributes } from '../common/props'
|
|
49
|
+
import type { BasaltProps, DataAttributes, Tone } from '../common/props'
|
|
50
50
|
import { RetryButton } from '../common/retry-button'
|
|
51
51
|
import { StatusDot } from '../theme/status-dot'
|
|
52
52
|
import { VX } from '../tokens'
|
|
53
53
|
import { InfoGlyph } from './widget-header'
|
|
54
54
|
import classes from './stat-strip.module.css'
|
|
55
|
-
import {
|
|
55
|
+
import { couldNotLoad } from '../common/could-not-load'
|
|
56
|
+
import { HOSTED, HOSTED_LOADING, HOSTED_COMPACT, VisualSlotContext } from './visual-slot'
|
|
56
57
|
|
|
57
58
|
/** The URL shot states an anchor can declare itself absent in (`data-shot-absent`). */
|
|
58
59
|
type StatStripShotState = 'empty' | 'loading' | 'error'
|
|
@@ -140,21 +141,23 @@ export type StatStripFooterEntry = {
|
|
|
140
141
|
shotAbsent?: readonly StatStripShotState[]
|
|
141
142
|
}
|
|
142
143
|
|
|
143
|
-
export type StatStripProps = BasaltProps &
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
144
|
+
export type StatStripProps = BasaltProps &
|
|
145
|
+
DataAttributes & {
|
|
146
|
+
/** The strip's accessible name. */
|
|
147
|
+
label: string
|
|
148
|
+
cells: readonly StatStripCell[]
|
|
149
|
+
/** Wider cells under the cells. */
|
|
150
|
+
footer?: readonly StatStripFooterEntry[]
|
|
151
|
+
/** The DESKTOP column count. Default: the cell count, capped at 6. A lone cell takes the whole strip
|
|
152
|
+
* whatever `cols` says. */
|
|
153
|
+
cols?: 2 | 3 | 4 | 5 | 6
|
|
154
|
+
/** The shot states the page hides the whole strip in (`data-shot-absent` on every derived anchor). */
|
|
155
|
+
shotAbsent?: readonly StatStripShotState[]
|
|
156
|
+
}
|
|
154
157
|
|
|
155
158
|
const EMPTY = '—'
|
|
156
159
|
|
|
157
|
-
function CellState({ state }: { state: StatStripCellState }) {
|
|
160
|
+
function CellState({ state, caption }: { state: StatStripCellState; caption: string }) {
|
|
158
161
|
if (state.kind === 'empty') {
|
|
159
162
|
// A stated reason IS the gap: it takes the value's place, so no bare dash sits above it.
|
|
160
163
|
if (state.reason !== undefined) {
|
|
@@ -177,7 +180,7 @@ function CellState({ state }: { state: StatStripCellState }) {
|
|
|
177
180
|
<div className={classes.error} role="alert" data-strip-state="error">
|
|
178
181
|
<span className={classes.errorHead}>
|
|
179
182
|
<StatusDot color={VX.status.bad} />
|
|
180
|
-
|
|
183
|
+
{couldNotLoad(caption)}
|
|
181
184
|
</span>
|
|
182
185
|
<p className={classes.reason}>{message}</p>
|
|
183
186
|
{state.onRetry !== undefined && (
|
|
@@ -311,7 +314,7 @@ function StripCell({
|
|
|
311
314
|
</span>
|
|
312
315
|
)}
|
|
313
316
|
</div>
|
|
314
|
-
{state !== undefined && <CellState state={state} />}
|
|
317
|
+
{state !== undefined && <CellState state={state} caption={cell.caption} />}
|
|
315
318
|
{state === undefined && hasHero && heroEl}
|
|
316
319
|
</div>
|
|
317
320
|
{state === undefined && cell.visual !== undefined && (
|
|
@@ -338,7 +341,7 @@ function StripCell({
|
|
|
338
341
|
<li key={row.key} className={classes.row} data-strip-row={row.key}>
|
|
339
342
|
<span className={classes.rowLabel}>{row.label}</span>
|
|
340
343
|
<span className={classes.visual}>
|
|
341
|
-
<VisualSlotContext.Provider value={
|
|
344
|
+
<VisualSlotContext.Provider value={HOSTED_COMPACT}>
|
|
342
345
|
{row.visual}
|
|
343
346
|
</VisualSlotContext.Provider>
|
|
344
347
|
</span>
|
|
@@ -407,8 +410,10 @@ export function StatStrip({
|
|
|
407
410
|
shotAbsent,
|
|
408
411
|
className,
|
|
409
412
|
style,
|
|
413
|
+
...domProps
|
|
410
414
|
}: StatStripProps) {
|
|
411
|
-
|
|
415
|
+
// A lone cell is the whole strip: a stated `cols` would leave it one track of an empty grid.
|
|
416
|
+
const desktop = cells.length === 1 ? 1 : (cols ?? Math.min(Math.max(cells.length, 2), 6))
|
|
412
417
|
// `StatGroup`'s rule: four is 2 + 2 below the full count, never 3 + 1.
|
|
413
418
|
const mid = desktop === 4 ? 2 : Math.min(desktop, 3)
|
|
414
419
|
const keys = new Set(cells.map((cell) => cell.key))
|
|
@@ -458,7 +463,11 @@ export function StatStrip({
|
|
|
458
463
|
for (const head of grid.querySelectorAll('[data-strip-head]')) observer.observe(head)
|
|
459
464
|
}, [cells, footer])
|
|
460
465
|
return (
|
|
461
|
-
<div
|
|
466
|
+
<div
|
|
467
|
+
{...pickDataAttributes(domProps)}
|
|
468
|
+
className={cx(classes.container, className)}
|
|
469
|
+
style={style}
|
|
470
|
+
>
|
|
462
471
|
<Card>
|
|
463
472
|
<Card.Section
|
|
464
473
|
component="section"
|
|
@@ -11,6 +11,8 @@ export interface VisualSlot {
|
|
|
11
11
|
readonly tone?: Tone
|
|
12
12
|
/** The host is loading: a `Meter` in the slot draws its loading state without its own `loading`. */
|
|
13
13
|
readonly loading?: boolean
|
|
14
|
+
/** A slot with no room for a caption (a multi-row cell's row, a `right`-placed sparkline): its `Sparkline` states no window of its own. */
|
|
15
|
+
readonly compact?: true
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
/** A host with no verdict of its own: one shared object, so a provider never re-renders its readers. */
|
|
@@ -19,4 +21,7 @@ export const HOSTED: VisualSlot = {}
|
|
|
19
21
|
/** `HOSTED` while the host loads. */
|
|
20
22
|
export const HOSTED_LOADING: VisualSlot = { loading: true }
|
|
21
23
|
|
|
24
|
+
/** A slot too small for a caption under its visual. */
|
|
25
|
+
export const HOSTED_COMPACT: VisualSlot = { compact: true }
|
|
26
|
+
|
|
22
27
|
export const VisualSlotContext = createContext<VisualSlot | null>(null)
|