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
|
@@ -69,6 +69,8 @@
|
|
|
69
69
|
.label {
|
|
70
70
|
position: relative;
|
|
71
71
|
min-width: 0;
|
|
72
|
+
/* A name truncates before it touches the value, whatever the column gap. */
|
|
73
|
+
padding-inline-end: var(--vx-space-stack-md, 0.75rem);
|
|
72
74
|
overflow: hidden;
|
|
73
75
|
text-overflow: ellipsis;
|
|
74
76
|
white-space: nowrap;
|
|
@@ -231,10 +233,26 @@
|
|
|
231
233
|
}
|
|
232
234
|
|
|
233
235
|
/*
|
|
234
|
-
* A column of DeltaBadges
|
|
235
|
-
*
|
|
236
|
-
*
|
|
236
|
+
* A column of DeltaBadges is a start-aligned two-track grid: the glyph track, then the figure. Every
|
|
237
|
+
* glyph shares one x and sits one fixed gap from its own figure ("▲ 9%" and "▲ 13%" alike); the
|
|
238
|
+
* figures are ragged on the right. End-aligning them in a fixed-width track kept the right edge but
|
|
239
|
+
* left a digit-wide hole between a short figure and its glyph (about 8px, Wave 50 S4).
|
|
237
240
|
*/
|
|
238
241
|
.secondary [data-delta] {
|
|
242
|
+
/* A block that hugs its content and sits on the cell's start, whatever the cell's `text-align`, so
|
|
243
|
+
* every glyph shares one x. */
|
|
244
|
+
display: grid;
|
|
245
|
+
width: max-content;
|
|
246
|
+
margin-inline-end: auto;
|
|
247
|
+
grid-auto-flow: column;
|
|
248
|
+
grid-template-columns: auto auto;
|
|
249
|
+
justify-items: start;
|
|
239
250
|
font-variant-numeric: tabular-nums;
|
|
251
|
+
/* The row's line box, not the badge's own `line-height: 1`: its baseline then sits on the value's. */
|
|
252
|
+
line-height: inherit;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/* A zero delta has no glyph: its figure is the only track. */
|
|
256
|
+
.secondary [data-delta]:not(:has([data-delta-glyph])) {
|
|
257
|
+
grid-template-columns: auto;
|
|
240
258
|
}
|
|
@@ -18,9 +18,10 @@
|
|
|
18
18
|
* the one scale, so a name stays beside its value and a full-scale bar ends at the track end.
|
|
19
19
|
*
|
|
20
20
|
* The secondary column aligns by content (override: `secondaryAlign`): a text secondary (a status word,
|
|
21
|
-
* `StatusVerdict`/`StatusDot`) starts on one x so the dots line up; figures ("41%", "+€7")
|
|
22
|
-
* `DeltaBadge`
|
|
23
|
-
*
|
|
21
|
+
* `StatusVerdict`/`StatusDot`) starts on one x so the dots line up; figures ("41%", "+€7") and numbers
|
|
22
|
+
* end. A `DeltaBadge` starts on one x too: a glyph track, then the figure, so every glyph shares an x and
|
|
23
|
+
* sits one fixed gap from its own figure; the figures are ragged on the right (a column of deltas is
|
|
24
|
+
* table-like, D33 allows tabular there).
|
|
24
25
|
*
|
|
25
26
|
* Colour law: bars are neutral. `accentLeader` (opt-in) lets the top row take the accent — the
|
|
26
27
|
* leader bar, and nothing else. Each value is rendered as text, never only a bar length.
|
|
@@ -49,11 +50,12 @@ import { Skeleton, VisuallyHidden } from '@mantine/core'
|
|
|
49
50
|
import { EmptyState } from './empty-state'
|
|
50
51
|
import { isValidElement } from 'react'
|
|
51
52
|
import type { ReactNode } from 'react'
|
|
52
|
-
import { cx } from '../common/props'
|
|
53
|
-
import type { BasaltProps } from '../common/props'
|
|
53
|
+
import { cx, pickDataAttributes } from '../common/props'
|
|
54
|
+
import type { BasaltProps, DataAttributes } from '../common/props'
|
|
54
55
|
import classes from './bar-list.module.css'
|
|
55
56
|
import { StatusDot } from '../theme/status-dot'
|
|
56
57
|
import { StatusVerdict } from '../theme/status-verdict'
|
|
58
|
+
import { skeletonRowCount } from './event-list-model'
|
|
57
59
|
import { asText, barPercent } from './scale'
|
|
58
60
|
|
|
59
61
|
type BarListItem = {
|
|
@@ -69,37 +71,38 @@ type BarListItem = {
|
|
|
69
71
|
tickLabel?: string
|
|
70
72
|
}
|
|
71
73
|
|
|
72
|
-
export type BarListProps = BasaltProps &
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
74
|
+
export type BarListProps = BasaltProps &
|
|
75
|
+
DataAttributes & {
|
|
76
|
+
/** Accessible name of the list. Required. */
|
|
77
|
+
label: string
|
|
78
|
+
/** Rows in display order (sort them yourself; the list does not reorder). */
|
|
79
|
+
items: readonly BarListItem[]
|
|
80
|
+
/**
|
|
81
|
+
* Formats each number. `part` is `'max'` for a row's denominator, `'value'` otherwise (the value and
|
|
82
|
+
* the tick), so a unit can sit on one side only: `'32 / 40 pts'`. Default: the number as written.
|
|
83
|
+
*/
|
|
84
|
+
format?: (value: number, part: 'value' | 'max') => string
|
|
85
|
+
/** Scale end shared by rows without their own `max`. Default: the largest of those rows' values. */
|
|
86
|
+
max?: number
|
|
87
|
+
/**
|
|
88
|
+
* `thin` (default): label on its own line above a thin bar, value right-aligned on that line.
|
|
89
|
+
* `inline`: the label sits inside a heavier track, the value outside it.
|
|
90
|
+
*/
|
|
91
|
+
variant?: 'thin' | 'inline'
|
|
92
|
+
/** The first row's bar takes the accent. Off by default. */
|
|
93
|
+
accentLeader?: boolean
|
|
94
|
+
/**
|
|
95
|
+
* Which edge the secondary column aligns to. Default: by content — text (a status word, a status
|
|
96
|
+
* mark) starts, figures and other elements end.
|
|
97
|
+
*/
|
|
98
|
+
secondaryAlign?: 'start' | 'end'
|
|
99
|
+
/** Renders row-shaped skeletons. */
|
|
100
|
+
loading?: boolean
|
|
101
|
+
/** Skeleton rows while loading. Default: the rows `items` holds now (a refetch, capped at 30), else 5. */
|
|
102
|
+
loadingRows?: number
|
|
103
|
+
/** Title of the `EmptyState` tile shown when `items` is empty. Default "No items to compare yet"; pass the cause for your list. */
|
|
104
|
+
emptyText?: string
|
|
105
|
+
}
|
|
103
106
|
|
|
104
107
|
/** `null`, `undefined`, `false` and `true` render nothing, so they are not a secondary value. */
|
|
105
108
|
const hasContent = (node: ReactNode): boolean =>
|
|
@@ -127,19 +130,21 @@ export function BarList({
|
|
|
127
130
|
accentLeader = false,
|
|
128
131
|
secondaryAlign,
|
|
129
132
|
loading = false,
|
|
130
|
-
loadingRows
|
|
133
|
+
loadingRows,
|
|
131
134
|
emptyText = 'No items to compare yet',
|
|
132
135
|
className,
|
|
133
136
|
style,
|
|
137
|
+
...rest
|
|
134
138
|
}: BarListProps) {
|
|
139
|
+
const data = pickDataAttributes(rest)
|
|
135
140
|
if (loading) {
|
|
136
141
|
// Each row is a real, empty row with a skeleton laid over it, so the list takes the height of
|
|
137
142
|
// the rows it will become in every layout instead of a fixed guess.
|
|
138
143
|
return (
|
|
139
|
-
<div className={cx(classes.frame, className)} style={style}>
|
|
144
|
+
<div {...data} className={cx(classes.frame, className)} style={style}>
|
|
140
145
|
<div className={classes.root} aria-busy="true" data-variant={variant}>
|
|
141
146
|
<VisuallyHidden>{`Loading ${label}`}</VisuallyHidden>
|
|
142
|
-
{Array.from({ length: loadingRows }, (_, i) => (
|
|
147
|
+
{Array.from({ length: skeletonRowCount(loadingRows, items.length) }, (_, i) => (
|
|
143
148
|
<div
|
|
144
149
|
key={i}
|
|
145
150
|
className={cx(classes.row, classes.skeletonRow)}
|
|
@@ -158,7 +163,7 @@ export function BarList({
|
|
|
158
163
|
}
|
|
159
164
|
if (items.length === 0) {
|
|
160
165
|
return (
|
|
161
|
-
<div className={cx(classes.frame, className)} style={style}>
|
|
166
|
+
<div {...data} className={cx(classes.frame, className)} style={style}>
|
|
162
167
|
{/* oxlint-disable-next-line jsx-a11y/prefer-tag-over-role -- a polite live region whose name is the visually hidden label inside; `<output>` cannot hold the tile's block content */}
|
|
163
168
|
<div className={classes.root} role="status">
|
|
164
169
|
<VisuallyHidden>{label}</VisuallyHidden>
|
|
@@ -179,7 +184,7 @@ export function BarList({
|
|
|
179
184
|
const align = secondaryAlign ?? (items.some((i) => isText(i.secondary)) ? 'start' : 'end')
|
|
180
185
|
return (
|
|
181
186
|
// The frame is the width container the wide layout keys on (a container cannot restyle its own grid).
|
|
182
|
-
<div className={cx(classes.frame, className)} style={style}>
|
|
187
|
+
<div {...data} className={cx(classes.frame, className)} style={style}>
|
|
183
188
|
{/* The explicit role is deliberate: `list-style: none` makes Safari/VoiceOver drop the implicit one. */}
|
|
184
189
|
<ul
|
|
185
190
|
className={classes.root}
|
|
@@ -26,6 +26,25 @@
|
|
|
26
26
|
gap: var(--vx-space-stack-sm);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
/* A bottom fade while more cards sit below the fold (`data-more`, set by `ColumnScroll`). A mask, not a
|
|
30
|
+
gradient of the page colour: a Board in a `Section` sits on the panel surface, and a fade to the
|
|
31
|
+
page colour (W50) left a 16 px band that read as no fade at all. The mask dissolves the cards
|
|
32
|
+
themselves, so it shows on any backdrop, and adds no height. */
|
|
33
|
+
.viewport[data-more] {
|
|
34
|
+
--board-fade: calc(var(--vx-space-stack-lg, 1.5rem) * 2);
|
|
35
|
+
mask-image: linear-gradient(to bottom, black calc(100% - var(--board-fade)), transparent);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* A quiet thumb: 6 px, a faint ink tint that firms on hover, no rail behind it (Mantine's default is a
|
|
39
|
+
heavy grey bar that read as chrome on the page). */
|
|
40
|
+
.thumb {
|
|
41
|
+
background: color-mix(in srgb, var(--vx-ink) 22%, transparent);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.thumb:hover {
|
|
45
|
+
background: color-mix(in srgb, var(--vx-ink) 40%, transparent);
|
|
46
|
+
}
|
|
47
|
+
|
|
29
48
|
.head {
|
|
30
49
|
display: flex;
|
|
31
50
|
align-items: center;
|
|
@@ -6,8 +6,10 @@ declare const classes: {
|
|
|
6
6
|
readonly root: string
|
|
7
7
|
readonly columns: string
|
|
8
8
|
readonly column: string
|
|
9
|
+
readonly viewport: string
|
|
9
10
|
readonly head: string
|
|
10
11
|
readonly title: string
|
|
12
|
+
readonly thumb: string
|
|
11
13
|
readonly count: string
|
|
12
14
|
readonly total: string
|
|
13
15
|
readonly list: string
|
package/src/dashboard/board.tsx
CHANGED
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
import { ScrollArea, SegmentedControl, Skeleton, Card, VisuallyHidden } from '@mantine/core'
|
|
44
44
|
import { Fragment, useEffect, useId, useRef, useState } from 'react'
|
|
45
45
|
import type { KeyboardEvent, ReactNode } from 'react'
|
|
46
|
-
import { cx } from '../common/props'
|
|
47
|
-
import type { BasaltProps } from '../common/props'
|
|
46
|
+
import { cx, pickDataAttributes } from '../common/props'
|
|
47
|
+
import type { BasaltProps, DataAttributes } from '../common/props'
|
|
48
48
|
import { useSizeClass } from '../shell/use-size-class'
|
|
49
49
|
import type { EnumField, FieldHandle } from '../state'
|
|
50
50
|
import { StatusDot } from '../theme/status-dot'
|
|
@@ -53,47 +53,49 @@ import classes from './board.module.css'
|
|
|
53
53
|
import { isBoardKey, isSafeHref, moveOnBoard } from './board-nav'
|
|
54
54
|
import type { BoardPos } from './board-nav'
|
|
55
55
|
import { EmptyState } from './empty-state'
|
|
56
|
+
import { useScrolledEdge } from './event-list-scroll'
|
|
56
57
|
|
|
57
|
-
export type BoardProps<T extends string = string> = BasaltProps &
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
/** Colour of the header's status dot (a `VX.status.*` token). Default muted. */
|
|
65
|
-
tone?: string
|
|
66
|
-
/** Right-aligned header text, already formatted ("3 items", "$12.40"). */
|
|
67
|
-
total?: string
|
|
68
|
-
/** The title of the `EmptyState` tile an empty column shows. Default "Nothing here"; say why it is empty. */
|
|
69
|
-
empty?: string
|
|
70
|
-
cards: readonly {
|
|
71
|
-
id: string
|
|
72
|
-
actor?: string
|
|
73
|
-
type?: string
|
|
58
|
+
export type BoardProps<T extends string = string> = BasaltProps &
|
|
59
|
+
DataAttributes & {
|
|
60
|
+
/** Accessible name of the board. Default "Board". */
|
|
61
|
+
label?: string
|
|
62
|
+
/** Columns in display order. Column and card `id`s must be unique within their parent. */
|
|
63
|
+
columns: readonly {
|
|
64
|
+
id: T
|
|
74
65
|
title: string
|
|
75
|
-
/**
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
|
|
66
|
+
/** Colour of the header's status dot (a `VX.status.*` token). Default muted. */
|
|
67
|
+
tone?: string
|
|
68
|
+
/** Right-aligned header text, already formatted ("3 items", "$12.40"). */
|
|
69
|
+
total?: string
|
|
70
|
+
/** The title of the `EmptyState` tile an empty column shows. Default "Nothing here"; say why it is empty. */
|
|
71
|
+
empty?: string
|
|
72
|
+
cards: readonly {
|
|
73
|
+
id: string
|
|
74
|
+
actor?: string
|
|
75
|
+
type?: string
|
|
76
|
+
title: string
|
|
77
|
+
/** A linked record; `href` is a link only when http(s) or relative. */
|
|
78
|
+
record?: { label: string; href?: string }
|
|
79
|
+
/** One muted status line ("Deferred · waiting on CI"). */
|
|
80
|
+
status?: string
|
|
81
|
+
/** An optional meter or preview; the one ReactNode slot. */
|
|
82
|
+
meter?: ReactNode
|
|
83
|
+
}[]
|
|
81
84
|
}[]
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
85
|
+
/** Called with the card and column ids on Enter, Space or a click. */
|
|
86
|
+
onOpen?: (cardId: string, columnId: string) => void
|
|
87
|
+
/** Each column scrolls alone inside a box of this height. Omitted: content-sized. */
|
|
88
|
+
height?: number | string
|
|
89
|
+
/** Renders column-shaped skeletons. */
|
|
90
|
+
loading?: boolean
|
|
91
|
+
/** The tile shown when no column has a card. Default "Nothing on the board". */
|
|
92
|
+
empty?: { title: string; description?: string; action?: ReactNode }
|
|
93
|
+
/**
|
|
94
|
+
* Compact: the store field holding the selected column id (an enum field of the column ids, the
|
|
95
|
+
* type `ViewTabs` takes). Omitted: internal state, first column.
|
|
96
|
+
*/
|
|
97
|
+
field?: FieldHandle<EnumField<T>>
|
|
98
|
+
}
|
|
97
99
|
|
|
98
100
|
const DEFAULT_EMPTY = { title: 'Nothing on the board' } as const
|
|
99
101
|
const SKELETON_COLUMNS = 3
|
|
@@ -180,6 +182,25 @@ export function Board<T extends string = string>({ field, ...props }: BoardProps
|
|
|
180
182
|
)
|
|
181
183
|
}
|
|
182
184
|
|
|
185
|
+
/** One column's scroll box. It marks its viewport `data-more` while cards remain below the fold, and
|
|
186
|
+
* CSS masks the column's bottom edge there, so a clipped last card is never silent. */
|
|
187
|
+
function ColumnScroll({ height, children }: { height?: number | string; children: ReactNode }) {
|
|
188
|
+
const [viewport, setViewport] = useState<HTMLDivElement | null>(null)
|
|
189
|
+
useScrolledEdge(viewport)
|
|
190
|
+
return (
|
|
191
|
+
<ScrollArea.Autosize
|
|
192
|
+
{...(height !== undefined && { mah: height })}
|
|
193
|
+
type="auto"
|
|
194
|
+
offsetScrollbars="y"
|
|
195
|
+
viewportRef={setViewport}
|
|
196
|
+
scrollbarSize={6}
|
|
197
|
+
classNames={{ viewport: classes.viewport, thumb: classes.thumb }}
|
|
198
|
+
>
|
|
199
|
+
{children}
|
|
200
|
+
</ScrollArea.Autosize>
|
|
201
|
+
)
|
|
202
|
+
}
|
|
203
|
+
|
|
183
204
|
function BoardView<T extends string>({
|
|
184
205
|
label = 'Board',
|
|
185
206
|
columns,
|
|
@@ -191,6 +212,7 @@ function BoardView<T extends string>({
|
|
|
191
212
|
onPick,
|
|
192
213
|
className,
|
|
193
214
|
style,
|
|
215
|
+
...rest
|
|
194
216
|
}: BoardViewProps<T>) {
|
|
195
217
|
const compact = useSizeClass() === 'compact'
|
|
196
218
|
const labelId = useId()
|
|
@@ -311,13 +333,7 @@ function BoardView<T extends string>({
|
|
|
311
333
|
)}
|
|
312
334
|
{col.total !== undefined && <span className={classes.total}>{col.total}</span>}
|
|
313
335
|
</div>
|
|
314
|
-
<
|
|
315
|
-
{...(height !== undefined && { mah: height })}
|
|
316
|
-
type="auto"
|
|
317
|
-
offsetScrollbars="y"
|
|
318
|
-
>
|
|
319
|
-
{list}
|
|
320
|
-
</ScrollArea.Autosize>
|
|
336
|
+
<ColumnScroll {...(height !== undefined && { height })}>{list}</ColumnScroll>
|
|
321
337
|
</div>
|
|
322
338
|
)
|
|
323
339
|
}
|
|
@@ -387,7 +403,12 @@ function BoardView<T extends string>({
|
|
|
387
403
|
}
|
|
388
404
|
|
|
389
405
|
return (
|
|
390
|
-
<div
|
|
406
|
+
<div
|
|
407
|
+
{...pickDataAttributes(rest)}
|
|
408
|
+
className={cx(classes.root, className)}
|
|
409
|
+
style={style}
|
|
410
|
+
data-board=""
|
|
411
|
+
>
|
|
391
412
|
{content}
|
|
392
413
|
</div>
|
|
393
414
|
)
|
|
@@ -20,13 +20,14 @@
|
|
|
20
20
|
import { Center, Stack } from '@mantine/core'
|
|
21
21
|
import type { ReactNode } from 'react'
|
|
22
22
|
import { VX, alpha } from '../tokens'
|
|
23
|
-
import { cx } from '../common/props'
|
|
24
|
-
import type { BasaltProps, SlotStylesProps } from '../common/props'
|
|
23
|
+
import { cx, pickDataAttributes } from '../common/props'
|
|
24
|
+
import type { BasaltProps, DataAttributes, SlotStylesProps } from '../common/props'
|
|
25
25
|
|
|
26
26
|
/** The five boxes `EmptyState` paints, and the whole styling seam it offers (`common/props.ts`). */
|
|
27
27
|
export type EmptyStateSlot = 'root' | 'icon' | 'title' | 'description' | 'action'
|
|
28
28
|
|
|
29
29
|
export type EmptyStateProps = BasaltProps &
|
|
30
|
+
DataAttributes &
|
|
30
31
|
SlotStylesProps<EmptyStateSlot> & {
|
|
31
32
|
/** Optional glyph slot, rendered faint at ~28-32px. No shipped illustration assets. */
|
|
32
33
|
icon?: ReactNode
|
|
@@ -65,10 +66,12 @@ export function EmptyState({
|
|
|
65
66
|
className,
|
|
66
67
|
style,
|
|
67
68
|
classNames,
|
|
69
|
+
...rest
|
|
68
70
|
}: EmptyStateProps) {
|
|
69
71
|
const resolved = tier ?? 'page'
|
|
70
72
|
return (
|
|
71
73
|
<Stack
|
|
74
|
+
{...pickDataAttributes(rest)}
|
|
72
75
|
align="center"
|
|
73
76
|
gap="xs"
|
|
74
77
|
className={cx(classNames?.root, className)}
|
|
@@ -99,7 +99,19 @@ export type RowContext = {
|
|
|
99
99
|
|
|
100
100
|
/** `null`, `undefined`, booleans and the empty string render nothing, so they are not content. */
|
|
101
101
|
export const present = (node: ReactNode): boolean =>
|
|
102
|
-
node !== undefined &&
|
|
102
|
+
node !== undefined &&
|
|
103
|
+
node !== null &&
|
|
104
|
+
typeof node !== 'boolean' &&
|
|
105
|
+
node !== '' &&
|
|
106
|
+
!(Array.isArray(node) && !node.some(present))
|
|
107
|
+
|
|
108
|
+
const SKELETON_DEFAULT_ROWS = 5
|
|
109
|
+
const SKELETON_MAX_ROWS = 30
|
|
110
|
+
|
|
111
|
+
/** Skeleton rows while loading, shared by `EventList` and `BarList`: an explicit `loadingRows`, else the
|
|
112
|
+
* rows held now (a refetch), capped at 30, else 5 (a cold load has no count to keep). */
|
|
113
|
+
export const skeletonRowCount = (loadingRows: number | undefined, held: number): number =>
|
|
114
|
+
loadingRows ?? (held > 0 ? Math.min(held, SKELETON_MAX_ROWS) : SKELETON_DEFAULT_ROWS)
|
|
103
115
|
|
|
104
116
|
/** The data attributes a row (real or skeleton) carries; the CSS keys on them. */
|
|
105
117
|
export function rowAttributes(ctx: RowContext, first: boolean, last: boolean) {
|
|
@@ -29,7 +29,6 @@ export function EventRow({
|
|
|
29
29
|
const at = toEventDate(item.at)
|
|
30
30
|
const valid = isValidEventDate(at)
|
|
31
31
|
const stamp = formatEventTime(at, ctx.timeMode, ctx.now)
|
|
32
|
-
const hasMeta = present(item.body) || present(item.chips)
|
|
33
32
|
return (
|
|
34
33
|
<Tag
|
|
35
34
|
className={classes.row}
|
|
@@ -37,8 +36,6 @@ export function EventRow({
|
|
|
37
36
|
role={Tag === 'div' ? 'listitem' : undefined}
|
|
38
37
|
data-event-id={item.id}
|
|
39
38
|
data-untimed={stamp === '' ? '' : undefined}
|
|
40
|
-
// A row whose only meta is chips and has no time: the chips join the sentence's line, not a line of their own.
|
|
41
|
-
data-chips-only={stamp === '' && !present(item.body) && present(item.chips) ? '' : undefined}
|
|
42
39
|
{...rowAttributes(ctx, first, last)}
|
|
43
40
|
>
|
|
44
41
|
{ctx.lead && <span className={classes.leading}>{item.leading}</span>}
|
|
@@ -51,12 +48,12 @@ export function EventRow({
|
|
|
51
48
|
{stamp}
|
|
52
49
|
</time>
|
|
53
50
|
)}
|
|
54
|
-
{
|
|
51
|
+
{present(item.body) && (
|
|
55
52
|
<div className={classes.meta}>
|
|
56
|
-
|
|
57
|
-
{present(item.chips) && <span className={classes.chips}>{item.chips}</span>}
|
|
53
|
+
<span className={classes.body}>{item.body}</span>
|
|
58
54
|
</div>
|
|
59
55
|
)}
|
|
56
|
+
{present(item.chips) && <div className={classes.chips}>{item.chips}</div>}
|
|
60
57
|
</Tag>
|
|
61
58
|
)
|
|
62
59
|
}
|