@orkestrel/table 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1353 @@
1
+ import { Emitter } from '@orkestrel/emitter';
2
+ import { EmitterErrorHandler } from '@orkestrel/emitter';
3
+ import { EmitterHooks } from '@orkestrel/emitter';
4
+ import { EmitterInterface } from '@orkestrel/emitter';
5
+ import { JSONRecord } from '@orkestrel/contract';
6
+
7
+ /**
8
+ * Check whether one column admits a filter and all its operands.
9
+ *
10
+ * @param column - The column that fixes the accepted operators and cell shapes.
11
+ * @param filter - The filter to inspect.
12
+ * @returns Whether the filter belongs to the column and the column can apply it.
13
+ */
14
+ export declare function admitsFilter(column: TableColumn, filter: TableFilter): boolean;
15
+
16
+ /**
17
+ * Audit a structurally valid schema for domain and budget faults.
18
+ *
19
+ * @param schema - The table schema to audit.
20
+ * @returns Frozen human-readable diagnostics, or an empty list when the schema is sound.
21
+ */
22
+ export declare function auditTable(schema: TableSchema): readonly string[];
23
+
24
+ /**
25
+ * Keep the rows whose cell falls between these bounds, both included.
26
+ *
27
+ * @remarks
28
+ * The bounds compare the way the column compares, so a `text` column holding ISO strings takes a
29
+ * pair of ISO strings and reads as a date range.
30
+ */
31
+ export declare interface BetweenFilter {
32
+ readonly column: string;
33
+ readonly operator: 'between';
34
+ readonly minimum: string | number;
35
+ readonly maximum: string | number;
36
+ }
37
+
38
+ /**
39
+ * Compare two cells of one column.
40
+ *
41
+ * @remarks
42
+ * It replaces the comparison the column's {@link ColumnCell} fixes, for that column alone, and it
43
+ * receives `undefined` for a row carrying no cell there. Sorting reads the result the way
44
+ * `Array.prototype.sort` does and applies {@link TableDirection} afterwards, so a comparator
45
+ * always describes ascending order.
46
+ *
47
+ * @param left - The first row's cell, or `undefined` when it carries none.
48
+ * @param right - The second row's cell, or `undefined` when it carries none.
49
+ * @returns A negative number when `left` sorts first, a positive number when `right` does, and
50
+ * zero when neither does.
51
+ * @example
52
+ * ```ts
53
+ * const natural: CellComparator = (left, right) => String(left).localeCompare(String(right))
54
+ * ```
55
+ */
56
+ export declare type CellComparator = (left: TableCell | undefined, right: TableCell | undefined) => number;
57
+
58
+ /**
59
+ * Test one column's cell against a filter.
60
+ *
61
+ * @remarks
62
+ * It replaces the test the column's {@link ColumnCell} fixes, for that column alone, and it
63
+ * receives every filter the table holds against that column.
64
+ *
65
+ * @param cell - The row's cell, or `undefined` when it carries none.
66
+ * @param filter - The filter the table is applying.
67
+ * @returns `true` to keep the row.
68
+ * @example
69
+ * ```ts
70
+ * const loose: CellMatcher = (cell, filter) =>
71
+ * filter.operator === 'contains' && String(cell).toLowerCase().includes(filter.text.toLowerCase())
72
+ * ```
73
+ */
74
+ export declare type CellMatcher = (cell: TableCell | undefined, filter: TableFilter) => boolean;
75
+
76
+ /** The maximum number of choices one `choice` column may offer. */
77
+ export declare const CHOICE_LIMIT = 1024;
78
+
79
+ /**
80
+ * A column drawn from a declared list, compared by the order that list declares.
81
+ *
82
+ * @remarks
83
+ * A cell holding a value the list does not offer is refused at admission.
84
+ */
85
+ export declare interface ChoiceColumn extends ColumnBase {
86
+ readonly cell: 'choice';
87
+ readonly choices: readonly ColumnChoice[];
88
+ }
89
+
90
+ /**
91
+ * Clone one row into an owned frozen snapshot.
92
+ *
93
+ * @param row - The row to own.
94
+ * @returns A frozen copy of the row's cells.
95
+ */
96
+ export declare function cloneRow(row: TableRow): TableRow;
97
+
98
+ /**
99
+ * Clone a table schema into an owned frozen snapshot.
100
+ *
101
+ * @param schema - The schema to own.
102
+ * @returns A frozen schema with every nested column, choice, list, and metadata record owned.
103
+ */
104
+ export declare function cloneSchema(schema: TableSchema): TableSchema;
105
+
106
+ /** Every column cell, in the order declared by the public contract. */
107
+ export declare const COLUMN_CELLS: readonly ColumnCell[];
108
+
109
+ /** The maximum number of columns one schema may declare. */
110
+ export declare const COLUMN_LIMIT = 256;
111
+
112
+ /**
113
+ * What every column carries, whatever its cells hold.
114
+ *
115
+ * @remarks
116
+ * `key` names the column, and it is the name a row uses for that column's cell. `label` is the
117
+ * heading a reader sees and `help` explains the column.
118
+ *
119
+ * `hidden` declares the column out of the presentation. It is still sorted, still filtered, and
120
+ * still serialized, because hiding is what a host draws rather than what the table holds.
121
+ *
122
+ * There is no `sortable` and no `filterable`. Every declared column sorts and filters; whether a
123
+ * heading offers either is the host's decision.
124
+ *
125
+ * `meta` is a bounded JSON carrier for whatever the schema declines to model. The table never
126
+ * reads it, no comparison sees it, and it round-trips verbatim. This package defines no key in
127
+ * it, so every key belongs to the host: an alignment, a format, a pixel width.
128
+ */
129
+ export declare interface ColumnBase {
130
+ readonly key: string;
131
+ readonly label?: string;
132
+ readonly help?: string;
133
+ readonly hidden?: boolean;
134
+ readonly meta?: JSONRecord;
135
+ }
136
+
137
+ /**
138
+ * What a column's cells hold.
139
+ *
140
+ * @remarks
141
+ * The cell is the discriminant of every {@link TableColumn} variant, so choosing it fixes what the
142
+ * cells hold, how the column compares, and which filter operators apply to it.
143
+ *
144
+ * A date, a time, and a timestamp are `text` holding a canonically spelled ISO string. Lexical
145
+ * order is chronological only when a column uses one offset, one precision, and normalized
146
+ * midnight spelling such as `00:00:00Z` instead of `24:00:00Z`. There is no temporal cell.
147
+ *
148
+ * @example
149
+ * ```ts
150
+ * const cell: ColumnCell = 'choice'
151
+ * ```
152
+ */
153
+ export declare type ColumnCell = 'text' | 'number' | 'flag' | 'choice';
154
+
155
+ /**
156
+ * One value a `choice` column offers.
157
+ *
158
+ * @remarks
159
+ * `value` is what the cell holds and `label` is what a reader sees. `help` explains the choice.
160
+ * The order a column declares its choices in is the order that column sorts by, which is what
161
+ * lets a status column sort draft before live before archived rather than alphabetically.
162
+ */
163
+ export declare interface ColumnChoice {
164
+ readonly value: string;
165
+ readonly label: string;
166
+ readonly help?: string;
167
+ }
168
+
169
+ /**
170
+ * Compare two cells in ascending order according to one column.
171
+ *
172
+ * @param column - The column that fixes the comparison.
173
+ * @param left - The first cell, or absence.
174
+ * @param right - The second cell, or absence.
175
+ * @returns A negative number, positive number, or zero in sort-comparator form.
176
+ */
177
+ export declare function compareCells(column: TableColumn, left: TableCell | undefined, right: TableCell | undefined): number;
178
+
179
+ /**
180
+ * Compute one atomic 0/1/N membership change over known keys.
181
+ *
182
+ * @param known - Every key the caller may change.
183
+ * @param current - The current key set.
184
+ * @param input - Every known key, one key, or a key list.
185
+ * @param include - Decide the next membership from each key's membership at that step.
186
+ * @returns `undefined` when any requested key is unknown, the current set for a no-op, or the next
187
+ * set when membership changes.
188
+ */
189
+ export declare function computeKeys(known: readonly TableKey[], current: ReadonlySet<TableKey>, input: TableKey | readonly TableKey[] | undefined, include: (included: boolean) => boolean): ReadonlySet<TableKey> | undefined;
190
+
191
+ /** Keep the rows whose cell holds this text somewhere inside it. */
192
+ export declare interface ContainsFilter {
193
+ readonly column: string;
194
+ readonly operator: 'contains';
195
+ readonly text: string;
196
+ }
197
+
198
+ /**
199
+ * Open a table against a schema.
200
+ *
201
+ * @param schema - The table declaration to own.
202
+ * @param options - Initial rows, lens overrides, pagination, and emitter wiring.
203
+ * @returns A live table interface.
204
+ * @throws A {@link TableError} coded `SCHEMA` when the schema is unusable, `KEY` when a seeded
205
+ * identity is unusable or repeated, and `CELL` when a seeded cell is invalid.
206
+ * @example
207
+ * ```ts
208
+ * const table = createTable({ key: 'id', columns: [{ cell: 'text', key: 'id' }] })
209
+ * table.rows.add({ id: '1' })
210
+ * ```
211
+ */
212
+ export declare function createTable(schema: TableSchema, options?: TableOptions): TableInterface;
213
+
214
+ /** Keep the rows whose cell holds exactly this value. */
215
+ export declare interface EqualsFilter {
216
+ readonly column: string;
217
+ readonly operator: 'equals';
218
+ readonly value: TableCell;
219
+ }
220
+
221
+ /** The keys of the rows somebody has opened. */
222
+ export declare class ExpansionManager implements ExpansionManagerInterface {
223
+ #private;
224
+ /**
225
+ * Create an expansion manager over one table's private stores.
226
+ *
227
+ * @param emitter - The table's event emitter.
228
+ * @param gate - The table lifecycle gate.
229
+ * @param rows - A read of every row key.
230
+ * @param read - A read of the expanded keys.
231
+ * @param write - The expanded-key commit boundary.
232
+ */
233
+ constructor(emitter: Emitter<TableEventMap>, gate: () => void, rows: () => readonly TableKey[], read: () => ReadonlySet<TableKey>, write: (keys: ReadonlySet<TableKey>) => void);
234
+ /** The keys of the rows opened right now. */
235
+ get keys(): ReadonlySet<TableKey>;
236
+ /** Open every row the table holds. */
237
+ expand(): void;
238
+ /** Open one row. */
239
+ expand(key: TableKey): boolean;
240
+ /** Open several rows. */
241
+ expand(keys: readonly TableKey[]): boolean;
242
+ /** Close every row. */
243
+ clear(): void;
244
+ /** Close one row. */
245
+ clear(key: TableKey): boolean;
246
+ /** Close several rows. */
247
+ clear(keys: readonly TableKey[]): boolean;
248
+ /** Open one row or close it when already open. */
249
+ toggle(key: TableKey): boolean;
250
+ /** Turn several rows around independently. */
251
+ toggle(keys: readonly TableKey[]): boolean;
252
+ }
253
+
254
+ /**
255
+ * The rows somebody has opened up.
256
+ *
257
+ * @remarks
258
+ * Expansion holds keys exactly as selection does, and what an opened row shows beside it is the
259
+ * host's to draw.
260
+ *
261
+ * @example
262
+ * ```ts
263
+ * table.expansion.toggle('7')
264
+ * table.expansion.keys.has('7') // true
265
+ * ```
266
+ */
267
+ export declare interface ExpansionManagerInterface {
268
+ /** The keys of the rows opened right now. */
269
+ readonly keys: ReadonlySet<TableKey>;
270
+ /** Open every row the table holds. */
271
+ expand(): void;
272
+ /**
273
+ * Open one row.
274
+ *
275
+ * @param key - The row's key.
276
+ * @returns `true` when the key named a row the table holds.
277
+ */
278
+ expand(key: TableKey): boolean;
279
+ /**
280
+ * Open several rows.
281
+ *
282
+ * @param keys - The rows' keys.
283
+ * @returns `true` when every key named a row the table holds. Every key is checked before any
284
+ * row opens.
285
+ */
286
+ expand(keys: readonly TableKey[]): boolean;
287
+ /** Close every row. */
288
+ clear(): void;
289
+ /**
290
+ * Close one row.
291
+ *
292
+ * @param key - The row's key.
293
+ * @returns `true` when the key named a row the table holds, whether or not it was open.
294
+ */
295
+ clear(key: TableKey): boolean;
296
+ /**
297
+ * Close several rows.
298
+ *
299
+ * @param keys - The rows' keys.
300
+ * @returns `true` when every key named a row the table holds. Every key is checked before any
301
+ * row closes.
302
+ */
303
+ clear(keys: readonly TableKey[]): boolean;
304
+ /**
305
+ * Open one row, or close it when it is already open.
306
+ *
307
+ * @param key - The row's key.
308
+ * @returns `true` when the key named a row the table holds.
309
+ */
310
+ toggle(key: TableKey): boolean;
311
+ /**
312
+ * Turn several rows around, each on its own.
313
+ *
314
+ * @param keys - The rows' keys.
315
+ * @returns `true` when every key named a row the table holds. Every key is checked before any
316
+ * row turns.
317
+ */
318
+ toggle(keys: readonly TableKey[]): boolean;
319
+ }
320
+
321
+ /**
322
+ * Find one column by key.
323
+ *
324
+ * @param schema - The schema whose columns to search.
325
+ * @param key - The column key to find.
326
+ * @returns The declared column, or `undefined` when no column has that key.
327
+ */
328
+ export declare function extractColumn(schema: TableSchema, key: string): TableColumn | undefined;
329
+
330
+ /**
331
+ * Read one row's declared identity.
332
+ *
333
+ * @param schema - The schema that names the identity column.
334
+ * @param row - The row whose identity to read.
335
+ * @returns The non-empty string identity, or `undefined` when it is unusable.
336
+ */
337
+ export declare function extractKey(schema: TableSchema, row: TableRow): TableKey | undefined;
338
+
339
+ /** The filters one table applies with and-only composition. */
340
+ export declare class FilterManager implements FilterManagerInterface {
341
+ #private;
342
+ /**
343
+ * Create a filter manager over one table's private filter store.
344
+ *
345
+ * @param schema - The table schema.
346
+ * @param emitter - The table's event emitter.
347
+ * @param gate - The table lifecycle gate.
348
+ * @param read - A read of the current filters.
349
+ * @param write - The filter commit boundary.
350
+ * @param clamp - The pagination clamp commit after a filter commit.
351
+ */
352
+ constructor(schema: TableSchema, emitter: Emitter<TableEventMap>, gate: () => void, read: () => readonly TableFilter[], write: (filters: readonly TableFilter[]) => void, clamp: () => number | undefined);
353
+ /** Find one column's filter. */
354
+ filter(column: string): TableFilter | undefined;
355
+ /** Read every filter as an owned frozen snapshot. */
356
+ filters(): readonly TableFilter[];
357
+ /** Filter several columns. */
358
+ set(filters: readonly TableFilter[]): void;
359
+ /** Filter one column. */
360
+ set(filter: TableFilter): void;
361
+ /** Stop filtering by every column. */
362
+ remove(): void;
363
+ /** Stop filtering by one column. */
364
+ remove(column: string): boolean;
365
+ /** Stop filtering by several columns. */
366
+ remove(columns: readonly string[]): boolean;
367
+ }
368
+
369
+ /**
370
+ * Which rows a table keeps.
371
+ *
372
+ * @remarks
373
+ * The table holds at most one filter per column and keeps the rows every filter accepts.
374
+ *
375
+ * @example
376
+ * ```ts
377
+ * table.filter.set({ column: 'name', operator: 'contains', text: 'ad' })
378
+ * table.count // how many rows are left
379
+ * ```
380
+ */
381
+ export declare interface FilterManagerInterface {
382
+ /**
383
+ * Find one column's filter.
384
+ *
385
+ * @param column - The column's key.
386
+ * @returns The filter, or `undefined` when nothing filters that column.
387
+ */
388
+ filter(column: string): TableFilter | undefined;
389
+ /**
390
+ * Every filter the table keeps rows by.
391
+ *
392
+ * @returns The filters, in the order they were set.
393
+ */
394
+ filters(): readonly TableFilter[];
395
+ /**
396
+ * Filter several columns.
397
+ *
398
+ * @param filters - The filters to set. A filter for a column already filtered replaces that
399
+ * column's filter; every other one joins the end of the list.
400
+ * @throws A {@link TableError} coded `COLUMN` when a filter names a column the schema does not
401
+ * declare, and `CELL` when an operand is one the column cannot hold. Every filter is checked
402
+ * before any is set.
403
+ */
404
+ set(filters: readonly TableFilter[]): void;
405
+ /**
406
+ * Filter one column.
407
+ *
408
+ * @param filter - The filter to set.
409
+ * @throws A {@link TableError} coded `COLUMN` when the filter names a column the schema does
410
+ * not declare, and `CELL` when an operand is one the column cannot hold.
411
+ */
412
+ set(filter: TableFilter): void;
413
+ /** Stop filtering by anything. */
414
+ remove(): void;
415
+ /**
416
+ * Stop filtering one column.
417
+ *
418
+ * @param column - The column's key.
419
+ * @returns `true` when the schema declares that column.
420
+ */
421
+ remove(column: string): boolean;
422
+ /**
423
+ * Stop filtering several columns.
424
+ *
425
+ * @param columns - The columns' keys.
426
+ * @returns `true` when the schema declares every one of them. Every key is checked before any
427
+ * filter goes.
428
+ */
429
+ remove(columns: readonly string[]): boolean;
430
+ }
431
+
432
+ /**
433
+ * How a filter tests a cell.
434
+ *
435
+ * @remarks
436
+ * `contains` looks for text inside a `text` or `choice` cell. `between` accepts a cell inside a
437
+ * pair of bounds, comparing the way the column compares. `equals` accepts a cell holding exactly
438
+ * one value, which is what a `flag` or a `choice` asks for.
439
+ *
440
+ * A column needing anything else takes a {@link CellMatcher} through
441
+ * {@link TableOptions.matchers}, so the operator set stays small and the schema stays data.
442
+ */
443
+ export declare type FilterOperator = 'contains' | 'between' | 'equals';
444
+
445
+ /**
446
+ * Keep the rows accepted by every filter.
447
+ *
448
+ * @param schema - The schema that declares the filtered columns.
449
+ * @param rows - The rows to filter.
450
+ * @param filters - The filters to apply with and-only composition.
451
+ * @param matchers - Optional per-column replacements for the default matcher.
452
+ * @returns A frozen copy of the accepted rows in their original order.
453
+ */
454
+ export declare function filterRows(schema: TableSchema, rows: readonly TableRow[], filters: readonly TableFilter[], matchers?: Readonly<Record<string, CellMatcher>>): readonly TableRow[];
455
+
456
+ /** A column of yes-or-no answers, compared false before true. */
457
+ export declare interface FlagColumn extends ColumnBase {
458
+ readonly cell: 'flag';
459
+ }
460
+
461
+ /**
462
+ * Determine whether an unknown value is a declared column cell.
463
+ *
464
+ * @param input - The value to inspect.
465
+ * @returns Whether the value is one of the four column cells.
466
+ */
467
+ export declare function isColumnCell(input: unknown): input is ColumnCell;
468
+
469
+ /**
470
+ * Determine whether an unknown value is one exact column choice record.
471
+ *
472
+ * @param input - The value to inspect.
473
+ * @returns Whether the value is a column choice.
474
+ */
475
+ export declare function isColumnChoice(input: unknown): input is ColumnChoice;
476
+
477
+ /**
478
+ * Determine whether an unknown value has one exact structural table-schema shape.
479
+ *
480
+ * @param input - The value to inspect.
481
+ * @returns Whether the value has the exact structure of a table schema.
482
+ */
483
+ export declare function isStructuralTableSchema(input: unknown): input is TableSchema;
484
+
485
+ /**
486
+ * Determine whether an unknown value has a table cell shape.
487
+ *
488
+ * @param input - The value to inspect.
489
+ * @returns Whether the value is a string, finite number, or boolean.
490
+ */
491
+ export declare function isTableCell(input: unknown): input is TableCell;
492
+
493
+ /**
494
+ * Determine whether an unknown value is one exact discriminated table column.
495
+ *
496
+ * @param input - The value to inspect.
497
+ * @returns Whether the value is a structurally valid table column.
498
+ */
499
+ export declare function isTableColumn(input: unknown): input is TableColumn;
500
+
501
+ /**
502
+ * Determine whether an unknown value is a table error.
503
+ *
504
+ * @param input - The value to inspect.
505
+ * @returns Whether the value is a {@link TableError} instance.
506
+ */
507
+ export declare function isTableError(input: unknown): input is TableError;
508
+
509
+ /**
510
+ * Determine whether an unknown value is a record of table cells.
511
+ *
512
+ * @param input - The value to inspect.
513
+ * @returns Whether every own key is a string and every value is a table cell.
514
+ */
515
+ export declare function isTableRow(input: unknown): input is TableRow;
516
+
517
+ /**
518
+ * Determine whether an unknown value is one semantically sound table schema.
519
+ *
520
+ * @param input - The value to inspect.
521
+ * @returns Whether the value has valid structure, domain relationships, and budgets.
522
+ */
523
+ export declare function isTableSchema(input: unknown): input is TableSchema;
524
+
525
+ /**
526
+ * Check whether a value has the shape required by one column cell.
527
+ *
528
+ * @param column - The column that owns the cell.
529
+ * @param value - The unknown value to inspect.
530
+ * @returns Whether the column can hold the value.
531
+ */
532
+ export declare function matchesCell(column: TableColumn, value: unknown): value is TableCell;
533
+
534
+ /**
535
+ * Test one cell against a filter according to its column.
536
+ *
537
+ * @param column - The column that fixes the accepted operators.
538
+ * @param cell - The cell to test, or absence.
539
+ * @param filter - The filter to apply.
540
+ * @returns Whether the filter accepts the cell.
541
+ */
542
+ export declare function matchesFilter(column: TableColumn, cell: TableCell | undefined, filter: TableFilter): boolean;
543
+
544
+ /** The maximum length, in UTF-16 code units, of a schema name or column key. */
545
+ export declare const NAME_LIMIT = 128;
546
+
547
+ /** The maximum total number of records, arrays, and leaves one schema retains. */
548
+ export declare const NODE_LIMIT = 16384;
549
+
550
+ /** A column of numbers, compared by magnitude. */
551
+ export declare interface NumberColumn extends ColumnBase {
552
+ readonly cell: 'number';
553
+ }
554
+
555
+ /** The page arithmetic over one table's filtered rows. */
556
+ export declare class PaginationManager implements PaginationManagerInterface {
557
+ #private;
558
+ /**
559
+ * Create a pagination manager over one table's private stores.
560
+ *
561
+ * @param emitter - The table's event emitter.
562
+ * @param gate - The table lifecycle gate.
563
+ * @param rows - A read of the filtered row count.
564
+ * @param readPage - A read of the current page.
565
+ * @param writePage - The page commit boundary.
566
+ * @param readLimit - A read of the current page size.
567
+ * @param writeLimit - The page-size commit boundary.
568
+ */
569
+ constructor(emitter: Emitter<TableEventMap>, gate: () => void, rows: () => number, readPage: () => number, writePage: (page: number) => void, readLimit: () => number | undefined, writeLimit: (limit: number | undefined) => void);
570
+ /** The page shown, counted from one. */
571
+ get page(): number;
572
+ /** The number of rows one page holds. */
573
+ get limit(): number | undefined;
574
+ /** The number of filtered rows skipped before this page. */
575
+ get offset(): number;
576
+ /** The number of pages filled by the filtered rows. */
577
+ get count(): number;
578
+ /** Show another page, clamped to the pages that exist. */
579
+ move(page: number): void;
580
+ /** Change the page size while keeping the first row previously shown. */
581
+ resize(limit?: number): void;
582
+ }
583
+
584
+ /**
585
+ * Which stretch of the filtered rows the view shows.
586
+ *
587
+ * @remarks
588
+ * `page` is the state, counted from one. `offset` and `count` are worked out from it and from the
589
+ * rows the filter admits, so nothing here can drift out of step with what the table holds. A page
590
+ * beyond the last one clamps to the last one.
591
+ *
592
+ * `offset` counts the rows skipped, from zero, which is what a database query asks for.
593
+ *
594
+ * @example
595
+ * ```ts
596
+ * table.pagination.resize(10)
597
+ * table.pagination.move(3)
598
+ * table.pagination.offset // 20
599
+ * ```
600
+ */
601
+ export declare interface PaginationManagerInterface {
602
+ /** The page the view shows, counted from one, and `1` when the table is not paged. */
603
+ readonly page: number;
604
+ /** How many rows a page holds, or `undefined` when the table is not paged. */
605
+ readonly limit: number | undefined;
606
+ /** How many rows the view skips before the page it shows, counted from zero. */
607
+ readonly offset: number;
608
+ /** How many pages the rows admitted by the filter fill, and `1` when the table is not paged. */
609
+ readonly count: number;
610
+ /**
611
+ * Show another page.
612
+ *
613
+ * @param page - The page to show, counted from one and clamped to the pages that exist.
614
+ */
615
+ move(page: number): void;
616
+ /**
617
+ * Say how many rows a page holds.
618
+ *
619
+ * @remarks
620
+ * The view keeps showing the first of the rows it was showing, so the page moves to wherever
621
+ * that row now falls.
622
+ *
623
+ * @param limit - How many rows a page holds. Leave it out to stop paging, and the view shows
624
+ * every row the filter admits.
625
+ */
626
+ resize(limit?: number): void;
627
+ }
628
+
629
+ /**
630
+ * Parse unknown wire rows against one table schema.
631
+ *
632
+ * @param schema - The schema that declares the accepted keys and cell shapes.
633
+ * @param input - The unknown row-list value to parse.
634
+ * @returns Frozen owned rows, or `undefined` when any row is refused.
635
+ */
636
+ export declare function parseRows(schema: TableSchema, input: unknown): readonly TableRow[] | undefined;
637
+
638
+ /**
639
+ * Parse unknown wire data into an owned, semantically sound table schema.
640
+ *
641
+ * @param input - The unknown schema value to parse.
642
+ * @returns An owned table schema, or `undefined` on refusal.
643
+ */
644
+ export declare function parseTable(input: unknown): TableSchema | undefined;
645
+
646
+ /** The rows one table holds in its own order. */
647
+ export declare class RowManager implements RowManagerInterface {
648
+ #private;
649
+ /**
650
+ * Create a row manager over one table's private row store.
651
+ *
652
+ * @param schema - The table schema.
653
+ * @param emitter - The table's event emitter.
654
+ * @param gate - The table lifecycle gate.
655
+ * @param read - A read of the current rows.
656
+ * @param write - The row commit boundary.
657
+ * @param settle - Commit dependent state, then order row and dependent announcements.
658
+ * @param rows - Rows to seed without announcements.
659
+ */
660
+ constructor(schema: TableSchema, emitter: Emitter<TableEventMap>, gate: () => void, read: () => readonly TableRow[], write: (rows: readonly TableRow[]) => void, settle: (removed: readonly TableKey[], announce: () => void) => void, rows?: readonly TableRow[]);
661
+ /** Find one row by key as an owned frozen snapshot. */
662
+ row(key: TableKey): TableRow | undefined;
663
+ /** Read every row as owned frozen snapshots in table order. */
664
+ rows(): readonly TableRow[];
665
+ /** Append several rows. */
666
+ add(rows: readonly TableRow[]): void;
667
+ /** Append one row. */
668
+ add(row: TableRow): void;
669
+ /** Merge several rows into the rows their keys name. */
670
+ update(rows: readonly TableRow[]): boolean;
671
+ /** Merge one row into the row its key names. */
672
+ update(row: TableRow): boolean;
673
+ /** Move one row to a clamped index in table order. */
674
+ move(key: TableKey, index: number): boolean;
675
+ /** Remove every row. */
676
+ remove(): void;
677
+ /** Remove one row. */
678
+ remove(key: TableKey): boolean;
679
+ /** Remove several rows. */
680
+ remove(keys: readonly TableKey[]): boolean;
681
+ }
682
+
683
+ /**
684
+ * The rows a table holds, in the order it holds them.
685
+ *
686
+ * @remarks
687
+ * This order is the table's own, and it is what the view shows when no sort term separates two
688
+ * rows. Sorting reads it and never rewrites it.
689
+ *
690
+ * @example
691
+ * ```ts
692
+ * table.rows.add({ id: '7', name: 'Ada', age: 36 })
693
+ * table.rows.update({ id: '7', age: 37 })
694
+ * ```
695
+ */
696
+ export declare interface RowManagerInterface {
697
+ /**
698
+ * Find one row by key.
699
+ *
700
+ * @param key - The row's key.
701
+ * @returns The row, or `undefined` when the table holds no such key.
702
+ */
703
+ row(key: TableKey): TableRow | undefined;
704
+ /**
705
+ * Every row the table holds, in its own order.
706
+ *
707
+ * @returns The rows, unfiltered, unsorted, and unpaged.
708
+ */
709
+ rows(): readonly TableRow[];
710
+ /**
711
+ * Take in several rows, appending them in the order given.
712
+ *
713
+ * @param rows - The rows to admit.
714
+ * @throws A {@link TableError} coded `KEY` when a row's key is missing, unusable, already
715
+ * taken, or repeated inside the batch, and `CELL` when a cell is one its column cannot hold.
716
+ * Every row is checked before any is admitted, so one refusal admits none of them.
717
+ */
718
+ add(rows: readonly TableRow[]): void;
719
+ /**
720
+ * Take in one row, appending it.
721
+ *
722
+ * @param row - The row to admit.
723
+ * @throws A {@link TableError} coded `KEY` when the row's key is missing, unusable, or already
724
+ * taken, and `CELL` when a cell is one its column cannot hold.
725
+ */
726
+ add(row: TableRow): void;
727
+ /**
728
+ * Write over several rows, each found by the key it carries.
729
+ *
730
+ * @param rows - The rows to write, each carrying the key of the row it writes over.
731
+ * @returns `true` when every key named a row the table holds.
732
+ * @throws A {@link TableError} coded `CELL` when a cell is one its column cannot hold. Every
733
+ * row is checked before any is written, so one refusal writes none of them.
734
+ */
735
+ update(rows: readonly TableRow[]): boolean;
736
+ /**
737
+ * Write over one row, found by the key it carries.
738
+ *
739
+ * @remarks
740
+ * The cells given replace the cells held; the cells left out stay as they are. A row's key
741
+ * therefore cannot move, because a different key names a different row.
742
+ *
743
+ * @param row - The cells to write, carrying the key of the row they belong to.
744
+ * @returns `true` when the key named a row the table holds.
745
+ * @throws A {@link TableError} coded `CELL` when a cell is one its column cannot hold.
746
+ */
747
+ update(row: TableRow): boolean;
748
+ /**
749
+ * Move one row to another place in the table's own order.
750
+ *
751
+ * @param key - The row's key.
752
+ * @param index - Where to put it, counted from zero and clamped to the rows that exist.
753
+ * @returns `true` when the key named a row the table holds.
754
+ */
755
+ move(key: TableKey, index: number): boolean;
756
+ /**
757
+ * Take out every row.
758
+ *
759
+ * @remarks
760
+ * Selection and expansion drop the keys they held, because those rows are gone.
761
+ */
762
+ remove(): void;
763
+ /**
764
+ * Take out one row.
765
+ *
766
+ * @param key - The row's key.
767
+ * @returns `true` when the key named a row the table holds.
768
+ */
769
+ remove(key: TableKey): boolean;
770
+ /**
771
+ * Take out several rows.
772
+ *
773
+ * @param keys - The rows' keys.
774
+ * @returns `true` when every key named a row the table holds. Every key is checked before any
775
+ * row goes, so one unknown key leaves the whole call undone.
776
+ */
777
+ remove(keys: readonly TableKey[]): boolean;
778
+ }
779
+
780
+ /** The keys of the rows somebody has picked. */
781
+ export declare class SelectionManager implements SelectionManagerInterface {
782
+ #private;
783
+ /**
784
+ * Create a selection manager over one table's private stores.
785
+ *
786
+ * @param emitter - The table's event emitter.
787
+ * @param gate - The table lifecycle gate.
788
+ * @param rows - A read of every row key.
789
+ * @param read - A read of the selected keys.
790
+ * @param write - The selected-key commit boundary.
791
+ */
792
+ constructor(emitter: Emitter<TableEventMap>, gate: () => void, rows: () => readonly TableKey[], read: () => ReadonlySet<TableKey>, write: (keys: ReadonlySet<TableKey>) => void);
793
+ /** The keys of the rows picked right now. */
794
+ get keys(): ReadonlySet<TableKey>;
795
+ /** Pick every row the table holds. */
796
+ select(): void;
797
+ /** Pick one row. */
798
+ select(key: TableKey): boolean;
799
+ /** Pick several rows. */
800
+ select(keys: readonly TableKey[]): boolean;
801
+ /** Drop every pick. */
802
+ clear(): void;
803
+ /** Drop one pick. */
804
+ clear(key: TableKey): boolean;
805
+ /** Drop several picks. */
806
+ clear(keys: readonly TableKey[]): boolean;
807
+ /** Pick one row or drop it when already picked. */
808
+ toggle(key: TableKey): boolean;
809
+ /** Turn several rows around independently. */
810
+ toggle(keys: readonly TableKey[]): boolean;
811
+ }
812
+
813
+ /**
814
+ * The rows somebody has picked.
815
+ *
816
+ * @remarks
817
+ * Selection holds keys, never rows or positions, so a pick survives a sort, a filter, and a page
818
+ * turn. A row that leaves the table takes its key out of the selection with it.
819
+ *
820
+ * @example
821
+ * ```ts
822
+ * table.selection.toggle('7')
823
+ * table.selection.keys.has('7') // true
824
+ * ```
825
+ */
826
+ export declare interface SelectionManagerInterface {
827
+ /** The keys of the rows picked right now. */
828
+ readonly keys: ReadonlySet<TableKey>;
829
+ /**
830
+ * Pick every row the table holds.
831
+ *
832
+ * @remarks
833
+ * Every row, not every visible one. A host picking one page hands that page's keys over
834
+ * instead.
835
+ */
836
+ select(): void;
837
+ /**
838
+ * Pick one row.
839
+ *
840
+ * @param key - The row's key.
841
+ * @returns `true` when the key named a row the table holds.
842
+ */
843
+ select(key: TableKey): boolean;
844
+ /**
845
+ * Pick several rows.
846
+ *
847
+ * @param keys - The rows' keys.
848
+ * @returns `true` when every key named a row the table holds. Every key is checked before any
849
+ * row is picked.
850
+ */
851
+ select(keys: readonly TableKey[]): boolean;
852
+ /** Drop every pick. */
853
+ clear(): void;
854
+ /**
855
+ * Drop one pick.
856
+ *
857
+ * @param key - The row's key.
858
+ * @returns `true` when the key named a row the table holds, whether or not it was picked.
859
+ */
860
+ clear(key: TableKey): boolean;
861
+ /**
862
+ * Drop several picks.
863
+ *
864
+ * @param keys - The rows' keys.
865
+ * @returns `true` when every key named a row the table holds. Every key is checked before any
866
+ * pick is dropped.
867
+ */
868
+ clear(keys: readonly TableKey[]): boolean;
869
+ /**
870
+ * Pick one row, or drop it when it is already picked.
871
+ *
872
+ * @param key - The row's key.
873
+ * @returns `true` when the key named a row the table holds.
874
+ */
875
+ toggle(key: TableKey): boolean;
876
+ /**
877
+ * Turn several rows around, each on its own.
878
+ *
879
+ * @param keys - The rows' keys.
880
+ * @returns `true` when every key named a row the table holds. Every key is checked before any
881
+ * row turns.
882
+ */
883
+ toggle(keys: readonly TableKey[]): boolean;
884
+ }
885
+
886
+ /**
887
+ * Project rows into schema-column-ordered JSON.
888
+ *
889
+ * @param schema - The schema that fixes cell order.
890
+ * @param rows - The rows to project.
891
+ * @returns A frozen list of owned JSON records with absent cells omitted.
892
+ */
893
+ export declare function serializeRows(schema: TableSchema, rows: readonly TableRow[]): readonly JSONRecord[];
894
+
895
+ /**
896
+ * Project a schema into declaration-ordered JSON.
897
+ *
898
+ * @param schema - The schema to project.
899
+ * @returns A deeply owned JSON record with absent members omitted.
900
+ * @throws A {@link TableError} coded `SCHEMA` when metadata cannot be owned.
901
+ */
902
+ export declare function serializeTable(schema: TableSchema): JSONRecord;
903
+
904
+ /** The ordered sort terms of one table. */
905
+ export declare class SortManager implements SortManagerInterface {
906
+ #private;
907
+ /**
908
+ * Create a sort manager over one table's private term store.
909
+ *
910
+ * @param schema - The table schema.
911
+ * @param emitter - The table's event emitter.
912
+ * @param gate - The table lifecycle gate.
913
+ * @param read - A read of the current terms.
914
+ * @param write - The term commit boundary.
915
+ */
916
+ constructor(schema: TableSchema, emitter: Emitter<TableEventMap>, gate: () => void, read: () => readonly TableOrder[], write: (orders: readonly TableOrder[]) => void);
917
+ /** Find one column's sort term. */
918
+ order(column: string): TableOrder | undefined;
919
+ /** Read every sort term as an owned frozen snapshot. */
920
+ orders(): readonly TableOrder[];
921
+ /** Sort by several columns. */
922
+ set(orders: readonly TableOrder[]): void;
923
+ /** Sort by one column. */
924
+ set(order: TableOrder): void;
925
+ /** Stop sorting by every column. */
926
+ remove(): void;
927
+ /** Stop sorting by one column. */
928
+ remove(column: string): boolean;
929
+ /** Stop sorting by several columns. */
930
+ remove(columns: readonly string[]): boolean;
931
+ }
932
+
933
+ /**
934
+ * The order a table reads its rows in.
935
+ *
936
+ * @remarks
937
+ * The table holds one term per column and applies them in the order they were set. Which
938
+ * direction a heading offers next is the host's decision, so there is no cycling verb here: read
939
+ * the column's term, decide, then set or remove it.
940
+ *
941
+ * @example
942
+ * ```ts
943
+ * table.sort.set({ column: 'age', direction: 'descending' })
944
+ * table.sort.orders() // [{ column: 'age', direction: 'descending' }]
945
+ * ```
946
+ */
947
+ export declare interface SortManagerInterface {
948
+ /**
949
+ * Find one column's term.
950
+ *
951
+ * @param column - The column's key.
952
+ * @returns The term, or `undefined` when nothing sorts that column.
953
+ */
954
+ order(column: string): TableOrder | undefined;
955
+ /**
956
+ * Every term the table sorts by.
957
+ *
958
+ * @returns The terms, first to last, in the order they decide.
959
+ */
960
+ orders(): readonly TableOrder[];
961
+ /**
962
+ * Sort by several columns.
963
+ *
964
+ * @param orders - The terms to set. A term for a column already sorted replaces that column's
965
+ * direction in place; every other term joins the end of the list.
966
+ * @throws A {@link TableError} coded `COLUMN` when a term names a column the schema does not
967
+ * declare. Every term is checked before any is set.
968
+ */
969
+ set(orders: readonly TableOrder[]): void;
970
+ /**
971
+ * Sort by one column.
972
+ *
973
+ * @param order - The term to set.
974
+ * @throws A {@link TableError} coded `COLUMN` when the term names a column the schema does not
975
+ * declare.
976
+ */
977
+ set(order: TableOrder): void;
978
+ /** Stop sorting by anything. */
979
+ remove(): void;
980
+ /**
981
+ * Stop sorting by one column.
982
+ *
983
+ * @param column - The column's key.
984
+ * @returns `true` when the schema declares that column.
985
+ */
986
+ remove(column: string): boolean;
987
+ /**
988
+ * Stop sorting by several columns.
989
+ *
990
+ * @param columns - The columns' keys.
991
+ * @returns `true` when the schema declares every one of them. Every key is checked before any
992
+ * term goes.
993
+ */
994
+ remove(columns: readonly string[]): boolean;
995
+ }
996
+
997
+ /**
998
+ * Order rows stably by a sequence of terms.
999
+ *
1000
+ * @param schema - The schema that declares the sorted columns.
1001
+ * @param rows - The rows to order.
1002
+ * @param orders - The ordered sort terms.
1003
+ * @param comparators - Optional per-column replacements for the default comparator.
1004
+ * @returns A frozen sorted copy that leaves the input untouched.
1005
+ */
1006
+ export declare function sortRows(schema: TableSchema, rows: readonly TableRow[], orders: readonly TableOrder[], comparators?: Readonly<Record<string, CellComparator>>): readonly TableRow[];
1007
+
1008
+ /** The maximum length, in UTF-16 code units, of any single retained string. */
1009
+ export declare const STRING_LIMIT = 65536;
1010
+
1011
+ /** A schema, its rows, and the lens through which they are read. */
1012
+ export declare class Table implements TableInterface {
1013
+ #private;
1014
+ /**
1015
+ * Open a table against a schema.
1016
+ *
1017
+ * @param schema - The table declaration to own.
1018
+ * @param options - Initial rows, lens overrides, pagination, and emitter wiring.
1019
+ * @throws A {@link TableError} coded `SCHEMA` when the schema is unusable, `KEY` when a seeded
1020
+ * identity is unusable or repeated, and `CELL` when a seeded cell is invalid.
1021
+ */
1022
+ constructor(schema: TableSchema, options?: TableOptions);
1023
+ /** The table's event emitter. */
1024
+ get emitter(): EmitterInterface<TableEventMap>;
1025
+ /** The owned frozen schema. */
1026
+ get schema(): TableSchema;
1027
+ /** The rows the table holds. */
1028
+ get rows(): RowManagerInterface;
1029
+ /** The ordered sort terms. */
1030
+ get sort(): SortManagerInterface;
1031
+ /** The filters applied with and-only composition. */
1032
+ get filter(): FilterManagerInterface;
1033
+ /** The selected row keys. */
1034
+ get selection(): SelectionManagerInterface;
1035
+ /** The expanded row keys. */
1036
+ get expansion(): ExpansionManagerInterface;
1037
+ /** The page arithmetic. */
1038
+ get pagination(): PaginationManagerInterface;
1039
+ /** The filtered, sorted, and paged rows as owned frozen snapshots. */
1040
+ get view(): readonly TableRow[];
1041
+ /** The number of rows admitted by the filters. */
1042
+ get count(): number;
1043
+ /** Whether the table has been torn down. */
1044
+ get destroyed(): boolean;
1045
+ /** Reset every moving axis to its opening state. */
1046
+ clear(): void;
1047
+ /** Tear the table down while leaving every getter readable. */
1048
+ destroy(): void;
1049
+ }
1050
+
1051
+ /**
1052
+ * Every value a cell can hold.
1053
+ *
1054
+ * @remarks
1055
+ * The variant follows the column: `text` and `choice` hold a `string`, `number` holds a `number`,
1056
+ * and `flag` holds a `boolean`. A cell nobody has filled has no key in its row, so absence is
1057
+ * `undefined` and never `null` or an empty string.
1058
+ */
1059
+ export declare type TableCell = string | number | boolean;
1060
+
1061
+ /**
1062
+ * Any column a schema can declare.
1063
+ *
1064
+ * @remarks
1065
+ * The union discriminates on `cell`, so narrowing on that member reaches each variant's own
1066
+ * members.
1067
+ *
1068
+ * @example
1069
+ * ```ts
1070
+ * function choices(column: TableColumn): readonly ColumnChoice[] {
1071
+ * return column.cell === 'choice' ? column.choices : []
1072
+ * }
1073
+ * ```
1074
+ */
1075
+ export declare type TableColumn = TextColumn | NumberColumn | FlagColumn | ChoiceColumn;
1076
+
1077
+ /**
1078
+ * Which way a column sorts.
1079
+ *
1080
+ * @remarks
1081
+ * A column nobody has sorted has no {@link TableOrder} at all, so there is no third member
1082
+ * standing for unsorted.
1083
+ */
1084
+ export declare type TableDirection = 'ascending' | 'descending';
1085
+
1086
+ /** An error raised by the table domain. */
1087
+ export declare class TableError extends Error {
1088
+ /** The machine-readable reason for this failure. */
1089
+ readonly code: TableErrorCode;
1090
+ /** Structured values that locate or explain this failure. */
1091
+ readonly context?: JSONRecord;
1092
+ /**
1093
+ * Create a table error.
1094
+ *
1095
+ * @param code - The machine-readable reason.
1096
+ * @param message - The human-readable failure text.
1097
+ * @param context - Optional structured failure details.
1098
+ */
1099
+ constructor(code: TableErrorCode, message: string, context?: JSONRecord);
1100
+ }
1101
+
1102
+ /**
1103
+ * The machine-readable code a table error carries.
1104
+ *
1105
+ * @remarks
1106
+ * `SCHEMA` rejects a malformed schema, including a `key` naming no declared column. `COLUMN`
1107
+ * names a column the schema does not declare. `KEY` reports a row identity that is missing,
1108
+ * unusable, or already taken. `CELL` reports a value the column's cell cannot hold. `DESTROYED`
1109
+ * refuses a write to a table that has been torn down.
1110
+ */
1111
+ export declare type TableErrorCode = 'SCHEMA' | 'COLUMN' | 'KEY' | 'CELL' | 'DESTROYED';
1112
+
1113
+ /**
1114
+ * Everything a table announces.
1115
+ *
1116
+ * @remarks
1117
+ * Every event fires after the state it reports is committed, and only when something actually
1118
+ * moved: a write that changes nothing announces nothing.
1119
+ *
1120
+ * `write` and `remove` carry one key and fire once per row, in the order the table wrote or
1121
+ * removed them. A listener that wants the row reads it back.
1122
+ *
1123
+ * `sort` and `filter` carry the whole axis as it now stands, and `select` and `expand` carry the
1124
+ * whole key set. Each payload is owned by the listener, so nothing it holds moves underneath it.
1125
+ *
1126
+ * `paginate` carries the page the table now shows, and fires whenever the paged window moves,
1127
+ * including a clamp and a change of page size.
1128
+ *
1129
+ * `clear` is a signal, and it is the whole announcement of that reset: a clear emits no `remove`,
1130
+ * no `select`, and no `paginate` beside it.
1131
+ */
1132
+ export declare type TableEventMap = {
1133
+ readonly write: readonly [key: TableKey];
1134
+ readonly remove: readonly [key: TableKey];
1135
+ readonly sort: readonly [orders: readonly TableOrder[]];
1136
+ readonly filter: readonly [filters: readonly TableFilter[]];
1137
+ readonly select: readonly [keys: ReadonlySet<TableKey>];
1138
+ readonly expand: readonly [keys: ReadonlySet<TableKey>];
1139
+ readonly paginate: readonly [page: number];
1140
+ readonly clear: readonly [];
1141
+ };
1142
+
1143
+ /**
1144
+ * Any filter a table can hold.
1145
+ *
1146
+ * @remarks
1147
+ * The union discriminates on `operator`, so each operator carries only the operands it uses and a
1148
+ * `between` missing a bound cannot be written down.
1149
+ *
1150
+ * A table holds at most one filter per column and keeps every row all of them accept. There is no
1151
+ * either-or composition in this version.
1152
+ *
1153
+ * @example
1154
+ * ```ts
1155
+ * const filter: TableFilter = { column: 'age', operator: 'between', minimum: 30, maximum: 40 }
1156
+ * ```
1157
+ */
1158
+ export declare type TableFilter = ContainsFilter | BetweenFilter | EqualsFilter;
1159
+
1160
+ /**
1161
+ * A table: what it declares, the rows it holds, and the lens it reads them through.
1162
+ *
1163
+ * @remarks
1164
+ * The table owns values, not pixels. It renders nothing, reads no document, and names no host
1165
+ * type, so one table serves a browser, a terminal, a report, and an export equally.
1166
+ *
1167
+ * Six managers hold everything that moves, one per axis: `rows`, `sort`, `filter`, `selection`,
1168
+ * `expansion`, and `pagination`. Nothing else is stored. `view` and `count` are worked out when
1169
+ * they are read, so no second copy of the answer can go stale.
1170
+ *
1171
+ * A write validates all of itself before any of it lands, and announces itself once it has.
1172
+ *
1173
+ * @example
1174
+ * ```ts
1175
+ * table.filter.set({ column: 'name', operator: 'contains', text: 'ad' })
1176
+ * table.sort.set({ column: 'age', direction: 'descending' })
1177
+ * table.view // the rows to draw now: filtered, sorted, paged
1178
+ * ```
1179
+ */
1180
+ export declare interface TableInterface {
1181
+ /** The table's event emitter. */
1182
+ readonly emitter: EmitterInterface<TableEventMap>;
1183
+ /** What this table declares. */
1184
+ readonly schema: TableSchema;
1185
+ /** The rows the table holds. */
1186
+ readonly rows: RowManagerInterface;
1187
+ /** The order the table reads them in. */
1188
+ readonly sort: SortManagerInterface;
1189
+ /** Which of them the table keeps. */
1190
+ readonly filter: FilterManagerInterface;
1191
+ /** The ones somebody has picked. */
1192
+ readonly selection: SelectionManagerInterface;
1193
+ /** The ones somebody has opened up. */
1194
+ readonly expansion: ExpansionManagerInterface;
1195
+ /** Which stretch of them the view shows. */
1196
+ readonly pagination: PaginationManagerInterface;
1197
+ /**
1198
+ * The rows to draw right now: filtered, then sorted, then paged.
1199
+ *
1200
+ * @remarks
1201
+ * It is worked out on every read and never stored, so it is right the instant anything moves.
1202
+ */
1203
+ readonly view: readonly TableRow[];
1204
+ /** How many rows the filter admits, before the page narrows them. */
1205
+ readonly count: number;
1206
+ /** Whether the table has been torn down. */
1207
+ readonly destroyed: boolean;
1208
+ /**
1209
+ * Put the table back the way it opened, holding nothing.
1210
+ *
1211
+ * @remarks
1212
+ * Every row goes, and sort, filter, selection, expansion, and the page all reset. The table
1213
+ * emits `clear` and nothing else, so a reset of ten thousand rows is one announcement.
1214
+ */
1215
+ clear(): void;
1216
+ /**
1217
+ * Tear the table down.
1218
+ *
1219
+ * @remarks
1220
+ * Calling it twice does what calling it once did. Afterwards every write throws a
1221
+ * {@link TableError} coded `DESTROYED`, while every getter still answers what the table last
1222
+ * held, so a host can read its way out of teardown without catching anything.
1223
+ */
1224
+ destroy(): void;
1225
+ }
1226
+
1227
+ /**
1228
+ * A row's identity.
1229
+ *
1230
+ * @remarks
1231
+ * Every row carries its own identity in the cell named by {@link TableSchema.key}, as a non-empty
1232
+ * string. A column's own identifier is a plain `string`; this names a row. Selection and expansion
1233
+ * hold these keys and nothing else, so a row keeps its selection through a re-sort.
1234
+ *
1235
+ * @example
1236
+ * ```ts
1237
+ * const key: TableKey = '7'
1238
+ * ```
1239
+ */
1240
+ export declare type TableKey = string;
1241
+
1242
+ /**
1243
+ * How to open a table.
1244
+ *
1245
+ * @param options - The table's settings.
1246
+ * @remarks
1247
+ * `on` wires listeners at construction and `error` receives any throw from one of them.
1248
+ *
1249
+ * `rows` seeds the rows. Seeding announces nothing, so a table opens quietly and every later
1250
+ * write is heard.
1251
+ *
1252
+ * `comparators` and `matchers` are keyed by column key. Each entry replaces, for that column
1253
+ * alone, the comparison or the test the column's {@link ColumnCell} fixes. They are the reason no
1254
+ * function belongs in the schema: behavior is supplied where the table is opened, and the schema
1255
+ * stays data that crosses a wire whole.
1256
+ *
1257
+ * `limit` is how many rows a page holds. Leave it out and the table is not paged.
1258
+ *
1259
+ * @example
1260
+ * ```ts
1261
+ * const options: TableOptions = {
1262
+ * rows: [{ id: '7', name: 'Ada', age: 36 }],
1263
+ * limit: 25,
1264
+ * on: { select: (keys) => highlight(keys) },
1265
+ * }
1266
+ * ```
1267
+ */
1268
+ export declare interface TableOptions {
1269
+ readonly on?: EmitterHooks<TableEventMap>;
1270
+ readonly error?: EmitterErrorHandler;
1271
+ readonly rows?: readonly TableRow[];
1272
+ readonly comparators?: Readonly<Record<string, CellComparator>>;
1273
+ readonly matchers?: Readonly<Record<string, CellMatcher>>;
1274
+ readonly limit?: number;
1275
+ }
1276
+
1277
+ /**
1278
+ * One column's place in the sort.
1279
+ *
1280
+ * @remarks
1281
+ * The order list is read left to right: the first term decides, and each later term breaks the
1282
+ * tie the terms before it left. Rows no term separates keep the order the table holds them in.
1283
+ *
1284
+ * @example
1285
+ * ```ts
1286
+ * const order: TableOrder = { column: 'age', direction: 'descending' }
1287
+ * ```
1288
+ */
1289
+ export declare interface TableOrder {
1290
+ readonly column: string;
1291
+ readonly direction: TableDirection;
1292
+ }
1293
+
1294
+ /**
1295
+ * One row, keyed by column.
1296
+ *
1297
+ * @remarks
1298
+ * A row declares a cell for the columns it carries and omits the rest. It carries no key the
1299
+ * schema does not declare, and the table clones and freezes it at admission, so nothing a caller
1300
+ * holds afterwards can move a stored row.
1301
+ *
1302
+ * @example
1303
+ * ```ts
1304
+ * const row: TableRow = { id: '7', name: 'Ada', age: 36, active: true }
1305
+ * ```
1306
+ */
1307
+ export declare type TableRow = Readonly<Record<string, TableCell>>;
1308
+
1309
+ /**
1310
+ * Everything a table declares about itself.
1311
+ *
1312
+ * @remarks
1313
+ * The schema is data. It carries no function, so all of it crosses a wire and nothing is dropped
1314
+ * on the way.
1315
+ *
1316
+ * `columns` is the schema's column list, and the order it declares is the order a host presents.
1317
+ * `key` names the column whose cells carry row identity; it is required, it must name a declared
1318
+ * column, and the table refuses a row whose cell there is missing, empty, or not a string. There
1319
+ * is no default column, no positional fallback, and no key generation: an index is a position,
1320
+ * and a position is not an identity.
1321
+ *
1322
+ * `name`, `label`, and `help` describe the table itself.
1323
+ *
1324
+ * @example
1325
+ * ```ts
1326
+ * const schema: TableSchema = {
1327
+ * label: 'People',
1328
+ * key: 'id',
1329
+ * columns: [
1330
+ * { cell: 'text', key: 'id', label: 'Reference' },
1331
+ * { cell: 'text', key: 'name', label: 'Name' },
1332
+ * { cell: 'number', key: 'age', label: 'Age' },
1333
+ * ],
1334
+ * }
1335
+ * ```
1336
+ */
1337
+ export declare interface TableSchema {
1338
+ readonly name?: string;
1339
+ readonly label?: string;
1340
+ readonly help?: string;
1341
+ readonly key: string;
1342
+ readonly columns: readonly TableColumn[];
1343
+ }
1344
+
1345
+ /** The maximum total length, in UTF-16 code units, of every string one schema retains. */
1346
+ export declare const TEXT_LIMIT = 1048576;
1347
+
1348
+ /** A column of text, compared lexically. */
1349
+ export declare interface TextColumn extends ColumnBase {
1350
+ readonly cell: 'text';
1351
+ }
1352
+
1353
+ export { }