basalt-ui 2.27.1 → 2.28.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 +111 -0
- package/MIGRATING.md +172 -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-design/SKILL.md +1 -1
- package/agent/skills/basalt-design/references/catalogue.md +40 -36
- package/agent/skills/basalt-design/references/recipes.md +47 -0
- package/configs/oxlint-basalt.json +2 -1
- package/configs/oxlint-plugin.js +110 -2
- package/configs/oxlint-plugin.test.ts +99 -4
- 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 +5 -2
- package/dist/charts/ChartCard.d.ts.map +1 -1
- package/dist/charts/ChartCard.js +46 -13
- package/dist/charts/Lines.d.ts.map +1 -1
- package/dist/charts/Lines.js +11 -4
- package/dist/charts/Sparkline.d.ts +9 -2
- package/dist/charts/Sparkline.d.ts.map +1 -1
- package/dist/charts/Sparkline.js +104 -41
- package/dist/charts/chart-box.module.css +69 -3
- package/dist/charts/chart-box.module.css.d.ts +5 -0
- package/dist/charts/chart-card.module.css +12 -4
- package/dist/charts/chart-card.module.css.d.ts +1 -0
- package/dist/charts/compile.d.ts.map +1 -1
- package/dist/charts/compile.js +21 -19
- 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 +31 -8
- package/dist/charts/ref-label.d.ts.map +1 -1
- package/dist/charts/ref-label.js +40 -9
- package/dist/charts/sparkline.module.css +6 -0
- package/dist/charts/state.d.ts +3 -3
- package/dist/charts/state.d.ts.map +1 -1
- package/dist/charts/state.js +20 -2
- package/dist/cli/shot/capture.d.ts +6 -1
- package/dist/cli/shot/capture.d.ts.map +1 -1
- package/dist/cli/shot/capture.js +18 -5
- 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/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 +1 -1
- package/dist/dashboard/bar-list.d.ts.map +1 -1
- package/dist/dashboard/bar-list.js +6 -2
- package/dist/dashboard/bar-list.module.css +0 -2
- 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 +228 -0
- package/dist/dashboard/board.module.css +160 -0
- package/dist/dashboard/board.module.css.d.ts +26 -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 +13 -6
- package/dist/dashboard/event-list-model.d.ts +51 -0
- package/dist/dashboard/event-list-model.d.ts.map +1 -0
- package/dist/dashboard/event-list-model.js +72 -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 +93 -0
- package/dist/dashboard/event-list-scroll.d.ts +27 -0
- package/dist/dashboard/event-list-scroll.d.ts.map +1 -0
- package/dist/dashboard/event-list-scroll.js +103 -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 +36 -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 +178 -0
- package/dist/dashboard/event-list.module.css +283 -0
- package/dist/dashboard/event-list.module.css.d.ts +33 -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-parts.d.ts.map +1 -1
- package/dist/dashboard/meter-parts.js +5 -3
- package/dist/dashboard/meter.module.css +2 -1
- package/dist/dashboard/query-state.js +1 -1
- package/dist/dashboard/settings-section.d.ts +4 -1
- package/dist/dashboard/settings-section.d.ts.map +1 -1
- package/dist/dashboard/settings-section.js +1 -1
- package/dist/dashboard/settings-section.module.css +19 -4
- 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.map +1 -1
- package/dist/dashboard/stat-card.js +26 -7
- package/dist/dashboard/stat-card.module.css +31 -7
- package/dist/dashboard/stat-card.module.css.d.ts +3 -0
- package/dist/dashboard/stat-strip.js +1 -1
- package/dist/dashboard/stat-strip.module.css +4 -1
- package/dist/dashboard/widget-header.d.ts.map +1 -1
- package/dist/dashboard/widget-header.js +15 -2
- package/dist/dashboard/widget-header.module.css +17 -1
- package/dist/guard/index.d.ts.map +1 -1
- package/dist/guard/index.js +2 -0
- 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 +46 -8
- 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 +44 -0
- package/dist/table/cell-kinds.d.ts.map +1 -0
- package/dist/table/cell-kinds.js +169 -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 +147 -0
- package/dist/table/data-table-fold.d.ts.map +1 -0
- package/dist/table/data-table-fold.js +288 -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 +11 -26
- package/dist/table/data-table.d.ts.map +1 -1
- package/dist/table/data-table.js +354 -254
- package/dist/table/data-table.module.css +210 -3
- package/dist/table/data-table.module.css.d.ts +12 -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 +32 -0
- 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 +34 -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 +79 -17
- package/src/charts/Lines.tsx +13 -4
- package/src/charts/Sparkline.tsx +131 -45
- package/src/charts/chart-box.module.css +69 -3
- package/src/charts/chart-box.module.css.d.ts +5 -0
- package/src/charts/chart-card.module.css +12 -4
- package/src/charts/chart-card.module.css.d.ts +1 -0
- package/src/charts/compile.ts +24 -20
- package/src/charts/labels.ts +175 -24
- package/src/charts/legend.tsx +3 -2
- package/src/charts/ref-label.ts +86 -17
- package/src/charts/sparkline.module.css +6 -0
- package/src/charts/state.tsx +36 -7
- package/src/cli/shot/capture.ts +29 -6
- package/src/common/empty-copy.ts +17 -0
- 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 +0 -2
- package/src/dashboard/bar-list.tsx +8 -5
- package/src/dashboard/board-nav.ts +67 -0
- package/src/dashboard/board.module.css +160 -0
- package/src/dashboard/board.module.css.d.ts +26 -0
- package/src/dashboard/board.tsx +394 -0
- package/src/dashboard/empty-state.tsx +16 -9
- package/src/dashboard/event-list-model.ts +113 -0
- package/src/dashboard/event-list-rows.tsx +120 -0
- package/src/dashboard/event-list-scroll.ts +145 -0
- package/src/dashboard/event-list-skeleton.tsx +58 -0
- package/src/dashboard/event-list.module.css +283 -0
- package/src/dashboard/event-list.module.css.d.ts +33 -0
- package/src/dashboard/event-list.tsx +309 -0
- package/src/dashboard/index.ts +2 -0
- package/src/dashboard/meter-parts.tsx +9 -2
- package/src/dashboard/meter.module.css +2 -1
- package/src/dashboard/query-state.tsx +1 -1
- package/src/dashboard/settings-section.module.css +19 -4
- package/src/dashboard/settings-section.tsx +7 -2
- package/src/dashboard/stat-card-parts.tsx +20 -3
- package/src/dashboard/stat-card.module.css +31 -7
- package/src/dashboard/stat-card.module.css.d.ts +3 -0
- package/src/dashboard/stat-card.tsx +25 -6
- package/src/dashboard/stat-strip.module.css +4 -1
- package/src/dashboard/stat-strip.tsx +1 -1
- package/src/dashboard/widget-header.module.css +17 -1
- package/src/dashboard/widget-header.tsx +29 -5
- package/src/guard/index.ts +2 -0
- package/src/index.ts +4 -0
- package/src/shell/app-main.module.css +18 -0
- package/src/styles.css +46 -8
- 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 +234 -0
- package/src/table/data-table-fold.tsx +514 -0
- package/src/table/data-table-state.ts +24 -13
- package/src/table/data-table.module.css +210 -3
- package/src/table/data-table.module.css.d.ts +12 -0
- package/src/table/data-table.tsx +406 -359
- 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 +32 -0
- 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,196 @@
|
|
|
1
|
+
import type { JSX, ReactNode } from 'react';
|
|
2
|
+
import type { Range } from '@tanstack/react-virtual';
|
|
3
|
+
import type { BasaltProps } from './props.js';
|
|
4
|
+
export type VirtualRow = {
|
|
5
|
+
readonly key: string;
|
|
6
|
+
readonly node: ReactNode;
|
|
7
|
+
/** A group header: the active one stays rendered while scrolled and is drawn `position: sticky`. */
|
|
8
|
+
readonly sticky?: boolean;
|
|
9
|
+
};
|
|
10
|
+
type InitialScroll = 'start' | 'end';
|
|
11
|
+
type ScrollOwner = {
|
|
12
|
+
readonly height: number | string;
|
|
13
|
+
readonly scroll?: never;
|
|
14
|
+
} | {
|
|
15
|
+
readonly scroll: 'parent';
|
|
16
|
+
readonly height?: never;
|
|
17
|
+
/**
|
|
18
|
+
* The caller's own scroll node for the parent mode, instead of the detected scrolling ancestor:
|
|
19
|
+
* lets one stable element own the scroll whether or not its rows are windowed. `null` = not
|
|
20
|
+
* mounted yet (the rows wait for it); omitted = detect the ancestor.
|
|
21
|
+
*/
|
|
22
|
+
readonly scrollRoot?: HTMLElement | null;
|
|
23
|
+
};
|
|
24
|
+
export type VirtualRowsProps = BasaltProps & ScrollOwner & {
|
|
25
|
+
readonly rows: readonly VirtualRow[];
|
|
26
|
+
/** Extra rows rendered beyond the viewport, each side. */
|
|
27
|
+
readonly overscan: number;
|
|
28
|
+
/** Estimated row height in px before a row is measured; estimate toward the LARGER end. */
|
|
29
|
+
readonly estimateSize: number;
|
|
30
|
+
/** px between rows. Default 0. */
|
|
31
|
+
readonly gap?: number;
|
|
32
|
+
/** Row gap of the peer-absent degrade when it should differ from the windowed `gap`. */
|
|
33
|
+
readonly fallbackGap?: number | string;
|
|
34
|
+
/** Where the list sits on first mount. Default 'start'. */
|
|
35
|
+
readonly initialScroll?: InitialScroll;
|
|
36
|
+
/** Which edge a count/edge-key change keeps fixed. Default 'start'. */
|
|
37
|
+
readonly anchorTo?: 'start' | 'end';
|
|
38
|
+
/** Follow an append while at the end. Default false. */
|
|
39
|
+
readonly followOnAppend?: boolean;
|
|
40
|
+
};
|
|
41
|
+
/** Caps `applyInitialScroll`'s clobber-recovery retries (see `agent/chat/virtualize.ts`'s fourth composition
|
|
42
|
+
* rule for the full mechanism this guards). A small fixed budget, not a time/frame-based deadline:
|
|
43
|
+
* every observed case of virtual-core's `_willUpdate` clobbering this effect's jump resolves within
|
|
44
|
+
* one extra commit, so this exists purely as a backstop against a pathological DOM that never
|
|
45
|
+
* reports settled — not as the expected path. Once exhausted, the effect gives up and marks the
|
|
46
|
+
* jump permanently done wherever the last attempt landed, rather than fighting the DOM (or a user
|
|
47
|
+
* who has since scrolled away) forever. Exported (like `messageBlockRenderCounter`) purely so its
|
|
48
|
+
* test can assert the exact bound without duplicating the number; not part of the public surface. */
|
|
49
|
+
export declare const MAX_INITIAL_SCROLL_ATTEMPTS = 5;
|
|
50
|
+
/**
|
|
51
|
+
* Minimal structural slice of `Virtualizer` (virtual-core 3.18.0) that
|
|
52
|
+
* {@link resolveGuardedMeasurement} needs — `indexFromElement`/`itemSizeCache`/`options` are all
|
|
53
|
+
* public instance members, but typing against the real (generic, peer-only) `Virtualizer` class
|
|
54
|
+
* would force this test-only-exported helper to import the peer's runtime types at module scope,
|
|
55
|
+
* the exact static-import-forces-the-peer problem the surrounding `lazy(() => import(...))` exists
|
|
56
|
+
* to avoid. A structural type sidesteps that without loosening to `any`. Generic over the item
|
|
57
|
+
* element type (rather than fixed at `Element`) so it stays exactly assignable FROM a real
|
|
58
|
+
* `Virtualizer<TScrollElement, TItemElement>` at the call site below — `indexFromElement` is
|
|
59
|
+
* declared with arrow-property (not method) syntax upstream, so it is checked contravariantly, and
|
|
60
|
+
* a fixed `Element` parameter there does not structurally match a real instance's narrower
|
|
61
|
+
* `TItemElement` parameter.
|
|
62
|
+
*/
|
|
63
|
+
type MeasurementCacheHost<TItemElement extends Element> = {
|
|
64
|
+
readonly indexFromElement: (node: TItemElement) => number;
|
|
65
|
+
readonly itemSizeCache: Map<unknown, number>;
|
|
66
|
+
readonly options: {
|
|
67
|
+
readonly getItemKey: (index: number) => unknown;
|
|
68
|
+
readonly estimateSize: (index: number) => number;
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Resolves the size a `measureElement` implementation should report, given what the underlying
|
|
73
|
+
* (default or custom) measurement already produced: that value unchanged when it is a genuine
|
|
74
|
+
* measurement, or the row's own last-known size when it is `0` — never a real reading for a mounted
|
|
75
|
+
* row, so a `0` only ever means the ResizeObserver measured through a `display: none` (or otherwise
|
|
76
|
+
* unlaid-out) ancestor, e.g. a virtualized transcript sitting inside a collapsed `ThreadFeedRow`.
|
|
77
|
+
* Falling through to it unguarded is what corrupted `itemSizeCache`/`measurementsCache`: virtual-
|
|
78
|
+
* core's default `resizeItem` writes whatever `measureElement` returns with no floor, so every
|
|
79
|
+
* mounted row remeasures at 0px the instant an ancestor hides, `getTotalSize()` collapses within
|
|
80
|
+
* the same tick, and the collapse is never undone — a later real remeasurement only OVERWRITES
|
|
81
|
+
* entries the ResizeObserver happens to re-fire for, it does not restore ones that silently kept
|
|
82
|
+
* their poisoned 0 (see `virtualize.ts`'s composition-rule doc for the full mechanism and the
|
|
83
|
+
* measured numbers).
|
|
84
|
+
*
|
|
85
|
+
* Takes the already-computed `size` plus the {@link MeasurementCacheHost} slice, rather than
|
|
86
|
+
* wrapping the `measureElement` function itself, so this stays a plain, non-generic-over-a-
|
|
87
|
+
* generic-function call at its one call site below (`instance` there is `Virtualizer<TScrollElement,
|
|
88
|
+
* TItemElement>` for THAT call's concrete type arguments, not the peer's own generic
|
|
89
|
+
* `measureElement` export — wrapping the latter directly hits TS's higher-rank inference limits on
|
|
90
|
+
* a doubly-generic HOF). That shape is also what makes this unit-testable with a fake host object
|
|
91
|
+
* and no ResizeObserver/layout engine at all (happy-dom has neither). Not exported from
|
|
92
|
+
* `agent-chat/index.ts`: a test-only escape hatch, matching
|
|
93
|
+
* `messageBlockRenderCounter`/`nonVirtualizedRowsFallback` above.
|
|
94
|
+
*/
|
|
95
|
+
export declare function resolveGuardedMeasurement<TItemElement extends Element>(host: MeasurementCacheHost<TItemElement>, element: TItemElement, size: number): number;
|
|
96
|
+
/**
|
|
97
|
+
* Decides what `VirtualRowsInner`'s one-shot initial-scroll effect should do this render,
|
|
98
|
+
* given the inputs the effect closes over. Pure and peer/DOM-free — pulled out of the lazy-loaded
|
|
99
|
+
* closure for the same reason `resolveGuardedMeasurement` is: it stays unit-testable without a
|
|
100
|
+
* real `Virtualizer` instance or `@tanstack/react-virtual` itself.
|
|
101
|
+
*
|
|
102
|
+
* `'start'` and an empty transcript resolve to `'skip-done'` — there is nothing to scroll to, and
|
|
103
|
+
* DONE is permanent (see `virtualize.ts`'s fourth composition rule: the real scroll must fire at
|
|
104
|
+
* most once, ever, so a later append never yanks a user who has scrolled up). A non-positive
|
|
105
|
+
* `containerHeight` — the transcript's own scroll node measuring `0`, e.g. mounted behind a
|
|
106
|
+
* `display: none` ancestor per `virtualize.ts`'s third composition rule — resolves to
|
|
107
|
+
* `'skip-retry'`: NOT done, so the caller's effect (which re-runs after EVERY commit until the jump
|
|
108
|
+
* lands — see {@link applyInitialScroll}) gets another chance the next time this subtree renders,
|
|
109
|
+
* instead of permanently stranding the transcript at the top the moment it becomes visible. Only a
|
|
110
|
+
* genuinely measured, non-empty, `'end'`-targeted mount resolves to `'scroll'`.
|
|
111
|
+
*/
|
|
112
|
+
export declare function resolveInitialScrollAction(initialScroll: InitialScroll, rowCount: number, containerHeight: number): 'scroll' | 'skip-done' | 'skip-retry';
|
|
113
|
+
/** The mutable half of the one-shot initial-scroll contract. `hasApplied` is whether it has
|
|
114
|
+
* PERMANENTLY finished — either there was nothing to do (`'start'`/empty transcript), or
|
|
115
|
+
* `scrollToEnd` fired and was subsequently CONFIRMED (via a real DOM read — see
|
|
116
|
+
* {@link applyInitialScroll}'s doc for why virtual-core's own tracked offset can't be trusted for
|
|
117
|
+
* this) to have survived whatever else committed since. `attempts` counts how many times
|
|
118
|
+
* `scrollToEnd` has been (re-)fired this mount; 0 means never attempted, and also gates whether a
|
|
119
|
+
* call re-derives {@link resolveInitialScrollAction} at all. One instance lives for the lifetime of
|
|
120
|
+
* a `VirtualRowsInner` mount, held in a `useRef` so it survives re-renders without itself
|
|
121
|
+
* triggering one. */
|
|
122
|
+
export type InitialScrollState = {
|
|
123
|
+
hasApplied: boolean;
|
|
124
|
+
attempts: number;
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* The stateful half of "fires once, on first mount, and never again" (`virtualize.ts`'s fourth
|
|
128
|
+
* composition rule): wraps {@link resolveInitialScrollAction}'s per-call decision with the
|
|
129
|
+
* ACROSS-CALLS memory that decision alone can't carry. Exported (like `resolveGuardedMeasurement`)
|
|
130
|
+
* so `VirtualRowsInner`'s effect below calls this SAME function rather than a hand-mirrored
|
|
131
|
+
* copy for tests — a fake `scrollToEnd` is the only DOM/peer-free way to prove the guard, since a
|
|
132
|
+
* real `Virtualizer`'s own `followOnAppend` also calls the real DOM `scrollTo` on a later append,
|
|
133
|
+
* making that specific call indistinguishable from this one at the DOM boundary (see this
|
|
134
|
+
* function's test suite for the measurement that ruled that boundary out).
|
|
135
|
+
*
|
|
136
|
+
* Firing `scrollToEnd()` once is NOT the same as landing there: virtual-core 3.18.0's own
|
|
137
|
+
* `_willUpdate` (verified against the installed dist) writes to the SAME scroll container from
|
|
138
|
+
* `this.scrollOffset`, which updates only from the ASYNCHRONOUS native `scroll` event — never from
|
|
139
|
+
* the synchronous call that requested a scroll. A commit that runs `_willUpdate` before this
|
|
140
|
+
* effect gets a turn (element-attach) or that re-derives an anchor while `scrollOffset` still holds
|
|
141
|
+
* the pre-jump value writes that STALE offset straight back to `scrollTop`, undoing the jump within
|
|
142
|
+
* about one extra commit of it landing (see `agent/chat/virtualize.ts`'s fourth composition rule for the full
|
|
143
|
+
* trace this was diagnosed from). So `resolveInitialScrollAction`'s `'scroll'` outcome does not, by
|
|
144
|
+
* itself, set `hasApplied`: `isAtEnd` — a real `scrollTop`/`scrollHeight`/`clientHeight` read, the
|
|
145
|
+
* one piece of ground truth that is NEVER stale, unlike virtual-core's own tracked offset — is
|
|
146
|
+
* consulted on the NEXT call (i.e. the next commit, exactly the cadence this dependency-free effect
|
|
147
|
+
* already runs on) to confirm the jump survived. If it didn't, `scrollToEnd` fires again; if it did,
|
|
148
|
+
* `hasApplied` is set and the effect is inert for the rest of the mount. `MAX_INITIAL_SCROLL_ATTEMPTS`
|
|
149
|
+
* bounds this so a DOM that pathologically never reports settled — or a user who scrolls away mid-
|
|
150
|
+
* measurement — can never be fought forever; once exhausted, `hasApplied` is set regardless, wherever
|
|
151
|
+
* the last attempt left the container.
|
|
152
|
+
*
|
|
153
|
+
* `state.hasApplied` is the ONLY thing that can permanently stop this from calling `scrollToEnd`
|
|
154
|
+
* again: `'start'` and an empty transcript set it immediately (nothing to verify), and `'skip-retry'`
|
|
155
|
+
* deliberately leaves it `false` so a transcript that mounted behind a hidden ancestor gets another
|
|
156
|
+
* attempt on the caller's next commit, rather than being silently abandoned the moment it becomes
|
|
157
|
+
* visible. That retry — and the clobber-recovery above — is why the caller's effect carries NO
|
|
158
|
+
* dependency array: the commit that matters (a collapsed `ThreadFeedRow` flipping its body back to
|
|
159
|
+
* `display: block`, or virtual-core's own follow-up commit after this effect's own jump) changes
|
|
160
|
+
* neither the row count nor the virtualizer identity, so a dependency-keyed effect would never
|
|
161
|
+
* re-run for it.
|
|
162
|
+
*
|
|
163
|
+
* `getContainerHeight` is a THUNK, not a number, for the same reason: reading `offsetHeight` forces
|
|
164
|
+
* a synchronous layout, and it is read at most ONCE per mount — only on the very first call
|
|
165
|
+
* (`attempts === 0`) — never again while verifying or retrying, so a landed transcript still pays
|
|
166
|
+
* nothing for the effect it keeps re-running (a streaming transcript commits on every chunk).
|
|
167
|
+
* `isAtEnd` is cheaper (a plain property read, no forced reflow beyond what the browser already
|
|
168
|
+
* tracks) and is exactly what the verification/retry loop above consults instead.
|
|
169
|
+
*/
|
|
170
|
+
export declare function applyInitialScroll(state: InitialScrollState, initialScroll: InitialScroll, rowCount: number, getContainerHeight: () => number, scrollToEnd: () => void, isAtEnd: () => boolean): void;
|
|
171
|
+
/** `scroll: 'parent'`'s ground-truth "at the end": the LIST's bottom edge against the scrollport's
|
|
172
|
+
* visible bottom (`null` scroller → the window). Not the whole scrollport — content after the list
|
|
173
|
+
* keeps that distance positive forever, which would make {@link applyInitialScroll} re-fire
|
|
174
|
+
* `scrollToEnd` up to its attempt cap and yank a user who has scrolled away. */
|
|
175
|
+
export declare function isListAtEnd(list: Element | null, scroller: HTMLElement | null, threshold: number): boolean;
|
|
176
|
+
/** The active sticky header: the last sticky index at or before the first visible index. */
|
|
177
|
+
export declare function activeStickyIndex(stickyIndexes: readonly number[], firstVisible: number | undefined): number | undefined;
|
|
178
|
+
/** `base` (virtual-core's `defaultRangeExtractor`) plus the active sticky index, ascending. */
|
|
179
|
+
export declare function extractRangeWithSticky(range: Range, stickyIndexes: readonly number[], base: (range: Range) => number[]): number[];
|
|
180
|
+
/**
|
|
181
|
+
* Every row rendered unwindowed in the same scroll owner. This is what a list falls back to when
|
|
182
|
+
* `@tanstack/react-virtual` fails to resolve (peer absent). Sticky headers stay `position: sticky`
|
|
183
|
+
* through CSS alone.
|
|
184
|
+
*
|
|
185
|
+
* NOT used as the `Suspense` fallback (see `SuspensePane`): mounting every real row for the one
|
|
186
|
+
* tick the lazy import takes would make that settle a genuine unmount/remount of every row,
|
|
187
|
+
* re-firing each row's effects and risking a message mid-stream during the resolve window.
|
|
188
|
+
*/
|
|
189
|
+
export declare function NonVirtualizedRows({ rows, height, gap, fallbackGap, className, style, }: VirtualRowsProps): JSX.Element;
|
|
190
|
+
/** Test-only escape hatch: proves the peer-absent degrade renders every row without having to fight
|
|
191
|
+
* `React.lazy`'s permanent once-per-module-instance resolution cache. */
|
|
192
|
+
export declare const nonVirtualizedRowsFallback: typeof NonVirtualizedRows;
|
|
193
|
+
/** The seam. `height` → own scroll node; `scroll: 'parent'` → the nearest scrolling ancestor. */
|
|
194
|
+
export declare function VirtualRows(props: VirtualRowsProps): JSX.Element;
|
|
195
|
+
export {};
|
|
196
|
+
//# sourceMappingURL=virtual-rows.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"virtual-rows.d.ts","sourceRoot":"","sources":["../../src/common/virtual-rows.tsx"],"names":[],"mappings":"AAmCA,OAAO,KAAK,EAAgC,GAAG,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACzE,OAAO,KAAK,EAAE,KAAK,E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,OAAO,GACrB,IAAI,CAwBN;AAkBD;;;gFAGgF;AAChF,wBAAgB,WAAW,CACzB,IAAI,EAAE,OAAO,GAAG,IAAI,EACpB,QAAQ,EAAE,WAAW,GAAG,IAAI,EAC5B,SAAS,EAAE,MAAM,GAChB,OAAO,CAOT;AAID,4FAA4F;AAC5F,wBAAgB,iBAAiB,CAC/B,aAAa,EAAE,SAAS,MAAM,EAAE,EAChC,YAAY,EAAE,MAAM,GAAG,SAAS,GAC/B,MAAM,GAAG,SAAS,CAQpB;AAED,+FAA+F;AAC/F,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,KAAK,EACZ,aAAa,EAAE,SAAS,MAAM,EAAE,EAChC,IAAI,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,EAAE,GAC/B,MAAM,EAAE,CAKV;AAID;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,IAAI,EACJ,MAAM,EACN,GAAO,EACP,WAAiB,EACjB,SAAS,EACT,KAAK,GACN,EAAE,gBAAgB,GAAG,GAAG,CAAC,OAAO,CA4BhC;AAED;yEACyE;AACzE,eAAO,MAAM,0BAA0B,2BAAqB,CAAA;AAgR5D,iGAAiG;AACjG,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,GAAG,CAAC,OAAO,CAehE"}
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import {
|
|
3
|
+
Fragment,
|
|
4
|
+
lazy,
|
|
5
|
+
Suspense,
|
|
6
|
+
useEffect,
|
|
7
|
+
useLayoutEffect,
|
|
8
|
+
useMemo,
|
|
9
|
+
useRef,
|
|
10
|
+
useState
|
|
11
|
+
} from "react";
|
|
12
|
+
import { cx } from "./props.js";
|
|
13
|
+
import { scrollParentOf } from "./scroll-parent.js";
|
|
14
|
+
const STICKY_STYLE = {
|
|
15
|
+
position: "sticky",
|
|
16
|
+
top: 0,
|
|
17
|
+
zIndex: 1,
|
|
18
|
+
background: "var(--virtual-rows-sticky-bg, var(--vx-surface-bg))"
|
|
19
|
+
};
|
|
20
|
+
const SCROLL_END_THRESHOLD = 64;
|
|
21
|
+
const MAX_INITIAL_SCROLL_ATTEMPTS = 5;
|
|
22
|
+
function resolveGuardedMeasurement(host, element, size) {
|
|
23
|
+
if (size > 0) return size;
|
|
24
|
+
const index = host.indexFromElement(element);
|
|
25
|
+
const key = host.options.getItemKey(index);
|
|
26
|
+
return host.itemSizeCache.get(key) ?? host.options.estimateSize(index);
|
|
27
|
+
}
|
|
28
|
+
function resolveInitialScrollAction(initialScroll, rowCount, containerHeight) {
|
|
29
|
+
if (initialScroll === "start") return "skip-done";
|
|
30
|
+
if (rowCount === 0) return "skip-done";
|
|
31
|
+
if (containerHeight <= 0) return "skip-retry";
|
|
32
|
+
return "scroll";
|
|
33
|
+
}
|
|
34
|
+
function applyInitialScroll(state, initialScroll, rowCount, getContainerHeight, scrollToEnd, isAtEnd) {
|
|
35
|
+
if (state.hasApplied) return;
|
|
36
|
+
if (state.attempts > 0) {
|
|
37
|
+
if (isAtEnd() || state.attempts >= MAX_INITIAL_SCROLL_ATTEMPTS) {
|
|
38
|
+
state.hasApplied = true;
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
scrollToEnd();
|
|
42
|
+
state.attempts += 1;
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const action = resolveInitialScrollAction(initialScroll, rowCount, getContainerHeight());
|
|
46
|
+
if (action === "skip-retry") return;
|
|
47
|
+
if (action === "skip-done") {
|
|
48
|
+
state.hasApplied = true;
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
scrollToEnd();
|
|
52
|
+
state.attempts += 1;
|
|
53
|
+
}
|
|
54
|
+
function isContainerAtEnd(container, threshold) {
|
|
55
|
+
if (container === null) return false;
|
|
56
|
+
const distanceFromEnd = container.scrollHeight - container.clientHeight - container.scrollTop;
|
|
57
|
+
return distanceFromEnd <= threshold;
|
|
58
|
+
}
|
|
59
|
+
function isListAtEnd(list, scroller, threshold) {
|
|
60
|
+
if (list === null) return false;
|
|
61
|
+
const visibleBottom = scroller === null ? window.innerHeight : scroller.getBoundingClientRect().top + scroller.clientTop + scroller.clientHeight;
|
|
62
|
+
return list.getBoundingClientRect().bottom - visibleBottom <= threshold;
|
|
63
|
+
}
|
|
64
|
+
function activeStickyIndex(stickyIndexes, firstVisible) {
|
|
65
|
+
if (firstVisible === void 0) return void 0;
|
|
66
|
+
let active;
|
|
67
|
+
for (const index of stickyIndexes) {
|
|
68
|
+
if (index > firstVisible) break;
|
|
69
|
+
active = index;
|
|
70
|
+
}
|
|
71
|
+
return active;
|
|
72
|
+
}
|
|
73
|
+
function extractRangeWithSticky(range, stickyIndexes, base) {
|
|
74
|
+
const indexes = base(range);
|
|
75
|
+
const active = activeStickyIndex(stickyIndexes, range.startIndex);
|
|
76
|
+
if (active === void 0 || indexes.includes(active)) return indexes;
|
|
77
|
+
return [active, ...indexes];
|
|
78
|
+
}
|
|
79
|
+
function NonVirtualizedRows({
|
|
80
|
+
rows,
|
|
81
|
+
height,
|
|
82
|
+
gap = 0,
|
|
83
|
+
fallbackGap = gap,
|
|
84
|
+
className,
|
|
85
|
+
style
|
|
86
|
+
}) {
|
|
87
|
+
const list = (
|
|
88
|
+
// theme-allow inline-display — the degrade target is a plain column of rows.
|
|
89
|
+
/* @__PURE__ */ jsx("div", { style: { display: "flex", flexDirection: "column", gap: fallbackGap }, children: rows.map(
|
|
90
|
+
(row) => row.sticky === true ? /* @__PURE__ */ jsx("div", { style: STICKY_STYLE, children: row.node }, row.key) : /* @__PURE__ */ jsx(Fragment, { children: row.node }, row.key)
|
|
91
|
+
) })
|
|
92
|
+
);
|
|
93
|
+
if (height === void 0)
|
|
94
|
+
return /* @__PURE__ */ jsx("div", { className: cx(className), style, children: list });
|
|
95
|
+
return (
|
|
96
|
+
// theme-allow raw-scroll-container — as above.
|
|
97
|
+
/* @__PURE__ */ jsx("div", { className: cx(className), style: { height, overflow: "auto", ...style }, children: list })
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
const nonVirtualizedRowsFallback = NonVirtualizedRows;
|
|
101
|
+
function guardedMeasure(base) {
|
|
102
|
+
return (element, entry, instance) => resolveGuardedMeasurement(instance, element, base(element, entry, instance));
|
|
103
|
+
}
|
|
104
|
+
function createRows(rv, useRowsVirtualizer, onWindow) {
|
|
105
|
+
return function VirtualRowsInner({
|
|
106
|
+
rows,
|
|
107
|
+
height,
|
|
108
|
+
overscan,
|
|
109
|
+
estimateSize,
|
|
110
|
+
gap = 0,
|
|
111
|
+
initialScroll = "start",
|
|
112
|
+
anchorTo = "start",
|
|
113
|
+
followOnAppend = false,
|
|
114
|
+
parent,
|
|
115
|
+
className,
|
|
116
|
+
style
|
|
117
|
+
}) {
|
|
118
|
+
"use no memo";
|
|
119
|
+
const ownRef = useRef(null);
|
|
120
|
+
const listRef = useRef(null);
|
|
121
|
+
const initialScrollStateRef = useRef({ hasApplied: false, attempts: 0 });
|
|
122
|
+
const stickyIndexes = useMemo(
|
|
123
|
+
() => rows.flatMap((row, index) => row.sticky === true ? [index] : []),
|
|
124
|
+
[rows]
|
|
125
|
+
);
|
|
126
|
+
const rangeExtractor = useMemo(
|
|
127
|
+
() => (range) => extractRangeWithSticky(range, stickyIndexes, rv.defaultRangeExtractor),
|
|
128
|
+
[stickyIndexes]
|
|
129
|
+
);
|
|
130
|
+
const elementNode = () => parent?.element ?? ownRef.current;
|
|
131
|
+
const scrollNode = () => onWindow ? document.scrollingElement : elementNode();
|
|
132
|
+
const virtualizer = useRowsVirtualizer({
|
|
133
|
+
count: rows.length,
|
|
134
|
+
getScrollElement: scrollNode,
|
|
135
|
+
estimateSize: () => estimateSize,
|
|
136
|
+
overscan,
|
|
137
|
+
gap,
|
|
138
|
+
scrollMargin: parent?.margin ?? 0,
|
|
139
|
+
// `scroll: 'parent'` mounts on a scroller that may already be scrolled (a list that was plain
|
|
140
|
+
// DOM a frame ago): start at that offset, not 0 — virtual-core writes its tracked offset back
|
|
141
|
+
// on attach, which would jump the scroller to the top.
|
|
142
|
+
...parent !== void 0 && { initialOffset: () => scrollNode()?.scrollTop ?? 0 },
|
|
143
|
+
rangeExtractor,
|
|
144
|
+
getItemKey: (index) => rows[index]?.key ?? index,
|
|
145
|
+
anchorTo,
|
|
146
|
+
followOnAppend,
|
|
147
|
+
scrollEndThreshold: SCROLL_END_THRESHOLD,
|
|
148
|
+
useFlushSync: false
|
|
149
|
+
});
|
|
150
|
+
useLayoutEffect(() => {
|
|
151
|
+
applyInitialScroll(
|
|
152
|
+
initialScrollStateRef.current,
|
|
153
|
+
initialScroll,
|
|
154
|
+
rows.length,
|
|
155
|
+
() => onWindow ? window.innerHeight : elementNode()?.offsetHeight ?? 0,
|
|
156
|
+
() => virtualizer.scrollToEnd({ behavior: "auto" }),
|
|
157
|
+
() => parent === void 0 ? isContainerAtEnd(scrollNode(), SCROLL_END_THRESHOLD) : isListAtEnd(listRef.current, parent.element, SCROLL_END_THRESHOLD)
|
|
158
|
+
);
|
|
159
|
+
});
|
|
160
|
+
const margin = parent?.margin ?? 0;
|
|
161
|
+
const virtualItems = virtualizer.getVirtualItems();
|
|
162
|
+
const activeSticky = activeStickyIndex(stickyIndexes, virtualizer.range?.startIndex);
|
|
163
|
+
const items = /* @__PURE__ */ jsx("div", { ref: listRef, style: { height: virtualizer.getTotalSize(), position: "relative" }, children: virtualItems.map((virtualItem) => {
|
|
164
|
+
const row = rows[virtualItem.index];
|
|
165
|
+
if (row === void 0) return null;
|
|
166
|
+
return /* @__PURE__ */ jsx(
|
|
167
|
+
"div",
|
|
168
|
+
{
|
|
169
|
+
ref: virtualizer.measureElement,
|
|
170
|
+
"data-index": virtualItem.index,
|
|
171
|
+
style: virtualItem.index === activeSticky ? STICKY_STYLE : {
|
|
172
|
+
position: "absolute",
|
|
173
|
+
top: 0,
|
|
174
|
+
left: 0,
|
|
175
|
+
width: "100%",
|
|
176
|
+
transform: `translateY(${virtualItem.start - margin}px)`
|
|
177
|
+
},
|
|
178
|
+
children: row.node
|
|
179
|
+
},
|
|
180
|
+
row.key
|
|
181
|
+
);
|
|
182
|
+
}) });
|
|
183
|
+
if (height === void 0) return items;
|
|
184
|
+
return /* @__PURE__ */ jsx(
|
|
185
|
+
"div",
|
|
186
|
+
{
|
|
187
|
+
ref: ownRef,
|
|
188
|
+
className: cx(className),
|
|
189
|
+
style: { height, overflow: "auto", ...style },
|
|
190
|
+
children: items
|
|
191
|
+
}
|
|
192
|
+
);
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
const LazyVirtualRows = lazy(
|
|
196
|
+
() => import("@tanstack/react-virtual").then((rv) => {
|
|
197
|
+
const { useVirtualizer, useWindowVirtualizer, measureElement } = rv;
|
|
198
|
+
const Rows = createRows(
|
|
199
|
+
rv,
|
|
200
|
+
(o) => useVirtualizer({
|
|
201
|
+
...o,
|
|
202
|
+
measureElement: guardedMeasure(measureElement)
|
|
203
|
+
}),
|
|
204
|
+
false
|
|
205
|
+
);
|
|
206
|
+
const WindowRows = createRows(
|
|
207
|
+
rv,
|
|
208
|
+
({ getScrollElement: _unused, ...o }) => useWindowVirtualizer({ ...o, measureElement: guardedMeasure(measureElement) }),
|
|
209
|
+
true
|
|
210
|
+
);
|
|
211
|
+
return {
|
|
212
|
+
default: function Dispatch(props) {
|
|
213
|
+
return props.parent?.element === null ? /* @__PURE__ */ jsx(WindowRows, { ...props }) : /* @__PURE__ */ jsx(Rows, { ...props });
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
}).catch(() => ({ default: NonVirtualizedRows }))
|
|
217
|
+
);
|
|
218
|
+
Object.assign(LazyVirtualRows, { displayName: "LazyVirtualRows" });
|
|
219
|
+
function SuspensePane({
|
|
220
|
+
height,
|
|
221
|
+
className,
|
|
222
|
+
style
|
|
223
|
+
}) {
|
|
224
|
+
return /* @__PURE__ */ jsx("div", { className: cx(className), style: { height, overflow: "auto", ...style } });
|
|
225
|
+
}
|
|
226
|
+
function measureParent(list, scrollRoot) {
|
|
227
|
+
if (list === null || scrollRoot === null) return null;
|
|
228
|
+
const element = scrollRoot ?? scrollParentOf(list);
|
|
229
|
+
const top = list.getBoundingClientRect().top;
|
|
230
|
+
const margin = element === null ? top + window.scrollY : top - element.getBoundingClientRect().top - element.clientTop + element.scrollTop;
|
|
231
|
+
return { element, margin: Math.round(margin) };
|
|
232
|
+
}
|
|
233
|
+
function sameParent(a, b) {
|
|
234
|
+
return a !== null && a.element === b.element && a.margin === b.margin;
|
|
235
|
+
}
|
|
236
|
+
function ParentRows(props) {
|
|
237
|
+
const { className, style, scrollRoot, ...rest } = props;
|
|
238
|
+
const listRef = useRef(null);
|
|
239
|
+
const [parent, setParent] = useState(null);
|
|
240
|
+
const remeasure = () => {
|
|
241
|
+
const next = measureParent(listRef.current, scrollRoot);
|
|
242
|
+
if (next !== null) setParent((prev) => sameParent(prev, next) ? prev : next);
|
|
243
|
+
};
|
|
244
|
+
useLayoutEffect(remeasure);
|
|
245
|
+
const scroller = parent?.element;
|
|
246
|
+
useEffect(() => {
|
|
247
|
+
const list = listRef.current;
|
|
248
|
+
if (list === null) return;
|
|
249
|
+
window.addEventListener("resize", remeasure);
|
|
250
|
+
const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(remeasure);
|
|
251
|
+
for (let node = list; node !== null; node = node.parentElement) {
|
|
252
|
+
observer?.observe(node);
|
|
253
|
+
if (node === scroller) break;
|
|
254
|
+
}
|
|
255
|
+
return () => {
|
|
256
|
+
window.removeEventListener("resize", remeasure);
|
|
257
|
+
observer?.disconnect();
|
|
258
|
+
};
|
|
259
|
+
}, [scroller, scrollRoot]);
|
|
260
|
+
return /* @__PURE__ */ jsx("div", { ref: listRef, className: cx(className), style, children: parent !== null && /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(LazyVirtualRows, { ...rest, parent }) }) });
|
|
261
|
+
}
|
|
262
|
+
function VirtualRows(props) {
|
|
263
|
+
if (props.scroll === "parent") return /* @__PURE__ */ jsx(ParentRows, { ...props });
|
|
264
|
+
return /* @__PURE__ */ jsx(
|
|
265
|
+
Suspense,
|
|
266
|
+
{
|
|
267
|
+
fallback: /* @__PURE__ */ jsx(
|
|
268
|
+
SuspensePane,
|
|
269
|
+
{
|
|
270
|
+
height: props.height,
|
|
271
|
+
...props.className !== void 0 && { className: props.className },
|
|
272
|
+
...props.style !== void 0 && { style: props.style }
|
|
273
|
+
}
|
|
274
|
+
),
|
|
275
|
+
children: /* @__PURE__ */ jsx(LazyVirtualRows, { ...props })
|
|
276
|
+
}
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
export {
|
|
280
|
+
MAX_INITIAL_SCROLL_ATTEMPTS,
|
|
281
|
+
NonVirtualizedRows,
|
|
282
|
+
VirtualRows,
|
|
283
|
+
activeStickyIndex,
|
|
284
|
+
applyInitialScroll,
|
|
285
|
+
extractRangeWithSticky,
|
|
286
|
+
isListAtEnd,
|
|
287
|
+
nonVirtualizedRowsFallback,
|
|
288
|
+
resolveGuardedMeasurement,
|
|
289
|
+
resolveInitialScrollAction
|
|
290
|
+
};
|
|
@@ -131,8 +131,9 @@
|
|
|
131
131
|
padding-inline: var(--button-padding-x-ctl);
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
+
/* An active filter is selection state, so its border is ink, not the accent (SPEC § 6.12). */
|
|
134
135
|
.pill[data-active] {
|
|
135
|
-
border-color: var(--vx-
|
|
136
|
+
border-color: color-mix(in srgb, var(--vx-ink) 55%, transparent);
|
|
136
137
|
color: var(--vx-ink);
|
|
137
138
|
}
|
|
138
139
|
|
|
@@ -176,6 +177,37 @@
|
|
|
176
177
|
font-weight: 500;
|
|
177
178
|
}
|
|
178
179
|
|
|
180
|
+
/* The two-span anatomy (`filter-pill.tsx`): the facet's name muted, the selection bright. A pill
|
|
181
|
+
* without a value renders neither span, so its single label keeps the button's own colour. */
|
|
182
|
+
.pillName {
|
|
183
|
+
flex-shrink: 0;
|
|
184
|
+
color: var(--vx-muted);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/* The Button label is a flex row (whitespace between its spans collapses), so the gap is the
|
|
188
|
+
* tier's own control gap, and the VALUE is what truncates past the pill's width cap. */
|
|
189
|
+
.pillLabel:has(.pillValue) {
|
|
190
|
+
column-gap: var(--vx-space-control-gap, 0.375rem);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.pillValue {
|
|
194
|
+
overflow: hidden;
|
|
195
|
+
text-overflow: ellipsis;
|
|
196
|
+
color: var(--vx-ink);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/* A numeric pill that also carries a name keeps the NAME in the body face — only the value is a
|
|
200
|
+
* number. */
|
|
201
|
+
.pill[data-numeric]:has(.pillValue) .pillName {
|
|
202
|
+
font-family: var(--mantine-font-family);
|
|
203
|
+
font-size: var(--vx-text-sm);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.pill[data-numeric] .pillValue {
|
|
207
|
+
font-family: var(--basalt-font-mono);
|
|
208
|
+
font-size: var(--vx-text-xs);
|
|
209
|
+
}
|
|
210
|
+
|
|
179
211
|
/* Numeric pill labels read mono at the smaller step. The FACE comes from the package-wide
|
|
180
212
|
* `[data-numeric]` law in `styles.css`; the `font-size` is the pill's own decision, which is why
|
|
181
213
|
* this rule exists at all. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enum-filter.d.ts","sourceRoot":"","sources":["../../src/controls/enum-filter.tsx"],"names":[],"mappings":"AA6BA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAGlD,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAK7D;;;;;GAKG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,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
|
4
4
|
import { POPOVER_ROW_HIT_GAP, useFilterRegistration, useFilterSurface } from "./filter-context.js";
|
|
5
|
-
import { FilterClearButton, FilterPill } from "./filter-pill.js";
|
|
5
|
+
import { FilterClearButton, FilterPill, filterReading } from "./filter-pill.js";
|
|
6
6
|
import { useControlName } from "./control-name.js";
|
|
7
7
|
import { PanelChoice, PanelRow } from "./panel-row.js";
|
|
8
8
|
function EnumFilter({
|
|
@@ -84,10 +84,16 @@ function EnumFilter({
|
|
|
84
84
|
}
|
|
85
85
|
)
|
|
86
86
|
);
|
|
87
|
+
const shownLabel = selected?.label ?? unmatchedLabel;
|
|
87
88
|
return /* @__PURE__ */ jsx(
|
|
88
89
|
FilterPill,
|
|
89
90
|
{
|
|
90
|
-
|
|
91
|
+
...filterReading({
|
|
92
|
+
name: label,
|
|
93
|
+
informative: !isDefault,
|
|
94
|
+
value: shownLabel ?? value,
|
|
95
|
+
unsetText: shownLabel ?? label
|
|
96
|
+
}),
|
|
91
97
|
active: !isDefault,
|
|
92
98
|
...numeric === true && { numeric: true },
|
|
93
99
|
...disabled === true && { disabled: true },
|
|
@@ -1,9 +1,33 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
import type { BasaltProps } from '../common/props.js';
|
|
3
|
-
export type
|
|
3
|
+
export type FilterPillReading = {
|
|
4
4
|
readonly label: string;
|
|
5
|
+
readonly value: string;
|
|
6
|
+
readonly unset?: never;
|
|
7
|
+
} | {
|
|
8
|
+
readonly label: string;
|
|
9
|
+
readonly unset: true;
|
|
10
|
+
readonly value?: never;
|
|
11
|
+
} | {
|
|
12
|
+
readonly label: string;
|
|
13
|
+
readonly value?: never;
|
|
14
|
+
readonly unset?: never;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* The ONE place a facet filter turns its state into a {@link FilterPillReading}: `informative` is
|
|
18
|
+
* the single predicate for "this filter is filtering" (and what the caller hands `active` too, so
|
|
19
|
+
* the muted anatomy and the ink border can never disagree); `value` is the selection's text and
|
|
20
|
+
* `unsetText` what the pill reads while it is not filtering (the control's existing copy).
|
|
21
|
+
*/
|
|
22
|
+
export declare function filterReading(input: {
|
|
23
|
+
readonly name: string;
|
|
24
|
+
readonly informative: boolean;
|
|
25
|
+
readonly value: string;
|
|
26
|
+
readonly unsetText: string;
|
|
27
|
+
}): FilterPillReading;
|
|
28
|
+
export type FilterPillProps = BasaltProps & FilterPillReading & {
|
|
5
29
|
readonly icon?: ReactNode;
|
|
6
|
-
/** Non-default →
|
|
30
|
+
/** Non-default → ink border (selection is ink, never the accent). Derived from `field.isDefault(value)`, never hand-set. */
|
|
7
31
|
readonly active?: boolean;
|
|
8
32
|
/** Mono label, for a numeric preset set (`7d` / `30d`) — the same law `[data-numeric]` applies
|
|
9
33
|
* to a numeric SegmentedControl label (`theme/segmented-control.module.css`). */
|
|
@@ -26,7 +50,7 @@ export type FilterPillProps = BasaltProps & {
|
|
|
26
50
|
/** `data-shown` — the CSS hook that reveals the `+N` fold pill once folding is needed. */
|
|
27
51
|
readonly shown?: boolean;
|
|
28
52
|
};
|
|
29
|
-
export declare function FilterPill({ label, icon, active, numeric, children, onClick, ariaLabel, pressed, disabled, className, style, hideGlyph, shown, }: FilterPillProps): ReactNode;
|
|
53
|
+
export declare function FilterPill({ label, value, unset, icon, active, numeric, children, onClick, ariaLabel, pressed, disabled, className, style, hideGlyph, shown, }: FilterPillProps): ReactNode;
|
|
30
54
|
/**
|
|
31
55
|
* The popover's `Clear` — one button for `EnumFilter`, `NumberFilter` and `MultiSelectFilter`. Its
|
|
32
56
|
* mousedown keeps focus where it is: a stepper commits its draft on blur, so a press that blurred
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter-pill.d.ts","sourceRoot":"","sources":["../../src/controls/filter-pill.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"filter-pill.d.ts","sourceRoot":"","sources":["../../src/controls/filter-pill.tsx"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EA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