nexus-shared 3.1.0 → 3.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 +704 -446
- package/LICENSE +21 -21
- package/README.md +44 -5
- package/dist/Client.Index.d.ts +3 -0
- package/dist/Client.Index.js +3 -0
- package/dist/Components/Forms/Crud.js +322 -161
- package/dist/Components/Forms/CrudHistory.d.ts +66 -0
- package/dist/Components/Forms/CrudHistory.js +140 -0
- package/dist/Components/Forms/CrudParts.js +2 -1
- package/dist/Components/Forms/Form.js +4 -1
- package/dist/Components/Inputs/CodeBox.d.ts +69 -0
- package/dist/Components/Inputs/CodeBox.js +316 -0
- package/dist/Components/Inputs/DatePicker.js +4 -1
- package/dist/Components/Inputs/DateRangePicker.js +4 -1
- package/dist/Components/Inputs/DateTimePicker.js +4 -1
- package/dist/Components/Inputs/Dropdown.js +4 -1
- package/dist/Components/Inputs/InputRenderer.js +3 -0
- package/dist/Components/Inputs/NumberBox.js +4 -2
- package/dist/Components/Inputs/TextArea.js +4 -1
- package/dist/Components/Inputs/TextBox.js +4 -1
- package/dist/Components/Inputs/TimePicker.js +4 -1
- package/dist/Components/Inputs/TreeView.d.ts +55 -5
- package/dist/Components/Inputs/TreeView.js +372 -23
- package/dist/Components/Layouts/ThemePicker.d.ts +3 -2
- package/dist/Components/Layouts/ThemePicker.js +16 -4
- package/dist/Components/Viewers/DataTable.js +63 -21
- package/dist/Components/Viewers/DataTableParts.d.ts +26 -8
- package/dist/Components/Viewers/DataTableParts.js +39 -10
- package/dist/Helpers/ApiModules.d.ts +3 -34
- package/dist/Helpers/ApiModules.js +3 -3
- package/dist/Helpers/ApiRoutes.d.ts +68 -26
- package/dist/Helpers/ApiRoutes.js +31 -27
- package/dist/Helpers/ArrayHelpers.d.ts +0 -0
- package/dist/Helpers/ArrayHelpers.js +2 -0
- package/dist/Helpers/CodeHelpers.d.ts +97 -0
- package/dist/Helpers/CodeHelpers.js +332 -0
- package/dist/Helpers/CrudBackend.d.ts +94 -4
- package/dist/Helpers/CrudBackend.js +168 -9
- package/dist/Helpers/CrudColumns.d.ts +51 -0
- package/dist/Helpers/CrudColumns.js +69 -0
- package/dist/Helpers/CrudHelpers.d.ts +50 -5
- package/dist/Helpers/CrudHelpers.js +109 -12
- package/dist/Helpers/InputParamsHelpers.js +8 -0
- package/dist/Helpers/MessageBuilder.js +2 -0
- package/dist/Helpers/NexusHelpers.d.ts +0 -0
- package/dist/Helpers/NexusHelpers.js +1 -0
- package/dist/Helpers/RequestCache.d.ts +35 -0
- package/dist/Helpers/RequestCache.js +113 -0
- package/dist/Helpers/TableExport.js +12 -12
- package/dist/Helpers/TableHelpers.d.ts +1 -1
- package/dist/Helpers/TableHelpers.js +7 -2
- package/dist/Helpers/TableJoins.d.ts +70 -0
- package/dist/Helpers/TableJoins.js +250 -0
- package/dist/Helpers/TableStore.d.ts +5 -0
- package/dist/Helpers/TableStore.js +9 -0
- package/dist/Helpers/TreeStore.d.ts +225 -11
- package/dist/Helpers/TreeStore.js +683 -90
- package/dist/Helpers/UserPreferences.d.ts +8 -0
- package/dist/Helpers/UserPreferences.js +17 -0
- package/dist/Interfaces/CrudInterfaces.d.ts +47 -9
- package/dist/Interfaces/FormInterfaces.d.ts +4 -1
- package/dist/Interfaces/InputInterfaces.d.ts +24 -0
- package/dist/Interfaces/MessageInterfaces.d.ts +1 -1
- package/dist/Interfaces/PreferenceInterfaces.d.ts +8 -0
- package/dist/Interfaces/PreferenceInterfaces.js +2 -5
- package/dist/Interfaces/TableInterfaces.d.ts +86 -4
- package/dist/Services/ApiProxy.d.ts +36 -1
- package/dist/Services/ApiProxy.js +182 -52
- package/dist/Services/ApiProxyRules.d.ts +203 -0
- package/dist/Services/ApiProxyRules.js +426 -0
- package/dist/Services/JoinSources.d.ts +48 -0
- package/dist/Services/JoinSources.js +74 -0
- package/dist/Services/ServerApi.d.ts +13 -2
- package/dist/Services/ServerApi.js +8 -3
- package/dist/Shared.Index.d.ts +4 -0
- package/dist/Shared.Index.js +4 -0
- package/package.json +87 -85
- package/src/Styles/Nexus.Avatar.css +79 -79
- package/src/Styles/Nexus.Base.css +117 -117
- package/src/Styles/Nexus.Button.css +180 -180
- package/src/Styles/Nexus.Calendar.css +273 -273
- package/src/Styles/Nexus.Chat.css +1443 -1443
- package/src/Styles/Nexus.Choice.css +343 -343
- package/src/Styles/Nexus.Crud.css +168 -168
- package/src/Styles/Nexus.DateTime.css +81 -81
- package/src/Styles/Nexus.Dropdown.css +725 -725
- package/src/Styles/Nexus.Editor.css +295 -295
- package/src/Styles/Nexus.Excel.css +389 -389
- package/src/Styles/Nexus.Form.css +279 -279
- package/src/Styles/Nexus.Index.css +37 -37
- package/src/Styles/Nexus.Input.css +196 -4
- package/src/Styles/Nexus.Markdown.css +237 -237
- package/src/Styles/Nexus.Menu.css +237 -237
- package/src/Styles/Nexus.Popup.css +724 -724
- package/src/Styles/Nexus.Rows.css +637 -637
- package/src/Styles/Nexus.Slider.css +276 -276
- package/src/Styles/Nexus.Tab.Buttons.css +432 -432
- package/src/Styles/Nexus.Table.css +31 -30
- package/src/Styles/Nexus.Theme.Picker.css +59 -3
- package/src/Styles/Nexus.Themes.css +194 -194
- package/src/Styles/Nexus.Time.css +144 -144
- package/src/Styles/Nexus.Toast.css +263 -263
- package/src/Styles/Nexus.Tokens.css +89 -89
- package/src/Styles/Nexus.Tree.css +500 -431
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { RequestCache } from "./RequestCache.ts";
|
|
1
2
|
export type TreeValue = string | number;
|
|
2
3
|
/** An item of a tree: any object with a value, a parent value, and a label under the keys the tree is given. */
|
|
3
4
|
export type TreeItem = object;
|
|
@@ -25,9 +26,79 @@ export interface TreeStoreOptions<TItem extends TreeItem = TreeItem> {
|
|
|
25
26
|
cascade?: boolean;
|
|
26
27
|
/** Default `leaves`. Ignored without `cascade`, where the value is every checked item. */
|
|
27
28
|
valueMode?: TreeValueMode;
|
|
29
|
+
/**
|
|
30
|
+
* Children come later, a page at a time: a node with none loaded yet can be expanded, and `rows` shows its loading,
|
|
31
|
+
* failed, or Load more state. A node whose children come in the items counts as loaded. Default false.
|
|
32
|
+
*/
|
|
33
|
+
lazy?: boolean;
|
|
34
|
+
/** With `lazy`: the top level comes from the loader too, and the items given (if any) are only a start. Default false. */
|
|
35
|
+
lazyRoots?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* With `lazy`: the item field saying whether it has children before they are loaded - a boolean, or a count (more
|
|
38
|
+
* than 0). Without it, or when the field is empty, a node counts as having children until its first page answers.
|
|
39
|
+
*/
|
|
40
|
+
hasChildrenKey?: string;
|
|
41
|
+
}
|
|
42
|
+
/** A row that is not an item, under a parent of a lazy tree: its page is on its way, failed (Retry), or more can be loaded. */
|
|
43
|
+
export type TreeStatusKind = "loading" | "error" | "more";
|
|
44
|
+
/** Where a lazy parent's children stand: what was asked of the loader, and what it said. */
|
|
45
|
+
export interface TreeChildPages {
|
|
46
|
+
/** `idle`: nothing asked yet; `loading`: a page is on its way; `failed`: the last page failed; `ready`: answered. */
|
|
47
|
+
status: "idle" | "loading" | "failed" | "ready";
|
|
48
|
+
/** Children the loader gave so far, as it counted them: the next page skips this many. */
|
|
49
|
+
loaded: number;
|
|
50
|
+
/** All of the parent's children on the server, when the loader said. */
|
|
51
|
+
total?: number;
|
|
52
|
+
/** Whether another page follows. */
|
|
53
|
+
hasMore: boolean;
|
|
54
|
+
/** A refresh made the pages old: they are drawn until fresh ones replace them. */
|
|
55
|
+
stale: boolean;
|
|
56
|
+
/** The request now current; an answer to an older one is ignored. */
|
|
57
|
+
request: number;
|
|
58
|
+
}
|
|
59
|
+
/** What a lazy tree's loader is asked for: one page of a parent's children. */
|
|
60
|
+
export interface TreeChildrenRequest<TItem extends TreeItem = TreeItem> {
|
|
61
|
+
/** The item whose children to load, or `null` for the top level. */
|
|
62
|
+
parent: TItem | null;
|
|
63
|
+
/** Its value, or `null` for the top level. */
|
|
64
|
+
parentValue: TreeValue | null;
|
|
65
|
+
/** Children already loaded: the page starts after them (an API's skip count). */
|
|
66
|
+
skip: number;
|
|
67
|
+
/** The most to return: the page size (an API's max count). */
|
|
68
|
+
take: number;
|
|
69
|
+
/** Aborted when the tree unmounts before the answer, unless a `cacheKey` keeps the answer for the next tree. */
|
|
70
|
+
signal: AbortSignal;
|
|
28
71
|
}
|
|
72
|
+
/** One page of children, as the loader answers it. */
|
|
73
|
+
export interface TreeChildrenPage<TItem extends TreeItem = TreeItem> {
|
|
74
|
+
/** The children, in order. Their parent field is not read: they go under the parent that was asked for. */
|
|
75
|
+
items: readonly TItem[];
|
|
76
|
+
/** All of the parent's children on the server: Load more says how many are left. */
|
|
77
|
+
total?: number;
|
|
78
|
+
/** Whether another page follows. Default: `total` says so, or the page was full. */
|
|
79
|
+
hasMore?: boolean;
|
|
80
|
+
}
|
|
81
|
+
/** Children's pages kept for every lazy tree on the page that names a `cacheKey`, for 5 minutes: see `RequestCache`. */
|
|
82
|
+
export declare const treePages: RequestCache<TreeChildrenPage<object>>;
|
|
83
|
+
/** The start of every key a tree keeps its pages under, or one parent's pages (`null`: the top level). */
|
|
84
|
+
export declare function treePagesKey(cacheKey: string, parent?: TreeValue | null): string;
|
|
85
|
+
/** The key one page is kept under. */
|
|
86
|
+
export declare function treePageKey(cacheKey: string, parent: TreeValue | null, skip: number, take: number): string;
|
|
87
|
+
/**
|
|
88
|
+
* Drops the kept pages of a tree's source - all of them, one parent's (`null`: the top level), or several parents' -
|
|
89
|
+
* after the records behind them changed elsewhere. Returns how many were dropped. A tree on screen keeps what it shows:
|
|
90
|
+
* its `refresh()` loads that again.
|
|
91
|
+
*/
|
|
92
|
+
export declare function expireTreePages(cacheKey: string, parent?: TreeValue | null | readonly (TreeValue | null)[]): number;
|
|
93
|
+
/** A has-children field read as the tree reads it: a boolean, or a count above 0; `undefined` when it says nothing. */
|
|
94
|
+
export declare function treeHasChildren(value: unknown): boolean | undefined;
|
|
95
|
+
/** The key of the status row under a parent (`null`: the top level), as `TreeNode.key` holds it. */
|
|
96
|
+
export declare function treeStatusKey(parentKey: string | null): string;
|
|
29
97
|
export interface TreeNode<TItem extends TreeItem = TreeItem> {
|
|
30
|
-
/**
|
|
98
|
+
/**
|
|
99
|
+
* A number unique to this node in its store for its whole life, for React keys and element ids. Counted per store,
|
|
100
|
+
* so a tree rendered on the server numbers its rows as the browser does.
|
|
101
|
+
*/
|
|
31
102
|
readonly uid: number;
|
|
32
103
|
/** The value as text: the key in maps, so `7` and `"7"` are the same item. */
|
|
33
104
|
key: string;
|
|
@@ -59,6 +130,19 @@ export interface TreeNode<TItem extends TreeItem = TreeItem> {
|
|
|
59
130
|
openChecked: number;
|
|
60
131
|
/** Being created and not saved yet: not part of the value or the items. */
|
|
61
132
|
draft: boolean;
|
|
133
|
+
/** With `lazy`: where its children's pages stand. */
|
|
134
|
+
pages?: TreeChildPages;
|
|
135
|
+
/**
|
|
136
|
+
* With `lazy`: not everything under it is loaded yet - its own pages, or a node's under it. With `cascade` such a node
|
|
137
|
+
* cannot be checked or unchecked as a whole (see `TreeStore.toggle`), and never shows checked unless the value names it.
|
|
138
|
+
*/
|
|
139
|
+
partial: boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Set only on a status row, a row that is not an item: under its `parent` (`null`: the top level) a page is on its
|
|
142
|
+
* way, failed, or more can be loaded. A status row is in `rows` only - never in `children`, the value, or the items -
|
|
143
|
+
* and its `item` is an empty object.
|
|
144
|
+
*/
|
|
145
|
+
status?: TreeStatusKind;
|
|
62
146
|
}
|
|
63
147
|
/** What expanding or collapsing did to the visible rows, for an animation. */
|
|
64
148
|
export interface TreeRowsChange<TItem extends TreeItem = TreeItem> {
|
|
@@ -86,12 +170,31 @@ export declare class TreeStore<TItem extends TreeItem = TreeItem> {
|
|
|
86
170
|
readonly labelKey: string;
|
|
87
171
|
readonly cascade: boolean;
|
|
88
172
|
readonly valueMode: TreeValueMode;
|
|
173
|
+
/** Children come a page at a time from a loader. */
|
|
174
|
+
readonly lazy: boolean;
|
|
175
|
+
private readonly hasChildrenKey;
|
|
89
176
|
private readonly isDisabled;
|
|
90
177
|
private readonly isChecked;
|
|
91
178
|
roots: TreeNode<TItem>[];
|
|
92
|
-
/**
|
|
179
|
+
/**
|
|
180
|
+
* The visible rows in order: top-level items, and the children of every expanded item whose parents are expanded,
|
|
181
|
+
* with a lazy parent's status row after its children. A new array after each change.
|
|
182
|
+
*/
|
|
93
183
|
rows: readonly TreeNode<TItem>[];
|
|
184
|
+
/** With `lazyRoots`: where the top level's pages stand. `null` when the top level comes from the items. */
|
|
185
|
+
rootPages: TreeChildPages | null;
|
|
94
186
|
private byKey;
|
|
187
|
+
/** The status row of each lazy parent that has had one, by the parent's key ("" for the top level). */
|
|
188
|
+
private statusRows;
|
|
189
|
+
/**
|
|
190
|
+
* With `lazy`: checked values whose items are not loaded yet, or not settled (see `settle`). They stay in the value,
|
|
191
|
+
* and check their items when the items come, so a saved value is never lost to a page not opened yet.
|
|
192
|
+
*/
|
|
193
|
+
private pending;
|
|
194
|
+
/** Whether the checks came from a value rather than from the items' own flags; items that come later follow the same rule. */
|
|
195
|
+
private valueGiven;
|
|
196
|
+
private requests;
|
|
197
|
+
private nextUid;
|
|
95
198
|
/** Without `cascade`: checked nodes, nodes that are not locked, and the checked ones among them. */
|
|
96
199
|
private checkedNodes;
|
|
97
200
|
private openNodes;
|
|
@@ -102,33 +205,53 @@ export declare class TreeStore<TItem extends TreeItem = TreeItem> {
|
|
|
102
205
|
get size(): number;
|
|
103
206
|
/** The node of a value. */
|
|
104
207
|
get(value: TreeValue | null | undefined): TreeNode<TItem> | undefined;
|
|
208
|
+
/** The node or status row whose `key` this is: what a view keeps for its focused row. */
|
|
209
|
+
find(key: string): TreeNode<TItem> | undefined;
|
|
210
|
+
/** Where a lazy parent's children stand (`null`: the top level); `undefined` when they do not come from a loader. */
|
|
211
|
+
pagesOf(parent: TreeNode<TItem> | null): TreeChildPages | undefined;
|
|
105
212
|
/**
|
|
106
213
|
* Replaces the items. Expanded items stay expanded. The checked items come from `value` when given, otherwise from
|
|
107
|
-
* the items' own flags.
|
|
214
|
+
* the items' own flags. In a lazy tree, an item whose children were loaded keeps them, unless the items now give it
|
|
215
|
+
* children of their own.
|
|
108
216
|
*/
|
|
109
217
|
setItems(items: readonly TItem[], value?: readonly TreeValue[]): void;
|
|
218
|
+
/** Moves the loaded children (and pages) of a node that is being built again onto its new node. */
|
|
219
|
+
private adoptChildren;
|
|
110
220
|
/** Every item in tree order, without drafts. */
|
|
111
221
|
items(): TItem[];
|
|
112
222
|
/** A node and everything under it, in tree order. */
|
|
113
223
|
subtree(node: TreeNode<TItem>): TreeNode<TItem>[];
|
|
114
224
|
/** The node's parents, the top-level one first. */
|
|
115
225
|
path(node: TreeNode<TItem>): TreeNode<TItem>[];
|
|
116
|
-
/**
|
|
226
|
+
/**
|
|
227
|
+
* The state of a node's box. With `cascade`, a lazy parent whose items are not all loaded is never `checked` - its
|
|
228
|
+
* unloaded items are not in the value - unless the value names it (`valueMode: "checked"`, where it stands for all).
|
|
229
|
+
*/
|
|
117
230
|
state(node: TreeNode<TItem>): TreeCheckState;
|
|
118
231
|
/** Checked boxes and all boxes: leaves with `cascade`, every item without it. Drafts count. */
|
|
119
232
|
counts(): {
|
|
120
233
|
checked: number;
|
|
121
234
|
total: number;
|
|
122
235
|
};
|
|
123
|
-
/**
|
|
236
|
+
/**
|
|
237
|
+
* The checked values, in tree order, following `valueMode`. In a lazy tree, values whose items are not loaded yet
|
|
238
|
+
* (or not settled) follow the others, so a saved value survives until its items come.
|
|
239
|
+
*/
|
|
124
240
|
value(): TreeValue[];
|
|
125
|
-
/** The items of the value, in the same order. */
|
|
241
|
+
/** The items of the value, in the same order. In a lazy tree it holds only the items loaded, so it can be shorter than `value()`. */
|
|
126
242
|
valueItems(): TItem[];
|
|
127
|
-
/**
|
|
243
|
+
/**
|
|
244
|
+
* Checks exactly these values. Locks do not apply: this is the saved state, not a user's change. In a lazy tree a
|
|
245
|
+
* value whose item is not loaded is kept, and checks the item when it comes. Returns whether anything changed.
|
|
246
|
+
*/
|
|
128
247
|
setValue(values: readonly TreeValue[]): boolean;
|
|
129
248
|
/**
|
|
130
249
|
* What a click on the node's box does. With `cascade` it checks every item under the node that is not locked, or
|
|
131
250
|
* unchecks them when they are all checked already. Returns whether anything changed; nothing does on a locked node.
|
|
251
|
+
*
|
|
252
|
+
* In a lazy tree with `cascade`, a node whose items are not all loaded (`partial`) does not change either: a check
|
|
253
|
+
* stands for everything under it, and the value can only hold the items that were loaded, so checking it would
|
|
254
|
+
* silently leave the rest out. The items under it whose own items are all loaded can still be checked one by one.
|
|
132
255
|
*/
|
|
133
256
|
toggle(node: TreeNode<TItem>): boolean;
|
|
134
257
|
/** Checks or unchecks a node; with `cascade`, every item under it that is not locked. Returns whether anything changed. */
|
|
@@ -137,25 +260,65 @@ export declare class TreeStore<TItem extends TreeItem = TreeItem> {
|
|
|
137
260
|
allState(): TreeCheckState | null;
|
|
138
261
|
/** What a click on a "select all" box does: checks every item that is not locked, or unchecks them all when all are checked. */
|
|
139
262
|
toggleAll(): boolean;
|
|
140
|
-
/**
|
|
263
|
+
/**
|
|
264
|
+
* Checks or unchecks every item that is not locked. Returns whether anything changed. In a lazy tree with `cascade`,
|
|
265
|
+
* a node whose items are not all loaded is passed over and the loaded parts under it are changed; values whose
|
|
266
|
+
* items are not loaded stay as they are.
|
|
267
|
+
*/
|
|
141
268
|
checkAll(checked: boolean): boolean;
|
|
142
269
|
/** Whether every parent of the node is expanded, so the node is a row. */
|
|
143
270
|
isVisible(node: TreeNode<TItem>): boolean;
|
|
271
|
+
/** Whether the node can be expanded: it has children, or (lazy) it may have some not loaded yet. */
|
|
272
|
+
canExpand(node: TreeNode<TItem>): boolean;
|
|
144
273
|
/** The node's row index, or -1 when it is not a row. */
|
|
145
274
|
indexOf(node: TreeNode<TItem>): number;
|
|
146
|
-
/** Expands a node. Returns the rows it added, or `null` when no rows changed. */
|
|
275
|
+
/** Expands a node. Returns the rows it added (a lazy node's status row too), or `null` when no rows changed. */
|
|
147
276
|
expand(node: TreeNode<TItem>): TreeRowsChange<TItem> | null;
|
|
148
277
|
/** Collapses a node. Returns the rows it removed, or `null` when no rows changed. */
|
|
149
278
|
collapse(node: TreeNode<TItem>): TreeRowsChange<TItem> | null;
|
|
150
|
-
/**
|
|
279
|
+
/**
|
|
280
|
+
* Expands every item, or only the first `levels` levels (1 expands the top-level items). In a lazy tree it opens the
|
|
281
|
+
* items whose children are loaded, and asks for nothing: a node open on a page still on its way stays open.
|
|
282
|
+
*/
|
|
151
283
|
expandAll(levels?: number): void;
|
|
152
284
|
collapseAll(): void;
|
|
153
|
-
/** Expands these items and their parents, so the items and their children show. */
|
|
285
|
+
/** Expands these items and their parents, so the items and their children show. In a lazy tree, only items whose children are loaded. */
|
|
154
286
|
expandValues(values: readonly TreeValue[]): void;
|
|
155
287
|
/** The values of the expanded items, in tree order. */
|
|
156
288
|
expandedValues(): TreeValue[];
|
|
157
289
|
/** Expands the parents of a node so it becomes a row. Returns whether rows changed. */
|
|
158
290
|
reveal(node: TreeNode<TItem>): boolean;
|
|
291
|
+
/**
|
|
292
|
+
* Marks a parent's next page as on its way (`null`: the top level) and returns the request's number, which the
|
|
293
|
+
* answer is given back with. An earlier request still out is forgotten. Returns 0 when the parent has no pages.
|
|
294
|
+
*/
|
|
295
|
+
beginLoad(parent: TreeNode<TItem> | null): number;
|
|
296
|
+
/**
|
|
297
|
+
* Adds a page of children that `request` asked for, after the ones loaded, and works out what follows: `hasMore`
|
|
298
|
+
* when the page says, else whether `total` is reached, else whether the page was full (`take` items). Their parent
|
|
299
|
+
* field is not read: they go under `parent`. A value already in the tree is passed over, so a page that overlaps
|
|
300
|
+
* the last one adds no row twice. Returns the nodes added and the rows they added (for an animation), or `null` when
|
|
301
|
+
* the answer is to an older request or the parent is gone.
|
|
302
|
+
*/
|
|
303
|
+
receivePage(parent: TreeNode<TItem> | null, request: number, page: TreeChildrenPage<TItem>, take: number): {
|
|
304
|
+
added: TreeNode<TItem>[];
|
|
305
|
+
change: TreeRowsChange<TItem> | null;
|
|
306
|
+
} | null;
|
|
307
|
+
/** The page `request` asked for failed: the parent shows a failed row with Retry. Returns false for an older request. */
|
|
308
|
+
failLoad(parent: TreeNode<TItem> | null, request: number): boolean;
|
|
309
|
+
/**
|
|
310
|
+
* Replaces a parent's children with fresh pages after a refresh (`request` from `beginLoad`): an item still there
|
|
311
|
+
* keeps its node - what is expanded and loaded under it - and takes the fresh item; one no longer there goes, and a
|
|
312
|
+
* value it held waits in the value for its item to come back. Returns false for an older request.
|
|
313
|
+
*/
|
|
314
|
+
replacePages(parent: TreeNode<TItem> | null, request: number, answers: readonly TreeChildrenPage<TItem>[], take: number): boolean;
|
|
315
|
+
/**
|
|
316
|
+
* Marks loaded pages old, for a refresh: every lazy parent (`null`), or a node and everything under it. The view
|
|
317
|
+
* loads again the ones on screen, and the rest load when next expanded; a page on its way is forgotten, and a node
|
|
318
|
+
* that had answered with no children may have some now.
|
|
319
|
+
*/
|
|
320
|
+
markStale(node?: TreeNode<TItem> | null): void;
|
|
321
|
+
private stalePages;
|
|
159
322
|
/**
|
|
160
323
|
* Adds an item under `parent` (at the top level for `null`), as its last child unless `index` is given, and expands
|
|
161
324
|
* the parent. A `draft` is not part of the value or the items until `update` saves it. Throws on a value in use.
|
|
@@ -164,6 +327,12 @@ export declare class TreeStore<TItem extends TreeItem = TreeItem> {
|
|
|
164
327
|
index?: number;
|
|
165
328
|
draft?: boolean;
|
|
166
329
|
}): TreeNode<TItem>;
|
|
330
|
+
/**
|
|
331
|
+
* Adds many items under `parent` (at the top level for `null`) after its children, in one pass: counts are updated
|
|
332
|
+
* along one path, not over the whole tree, so a page of 50 joins a tree of 100,000 in well under a millisecond. A
|
|
333
|
+
* value already in the tree is passed over. The parent is not expanded. Returns the nodes added.
|
|
334
|
+
*/
|
|
335
|
+
insertMany(parent: TreeNode<TItem> | null, items: readonly TItem[]): TreeNode<TItem>[];
|
|
167
336
|
/**
|
|
168
337
|
* Replaces a node's item, e.g. after a rename, or once a draft is saved and the server gave it an id. The value can
|
|
169
338
|
* change; the parent cannot. Throws on a value another item uses.
|
|
@@ -174,11 +343,56 @@ export declare class TreeStore<TItem extends TreeItem = TreeItem> {
|
|
|
174
343
|
/** Removes a node and everything under it. Returns the removed nodes in tree order. */
|
|
175
344
|
remove(node: TreeNode<TItem>): TreeNode<TItem>[];
|
|
176
345
|
private createNode;
|
|
346
|
+
/** A lazy node's pages before anything is asked: none to ask for when its item says it has no children. */
|
|
347
|
+
private newPages;
|
|
348
|
+
/** Whether a parent (`null`: the top level) is still in the tree, so an answer for it applies. */
|
|
349
|
+
private owns;
|
|
350
|
+
/** After a parent's pages changed state: its `partial` and counts along its path, and its rows. */
|
|
351
|
+
private changedPages;
|
|
352
|
+
/**
|
|
353
|
+
* Creates nodes for items under a parent, after its children, and updates counts along the parent's path only. A
|
|
354
|
+
* value already in the tree is passed over.
|
|
355
|
+
*/
|
|
356
|
+
private addNodes;
|
|
357
|
+
/** Adds (1) or takes away (-1) nodes' share of the counts kept for a tree without `cascade`. */
|
|
358
|
+
private count;
|
|
359
|
+
/** Whether an item that has just come starts checked: its value is waiting, a parent's value stands for it, or its own flag. */
|
|
360
|
+
private arrivalChecked;
|
|
361
|
+
/**
|
|
362
|
+
* Whether a waiting value is settled now that its item is here, so the tree's own checks say it all:
|
|
363
|
+
* - without `cascade`, at once - the item is its own value, and came checked;
|
|
364
|
+
* - with `cascade`, a parent named in a value of leaves (or of every parent with a checked item) means nothing, as in
|
|
365
|
+
* a tree loaded whole;
|
|
366
|
+
* - with `cascade`, any other waits until everything under its item is loaded: an unloaded item, or a "checked"-mode
|
|
367
|
+
* parent that stands for all of its items, loaded or not.
|
|
368
|
+
*/
|
|
369
|
+
private settle;
|
|
370
|
+
private settleAll;
|
|
371
|
+
private settleAround;
|
|
372
|
+
private dropClaimsAbove;
|
|
373
|
+
/** With `cascade`: the highest nodes whose items are all loaded - the roots, or below a partial node its loaded parts. */
|
|
374
|
+
private settledTops;
|
|
375
|
+
/**
|
|
376
|
+
* Fresh items in place of a parent's children: a node whose value is still there is kept (with what is expanded and
|
|
377
|
+
* loaded under it) and takes the fresh item; one not there goes, unless it is a draft being named.
|
|
378
|
+
*/
|
|
379
|
+
private reconcile;
|
|
380
|
+
/** Rows again for a parent's block (`null`: every row), when it is expanded and a row: its children's rows and its status row. */
|
|
381
|
+
private refreshBlock;
|
|
382
|
+
/** The rows these nodes show - each node, then the rows of its children when it is expanded - and, in a lazy tree, each expanded parent's status row after its children. `parent` owns `nodes`, for its own status row. */
|
|
383
|
+
private visibleRows;
|
|
384
|
+
/** The status row an expanded parent (`null`: the top level) shows after its children, if its pages need one. */
|
|
385
|
+
private statusRowOf;
|
|
177
386
|
private keysOf;
|
|
178
387
|
/** With `valueMode: "checked"`, a parent in the value stands for all of its items. */
|
|
179
388
|
private checkedByParent;
|
|
180
389
|
/** Locks and counts for every node, given in tree order: parents pass locks down, children pass counts up. */
|
|
181
390
|
private recount;
|
|
391
|
+
/**
|
|
392
|
+
* A node's lock, `partial`, and counts, from its own flags and its children's (already worked out): what `recount`
|
|
393
|
+
* does for every node, and what a page of children does for each node on its parent's path.
|
|
394
|
+
*/
|
|
395
|
+
private aggregate;
|
|
182
396
|
/** Sets every open leaf under a node (the node itself for a leaf), updating counts up the path of each leaf that changes. */
|
|
183
397
|
private setLeaves;
|
|
184
398
|
private setNodeChecked;
|