@orkestrel/table 0.0.11 → 0.0.13
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/README.md +1 -1
- package/dist/src/browser/index.d.ts +8 -773
- package/dist/src/browser/index.js +34 -446
- package/dist/src/browser/index.js.map +1 -1
- package/dist/src/core/index.cjs +118 -92
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +11 -7
- package/dist/src/core/index.d.ts +11 -7
- package/dist/src/core/index.js +119 -93
- package/dist/src/core/index.js.map +1 -1
- package/package.json +18 -18
|
@@ -1,81 +1,12 @@
|
|
|
1
1
|
import type { EmitterErrorHandler } from '@orkestrel/emitter';
|
|
2
2
|
import type { EmitterHooks } from '@orkestrel/emitter';
|
|
3
3
|
import type { EmitterInterface } from '@orkestrel/emitter';
|
|
4
|
-
import type {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* @remarks
|
|
11
|
-
* A `text` column holding ISO strings therefore takes a pair of ISO strings and reads as a date
|
|
12
|
-
* range.
|
|
13
|
-
*/
|
|
14
|
-
declare interface BetweenFilter {
|
|
15
|
-
readonly column: string;
|
|
16
|
-
readonly operator: 'between';
|
|
17
|
-
readonly minimum: string | number;
|
|
18
|
-
readonly maximum: string | number;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Represents a column drawn from a declared list, compared by the order that list declares. It
|
|
23
|
-
* requires `choices`.
|
|
24
|
-
*
|
|
25
|
-
* @remarks
|
|
26
|
-
* A cell holding a value the list does not offer is refused at admission.
|
|
27
|
-
*/
|
|
28
|
-
declare interface ChoiceColumn extends ColumnBase {
|
|
29
|
-
readonly cell: 'choice';
|
|
30
|
-
readonly choices: readonly ColumnChoice[];
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Describes what every column carries, whatever its cells hold — the name a row's cell uses, the
|
|
35
|
-
* text a reader sees, whether a host draws the column, and the metadata a host attaches to it.
|
|
36
|
-
*
|
|
37
|
-
* @remarks
|
|
38
|
-
* `key` names the column, and it is the name a row uses for that column's cell. `label` is the
|
|
39
|
-
* heading a reader sees and `help` explains the column.
|
|
40
|
-
*
|
|
41
|
-
* `hidden` declares the column out of the presentation. It is still sorted, still filtered, and
|
|
42
|
-
* still serialized, because hiding is what a host draws rather than what the table holds.
|
|
43
|
-
*
|
|
44
|
-
* There is no `sortable` and no `filterable`. Every declared column sorts and filters; whether a
|
|
45
|
-
* heading offers either is the host's decision.
|
|
46
|
-
*
|
|
47
|
-
* `meta` is a bounded JSON carrier for whatever the schema declines to model. The table never
|
|
48
|
-
* reads it, no comparison sees it, and it round-trips verbatim. This package defines no key in
|
|
49
|
-
* it, so every key belongs to the host: an alignment, a format, a pixel width.
|
|
50
|
-
*/
|
|
51
|
-
declare interface ColumnBase {
|
|
52
|
-
readonly key: string;
|
|
53
|
-
readonly label?: string;
|
|
54
|
-
readonly help?: string;
|
|
55
|
-
readonly hidden?: boolean;
|
|
56
|
-
readonly meta?: JSONRecord;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Represents one value a `choice` column offers — `value` is stored, `label` is read, and `help`
|
|
61
|
-
* explains.
|
|
62
|
-
*
|
|
63
|
-
* @remarks
|
|
64
|
-
* The order a column declares its choices in is the order that column sorts by, which is what
|
|
65
|
-
* lets a status column sort draft before live before archived rather than alphabetically.
|
|
66
|
-
*/
|
|
67
|
-
declare interface ColumnChoice {
|
|
68
|
-
readonly value: string;
|
|
69
|
-
readonly label: string;
|
|
70
|
-
readonly help?: string;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/** Keeps the rows whose cell holds this `text` somewhere inside it. */
|
|
74
|
-
declare interface ContainsFilter {
|
|
75
|
-
readonly column: string;
|
|
76
|
-
readonly operator: 'contains';
|
|
77
|
-
readonly text: string;
|
|
78
|
-
}
|
|
4
|
+
import type { TableDirection } from '@orkestrel/table';
|
|
5
|
+
import type { TableInterface } from '@orkestrel/table';
|
|
6
|
+
import type { TableKey } from '@orkestrel/table';
|
|
7
|
+
import type { TableOrder } from '@orkestrel/table';
|
|
8
|
+
import type { TableRow } from '@orkestrel/table';
|
|
9
|
+
import type { TableSchema } from '@orkestrel/table';
|
|
79
10
|
|
|
80
11
|
/** Creates a native table binding with one retained row owner.
|
|
81
12
|
* @param element - The native table to bind.
|
|
@@ -85,214 +16,14 @@ declare interface ContainsFilter {
|
|
|
85
16
|
*/
|
|
86
17
|
export declare function createTableBinding(element: HTMLTableElement, document: TableInterface, options?: TableBindingOptions): TableBindingInterface;
|
|
87
18
|
|
|
88
|
-
/** Keeps the rows whose cell holds exactly this `value`. */
|
|
89
|
-
declare interface EqualsFilter {
|
|
90
|
-
readonly column: string;
|
|
91
|
-
readonly operator: 'equals';
|
|
92
|
-
readonly value: TableCell;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Manages the rows somebody has opened up.
|
|
97
|
-
*
|
|
98
|
-
* @remarks
|
|
99
|
-
* Expansion holds keys exactly as selection does, and what an opened row shows beside it is the
|
|
100
|
-
* host's to draw.
|
|
101
|
-
*
|
|
102
|
-
* @example
|
|
103
|
-
* ```ts
|
|
104
|
-
* table.expansion.toggle('7')
|
|
105
|
-
* table.expansion.keys.has('7') // true
|
|
106
|
-
* ```
|
|
107
|
-
*/
|
|
108
|
-
declare interface ExpansionManagerInterface {
|
|
109
|
-
/** Holds the keys of the rows opened right now. */
|
|
110
|
-
readonly keys: ReadonlySet<TableKey>;
|
|
111
|
-
/** Opens every row the table holds, one row, or several. */
|
|
112
|
-
expand(): void;
|
|
113
|
-
/**
|
|
114
|
-
* Opens one row.
|
|
115
|
-
*
|
|
116
|
-
* @param key - The row's key.
|
|
117
|
-
* @returns True if the key named a row the table holds; false otherwise.
|
|
118
|
-
*/
|
|
119
|
-
expand(key: TableKey): boolean;
|
|
120
|
-
/**
|
|
121
|
-
* Opens several rows.
|
|
122
|
-
*
|
|
123
|
-
* @param keys - The rows' keys.
|
|
124
|
-
* @returns True if every key named a row the table holds; false otherwise. Every key is
|
|
125
|
-
* checked before any row opens.
|
|
126
|
-
*/
|
|
127
|
-
expand(keys: readonly TableKey[]): boolean;
|
|
128
|
-
/**
|
|
129
|
-
* Closes every row, one row, or several. A known key that was not open still answers `true`.
|
|
130
|
-
*/
|
|
131
|
-
clear(): void;
|
|
132
|
-
/**
|
|
133
|
-
* Closes one row.
|
|
134
|
-
*
|
|
135
|
-
* @param key - The row's key.
|
|
136
|
-
* @returns True if the key named a row the table holds, whether or not it was
|
|
137
|
-
* open; false otherwise.
|
|
138
|
-
*/
|
|
139
|
-
clear(key: TableKey): boolean;
|
|
140
|
-
/**
|
|
141
|
-
* Closes several rows.
|
|
142
|
-
*
|
|
143
|
-
* @param keys - The rows' keys.
|
|
144
|
-
* @returns True if every key named a row the table holds; false otherwise. Every key is
|
|
145
|
-
* checked before any row closes.
|
|
146
|
-
*/
|
|
147
|
-
clear(keys: readonly TableKey[]): boolean;
|
|
148
|
-
/**
|
|
149
|
-
* Opens one row, or closes it when it is already open; over a list, turns each row around on
|
|
150
|
-
* its own.
|
|
151
|
-
*
|
|
152
|
-
* @param key - The row's key.
|
|
153
|
-
* @returns True if the key named a row the table holds; false otherwise.
|
|
154
|
-
*/
|
|
155
|
-
toggle(key: TableKey): boolean;
|
|
156
|
-
/**
|
|
157
|
-
* Turns several rows around, each on its own.
|
|
158
|
-
*
|
|
159
|
-
* @param keys - The rows' keys.
|
|
160
|
-
* @returns True if every key named a row the table holds; false otherwise. Every key is
|
|
161
|
-
* checked before any row turns.
|
|
162
|
-
*/
|
|
163
|
-
toggle(keys: readonly TableKey[]): boolean;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Manages which rows a table keeps.
|
|
168
|
-
*
|
|
169
|
-
* @remarks
|
|
170
|
-
* The table holds at most one filter per column and keeps the rows every filter accepts.
|
|
171
|
-
*
|
|
172
|
-
* @example
|
|
173
|
-
* ```ts
|
|
174
|
-
* table.filter.set({ column: 'name', operator: 'contains', text: 'ad' })
|
|
175
|
-
* table.count // how many rows are left
|
|
176
|
-
* ```
|
|
177
|
-
*/
|
|
178
|
-
declare interface FilterManagerInterface {
|
|
179
|
-
/**
|
|
180
|
-
* Finds one column's filter; `undefined` when nothing filters that column.
|
|
181
|
-
*
|
|
182
|
-
* @param column - The column's key.
|
|
183
|
-
* @returns The filter, or `undefined` when nothing filters that column.
|
|
184
|
-
*/
|
|
185
|
-
filter(column: string): TableFilter | undefined;
|
|
186
|
-
/**
|
|
187
|
-
* Reads every filter the table keeps rows by, in the order they were set.
|
|
188
|
-
*
|
|
189
|
-
* @returns The filters the table keeps rows by.
|
|
190
|
-
*/
|
|
191
|
-
filters(): readonly TableFilter[];
|
|
192
|
-
/**
|
|
193
|
-
* Filters one column or several. A filter for a column already filtered replaces it; every
|
|
194
|
-
* other one joins the end. An undeclared column raises `COLUMN`, and a filter the column does
|
|
195
|
-
* not admit raises `CELL`.
|
|
196
|
-
*
|
|
197
|
-
* @param filters - The filters to set. A filter for a column already filtered replaces that
|
|
198
|
-
* column's filter; every other one joins the end of the list.
|
|
199
|
-
* @throws A {@link TableError} coded `COLUMN` when a filter names a column the schema does not
|
|
200
|
-
* declare, and `CELL` when an operand is one the column cannot hold. Every filter is checked
|
|
201
|
-
* before any is set.
|
|
202
|
-
*/
|
|
203
|
-
set(filters: readonly TableFilter[]): void;
|
|
204
|
-
/**
|
|
205
|
-
* Filters one column.
|
|
206
|
-
*
|
|
207
|
-
* @param filter - The filter to set.
|
|
208
|
-
* @throws A {@link TableError} coded `COLUMN` when the filter names a column the schema does
|
|
209
|
-
* not declare, and `CELL` when an operand is one the column cannot hold.
|
|
210
|
-
*/
|
|
211
|
-
set(filter: TableFilter): void;
|
|
212
|
-
/**
|
|
213
|
-
* Stops filtering everything, one column, or several. An undeclared column returns `false` and
|
|
214
|
-
* stops nothing.
|
|
215
|
-
*/
|
|
216
|
-
remove(): void;
|
|
217
|
-
/**
|
|
218
|
-
* Stops filtering one column.
|
|
219
|
-
*
|
|
220
|
-
* @param column - The column's key.
|
|
221
|
-
* @returns True if the schema declares that column; false otherwise.
|
|
222
|
-
*/
|
|
223
|
-
remove(column: string): boolean;
|
|
224
|
-
/**
|
|
225
|
-
* Stops filtering several columns.
|
|
226
|
-
*
|
|
227
|
-
* @param columns - The columns' keys.
|
|
228
|
-
* @returns True if the schema declares every one of them; false otherwise. Every key is
|
|
229
|
-
* checked before any filter goes.
|
|
230
|
-
*/
|
|
231
|
-
remove(columns: readonly string[]): boolean;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
/** Represents a column of yes-or-no answers, compared false before true. */
|
|
235
|
-
declare interface FlagColumn extends ColumnBase {
|
|
236
|
-
readonly cell: 'flag';
|
|
237
|
-
}
|
|
238
|
-
|
|
239
19
|
/** Checks whether a caught value is a native table binding error.
|
|
20
|
+
* @remarks
|
|
21
|
+
* Recognizes self-branded errors across copies and subclasses and refuses transparent proxies.
|
|
240
22
|
* @param value - The caught value.
|
|
241
23
|
* @returns Whether the value is a binding error.
|
|
242
24
|
*/
|
|
243
25
|
export declare function isTableBindingError(value: unknown): value is TableBindingError;
|
|
244
26
|
|
|
245
|
-
/** Represents a column of numbers, compared by magnitude. */
|
|
246
|
-
declare interface NumberColumn extends ColumnBase {
|
|
247
|
-
readonly cell: 'number';
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
/**
|
|
251
|
-
* Manages which stretch of the filtered rows the view shows.
|
|
252
|
-
*
|
|
253
|
-
* @remarks
|
|
254
|
-
* `page` is the state, counted from one. `offset` and `count` are worked out from it and from the
|
|
255
|
-
* rows the filter admits, so nothing here can drift out of step with what the table holds. A page
|
|
256
|
-
* beyond the last one clamps to the last one.
|
|
257
|
-
*
|
|
258
|
-
* `offset` counts the rows skipped, from zero, which is what a database query asks for.
|
|
259
|
-
*
|
|
260
|
-
* @example
|
|
261
|
-
* ```ts
|
|
262
|
-
* table.pagination.resize(10)
|
|
263
|
-
* table.pagination.move(3)
|
|
264
|
-
* table.pagination.offset // 20
|
|
265
|
-
* ```
|
|
266
|
-
*/
|
|
267
|
-
declare interface PaginationManagerInterface {
|
|
268
|
-
/** Holds the page the view shows, counted from one, and `1` when the table is not paged. */
|
|
269
|
-
readonly page: number;
|
|
270
|
-
/** Holds the number of rows one page shows, or `undefined` when the table is not paged. */
|
|
271
|
-
readonly limit: number | undefined;
|
|
272
|
-
/** Holds the number of rows the view skips before the page it shows, counted from zero. */
|
|
273
|
-
readonly offset: number;
|
|
274
|
-
/** Counts the pages the rows admitted by the filter fill, and `1` when the table is not paged. */
|
|
275
|
-
readonly count: number;
|
|
276
|
-
/**
|
|
277
|
-
* Shows another page, counted from one and clamped to the pages that exist.
|
|
278
|
-
*
|
|
279
|
-
* @param page - The page to show, counted from one and clamped to the pages that exist. `NaN`
|
|
280
|
-
* shows the first page.
|
|
281
|
-
*/
|
|
282
|
-
move(page: number): void;
|
|
283
|
-
/**
|
|
284
|
-
* Sets how many rows a page holds, keeping the first row the view was showing. Leave the
|
|
285
|
-
* argument out to stop paging.
|
|
286
|
-
*
|
|
287
|
-
* @remarks
|
|
288
|
-
* The page moves to wherever that first row now falls.
|
|
289
|
-
*
|
|
290
|
-
* @param limit - How many rows a page holds. Leave it out to stop paging, and the view shows
|
|
291
|
-
* every row the filter admits.
|
|
292
|
-
*/
|
|
293
|
-
resize(limit?: number): void;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
27
|
/** Reads declared header metadata and explicit row keys into a validated core projection.
|
|
297
28
|
* @param element - A native table with data-table-key naming its identity column.
|
|
298
29
|
* @returns The schema and rows, validated together before any mutation.
|
|
@@ -324,262 +55,6 @@ export declare function readTableRows(schema: TableSchema, elements: readonly HT
|
|
|
324
55
|
*/
|
|
325
56
|
export declare function readTableSchema(element: HTMLTableElement): TableSchema;
|
|
326
57
|
|
|
327
|
-
/**
|
|
328
|
-
* Manages the rows a table holds, in the order it holds them.
|
|
329
|
-
*
|
|
330
|
-
* @remarks
|
|
331
|
-
* This order is the table's own, and it is what the view shows when no sort term separates two
|
|
332
|
-
* rows. Sorting reads it and never rewrites it.
|
|
333
|
-
*
|
|
334
|
-
* @example
|
|
335
|
-
* ```ts
|
|
336
|
-
* table.rows.add({ id: '7', name: 'Ada', age: 36 })
|
|
337
|
-
* table.rows.update({ id: '7', age: 37 })
|
|
338
|
-
* ```
|
|
339
|
-
*/
|
|
340
|
-
declare interface RowManagerInterface {
|
|
341
|
-
/**
|
|
342
|
-
* Finds one row by key; `undefined` when the table holds no such key.
|
|
343
|
-
*
|
|
344
|
-
* @param key - The row's key.
|
|
345
|
-
* @returns The row, or `undefined` when the table holds no such key.
|
|
346
|
-
*/
|
|
347
|
-
row(key: TableKey): TableRow | undefined;
|
|
348
|
-
/**
|
|
349
|
-
* Reads every row the table holds, in its own order — unfiltered, unsorted, and unpaged.
|
|
350
|
-
*
|
|
351
|
-
* @returns The rows, in the order the table holds them.
|
|
352
|
-
*/
|
|
353
|
-
rows(): readonly TableRow[];
|
|
354
|
-
/**
|
|
355
|
-
* Takes in one row or several, appending them in the order given. Every row is checked before
|
|
356
|
-
* any is admitted.
|
|
357
|
-
*
|
|
358
|
-
* @param rows - The rows to admit.
|
|
359
|
-
* @throws A {@link TableError} coded `KEY` when a row's key is missing, unusable, already
|
|
360
|
-
* taken, or repeated inside the batch, and `CELL` when a cell is one its column cannot hold.
|
|
361
|
-
* Every row is checked before any is admitted, so one refusal admits none of them.
|
|
362
|
-
*/
|
|
363
|
-
add(rows: readonly TableRow[]): void;
|
|
364
|
-
/**
|
|
365
|
-
* Takes in one row, appending it.
|
|
366
|
-
*
|
|
367
|
-
* @param row - The row to admit.
|
|
368
|
-
* @throws A {@link TableError} coded `KEY` when the row's key is missing, unusable, or already
|
|
369
|
-
* taken, and `CELL` when a cell is one its column cannot hold.
|
|
370
|
-
*/
|
|
371
|
-
add(row: TableRow): void;
|
|
372
|
-
/**
|
|
373
|
-
* Writes over one row or several, each found by the key it carries. The cells given replace;
|
|
374
|
-
* the cells left out stay.
|
|
375
|
-
*
|
|
376
|
-
* @param rows - The rows to write, each carrying the key of the row it writes over.
|
|
377
|
-
* @returns True if every key named a row the table holds; false otherwise.
|
|
378
|
-
* @throws A {@link TableError} coded `CELL` when a cell is one its column cannot hold. Every
|
|
379
|
-
* row is checked before any is written, so one refusal writes none of them.
|
|
380
|
-
*/
|
|
381
|
-
update(rows: readonly TableRow[]): boolean;
|
|
382
|
-
/**
|
|
383
|
-
* Writes over one row, found by the key it carries.
|
|
384
|
-
*
|
|
385
|
-
* @remarks
|
|
386
|
-
* The cells given replace the cells held; the cells left out stay as they are. A row's key
|
|
387
|
-
* therefore cannot move, because a different key names a different row.
|
|
388
|
-
*
|
|
389
|
-
* @param row - The cells to write, carrying the key of the row they belong to.
|
|
390
|
-
* @returns True if the key named a row the table holds; false otherwise.
|
|
391
|
-
* @throws A {@link TableError} coded `CELL` when a cell is one its column cannot hold.
|
|
392
|
-
*/
|
|
393
|
-
update(row: TableRow): boolean;
|
|
394
|
-
/**
|
|
395
|
-
* Replaces complete rows under existing keys, removing omitted cells without moving identities.
|
|
396
|
-
* @param rows - Whole rows to replace; every key must already exist.
|
|
397
|
-
* @returns Whether every key exists. A missing key leaves the batch unchanged.
|
|
398
|
-
* @throws A table error when any row is invalid, before any row is written.
|
|
399
|
-
*/
|
|
400
|
-
replace(rows: readonly TableRow[]): boolean;
|
|
401
|
-
/**
|
|
402
|
-
* Replaces one complete row while retaining its position, selection, and expansion.
|
|
403
|
-
* @param row - The whole replacement, including its existing identity.
|
|
404
|
-
* @returns Whether the key exists.
|
|
405
|
-
*/
|
|
406
|
-
replace(row: TableRow): boolean;
|
|
407
|
-
/**
|
|
408
|
-
* Moves one row to another place in the table's own order, counted from zero and clamped to the
|
|
409
|
-
* rows that exist.
|
|
410
|
-
*
|
|
411
|
-
* @param key - The row's key.
|
|
412
|
-
* @param index - Where to put it, counted from zero and clamped to the rows that exist. `NaN`
|
|
413
|
-
* puts the row first.
|
|
414
|
-
* @returns True if the key named a row the table holds; false otherwise.
|
|
415
|
-
*/
|
|
416
|
-
move(key: TableKey, index: number): boolean;
|
|
417
|
-
/**
|
|
418
|
-
* Takes out every row, one row, or several. Selection and expansion drop the keys of the rows
|
|
419
|
-
* that went.
|
|
420
|
-
*/
|
|
421
|
-
remove(): void;
|
|
422
|
-
/**
|
|
423
|
-
* Takes out one row.
|
|
424
|
-
*
|
|
425
|
-
* @param key - The row's key.
|
|
426
|
-
* @returns True if the key named a row the table holds; false otherwise.
|
|
427
|
-
*/
|
|
428
|
-
remove(key: TableKey): boolean;
|
|
429
|
-
/**
|
|
430
|
-
* Takes out several rows.
|
|
431
|
-
*
|
|
432
|
-
* @param keys - The rows' keys.
|
|
433
|
-
* @returns True if every key named a row the table holds; false otherwise. Every key is
|
|
434
|
-
* checked before any row goes, so one unknown key leaves the whole call undone.
|
|
435
|
-
*/
|
|
436
|
-
remove(keys: readonly TableKey[]): boolean;
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
/**
|
|
440
|
-
* Manages the rows somebody has picked.
|
|
441
|
-
*
|
|
442
|
-
* @remarks
|
|
443
|
-
* Selection holds keys, never rows or positions, so a pick survives a sort, a filter, and a page
|
|
444
|
-
* turn. A row that leaves the table takes its key out of the selection with it.
|
|
445
|
-
*
|
|
446
|
-
* @example
|
|
447
|
-
* ```ts
|
|
448
|
-
* table.selection.toggle('7')
|
|
449
|
-
* table.selection.keys.has('7') // true
|
|
450
|
-
* ```
|
|
451
|
-
*/
|
|
452
|
-
declare interface SelectionManagerInterface {
|
|
453
|
-
/** Holds the keys of the rows picked right now. */
|
|
454
|
-
readonly keys: ReadonlySet<TableKey>;
|
|
455
|
-
/**
|
|
456
|
-
* Picks every row the table holds, one row, or several. Every row, not every visible one.
|
|
457
|
-
*
|
|
458
|
-
* @remarks
|
|
459
|
-
* A host picking one page hands that page's keys over instead.
|
|
460
|
-
*/
|
|
461
|
-
select(): void;
|
|
462
|
-
/**
|
|
463
|
-
* Picks one row.
|
|
464
|
-
*
|
|
465
|
-
* @param key - The row's key.
|
|
466
|
-
* @returns True if the key named a row the table holds; false otherwise.
|
|
467
|
-
*/
|
|
468
|
-
select(key: TableKey): boolean;
|
|
469
|
-
/**
|
|
470
|
-
* Picks several rows.
|
|
471
|
-
*
|
|
472
|
-
* @param keys - The rows' keys.
|
|
473
|
-
* @returns True if every key named a row the table holds; false otherwise. Every key is
|
|
474
|
-
* checked before any row is picked.
|
|
475
|
-
*/
|
|
476
|
-
select(keys: readonly TableKey[]): boolean;
|
|
477
|
-
/**
|
|
478
|
-
* Drops every pick, one pick, or several. A known key that was not picked still answers `true`.
|
|
479
|
-
*/
|
|
480
|
-
clear(): void;
|
|
481
|
-
/**
|
|
482
|
-
* Drops one pick.
|
|
483
|
-
*
|
|
484
|
-
* @param key - The row's key.
|
|
485
|
-
* @returns True if the key named a row the table holds, whether or not it was
|
|
486
|
-
* picked; false otherwise.
|
|
487
|
-
*/
|
|
488
|
-
clear(key: TableKey): boolean;
|
|
489
|
-
/**
|
|
490
|
-
* Drops several picks.
|
|
491
|
-
*
|
|
492
|
-
* @param keys - The rows' keys.
|
|
493
|
-
* @returns True if every key named a row the table holds; false otherwise. Every key is
|
|
494
|
-
* checked before any pick is dropped.
|
|
495
|
-
*/
|
|
496
|
-
clear(keys: readonly TableKey[]): boolean;
|
|
497
|
-
/**
|
|
498
|
-
* Picks one row, or drops it when it is already picked; over a list, turns each row around on
|
|
499
|
-
* its own.
|
|
500
|
-
*
|
|
501
|
-
* @param key - The row's key.
|
|
502
|
-
* @returns True if the key named a row the table holds; false otherwise.
|
|
503
|
-
*/
|
|
504
|
-
toggle(key: TableKey): boolean;
|
|
505
|
-
/**
|
|
506
|
-
* Turns several rows around, each on its own.
|
|
507
|
-
*
|
|
508
|
-
* @param keys - The rows' keys.
|
|
509
|
-
* @returns True if every key named a row the table holds; false otherwise. Every key is
|
|
510
|
-
* checked before any row turns.
|
|
511
|
-
*/
|
|
512
|
-
toggle(keys: readonly TableKey[]): boolean;
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
/**
|
|
516
|
-
* Manages the order a table reads its rows in.
|
|
517
|
-
*
|
|
518
|
-
* @remarks
|
|
519
|
-
* The table holds one term per column and applies them in the order they were set. Which
|
|
520
|
-
* direction a heading offers next is the host's decision, so there is no cycling verb here: read
|
|
521
|
-
* the column's term, decide, then set or remove it.
|
|
522
|
-
*
|
|
523
|
-
* @example
|
|
524
|
-
* ```ts
|
|
525
|
-
* table.sort.set({ column: 'age', direction: 'descending' })
|
|
526
|
-
* table.sort.orders() // [{ column: 'age', direction: 'descending' }]
|
|
527
|
-
* ```
|
|
528
|
-
*/
|
|
529
|
-
declare interface SortManagerInterface {
|
|
530
|
-
/**
|
|
531
|
-
* Finds one column's term; `undefined` when nothing sorts that column.
|
|
532
|
-
*
|
|
533
|
-
* @param column - The column's key.
|
|
534
|
-
* @returns The term, or `undefined` when nothing sorts that column.
|
|
535
|
-
*/
|
|
536
|
-
order(column: string): TableOrder | undefined;
|
|
537
|
-
/**
|
|
538
|
-
* Reads every term the table sorts by, first to last, in the order they decide.
|
|
539
|
-
*
|
|
540
|
-
* @returns The terms the table sorts by.
|
|
541
|
-
*/
|
|
542
|
-
orders(): readonly TableOrder[];
|
|
543
|
-
/**
|
|
544
|
-
* Sorts by one column or several. A term for a column already sorted replaces its direction in
|
|
545
|
-
* place; every other term joins the end. An undeclared column raises `COLUMN`.
|
|
546
|
-
*
|
|
547
|
-
* @param orders - The terms to set. A term for a column already sorted replaces that column's
|
|
548
|
-
* direction in place; every other term joins the end of the list.
|
|
549
|
-
* @throws A {@link TableError} coded `COLUMN` when a term names a column the schema does not
|
|
550
|
-
* declare. Every term is checked before any is set.
|
|
551
|
-
*/
|
|
552
|
-
set(orders: readonly TableOrder[]): void;
|
|
553
|
-
/**
|
|
554
|
-
* Sorts by one column.
|
|
555
|
-
*
|
|
556
|
-
* @param order - The term to set.
|
|
557
|
-
* @throws A {@link TableError} coded `COLUMN` when the term names a column the schema does not
|
|
558
|
-
* declare.
|
|
559
|
-
*/
|
|
560
|
-
set(order: TableOrder): void;
|
|
561
|
-
/**
|
|
562
|
-
* Stops sorting by everything, by one column, or by several. An undeclared column returns
|
|
563
|
-
* `false` and stops nothing.
|
|
564
|
-
*/
|
|
565
|
-
remove(): void;
|
|
566
|
-
/**
|
|
567
|
-
* Stops sorting by one column.
|
|
568
|
-
*
|
|
569
|
-
* @param column - The column's key.
|
|
570
|
-
* @returns True if the schema declares that column; false otherwise.
|
|
571
|
-
*/
|
|
572
|
-
remove(column: string): boolean;
|
|
573
|
-
/**
|
|
574
|
-
* Stops sorting by several columns.
|
|
575
|
-
*
|
|
576
|
-
* @param columns - The columns' keys.
|
|
577
|
-
* @returns True if the schema declares every one of them; false otherwise. Every key is
|
|
578
|
-
* checked before any term goes.
|
|
579
|
-
*/
|
|
580
|
-
remove(columns: readonly string[]): boolean;
|
|
581
|
-
}
|
|
582
|
-
|
|
583
58
|
/** Retains keyed native rows while projecting every core table manager. */
|
|
584
59
|
export declare class TableBinding implements TableBindingInterface {
|
|
585
60
|
#private;
|
|
@@ -654,193 +129,12 @@ export declare interface TableBindingOptions {
|
|
|
654
129
|
readonly error?: EmitterErrorHandler;
|
|
655
130
|
}
|
|
656
131
|
|
|
657
|
-
/**
|
|
658
|
-
* Represents every value a cell can hold — a `string`, a `number`, or a `boolean`.
|
|
659
|
-
*
|
|
660
|
-
* @remarks
|
|
661
|
-
* The variant follows the column: `text` and `choice` hold a `string`, `number` holds a `number`,
|
|
662
|
-
* and `flag` holds a `boolean`. A cell nobody has filled has no key in its row, so absence is
|
|
663
|
-
* `undefined` and never `null` or an empty string.
|
|
664
|
-
*/
|
|
665
|
-
declare type TableCell = string | number | boolean;
|
|
666
|
-
|
|
667
|
-
/**
|
|
668
|
-
* Represents any column a schema can declare — the union discriminated on `cell`.
|
|
669
|
-
*
|
|
670
|
-
* @remarks
|
|
671
|
-
* Narrowing on `cell` reaches each variant's own members.
|
|
672
|
-
*
|
|
673
|
-
* @example
|
|
674
|
-
* ```ts
|
|
675
|
-
* function choices(column: TableColumn): readonly ColumnChoice[] {
|
|
676
|
-
* return column.cell === 'choice' ? column.choices : []
|
|
677
|
-
* }
|
|
678
|
-
* ```
|
|
679
|
-
*/
|
|
680
|
-
declare type TableColumn = TextColumn | NumberColumn | FlagColumn | ChoiceColumn;
|
|
681
|
-
|
|
682
|
-
/**
|
|
683
|
-
* Names which way a column sorts. A column nobody has sorted carries no term at all.
|
|
684
|
-
*
|
|
685
|
-
* @remarks
|
|
686
|
-
* No member of this union stands for unsorted; that state is the missing {@link TableOrder}.
|
|
687
|
-
*/
|
|
688
|
-
declare type TableDirection = 'ascending' | 'descending';
|
|
689
|
-
|
|
690
|
-
/**
|
|
691
|
-
* Lists everything a table announces, mapping each event to the payload its listeners receive.
|
|
692
|
-
*
|
|
693
|
-
* @remarks
|
|
694
|
-
* Every event fires after the state it reports is committed, and only when something actually
|
|
695
|
-
* moved: a write that changes nothing announces nothing.
|
|
696
|
-
*
|
|
697
|
-
* `write` and `remove` carry one key and fire once per row, in the order the table wrote or
|
|
698
|
-
* removed them. A listener that wants the row reads it back.
|
|
699
|
-
*
|
|
700
|
-
* `sort` and `filter` carry the whole axis as it now stands, and `select` and `expand` carry the
|
|
701
|
-
* whole key set. Each payload is owned by the listener, so nothing it holds moves underneath it.
|
|
702
|
-
*
|
|
703
|
-
* `paginate` carries the page the table now shows, and fires whenever the paged window moves,
|
|
704
|
-
* including a clamp and a change of page size.
|
|
705
|
-
*
|
|
706
|
-
* `clear` is a signal, and it is the whole announcement of that reset: a clear emits no `remove`,
|
|
707
|
-
* no `select`, and no `paginate` beside it.
|
|
708
|
-
*/
|
|
709
|
-
declare type TableEventMap = {
|
|
710
|
-
readonly write: readonly [key: TableKey];
|
|
711
|
-
readonly remove: readonly [key: TableKey];
|
|
712
|
-
readonly sort: readonly [orders: readonly TableOrder[]];
|
|
713
|
-
readonly filter: readonly [filters: readonly TableFilter[]];
|
|
714
|
-
readonly select: readonly [keys: ReadonlySet<TableKey>];
|
|
715
|
-
readonly expand: readonly [keys: ReadonlySet<TableKey>];
|
|
716
|
-
readonly paginate: readonly [page: number];
|
|
717
|
-
readonly clear: readonly [];
|
|
718
|
-
};
|
|
719
|
-
|
|
720
132
|
/** Proposes one row's next expansion state in a cancelable expand request. */
|
|
721
133
|
export declare interface TableExpansion {
|
|
722
134
|
readonly key: TableKey;
|
|
723
135
|
readonly expanded: boolean;
|
|
724
136
|
}
|
|
725
137
|
|
|
726
|
-
/**
|
|
727
|
-
* Represents any filter a table can hold — the union discriminated on `operator`.
|
|
728
|
-
*
|
|
729
|
-
* @remarks
|
|
730
|
-
* Each operator carries only the operands it uses, so a `between` missing a bound cannot be
|
|
731
|
-
* written down.
|
|
732
|
-
*
|
|
733
|
-
* A table holds at most one filter per column and keeps every row all of them accept. There is no
|
|
734
|
-
* either-or composition in this version.
|
|
735
|
-
*
|
|
736
|
-
* @example
|
|
737
|
-
* ```ts
|
|
738
|
-
* const filter: TableFilter = { column: 'age', operator: 'between', minimum: 30, maximum: 40 }
|
|
739
|
-
* ```
|
|
740
|
-
*/
|
|
741
|
-
declare type TableFilter = ContainsFilter | BetweenFilter | EqualsFilter;
|
|
742
|
-
|
|
743
|
-
/**
|
|
744
|
-
* Represents a table: what it declares, the rows it holds, and the lens it reads them through.
|
|
745
|
-
*
|
|
746
|
-
* @remarks
|
|
747
|
-
* The table owns values, not pixels. It renders nothing, reads no document, and names no host
|
|
748
|
-
* type, so one table serves a browser, a terminal, a report, and an export equally.
|
|
749
|
-
*
|
|
750
|
-
* One manager holds each axis that moves: `rows`, `sort`, `filter`, `selection`, `expansion`, and
|
|
751
|
-
* `pagination`. Nothing else is stored. `view` and `count` are worked out when they are read, so no
|
|
752
|
-
* second copy of the answer can go stale.
|
|
753
|
-
*
|
|
754
|
-
* A write validates all of itself before any of it lands, and announces itself once it has.
|
|
755
|
-
*
|
|
756
|
-
* @example
|
|
757
|
-
* ```ts
|
|
758
|
-
* table.filter.set({ column: 'name', operator: 'contains', text: 'ad' })
|
|
759
|
-
* table.sort.set({ column: 'age', direction: 'descending' })
|
|
760
|
-
* table.view // the rows to draw now: filtered, sorted, paged
|
|
761
|
-
* ```
|
|
762
|
-
*/
|
|
763
|
-
declare interface TableInterface {
|
|
764
|
-
/** Holds the table's event emitter. */
|
|
765
|
-
readonly emitter: EmitterInterface<TableEventMap>;
|
|
766
|
-
/** Holds what this table declares. */
|
|
767
|
-
readonly schema: TableSchema;
|
|
768
|
-
/** Manages the rows the table holds. */
|
|
769
|
-
readonly rows: RowManagerInterface;
|
|
770
|
-
/** Manages the order the table reads them in. */
|
|
771
|
-
readonly sort: SortManagerInterface;
|
|
772
|
-
/** Manages which of them the table keeps. */
|
|
773
|
-
readonly filter: FilterManagerInterface;
|
|
774
|
-
/** Manages the ones somebody has picked. */
|
|
775
|
-
readonly selection: SelectionManagerInterface;
|
|
776
|
-
/** Manages the ones somebody has opened up. */
|
|
777
|
-
readonly expansion: ExpansionManagerInterface;
|
|
778
|
-
/** Manages which stretch of them the view shows. */
|
|
779
|
-
readonly pagination: PaginationManagerInterface;
|
|
780
|
-
/**
|
|
781
|
-
* Returns the rows to draw right now: filtered, then sorted, then paged.
|
|
782
|
-
*
|
|
783
|
-
* @remarks
|
|
784
|
-
* It is worked out on every read and never stored, so it is right the instant anything moves.
|
|
785
|
-
*/
|
|
786
|
-
readonly view: readonly TableRow[];
|
|
787
|
-
/** Counts the rows the filter admits, before the page narrows them. */
|
|
788
|
-
readonly count: number;
|
|
789
|
-
/** Reports whether the table has been torn down. */
|
|
790
|
-
readonly destroyed: boolean;
|
|
791
|
-
/**
|
|
792
|
-
* Puts the table back the way it opened, holding nothing. Rows, sort, filter, selection,
|
|
793
|
-
* expansion, and the page all reset.
|
|
794
|
-
*
|
|
795
|
-
* @remarks
|
|
796
|
-
* The table emits `clear` and nothing else, so a reset of ten thousand rows is one
|
|
797
|
-
* announcement.
|
|
798
|
-
*/
|
|
799
|
-
clear(): void;
|
|
800
|
-
/**
|
|
801
|
-
* Tears the table down. Idempotent; afterwards every write raises `DESTROYED` and every getter
|
|
802
|
-
* still answers.
|
|
803
|
-
*
|
|
804
|
-
* @remarks
|
|
805
|
-
* The write throws a {@link TableError} carrying that code, and what a getter answers is what
|
|
806
|
-
* the table last held, so a host can read its way out of teardown without catching anything.
|
|
807
|
-
*/
|
|
808
|
-
destroy(): void;
|
|
809
|
-
}
|
|
810
|
-
|
|
811
|
-
/**
|
|
812
|
-
* Represents a row's identity — a `string`, carried in the cell the schema's `key` names.
|
|
813
|
-
*
|
|
814
|
-
* @remarks
|
|
815
|
-
* The identity must be non-empty. A column's own identifier is a plain `string`; this names a row.
|
|
816
|
-
* Selection and expansion hold these keys and nothing else, so a row keeps its selection through a
|
|
817
|
-
* re-sort.
|
|
818
|
-
*
|
|
819
|
-
* @example
|
|
820
|
-
* ```ts
|
|
821
|
-
* const key: TableKey = '7'
|
|
822
|
-
* ```
|
|
823
|
-
*/
|
|
824
|
-
declare type TableKey = string;
|
|
825
|
-
|
|
826
|
-
/**
|
|
827
|
-
* Represents one column's place in the sort — the `column` and its `direction`. The list is read
|
|
828
|
-
* left to right.
|
|
829
|
-
*
|
|
830
|
-
* @remarks
|
|
831
|
-
* The first term decides, and each later term breaks the tie the terms before it left. Rows no
|
|
832
|
-
* term separates keep the order the table holds them in.
|
|
833
|
-
*
|
|
834
|
-
* @example
|
|
835
|
-
* ```ts
|
|
836
|
-
* const order: TableOrder = { column: 'age', direction: 'descending' }
|
|
837
|
-
* ```
|
|
838
|
-
*/
|
|
839
|
-
declare interface TableOrder {
|
|
840
|
-
readonly column: string;
|
|
841
|
-
readonly direction: TableDirection;
|
|
842
|
-
}
|
|
843
|
-
|
|
844
138
|
/** Holds a validated native table projection for constructing a core document. */
|
|
845
139
|
export declare interface TableProjection {
|
|
846
140
|
readonly schema: TableSchema;
|
|
@@ -863,57 +157,6 @@ export declare interface TableRange {
|
|
|
863
157
|
*/
|
|
864
158
|
export declare type TableRenderHandler = (element: HTMLTableRowElement, row: TableRow) => void;
|
|
865
159
|
|
|
866
|
-
/**
|
|
867
|
-
* Represents one row, keyed by column. A column nobody has filled has no key here.
|
|
868
|
-
*
|
|
869
|
-
* @remarks
|
|
870
|
-
* A row carries no key the schema does not declare, and the table clones and freezes it at
|
|
871
|
-
* admission, so nothing a caller holds afterwards can move a stored row.
|
|
872
|
-
*
|
|
873
|
-
* @example
|
|
874
|
-
* ```ts
|
|
875
|
-
* const row: TableRow = { id: '7', name: 'Ada', age: 36, active: true }
|
|
876
|
-
* ```
|
|
877
|
-
*/
|
|
878
|
-
declare type TableRow = Readonly<Record<string, TableCell>>;
|
|
879
|
-
|
|
880
|
-
/**
|
|
881
|
-
* Holds everything a table declares about itself — how the table is described, which column
|
|
882
|
-
* carries row identity, and the columns it declares, in the order it declares them.
|
|
883
|
-
*
|
|
884
|
-
* @remarks
|
|
885
|
-
* The schema is data. It carries no function, so all of it crosses a wire and nothing is dropped
|
|
886
|
-
* on the way.
|
|
887
|
-
*
|
|
888
|
-
* `columns` is the schema's column list, and the order it declares is the order a host presents.
|
|
889
|
-
* `key` names the column whose cells carry row identity; it is required, it must name a declared
|
|
890
|
-
* column, and the table refuses a row whose cell there is missing, empty, or not a string. There
|
|
891
|
-
* is no default column, no positional fallback, and no key generation: an index is a position,
|
|
892
|
-
* and a position is not an identity.
|
|
893
|
-
*
|
|
894
|
-
* `name`, `label`, and `help` describe the table itself.
|
|
895
|
-
*
|
|
896
|
-
* @example
|
|
897
|
-
* ```ts
|
|
898
|
-
* const schema: TableSchema = {
|
|
899
|
-
* label: 'People',
|
|
900
|
-
* key: 'id',
|
|
901
|
-
* columns: [
|
|
902
|
-
* { cell: 'text', key: 'id', label: 'Reference' },
|
|
903
|
-
* { cell: 'text', key: 'name', label: 'Name' },
|
|
904
|
-
* { cell: 'number', key: 'age', label: 'Age' },
|
|
905
|
-
* ],
|
|
906
|
-
* }
|
|
907
|
-
* ```
|
|
908
|
-
*/
|
|
909
|
-
declare interface TableSchema {
|
|
910
|
-
readonly name?: string;
|
|
911
|
-
readonly label?: string;
|
|
912
|
-
readonly help?: string;
|
|
913
|
-
readonly key: string;
|
|
914
|
-
readonly columns: readonly TableColumn[];
|
|
915
|
-
}
|
|
916
|
-
|
|
917
160
|
/** Describes a column's direction and one-based priority among active sort orders. */
|
|
918
161
|
export declare interface TableSortDescription {
|
|
919
162
|
readonly column: string;
|
|
@@ -922,12 +165,4 @@ export declare interface TableSortDescription {
|
|
|
922
165
|
readonly count: number;
|
|
923
166
|
}
|
|
924
167
|
|
|
925
|
-
/**
|
|
926
|
-
* Represents a column of text, compared lexically. Carries a date, a time, and a timestamp as ISO
|
|
927
|
-
* strings.
|
|
928
|
-
*/
|
|
929
|
-
declare interface TextColumn extends ColumnBase {
|
|
930
|
-
readonly cell: 'text';
|
|
931
|
-
}
|
|
932
|
-
|
|
933
168
|
export { }
|