@vokril/ui-solid 0.19.0 → 0.20.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 +14 -0
- package/README.md +38 -2
- package/dist/createResizableSidebar-A0F4JmSU.js +472 -0
- package/dist/createResizableSidebar-DwCuRuho.cjs +1 -0
- package/dist/createVirtualWindow-9T5ZJCQR.cjs +1 -0
- package/dist/createVirtualWindow-Dqm5jxZa.js +117 -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 +64 -0
- package/dist/layout/createVirtualWindow.d.ts +64 -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-BnUQ-LKT.cjs +1 -0
- package/dist/rowSource-CLEYuC95.js +1236 -0
- package/dist/server/createResizableSidebar-CZ0IGNm8.js +310 -0
- package/dist/server/createResizableSidebar-DDniLGSD.cjs +1 -0
- package/dist/server/createVirtualWindow-9T5ZJCQR.cjs +1 -0
- package/dist/server/createVirtualWindow-Dqm5jxZa.js +117 -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-CdvoDIN7.cjs +1 -0
- package/dist/server/rowSource-D7lSI6LT.js +1122 -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 +129 -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,64 @@
|
|
|
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
|
+
*
|
|
56
|
+
* `topInset` moves the top edge down by that many px, for a caller that paints
|
|
57
|
+
* over it: without it "scroll just enough" parks the item under the overlay.
|
|
58
|
+
* `center` ignores it — the middle of the viewport is already clear.
|
|
59
|
+
*/
|
|
60
|
+
scrollToIndex: (index: number, align?: 'auto' | 'center', topInset?: number) => void;
|
|
61
|
+
/** Scroll so content position `contentTop` sits at the viewport's top edge (clamped to the list). */
|
|
62
|
+
scrollToContentTop: (contentTop: number) => void;
|
|
63
|
+
}
|
|
64
|
+
export declare function createVirtualWindow(options: VirtualWindowOptions): VirtualWindow;
|
|
@@ -0,0 +1,64 @@
|
|
|
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
|
+
*
|
|
56
|
+
* `topInset` moves the top edge down by that many px, for a caller that paints
|
|
57
|
+
* over it: without it "scroll just enough" parks the item under the overlay.
|
|
58
|
+
* `center` ignores it — the middle of the viewport is already clear.
|
|
59
|
+
*/
|
|
60
|
+
scrollToIndex: (index: number, align?: 'auto' | 'center', topInset?: number) => void;
|
|
61
|
+
/** Scroll so content position `contentTop` sits at the viewport's top edge (clamped to the list). */
|
|
62
|
+
scrollToContentTop: (contentTop: number) => void;
|
|
63
|
+
}
|
|
64
|
+
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-DwCuRuho.cjs"),r=require("../Stepper-DTuchuOX.cjs"),a=require("../createVirtualWindow-9T5ZJCQR.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-A0F4JmSU.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-Dqm5jxZa.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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const l=require("solid-js/web"),m=require("solid-js"),Z=require("@vokril/icons"),ke=require("./OverlayScrollArea-BSlaXG1h.cjs"),Ce=require("./i18n-DZ0JlZal.cjs"),xe=require("./errorHandler-DoDAPpv2.cjs"),j=require("./keys-GMxY2wcl.cjs"),be=require("./useListCommands-Dnm4ktP1.cjs"),Ie=require("./builtins-DM7FDxEt.cjs"),J=require("./createVirtualWindow-9T5ZJCQR.cjs"),Te=require("./DesktopContextMenuContext-DMGNVjaR.cjs"),p=require("./bugIndicatingError-D2X5Hfgg.cjs"),ee={canExpand:!0,canMultiSelect:!0,canTypeAhead:!0,canRename:!1,canDestroy:!1,expandAll:!1};function te(e,n){return`${e}-row-${n}`}function ge(e){const{treeId:n,label:o,multiSelectable:t,focusMode:r,cursorKey:a}=e;return{role:e.flat===!0?"listbox":"tree",tabIndex:r==="active-descendant"||a===null?0:-1,"aria-label":o,"aria-multiselectable":t?!0:void 0,"aria-activedescendant":r==="active-descendant"&&a!==null?te(n,a):void 0}}function we(e){const{treeId:n,rows:o,index:t}=e,r=o.at(t),a=e.flat===!0,{posInSet:c,setSize:s}=o.siblingPosition(t);return{role:a?"option":"treeitem",id:te(n,r.key),"aria-level":a?void 0:r.depth+1,"aria-setsize":s,"aria-posinset":c,"aria-expanded":!a&&r.expandable?r.expanded:void 0,"aria-busy":r.busy===!0?!0:void 0}}function ye(e){return{...e.structure,tabIndex:e.focusMode==="roving-tabindex"&&e.isCursor?0:-1,"aria-selected":e.isSelected}}const Ae=/[\^$.*+?(){}|[\]\\]/;function Re(e){const n=e.trim();if(n.length===0)return null;if(Ae.test(n))try{const t=new RegExp(n,"gi");return r=>Me(r,t)}catch(t){xe.bestEffortFailed("fall through to substring",t)}const o=n.toLowerCase();return t=>_e(t,o,n.length)}function Me(e,n){n.lastIndex=0;const o=[];let t=0,r;for(;(r=n.exec(e))!==null;)r.index>t&&o.push({text:e.slice(t,r.index),match:!1}),o.push({text:r[0],match:!0}),t=r.index+r[0].length,r[0].length===0&&(n.lastIndex+=1);return t<e.length&&o.push({text:e.slice(t),match:!1}),o.length>0?o:[{text:e,match:!1}]}function _e(e,n,o){if(o===0)return[{text:e,match:!1}];const t=e.toLowerCase(),r=[];let a=0;for(;a<=e.length;){const c=t.indexOf(n,a);if(c===-1){a<e.length&&r.push({text:e.slice(a),match:!1});break}c>a&&r.push({text:e.slice(a,c),match:!1}),r.push({text:e.slice(c,c+o),match:!0}),a=c+o}return r.length>0?r:[{text:e,match:!1}]}const Ee="vk_treeStickyHost_6aT7a",De="vk_treeViewport_Ku3yB",$e="vk_treeContainer_iMrOQ",Ke="vk_treeSlice_homAf",Oe="vk_treeRow_Hh9r0",Ge="vk_treeRowCursor_QlUrp",He="vk_treeRowSelected_UdZj-",Pe="vk_treeIndentGuides_W4J04",Ne="vk_treeIndentGuideActive_9m4l3",Le="vk_treeRowChevron_6WMjE",Fe="vk_treeRowChevronSpacer_Jbp-q",qe="vk_treeRowChevronIcon_KP24Y",Be="vk_treeRowChevronIconOpen_fRKNn",Ue="vk_treeRowContent_RR7pP",We="vk_treeRowActions_LYQUv",Qe="vk_treeEmpty_s8RQ-",Ve="vk_treeRowChevronBusy_lZT8a",Ye="vk_treeSpeedSearchBadge_9GHNi",ze="vk_treeSpeedSearchIcon_48Ae2",Xe="vk_treeSpeedSearchText_F4SZ8",Ze="vk_treeMatchHighlight_NY75y",T={treeStickyHost:Ee,treeViewport:De,treeContainer:$e,treeSlice:Ke,treeRow:Oe,treeRowCursor:Ge,treeRowSelected:He,treeIndentGuides:Pe,treeIndentGuideActive:Ne,treeRowChevron:Le,treeRowChevronSpacer:Fe,treeRowChevronIcon:qe,treeRowChevronIconOpen:Be,treeRowContent:Ue,treeRowActions:We,treeEmpty:Qe,treeRowChevronBusy:Ve,treeSpeedSearchBadge:Ye,treeSpeedSearchIcon:ze,treeSpeedSearchText:Xe,treeMatchHighlight:Ze};var Je=l.template("<span aria-hidden=true tabindex=-1>"),z=l.template("<span aria-hidden=true>"),je=l.template("<span tabindex=-1>"),pe=l.template("<div><span>"),et=l.template("<mark>");function tt(e){return e.ctrlKey||e.metaKey?"toggle":e.shiftKey?"range":"replace"}function ne(e){let n;m.createEffect(()=>{if(e.sticky===!0||!e.isCursor||!e.treeHasFocus())return;const t=n;!t||t.contains(t.ownerDocument.activeElement)||queueMicrotask(()=>t.focus({preventScroll:!0}))});const o=()=>l.createComponent(m.Show,{get when(){return e.row.expandable},get fallback(){return(()=>{var t=z();return l.effect(()=>l.className(t,T.treeRowChevronSpacer)),t})()},get children(){var t=Je();return t.$$dblclick=r=>r.stopPropagation(),t.$$keydown=r=>{(j.isKey(r,"Enter")||r.key===" ")&&(r.stopPropagation(),e.onToggle(e.row))},t.$$click=r=>{r.stopPropagation(),e.onToggle(e.row)},l.insert(t,l.createComponent(m.Show,{get when(){return e.row.busy},get fallback(){return l.createComponent(Z.VpChevronRight,{get class(){return`${T.treeRowChevronIcon} ${e.row.expanded?T.treeRowChevronIconOpen:""}`}})},get children(){return l.createComponent(Z.VpLoader2,{"data-motion-exempt":"true",get class(){return`${T.treeRowChevronIcon} ${T.treeRowChevronBusy}`}})}})),l.effect(()=>l.className(t,T.treeRowChevron)),t}});return(()=>{var t=pe(),r=t.firstChild,a=n;return typeof a=="function"?l.use(a,t):n=t,l.spread(t,l.mergeProps({get tabIndex(){return e.sticky===!0?-1:0}},()=>e.sticky===!0?{tabIndex:-1}:e.aria,{get onKeyDown(){var c;return(c=e.dom)==null?void 0:c.onKeyDown},get class(){var c;return`${T.treeRow} ${((c=e.dom)==null?void 0:c.class)??""}`},get classList(){return{[T.treeRowCursor]:e.isCursor,[T.treeRowSelected]:e.isSelected}},get style(){return{height:`${e.rowHeight}px`,"--tree-depth":String(e.row.depth)}}},()=>e.sticky===!0?{"data-tree-sticky-key":e.row.key}:{"data-tree-row-key":e.row.key},()=>{var c;return((c=e.dom)==null?void 0:c.title)!==void 0?{title:e.dom.title}:{}},()=>{var c;return((c=e.dom)==null?void 0:c.draggable)!==void 0?{draggable:e.dom.draggable}:{}},()=>{var c;return(c=e.dom)!=null&&c.onDragStart?{onDragStart:e.dom.onDragStart}:{}},()=>{var c;return(c=e.dom)!=null&&c.onDragOver?{onDragOver:e.dom.onDragOver}:{}},()=>{var c;return(c=e.dom)!=null&&c.onDragLeave?{onDragLeave:e.dom.onDragLeave}:{}},()=>{var c;return(c=e.dom)!=null&&c.onDrop?{onDrop:e.dom.onDrop}:{}},()=>{var c;return(c=e.dom)!=null&&c.onDragEnd?{onDragEnd:e.dom.onDragEnd}:{}},()=>{var c;return(c=e.dom)!=null&&c.onMouseEnter?{onMouseEnter:e.dom.onMouseEnter}:{}},()=>{var c;return(c=e.dom)!=null&&c.onMouseLeave?{onMouseLeave:e.dom.onMouseLeave}:{}},{onMouseDown:c=>{if(c.button===2){e.isSelected?e.onFocusRow(e.index):e.onSelect(e.index,"replace");return}c.button===0&&e.onSelect(e.index,tt(c))},onClick:c=>e.onActivateClick(e.row,"single-click",c),onDblClick:c=>e.onActivateClick(e.row,"double-click",c),onContextMenu:c=>{c.preventDefault(),c.stopPropagation(),e.onOpenMenu(e.row,c)}}),!1,!0),l.insert(t,l.createComponent(m.Show,{get when(){return l.memo(()=>e.indentGuide!=="none")()&&e.row.depth>0},get children(){var c=z();return l.effect(()=>l.className(c,T.treeIndentGuides)),c}}),r),l.insert(t,l.createComponent(m.Show,{get when(){return l.memo(()=>e.indentGuide==="active"&&e.activeGuideDepth>=0)()&&e.row.depth>e.activeGuideDepth},get children(){var c=z();return l.effect(s=>{var g=T.treeIndentGuideActive,S=`${e.activeGuideDepth}`;return g!==s.e&&l.className(c,s.e=g),S!==s.t&&l.setStyleProperty(c,"--tree-active-col",s.t=S),s},{e:void 0,t:void 0}),c}}),r),l.insert(t,l.createComponent(m.Show,{get when(){return e.showChevronGutter},get children(){return o()}}),r),l.insert(r,()=>e.content),l.insert(t,l.createComponent(m.Show,{get when(){return e.actions},get children(){var c=je();return c.$$dblclick=s=>s.stopPropagation(),c.$$keydown=s=>s.stopPropagation(),c.$$click=s=>s.stopPropagation(),l.insert(c,()=>e.actions),l.effect(()=>l.className(c,T.treeRowActions)),c}}),null),l.effect(()=>l.className(r,T.treeRowContent)),t})()}function nt(e){const n=()=>e.query?typeof e.query=="function"?e.query():e.query:"",o=m.createMemo(()=>{const t=n().trim();if(t.length===0)return null;const r=Re(t);return r?r(e.text):null});return l.createComponent(m.Show,{get when(){return o()},get fallback(){return l.memo(()=>e.text)},get children(){return l.createComponent(m.For,{get each(){return o()},children:t=>l.createComponent(m.Show,{get when(){return t.match},get fallback(){return l.memo(()=>t.text)},get children(){var r=et();return l.insert(r,()=>t.text),l.effect(()=>l.className(r,e.class??T.treeMatchHighlight)),r}})})}})}l.delegateEvents(["click","keydown","dblclick"]);const rt="vk_treeStickyWidget_Q-8QQ",ot="vk_treeStickyRow_7gWG2",le={treeStickyWidget:rt,treeStickyRow:ot};var ct=l.template("<div role=list>"),at=l.template("<div role=listitem>");function lt(e){return(()=>{var n=ct();return l.insert(n,l.createComponent(m.Index,{get each(){return e.rows},children:(o,t)=>(()=>{var r=at();return l.insert(r,l.createComponent(ne,{sticky:!0,get row(){return o().row},get index(){return o().index},get rowHeight(){return e.descriptor.rowHeight},get isCursor(){return e.isCursor(o().index)},get isSelected(){return e.isSelected(o().row)},treeHasFocus:()=>!1,get showChevronGutter(){return e.showChevronGutter},get indentGuide(){return e.indentGuide},get activeGuideDepth(){return e.activeGuideDepth},get dom(){var a,c;return(c=(a=e.descriptor).rowProps)==null?void 0:c.call(a,o().row)},get content(){return e.descriptor.renderContent(o().row)},get actions(){var a,c;return(c=(a=e.descriptor).renderActions)==null?void 0:c.call(a,o().row)},get onSelect(){return e.onSelect},get onFocusRow(){return e.onFocusRow},get onToggle(){return e.onToggle},onActivateClick:()=>e.onReveal(o().index),get onOpenMenu(){return e.onOpenMenu}})),l.effect(a=>{var c=le.treeStickyRow,s=`${o().top}px`,g=`${e.rows.length-t}`;return c!==a.e&&l.className(r,a.e=c),s!==a.t&&l.setStyleProperty(r,"top",a.t=s),g!==a.a&&l.setStyleProperty(r,"z-index",a.a=g),a},{e:void 0,t:void 0,a:void 0}),r})()})),l.effect(o=>{var t=le.treeStickyWidget,r=e.label,a=`${e.height}px`;return t!==o.e&&l.className(n,o.e=t),r!==o.t&&l.setAttribute(n,"aria-label",o.t=r),a!==o.a&&l.setStyleProperty(n,"height",o.a=a),o},{e:void 0,t:void 0,a:void 0}),n})()}var it=l.template("<div role=status aria-live=polite aria-atomic=true><span>"),ut=l.template("<div><div>"),st=l.template("<p>"),dt=l.template("<div>");const ie="roving-tabindex";function ht(e){const n=()=>e.surface.descriptor,o=()=>e.surface.controller;let t;const r=m.createMemo(()=>({...ee,...n().capabilities})),a=()=>r().canExpand&&(n().chevronGutter??!0),c=m.createMemo(()=>{if((n().indentGuide??"none")!=="active")return-1;const v=e.surface.cursorRow();return v?v.depth-1:-1}),s=m.createMemo(()=>{const{start:v,end:u}=e.surface.scroller.range();return Array.from({length:u-v},(A,I)=>v+I)}),g=m.createSelector(()=>o().cursorIndex());be.useListCommands({container:()=>t,supportsMultiselect:()=>r().canMultiSelect,verbs:{selectAll:()=>o().selectAll()}});const S=Ie.useKeybindingsOptional()===null,d=v=>(v.key==="a"||v.key==="A")&&(v.ctrlKey||v.metaKey)&&!v.altKey&&!v.shiftKey,y=m.createMemo(()=>ge({treeId:n().id,label:n().ariaLabel,multiSelectable:r().canMultiSelect,focusMode:ie,cursorKey:o().cursorKey(),flat:!r().canExpand})),C=v=>{const u=v;return u!=null&&u.tagName?u.tagName==="INPUT"||u.tagName==="TEXTAREA"||u.isContentEditable===!0:!1},R=()=>t!==void 0&&t.contains(t.ownerDocument.activeElement),x=(v,u)=>{o().selectIndex(v,u)},H=(v,u,A)=>{var I,b;(b=(I=n()).onActivate)==null||b.call(I,v,u,A)},_=(v,u)=>{e.surface.openMenu(v,{x:u.clientX,y:u.clientY},u)},N=v=>{t==null||t.focus({preventScroll:!0}),e.surface.scroller.scrollToIndex(v,"auto",e.surface.stickyInsetFor(v))};return(()=>{var v=dt();return l.insert(v,l.createComponent(m.Show,{get when(){return o().typeAheadQuery().length>0},get children(){var u=it(),A=u.firstChild;return l.insert(u,l.createComponent(Z.VpSearch,{get class(){return T.treeSpeedSearchIcon}}),A),l.insert(A,()=>o().typeAheadQuery()),l.effect(I=>{var b=T.treeSpeedSearchBadge,E=T.treeSpeedSearchText;return b!==I.e&&l.className(u,I.e=b),E!==I.t&&l.className(A,I.t=E),I},{e:void 0,t:void 0}),u}}),null),l.insert(v,l.createComponent(ke.OverlayScrollArea,{viewportRef:u=>{var A;e.surface.scroller.containerRef(u),(A=e.viewportRef)==null||A.call(e,u)},get viewportClass(){return`${T.treeViewport} ${e.viewportClass??""}`.trim()},get children(){return[(()=>{var u=ut(),A=u.firstChild,I=t;return typeof I=="function"?l.use(I,u):t=u,l.spread(u,l.mergeProps(y,{get class(){return T.treeContainer},get style(){return{height:`${e.surface.scroller.totalHeight()}px`}},onKeyDown:b=>{if(!C(b.target)){if(S&&d(b)&&r().canMultiSelect){b.preventDefault(),o().selectAll();return}o().handleKeyDown(b)}},onFocus:b=>{b.target===b.currentTarget&&o().cursorIndex()<0&&o().focusIndex(0)}}),!1,!0),l.insert(A,l.createComponent(m.Index,{get each(){return s()},children:b=>{const E=m.createMemo(()=>e.surface.source().at(b())),L=()=>g(b()),W=()=>o().selectedKeys().has(E().key),re=m.createMemo(()=>we({treeId:n().id,rows:e.surface.source(),index:b(),flat:!r().canExpand}));return l.createComponent(ne,{get row(){return E()},get index(){return b()},get aria(){return ye({structure:re(),focusMode:ie,isCursor:L(),isSelected:W()})},get rowHeight(){return n().rowHeight},get isCursor(){return L()},get isSelected(){return W()},treeHasFocus:R,get showChevronGutter(){return a()},get indentGuide(){return n().indentGuide??"none"},get activeGuideDepth(){return c()},get dom(){var K,O;return(O=(K=n()).rowProps)==null?void 0:O.call(K,E())},get content(){return n().renderContent(E())},get actions(){var K,O;return(O=(K=n()).renderActions)==null?void 0:O.call(K,E())},onSelect:x,onFocusRow:K=>o().focusIndex(K),onToggle:K=>{var O,V;return(V=(O=n()).onToggle)==null?void 0:V.call(O,K)},onActivateClick:H,onOpenMenu:_})}})),l.effect(b=>{var E=T.treeSlice,L=`translate3d(0, ${e.surface.scroller.offsetY()}px, 0)`;return E!==b.e&&l.className(A,b.e=E),L!==b.t&&l.setStyleProperty(A,"transform",b.t=L),b},{e:void 0,t:void 0}),u})(),l.createComponent(m.Show,{get when(){return l.memo(()=>e.surface.source().length===0)()&&n().emptyLabel},get children(){var u=st();return l.insert(u,()=>n().emptyLabel),l.effect(()=>l.className(u,T.treeEmpty)),u}})]}}),null),l.insert(v,l.createComponent(m.Show,{get when(){return e.surface.stickyState().rows.length>0},get children(){return l.createComponent(lt,{get rows(){return e.surface.stickyState().rows},get height(){return e.surface.stickyState().height},get label(){return Ce.t("Sticky parent rows")},get descriptor(){return n()},get showChevronGutter(){return a()},get indentGuide(){return n().indentGuide??"none"},get activeGuideDepth(){return c()},isCursor:u=>o().cursorIndex()===u,isSelected:u=>o().selectedKeys().has(u.key),onSelect:x,onFocusRow:u=>o().focusIndex(u),onToggle:u=>{var A,I;return(I=(A=n()).onToggle)==null?void 0:I.call(A,u)},onReveal:N,onOpenMenu:_})}}),null),l.effect(u=>{var A=T.treeStickyHost,I=`${n().indentBaseRem??0}rem`;return A!==u.e&&l.className(v,u.e=A),I!==u.t&&l.setStyleProperty(v,"--tree-indent-base",u.t=I),u},{e:void 0,t:void 0}),v})()}const ue=10,U=(e,n)=>Math.max(0,Math.min(e,n-1));function ft(e){return e.key.length===1&&e.key!==" "&&!e.ctrlKey&&!e.metaKey&&!e.altKey}function gt(e,n){const{index:o,rowCount:t,capabilities:r}=n;if(t===0)return null;const a=o<0?-1:o;switch(j.namedKeyOf(e)){case"ArrowDown":return e.shiftKey&&r.canMultiSelect?{type:"extend",to:U(a+1,t)}:{type:"move",to:U(a+1,t)};case"ArrowUp":return a<0?{type:"move",to:t-1}:e.shiftKey&&r.canMultiSelect?{type:"extend",to:U(a-1,t)}:{type:"move",to:U(a-1,t)};case"Home":return{type:"move",to:0};case"End":return{type:"move",to:t-1};case"PageDown":return{type:"move",to:U(Math.max(a,0)+ue,t)};case"PageUp":return{type:"move",to:U(Math.max(a,0)-ue,t)};case"ArrowRight":return r.canExpand?{type:"expandOrDescend"}:{type:"flatNavigate",direction:"in"};case"ArrowLeft":return e.ctrlKey||e.metaKey?null:r.canExpand?{type:"collapseOrAscend"}:{type:"flatNavigate",direction:"out"};case"Enter":return{type:"activate"};case"ContextMenu":return{type:"openMenu"};case"F10":return e.shiftKey?{type:"openMenu"}:null}return e.key===" "?r.canExpand?{type:"toggle"}:null:r.canTypeAhead&&ft(e)?{type:"typeAhead",char:e.key}:null}function wt(e,n,o,t=!1){const r=o.toLowerCase();if(r.length===0)return-1;const a=e.length;if(a===0)return-1;const c=t?0:1;for(let s=c;s<=a;s++){const g=(n+s+a)%a;if(e.at(g).label.toLowerCase().startsWith(r))return g}for(let s=c;s<=a;s++){const g=(n+s+a)%a;if(e.at(g).label.toLowerCase().includes(r))return g}return-1}function me(e,n,o){const t=[...o].filter(S=>e.indexOfKey(S)>=0),r=yt(e,n,t),a=mt(e,r),c=S=>S.selectable!==!1&&(a===void 0||S.kind===a),s=new Set(t);let g=r<0?-1:e.parentIndex(r);for(;;){const S=vt(e,g,c);if(g<0)return S;const d=S.length===s.size&&S.every(C=>s.has(C));if(S.length>0&&!d)return S;const y=e.at(g);if(S.length>0&&c(y))return[y.key,...S];g=e.parentIndex(g)}}function yt(e,n,o){const t=n>=0&&n<e.length?e.at(n).key:void 0;if(t!==void 0&&!o.includes(t))return n;const r=o[0];return r===void 0?-1:e.indexOfKey(r)}function mt(e,n){if(n>=0){const t=e.at(n);if(t.selectable!==!1)return t.kind}const o=Math.max(n,0);for(let t=0;t<e.length;t++){const r=e.at((o+t)%e.length);if(r.selectable!==!1)return r.kind}}function vt(e,n,o){const t=n<0?0:n+1,r=n<0?e.length-1:e.subtreeEnd(n),a=[];for(let c=t;c<=r;c++){const s=e.at(c);o(s)&&a.push(s.key)}return a}const se=1e3;function X(e,n){const o=[];for(let t=e.parentIndex(n);t!==-1;t=e.parentIndex(t))o.push(e.at(t).key);return{key:e.at(n).key,ancestors:o,index:n}}function de(e,n){if(n===null||e.length===0)return-1;if(n.index<e.length&&e.at(n.index).key===n.key)return n.index;const o=e.indexOfKey(n.key);if(o>=0)return o;for(const t of n.ancestors){const r=e.indexOfKey(t);if(r>=0)return r}return Math.min(n.index,e.length-1)}function ve(e){const n=()=>({...ee,...e.capabilities,expandAll:!1}),[o,t]=m.createSignal(null),[r,a]=m.createSignal(new Set),[c,s]=m.createSignal(null),g=m.createMemo(()=>de(e.rows(),o())),S=()=>de(e.rows(),c()),d=m.createMemo(()=>{const i=g();return i<0?null:e.rows().at(i).key});m.createEffect(()=>{const i=o(),h=g();if(i===null||h<0)return;const f=e.rows(),w=f.at(h).key;if(w===i.key){h!==i.index&&t(X(f,h));return}i.ancestors.includes(w)&&t(X(f,h))});const[y,C]=m.createSignal("");let R=0,x;const H=()=>{x!==void 0&&(clearTimeout(x),x=void 0),y().length>0&&C("")},_=()=>{x!==void 0&&(clearTimeout(x),x=void 0),x=setTimeout(()=>{C(""),x=void 0},se)};m.onCleanup(()=>{x!==void 0&&(clearTimeout(x),x=void 0)});const N=i=>{const h=e.rows();return i>=0&&i<h.length?h.at(i):void 0},v=(i,h)=>{var w;const f=X(e.rows(),i);t(f),h&&s(f),(w=e.onScrollToIndex)==null||w.call(e,i)},u=i=>{const h=e.rows();i<0||i>=h.length||i===g()||v(i,!0)},A=i=>{var f;const h=e.rows().indexOfKey(i);h<0||(h===g()?(f=e.onScrollToIndex)==null||f.call(e,h):u(h))},I=(i,h)=>{var P;const f=e.rows(),w=(P=N(i))==null?void 0:P.kind,[k,M]=i<=h?[i,h]:[h,i],D=new Set;for(let F=Math.max(k,0);F<=Math.min(M,f.length-1);F++){const q=f.at(F);q.selectable!==!1&&(w!==void 0&&q.kind!==w||D.add(q.key))}return D},b=(i,h)=>{H();const f=N(i);if(f){if(f.selectable===!1&&h!=="range"){u(i);return}if(h==="toggle"&&n().canMultiSelect){const w=new Set(r());w.has(f.key)?w.delete(f.key):w.add(f.key),a(w),v(i,!0);return}if(h==="range"&&n().canMultiSelect){const w=S();a(I(w>=0?w:i,i)),v(i,!1);return}a(new Set([f.key])),v(i,!0)}},E=(i,h)=>{const f=e.rows().indexOfKey(i);f>=0&&b(f,h)},L=()=>{H(),r().size>0&&a(new Set)},W=(i,h)=>{const f=e.rows(),w=N(i);if(!w)return;const k=w.depth+1,M=f.subtreeEnd(i);for(let D=i+1;D<=M;D=f.subtreeEnd(D)+1){const P=f.at(D);P.depth===k&&h(P,D)}};return{cursorIndex:g,cursorKey:d,selectedKeys:r,typeAheadQuery:y,get capabilities(){return n()},focusIndex:u,focusKey:A,selectIndex:b,selectKey:E,clearSelection:L,selectChildren:i=>{const h=new Set;let f,w=!1,k=-1;W(i,(M,D)=>{if(M.selectable!==!1){if(!w)f=M.kind,k=D,w=!0;else if(f!==void 0&&M.kind!==f)return;h.add(M.key)}}),h.size!==0&&(a(h),k>=0&&v(k,!0))},selectAll:()=>{n().canMultiSelect&&a(new Set(me(e.rows(),g(),r())))},childKindsHomogeneous:i=>{let h,f=!1,w=0,k=0;return W(i,M=>{M.selectable!==!1&&(w++,f?(h===void 0||M.kind===h)&&k++:(h=M.kind,f=!0,k++))}),{homogeneous:w>0&&w===k,total:w,selectable:k}},handleKeyDown:i=>{var M,D,P,F,q,oe,ce;if(j.isKey(i,"Escape")&&y().length>0){i.preventDefault(),i.stopPropagation(),H();return}const h=e.rows(),f=g(),w=gt(i,{index:f,rowCount:h.length,capabilities:n()});if(!w)return;const k=N(f);switch(w.type){case"move":i.preventDefault(),u(w.to);return;case"extend":{i.preventDefault();const $=S();a(I($>=0?$:f,w.to)),v(w.to,!1);return}case"expandOrDescend":if(!k)return;if(i.preventDefault(),k.expandable&&!k.expanded){(M=e.onToggle)==null||M.call(e,k);return}u(f+1);return;case"collapseOrAscend":{if(!k)return;if(i.preventDefault(),k.expandable&&k.expanded){(D=e.onToggle)==null||D.call(e,k);return}const $=h.parentIndex(f);$>=0&&u($);return}case"toggle":if(!(k!=null&&k.expandable))return;i.preventDefault(),(P=e.onToggle)==null||P.call(e,k);return;case"flatNavigate":i.preventDefault(),(F=e.onFlatNavigate)==null||F.call(e,w.direction,k);return;case"activate":if(!k)return;i.preventDefault(),(q=e.onActivate)==null||q.call(e,k);return;case"openMenu":{if(!k)return;i.preventDefault();const $=i.target,G=$==null?void 0:$.getBoundingClientRect();(oe=e.onOpenMenu)==null||oe.call(e,k,{x:Math.round((G==null?void 0:G.left)??0),y:Math.round((G==null?void 0:G.bottom)??0)});return}case"typeAhead":{const $=((ce=e.now)==null?void 0:ce.call(e))??Date.now(),G=$-R>se,B=G?"":y(),Y=B.length===1&&B.toLowerCase()===w.char.toLowerCase()?B:`${B}${w.char}`,ae=wt(h,f,Y,Y.length>1&&!G);if(R=$,ae<0){C(B),B.length>0?_():H();return}C(Y),_(),i.preventDefault(),u(ae);return}}},openMenuAt:(i,h)=>{var w;const f=N(i);f&&((w=e.onOpenMenu)==null||w.call(e,f,h))}}}const St=.4,kt={rows:[],height:0};function Se(e){return Math.max(Math.floor(e),1)}function Ct(e,n,o){let t=n,r=e.parentIndex(t);for(;r!==-1;){if(r===o)return t;t=r,r=e.parentIndex(t)}return o===-1?t:-1}function xt(e,n,o,t){let r=e;for(let c=0;c<e.length;c++)if(e[c].top+t>o||c>=n){r=e.slice(0,c);break}const a=r[r.length-1];return a?{rows:r,height:a.top+t}:{rows:[],height:0}}function bt(e){const{rows:n,scrollTop:o,rowHeight:t,viewportHeight:r}=e;if(n.length===0||t<=0)return kt;const a=Se(e.maxCount),c=[];let s=0,g=-1;for(;;){const S=Math.floor((o+s)/t);if(S<0||S>=n.length)break;const d=Ct(n,S,g);if(d===-1)break;const y=n.subtreeEnd(d);if(y===d||d===S&&o===d*t-s)break;const C=(y+1)*t-o,R=s,x=R+t>C&&R<=C?C-t:R;if(c.push({index:d,row:n.at(d),top:x}),s=x+t,g=d,c.length>=a)break}return xt(c,a,r*St,t)}function It(e,n,o,t){if(n<0||n>=e.length)return 0;const r=Se(t);let a=0,c=e.parentIndex(n);for(;c!==-1&&(a++,a!==r);)c=e.parentIndex(c);return a*o}function he(e,n,o){if(n<=0||e.length===0||o<=0)return null;const t=Math.min(e.length-1,Math.floor(n/o));return{key:e.at(t).key,offset:n-t*o,contentTop:n}}function Tt(e,n,o,t){if(n===null||Math.abs(o-n.contentTop)>=J.SCROLL_TOLERANCE_PX)return null;const r=e.indexOfKey(n.key);if(r<0)return null;const a=r*t+n.offset;return Math.abs(a-n.contentTop)>=J.SCROLL_TOLERANCE_PX?a:null}const At=8,fe=7,Rt={rows:[],height:0};function Mt(e){const n=m.useContext(Te.DesktopContextMenuContext),o=m.createMemo(()=>e.rows()),t=J.createVirtualWindow({count:()=>o().length,itemHeight:e.rowHeight,overscan:e.overscan??At}),r=m.createMemo(()=>e.stickyScroll!==!0?Rt:bt({rows:o(),scrollTop:t.scrollTop(),rowHeight:e.rowHeight,viewportHeight:t.viewportHeight(),maxCount:e.stickyScrollMaxCount??fe})),a=d=>e.stickyScroll===!0?It(o(),d,e.rowHeight,e.stickyScrollMaxCount??fe):0,c=ve({rows:o,...e.capabilities?{capabilities:e.capabilities}:{},onToggle:d=>{var y;return(y=e.onToggle)==null?void 0:y.call(e,d)},onActivate:d=>{var y;return(y=e.onActivate)==null?void 0:y.call(e,d,"keyboard")},onOpenMenu:(d,y)=>S(d,y),onCollapseAll:()=>{var d;return(d=e.onCollapseAll)==null?void 0:d.call(e)},onFlatNavigate:(d,y)=>{var C;return(C=e.onFlatNavigate)==null?void 0:C.call(e,d,y)},onRename:d=>{var y;return(y=e.onRename)==null?void 0:y.call(e,d)},onDestroy:d=>{var y;return(y=e.onDestroy)==null?void 0:y.call(e,d)},onScrollToIndex:d=>t.scrollToIndex(d,"auto",a(d))}),s=()=>{const d=c.cursorIndex();return d<0?void 0:o().at(d)};let g=null;m.createEffect(()=>{const d=t.scrollTop();g=he(m.untrack(o),d,e.rowHeight)}),m.createEffect(m.on(o,d=>{const y=Tt(d,g,t.readScrollTop(),e.rowHeight);y!==null&&t.scrollToContentTop(y),g=he(d,t.readScrollTop(),e.rowHeight)},{defer:!0}));function S(d,y,C){if(e.openMenu){e.openMenu(d,y,C);return}if(!e.buildMenu)return;const R=e.buildMenu(d,c.selectedKeys());if(R.length!==0){if(!n)throw new p.BugIndicatingError("createTreeSurface: descriptor builds a context menu but no DesktopContextMenuProvider is mounted");n.open(y.x,y.y,R,C)}}return{descriptor:e,controller:c,scroller:t,source:o,cursorRow:s,stickyState:r,stickyInsetFor:a,openMenu:S}}const _t=.85;function Q(e,n){if(!Number.isInteger(n)||n<0||n>=e.length)throw new p.BugIndicatingError(`tree row source: index ${n} is outside 0..${e.length-1}`)}function Et(e){const n=e.length,o=new Int32Array(n),t=new Int32Array(n),r=new Int32Array(n),a=new Int32Array(n),c=[],s=[],g=[],S=[];let d=-1,y=-1;for(let C=0;C<n;C++){const R=e[C].depth;for(;s.length>0&&e[s[s.length-1]].depth>=R;)t[s.pop()]=C-1,g.pop(),S.pop();const x=s.length-1;o[C]=x<0?-1:s[x];const H=x<0?d:g[x];let _=x<0?y:S[x];H!==R&&(_=c.length,c.push(0),x<0?(d=R,y=_):(g[x]=R,S[x]=_)),c[_]=c[_]+1,a[C]=_,r[C]=c[_],s.push(C),g.push(-1),S.push(-1)}for(const C of s)t[C]=n-1;return{parent:o,subtreeEnd:t,posInSet:r,group:a,groupSizes:c}}function Dt(e){const n=new Map;for(let o=0;o<e.length;o++){const t=e[o].key,r=n.get(t);if(r!==void 0)throw new p.BugIndicatingError(`tree row source: key "${t}" occurs at rows ${r} and ${o}`);n.set(t,o)}return n}function $t(e){const n=e.slice(),o=Et(n),t=Dt(n),r={length:n.length,at:a=>(Q(r,a),n[a]),parentIndex:a=>(Q(r,a),o.parent[a]),subtreeEnd:a=>(Q(r,a),o.subtreeEnd[a]),siblingPosition:a=>(Q(r,a),{posInSet:o.posInSet[a],setSize:o.groupSizes[o.group[a]]}),indexOfKey:a=>t.get(a)??-1};return r}exports.DEFAULT_TREE_CAPABILITIES=ee;exports.TREE_INDENT_STEP_REM=_t;exports.TreeHighlight=nt;exports.TreeRow=ne;exports.TreeSurface=ht;exports.assertRowIndex=Q;exports.buildTreeContainerAria=ge;exports.buildTreeRowAria=ye;exports.buildTreeRowStructureAria=we;exports.createTreeController=ve;exports.createTreeSurface=Mt;exports.selectAllInScope=me;exports.treeRowDomId=te;exports.treeRowsFrom=$t;
|