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
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* EventList (docs/waves/design-parity/SPEC.md § 6.7). One row shape for the plain and the virtualised
|
|
3
|
+
* path: nothing here keys on a parent selector, so the seam's wrapper divs change no geometry.
|
|
4
|
+
* Two type rungs: the row size (actor, sentence, body, leading glyph) and the micro size (day header,
|
|
5
|
+
* time, chips; a chip Badge is pinned to it whatever `size` it asks for).
|
|
6
|
+
* Line one is the glyph and the sentence at full width; line two leads with the mono time, then the
|
|
7
|
+
* body (it wraps, never truncates); the chips, when a row has any, sit on a line of their own under the
|
|
8
|
+
* time, so their place never depends on the body.
|
|
9
|
+
*/
|
|
10
|
+
.frame {
|
|
11
|
+
inline-size: 100%;
|
|
12
|
+
min-width: 0;
|
|
13
|
+
/* The sticky header backdrop, for the plain path and the seam alike: the page surface a `Section`
|
|
14
|
+
sits on. A list inside a card sets `--event-list-bg: var(--vx-surface-panel)` via `className`. */
|
|
15
|
+
--event-list-bg: var(--vx-surface-bg);
|
|
16
|
+
--virtual-rows-sticky-bg: var(--event-list-bg);
|
|
17
|
+
/* Chip and hover fill: a faint ink tint over the backdrop, visible in both schemes. */
|
|
18
|
+
--event-list-tint: color-mix(in srgb, var(--vx-ink) 7%, var(--event-list-bg));
|
|
19
|
+
--event-list-hover: color-mix(in srgb, var(--vx-ink) 12%, var(--event-list-bg));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.root {
|
|
23
|
+
min-width: 0;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.scroll {
|
|
27
|
+
overflow: auto;
|
|
28
|
+
/* The prepend anchor is manual (event-list.tsx); native anchoring would add the delta twice. */
|
|
29
|
+
overflow-anchor: none;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/* A bottom fade while more rows sit below the fold (`data-more`); it overlays the last rows and adds no height. */
|
|
33
|
+
.scroll[data-more]::after {
|
|
34
|
+
content: '';
|
|
35
|
+
display: block;
|
|
36
|
+
position: sticky;
|
|
37
|
+
inset-block-end: 0;
|
|
38
|
+
block-size: var(--vx-space-stack-lg, 1.5rem);
|
|
39
|
+
margin-block-start: calc(var(--vx-space-stack-lg, 1.5rem) * -1);
|
|
40
|
+
background: linear-gradient(transparent, var(--event-list-bg));
|
|
41
|
+
pointer-events: none;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/* The count of rows out of view each way (`data-above` / `data-below`, set by `useScrolledEdge`): small mono
|
|
45
|
+
text at the end of the edge, over the sticky header (top) and the fade (bottom). Zero height: no shift. */
|
|
46
|
+
.scroll[data-above]::before {
|
|
47
|
+
content: '↑ ' attr(data-above) ' above';
|
|
48
|
+
display: block;
|
|
49
|
+
position: sticky;
|
|
50
|
+
inset-block-start: 0;
|
|
51
|
+
z-index: 2;
|
|
52
|
+
block-size: 0;
|
|
53
|
+
/* Moved, not padded: padding would add height to the content. */
|
|
54
|
+
translate: 0 var(--vx-space-stack-xs);
|
|
55
|
+
text-align: end;
|
|
56
|
+
/* Inside the box: flush text lost its last glyph edge to the clip at 390. */
|
|
57
|
+
padding-inline-end: var(--vx-space-stack-xs);
|
|
58
|
+
font-family: var(--basalt-font-mono);
|
|
59
|
+
font-size: var(--vx-text-micro);
|
|
60
|
+
line-height: 1.4;
|
|
61
|
+
white-space: nowrap;
|
|
62
|
+
color: var(--vx-muted);
|
|
63
|
+
pointer-events: none;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.scroll[data-below]::after {
|
|
67
|
+
content: '↓ ' attr(data-below) ' below';
|
|
68
|
+
display: flex;
|
|
69
|
+
align-items: flex-end;
|
|
70
|
+
justify-content: flex-end;
|
|
71
|
+
box-sizing: border-box;
|
|
72
|
+
padding-inline-end: var(--vx-space-stack-xs);
|
|
73
|
+
/* Self-contained, like the fade it shares the pseudo with: sticky and cancelled, so it adds no height. */
|
|
74
|
+
position: sticky;
|
|
75
|
+
inset-block-end: 0;
|
|
76
|
+
block-size: var(--vx-space-stack-lg, 1.5rem);
|
|
77
|
+
margin-block-start: calc(var(--vx-space-stack-lg, 1.5rem) * -1);
|
|
78
|
+
pointer-events: none;
|
|
79
|
+
font-family: var(--basalt-font-mono);
|
|
80
|
+
font-size: var(--vx-text-micro);
|
|
81
|
+
line-height: 1.4;
|
|
82
|
+
white-space: nowrap;
|
|
83
|
+
color: var(--vx-muted);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/* Loading after rows: the skeleton keeps their last height, so the box does not collapse. */
|
|
87
|
+
.skeleton {
|
|
88
|
+
min-block-size: var(--event-list-held, var(--event-list-last, 0px));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.virtual {
|
|
92
|
+
min-width: 0;
|
|
93
|
+
/* The plain rows' last height (see useHeldHeight): no collapse while the seam loads. */
|
|
94
|
+
min-block-size: var(--event-list-held, 0px);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.group {
|
|
98
|
+
min-width: 0;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.list {
|
|
102
|
+
margin: 0;
|
|
103
|
+
padding: 0;
|
|
104
|
+
list-style: none;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.header {
|
|
108
|
+
position: sticky;
|
|
109
|
+
top: 0;
|
|
110
|
+
z-index: 1;
|
|
111
|
+
display: flex;
|
|
112
|
+
align-items: baseline;
|
|
113
|
+
gap: var(--vx-space-control-gap);
|
|
114
|
+
margin: 0;
|
|
115
|
+
padding-block: var(--vx-space-stack-xs);
|
|
116
|
+
background: var(--event-list-bg);
|
|
117
|
+
font-family: var(--basalt-font-mono);
|
|
118
|
+
font-size: var(--vx-text-micro);
|
|
119
|
+
font-weight: 400;
|
|
120
|
+
letter-spacing: 0.06em;
|
|
121
|
+
color: var(--vx-muted);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/* A scrolled box: a short fade under the sticky day header, so a row passing beneath it reads as
|
|
125
|
+
scrolled, not overlapped. */
|
|
126
|
+
.scroll[data-scrolled] .header::after {
|
|
127
|
+
content: '';
|
|
128
|
+
position: absolute;
|
|
129
|
+
inset-inline: 0;
|
|
130
|
+
inset-block-start: 100%;
|
|
131
|
+
block-size: var(--vx-space-stack-sm);
|
|
132
|
+
background: linear-gradient(var(--event-list-bg), transparent);
|
|
133
|
+
pointer-events: none;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.count {
|
|
137
|
+
opacity: 0.7;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.row {
|
|
141
|
+
--event-list-lead: calc(1.25rem * var(--mantine-scale, 1));
|
|
142
|
+
position: relative;
|
|
143
|
+
display: grid;
|
|
144
|
+
grid-template-columns: auto minmax(0, 1fr);
|
|
145
|
+
grid-template-areas:
|
|
146
|
+
'line line'
|
|
147
|
+
'time meta'
|
|
148
|
+
'chips chips';
|
|
149
|
+
column-gap: var(--vx-space-stack-md);
|
|
150
|
+
padding-block: var(--vx-space-stack-xs);
|
|
151
|
+
font-size: var(--vx-text-sm);
|
|
152
|
+
line-height: 1.4;
|
|
153
|
+
color: var(--vx-ink);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/* A consistent gap between the rows of a feed (a rail row has its rail; a hairline would be a divider the
|
|
157
|
+
divider law does not list): nine rows of one day read as nine. Padding, not margin: the windowed seam
|
|
158
|
+
measures a row's own box, and the same on every row, so a prepend moves nothing. */
|
|
159
|
+
.row:not([data-rail]) {
|
|
160
|
+
padding-block: calc(var(--vx-space-stack-xs) * 1.5);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.row[data-density='timeline'] {
|
|
164
|
+
padding-block: var(--vx-space-stack-sm);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.row[data-lead] {
|
|
168
|
+
grid-template-columns: var(--event-list-lead) auto minmax(0, 1fr);
|
|
169
|
+
grid-template-areas:
|
|
170
|
+
'lead line line'
|
|
171
|
+
'. time meta'
|
|
172
|
+
'. chips chips';
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/* An untimed row has no time to lead the meta line: the meta takes the whole line. */
|
|
176
|
+
.row[data-untimed] {
|
|
177
|
+
grid-template-areas:
|
|
178
|
+
'line line'
|
|
179
|
+
'meta meta'
|
|
180
|
+
'chips chips';
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.row[data-lead][data-untimed] {
|
|
184
|
+
grid-template-areas:
|
|
185
|
+
'lead line line'
|
|
186
|
+
'. meta meta'
|
|
187
|
+
'. chips chips';
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
.leading {
|
|
191
|
+
grid-area: lead;
|
|
192
|
+
display: flex;
|
|
193
|
+
align-items: center;
|
|
194
|
+
justify-content: center;
|
|
195
|
+
min-height: 1.4em;
|
|
196
|
+
/* A glyph or avatar initial rides the row size, never a size of its own. */
|
|
197
|
+
font-size: var(--vx-text-sm);
|
|
198
|
+
color: var(--vx-muted);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/* The rail: a 1 px neutral line through the leading column; the first and last rows start and stop at the glyph. */
|
|
202
|
+
.row[data-rail]::before {
|
|
203
|
+
content: '';
|
|
204
|
+
position: absolute;
|
|
205
|
+
inset-inline-start: calc(var(--event-list-lead) / 2);
|
|
206
|
+
inset-block: 0;
|
|
207
|
+
inline-size: 1px;
|
|
208
|
+
background: var(--vx-surface-border);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
.row[data-rail][data-first]::before {
|
|
212
|
+
inset-block-start: calc(var(--vx-space-stack-sm) + 0.7em);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
.row[data-rail][data-last]::before {
|
|
216
|
+
inset-block-end: calc(100% - var(--vx-space-stack-sm) - 0.7em);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
.row[data-rail][data-first][data-last]::before {
|
|
220
|
+
display: none;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
.line {
|
|
224
|
+
grid-area: line;
|
|
225
|
+
min-width: 0;
|
|
226
|
+
overflow: hidden;
|
|
227
|
+
text-overflow: ellipsis;
|
|
228
|
+
white-space: nowrap;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
.row[data-density='timeline'] .line {
|
|
232
|
+
overflow: visible;
|
|
233
|
+
white-space: normal;
|
|
234
|
+
overflow-wrap: anywhere;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
.actor {
|
|
238
|
+
/* 550, the theme's medium: at 13 px a plain 500 reads the same as the sentence. */
|
|
239
|
+
font-weight: 550;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
.time {
|
|
243
|
+
grid-area: time;
|
|
244
|
+
font-family: var(--basalt-font-mono);
|
|
245
|
+
font-size: var(--vx-text-micro);
|
|
246
|
+
line-height: 1.4;
|
|
247
|
+
color: var(--vx-muted);
|
|
248
|
+
white-space: nowrap;
|
|
249
|
+
/* As tall as a row line and centred in it, so it sits on the first line of a wrapped body. */
|
|
250
|
+
display: flex;
|
|
251
|
+
align-items: center;
|
|
252
|
+
align-self: start;
|
|
253
|
+
block-size: calc(var(--vx-text-sm) * 1.4);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/* The meta line: the body wraps (never truncated) beside the time. */
|
|
257
|
+
.meta {
|
|
258
|
+
grid-area: meta;
|
|
259
|
+
min-width: 0;
|
|
260
|
+
color: var(--vx-muted);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.body {
|
|
264
|
+
min-width: 0;
|
|
265
|
+
overflow-wrap: anywhere;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/* The chips: one fixed line under the time (the row's third), whatever the body holds. */
|
|
269
|
+
.chips {
|
|
270
|
+
grid-area: chips;
|
|
271
|
+
display: flex;
|
|
272
|
+
flex-wrap: wrap;
|
|
273
|
+
align-items: center;
|
|
274
|
+
gap: var(--vx-space-control-gap);
|
|
275
|
+
padding-block-start: var(--vx-space-stack-xs);
|
|
276
|
+
font-size: var(--vx-text-micro);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/* A neutral chip needs a visible surface in light as well: the theme's subtle fill is the page. */
|
|
280
|
+
.chips :global(.mantine-Badge-root) {
|
|
281
|
+
background: var(--event-list-tint);
|
|
282
|
+
/* A chip is always the micro rung: Mantine writes `--badge-fz` inline from `size`, so the pin is the
|
|
283
|
+
property itself, which the class beats and the inline custom property does not reach. */
|
|
284
|
+
font-size: var(--vx-text-micro);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
.earlier {
|
|
288
|
+
display: flex;
|
|
289
|
+
justify-content: flex-start;
|
|
290
|
+
padding-block: var(--vx-space-stack-xs);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
.earlierButton:hover:not(:disabled, [data-disabled]) {
|
|
294
|
+
background: var(--event-list-hover);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
.skeletonGlyph {
|
|
298
|
+
inline-size: 0.5rem;
|
|
299
|
+
block-size: 0.5rem;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
.skeletonLine {
|
|
303
|
+
/* A share of the row, capped near a loaded sentence so a wide list does not stretch the bar. */
|
|
304
|
+
inline-size: min(70%, 28rem);
|
|
305
|
+
block-size: 0.75rem;
|
|
306
|
+
margin-block: 0.25rem;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
.skeletonTime {
|
|
310
|
+
inline-size: 3rem;
|
|
311
|
+
block-size: 0.625rem;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
.skeletonGroup {
|
|
315
|
+
min-width: 0;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
.skeletonHeader {
|
|
319
|
+
inline-size: 6rem;
|
|
320
|
+
block-size: 0.5rem;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
.skeletonChip {
|
|
324
|
+
inline-size: 3rem;
|
|
325
|
+
block-size: 1rem;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
.skeletonMeta {
|
|
329
|
+
inline-size: min(40%, 16rem);
|
|
330
|
+
block-size: 0.625rem;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/* The live region around the `EmptyState` tile (SPEC § 6.11); the tile paints its own ring. */
|
|
334
|
+
.empty {
|
|
335
|
+
display: block;
|
|
336
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed CSS-module declaration (the S4 CSS-modules path). Named string props — not an index
|
|
3
|
+
* signature — so dot access stays verbatim under the package's strict flags.
|
|
4
|
+
*/
|
|
5
|
+
declare const classes: {
|
|
6
|
+
readonly frame: string
|
|
7
|
+
readonly root: string
|
|
8
|
+
readonly scroll: string
|
|
9
|
+
readonly virtual: string
|
|
10
|
+
readonly skeleton: string
|
|
11
|
+
readonly group: string
|
|
12
|
+
readonly list: string
|
|
13
|
+
readonly header: string
|
|
14
|
+
readonly count: string
|
|
15
|
+
readonly row: string
|
|
16
|
+
readonly leading: string
|
|
17
|
+
readonly line: string
|
|
18
|
+
readonly actor: string
|
|
19
|
+
readonly time: string
|
|
20
|
+
readonly meta: string
|
|
21
|
+
readonly body: string
|
|
22
|
+
readonly chips: string
|
|
23
|
+
readonly earlier: string
|
|
24
|
+
readonly earlierButton: string
|
|
25
|
+
readonly empty: string
|
|
26
|
+
readonly skeletonGroup: string
|
|
27
|
+
readonly skeletonHeader: string
|
|
28
|
+
readonly skeletonChip: string
|
|
29
|
+
readonly skeletonGlyph: string
|
|
30
|
+
readonly skeletonLine: string
|
|
31
|
+
readonly skeletonTime: string
|
|
32
|
+
readonly skeletonMeta: string
|
|
33
|
+
}
|
|
34
|
+
export default classes
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EventList — a day-grouped feed or timeline of things that happened: a leading glyph, the actor and
|
|
3
|
+
* a sentence on line one; line two leads with the mono time, then the muted body and the chips. Choose it
|
|
4
|
+
* for activity, history and audit trails; a table is for comparing rows, this is for reading them
|
|
5
|
+
* in order. An HTML/CSS primitive (no chart engine).
|
|
6
|
+
*
|
|
7
|
+
* The caller's order is kept — the list never sorts. `order` only says which end is "earlier", so
|
|
8
|
+
* day groups and the `earlier` control land on the right edge. Days are local. Item `id`s are the
|
|
9
|
+
* rows' identity (keys, prepend anchoring): keep them unique and stable.
|
|
10
|
+
*
|
|
11
|
+
* The row is two lines at every width: line one is the glyph and `actor + sentence` (clamped to one line in
|
|
12
|
+
* `feed`, wrapping in `timeline`); line two leads with the time, then the body (it wraps, never
|
|
13
|
+
* truncates), then the chips (they follow its last word in the same flow, each chip unbroken). A row with no body or
|
|
14
|
+
* chips still has line two, the time alone; an untimed row's line two is body and chips only.
|
|
15
|
+
*
|
|
16
|
+
* Above 200 rows the rows window through the package's one lazy virtual-list seam
|
|
17
|
+
* (`@tanstack/react-virtual`, an optional peer); at or below it the list is plain DOM and the peer is
|
|
18
|
+
* never loaded. A list crossing 200 rows keeps its scroll node and may land a few rows off its place. With `height` the list owns its scroll node — an oldest-first list then opens on its
|
|
19
|
+
* newest end and keeps the visible row across a prepend; without it the rows follow the nearest
|
|
20
|
+
* scrolling ancestor (the shell's scrollport) and the page keeps scrolling. States follow `BarList`:
|
|
21
|
+
* `loading` is row-shaped skeletons (the box keeps its height), an empty list is an `EmptyState` tile
|
|
22
|
+
* (`empty`) that sizes to its content.
|
|
23
|
+
* An error is the caller's: `QueryState` is not a public export, so put the list in a `Section`
|
|
24
|
+
* with `query` (it owns the failure and its retry) or render your own error note.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* import { EventList } from 'basalt-ui'
|
|
28
|
+
*
|
|
29
|
+
* <EventList
|
|
30
|
+
* label="Activity"
|
|
31
|
+
* items={[{ id: 'e1', at: Date.now(), actor: 'Ada', title: 'merged #482', chips: <Badge>main</Badge> }]}
|
|
32
|
+
* earlier={{ onLoad: loadMore, remaining: 12 }}
|
|
33
|
+
* />
|
|
34
|
+
*
|
|
35
|
+
* // A record's history: rail, full sentences, oldest first, in a box that opens on the newest event.
|
|
36
|
+
* <EventList label="History" density="timeline" order="oldest-first" height={440} items={events} />
|
|
37
|
+
*/
|
|
38
|
+
import { Button, VisuallyHidden } from '@mantine/core'
|
|
39
|
+
import { useId, useRef, useState, useSyncExternalStore } from 'react'
|
|
40
|
+
import type { CSSProperties, ReactNode } from 'react'
|
|
41
|
+
import { cx, pickDataAttributes } from '../common/props'
|
|
42
|
+
import type { BasaltProps, DataAttributes } from '../common/props'
|
|
43
|
+
import { VirtualRows } from '../common/virtual-rows'
|
|
44
|
+
import classes from './event-list.module.css'
|
|
45
|
+
import { EmptyState } from './empty-state'
|
|
46
|
+
import { buildRows, DayHeader, EventRow } from './event-list-rows'
|
|
47
|
+
import {
|
|
48
|
+
defaultDayLabel,
|
|
49
|
+
groupByDay,
|
|
50
|
+
isValidEventDate,
|
|
51
|
+
present,
|
|
52
|
+
skeletonRowCount,
|
|
53
|
+
toEventDate,
|
|
54
|
+
} from './event-list-model'
|
|
55
|
+
import type { RowContext } from './event-list-model'
|
|
56
|
+
import {
|
|
57
|
+
useHeldHeight,
|
|
58
|
+
useOpenAtEnd,
|
|
59
|
+
usePrependAnchor,
|
|
60
|
+
useRowBoundary,
|
|
61
|
+
useScrolledEdge,
|
|
62
|
+
} from './event-list-scroll'
|
|
63
|
+
import { SkeletonRows } from './event-list-skeleton'
|
|
64
|
+
|
|
65
|
+
/** Rows above this window through the virtual-list seam; at or below it the list is plain DOM. */
|
|
66
|
+
const VIRTUALIZE_THRESHOLD = 200
|
|
67
|
+
|
|
68
|
+
export type EventListProps = BasaltProps &
|
|
69
|
+
DataAttributes & {
|
|
70
|
+
/** Accessible name of the list. Default "Events". */
|
|
71
|
+
label?: string
|
|
72
|
+
/** Events in display order — kept as given, never re-sorted. `id`s must be unique within the list. */
|
|
73
|
+
items: readonly {
|
|
74
|
+
id: string
|
|
75
|
+
at: Date | number
|
|
76
|
+
actor?: ReactNode
|
|
77
|
+
title: ReactNode
|
|
78
|
+
body?: ReactNode
|
|
79
|
+
/** A glyph or avatar in the leading column. */
|
|
80
|
+
leading?: ReactNode
|
|
81
|
+
chips?: ReactNode
|
|
82
|
+
}[]
|
|
83
|
+
/** `feed`: one clamped line, about 52 px a two-line row. `timeline`: a rail, full sentences, body and chips in full. */
|
|
84
|
+
density?: 'feed' | 'timeline'
|
|
85
|
+
/** The 1 px line through the leading column joining rows within a day group. Default: `density === 'timeline'`. */
|
|
86
|
+
rail?: boolean
|
|
87
|
+
/** Day headers (`micro` mono, muted, with the row count) or one flat list. Default `day`. */
|
|
88
|
+
group?: 'day' | 'none'
|
|
89
|
+
/**
|
|
90
|
+
* The instant "Today" and relative times are measured from. Default: the client clock, read once
|
|
91
|
+
* after mount; until then (the server render, the hydrating paint) days read as dates and a
|
|
92
|
+
* `relative` time as a date-time, so server and client markup match.
|
|
93
|
+
*/
|
|
94
|
+
now?: number | Date
|
|
95
|
+
/** Overrides the `Today` / `Yesterday` / short-date header text. Without a clock yet, `now` is the day itself. */
|
|
96
|
+
dayLabel?: (day: Date, now: Date) => string
|
|
97
|
+
/**
|
|
98
|
+
* The time column. Default `clock` when grouped by day, `date-time` when not. A function formats it
|
|
99
|
+
* yourself; one returning an empty string renders no time for that row (an untimed entry).
|
|
100
|
+
*/
|
|
101
|
+
time?: 'clock' | 'relative' | 'date-time' | ((at: Date) => string)
|
|
102
|
+
/** Which end of `items` is earlier. Does not sort. Default `newest-first`. */
|
|
103
|
+
order?: 'newest-first' | 'oldest-first'
|
|
104
|
+
/**
|
|
105
|
+
* A quiet "Show earlier (N)" control at the earlier end (bottom for newest-first, top for
|
|
106
|
+
* oldest-first). With `height`, prepending (oldest-first) keeps the visible row where it is and a
|
|
107
|
+
* list opens on its newest end; a content-sized list leaves scrolling to the page.
|
|
108
|
+
*/
|
|
109
|
+
earlier?: { onLoad: () => void; loading?: boolean; remaining?: number }
|
|
110
|
+
/** The list owns a scroll node of this height (modal, aside, card). Omitted: content-sized. */
|
|
111
|
+
height?: number | string
|
|
112
|
+
/** Renders row-shaped skeletons. */
|
|
113
|
+
loading?: boolean
|
|
114
|
+
/** Skeleton rows while loading. Default: the rows `items` holds now (a refetch, capped at 30), else 5. */
|
|
115
|
+
loadingRows?: number
|
|
116
|
+
/**
|
|
117
|
+
* The empty state, an `EmptyState` in a ring-edged tile that sizes to its content (no void in a
|
|
118
|
+
* bounded `height`). Default: "Nothing has happened yet" with a one-line why.
|
|
119
|
+
*/
|
|
120
|
+
empty?: { title: string; description?: string; action?: ReactNode }
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const subscribeNever = (): (() => void) => () => {}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* The client clock, read once after mount through `useSyncExternalStore` (the server snapshot is
|
|
127
|
+
* `null`, like `SyncButton`'s age): a server render never reads `Date.now()`, and the hydrating
|
|
128
|
+
* paint matches it before React re-renders with the real clock.
|
|
129
|
+
*/
|
|
130
|
+
function useClientClock(): number | null {
|
|
131
|
+
const at = useRef<number | null>(null)
|
|
132
|
+
return useSyncExternalStore(
|
|
133
|
+
subscribeNever,
|
|
134
|
+
() => (at.current ??= Date.now()),
|
|
135
|
+
() => null,
|
|
136
|
+
)
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** Whether these rows were plain before: set while plain rows show, cleared when the rows go. */
|
|
140
|
+
function usePlainBefore(hasRows: boolean, windowed: boolean): boolean {
|
|
141
|
+
const [plain, setPlain] = useState(false)
|
|
142
|
+
const next = hasRows ? plain || !windowed : false
|
|
143
|
+
if (next !== plain) setPlain(next)
|
|
144
|
+
return next
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const DEFAULT_EMPTY = {
|
|
148
|
+
title: 'Nothing has happened yet',
|
|
149
|
+
description: 'Events appear here as they happen.',
|
|
150
|
+
} as const
|
|
151
|
+
|
|
152
|
+
export function EventList({
|
|
153
|
+
label = 'Events',
|
|
154
|
+
items,
|
|
155
|
+
density = 'feed',
|
|
156
|
+
rail,
|
|
157
|
+
group = 'day',
|
|
158
|
+
now,
|
|
159
|
+
dayLabel,
|
|
160
|
+
time,
|
|
161
|
+
order = 'newest-first',
|
|
162
|
+
earlier,
|
|
163
|
+
height,
|
|
164
|
+
loading = false,
|
|
165
|
+
loadingRows,
|
|
166
|
+
empty = DEFAULT_EMPTY,
|
|
167
|
+
className,
|
|
168
|
+
style,
|
|
169
|
+
...rest
|
|
170
|
+
}: EventListProps) {
|
|
171
|
+
const clock = useClientClock()
|
|
172
|
+
// The scroll node as state, so a windowed list can wait for it (see `VirtualRows` `scrollRoot`).
|
|
173
|
+
const [scrollEl, setScrollEl] = useState<HTMLDivElement | null>(null)
|
|
174
|
+
const labelId = useId()
|
|
175
|
+
const nowDate = now !== undefined ? new Date(now) : clock === null ? null : new Date(clock)
|
|
176
|
+
const grouped = group === 'day'
|
|
177
|
+
const withRail = rail ?? density === 'timeline'
|
|
178
|
+
const ctx: RowContext = {
|
|
179
|
+
density,
|
|
180
|
+
rail: withRail,
|
|
181
|
+
lead: withRail || items.some((i) => present(i.leading)),
|
|
182
|
+
timeMode: time ?? (grouped ? 'clock' : 'date-time'),
|
|
183
|
+
now: nowDate,
|
|
184
|
+
}
|
|
185
|
+
const oldestFirst = order === 'oldest-first'
|
|
186
|
+
const hasRows = !loading && items.length > 0
|
|
187
|
+
const virtualised = hasRows && items.length > VIRTUALIZE_THRESHOLD
|
|
188
|
+
const ownScroll = height !== undefined
|
|
189
|
+
const opensAtEnd = oldestFirst && ownScroll
|
|
190
|
+
const plainBefore = usePlainBefore(hasRows, virtualised)
|
|
191
|
+
usePrependAnchor(scrollEl, opensAtEnd && hasRows && !virtualised, items)
|
|
192
|
+
useOpenAtEnd(scrollEl, opensAtEnd && hasRows && !virtualised, items.length)
|
|
193
|
+
useRowBoundary(scrollEl, opensAtEnd && hasRows && !virtualised)
|
|
194
|
+
useScrolledEdge(ownScroll ? scrollEl : null)
|
|
195
|
+
useHeldHeight(
|
|
196
|
+
scrollEl,
|
|
197
|
+
loading ? 'loading' : !hasRows ? 'none' : virtualised ? 'windowed' : 'plain',
|
|
198
|
+
)
|
|
199
|
+
|
|
200
|
+
const control =
|
|
201
|
+
earlier === undefined || !hasRows ? null : (
|
|
202
|
+
<div className={classes.earlier} data-end={oldestFirst ? 'top' : 'bottom'}>
|
|
203
|
+
<Button
|
|
204
|
+
variant="default"
|
|
205
|
+
size="compact-sm"
|
|
206
|
+
className={classes.earlierButton}
|
|
207
|
+
loading={earlier.loading === true}
|
|
208
|
+
onClick={earlier.onLoad}
|
|
209
|
+
>
|
|
210
|
+
{earlier.remaining === undefined ? 'Show earlier' : `Show earlier (${earlier.remaining})`}
|
|
211
|
+
</Button>
|
|
212
|
+
</div>
|
|
213
|
+
)
|
|
214
|
+
|
|
215
|
+
let content: ReactNode
|
|
216
|
+
if (loading) {
|
|
217
|
+
content = (
|
|
218
|
+
<div aria-busy="true" className={classes.skeleton}>
|
|
219
|
+
<VisuallyHidden>{`Loading ${label}`}</VisuallyHidden>
|
|
220
|
+
<SkeletonRows
|
|
221
|
+
count={skeletonRowCount(loadingRows, items.length)}
|
|
222
|
+
ctx={ctx}
|
|
223
|
+
grouped={grouped}
|
|
224
|
+
height={height}
|
|
225
|
+
/>
|
|
226
|
+
</div>
|
|
227
|
+
)
|
|
228
|
+
} else if (items.length === 0) {
|
|
229
|
+
content = (
|
|
230
|
+
// oxlint-disable-next-line jsx-a11y/prefer-tag-over-role -- a polite live region whose name is the visually hidden label inside
|
|
231
|
+
<div className={classes.empty} role="status">
|
|
232
|
+
<VisuallyHidden>{label}</VisuallyHidden>
|
|
233
|
+
<EmptyState
|
|
234
|
+
tier="section"
|
|
235
|
+
title={empty.title}
|
|
236
|
+
{...(empty.description !== undefined && { description: empty.description })}
|
|
237
|
+
{...(empty.action !== undefined && { action: empty.action })}
|
|
238
|
+
/>
|
|
239
|
+
</div>
|
|
240
|
+
)
|
|
241
|
+
} else {
|
|
242
|
+
const groups = grouped
|
|
243
|
+
? groupByDay(items)
|
|
244
|
+
: [{ day: toEventDate(items[0]?.at ?? 0), key: 'all', id: 'all#0', items }]
|
|
245
|
+
// A list with no real instant has no day to name: no headers, whatever `group` says.
|
|
246
|
+
const showHeaders = grouped && groups.some((g) => isValidEventDate(g.day))
|
|
247
|
+
// A caller's `dayLabel` only ever sees a real day.
|
|
248
|
+
const headerText = (day: Date): string =>
|
|
249
|
+
!isValidEventDate(day)
|
|
250
|
+
? ''
|
|
251
|
+
: dayLabel === undefined
|
|
252
|
+
? defaultDayLabel(day, nowDate)
|
|
253
|
+
: dayLabel(day, nowDate ?? day)
|
|
254
|
+
if (virtualised) {
|
|
255
|
+
const seam = {
|
|
256
|
+
rows: buildRows(groups, showHeaders, ctx, headerText),
|
|
257
|
+
overscan: 8,
|
|
258
|
+
estimateSize: density === 'timeline' ? 96 : 60,
|
|
259
|
+
className: classes.virtual,
|
|
260
|
+
anchorTo: oldestFirst ? ('end' as const) : ('start' as const),
|
|
261
|
+
// The shell scrollport is never jumped: only an own scroll node opens on its newest end.
|
|
262
|
+
// And only when the rows first appeared windowed: a list crossing 200 on an `earlier` load
|
|
263
|
+
// does not jump to the newest end.
|
|
264
|
+
initialScroll: opensAtEnd && !plainBefore ? ('end' as const) : ('start' as const),
|
|
265
|
+
// Own scroll node → the seam windows against it; none → the nearest scrolling ancestor.
|
|
266
|
+
...(ownScroll && { scrollRoot: scrollEl }),
|
|
267
|
+
}
|
|
268
|
+
content = (
|
|
269
|
+
// oxlint-disable-next-line jsx-a11y/prefer-tag-over-role -- the seam renders divs, so the list role is explicit
|
|
270
|
+
<div role="list" aria-label={label}>
|
|
271
|
+
<VirtualRows scroll="parent" {...seam} />
|
|
272
|
+
</div>
|
|
273
|
+
)
|
|
274
|
+
} else {
|
|
275
|
+
content = groups.map((g) => {
|
|
276
|
+
// Per run (day + occurrence), so the same day can open two runs and a same-day prepend
|
|
277
|
+
// does not remount the group.
|
|
278
|
+
const headerId = `${labelId}-${g.id}`
|
|
279
|
+
return (
|
|
280
|
+
<div key={g.id} className={classes.group}>
|
|
281
|
+
{showHeaders && (
|
|
282
|
+
<DayHeader id={headerId} text={headerText(g.day)} count={g.items.length} as="h3" />
|
|
283
|
+
)}
|
|
284
|
+
<ol
|
|
285
|
+
className={classes.list}
|
|
286
|
+
// The explicit role is deliberate: `list-style: none` makes Safari/VoiceOver drop the implicit one.
|
|
287
|
+
// oxlint-disable-next-line jsx-a11y/no-redundant-roles
|
|
288
|
+
role="list"
|
|
289
|
+
{...(showHeaders ? { 'aria-labelledby': headerId } : { 'aria-label': label })}
|
|
290
|
+
>
|
|
291
|
+
{g.items.map((item, i) => (
|
|
292
|
+
<EventRow
|
|
293
|
+
key={item.id}
|
|
294
|
+
item={item}
|
|
295
|
+
ctx={ctx}
|
|
296
|
+
first={i === 0}
|
|
297
|
+
last={i === g.items.length - 1}
|
|
298
|
+
tag="li"
|
|
299
|
+
/>
|
|
300
|
+
))}
|
|
301
|
+
</ol>
|
|
302
|
+
</div>
|
|
303
|
+
)
|
|
304
|
+
})
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
// The box keeps its height for rows and skeletons; an empty state sizes to its content.
|
|
309
|
+
const boxed = ownScroll && (loading || items.length > 0)
|
|
310
|
+
// `--event-list-trim` is set by `useRowBoundary`: the box gives up the remainder of a row it would cut.
|
|
311
|
+
const scrollStyle: CSSProperties | undefined = boxed
|
|
312
|
+
? {
|
|
313
|
+
height: `calc(${typeof height === 'number' ? `${height}px` : String(height)} - var(--event-list-trim, 0px))`,
|
|
314
|
+
}
|
|
315
|
+
: undefined
|
|
316
|
+
return (
|
|
317
|
+
<div
|
|
318
|
+
{...pickDataAttributes(rest)}
|
|
319
|
+
className={cx(classes.frame, className)}
|
|
320
|
+
style={style}
|
|
321
|
+
data-density={density}
|
|
322
|
+
>
|
|
323
|
+
{oldestFirst && control}
|
|
324
|
+
{/* theme-allow raw-scroll-container — the list owns its scroll node when given a height, like the virtual seam. */}
|
|
325
|
+
<div
|
|
326
|
+
ref={setScrollEl}
|
|
327
|
+
className={cx(classes.root, boxed && classes.scroll)}
|
|
328
|
+
style={scrollStyle}
|
|
329
|
+
>
|
|
330
|
+
{/* One wrapper around whatever shows, so its box is the content's box (see useHeldHeight). */}
|
|
331
|
+
<div>{content}</div>
|
|
332
|
+
</div>
|
|
333
|
+
{!oldestFirst && control}
|
|
334
|
+
</div>
|
|
335
|
+
)
|
|
336
|
+
}
|