@vokril/ui-solid 0.19.1 → 0.20.1
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 +14 -0
- package/README.md +38 -2
- package/dist/createResizableSidebar-CeksJQ9Q.cjs +1 -0
- package/dist/createResizableSidebar-DnHgvr7P.js +472 -0
- package/dist/createVirtualWindow-C8_UuF7B.cjs +1 -0
- package/dist/createVirtualWindow-CGPw2jm_.js +121 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +108 -104
- package/dist/layout/createVirtualScroller.d.cts +8 -31
- package/dist/layout/createVirtualScroller.d.ts +8 -31
- package/dist/layout/createVirtualWindow.d.cts +66 -0
- package/dist/layout/createVirtualWindow.d.ts +66 -0
- package/dist/layout/index.cjs +1 -1
- package/dist/layout/index.d.cts +2 -0
- package/dist/layout/index.d.ts +2 -0
- package/dist/layout/index.js +7 -6
- package/dist/layout/virtualScrollerUtils.d.cts +58 -22
- package/dist/layout/virtualScrollerUtils.d.ts +58 -22
- package/dist/rowSource-CfGSdY64.js +1236 -0
- package/dist/rowSource-D0MM14Bu.cjs +1 -0
- package/dist/server/createResizableSidebar-B0NDaq7D.cjs +1 -0
- package/dist/server/createResizableSidebar-Dn9UMUf_.js +310 -0
- package/dist/server/createVirtualWindow-C8_UuF7B.cjs +1 -0
- package/dist/server/createVirtualWindow-CGPw2jm_.js +121 -0
- package/dist/server/index.cjs +1 -1
- package/dist/server/index.js +110 -106
- package/dist/server/layout/index.cjs +1 -1
- package/dist/server/layout/index.js +7 -6
- package/dist/server/rowSource-BGuQROhJ.js +1122 -0
- package/dist/server/rowSource-IX742JOS.cjs +1 -0
- package/dist/server/tree/index.cjs +1 -1
- package/dist/server/tree/index.js +11 -8
- package/dist/solid/layout/createVirtualScroller.js +17 -100
- package/dist/solid/layout/createVirtualWindow.js +142 -0
- package/dist/solid/layout/index.js +1 -0
- package/dist/solid/layout/virtualScrollerUtils.js +31 -32
- package/dist/solid/tree/TreeSurface.jsx +20 -13
- package/dist/solid/tree/createTreeController.js +110 -62
- package/dist/solid/tree/createTreeSurface.js +29 -12
- package/dist/solid/tree/index.js +1 -0
- package/dist/solid/tree/rowSource.js +93 -0
- package/dist/solid/tree/selectAllInScope.js +31 -25
- package/dist/solid/tree/stickyScroll.js +12 -10
- package/dist/solid/tree/treeAria.js +11 -30
- package/dist/solid/tree/treeKeymap.js +2 -24
- package/dist/solid/tree/viewportAnchor.js +23 -0
- package/dist/style.css +1 -1
- package/dist/tree/TreeStickyHeader.d.cts +1 -1
- package/dist/tree/TreeStickyHeader.d.ts +1 -1
- package/dist/tree/TreeSurface.d.cts +1 -1
- package/dist/tree/TreeSurface.d.ts +1 -1
- package/dist/tree/createTreeController.d.cts +19 -8
- package/dist/tree/createTreeController.d.ts +19 -8
- package/dist/tree/createTreeSurface.d.cts +8 -3
- package/dist/tree/createTreeSurface.d.ts +8 -3
- package/dist/tree/descriptor.d.cts +8 -9
- package/dist/tree/descriptor.d.ts +8 -9
- package/dist/tree/index.cjs +1 -1
- package/dist/tree/index.d.cts +1 -0
- package/dist/tree/index.d.ts +1 -0
- package/dist/tree/index.js +11 -8
- package/dist/tree/rowSource.d.cts +41 -0
- package/dist/tree/rowSource.d.ts +41 -0
- package/dist/tree/selectAllInScope.d.cts +20 -2
- package/dist/tree/selectAllInScope.d.ts +20 -2
- package/dist/tree/stickyScroll.d.cts +32 -5
- package/dist/tree/stickyScroll.d.ts +32 -5
- package/dist/tree/treeAria.d.cts +26 -10
- package/dist/tree/treeAria.d.ts +26 -10
- package/dist/tree/treeKeymap.d.cts +2 -16
- package/dist/tree/treeKeymap.d.ts +2 -16
- package/dist/tree/viewportAnchor.d.cts +21 -0
- package/dist/tree/viewportAnchor.d.ts +21 -0
- package/dist/ui.css +1 -1
- package/package.json +1 -1
- package/dist/createResizableSidebar-Dau7TIuH.cjs +0 -1
- package/dist/createResizableSidebar-gvf9me4K.js +0 -449
- package/dist/createVirtualScroller-CL49JE2P.cjs +0 -1
- package/dist/createVirtualScroller-vu-l4rVv.js +0 -93
- package/dist/descriptor-CaHgh9N_.cjs +0 -1
- package/dist/descriptor-eGtcBtpI.js +0 -1106
- package/dist/server/createResizableSidebar-BQG5elmd.js +0 -287
- package/dist/server/createResizableSidebar-tU8FO2MK.cjs +0 -1
- package/dist/server/createVirtualScroller-CL49JE2P.cjs +0 -1
- package/dist/server/createVirtualScroller-vu-l4rVv.js +0 -93
- package/dist/server/descriptor-CEGvvJZh.cjs +0 -1
- package/dist/server/descriptor-GLoKPx6x.js +0 -992
|
@@ -1,46 +1,23 @@
|
|
|
1
1
|
import { type Accessor } from 'solid-js';
|
|
2
|
+
import { type VirtualWindow } from './createVirtualWindow.js';
|
|
2
3
|
export interface VirtualScrollerOptions<T> {
|
|
3
4
|
/** Full list of items */
|
|
4
|
-
items: Accessor<T[]>;
|
|
5
|
+
items: Accessor<readonly T[]>;
|
|
5
6
|
/** Fixed height of each row in pixels */
|
|
6
7
|
itemHeight: number;
|
|
7
8
|
/** Overscan rows above/below viewport */
|
|
8
9
|
overscan?: number;
|
|
9
10
|
}
|
|
10
|
-
|
|
11
|
+
/**
|
|
12
|
+
* A virtual window over an ARRAY: the window's arithmetic plus the visible
|
|
13
|
+
* items. A list whose items are not an array (computed on demand) uses
|
|
14
|
+
* `createVirtualWindow` directly and reads its rows by index.
|
|
15
|
+
*/
|
|
16
|
+
export interface VirtualScrollerResult<T> extends Omit<VirtualWindow, 'range' | 'readScrollTop' | 'scrollToContentTop'> {
|
|
11
17
|
/** Items currently visible (including overscan) */
|
|
12
18
|
visibleItems: Accessor<{
|
|
13
19
|
item: T;
|
|
14
20
|
index: number;
|
|
15
21
|
}[]>;
|
|
16
|
-
/** Total scroll height in px */
|
|
17
|
-
totalHeight: Accessor<number>;
|
|
18
|
-
/** Offset top for the visible slice container */
|
|
19
|
-
offsetY: Accessor<number>;
|
|
20
|
-
/**
|
|
21
|
-
* The live scroll position, in px.
|
|
22
|
-
*
|
|
23
|
-
* NOT `offsetY`, which is `startIndex × itemHeight` with the overscan already
|
|
24
|
-
* subtracted — a caller doing geometry against the viewport's top edge needs
|
|
25
|
-
* the real thing, or it lands a whole overscan window off.
|
|
26
|
-
*/
|
|
27
|
-
scrollTop: Accessor<number>;
|
|
28
|
-
/** The viewport's own height, in px. Kept live by the ResizeObserver below. */
|
|
29
|
-
viewportHeight: Accessor<number>;
|
|
30
|
-
/** Attach to the scroll container */
|
|
31
|
-
containerRef: (el: HTMLElement) => void;
|
|
32
|
-
/**
|
|
33
|
-
* Scroll a row into view. `align: 'auto'` (default) is a minimal scroll —
|
|
34
|
-
* already-visible rows don't move, off-screen rows snap to the nearest
|
|
35
|
-
* edge (matching common list-scrolling behaviour, used by keyboard nav). `align: 'center'` always
|
|
36
|
-
* centers the row (used by "reveal"/"go to" so the target lands mid-pane).
|
|
37
|
-
*
|
|
38
|
-
* `topInset` moves the top edge down by that many px, for a caller that paints
|
|
39
|
-
* something over it: without it, "scroll just enough" parks the row exactly
|
|
40
|
-
* under the overlay and the row the user asked for is the one they cannot see.
|
|
41
|
-
* `center` ignores it — the middle of the viewport is already clear of any
|
|
42
|
-
* top chrome.
|
|
43
|
-
*/
|
|
44
|
-
scrollToIndex: (index: number, align?: 'auto' | 'center', topInset?: number) => void;
|
|
45
22
|
}
|
|
46
23
|
export declare function createVirtualScroller<T>(options: VirtualScrollerOptions<T>): VirtualScrollerResult<T>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* createVirtualWindow — which indices of a long list to render, and where.
|
|
3
|
+
*
|
|
4
|
+
* It knows a COUNT, never the items: the caller reads whatever it renders by
|
|
5
|
+
* index. That is what lets a list whose rows are computed on demand (a tree row
|
|
6
|
+
* source) stay virtual all the way down — an API that asked for an array would
|
|
7
|
+
* force the caller to build every row just to have one.
|
|
8
|
+
*
|
|
9
|
+
* Scroll positions are in content space (`index × itemHeight`), also past the
|
|
10
|
+
* browser's height limit — see `virtualScrollerUtils.ts`. The CONTENT position
|
|
11
|
+
* is the window's truth and the element's position follows it through the
|
|
12
|
+
* mapping. Past the limit the mapping depends on the count, so a list that grows
|
|
13
|
+
* or shrinks would otherwise move what the user is reading: rows appended below
|
|
14
|
+
* would slide the viewport. When the count or the viewport changes, the content
|
|
15
|
+
* position stands and the element is placed to match it.
|
|
16
|
+
*/
|
|
17
|
+
import { type Accessor } from 'solid-js';
|
|
18
|
+
import { type VirtualRange } from './virtualScrollerUtils.cjs';
|
|
19
|
+
export interface VirtualWindowOptions {
|
|
20
|
+
/** How many items the list has. */
|
|
21
|
+
count: Accessor<number>;
|
|
22
|
+
/** Fixed height of each item, px. */
|
|
23
|
+
itemHeight: number;
|
|
24
|
+
/** Items rendered beyond each edge of the viewport. */
|
|
25
|
+
overscan?: number;
|
|
26
|
+
}
|
|
27
|
+
export interface VirtualWindow {
|
|
28
|
+
/** The indices to render, `[start, end)`, overscan included. */
|
|
29
|
+
range: Accessor<VirtualRange>;
|
|
30
|
+
/** The scroll container's height, px — the content's, capped at the browser-safe extent. */
|
|
31
|
+
totalHeight: Accessor<number>;
|
|
32
|
+
/** Where the rendered slice starts inside the scroll container, px. */
|
|
33
|
+
offsetY: Accessor<number>;
|
|
34
|
+
/**
|
|
35
|
+
* The scroll position in CONTENT space: `index × itemHeight` arithmetic holds
|
|
36
|
+
* against it even when the container is capped. Equal to the element's
|
|
37
|
+
* `scrollTop` while the list fits. Scroll events coalesce into one update per
|
|
38
|
+
* frame.
|
|
39
|
+
*/
|
|
40
|
+
scrollTop: Accessor<number>;
|
|
41
|
+
/**
|
|
42
|
+
* The content position NOW, without waiting for the frame: a scroll this
|
|
43
|
+
* window placed, or one whose event is being coalesced. A caller deciding
|
|
44
|
+
* whether someone else scrolled in the same turn reads this.
|
|
45
|
+
*/
|
|
46
|
+
readScrollTop: () => number;
|
|
47
|
+
/** The viewport's own height, px. Kept live by a ResizeObserver. */
|
|
48
|
+
viewportHeight: Accessor<number>;
|
|
49
|
+
/** Attach to the scroll container. */
|
|
50
|
+
containerRef: (el: HTMLElement) => void;
|
|
51
|
+
/**
|
|
52
|
+
* Scroll an item into view. `auto` (default) is a minimal scroll — an item
|
|
53
|
+
* already in view does not move, one outside snaps to the nearest edge (the
|
|
54
|
+
* keyboard's behaviour). `center` places it in the middle (reveal, go to).
|
|
55
|
+
* "In view" is where the element stands now, a scroll whose event has not
|
|
56
|
+
* arrived yet included.
|
|
57
|
+
*
|
|
58
|
+
* `topInset` moves the top edge down by that many px, for a caller that paints
|
|
59
|
+
* over it: without it "scroll just enough" parks the item under the overlay.
|
|
60
|
+
* `center` ignores it — the middle of the viewport is already clear.
|
|
61
|
+
*/
|
|
62
|
+
scrollToIndex: (index: number, align?: 'auto' | 'center', topInset?: number) => void;
|
|
63
|
+
/** Scroll so content position `contentTop` sits at the viewport's top edge (clamped to the list). */
|
|
64
|
+
scrollToContentTop: (contentTop: number) => void;
|
|
65
|
+
}
|
|
66
|
+
export declare function createVirtualWindow(options: VirtualWindowOptions): VirtualWindow;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* createVirtualWindow — which indices of a long list to render, and where.
|
|
3
|
+
*
|
|
4
|
+
* It knows a COUNT, never the items: the caller reads whatever it renders by
|
|
5
|
+
* index. That is what lets a list whose rows are computed on demand (a tree row
|
|
6
|
+
* source) stay virtual all the way down — an API that asked for an array would
|
|
7
|
+
* force the caller to build every row just to have one.
|
|
8
|
+
*
|
|
9
|
+
* Scroll positions are in content space (`index × itemHeight`), also past the
|
|
10
|
+
* browser's height limit — see `virtualScrollerUtils.ts`. The CONTENT position
|
|
11
|
+
* is the window's truth and the element's position follows it through the
|
|
12
|
+
* mapping. Past the limit the mapping depends on the count, so a list that grows
|
|
13
|
+
* or shrinks would otherwise move what the user is reading: rows appended below
|
|
14
|
+
* would slide the viewport. When the count or the viewport changes, the content
|
|
15
|
+
* position stands and the element is placed to match it.
|
|
16
|
+
*/
|
|
17
|
+
import { type Accessor } from 'solid-js';
|
|
18
|
+
import { type VirtualRange } from './virtualScrollerUtils.js';
|
|
19
|
+
export interface VirtualWindowOptions {
|
|
20
|
+
/** How many items the list has. */
|
|
21
|
+
count: Accessor<number>;
|
|
22
|
+
/** Fixed height of each item, px. */
|
|
23
|
+
itemHeight: number;
|
|
24
|
+
/** Items rendered beyond each edge of the viewport. */
|
|
25
|
+
overscan?: number;
|
|
26
|
+
}
|
|
27
|
+
export interface VirtualWindow {
|
|
28
|
+
/** The indices to render, `[start, end)`, overscan included. */
|
|
29
|
+
range: Accessor<VirtualRange>;
|
|
30
|
+
/** The scroll container's height, px — the content's, capped at the browser-safe extent. */
|
|
31
|
+
totalHeight: Accessor<number>;
|
|
32
|
+
/** Where the rendered slice starts inside the scroll container, px. */
|
|
33
|
+
offsetY: Accessor<number>;
|
|
34
|
+
/**
|
|
35
|
+
* The scroll position in CONTENT space: `index × itemHeight` arithmetic holds
|
|
36
|
+
* against it even when the container is capped. Equal to the element's
|
|
37
|
+
* `scrollTop` while the list fits. Scroll events coalesce into one update per
|
|
38
|
+
* frame.
|
|
39
|
+
*/
|
|
40
|
+
scrollTop: Accessor<number>;
|
|
41
|
+
/**
|
|
42
|
+
* The content position NOW, without waiting for the frame: a scroll this
|
|
43
|
+
* window placed, or one whose event is being coalesced. A caller deciding
|
|
44
|
+
* whether someone else scrolled in the same turn reads this.
|
|
45
|
+
*/
|
|
46
|
+
readScrollTop: () => number;
|
|
47
|
+
/** The viewport's own height, px. Kept live by a ResizeObserver. */
|
|
48
|
+
viewportHeight: Accessor<number>;
|
|
49
|
+
/** Attach to the scroll container. */
|
|
50
|
+
containerRef: (el: HTMLElement) => void;
|
|
51
|
+
/**
|
|
52
|
+
* Scroll an item into view. `auto` (default) is a minimal scroll — an item
|
|
53
|
+
* already in view does not move, one outside snaps to the nearest edge (the
|
|
54
|
+
* keyboard's behaviour). `center` places it in the middle (reveal, go to).
|
|
55
|
+
* "In view" is where the element stands now, a scroll whose event has not
|
|
56
|
+
* arrived yet included.
|
|
57
|
+
*
|
|
58
|
+
* `topInset` moves the top edge down by that many px, for a caller that paints
|
|
59
|
+
* over it: without it "scroll just enough" parks the item under the overlay.
|
|
60
|
+
* `center` ignores it — the middle of the viewport is already clear.
|
|
61
|
+
*/
|
|
62
|
+
scrollToIndex: (index: number, align?: 'auto' | 'center', topInset?: number) => void;
|
|
63
|
+
/** Scroll so content position `contentTop` sits at the viewport's top edge (clamped to the list). */
|
|
64
|
+
scrollToContentTop: (contentTop: number) => void;
|
|
65
|
+
}
|
|
66
|
+
export declare function createVirtualWindow(options: VirtualWindowOptions): VirtualWindow;
|
package/dist/layout/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../createResizableSidebar-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../createResizableSidebar-CeksJQ9Q.cjs"),r=require("../Stepper-DTuchuOX.cjs"),a=require("../createVirtualWindow-C8_UuF7B.cjs");exports.PageHeader=e.PageHeader;exports.PageHeaderIcon=e.PageHeaderIcon;exports.ResizableSplitPane=e.ResizableSplitPane;exports.ResizeHandle=e.ResizeHandle;exports.createResizableSidebar=e.createResizableSidebar;exports.createVirtualScroller=e.createVirtualScroller;exports.Accordion=r.Accordion;exports.Breadcrumb=r.Breadcrumb;exports.Stepper=r.Stepper;exports.Tabs=r.Tabs;exports.createVirtualWindow=a.createVirtualWindow;
|
package/dist/layout/index.d.cts
CHANGED
|
@@ -7,4 +7,6 @@ export * from '../navigation/Accordion.cjs';
|
|
|
7
7
|
export * from '../navigation/Stepper.cjs';
|
|
8
8
|
export * from './PageHeaderIcon.cjs';
|
|
9
9
|
export * from './createVirtualScroller.cjs';
|
|
10
|
+
export * from './createVirtualWindow.cjs';
|
|
11
|
+
export type { VirtualRange } from './virtualScrollerUtils.cjs';
|
|
10
12
|
export * from './createResizableSidebar.cjs';
|
package/dist/layout/index.d.ts
CHANGED
|
@@ -7,4 +7,6 @@ export * from '../navigation/Accordion.js';
|
|
|
7
7
|
export * from '../navigation/Stepper.js';
|
|
8
8
|
export * from './PageHeaderIcon.js';
|
|
9
9
|
export * from './createVirtualScroller.js';
|
|
10
|
+
export * from './createVirtualWindow.js';
|
|
11
|
+
export type { VirtualRange } from './virtualScrollerUtils.js';
|
|
10
12
|
export * from './createResizableSidebar.js';
|
package/dist/layout/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as r, a as s, R as o, b as c, c as t } from "../createResizableSidebar-
|
|
2
|
-
import { A as l, B as b, S as
|
|
3
|
-
import { c as m } from "../
|
|
1
|
+
import { P as r, a as s, R as o, b as c, c as t, d as i } from "../createResizableSidebar-DnHgvr7P.js";
|
|
2
|
+
import { A as l, B as b, S as p, T as n } from "../Stepper-aiuAdbkl.js";
|
|
3
|
+
import { c as m } from "../createVirtualWindow-CGPw2jm_.js";
|
|
4
4
|
export {
|
|
5
5
|
l as Accordion,
|
|
6
6
|
b as Breadcrumb,
|
|
@@ -8,8 +8,9 @@ export {
|
|
|
8
8
|
s as PageHeaderIcon,
|
|
9
9
|
o as ResizableSplitPane,
|
|
10
10
|
c as ResizeHandle,
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
p as Stepper,
|
|
12
|
+
n as Tabs,
|
|
13
13
|
t as createResizableSidebar,
|
|
14
|
-
|
|
14
|
+
i as createVirtualScroller,
|
|
15
|
+
m as createVirtualWindow
|
|
15
16
|
};
|
|
@@ -1,27 +1,63 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* The arithmetic of a virtualised list — pure, so it is tested without a DOM.
|
|
3
|
+
*
|
|
4
|
+
* Two coordinate spaces meet here. CONTENT space is where `index × itemHeight`
|
|
5
|
+
* holds: row 500,000 starts at 11,000,000 px. DOM space is the scroll container
|
|
6
|
+
* the browser actually lays out, and browsers clamp an element's height well
|
|
7
|
+
* below what a million rows need (a few tens of millions of pixels, depending
|
|
8
|
+
* on the engine).
|
|
9
|
+
* Up to `MAX_SCROLL_EXTENT_PX` the two are the same. Past it the container is
|
|
10
|
+
* capped and a scroll position maps PROPORTIONALLY between the two spaces: the
|
|
11
|
+
* thumb's travel still spans every row, and everything that reasons in rows —
|
|
12
|
+
* the visible range, sticky ancestors, scroll-to-index — keeps reasoning in
|
|
13
|
+
* content space without knowing about the cap.
|
|
14
|
+
*/
|
|
15
|
+
/** The tallest scroll container a list asks the browser for, px. */
|
|
16
|
+
export declare const MAX_SCROLL_EXTENT_PX = 16000000;
|
|
17
|
+
/**
|
|
18
|
+
* Two scroll positions closer than this are the same position. Browsers round
|
|
19
|
+
* `scrollTop` to device pixels, so a position written and read back can differ
|
|
20
|
+
* by a fraction of a pixel; an exact comparison would read that as a scroll.
|
|
21
|
+
*/
|
|
22
|
+
export declare const SCROLL_TOLERANCE_PX = 1;
|
|
23
|
+
export interface VirtualRange {
|
|
24
|
+
/** First index to render, overscan included. */
|
|
25
|
+
readonly start: number;
|
|
26
|
+
/** One past the last index to render. */
|
|
27
|
+
readonly end: number;
|
|
4
28
|
}
|
|
5
|
-
|
|
6
|
-
|
|
29
|
+
/** The two heights of a list: its content's and its (possibly capped) container's. */
|
|
30
|
+
export interface ScrollExtent {
|
|
31
|
+
readonly content: number;
|
|
32
|
+
readonly dom: number;
|
|
33
|
+
readonly viewport: number;
|
|
34
|
+
}
|
|
35
|
+
export declare function scrollExtentOf(params: {
|
|
36
|
+
count: number;
|
|
7
37
|
itemHeight: number;
|
|
8
|
-
|
|
9
|
-
}):
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
38
|
+
viewport: number;
|
|
39
|
+
}): ScrollExtent;
|
|
40
|
+
/** DOM scroll position → content scroll position. Identity while the list fits. */
|
|
41
|
+
export declare function contentScrollTop(domTop: number, extent: ScrollExtent): number;
|
|
42
|
+
/** Content scroll position → DOM scroll position — the inverse of {@link contentScrollTop}. */
|
|
43
|
+
export declare function domScrollTop(contentTop: number, extent: ScrollExtent): number;
|
|
44
|
+
/** The indices to render for a content scroll position. */
|
|
45
|
+
export declare function visibleRange(params: {
|
|
46
|
+
contentTop: number;
|
|
47
|
+
viewport: number;
|
|
13
48
|
itemHeight: number;
|
|
14
49
|
overscan: number;
|
|
15
|
-
|
|
16
|
-
}):
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
50
|
+
count: number;
|
|
51
|
+
}): VirtualRange;
|
|
52
|
+
/**
|
|
53
|
+
* Where the rendered slice sits inside the scroll container, px. While the list
|
|
54
|
+
* fits this is the first index's own top; once capped, the slice is placed
|
|
55
|
+
* relative to the DOM scroll position so its rows line up with the content
|
|
56
|
+
* position they stand for.
|
|
57
|
+
*/
|
|
58
|
+
export declare function sliceOffset(params: {
|
|
59
|
+
start: number;
|
|
20
60
|
itemHeight: number;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}):
|
|
24
|
-
export declare function getVisibleSlice<T>(items: T[], window: VirtualWindow): Array<{
|
|
25
|
-
item: T;
|
|
26
|
-
index: number;
|
|
27
|
-
}>;
|
|
61
|
+
domTop: number;
|
|
62
|
+
contentTop: number;
|
|
63
|
+
}): number;
|
|
@@ -1,27 +1,63 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* The arithmetic of a virtualised list — pure, so it is tested without a DOM.
|
|
3
|
+
*
|
|
4
|
+
* Two coordinate spaces meet here. CONTENT space is where `index × itemHeight`
|
|
5
|
+
* holds: row 500,000 starts at 11,000,000 px. DOM space is the scroll container
|
|
6
|
+
* the browser actually lays out, and browsers clamp an element's height well
|
|
7
|
+
* below what a million rows need (a few tens of millions of pixels, depending
|
|
8
|
+
* on the engine).
|
|
9
|
+
* Up to `MAX_SCROLL_EXTENT_PX` the two are the same. Past it the container is
|
|
10
|
+
* capped and a scroll position maps PROPORTIONALLY between the two spaces: the
|
|
11
|
+
* thumb's travel still spans every row, and everything that reasons in rows —
|
|
12
|
+
* the visible range, sticky ancestors, scroll-to-index — keeps reasoning in
|
|
13
|
+
* content space without knowing about the cap.
|
|
14
|
+
*/
|
|
15
|
+
/** The tallest scroll container a list asks the browser for, px. */
|
|
16
|
+
export declare const MAX_SCROLL_EXTENT_PX = 16000000;
|
|
17
|
+
/**
|
|
18
|
+
* Two scroll positions closer than this are the same position. Browsers round
|
|
19
|
+
* `scrollTop` to device pixels, so a position written and read back can differ
|
|
20
|
+
* by a fraction of a pixel; an exact comparison would read that as a scroll.
|
|
21
|
+
*/
|
|
22
|
+
export declare const SCROLL_TOLERANCE_PX = 1;
|
|
23
|
+
export interface VirtualRange {
|
|
24
|
+
/** First index to render, overscan included. */
|
|
25
|
+
readonly start: number;
|
|
26
|
+
/** One past the last index to render. */
|
|
27
|
+
readonly end: number;
|
|
4
28
|
}
|
|
5
|
-
|
|
6
|
-
|
|
29
|
+
/** The two heights of a list: its content's and its (possibly capped) container's. */
|
|
30
|
+
export interface ScrollExtent {
|
|
31
|
+
readonly content: number;
|
|
32
|
+
readonly dom: number;
|
|
33
|
+
readonly viewport: number;
|
|
34
|
+
}
|
|
35
|
+
export declare function scrollExtentOf(params: {
|
|
36
|
+
count: number;
|
|
7
37
|
itemHeight: number;
|
|
8
|
-
|
|
9
|
-
}):
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
38
|
+
viewport: number;
|
|
39
|
+
}): ScrollExtent;
|
|
40
|
+
/** DOM scroll position → content scroll position. Identity while the list fits. */
|
|
41
|
+
export declare function contentScrollTop(domTop: number, extent: ScrollExtent): number;
|
|
42
|
+
/** Content scroll position → DOM scroll position — the inverse of {@link contentScrollTop}. */
|
|
43
|
+
export declare function domScrollTop(contentTop: number, extent: ScrollExtent): number;
|
|
44
|
+
/** The indices to render for a content scroll position. */
|
|
45
|
+
export declare function visibleRange(params: {
|
|
46
|
+
contentTop: number;
|
|
47
|
+
viewport: number;
|
|
13
48
|
itemHeight: number;
|
|
14
49
|
overscan: number;
|
|
15
|
-
|
|
16
|
-
}):
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
50
|
+
count: number;
|
|
51
|
+
}): VirtualRange;
|
|
52
|
+
/**
|
|
53
|
+
* Where the rendered slice sits inside the scroll container, px. While the list
|
|
54
|
+
* fits this is the first index's own top; once capped, the slice is placed
|
|
55
|
+
* relative to the DOM scroll position so its rows line up with the content
|
|
56
|
+
* position they stand for.
|
|
57
|
+
*/
|
|
58
|
+
export declare function sliceOffset(params: {
|
|
59
|
+
start: number;
|
|
20
60
|
itemHeight: number;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}):
|
|
24
|
-
export declare function getVisibleSlice<T>(items: T[], window: VirtualWindow): Array<{
|
|
25
|
-
item: T;
|
|
26
|
-
index: number;
|
|
27
|
-
}>;
|
|
61
|
+
domTop: number;
|
|
62
|
+
contentTop: number;
|
|
63
|
+
}): number;
|