@ac-kit/ui-common 0.0.0-stage → 0.2.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 +244 -0
- package/LICENSE +28 -0
- package/README.md +633 -2
- package/dist/anchored/anchored.d.ts +19 -0
- package/dist/anchored/anchored.d.ts.map +1 -0
- package/dist/anchored/anchored.js +2 -0
- package/dist/anchored/anchored.js.map +1 -0
- package/dist/button/button.d.ts +35 -0
- package/dist/button/button.d.ts.map +1 -0
- package/dist/button/button.js +22 -0
- package/dist/button/button.js.map +1 -0
- package/dist/dialog/dialog.d.ts +33 -0
- package/dist/dialog/dialog.d.ts.map +1 -0
- package/dist/dialog/dialog.js +23 -0
- package/dist/dialog/dialog.js.map +1 -0
- package/dist/focus/owns-arrow-keys.d.ts +31 -0
- package/dist/focus/owns-arrow-keys.d.ts.map +1 -0
- package/dist/focus/owns-arrow-keys.js +64 -0
- package/dist/focus/owns-arrow-keys.js.map +1 -0
- package/dist/focus/roving-focus.d.ts +34 -0
- package/dist/focus/roving-focus.d.ts.map +1 -0
- package/dist/focus/roving-focus.js +72 -0
- package/dist/focus/roving-focus.js.map +1 -0
- package/dist/focus/typeahead.d.ts +112 -0
- package/dist/focus/typeahead.d.ts.map +1 -0
- package/dist/focus/typeahead.js +178 -0
- package/dist/focus/typeahead.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/knob/knob.d.ts +106 -0
- package/dist/knob/knob.d.ts.map +1 -0
- package/dist/knob/knob.js +116 -0
- package/dist/knob/knob.js.map +1 -0
- package/dist/menu/menu.d.ts +157 -0
- package/dist/menu/menu.d.ts.map +1 -0
- package/dist/menu/menu.js +162 -0
- package/dist/menu/menu.js.map +1 -0
- package/dist/meter/meter.d.ts +63 -0
- package/dist/meter/meter.d.ts.map +1 -0
- package/dist/meter/meter.js +57 -0
- package/dist/meter/meter.js.map +1 -0
- package/dist/preact/_anchor.d.ts +13 -0
- package/dist/preact/_anchor.d.ts.map +1 -0
- package/dist/preact/_anchor.js +39 -0
- package/dist/preact/_anchor.js.map +1 -0
- package/dist/preact/_dom.d.ts +14 -0
- package/dist/preact/_dom.d.ts.map +1 -0
- package/dist/preact/_dom.js +31 -0
- package/dist/preact/_dom.js.map +1 -0
- package/dist/preact/_live-announcer.d.ts +26 -0
- package/dist/preact/_live-announcer.d.ts.map +1 -0
- package/dist/preact/_live-announcer.js +101 -0
- package/dist/preact/_live-announcer.js.map +1 -0
- package/dist/preact/button.d.ts +40 -0
- package/dist/preact/button.d.ts.map +1 -0
- package/dist/preact/button.js +22 -0
- package/dist/preact/button.js.map +1 -0
- package/dist/preact/dialog.d.ts +43 -0
- package/dist/preact/dialog.d.ts.map +1 -0
- package/dist/preact/dialog.js +89 -0
- package/dist/preact/dialog.js.map +1 -0
- package/dist/preact/index.d.ts +20 -0
- package/dist/preact/index.d.ts.map +1 -0
- package/dist/preact/index.js +20 -0
- package/dist/preact/index.js.map +1 -0
- package/dist/preact/join-classes.d.ts +10 -0
- package/dist/preact/join-classes.d.ts.map +1 -0
- package/dist/preact/join-classes.js +12 -0
- package/dist/preact/join-classes.js.map +1 -0
- package/dist/preact/knob.d.ts +51 -0
- package/dist/preact/knob.d.ts.map +1 -0
- package/dist/preact/knob.js +144 -0
- package/dist/preact/knob.js.map +1 -0
- package/dist/preact/menu-button.d.ts +117 -0
- package/dist/preact/menu-button.d.ts.map +1 -0
- package/dist/preact/menu-button.js +330 -0
- package/dist/preact/menu-button.js.map +1 -0
- package/dist/preact/meter.d.ts +34 -0
- package/dist/preact/meter.d.ts.map +1 -0
- package/dist/preact/meter.js +21 -0
- package/dist/preact/meter.js.map +1 -0
- package/dist/preact/progress-ring.d.ts +42 -0
- package/dist/preact/progress-ring.d.ts.map +1 -0
- package/dist/preact/progress-ring.js +26 -0
- package/dist/preact/progress-ring.js.map +1 -0
- package/dist/preact/radio-group.d.ts +50 -0
- package/dist/preact/radio-group.d.ts.map +1 -0
- package/dist/preact/radio-group.js +42 -0
- package/dist/preact/radio-group.js.map +1 -0
- package/dist/preact/readout.d.ts +22 -0
- package/dist/preact/readout.d.ts.map +1 -0
- package/dist/preact/readout.js +13 -0
- package/dist/preact/readout.js.map +1 -0
- package/dist/preact/slider.d.ts +40 -0
- package/dist/preact/slider.d.ts.map +1 -0
- package/dist/preact/slider.js +164 -0
- package/dist/preact/slider.js.map +1 -0
- package/dist/preact/spin-button.d.ts +67 -0
- package/dist/preact/spin-button.d.ts.map +1 -0
- package/dist/preact/spin-button.js +132 -0
- package/dist/preact/spin-button.js.map +1 -0
- package/dist/preact/switch.d.ts +25 -0
- package/dist/preact/switch.d.ts.map +1 -0
- package/dist/preact/switch.js +19 -0
- package/dist/preact/switch.js.map +1 -0
- package/dist/preact/tabs.d.ts +97 -0
- package/dist/preact/tabs.d.ts.map +1 -0
- package/dist/preact/tabs.js +264 -0
- package/dist/preact/tabs.js.map +1 -0
- package/dist/preact/toaster.d.ts +43 -0
- package/dist/preact/toaster.d.ts.map +1 -0
- package/dist/preact/toaster.js +356 -0
- package/dist/preact/toaster.js.map +1 -0
- package/dist/preact/toggle-button.d.ts +26 -0
- package/dist/preact/toggle-button.d.ts.map +1 -0
- package/dist/preact/toggle-button.js +16 -0
- package/dist/preact/toggle-button.js.map +1 -0
- package/dist/preact/toolbar.d.ts +24 -0
- package/dist/preact/toolbar.d.ts.map +1 -0
- package/dist/preact/toolbar.js +142 -0
- package/dist/preact/toolbar.js.map +1 -0
- package/dist/preact/tooltip.d.ts +67 -0
- package/dist/preact/tooltip.d.ts.map +1 -0
- package/dist/preact/tooltip.js +165 -0
- package/dist/preact/tooltip.js.map +1 -0
- package/dist/preact/tree.d.ts +93 -0
- package/dist/preact/tree.d.ts.map +1 -0
- package/dist/preact/tree.js +399 -0
- package/dist/preact/tree.js.map +1 -0
- package/dist/preact/use-element-binding.d.ts +32 -0
- package/dist/preact/use-element-binding.d.ts.map +1 -0
- package/dist/preact/use-element-binding.js +51 -0
- package/dist/preact/use-element-binding.js.map +1 -0
- package/dist/progress/progress.d.ts +51 -0
- package/dist/progress/progress.d.ts.map +1 -0
- package/dist/progress/progress.js +43 -0
- package/dist/progress/progress.js.map +1 -0
- package/dist/readout/readout.d.ts +41 -0
- package/dist/readout/readout.d.ts.map +1 -0
- package/dist/readout/readout.js +26 -0
- package/dist/readout/readout.js.map +1 -0
- package/dist/slider/_clamped-value.d.ts +7 -0
- package/dist/slider/_clamped-value.d.ts.map +1 -0
- package/dist/slider/_clamped-value.js +9 -0
- package/dist/slider/_clamped-value.js.map +1 -0
- package/dist/slider/slider-attributes.d.ts +50 -0
- package/dist/slider/slider-attributes.d.ts.map +1 -0
- package/dist/slider/slider-attributes.js +38 -0
- package/dist/slider/slider-attributes.js.map +1 -0
- package/dist/slider/slider-range.d.ts +59 -0
- package/dist/slider/slider-range.d.ts.map +1 -0
- package/dist/slider/slider-range.js +73 -0
- package/dist/slider/slider-range.js.map +1 -0
- package/dist/slider/slider-track.d.ts +37 -0
- package/dist/slider/slider-track.d.ts.map +1 -0
- package/dist/slider/slider-track.js +35 -0
- package/dist/slider/slider-track.js.map +1 -0
- package/dist/slider/stepped-value.d.ts +31 -0
- package/dist/slider/stepped-value.d.ts.map +1 -0
- package/dist/slider/stepped-value.js +55 -0
- package/dist/slider/stepped-value.js.map +1 -0
- package/dist/spin-button/spin-button.d.ts +110 -0
- package/dist/spin-button/spin-button.d.ts.map +1 -0
- package/dist/spin-button/spin-button.js +179 -0
- package/dist/spin-button/spin-button.js.map +1 -0
- package/dist/switch/switch.d.ts +30 -0
- package/dist/switch/switch.d.ts.map +1 -0
- package/dist/switch/switch.js +26 -0
- package/dist/switch/switch.js.map +1 -0
- package/dist/tabs/tabs.d.ts +157 -0
- package/dist/tabs/tabs.d.ts.map +1 -0
- package/dist/tabs/tabs.js +120 -0
- package/dist/tabs/tabs.js.map +1 -0
- package/dist/toast/toast-queue.d.ts +212 -0
- package/dist/toast/toast-queue.d.ts.map +1 -0
- package/dist/toast/toast-queue.js +290 -0
- package/dist/toast/toast-queue.js.map +1 -0
- package/dist/toast/toasts-obscure.d.ts +25 -0
- package/dist/toast/toasts-obscure.d.ts.map +1 -0
- package/dist/toast/toasts-obscure.js +30 -0
- package/dist/toast/toasts-obscure.js.map +1 -0
- package/dist/toggle-button/toggle-button.d.ts +44 -0
- package/dist/toggle-button/toggle-button.d.ts.map +1 -0
- package/dist/toggle-button/toggle-button.js +31 -0
- package/dist/toggle-button/toggle-button.js.map +1 -0
- package/dist/tone.d.ts +8 -0
- package/dist/tone.d.ts.map +1 -0
- package/dist/tone.js +2 -0
- package/dist/tone.js.map +1 -0
- package/dist/toolbar/toolbar.d.ts +35 -0
- package/dist/toolbar/toolbar.d.ts.map +1 -0
- package/dist/toolbar/toolbar.js +23 -0
- package/dist/toolbar/toolbar.js.map +1 -0
- package/dist/tooltip/tooltip.d.ts +183 -0
- package/dist/tooltip/tooltip.d.ts.map +1 -0
- package/dist/tooltip/tooltip.js +185 -0
- package/dist/tooltip/tooltip.js.map +1 -0
- package/dist/tree/tree.d.ts +302 -0
- package/dist/tree/tree.d.ts.map +1 -0
- package/dist/tree/tree.js +439 -0
- package/dist/tree/tree.js.map +1 -0
- package/package.json +110 -3
- package/styles.css +1883 -0
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import { type Predicate } from "@ac-kit/core";
|
|
2
|
+
import type { KeyInput } from "@ac-kit/ui-gesture";
|
|
3
|
+
/**
|
|
4
|
+
* A tree's shape, as a tree view reads it: its roots, each node's children, and
|
|
5
|
+
* which nodes are branches. Nodes are compared by identity, so a node appears
|
|
6
|
+
* once.
|
|
7
|
+
*/
|
|
8
|
+
export type TreeSource<Node> = {
|
|
9
|
+
readonly roots: readonly Node[];
|
|
10
|
+
/**
|
|
11
|
+
* A branch's children; `undefined` for a leaf, or for a branch whose children
|
|
12
|
+
* are not loaded yet (a lazy tree loads them once the branch is expanded).
|
|
13
|
+
*/
|
|
14
|
+
readonly childrenOf: (node: Node) => readonly Node[] | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Whether a node is a branch, that can be expanded. Defaults to having at
|
|
17
|
+
* least one child: give it for a lazy tree, whose unloaded branches have no
|
|
18
|
+
* children yet.
|
|
19
|
+
*/
|
|
20
|
+
readonly isBranch?: Predicate<[node: Node]>;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* The rows a tree view shows: every root, and the children of each expanded
|
|
24
|
+
* branch, in document order, with what WAI-ARIA states of each (`aria-level`,
|
|
25
|
+
* `aria-posinset`, `aria-setsize`, `aria-expanded`). Indices are row numbers,
|
|
26
|
+
* from 0.
|
|
27
|
+
*/
|
|
28
|
+
export type TreeRows<Node> = {
|
|
29
|
+
readonly count: number;
|
|
30
|
+
nodeAt(index: number): Node;
|
|
31
|
+
/** From 1 for a root, as `aria-level`. */
|
|
32
|
+
levelAt(index: number): number;
|
|
33
|
+
/** From 1 among its siblings, as `aria-posinset`. */
|
|
34
|
+
positionAt(index: number): number;
|
|
35
|
+
/** How many siblings it has, itself included, as `aria-setsize`. */
|
|
36
|
+
setSizeAt(index: number): number;
|
|
37
|
+
/** The row of its parent; -1 for a root. */
|
|
38
|
+
parentAt(index: number): number;
|
|
39
|
+
isBranchAt(index: number): boolean;
|
|
40
|
+
isExpandedAt(index: number): boolean;
|
|
41
|
+
/** An expanded branch whose children are not loaded yet. */
|
|
42
|
+
isLoadingAt(index: number): boolean;
|
|
43
|
+
/** The row showing `node`; -1 when it is not shown. O(1). */
|
|
44
|
+
indexOf(node: Node): number;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* The rows of a tree view: {@link TreeRows}. A branch shows its children while
|
|
48
|
+
* `isExpanded` holds for it; an expanded branch whose children are `undefined`
|
|
49
|
+
* shows as loading. The walk is iterative (`@ac-kit/algo`'s `walkTree`), so a
|
|
50
|
+
* deep tree cannot overflow the stack, and it reads only what is shown:
|
|
51
|
+
* `childrenOf` is called for the expanded branches and, without `isBranch`, for
|
|
52
|
+
* every row.
|
|
53
|
+
*
|
|
54
|
+
* Time complexity: O(r) for r rows shown. Memory: O(r).
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* const source = {
|
|
58
|
+
* roots: [root],
|
|
59
|
+
* childrenOf: (node) => node.children,
|
|
60
|
+
* };
|
|
61
|
+
* const rows = visibleTreeRows(source, (node) => expanded.has(node));
|
|
62
|
+
* rows.levelAt(0); // 1
|
|
63
|
+
*
|
|
64
|
+
* @throws {Error} When a node is shown twice: the tree is not a tree (a node
|
|
65
|
+
* with two parents, or a cycle through an expanded branch).
|
|
66
|
+
*/
|
|
67
|
+
export declare function visibleTreeRows<Node>(source: TreeSource<Node>, isExpanded: Predicate<[node: Node]>): TreeRows<Node>;
|
|
68
|
+
/**
|
|
69
|
+
* The nodes from a root down to the node of row `index`, that row's included:
|
|
70
|
+
* what a tree view keeps of its focused row, to find the nearest one still
|
|
71
|
+
* shown once its branch closes ({@link treeTabStop}).
|
|
72
|
+
*
|
|
73
|
+
* Time complexity: O(depth). Memory: O(depth).
|
|
74
|
+
*
|
|
75
|
+
* @throws {RangeError} When `index` is not a row of `rows`.
|
|
76
|
+
*/
|
|
77
|
+
export declare function treePath<Node>(rows: TreeRows<Node>, index: number): Node[];
|
|
78
|
+
/**
|
|
79
|
+
* The row that holds a tree view's tab stop: the deepest node of `focusedPath`
|
|
80
|
+
* still shown (the focused row, or its nearest ancestor once a branch around it
|
|
81
|
+
* closed); before anything was focused (`focusedPath` empty), or when none of
|
|
82
|
+
* it is shown any more, the first row selected, else the first row, as the
|
|
83
|
+
* WAI-ARIA tree view pattern sets. -1 for no rows.
|
|
84
|
+
*
|
|
85
|
+
* Time complexity: O(p + s), p nodes in the path and s selected. Memory: O(1).
|
|
86
|
+
*/
|
|
87
|
+
export declare function treeTabStop<Node>(rows: TreeRows<Node>, focusedPath: readonly Node[], selected: ReadonlySet<Node>): number;
|
|
88
|
+
/**
|
|
89
|
+
* How a tree view lets nodes be selected: one at a time, several, or none (a
|
|
90
|
+
* navigation tree, whose nodes are only activated).
|
|
91
|
+
*/
|
|
92
|
+
export type TreeSelectionMode = "single" | "multiple" | "none";
|
|
93
|
+
/** The attributes of a tree view, keyed by their HTML attribute names. */
|
|
94
|
+
export type TreeAttributes = {
|
|
95
|
+
role: "tree";
|
|
96
|
+
"aria-label"?: string;
|
|
97
|
+
"aria-labelledby"?: string;
|
|
98
|
+
"aria-multiselectable"?: "true";
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Input of {@link treeAttributes}: its accessible name, as text or as the id of
|
|
102
|
+
* the element naming it, and how it selects.
|
|
103
|
+
*/
|
|
104
|
+
export type TreeAttributesInput = ({
|
|
105
|
+
label: string;
|
|
106
|
+
labelledBy?: undefined;
|
|
107
|
+
} | {
|
|
108
|
+
label?: undefined;
|
|
109
|
+
labelledBy: string;
|
|
110
|
+
}) & {
|
|
111
|
+
/** Defaults to `single`. */
|
|
112
|
+
selectionMode?: TreeSelectionMode;
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* The attributes of a tree view (WAI-ARIA tree view pattern): the `tree` role,
|
|
116
|
+
* named, multi-selectable when several nodes can be selected.
|
|
117
|
+
*
|
|
118
|
+
* Time complexity: O(1). Memory: O(1).
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* treeAttributes({ labelledBy: "structure", selectionMode: "multiple" });
|
|
122
|
+
* // { role: "tree", "aria-labelledby": "structure",
|
|
123
|
+
* // "aria-multiselectable": "true" }
|
|
124
|
+
*/
|
|
125
|
+
export declare function treeAttributes(input: TreeAttributesInput): TreeAttributes;
|
|
126
|
+
/** The attributes of a tree item, keyed by their HTML attribute names. */
|
|
127
|
+
export type TreeItemAttributes = {
|
|
128
|
+
role: "treeitem";
|
|
129
|
+
"aria-level": number;
|
|
130
|
+
"aria-posinset": number;
|
|
131
|
+
"aria-setsize": number;
|
|
132
|
+
tabindex: 0 | -1;
|
|
133
|
+
"aria-expanded"?: "true" | "false";
|
|
134
|
+
"aria-selected"?: "true" | "false";
|
|
135
|
+
"aria-disabled"?: "true";
|
|
136
|
+
"aria-busy"?: "true";
|
|
137
|
+
};
|
|
138
|
+
/** Input of {@link treeItemAttributes}. */
|
|
139
|
+
export type TreeItemAttributesInput = {
|
|
140
|
+
rows: TreeRows<unknown>;
|
|
141
|
+
index: number;
|
|
142
|
+
/** Defaults to `single`. */
|
|
143
|
+
selectionMode?: TreeSelectionMode;
|
|
144
|
+
isSelected: boolean;
|
|
145
|
+
/** Whether it holds the tree's tab stop ({@link treeTabStop}). */
|
|
146
|
+
isTabStop: boolean;
|
|
147
|
+
isDisabled?: boolean;
|
|
148
|
+
};
|
|
149
|
+
/**
|
|
150
|
+
* The attributes of the tree item of row `index`: its level, position and set
|
|
151
|
+
* size (every row states them, so a tree drawn as one flat list, or only in
|
|
152
|
+
* part, reads as nested), expanded or not for a branch, busy while its children
|
|
153
|
+
* load, and in the tab order only as the tree's tab stop. Selection is stated
|
|
154
|
+
* on every item when several can be selected, and only on the selected one
|
|
155
|
+
* otherwise, so a screen reader does not say "not selected" on each row. A
|
|
156
|
+
* disabled item stays focusable, as the WAI-ARIA practices advise for the items
|
|
157
|
+
* of a composite widget.
|
|
158
|
+
*
|
|
159
|
+
* Time complexity: O(1). Memory: O(1).
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* treeItemAttributes({ rows, index: 0, isSelected: true, isTabStop: true });
|
|
163
|
+
* // { role: "treeitem", "aria-level": 1, "aria-posinset": 1,
|
|
164
|
+
* // "aria-setsize": 1, tabindex: 0, "aria-expanded": "true",
|
|
165
|
+
* // "aria-selected": "true" } for an expanded root branch
|
|
166
|
+
*
|
|
167
|
+
* @throws {RangeError} When `index` is not a row of `rows`.
|
|
168
|
+
*/
|
|
169
|
+
export declare function treeItemAttributes(input: TreeItemAttributesInput): TreeItemAttributes;
|
|
170
|
+
/** Input of {@link treeKeyAction}: the key and the rows around focus. */
|
|
171
|
+
export type TreeKeyInput = KeyInput & {
|
|
172
|
+
/** The focused row. */
|
|
173
|
+
current: number;
|
|
174
|
+
rows: TreeRows<unknown>;
|
|
175
|
+
/** `rtl` swaps Left and Right. Defaults to `ltr`. */
|
|
176
|
+
direction?: "ltr" | "rtl";
|
|
177
|
+
/** Defaults to `single`. */
|
|
178
|
+
selectionMode?: TreeSelectionMode;
|
|
179
|
+
/** Whether a typeahead query is in progress, so Space extends it. */
|
|
180
|
+
isTypingAhead?: boolean;
|
|
181
|
+
};
|
|
182
|
+
/**
|
|
183
|
+
* What a key does in a tree view (WAI-ARIA tree view pattern):
|
|
184
|
+
*
|
|
185
|
+
* - `focus` a row: Arrow Down and Up to the next and previous row, Home and End
|
|
186
|
+
* to the first and last; Arrow Right to a branch's first child once it is
|
|
187
|
+
* expanded, Arrow Left to the parent. At an end, or where a key has nowhere
|
|
188
|
+
* to go, the focused row itself: consume the key, change nothing. `toggles`
|
|
189
|
+
* for Shift Arrow Down and Up when several nodes can be selected: the row
|
|
190
|
+
* reached flips its selection;
|
|
191
|
+
* - `expand` a collapsed branch (Arrow Right), `collapse` an expanded one (Arrow
|
|
192
|
+
* Left);
|
|
193
|
+
* - `expandSiblings`: `*` expands every branch beside the focused row;
|
|
194
|
+
* - `activate` the focused row: Enter (its default action; for a branch with
|
|
195
|
+
* none, expanding or collapsing it);
|
|
196
|
+
* - `select`: Space, the focused row alone in single selection, flipping it in
|
|
197
|
+
* multiple selection;
|
|
198
|
+
* - `selectRange` from the most recently selected row (`"anchor"`) or the focused
|
|
199
|
+
* one to `to`, focus moving to `focus`: Shift Space, and Ctrl Shift Home and
|
|
200
|
+
* End (to the first and last rows);
|
|
201
|
+
* - `selectAll`: Ctrl A, or Cmd A;
|
|
202
|
+
* - `typeahead` a character, Space included while a query is in progress.
|
|
203
|
+
*/
|
|
204
|
+
export type TreeKeyAction = {
|
|
205
|
+
readonly kind: "focus";
|
|
206
|
+
readonly index: number;
|
|
207
|
+
readonly toggles: boolean;
|
|
208
|
+
} | {
|
|
209
|
+
readonly kind: "expand";
|
|
210
|
+
readonly index: number;
|
|
211
|
+
} | {
|
|
212
|
+
readonly kind: "collapse";
|
|
213
|
+
readonly index: number;
|
|
214
|
+
} | {
|
|
215
|
+
readonly kind: "expandSiblings";
|
|
216
|
+
readonly index: number;
|
|
217
|
+
} | {
|
|
218
|
+
readonly kind: "activate";
|
|
219
|
+
readonly index: number;
|
|
220
|
+
} | {
|
|
221
|
+
readonly kind: "select";
|
|
222
|
+
readonly index: number;
|
|
223
|
+
} | {
|
|
224
|
+
readonly kind: "selectRange";
|
|
225
|
+
readonly from: number | "anchor";
|
|
226
|
+
readonly to: number;
|
|
227
|
+
readonly focus: number;
|
|
228
|
+
} | {
|
|
229
|
+
readonly kind: "selectAll";
|
|
230
|
+
} | {
|
|
231
|
+
readonly kind: "typeahead";
|
|
232
|
+
readonly character: string;
|
|
233
|
+
};
|
|
234
|
+
/**
|
|
235
|
+
* The action of a key on a tree view's focused row, {@link TreeKeyAction}.
|
|
236
|
+
* `undefined` for a key the tree does not use, or with a modifier it does not
|
|
237
|
+
* take (Alt always; Ctrl or Cmd outside the selection shortcuts). Disabled
|
|
238
|
+
* nodes take focus like the others, so the caller checks them before activating
|
|
239
|
+
* or selecting one. Right-to-left, Arrow Right and Left swap.
|
|
240
|
+
*
|
|
241
|
+
* Time complexity: O(1). Memory: O(1).
|
|
242
|
+
*
|
|
243
|
+
* @example
|
|
244
|
+
* treeKeyAction({ key: "ArrowRight", current: 0, rows });
|
|
245
|
+
* // { kind: "expand", index: 0 } on a collapsed branch
|
|
246
|
+
*
|
|
247
|
+
* @throws {RangeError} When `current` is not a row of `rows`.
|
|
248
|
+
*/
|
|
249
|
+
export declare function treeKeyAction(input: TreeKeyInput): TreeKeyAction | undefined;
|
|
250
|
+
/**
|
|
251
|
+
* A change to a tree view's selection:
|
|
252
|
+
*
|
|
253
|
+
* - `replace` it with the node of row `index` alone (a click, single selection);
|
|
254
|
+
* - `toggle` that node in or out;
|
|
255
|
+
* - `range`: the nodes of the rows from `from` to `to`, both included, added to
|
|
256
|
+
* the selection (`isAdded`) or replacing it;
|
|
257
|
+
* - `all`: every node, or none when every node is already selected.
|
|
258
|
+
*/
|
|
259
|
+
export type TreeSelectionChange = {
|
|
260
|
+
readonly kind: "replace";
|
|
261
|
+
readonly index: number;
|
|
262
|
+
} | {
|
|
263
|
+
readonly kind: "toggle";
|
|
264
|
+
readonly index: number;
|
|
265
|
+
} | {
|
|
266
|
+
readonly kind: "range";
|
|
267
|
+
readonly from: number;
|
|
268
|
+
readonly to: number;
|
|
269
|
+
readonly isAdded: boolean;
|
|
270
|
+
} | {
|
|
271
|
+
readonly kind: "all";
|
|
272
|
+
};
|
|
273
|
+
/** Context of {@link nextTreeSelection}. */
|
|
274
|
+
export type TreeSelectionContext<Node> = {
|
|
275
|
+
readonly source: TreeSource<Node>;
|
|
276
|
+
readonly rows: TreeRows<Node>;
|
|
277
|
+
/** Nodes never selected. Defaults to none. */
|
|
278
|
+
readonly isDisabled?: Predicate<[node: Node]>;
|
|
279
|
+
};
|
|
280
|
+
/**
|
|
281
|
+
* The selection after `change`: a new set, or `selected` itself when nothing
|
|
282
|
+
* changes, so a caller reports only real changes. Disabled nodes are never
|
|
283
|
+
* added; a range or `all` keeps the disabled nodes already selected. `all`
|
|
284
|
+
* takes every node of the tree whose children are loaded, shown or not.
|
|
285
|
+
*
|
|
286
|
+
* Time complexity: O(s + k), s selected and k nodes the change covers (every
|
|
287
|
+
* loaded node for `all`). Memory: O(s + k).
|
|
288
|
+
*
|
|
289
|
+
* @throws {RangeError} When an index is not a row of `context.rows`.
|
|
290
|
+
*/
|
|
291
|
+
export declare function nextTreeSelection<Node>(selected: ReadonlySet<Node>, change: TreeSelectionChange, context: TreeSelectionContext<Node>): ReadonlySet<Node>;
|
|
292
|
+
/**
|
|
293
|
+
* The expanded set once every branch beside the node of row `index` (its
|
|
294
|
+
* siblings, itself included) is expanded: what `*` does. `expanded` itself when
|
|
295
|
+
* they all already are.
|
|
296
|
+
*
|
|
297
|
+
* Time complexity: O(e + s), e expanded and s siblings. Memory: O(e + s).
|
|
298
|
+
*
|
|
299
|
+
* @throws {RangeError} When `index` is not a row of `rows`.
|
|
300
|
+
*/
|
|
301
|
+
export declare function expandTreeSiblings<Node>(source: TreeSource<Node>, rows: TreeRows<Node>, index: number, expanded: ReadonlySet<Node>): ReadonlySet<Node>;
|
|
302
|
+
//# sourceMappingURL=tree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../../src/tree/tree.ts"],"names":[],"mappings":"AACA,OAAO,EAAmC,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAC/E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAKnD;;;;GAIG;AACH,MAAM,MAAM,UAAU,CAAC,IAAI,IAAI;IAC9B,QAAQ,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,CAAC;IAChC;;;OAGG;IACH,QAAQ,CAAC,UAAU,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,SAAS,IAAI,EAAE,GAAG,SAAS,CAAC;IACjE;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;CAC5C,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,CAAC,IAAI,IAAI;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,0CAA0C;IAC1C,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAC/B,qDAAqD;IACrD,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAClC,oEAAoE;IACpE,SAAS,CAAC,KAAK,EAAE,MAAM,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