basalt-ui 2.27.2 → 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 +466 -307
- package/MIGRATING.md +358 -12
- package/agent/rules/basalt-batteries.md +1 -1
- package/agent/rules/basalt-mantine.md +1 -1
- package/agent/rules/basalt-tokens.md +2 -2
- 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 +12 -6
- package/agent/skills/basalt-design/references/catalogue.md +42 -36
- package/agent/skills/basalt-design/references/recipes.md +47 -0
- package/agent/skills/basalt-design/references/states.md +1 -1
- package/configs/oxlint-basalt.json +2 -1
- package/configs/oxlint-plugin.js +112 -3
- package/configs/oxlint-plugin.test.ts +99 -4
- package/configs/oxlint.json +1 -0
- package/dist/agent/chat/thread-message.d.ts +1 -160
- package/dist/agent/chat/thread-message.d.ts.map +1 -1
- package/dist/agent/chat/thread-message.js +7 -162
- package/dist/agent/chat/virtualize.d.ts +5 -5
- package/dist/charts/ChartCard.d.ts +14 -7
- package/dist/charts/ChartCard.d.ts.map +1 -1
- package/dist/charts/ChartCard.js +112 -23
- package/dist/charts/Lines.d.ts.map +1 -1
- package/dist/charts/Lines.js +11 -4
- package/dist/charts/Sparkline.d.ts +14 -2
- package/dist/charts/Sparkline.d.ts.map +1 -1
- package/dist/charts/Sparkline.js +155 -44
- package/dist/charts/chart-box.module.css +59 -2
- package/dist/charts/chart-box.module.css.d.ts +5 -0
- package/dist/charts/chart-card.module.css +28 -17
- package/dist/charts/chart-card.module.css.d.ts +3 -0
- package/dist/charts/compile.d.ts +1 -1
- package/dist/charts/compile.d.ts.map +1 -1
- package/dist/charts/compile.js +38 -27
- package/dist/charts/labels.d.ts +13 -3
- package/dist/charts/labels.d.ts.map +1 -1
- package/dist/charts/labels.js +131 -20
- package/dist/charts/legend.d.ts.map +1 -1
- package/dist/charts/legend.js +1 -1
- package/dist/charts/ref-label.d.ts +37 -8
- package/dist/charts/ref-label.d.ts.map +1 -1
- package/dist/charts/ref-label.js +55 -10
- package/dist/charts/sparkline.module.css +50 -0
- package/dist/charts/sparkline.module.css.d.ts +3 -0
- package/dist/charts/state.d.ts +4 -4
- package/dist/charts/state.d.ts.map +1 -1
- package/dist/charts/state.js +23 -5
- 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 +34 -2
- package/dist/cli/shot/capture.d.ts.map +1 -1
- package/dist/cli/shot/capture.js +95 -12
- 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/empty-copy.d.ts +16 -0
- package/dist/common/empty-copy.d.ts.map +1 -0
- package/dist/common/empty-copy.js +9 -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/common/virtual-rows.d.ts +196 -0
- package/dist/common/virtual-rows.d.ts.map +1 -0
- package/dist/common/virtual-rows.js +290 -0
- package/dist/controls/controls.module.css +33 -1
- package/dist/controls/controls.module.css.d.ts +2 -0
- package/dist/controls/enum-filter.d.ts.map +1 -1
- package/dist/controls/enum-filter.js +8 -2
- package/dist/controls/filter-pill.d.ts +27 -3
- package/dist/controls/filter-pill.d.ts.map +1 -1
- package/dist/controls/filter-pill.js +15 -4
- package/dist/controls/form-layout.d.ts +9 -3
- package/dist/controls/form-layout.d.ts.map +1 -1
- package/dist/controls/form-layout.js +74 -12
- package/dist/controls/form-layout.module.css +112 -7
- package/dist/controls/form-layout.module.css.d.ts +1 -0
- package/dist/controls/multi-select-filter.d.ts +2 -2
- package/dist/controls/multi-select-filter.d.ts.map +1 -1
- package/dist/controls/multi-select-filter.js +12 -6
- package/dist/controls/range-filter.d.ts +1 -1
- package/dist/controls/range-filter.d.ts.map +1 -1
- package/dist/controls/range-filter.js +8 -2
- package/dist/dashboard/bar-list.d.ts +5 -5
- package/dist/dashboard/bar-list.d.ts.map +1 -1
- package/dist/dashboard/bar-list.js +15 -8
- package/dist/dashboard/bar-list.module.css +21 -5
- package/dist/dashboard/board-nav.d.ts +22 -0
- package/dist/dashboard/board-nav.d.ts.map +1 -0
- package/dist/dashboard/board-nav.js +49 -0
- package/dist/dashboard/board.d.ts +52 -0
- package/dist/dashboard/board.d.ts.map +1 -0
- package/dist/dashboard/board.js +247 -0
- package/dist/dashboard/board.module.css +179 -0
- package/dist/dashboard/board.module.css.d.ts +28 -0
- package/dist/dashboard/empty-state.d.ts +6 -6
- package/dist/dashboard/empty-state.d.ts.map +1 -1
- package/dist/dashboard/empty-state.js +17 -8
- package/dist/dashboard/event-list-model.d.ts +54 -0
- package/dist/dashboard/event-list-model.d.ts.map +1 -0
- package/dist/dashboard/event-list-model.js +76 -0
- package/dist/dashboard/event-list-rows.d.ts +23 -0
- package/dist/dashboard/event-list-rows.d.ts.map +1 -0
- package/dist/dashboard/event-list-rows.js +89 -0
- package/dist/dashboard/event-list-scroll.d.ts +55 -0
- package/dist/dashboard/event-list-scroll.d.ts.map +1 -0
- package/dist/dashboard/event-list-scroll.js +216 -0
- package/dist/dashboard/event-list-skeleton.d.ts +10 -0
- package/dist/dashboard/event-list-skeleton.d.ts.map +1 -0
- package/dist/dashboard/event-list-skeleton.js +34 -0
- package/dist/dashboard/event-list.d.ts +65 -0
- package/dist/dashboard/event-list.d.ts.map +1 -0
- package/dist/dashboard/event-list.js +208 -0
- package/dist/dashboard/event-list.module.css +336 -0
- package/dist/dashboard/event-list.module.css.d.ts +34 -0
- package/dist/dashboard/index.d.ts +2 -0
- package/dist/dashboard/index.d.ts.map +1 -1
- package/dist/dashboard/index.js +4 -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 +36 -6
- 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 +20 -12
- 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 +29 -11
- 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 +8 -5
- package/dist/dashboard/settings-section.d.ts.map +1 -1
- package/dist/dashboard/settings-section.js +12 -8
- package/dist/dashboard/settings-section.module.css +25 -4
- package/dist/dashboard/settings-section.module.css.d.ts +1 -0
- package/dist/dashboard/stat-card-parts.d.ts +5 -1
- package/dist/dashboard/stat-card-parts.d.ts.map +1 -1
- package/dist/dashboard/stat-card-parts.js +8 -3
- 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 +47 -12
- package/dist/dashboard/stat-card.module.css +42 -7
- package/dist/dashboard/stat-card.module.css.d.ts +3 -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 +8 -6
- 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 +12 -15
- 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 +4 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/shell/app-main.module.css +18 -0
- package/dist/styles.css +69 -0
- package/dist/surfaces.d.ts +2 -2
- package/dist/surfaces.d.ts.map +1 -1
- package/dist/surfaces.js +8 -2
- package/dist/table/cell-kinds.d.ts +47 -0
- package/dist/table/cell-kinds.d.ts.map +1 -0
- package/dist/table/cell-kinds.js +180 -0
- package/dist/table/cell-kinds.module.css +55 -0
- package/dist/table/cell-kinds.module.css.d.ts +15 -0
- package/dist/table/data-table-fold.d.ts +155 -0
- package/dist/table/data-table-fold.d.ts.map +1 -0
- package/dist/table/data-table-fold.js +320 -0
- package/dist/table/data-table-state.d.ts +10 -3
- package/dist/table/data-table-state.d.ts.map +1 -1
- package/dist/table/data-table-state.js +11 -6
- package/dist/table/data-table.d.ts +13 -28
- package/dist/table/data-table.d.ts.map +1 -1
- package/dist/table/data-table.js +362 -255
- package/dist/table/data-table.module.css +282 -3
- package/dist/table/data-table.module.css.d.ts +16 -0
- package/dist/table/table-features.d.ts +34 -4
- package/dist/table/table-features.d.ts.map +1 -1
- package/dist/table/table-features.js +10 -0
- package/dist/theme/card-inset.module.css +35 -0
- package/dist/theme/controls.module.css +55 -2
- package/dist/theme/ctl-theme.d.ts.map +1 -1
- package/dist/theme/ctl-theme.js +5 -0
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +14 -10
- package/dist/tokens/core.d.ts +1 -0
- package/dist/tokens/core.d.ts.map +1 -1
- package/dist/tokens/core.js +1 -0
- package/dist/tokens/derive.js +1 -1
- package/dist/tokens/palette.d.ts +2 -1
- package/dist/tokens/palette.d.ts.map +1 -1
- package/llms.txt +295 -5
- package/package.json +1 -1
- package/src/agent/chat/thread-message.tsx +10 -403
- package/src/agent/chat/virtualize.ts +5 -5
- package/src/charts/ChartCard.tsx +175 -31
- package/src/charts/Lines.tsx +13 -4
- package/src/charts/Sparkline.tsx +213 -48
- package/src/charts/chart-box.module.css +59 -2
- package/src/charts/chart-box.module.css.d.ts +5 -0
- package/src/charts/chart-card.module.css +28 -17
- package/src/charts/chart-card.module.css.d.ts +3 -0
- package/src/charts/compile.ts +59 -33
- package/src/charts/labels.ts +175 -24
- package/src/charts/legend.tsx +3 -2
- package/src/charts/ref-label.ts +114 -18
- package/src/charts/sparkline.module.css +50 -0
- package/src/charts/sparkline.module.css.d.ts +3 -0
- package/src/charts/state.tsx +40 -10
- 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 +138 -16
- 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/empty-copy.ts +17 -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/common/virtual-rows.tsx +682 -0
- package/src/controls/controls.module.css +33 -1
- package/src/controls/controls.module.css.d.ts +2 -0
- package/src/controls/enum-filter.tsx +8 -2
- package/src/controls/filter-pill.tsx +80 -27
- package/src/controls/form-layout.module.css +112 -7
- package/src/controls/form-layout.module.css.d.ts +1 -0
- package/src/controls/form-layout.tsx +115 -22
- package/src/controls/multi-select-filter.tsx +22 -11
- package/src/controls/range-filter.tsx +9 -3
- package/src/dashboard/bar-list.module.css +21 -5
- package/src/dashboard/bar-list.tsx +53 -45
- package/src/dashboard/board-nav.ts +67 -0
- package/src/dashboard/board.module.css +179 -0
- package/src/dashboard/board.module.css.d.ts +28 -0
- package/src/dashboard/board.tsx +415 -0
- package/src/dashboard/empty-state.tsx +21 -11
- package/src/dashboard/event-list-model.ts +125 -0
- package/src/dashboard/event-list-rows.tsx +117 -0
- package/src/dashboard/event-list-scroll.ts +291 -0
- package/src/dashboard/event-list-skeleton.tsx +62 -0
- package/src/dashboard/event-list.module.css +336 -0
- package/src/dashboard/event-list.module.css.d.ts +34 -0
- package/src/dashboard/event-list.tsx +336 -0
- package/src/dashboard/index.ts +2 -0
- package/src/dashboard/meter-model.ts +16 -7
- package/src/dashboard/meter-parts.tsx +53 -14
- package/src/dashboard/meter.module.css +20 -12
- 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 +55 -30
- package/src/dashboard/section.tsx +83 -41
- package/src/dashboard/settings-section.module.css +25 -4
- package/src/dashboard/settings-section.module.css.d.ts +1 -0
- package/src/dashboard/settings-section.tsx +18 -8
- package/src/dashboard/stat-card-parts.tsx +20 -3
- package/src/dashboard/stat-card.module.css +42 -7
- package/src/dashboard/stat-card.module.css.d.ts +3 -0
- package/src/dashboard/stat-card.tsx +55 -13
- package/src/dashboard/stat-group.tsx +22 -14
- package/src/dashboard/stat-strip.module.css +8 -6
- package/src/dashboard/stat-strip.tsx +29 -20
- package/src/dashboard/visual-slot.ts +5 -0
- package/src/dashboard/widget-header.module.css +12 -15
- package/src/dashboard/widget-header.tsx +8 -5
- package/src/format/shared.ts +30 -1
- package/src/guard/index.ts +7 -1
- package/src/index.ts +4 -0
- package/src/shell/app-main.module.css +18 -0
- package/src/styles.css +69 -0
- package/src/surfaces.ts +7 -1
- package/src/table/cell-kinds.module.css +55 -0
- package/src/table/cell-kinds.module.css.d.ts +15 -0
- package/src/table/cell-kinds.tsx +263 -0
- package/src/table/data-table-fold.tsx +567 -0
- package/src/table/data-table-state.ts +24 -13
- package/src/table/data-table.module.css +282 -3
- package/src/table/data-table.module.css.d.ts +16 -0
- package/src/table/data-table.tsx +430 -362
- package/src/table/table-features.ts +44 -4
- package/src/theme/__snapshots__/plain-theme.test.ts.snap +2 -66
- package/src/theme/card-inset.module.css +35 -0
- package/src/theme/controls.module.css +55 -2
- package/src/theme/ctl-theme.tsx +8 -0
- package/src/theme/index.ts +12 -8
- package/src/tokens/core.ts +1 -0
- package/src/tokens/derive.ts +1 -1
- package/src/tokens/palette.ts +4 -1
package/src/dashboard/index.ts
CHANGED
|
@@ -10,3 +10,5 @@ export { SettingsSection, SettingsRow, DangerZone } from './settings-section'
|
|
|
10
10
|
export { Meter, type MeterProps } from './meter'
|
|
11
11
|
export type { MeterSegment, MeterTick, MeterZone } from './meter-model'
|
|
12
12
|
export { BarList, type BarListProps } from './bar-list'
|
|
13
|
+
export { EventList, type EventListProps } from './event-list'
|
|
14
|
+
export { Board, type BoardProps } from './board'
|
|
@@ -10,8 +10,9 @@ export type MeterSegment = {
|
|
|
10
10
|
label: string
|
|
11
11
|
color?: string
|
|
12
12
|
/**
|
|
13
|
-
* `'muted'`: the part takes the one flat muted fill every muted part shares, a
|
|
14
|
-
* between neighbours (never a lightness step). A `color` wins.
|
|
13
|
+
* `'muted'`: the part takes the one flat muted fill every muted part shares, a visible 2px
|
|
14
|
+
* separator between neighbours (never a lightness step). A `color` wins. Give each categorical part its own
|
|
15
|
+
* series `color`; `muted` is for a tail "other" part, and a bar of only muted parts reads as one slab.
|
|
15
16
|
*/
|
|
16
17
|
tone?: 'muted'
|
|
17
18
|
forecast?: boolean
|
|
@@ -87,7 +88,7 @@ export type Part = {
|
|
|
87
88
|
readonly size: number
|
|
88
89
|
readonly color: string | undefined
|
|
89
90
|
readonly forecast: boolean
|
|
90
|
-
/** A
|
|
91
|
+
/** A categorical part right after another: a 2px separator (not a hairline) keeps neighbours, muted ones included, apart. */
|
|
91
92
|
readonly seam: boolean
|
|
92
93
|
readonly label: string
|
|
93
94
|
/** The segment's own (normalised) amount, in the reading's units — what its caption states. */
|
|
@@ -205,11 +206,18 @@ export function normalizeSegments(segments: readonly MeterSegment[]): MeterSegme
|
|
|
205
206
|
return segments.map((s) => ({ ...s, value: Number.isFinite(s.value) ? Math.max(0, s.value) : 0 }))
|
|
206
207
|
}
|
|
207
208
|
|
|
209
|
+
const isMuted = (s: MeterSegment) => s.tone === 'muted' && s.color === undefined && !s.forecast
|
|
210
|
+
|
|
211
|
+
/** Three or more categorical parts that all take the one muted fill read as a single slab. */
|
|
212
|
+
export function allPartsMuted(segments: readonly MeterSegment[]): boolean {
|
|
213
|
+
const parts = segments.filter((s) => s.forecast !== true)
|
|
214
|
+
return parts.length >= 3 && parts.every(isMuted)
|
|
215
|
+
}
|
|
216
|
+
|
|
208
217
|
/** Segment amounts (already normalised) accumulate from `min`; a part never passes the track end. */
|
|
209
218
|
export function layoutSegments(segments: readonly MeterSegment[], span: number): Part[] {
|
|
210
219
|
let cursor = 0
|
|
211
|
-
|
|
212
|
-
let prevMuted = false
|
|
220
|
+
let prevCategorical = false
|
|
213
221
|
return segments.map((s) => {
|
|
214
222
|
const size = Math.max(0, Math.min(clamp01(s.value / span), 1 - cursor))
|
|
215
223
|
const forecast = s.forecast === true
|
|
@@ -219,12 +227,13 @@ export function layoutSegments(segments: readonly MeterSegment[], span: number):
|
|
|
219
227
|
size,
|
|
220
228
|
color: forecast ? undefined : isMuted(s) ? mutedFill(MUTED_PART) : s.color,
|
|
221
229
|
forecast,
|
|
222
|
-
seam:
|
|
230
|
+
seam: !forecast && prevCategorical,
|
|
223
231
|
label: s.label,
|
|
224
232
|
amount: s.value,
|
|
225
233
|
}
|
|
226
234
|
cursor += size
|
|
227
|
-
|
|
235
|
+
// A zero-size part has no visible edge: the next part has no neighbour to be separated from.
|
|
236
|
+
if (size > 0) prevCategorical = !forecast
|
|
228
237
|
return part
|
|
229
238
|
})
|
|
230
239
|
}
|
|
@@ -3,7 +3,9 @@ import { Skeleton, VisuallyHidden } from '@mantine/core'
|
|
|
3
3
|
import { useContext, useId, useRef, useState } from 'react'
|
|
4
4
|
import type { CSSProperties, ReactNode, RefObject } from 'react'
|
|
5
5
|
import { useIsomorphicLayoutEffect } from '../common/isomorphic-layout-effect'
|
|
6
|
+
import { splitEmptyCopy } from '../common/empty-copy'
|
|
6
7
|
import { cx } from '../common/props'
|
|
8
|
+
import type { DataAttributes } from '../common/props'
|
|
7
9
|
import {
|
|
8
10
|
ariaValues,
|
|
9
11
|
modelBar,
|
|
@@ -30,6 +32,7 @@ import type {
|
|
|
30
32
|
ZoneLabel,
|
|
31
33
|
} from './meter-model'
|
|
32
34
|
import classes from './meter.module.css'
|
|
35
|
+
import { EmptyState } from './empty-state'
|
|
33
36
|
import { VisualSlotContext } from './visual-slot'
|
|
34
37
|
import { toPct } from './scale'
|
|
35
38
|
|
|
@@ -38,6 +41,8 @@ export type Shell = {
|
|
|
38
41
|
style: CSSProperties | undefined
|
|
39
42
|
/** `size="row"`: one text line tall, no caption rows. */
|
|
40
43
|
row: boolean
|
|
44
|
+
/** The consumer's `data-*` (`data-shot`), on the root of every state. */
|
|
45
|
+
data: DataAttributes
|
|
41
46
|
}
|
|
42
47
|
|
|
43
48
|
/**
|
|
@@ -46,6 +51,7 @@ export type Shell = {
|
|
|
46
51
|
*/
|
|
47
52
|
function rootProps(shell: Shell) {
|
|
48
53
|
return {
|
|
54
|
+
...shell.data,
|
|
49
55
|
className: cx(classes.root, shell.row && classes.row, shell.className),
|
|
50
56
|
style: shell.style,
|
|
51
57
|
'data-basalt-meter': '',
|
|
@@ -160,6 +166,21 @@ export function MeterEmpty(props: {
|
|
|
160
166
|
shell: Shell
|
|
161
167
|
}) {
|
|
162
168
|
const { label, text, ring, zoned, shell } = props
|
|
169
|
+
// A host that states its gap (non-blank `text`) gets the one empty box `BarList` and `EventList` draw: no
|
|
170
|
+
// track, no ring, the same `EmptyState` tile.
|
|
171
|
+
if (text !== undefined && text.trim() !== '') {
|
|
172
|
+
const copy = splitEmptyCopy(text)
|
|
173
|
+
return (
|
|
174
|
+
// oxlint-disable-next-line jsx-a11y/prefer-tag-over-role -- a polite live region named by the Meter's label; `<output>` cannot hold the tile's block content
|
|
175
|
+
<div {...rootProps(shell)} role="status" aria-label={label}>
|
|
176
|
+
<EmptyState
|
|
177
|
+
tier="section"
|
|
178
|
+
title={copy.title}
|
|
179
|
+
{...(copy.description !== undefined && { description: copy.description })}
|
|
180
|
+
/>
|
|
181
|
+
</div>
|
|
182
|
+
)
|
|
183
|
+
}
|
|
163
184
|
// The ring has a reading slot (its centre), so the dash sits there as the reading. A bar states its
|
|
164
185
|
// gap once, and only if the host says so (`text`): otherwise the caption rows a loaded Meter would
|
|
165
186
|
// have stay blank, so the muted track keeps the loaded height without a dash under it.
|
|
@@ -178,15 +199,11 @@ export function MeterEmpty(props: {
|
|
|
178
199
|
</div>
|
|
179
200
|
</>
|
|
180
201
|
)}
|
|
181
|
-
{
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
<VisuallyHidden className={classes.summary}>No reading</VisuallyHidden>
|
|
187
|
-
{!shell.row && <Line zoned={zoned} />}
|
|
188
|
-
</>
|
|
189
|
-
)
|
|
202
|
+
{!ring && (
|
|
203
|
+
<>
|
|
204
|
+
<VisuallyHidden className={classes.summary}>No reading</VisuallyHidden>
|
|
205
|
+
{!shell.row && <Line zoned={zoned} />}
|
|
206
|
+
</>
|
|
190
207
|
)}
|
|
191
208
|
</output>
|
|
192
209
|
)
|
|
@@ -774,6 +791,9 @@ export function MeterBar(props: {
|
|
|
774
791
|
...labelled,
|
|
775
792
|
]
|
|
776
793
|
const zoneLabels = compact ? [] : model.zoneLabels
|
|
794
|
+
// With no zone names to own the row below the track, the marker's reading shares the caption row
|
|
795
|
+
// with the end caption (both on one line when they fit), centred on the marker like ZoneReading.
|
|
796
|
+
const readingInRow = anchored && zoneLabels.length === 0
|
|
777
797
|
// On a zoned track the zone names own the row below; the figures at its two ends sit above the
|
|
778
798
|
// track, where nothing else competes for them. Every other tick label stays with the names.
|
|
779
799
|
const isEnd = (t: TickMark) => t.pct <= 0 || t.pct >= 100
|
|
@@ -790,13 +810,19 @@ export function MeterBar(props: {
|
|
|
790
810
|
const items: CaptionItem[] = compact
|
|
791
811
|
? []
|
|
792
812
|
: [
|
|
793
|
-
...(start !== null && !anchored
|
|
813
|
+
...(start !== null && (!anchored || readingInRow)
|
|
794
814
|
? [
|
|
795
815
|
{
|
|
796
816
|
key: 'start',
|
|
797
817
|
node: glue(start),
|
|
818
|
+
// `readingAt="start"` labels the track's start edge ("60-day low"), not the reading: it stays
|
|
819
|
+
// at the edge instead of sitting centred under the reading tick as if it were its caption.
|
|
820
|
+
...(readingInRow &&
|
|
821
|
+
props.readingAt !== 'start' &&
|
|
822
|
+
model.markerPct !== undefined && { pct: model.markerPct }),
|
|
798
823
|
// The reading sits at its fill's end (clamped inside the track); `readingAt="start"` keeps the old start edge.
|
|
799
824
|
...(props.readingAt !== 'start' &&
|
|
825
|
+
!readingInRow &&
|
|
800
826
|
model.fillEndPct !== undefined && {
|
|
801
827
|
pct: model.fillEndPct,
|
|
802
828
|
align: 'end' as const,
|
|
@@ -810,8 +836,9 @@ export function MeterBar(props: {
|
|
|
810
836
|
key: 'forecast',
|
|
811
837
|
node: glue(model.forecastText),
|
|
812
838
|
drop: 2,
|
|
813
|
-
// The reading ends at the boundary, the forecast ends where its fill does
|
|
814
|
-
// If that
|
|
839
|
+
// The reading ends at the boundary, the forecast ends where its fill does (a tick
|
|
840
|
+
// marks that end). If that would cover the reading, it falls back to starting at the
|
|
841
|
+
// boundary before it drops.
|
|
815
842
|
...(props.readingAt !== 'start' && model.forecastEndPct !== undefined
|
|
816
843
|
? {
|
|
817
844
|
pct: model.forecastEndPct,
|
|
@@ -925,6 +952,16 @@ export function MeterBar(props: {
|
|
|
925
952
|
<>
|
|
926
953
|
<Tick kind="marker" className={classes.marker} pct={model.markerPct} />
|
|
927
954
|
<Tick kind="boundary" className={classes.boundaryTick} pct={model.boundaryPct} />
|
|
955
|
+
{/* At the track end the track itself marks the forecast end. */}
|
|
956
|
+
<Tick
|
|
957
|
+
kind="forecastEnd"
|
|
958
|
+
className={classes.boundaryTick}
|
|
959
|
+
pct={
|
|
960
|
+
model.forecastEndPct !== undefined && model.forecastEndPct < 100
|
|
961
|
+
? model.forecastEndPct
|
|
962
|
+
: undefined
|
|
963
|
+
}
|
|
964
|
+
/>
|
|
928
965
|
{model.ticks.map((t) => (
|
|
929
966
|
<Tick key={t.key} kind="tick" className={classes.tick} pct={t.pct} />
|
|
930
967
|
))}
|
|
@@ -933,7 +970,9 @@ export function MeterBar(props: {
|
|
|
933
970
|
)}
|
|
934
971
|
</div>
|
|
935
972
|
{zoneLabels.length > 0 && <LabelRow zones={zoneLabels} ticks={belowTicks} />}
|
|
936
|
-
{anchored &&
|
|
973
|
+
{anchored &&
|
|
974
|
+
!readingInRow &&
|
|
975
|
+
quiet(<ZoneReading pct={model.markerPct ?? 0}>{start}</ZoneReading>)}
|
|
937
976
|
{!loading && model.describedByText !== null && (
|
|
938
977
|
<VisuallyHidden id={describedId} className={classes.summary}>
|
|
939
978
|
{model.describedByText}
|
|
@@ -958,7 +997,7 @@ function tickPosition(kind: TickKind, pct: number): CSSProperties {
|
|
|
958
997
|
return { insetInlineStart: `calc(100% - ${TICK_WIDTH})`, marginInlineStart: 0 }
|
|
959
998
|
}
|
|
960
999
|
|
|
961
|
-
type TickKind = 'marker' | 'boundary' | 'target' | 'tick'
|
|
1000
|
+
type TickKind = 'marker' | 'boundary' | 'forecastEnd' | 'target' | 'tick'
|
|
962
1001
|
|
|
963
1002
|
function Tick({
|
|
964
1003
|
kind,
|
|
@@ -14,6 +14,12 @@
|
|
|
14
14
|
--basalt-meter-caption: var(--vx-text-micro);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
/* A bar fills its container's width: as a flex item (a StatCard visual, a strip cell) it would
|
|
18
|
+
* otherwise size to its captions and stop part-way across the card. */
|
|
19
|
+
.root:has(> .trackBox) {
|
|
20
|
+
inline-size: 100%;
|
|
21
|
+
}
|
|
22
|
+
|
|
17
23
|
.track {
|
|
18
24
|
position: relative;
|
|
19
25
|
display: flex;
|
|
@@ -62,10 +68,10 @@
|
|
|
62
68
|
background: color-mix(in srgb, var(--vx-muted) 65%, transparent);
|
|
63
69
|
}
|
|
64
70
|
|
|
65
|
-
/*
|
|
71
|
+
/* Adjacent categorical parts (muted ones share one fill): a track-coloured gap, not a hairline, tells them apart. */
|
|
66
72
|
.fill[data-meter-seam] {
|
|
67
73
|
box-sizing: border-box;
|
|
68
|
-
border-inline-start:
|
|
74
|
+
border-inline-start: 2px solid var(--vx-surface-subtle);
|
|
69
75
|
}
|
|
70
76
|
|
|
71
77
|
/* The committed/forecast pair: the same neutral at two strengths. Flat, never hatched. */
|
|
@@ -142,7 +148,8 @@
|
|
|
142
148
|
--basalt-reading-dir: 1;
|
|
143
149
|
position: relative;
|
|
144
150
|
height: 1.25em;
|
|
145
|
-
|
|
151
|
+
/* Clipped along the row only: a descender hangs below the 1.25em box of a taller caption line. */
|
|
152
|
+
overflow-x: clip;
|
|
146
153
|
font-family: var(--basalt-font-numeral, var(--basalt-font-sans));
|
|
147
154
|
font-variant-numeric: lining-nums;
|
|
148
155
|
font-size: var(--basalt-meter-caption);
|
|
@@ -167,7 +174,11 @@
|
|
|
167
174
|
translate: none;
|
|
168
175
|
}
|
|
169
176
|
|
|
170
|
-
/*
|
|
177
|
+
/*
|
|
178
|
+
* The reading on a zone track: a notch standing proud of the bands. A panel core in an ink ring, so
|
|
179
|
+
* one of the two always contrasts with the fill under it: the core on an ink fill, the ring on a
|
|
180
|
+
* light one (an ink core on an ink track vanished).
|
|
181
|
+
*/
|
|
171
182
|
.marker {
|
|
172
183
|
position: absolute;
|
|
173
184
|
top: -3px;
|
|
@@ -175,7 +186,8 @@
|
|
|
175
186
|
width: 3px;
|
|
176
187
|
margin-inline-start: -1.5px;
|
|
177
188
|
border-radius: var(--vx-radius-fine);
|
|
178
|
-
background: var(--vx-
|
|
189
|
+
background: var(--vx-surface-panel);
|
|
190
|
+
box-shadow: 0 0 0 1.5px var(--vx-ink);
|
|
179
191
|
}
|
|
180
192
|
|
|
181
193
|
.tick {
|
|
@@ -186,8 +198,9 @@
|
|
|
186
198
|
margin-inline-start: -1px;
|
|
187
199
|
border-radius: var(--vx-radius-fine);
|
|
188
200
|
background: var(--vx-ink);
|
|
189
|
-
/* A
|
|
190
|
-
|
|
201
|
+
/* A panel-coloured 2px halo (the opposite pole of ink in both schemes) keeps the tick readable on
|
|
202
|
+
* a fill that is itself near-ink: `tone="ink"`, or --vx-line in dark. */
|
|
203
|
+
box-shadow: 0 0 0 2px var(--vx-surface-panel);
|
|
191
204
|
}
|
|
192
205
|
|
|
193
206
|
.boundaryTick {
|
|
@@ -323,11 +336,6 @@
|
|
|
323
336
|
border-radius: var(--vx-radius-fine);
|
|
324
337
|
}
|
|
325
338
|
|
|
326
|
-
.empty {
|
|
327
|
-
font-size: var(--basalt-meter-caption);
|
|
328
|
-
color: var(--vx-muted);
|
|
329
|
-
}
|
|
330
|
-
|
|
331
339
|
/* One caption-height line: a blank caption row of an empty Meter, so it stands at the loaded height. */
|
|
332
340
|
.line {
|
|
333
341
|
display: flex;
|
package/src/dashboard/meter.tsx
CHANGED
|
@@ -24,7 +24,16 @@
|
|
|
24
24
|
*
|
|
25
25
|
* Categorical `segments` (no `forecast` part) are captioned one per part — swatch, name, value — under
|
|
26
26
|
* the track and the default start caption is dropped (an explicit `startCaption` still shows);
|
|
27
|
-
* committed/forecast keeps the reading plus the forecast caption.
|
|
27
|
+
* committed/forecast keeps the reading plus the forecast caption. The reading is captioned at the
|
|
28
|
+
* committed fill's end and the forecast at the forecast's end, which a tick marks (none when it
|
|
29
|
+
* reaches the track end); the forecast caption drops before it ever sits under the boundary tick.
|
|
30
|
+
* Adjacent categorical parts are separated by a 2px separator, muted ones included; give each part its own
|
|
31
|
+
* series colour (`tone="muted"` is for a tail "other" part — a bar of only muted parts warns once in
|
|
32
|
+
* development).
|
|
33
|
+
*
|
|
34
|
+
* Captions keep at least a gap step between them at any width: at
|
|
35
|
+
* narrow widths the lower-priority ones drop first (tick captions, then the forecast), and what is
|
|
36
|
+
* dropped stays in the described-by text. A bar fills its container's width.
|
|
28
37
|
*
|
|
29
38
|
* @example
|
|
30
39
|
* import { Meter } from 'basalt-ui'
|
|
@@ -53,28 +62,31 @@
|
|
|
53
62
|
*/
|
|
54
63
|
import { useContext } from 'react'
|
|
55
64
|
import type { ReactNode } from 'react'
|
|
56
|
-
import
|
|
65
|
+
import { pickDataAttributes } from '../common/props'
|
|
66
|
+
import type { BasaltProps, DataAttributes } from '../common/props'
|
|
57
67
|
import { VX } from '../tokens'
|
|
58
|
-
import {
|
|
68
|
+
import { reportOnce } from '../common/validate'
|
|
69
|
+
import { allPartsMuted, isReading, normalizeSegments, segmentReading, spanOf } from './meter-model'
|
|
59
70
|
import type { MeterSegment, MeterTick, MeterZone } from './meter-model'
|
|
60
71
|
import { MeterBar, MeterEmpty, MeterRing, MeterRingLoading } from './meter-parts'
|
|
61
72
|
import { asText } from './scale'
|
|
62
73
|
import { VisualSlotContext } from './visual-slot'
|
|
63
74
|
|
|
64
|
-
type Common = BasaltProps &
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
type Common = BasaltProps &
|
|
76
|
+
DataAttributes & {
|
|
77
|
+
/** Accessible name (`aria-label`). Required: a meter without one is announced as a bare number. */
|
|
78
|
+
label: string
|
|
79
|
+
/** Track start. Default 0. */
|
|
80
|
+
min?: number
|
|
81
|
+
/** Track end. Default 100. */
|
|
82
|
+
max?: number
|
|
83
|
+
/** Formats values in captions and the accessible text. Default: the number as written. */
|
|
84
|
+
format?: (value: number) => string
|
|
85
|
+
/** Renders a skeleton with the meter's footprint. */
|
|
86
|
+
loading?: boolean
|
|
87
|
+
/** The empty box shown when there is no reading (the same `EmptyState` tile `BarList` and `EventList` draw, no track; the first sentence is its title, the rest its muted line). None by default: the muted track stands alone, caption rows blank. */
|
|
88
|
+
emptyText?: string
|
|
89
|
+
}
|
|
78
90
|
|
|
79
91
|
type BarCommon = Common & {
|
|
80
92
|
shape?: 'bar'
|
|
@@ -222,7 +234,7 @@ function barTone(tone: 'muted' | 'ink' | undefined, plain: boolean): 'muted' | u
|
|
|
222
234
|
export function Meter(props: MeterProps) {
|
|
223
235
|
const { label, min = 0, max = 100, format = asText, className, style } = props
|
|
224
236
|
const row = props.size === 'row'
|
|
225
|
-
const shell = { className, style, row }
|
|
237
|
+
const shell = { className, style, row, data: pickDataAttributes(props) }
|
|
226
238
|
const ring = props.shape === 'ring'
|
|
227
239
|
warnInvalidTrack(min, max)
|
|
228
240
|
const host = useContext(VisualSlotContext)
|
|
@@ -238,6 +250,12 @@ export function Meter(props: MeterProps) {
|
|
|
238
250
|
props.segments === undefined || (loading && props.segments.length === 0)
|
|
239
251
|
? undefined
|
|
240
252
|
: normalizeSegments(props.segments)
|
|
253
|
+
if (segments !== undefined && allPartsMuted(segments)) {
|
|
254
|
+
reportOnce(
|
|
255
|
+
'Meter',
|
|
256
|
+
'[basalt] Meter: every segment is tone="muted", so the parts read as one slab; give each part its own series colour (muted is for a tail "other" part)',
|
|
257
|
+
)
|
|
258
|
+
}
|
|
241
259
|
const placeholder =
|
|
242
260
|
props.zones !== undefined && props.zones.length > 0 ? min + spanOf(min, max).span / 2 : min
|
|
243
261
|
const reading = loading
|
|
@@ -9,11 +9,14 @@
|
|
|
9
9
|
min-width: 0;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
/* The aside sits right after the sentence it dates and wraps under it when the line is full — never
|
|
13
|
+
* pinned to the far edge, where it read as belonging to nothing. */
|
|
12
14
|
.top {
|
|
13
15
|
display: flex;
|
|
16
|
+
flex-wrap: wrap;
|
|
14
17
|
align-items: baseline;
|
|
15
|
-
|
|
16
|
-
gap: var(--vx-space-stack-
|
|
18
|
+
column-gap: var(--vx-space-stack-md);
|
|
19
|
+
row-gap: var(--vx-space-stack-xs);
|
|
17
20
|
min-width: 0;
|
|
18
21
|
}
|
|
19
22
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* PageSummary — a page's opening (docs/waves/design-parity/SPEC.md § 6.9): one headline sentence
|
|
3
3
|
* that carries at least one live number, an optional facts line under it, and an optional `aside`
|
|
4
|
-
*
|
|
4
|
+
* after the headline (beside it, wrapping under it when the line is full). It renders an `h2` at the `h1` type step (head face, −0.02em): the page's own
|
|
5
5
|
* h1 is the shell breadcrumb's / `PageTitle`'s, and a second one would split the outline. The facts
|
|
6
6
|
* are the proportional sans at `xs`, muted, `·`-separated — a time fact may take mono itself, the line does
|
|
7
7
|
* not (D33).
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
*/
|
|
33
33
|
import { Skeleton } from '@mantine/core'
|
|
34
34
|
import type { ReactNode } from 'react'
|
|
35
|
-
import { cx } from '../common/props'
|
|
36
|
-
import type { BasaltProps } from '../common/props'
|
|
35
|
+
import { cx, pickDataAttributes } from '../common/props'
|
|
36
|
+
import type { BasaltProps, DataAttributes } from '../common/props'
|
|
37
37
|
import classes from './page-summary.module.css'
|
|
38
38
|
|
|
39
39
|
type Fact = ReactNode | null | false | undefined
|
|
@@ -43,7 +43,7 @@ type PageSummaryContent = {
|
|
|
43
43
|
sentence: ReactNode
|
|
44
44
|
/** Short facts under the headline, e.g. `['3 need you', oldest && `oldest ${oldest}`]`. */
|
|
45
45
|
facts?: readonly Fact[]
|
|
46
|
-
/**
|
|
46
|
+
/** After the headline: a date or a freshness word. */
|
|
47
47
|
aside?: ReactNode
|
|
48
48
|
loading?: false
|
|
49
49
|
}
|
|
@@ -51,7 +51,9 @@ type PageSummaryContent = {
|
|
|
51
51
|
/** While the sentence's data loads: a skeleton of the same shape, no content props needed. */
|
|
52
52
|
type PageSummaryLoading = Partial<Omit<PageSummaryContent, 'loading'>> & { loading: true }
|
|
53
53
|
|
|
54
|
-
export type PageSummaryProps = BasaltProps &
|
|
54
|
+
export type PageSummaryProps = BasaltProps &
|
|
55
|
+
DataAttributes &
|
|
56
|
+
(PageSummaryContent | PageSummaryLoading)
|
|
55
57
|
|
|
56
58
|
const NO_FACTS: readonly Fact[] = []
|
|
57
59
|
|
|
@@ -60,7 +62,12 @@ const isShown = (fact: Fact): boolean =>
|
|
|
60
62
|
|
|
61
63
|
export function PageSummary(props: PageSummaryProps) {
|
|
62
64
|
const { className, style } = props
|
|
63
|
-
const common = {
|
|
65
|
+
const common = {
|
|
66
|
+
...pickDataAttributes(props),
|
|
67
|
+
className: cx(classes.root, className),
|
|
68
|
+
'data-page-summary': '',
|
|
69
|
+
style,
|
|
70
|
+
}
|
|
64
71
|
|
|
65
72
|
if (props.loading === true) {
|
|
66
73
|
return (
|