@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
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* It lives OUTSIDE the scroll viewport, as an absolute child of TreeSurface's
|
|
5
5
|
* host, for two independent reasons. Chrome inside the scroll area breaks the
|
|
6
|
-
* virtual
|
|
6
|
+
* virtual window's `scrollTop` arithmetic (the database panel's connection
|
|
7
7
|
* header sits outside for exactly this reason, and says so). And
|
|
8
8
|
* `OverlayScrollArea` watches its viewport with a MutationObserver over
|
|
9
9
|
* `{childList, subtree}` — a widget that re-renders on every scroll frame in
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* It lives OUTSIDE the scroll viewport, as an absolute child of TreeSurface's
|
|
5
5
|
* host, for two independent reasons. Chrome inside the scroll area breaks the
|
|
6
|
-
* virtual
|
|
6
|
+
* virtual window's `scrollTop` arithmetic (the database panel's connection
|
|
7
7
|
* header sits outside for exactly this reason, and says so). And
|
|
8
8
|
* `OverlayScrollArea` watches its viewport with a MutationObserver over
|
|
9
9
|
* `{childList, subtree}` — a widget that re-renders on every scroll frame in
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* TreeSurface — the shared DOM base under every tree in the app.
|
|
3
3
|
*
|
|
4
|
-
* It owns the scroll container (exactly one, and it is the virtual
|
|
4
|
+
* It owns the scroll container (exactly one, and it is the virtual window's:
|
|
5
5
|
* a tree nested inside someone else's scroller is a dead tree), the `role=tree`
|
|
6
6
|
* semantics, the keyboard entry point, and the row stack. It owns no surface
|
|
7
7
|
* knowledge whatsoever — no `if` in this file may ask which tree it is drawing.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* TreeSurface — the shared DOM base under every tree in the app.
|
|
3
3
|
*
|
|
4
|
-
* It owns the scroll container (exactly one, and it is the virtual
|
|
4
|
+
* It owns the scroll container (exactly one, and it is the virtual window's:
|
|
5
5
|
* a tree nested inside someone else's scroller is a dead tree), the `role=tree`
|
|
6
6
|
* semantics, the keyboard entry point, and the row stack. It owns no surface
|
|
7
7
|
* knowledge whatsoever — no `if` in this file may ask which tree it is drawing.
|
|
@@ -2,20 +2,27 @@
|
|
|
2
2
|
* createTreeController — the headless brain every tree surface shares.
|
|
3
3
|
*
|
|
4
4
|
* It owns the cursor, the selection, the keyboard, and the a11y wiring; it owns
|
|
5
|
-
* no DOM and knows no surface. A surface hands it
|
|
6
|
-
* back state plus a keydown handler. What the rows LOOK like is none of its
|
|
5
|
+
* no DOM and knows no surface. A surface hands it a row source and callbacks and
|
|
6
|
+
* gets back state plus a keydown handler. What the rows LOOK like is none of its
|
|
7
7
|
* business — that belongs to `<TreeRow>` and the surface descriptor.
|
|
8
8
|
*
|
|
9
9
|
* The cursor and the selection are two different things, and keeping them apart
|
|
10
10
|
* is the point. Arrow keys move the cursor and leave the selection alone; Enter
|
|
11
|
-
* and clicks change the selection.
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* and clicks change the selection. Surfaces that conflated them — one where a
|
|
12
|
+
* plain click actively CLEARED the selection — never got Shift+Arrow right.
|
|
13
|
+
*
|
|
14
|
+
* The cursor and the range anchor are held by KEY, not by index. An index means
|
|
15
|
+
* "the row that happens to be there": expanding a folder above the cursor used
|
|
16
|
+
* to move the cursor onto a different row, without the user touching it. A key
|
|
17
|
+
* follows its row; a row that disappears (its parent collapsed) hands the cursor
|
|
18
|
+
* to its nearest surviving ancestor, as the reference tree does, and only with
|
|
19
|
+
* none left does the old index stand in.
|
|
14
20
|
*/
|
|
15
21
|
import { type Accessor } from 'solid-js';
|
|
16
22
|
import { type SelectionModifier, type TreeCapabilities, type TreePoint, type TreeRow } from './types.cjs';
|
|
23
|
+
import type { TreeRowSource } from './rowSource.cjs';
|
|
17
24
|
export interface TreeControllerOptions {
|
|
18
|
-
rows: Accessor<
|
|
25
|
+
rows: Accessor<TreeRowSource<TreeRow>>;
|
|
19
26
|
capabilities?: Partial<TreeCapabilities>;
|
|
20
27
|
/** Expand or collapse the row. The surface owns what that means. */
|
|
21
28
|
onToggle?: (row: TreeRow) => void;
|
|
@@ -48,8 +55,12 @@ export interface TreeController {
|
|
|
48
55
|
capabilities: TreeCapabilities;
|
|
49
56
|
/** Move the cursor without touching the selection. */
|
|
50
57
|
focusIndex: (index: number) => void;
|
|
58
|
+
/** Move the cursor to the row with this key, without touching the selection; nothing when no row has it. */
|
|
59
|
+
focusKey: (key: string) => void;
|
|
51
60
|
/** Click path. `replace` also moves the cursor and resets the range anchor. */
|
|
52
61
|
selectIndex: (index: number, modifier: SelectionModifier) => void;
|
|
62
|
+
/** The click path for the row with this key; nothing when no row has it. */
|
|
63
|
+
selectKey: (key: string, modifier: SelectionModifier) => void;
|
|
53
64
|
/**
|
|
54
65
|
* Drop the selection without moving the cursor. For after a bulk action has
|
|
55
66
|
* consumed it — a cherry-pick of five commits must not leave those five looking
|
|
@@ -59,8 +70,8 @@ export interface TreeController {
|
|
|
59
70
|
/** Select the DIRECT children of `index`, kind-locked ("Select All Child Objects"). */
|
|
60
71
|
selectChildren: (index: number) => void;
|
|
61
72
|
/**
|
|
62
|
-
* `list.selectAll` (`Ctrl/Cmd+A
|
|
63
|
-
*
|
|
73
|
+
* `list.selectAll` (`Ctrl/Cmd+A`): the reference's tree Select All — the cursor row's scope, widening one level per
|
|
74
|
+
* press (`selectAllInScope`). Does nothing on a single-selection tree.
|
|
64
75
|
*/
|
|
65
76
|
selectAll: () => void;
|
|
66
77
|
/** Whether `index`'s selectable direct children all share one kind (the enablement gate). */
|
|
@@ -2,20 +2,27 @@
|
|
|
2
2
|
* createTreeController — the headless brain every tree surface shares.
|
|
3
3
|
*
|
|
4
4
|
* It owns the cursor, the selection, the keyboard, and the a11y wiring; it owns
|
|
5
|
-
* no DOM and knows no surface. A surface hands it
|
|
6
|
-
* back state plus a keydown handler. What the rows LOOK like is none of its
|
|
5
|
+
* no DOM and knows no surface. A surface hands it a row source and callbacks and
|
|
6
|
+
* gets back state plus a keydown handler. What the rows LOOK like is none of its
|
|
7
7
|
* business — that belongs to `<TreeRow>` and the surface descriptor.
|
|
8
8
|
*
|
|
9
9
|
* The cursor and the selection are two different things, and keeping them apart
|
|
10
10
|
* is the point. Arrow keys move the cursor and leave the selection alone; Enter
|
|
11
|
-
* and clicks change the selection.
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* and clicks change the selection. Surfaces that conflated them — one where a
|
|
12
|
+
* plain click actively CLEARED the selection — never got Shift+Arrow right.
|
|
13
|
+
*
|
|
14
|
+
* The cursor and the range anchor are held by KEY, not by index. An index means
|
|
15
|
+
* "the row that happens to be there": expanding a folder above the cursor used
|
|
16
|
+
* to move the cursor onto a different row, without the user touching it. A key
|
|
17
|
+
* follows its row; a row that disappears (its parent collapsed) hands the cursor
|
|
18
|
+
* to its nearest surviving ancestor, as the reference tree does, and only with
|
|
19
|
+
* none left does the old index stand in.
|
|
14
20
|
*/
|
|
15
21
|
import { type Accessor } from 'solid-js';
|
|
16
22
|
import { type SelectionModifier, type TreeCapabilities, type TreePoint, type TreeRow } from './types.js';
|
|
23
|
+
import type { TreeRowSource } from './rowSource.js';
|
|
17
24
|
export interface TreeControllerOptions {
|
|
18
|
-
rows: Accessor<
|
|
25
|
+
rows: Accessor<TreeRowSource<TreeRow>>;
|
|
19
26
|
capabilities?: Partial<TreeCapabilities>;
|
|
20
27
|
/** Expand or collapse the row. The surface owns what that means. */
|
|
21
28
|
onToggle?: (row: TreeRow) => void;
|
|
@@ -48,8 +55,12 @@ export interface TreeController {
|
|
|
48
55
|
capabilities: TreeCapabilities;
|
|
49
56
|
/** Move the cursor without touching the selection. */
|
|
50
57
|
focusIndex: (index: number) => void;
|
|
58
|
+
/** Move the cursor to the row with this key, without touching the selection; nothing when no row has it. */
|
|
59
|
+
focusKey: (key: string) => void;
|
|
51
60
|
/** Click path. `replace` also moves the cursor and resets the range anchor. */
|
|
52
61
|
selectIndex: (index: number, modifier: SelectionModifier) => void;
|
|
62
|
+
/** The click path for the row with this key; nothing when no row has it. */
|
|
63
|
+
selectKey: (key: string, modifier: SelectionModifier) => void;
|
|
53
64
|
/**
|
|
54
65
|
* Drop the selection without moving the cursor. For after a bulk action has
|
|
55
66
|
* consumed it — a cherry-pick of five commits must not leave those five looking
|
|
@@ -59,8 +70,8 @@ export interface TreeController {
|
|
|
59
70
|
/** Select the DIRECT children of `index`, kind-locked ("Select All Child Objects"). */
|
|
60
71
|
selectChildren: (index: number) => void;
|
|
61
72
|
/**
|
|
62
|
-
* `list.selectAll` (`Ctrl/Cmd+A
|
|
63
|
-
*
|
|
73
|
+
* `list.selectAll` (`Ctrl/Cmd+A`): the reference's tree Select All — the cursor row's scope, widening one level per
|
|
74
|
+
* press (`selectAllInScope`). Does nothing on a single-selection tree.
|
|
64
75
|
*/
|
|
65
76
|
selectAll: () => void;
|
|
66
77
|
/** Whether `index`'s selectable direct children all share one kind (the enablement gate). */
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type VirtualWindow } from '../layout/createVirtualWindow.cjs';
|
|
2
2
|
import { type TreeController } from './createTreeController.cjs';
|
|
3
3
|
import { type StickyTreeState } from './stickyScroll.cjs';
|
|
4
4
|
import type { TreeSurfaceDescriptor, TreeSurfaceRow } from './descriptor.cjs';
|
|
5
|
+
import type { TreeRowSource } from './rowSource.cjs';
|
|
5
6
|
import type { TreePoint } from './types.cjs';
|
|
6
7
|
export interface TreeSurfaceApi<TNode> {
|
|
7
8
|
descriptor: TreeSurfaceDescriptor<TNode>;
|
|
8
9
|
controller: TreeController;
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
/** The virtual window: which row indices are rendered, and the scroll geometry. */
|
|
11
|
+
scroller: VirtualWindow;
|
|
12
|
+
/** The current row source — the descriptor's, memoised. */
|
|
13
|
+
source: () => TreeRowSource<TreeSurfaceRow<TNode>>;
|
|
14
|
+
/** The row under the cursor; none before the tree is first focused. */
|
|
15
|
+
cursorRow: () => TreeSurfaceRow<TNode> | undefined;
|
|
11
16
|
/** The pinned ancestor chain for the current scroll position. Empty when off. */
|
|
12
17
|
stickyState: () => StickyTreeState<TNode>;
|
|
13
18
|
/**
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type VirtualWindow } from '../layout/createVirtualWindow.js';
|
|
2
2
|
import { type TreeController } from './createTreeController.js';
|
|
3
3
|
import { type StickyTreeState } from './stickyScroll.js';
|
|
4
4
|
import type { TreeSurfaceDescriptor, TreeSurfaceRow } from './descriptor.js';
|
|
5
|
+
import type { TreeRowSource } from './rowSource.js';
|
|
5
6
|
import type { TreePoint } from './types.js';
|
|
6
7
|
export interface TreeSurfaceApi<TNode> {
|
|
7
8
|
descriptor: TreeSurfaceDescriptor<TNode>;
|
|
8
9
|
controller: TreeController;
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
/** The virtual window: which row indices are rendered, and the scroll geometry. */
|
|
11
|
+
scroller: VirtualWindow;
|
|
12
|
+
/** The current row source — the descriptor's, memoised. */
|
|
13
|
+
source: () => TreeRowSource<TreeSurfaceRow<TNode>>;
|
|
14
|
+
/** The row under the cursor; none before the tree is first focused. */
|
|
15
|
+
cursorRow: () => TreeSurfaceRow<TNode> | undefined;
|
|
11
16
|
/** The pinned ancestor chain for the current scroll position. Empty when off. */
|
|
12
17
|
stickyState: () => StickyTreeState<TNode>;
|
|
13
18
|
/**
|
|
@@ -13,10 +13,11 @@
|
|
|
13
13
|
* What is deliberately NOT here: the data source. Each surface already owns a
|
|
14
14
|
* working state machine — git watches a repo, the filesystem watches a disk, the
|
|
15
15
|
* database queries a catalog — and the engine has no business replacing them. It
|
|
16
|
-
* asks only for the
|
|
16
|
+
* asks only for the result as a row source (`rowSource.ts`), in render order.
|
|
17
17
|
*/
|
|
18
18
|
import type { Accessor, JSX } from 'solid-js';
|
|
19
19
|
import type { DesktopContextMenuEntry } from '../context/DesktopContextMenuContext.cjs';
|
|
20
|
+
import type { TreeRowSource } from './rowSource.cjs';
|
|
20
21
|
import type { TreeCapabilities, TreeRow } from './types.cjs';
|
|
21
22
|
/** A row plus the surface's own payload, which the engine never looks inside. */
|
|
22
23
|
export interface TreeSurfaceRow<TNode> extends TreeRow {
|
|
@@ -67,16 +68,14 @@ export interface TreeSurfaceDescriptor<TNode> {
|
|
|
67
68
|
* list mode and tree mode are the same descriptor with this one field flipped.
|
|
68
69
|
*/
|
|
69
70
|
capabilities?: Partial<TreeCapabilities>;
|
|
70
|
-
/** The flattened tree, in render order. The surface owns the flattening. */
|
|
71
|
-
rows: Accessor<readonly TreeSurfaceRow<TNode>[]>;
|
|
72
71
|
/**
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
72
|
+
* The tree's rows, in render order — a new source for every structural
|
|
73
|
+
* change. A surface that keeps an array wraps it with `treeRowsFrom`; one that
|
|
74
|
+
* computes rows on demand implements the source itself. The engine memoises
|
|
75
|
+
* this accessor, so building the source here runs once per change.
|
|
77
76
|
*/
|
|
78
|
-
|
|
79
|
-
/** Fixed, and equal to the CSS row height — the virtual
|
|
77
|
+
rows: Accessor<TreeRowSource<TreeSurfaceRow<TNode>>>;
|
|
78
|
+
/** Fixed, and equal to the CSS row height — the virtual window does arithmetic with it. */
|
|
80
79
|
rowHeight: number;
|
|
81
80
|
overscan?: number;
|
|
82
81
|
/**
|
|
@@ -13,10 +13,11 @@
|
|
|
13
13
|
* What is deliberately NOT here: the data source. Each surface already owns a
|
|
14
14
|
* working state machine — git watches a repo, the filesystem watches a disk, the
|
|
15
15
|
* database queries a catalog — and the engine has no business replacing them. It
|
|
16
|
-
* asks only for the
|
|
16
|
+
* asks only for the result as a row source (`rowSource.ts`), in render order.
|
|
17
17
|
*/
|
|
18
18
|
import type { Accessor, JSX } from 'solid-js';
|
|
19
19
|
import type { DesktopContextMenuEntry } from '../context/DesktopContextMenuContext.js';
|
|
20
|
+
import type { TreeRowSource } from './rowSource.js';
|
|
20
21
|
import type { TreeCapabilities, TreeRow } from './types.js';
|
|
21
22
|
/** A row plus the surface's own payload, which the engine never looks inside. */
|
|
22
23
|
export interface TreeSurfaceRow<TNode> extends TreeRow {
|
|
@@ -67,16 +68,14 @@ export interface TreeSurfaceDescriptor<TNode> {
|
|
|
67
68
|
* list mode and tree mode are the same descriptor with this one field flipped.
|
|
68
69
|
*/
|
|
69
70
|
capabilities?: Partial<TreeCapabilities>;
|
|
70
|
-
/** The flattened tree, in render order. The surface owns the flattening. */
|
|
71
|
-
rows: Accessor<readonly TreeSurfaceRow<TNode>[]>;
|
|
72
71
|
/**
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
72
|
+
* The tree's rows, in render order — a new source for every structural
|
|
73
|
+
* change. A surface that keeps an array wraps it with `treeRowsFrom`; one that
|
|
74
|
+
* computes rows on demand implements the source itself. The engine memoises
|
|
75
|
+
* this accessor, so building the source here runs once per change.
|
|
77
76
|
*/
|
|
78
|
-
|
|
79
|
-
/** Fixed, and equal to the CSS row height — the virtual
|
|
77
|
+
rows: Accessor<TreeRowSource<TreeSurfaceRow<TNode>>>;
|
|
78
|
+
/** Fixed, and equal to the CSS row height — the virtual window does arithmetic with it. */
|
|
80
79
|
rowHeight: number;
|
|
81
80
|
overscan?: number;
|
|
82
81
|
/**
|
package/dist/tree/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../rowSource-D0MM14Bu.cjs");exports.DEFAULT_TREE_CAPABILITIES=e.DEFAULT_TREE_CAPABILITIES;exports.TREE_INDENT_STEP_REM=e.TREE_INDENT_STEP_REM;exports.TreeHighlight=e.TreeHighlight;exports.TreeRow=e.TreeRow;exports.TreeSurface=e.TreeSurface;exports.assertRowIndex=e.assertRowIndex;exports.buildTreeContainerAria=e.buildTreeContainerAria;exports.buildTreeRowAria=e.buildTreeRowAria;exports.buildTreeRowStructureAria=e.buildTreeRowStructureAria;exports.createTreeController=e.createTreeController;exports.createTreeSurface=e.createTreeSurface;exports.selectAllInScope=e.selectAllInScope;exports.treeRowDomId=e.treeRowDomId;exports.treeRowsFrom=e.treeRowsFrom;
|
package/dist/tree/index.d.cts
CHANGED
|
@@ -6,3 +6,4 @@ export { DEFAULT_TREE_CAPABILITIES, type TreeRow as TreeRowModel, type TreeCapab
|
|
|
6
6
|
export * from './treeAria.cjs';
|
|
7
7
|
export { createTreeController, type TreeControllerOptions } from './createTreeController.cjs';
|
|
8
8
|
export { selectAllInScope, type SelectAllRow } from './selectAllInScope.cjs';
|
|
9
|
+
export { assertRowIndex, treeRowsFrom, type TreeRowShape, type TreeRowSource, type TreeSiblingPosition, } from './rowSource.cjs';
|
package/dist/tree/index.d.ts
CHANGED
|
@@ -6,3 +6,4 @@ export { DEFAULT_TREE_CAPABILITIES, type TreeRow as TreeRowModel, type TreeCapab
|
|
|
6
6
|
export * from './treeAria.js';
|
|
7
7
|
export { createTreeController, type TreeControllerOptions } from './createTreeController.js';
|
|
8
8
|
export { selectAllInScope, type SelectAllRow } from './selectAllInScope.js';
|
|
9
|
+
export { assertRowIndex, treeRowsFrom, type TreeRowShape, type TreeRowSource, type TreeSiblingPosition, } from './rowSource.js';
|
package/dist/tree/index.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import { D as
|
|
1
|
+
import { D as a, T as s, a as T, b as o, c as t, d as i, e as l, f as E, g as R, h as c, i as u, s as A, t as I, j as d } from "../rowSource-CfGSdY64.js";
|
|
2
2
|
export {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
a as DEFAULT_TREE_CAPABILITIES,
|
|
4
|
+
s as TREE_INDENT_STEP_REM,
|
|
5
|
+
T as TreeHighlight,
|
|
6
6
|
o as TreeRow,
|
|
7
7
|
t as TreeSurface,
|
|
8
|
-
|
|
9
|
-
l as
|
|
8
|
+
i as assertRowIndex,
|
|
9
|
+
l as buildTreeContainerAria,
|
|
10
|
+
E as buildTreeRowAria,
|
|
11
|
+
R as buildTreeRowStructureAria,
|
|
10
12
|
c as createTreeController,
|
|
11
|
-
|
|
13
|
+
u as createTreeSurface,
|
|
12
14
|
A as selectAllInScope,
|
|
13
|
-
I as treeRowDomId
|
|
15
|
+
I as treeRowDomId,
|
|
16
|
+
d as treeRowsFrom
|
|
14
17
|
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { TreeRow } from './types.cjs';
|
|
2
|
+
/** What the structural questions read of a row: its identity and its depth. */
|
|
3
|
+
export type TreeRowShape = Pick<TreeRow, 'key' | 'depth'>;
|
|
4
|
+
/** `aria-posinset` / `aria-setsize`: 1-based position among the siblings, and their count. */
|
|
5
|
+
export interface TreeSiblingPosition {
|
|
6
|
+
readonly posInSet: number;
|
|
7
|
+
readonly setSize: number;
|
|
8
|
+
}
|
|
9
|
+
export interface TreeRowSource<TRow extends TreeRowShape = TreeRow> {
|
|
10
|
+
/** Number of rendered rows. */
|
|
11
|
+
readonly length: number;
|
|
12
|
+
/**
|
|
13
|
+
* The row at `index`. Type-ahead may read every row through this, so a source
|
|
14
|
+
* that builds rows lazily keeps it cheap — or its surface turns
|
|
15
|
+
* `canTypeAhead` off.
|
|
16
|
+
*/
|
|
17
|
+
at(index: number): TRow;
|
|
18
|
+
/** The nearest preceding row with a smaller depth; -1 for a root. */
|
|
19
|
+
parentIndex(index: number): number;
|
|
20
|
+
/** The last row of `index`'s rendered subtree — `index` itself when it shows no children. */
|
|
21
|
+
subtreeEnd(index: number): number;
|
|
22
|
+
/**
|
|
23
|
+
* Position among the siblings: the rows with the same parent AND the same
|
|
24
|
+
* depth. "3 of 7" means 3 of 7 children, never 3 of 400 visible rows.
|
|
25
|
+
*/
|
|
26
|
+
siblingPosition(index: number): TreeSiblingPosition;
|
|
27
|
+
/** The index of the row with this key, or -1. */
|
|
28
|
+
indexOfKey(key: string): number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* A structural question about a row that does not exist is a caller's bug, not
|
|
32
|
+
* an empty answer: an engine that silently got `-1` back would walk the wrong
|
|
33
|
+
* row instead of failing where the mistake is.
|
|
34
|
+
*/
|
|
35
|
+
export declare function assertRowIndex(source: Pick<TreeRowSource<TreeRowShape>, 'length'>, index: number): void;
|
|
36
|
+
/**
|
|
37
|
+
* The source of an array of rows, in render order. The source keeps its own
|
|
38
|
+
* copy, so a caller that mutates its array afterwards changes nothing here; the
|
|
39
|
+
* parent, subtree-end and sibling tables and the key index are built at once.
|
|
40
|
+
*/
|
|
41
|
+
export declare function treeRowsFrom<TRow extends TreeRowShape>(input: readonly TRow[]): TreeRowSource<TRow>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { TreeRow } from './types.js';
|
|
2
|
+
/** What the structural questions read of a row: its identity and its depth. */
|
|
3
|
+
export type TreeRowShape = Pick<TreeRow, 'key' | 'depth'>;
|
|
4
|
+
/** `aria-posinset` / `aria-setsize`: 1-based position among the siblings, and their count. */
|
|
5
|
+
export interface TreeSiblingPosition {
|
|
6
|
+
readonly posInSet: number;
|
|
7
|
+
readonly setSize: number;
|
|
8
|
+
}
|
|
9
|
+
export interface TreeRowSource<TRow extends TreeRowShape = TreeRow> {
|
|
10
|
+
/** Number of rendered rows. */
|
|
11
|
+
readonly length: number;
|
|
12
|
+
/**
|
|
13
|
+
* The row at `index`. Type-ahead may read every row through this, so a source
|
|
14
|
+
* that builds rows lazily keeps it cheap — or its surface turns
|
|
15
|
+
* `canTypeAhead` off.
|
|
16
|
+
*/
|
|
17
|
+
at(index: number): TRow;
|
|
18
|
+
/** The nearest preceding row with a smaller depth; -1 for a root. */
|
|
19
|
+
parentIndex(index: number): number;
|
|
20
|
+
/** The last row of `index`'s rendered subtree — `index` itself when it shows no children. */
|
|
21
|
+
subtreeEnd(index: number): number;
|
|
22
|
+
/**
|
|
23
|
+
* Position among the siblings: the rows with the same parent AND the same
|
|
24
|
+
* depth. "3 of 7" means 3 of 7 children, never 3 of 400 visible rows.
|
|
25
|
+
*/
|
|
26
|
+
siblingPosition(index: number): TreeSiblingPosition;
|
|
27
|
+
/** The index of the row with this key, or -1. */
|
|
28
|
+
indexOfKey(key: string): number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* A structural question about a row that does not exist is a caller's bug, not
|
|
32
|
+
* an empty answer: an engine that silently got `-1` back would walk the wrong
|
|
33
|
+
* row instead of failing where the mistake is.
|
|
34
|
+
*/
|
|
35
|
+
export declare function assertRowIndex(source: Pick<TreeRowSource<TreeRowShape>, 'length'>, index: number): void;
|
|
36
|
+
/**
|
|
37
|
+
* The source of an array of rows, in render order. The source keeps its own
|
|
38
|
+
* copy, so a caller that mutates its array afterwards changes nothing here; the
|
|
39
|
+
* parent, subtree-end and sibling tables and the key index are built at once.
|
|
40
|
+
*/
|
|
41
|
+
export declare function treeRowsFrom<TRow extends TreeRowShape>(input: readonly TRow[]): TreeRowSource<TRow>;
|
|
@@ -1,5 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* "Select All" in a tree — the reference's `list.selectAll` on a tree (`listCommands.ts`), over the row source.
|
|
3
|
+
*
|
|
4
|
+
* The reference does not select the whole tree. It selects the row's SCOPE: every visible row under the parent of the
|
|
5
|
+
* row the user is on (the cursor, or the first selected row when the cursor is part of the selection). A press that
|
|
6
|
+
* finds the scope already selected climbs one level — the scope row joins the selection, and the next press starts
|
|
7
|
+
* from it, so repeated presses widen the selection out to the whole tree.
|
|
8
|
+
*
|
|
9
|
+
* Two rules ride on top, because the engine enforces them on every other selection path:
|
|
10
|
+
* - furniture (`selectable: false`: headers, "Loading…", a grouping folder) is never selected. A scope row that is
|
|
11
|
+
* furniture cannot join the selection, so that press climbs straight past it;
|
|
12
|
+
* - the kind lock: one kind only, so a tree's "drop 5 tables" cannot sweep in a view. The kind is the starting
|
|
13
|
+
* row's, or — when the starting row is furniture — the next selectable row's.
|
|
14
|
+
*
|
|
15
|
+
* The reference compares selection LENGTHS to decide that the scope is already selected; this compares the sets, so
|
|
16
|
+
* three rows picked across folders do not count as "this folder is selected".
|
|
17
|
+
*/
|
|
18
|
+
import type { TreeRowSource } from './rowSource.cjs';
|
|
1
19
|
import type { TreeRow } from './types.cjs';
|
|
2
|
-
/** What the rule reads of a row — a tree row, or a list's own row with its depth (
|
|
20
|
+
/** What the rule reads of a row — a tree row, or a list's own row with its depth (wrapped with `treeRowsFrom`). */
|
|
3
21
|
export type SelectAllRow = Pick<TreeRow, 'key' | 'depth' | 'kind' | 'selectable'>;
|
|
4
22
|
/** The new selection, in row order — a climbed scope row first, as the reference puts it. */
|
|
5
|
-
export declare function selectAllInScope(rows:
|
|
23
|
+
export declare function selectAllInScope(rows: TreeRowSource<SelectAllRow>, cursor: number, selection: Iterable<string>): string[];
|
|
@@ -1,5 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* "Select All" in a tree — the reference's `list.selectAll` on a tree (`listCommands.ts`), over the row source.
|
|
3
|
+
*
|
|
4
|
+
* The reference does not select the whole tree. It selects the row's SCOPE: every visible row under the parent of the
|
|
5
|
+
* row the user is on (the cursor, or the first selected row when the cursor is part of the selection). A press that
|
|
6
|
+
* finds the scope already selected climbs one level — the scope row joins the selection, and the next press starts
|
|
7
|
+
* from it, so repeated presses widen the selection out to the whole tree.
|
|
8
|
+
*
|
|
9
|
+
* Two rules ride on top, because the engine enforces them on every other selection path:
|
|
10
|
+
* - furniture (`selectable: false`: headers, "Loading…", a grouping folder) is never selected. A scope row that is
|
|
11
|
+
* furniture cannot join the selection, so that press climbs straight past it;
|
|
12
|
+
* - the kind lock: one kind only, so a tree's "drop 5 tables" cannot sweep in a view. The kind is the starting
|
|
13
|
+
* row's, or — when the starting row is furniture — the next selectable row's.
|
|
14
|
+
*
|
|
15
|
+
* The reference compares selection LENGTHS to decide that the scope is already selected; this compares the sets, so
|
|
16
|
+
* three rows picked across folders do not count as "this folder is selected".
|
|
17
|
+
*/
|
|
18
|
+
import type { TreeRowSource } from './rowSource.js';
|
|
1
19
|
import type { TreeRow } from './types.js';
|
|
2
|
-
/** What the rule reads of a row — a tree row, or a list's own row with its depth (
|
|
20
|
+
/** What the rule reads of a row — a tree row, or a list's own row with its depth (wrapped with `treeRowsFrom`). */
|
|
3
21
|
export type SelectAllRow = Pick<TreeRow, 'key' | 'depth' | 'kind' | 'selectable'>;
|
|
4
22
|
/** The new selection, in row order — a climbed scope row first, as the reference puts it. */
|
|
5
|
-
export declare function selectAllInScope(rows:
|
|
23
|
+
export declare function selectAllInScope(rows: TreeRowSource<SelectAllRow>, cursor: number, selection: Iterable<string>): string[];
|
|
@@ -1,6 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sticky ancestor headers — the whole behaviour, as arithmetic.
|
|
3
|
+
*
|
|
4
|
+
* Scrolling down a tree, the chain of ancestors above the first visible row
|
|
5
|
+
* pins itself to the top, so "which folder am I in" survives the scroll
|
|
6
|
+
* position. The chain is live: as a parent's last child scrolls up past the
|
|
7
|
+
* stack, the parent is PUSHED OUT behind the rows above it rather than snapping
|
|
8
|
+
* away — that push is the entire feel of the thing, and §push-out below is where
|
|
9
|
+
* it happens.
|
|
10
|
+
*
|
|
11
|
+
* Nothing here touches Solid or the DOM: the behaviour is a pure function of the
|
|
12
|
+
* row source and the scroll position, tested as one.
|
|
13
|
+
*
|
|
14
|
+
* The reference implementation measures the DOM on every frame. Three facts
|
|
15
|
+
* about these trees delete all of that:
|
|
16
|
+
*
|
|
17
|
+
* 1. `rowHeight` is FIXED and lives in the descriptor, because the virtual
|
|
18
|
+
* window already does arithmetic with it. The top of row `i` is
|
|
19
|
+
* `i × rowHeight` in content space — measured by no one, also past the
|
|
20
|
+
* browser's height limit.
|
|
21
|
+
* 2. Trees do not scroll horizontally, so there is no `scrollLeft` to sync.
|
|
22
|
+
* 3. The row source answers the two structural questions directly — a row's
|
|
23
|
+
* parent (`parentIndex`) and where its subtree ends (`subtreeEnd`) — so the
|
|
24
|
+
* chain costs one step per pinned row, however many rows the tree has.
|
|
25
|
+
*/
|
|
26
|
+
import type { TreeRowSource } from './rowSource.cjs';
|
|
1
27
|
import type { TreeSurfaceRow } from './descriptor.cjs';
|
|
2
28
|
export interface StickyTreeRow<TNode> {
|
|
3
|
-
/** Index into the
|
|
29
|
+
/** Index into the row source — a click on the clone acts on the real row. */
|
|
4
30
|
index: number;
|
|
5
31
|
row: TreeSurfaceRow<TNode>;
|
|
6
32
|
/** Top within the widget, px. While being pushed out it slides UP, behind the row above. */
|
|
@@ -13,10 +39,10 @@ export interface StickyTreeState<TNode> {
|
|
|
13
39
|
}
|
|
14
40
|
/**
|
|
15
41
|
* The sticky stack for a scroll position: which ancestors are pinned, and where
|
|
16
|
-
* each sits inside the widget.
|
|
42
|
+
* each sits inside the widget. `scrollTop` is in content space.
|
|
17
43
|
*/
|
|
18
44
|
export declare function computeStickyTreeState<TNode>(params: {
|
|
19
|
-
rows:
|
|
45
|
+
rows: TreeRowSource<TreeSurfaceRow<TNode>>;
|
|
20
46
|
scrollTop: number;
|
|
21
47
|
rowHeight: number;
|
|
22
48
|
viewportHeight: number;
|
|
@@ -28,6 +54,7 @@ export declare function computeStickyTreeState<TNode>(params: {
|
|
|
28
54
|
*
|
|
29
55
|
* Derived from the TARGET's ancestors, not from the widget currently on screen:
|
|
30
56
|
* scrolling to a row is what CHANGES the widget, so measuring the old one aims
|
|
31
|
-
* at where the stack used to be.
|
|
57
|
+
* at where the stack used to be. The walk stops at `maxCount` ancestors — no
|
|
58
|
+
* more than that can pin.
|
|
32
59
|
*/
|
|
33
|
-
export declare function stickyInsetForIndex<TNode>(rows:
|
|
60
|
+
export declare function stickyInsetForIndex<TNode>(rows: TreeRowSource<TreeSurfaceRow<TNode>>, index: number, rowHeight: number, maxCount: number): number;
|
|
@@ -1,6 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sticky ancestor headers — the whole behaviour, as arithmetic.
|
|
3
|
+
*
|
|
4
|
+
* Scrolling down a tree, the chain of ancestors above the first visible row
|
|
5
|
+
* pins itself to the top, so "which folder am I in" survives the scroll
|
|
6
|
+
* position. The chain is live: as a parent's last child scrolls up past the
|
|
7
|
+
* stack, the parent is PUSHED OUT behind the rows above it rather than snapping
|
|
8
|
+
* away — that push is the entire feel of the thing, and §push-out below is where
|
|
9
|
+
* it happens.
|
|
10
|
+
*
|
|
11
|
+
* Nothing here touches Solid or the DOM: the behaviour is a pure function of the
|
|
12
|
+
* row source and the scroll position, tested as one.
|
|
13
|
+
*
|
|
14
|
+
* The reference implementation measures the DOM on every frame. Three facts
|
|
15
|
+
* about these trees delete all of that:
|
|
16
|
+
*
|
|
17
|
+
* 1. `rowHeight` is FIXED and lives in the descriptor, because the virtual
|
|
18
|
+
* window already does arithmetic with it. The top of row `i` is
|
|
19
|
+
* `i × rowHeight` in content space — measured by no one, also past the
|
|
20
|
+
* browser's height limit.
|
|
21
|
+
* 2. Trees do not scroll horizontally, so there is no `scrollLeft` to sync.
|
|
22
|
+
* 3. The row source answers the two structural questions directly — a row's
|
|
23
|
+
* parent (`parentIndex`) and where its subtree ends (`subtreeEnd`) — so the
|
|
24
|
+
* chain costs one step per pinned row, however many rows the tree has.
|
|
25
|
+
*/
|
|
26
|
+
import type { TreeRowSource } from './rowSource.js';
|
|
1
27
|
import type { TreeSurfaceRow } from './descriptor.js';
|
|
2
28
|
export interface StickyTreeRow<TNode> {
|
|
3
|
-
/** Index into the
|
|
29
|
+
/** Index into the row source — a click on the clone acts on the real row. */
|
|
4
30
|
index: number;
|
|
5
31
|
row: TreeSurfaceRow<TNode>;
|
|
6
32
|
/** Top within the widget, px. While being pushed out it slides UP, behind the row above. */
|
|
@@ -13,10 +39,10 @@ export interface StickyTreeState<TNode> {
|
|
|
13
39
|
}
|
|
14
40
|
/**
|
|
15
41
|
* The sticky stack for a scroll position: which ancestors are pinned, and where
|
|
16
|
-
* each sits inside the widget.
|
|
42
|
+
* each sits inside the widget. `scrollTop` is in content space.
|
|
17
43
|
*/
|
|
18
44
|
export declare function computeStickyTreeState<TNode>(params: {
|
|
19
|
-
rows:
|
|
45
|
+
rows: TreeRowSource<TreeSurfaceRow<TNode>>;
|
|
20
46
|
scrollTop: number;
|
|
21
47
|
rowHeight: number;
|
|
22
48
|
viewportHeight: number;
|
|
@@ -28,6 +54,7 @@ export declare function computeStickyTreeState<TNode>(params: {
|
|
|
28
54
|
*
|
|
29
55
|
* Derived from the TARGET's ancestors, not from the widget currently on screen:
|
|
30
56
|
* scrolling to a row is what CHANGES the widget, so measuring the old one aims
|
|
31
|
-
* at where the stack used to be.
|
|
57
|
+
* at where the stack used to be. The walk stops at `maxCount` ancestors — no
|
|
58
|
+
* more than that can pin.
|
|
32
59
|
*/
|
|
33
|
-
export declare function stickyInsetForIndex<TNode>(rows:
|
|
60
|
+
export declare function stickyInsetForIndex<TNode>(rows: TreeRowSource<TreeSurfaceRow<TNode>>, index: number, rowHeight: number, maxCount: number): number;
|