@orkestrel/table 0.0.10 → 0.0.12

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.
@@ -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 { JSONRecord } from '@orkestrel/contract';
5
-
6
- /**
7
- * Keeps the rows whose cell falls between `minimum` and `maximum`, both included, compared the
8
- * way the column compares.
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,12 @@ 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.
240
20
  * @param value - The caught value.
241
21
  * @returns Whether the value is a binding error.
242
22
  */
243
23
  export declare function isTableBindingError(value: unknown): value is TableBindingError;
244
24
 
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
25
  /** Reads declared header metadata and explicit row keys into a validated core projection.
297
26
  * @param element - A native table with data-table-key naming its identity column.
298
27
  * @returns The schema and rows, validated together before any mutation.
@@ -324,262 +53,6 @@ export declare function readTableRows(schema: TableSchema, elements: readonly HT
324
53
  */
325
54
  export declare function readTableSchema(element: HTMLTableElement): TableSchema;
326
55
 
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
56
  /** Retains keyed native rows while projecting every core table manager. */
584
57
  export declare class TableBinding implements TableBindingInterface {
585
58
  #private;
@@ -612,9 +85,10 @@ export declare class TableBindingError extends Error {
612
85
  /** Names a native binding failure at its structure, rendering, or lifecycle boundary. */
613
86
  export declare type TableBindingErrorCode = 'STRUCTURE';
614
87
 
615
- /** Announces cancelable sorting, completed rendering, and failed DOM operations. */
88
+ /** Announces cancelable sorting and expanding, completed rendering, and failed DOM operations. */
616
89
  export declare type TableBindingEventMap = {
617
90
  readonly sort: readonly [event: CustomEvent<readonly TableOrder[]>];
91
+ readonly expand: readonly [event: CustomEvent<readonly TableExpansion[]>];
618
92
  readonly render: readonly [];
619
93
  readonly error: readonly [error: unknown];
620
94
  };
@@ -653,185 +127,10 @@ export declare interface TableBindingOptions {
653
127
  readonly error?: EmitterErrorHandler;
654
128
  }
655
129
 
656
- /**
657
- * Represents every value a cell can hold — a `string`, a `number`, or a `boolean`.
658
- *
659
- * @remarks
660
- * The variant follows the column: `text` and `choice` hold a `string`, `number` holds a `number`,
661
- * and `flag` holds a `boolean`. A cell nobody has filled has no key in its row, so absence is
662
- * `undefined` and never `null` or an empty string.
663
- */
664
- declare type TableCell = string | number | boolean;
665
-
666
- /**
667
- * Represents any column a schema can declare — the union discriminated on `cell`.
668
- *
669
- * @remarks
670
- * Narrowing on `cell` reaches each variant's own members.
671
- *
672
- * @example
673
- * ```ts
674
- * function choices(column: TableColumn): readonly ColumnChoice[] {
675
- * return column.cell === 'choice' ? column.choices : []
676
- * }
677
- * ```
678
- */
679
- declare type TableColumn = TextColumn | NumberColumn | FlagColumn | ChoiceColumn;
680
-
681
- /**
682
- * Names which way a column sorts. A column nobody has sorted carries no term at all.
683
- *
684
- * @remarks
685
- * No member of this union stands for unsorted; that state is the missing {@link TableOrder}.
686
- */
687
- declare type TableDirection = 'ascending' | 'descending';
688
-
689
- /**
690
- * Lists everything a table announces, mapping each event to the payload its listeners receive.
691
- *
692
- * @remarks
693
- * Every event fires after the state it reports is committed, and only when something actually
694
- * moved: a write that changes nothing announces nothing.
695
- *
696
- * `write` and `remove` carry one key and fire once per row, in the order the table wrote or
697
- * removed them. A listener that wants the row reads it back.
698
- *
699
- * `sort` and `filter` carry the whole axis as it now stands, and `select` and `expand` carry the
700
- * whole key set. Each payload is owned by the listener, so nothing it holds moves underneath it.
701
- *
702
- * `paginate` carries the page the table now shows, and fires whenever the paged window moves,
703
- * including a clamp and a change of page size.
704
- *
705
- * `clear` is a signal, and it is the whole announcement of that reset: a clear emits no `remove`,
706
- * no `select`, and no `paginate` beside it.
707
- */
708
- declare type TableEventMap = {
709
- readonly write: readonly [key: TableKey];
710
- readonly remove: readonly [key: TableKey];
711
- readonly sort: readonly [orders: readonly TableOrder[]];
712
- readonly filter: readonly [filters: readonly TableFilter[]];
713
- readonly select: readonly [keys: ReadonlySet<TableKey>];
714
- readonly expand: readonly [keys: ReadonlySet<TableKey>];
715
- readonly paginate: readonly [page: number];
716
- readonly clear: readonly [];
717
- };
718
-
719
- /**
720
- * Represents any filter a table can hold — the union discriminated on `operator`.
721
- *
722
- * @remarks
723
- * Each operator carries only the operands it uses, so a `between` missing a bound cannot be
724
- * written down.
725
- *
726
- * A table holds at most one filter per column and keeps every row all of them accept. There is no
727
- * either-or composition in this version.
728
- *
729
- * @example
730
- * ```ts
731
- * const filter: TableFilter = { column: 'age', operator: 'between', minimum: 30, maximum: 40 }
732
- * ```
733
- */
734
- declare type TableFilter = ContainsFilter | BetweenFilter | EqualsFilter;
735
-
736
- /**
737
- * Represents a table: what it declares, the rows it holds, and the lens it reads them through.
738
- *
739
- * @remarks
740
- * The table owns values, not pixels. It renders nothing, reads no document, and names no host
741
- * type, so one table serves a browser, a terminal, a report, and an export equally.
742
- *
743
- * One manager holds each axis that moves: `rows`, `sort`, `filter`, `selection`, `expansion`, and
744
- * `pagination`. Nothing else is stored. `view` and `count` are worked out when they are read, so no
745
- * second copy of the answer can go stale.
746
- *
747
- * A write validates all of itself before any of it lands, and announces itself once it has.
748
- *
749
- * @example
750
- * ```ts
751
- * table.filter.set({ column: 'name', operator: 'contains', text: 'ad' })
752
- * table.sort.set({ column: 'age', direction: 'descending' })
753
- * table.view // the rows to draw now: filtered, sorted, paged
754
- * ```
755
- */
756
- declare interface TableInterface {
757
- /** Holds the table's event emitter. */
758
- readonly emitter: EmitterInterface<TableEventMap>;
759
- /** Holds what this table declares. */
760
- readonly schema: TableSchema;
761
- /** Manages the rows the table holds. */
762
- readonly rows: RowManagerInterface;
763
- /** Manages the order the table reads them in. */
764
- readonly sort: SortManagerInterface;
765
- /** Manages which of them the table keeps. */
766
- readonly filter: FilterManagerInterface;
767
- /** Manages the ones somebody has picked. */
768
- readonly selection: SelectionManagerInterface;
769
- /** Manages the ones somebody has opened up. */
770
- readonly expansion: ExpansionManagerInterface;
771
- /** Manages which stretch of them the view shows. */
772
- readonly pagination: PaginationManagerInterface;
773
- /**
774
- * Returns the rows to draw right now: filtered, then sorted, then paged.
775
- *
776
- * @remarks
777
- * It is worked out on every read and never stored, so it is right the instant anything moves.
778
- */
779
- readonly view: readonly TableRow[];
780
- /** Counts the rows the filter admits, before the page narrows them. */
781
- readonly count: number;
782
- /** Reports whether the table has been torn down. */
783
- readonly destroyed: boolean;
784
- /**
785
- * Puts the table back the way it opened, holding nothing. Rows, sort, filter, selection,
786
- * expansion, and the page all reset.
787
- *
788
- * @remarks
789
- * The table emits `clear` and nothing else, so a reset of ten thousand rows is one
790
- * announcement.
791
- */
792
- clear(): void;
793
- /**
794
- * Tears the table down. Idempotent; afterwards every write raises `DESTROYED` and every getter
795
- * still answers.
796
- *
797
- * @remarks
798
- * The write throws a {@link TableError} carrying that code, and what a getter answers is what
799
- * the table last held, so a host can read its way out of teardown without catching anything.
800
- */
801
- destroy(): void;
802
- }
803
-
804
- /**
805
- * Represents a row's identity — a `string`, carried in the cell the schema's `key` names.
806
- *
807
- * @remarks
808
- * The identity must be non-empty. A column's own identifier is a plain `string`; this names a row.
809
- * Selection and expansion hold these keys and nothing else, so a row keeps its selection through a
810
- * re-sort.
811
- *
812
- * @example
813
- * ```ts
814
- * const key: TableKey = '7'
815
- * ```
816
- */
817
- declare type TableKey = string;
818
-
819
- /**
820
- * Represents one column's place in the sort — the `column` and its `direction`. The list is read
821
- * left to right.
822
- *
823
- * @remarks
824
- * The first term decides, and each later term breaks the tie the terms before it left. Rows no
825
- * term separates keep the order the table holds them in.
826
- *
827
- * @example
828
- * ```ts
829
- * const order: TableOrder = { column: 'age', direction: 'descending' }
830
- * ```
831
- */
832
- declare interface TableOrder {
833
- readonly column: string;
834
- readonly direction: TableDirection;
130
+ /** Proposes one row's next expansion state in a cancelable expand request. */
131
+ export declare interface TableExpansion {
132
+ readonly key: TableKey;
133
+ readonly expanded: boolean;
835
134
  }
836
135
 
837
136
  /** Holds a validated native table projection for constructing a core document. */
@@ -856,57 +155,6 @@ export declare interface TableRange {
856
155
  */
857
156
  export declare type TableRenderHandler = (element: HTMLTableRowElement, row: TableRow) => void;
858
157
 
859
- /**
860
- * Represents one row, keyed by column. A column nobody has filled has no key here.
861
- *
862
- * @remarks
863
- * A row carries no key the schema does not declare, and the table clones and freezes it at
864
- * admission, so nothing a caller holds afterwards can move a stored row.
865
- *
866
- * @example
867
- * ```ts
868
- * const row: TableRow = { id: '7', name: 'Ada', age: 36, active: true }
869
- * ```
870
- */
871
- declare type TableRow = Readonly<Record<string, TableCell>>;
872
-
873
- /**
874
- * Holds everything a table declares about itself — how the table is described, which column
875
- * carries row identity, and the columns it declares, in the order it declares them.
876
- *
877
- * @remarks
878
- * The schema is data. It carries no function, so all of it crosses a wire and nothing is dropped
879
- * on the way.
880
- *
881
- * `columns` is the schema's column list, and the order it declares is the order a host presents.
882
- * `key` names the column whose cells carry row identity; it is required, it must name a declared
883
- * column, and the table refuses a row whose cell there is missing, empty, or not a string. There
884
- * is no default column, no positional fallback, and no key generation: an index is a position,
885
- * and a position is not an identity.
886
- *
887
- * `name`, `label`, and `help` describe the table itself.
888
- *
889
- * @example
890
- * ```ts
891
- * const schema: TableSchema = {
892
- * label: 'People',
893
- * key: 'id',
894
- * columns: [
895
- * { cell: 'text', key: 'id', label: 'Reference' },
896
- * { cell: 'text', key: 'name', label: 'Name' },
897
- * { cell: 'number', key: 'age', label: 'Age' },
898
- * ],
899
- * }
900
- * ```
901
- */
902
- declare interface TableSchema {
903
- readonly name?: string;
904
- readonly label?: string;
905
- readonly help?: string;
906
- readonly key: string;
907
- readonly columns: readonly TableColumn[];
908
- }
909
-
910
158
  /** Describes a column's direction and one-based priority among active sort orders. */
911
159
  export declare interface TableSortDescription {
912
160
  readonly column: string;
@@ -915,12 +163,4 @@ export declare interface TableSortDescription {
915
163
  readonly count: number;
916
164
  }
917
165
 
918
- /**
919
- * Represents a column of text, compared lexically. Carries a date, a time, and a timestamp as ISO
920
- * strings.
921
- */
922
- declare interface TextColumn extends ColumnBase {
923
- readonly cell: 'text';
924
- }
925
-
926
166
  export { }