@umriss-ui/table 0.42.0 → 0.44.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +47 -0
- package/README.md +44 -4
- package/dist/index.d.ts +160 -33
- package/dist/table.css +1 -1
- package/dist/table.js +2593 -2226
- package/dist/xlsx.d.ts +37 -0
- package/dist/xlsx.js +107 -0
- package/docs/llms-full.md +1653 -368
- package/package.json +12 -4
package/CHANGELOG.md
CHANGED
|
@@ -26,6 +26,53 @@ is one of the internal numbers from before core's first publication as `0.1.0`
|
|
|
26
26
|
|
|
27
27
|
---
|
|
28
28
|
|
|
29
|
+
## 0.44.0 – A server that answers late, and an Excel file (Oct. 2026)
|
|
30
|
+
|
|
31
|
+
### Added
|
|
32
|
+
|
|
33
|
+
- **Server mode, answered** (ADR-0072): `answers` names the request the rows answer, so a late answer leaves the table loading, and the snapshot carries `request`; `error` shows in place of the rows with Try again, which reports the current request again; `selection.allMatching`, `except` and `selectMatching` stand for all that match, offered as "Select all N that match" on a ticked page and counted by the toolbar as `rowCount` less the exceptions; `exportRows(request)` lets Export write every match in the visible columns (busy and announced while it runs, a rejection shown beside it); `totals` shows the server's sums over every match in the footer, a skeleton while busy, each cell reading "All matches".
|
|
34
|
+
- **Excel through `@umriss-ui/table/xlsx`** (ADR-0073): a writer of the library's own - stored ZIP, typed cells, dates as local serials, limits that throw - in a second entry of under 4 kB gzipped that the main entry does not contain, with no runtime dependency. An export format is a value handed to `Export`: `format` and `label`; `csv` is one, `snapshot.exportAs(format)` writes any; the `ExportFormat`, `ExportSheet` and `ExportContext` types are exported.
|
|
35
|
+
- **Development warnings,** once each: a column's `value`, `sortValue`, `groupValue` or the `rowKey` held for its source text that reads a changed outer value (the first 1,000 rows are probed; the way out is the value in the rows or a `key` on the column); a `pageSize` with no `Pagination`; `Toolbar`, `Search`, `ColumnMenu`, `Export` or `Pagination` in no table and without `of`; a virtual table that renders every row in a scroll area taller than the viewport (it needs `maxHeight` or a parent of definite height); a date format over a column without points in time and a number format over a column without numbers; rows that are not an array, which read as none, with the warning naming what arrived.
|
|
36
|
+
|
|
37
|
+
### Changed
|
|
38
|
+
|
|
39
|
+
- **In server mode a bulk action's `onSelect` receives `Z[] | AllMatching`** (`{ request, except }`) while all that match are selected; an automatic table's receives `Z[]` (was `readonly Z[]`).
|
|
40
|
+
- Migration: handle the second shape - `Array.isArray` tells the array; the `'except'` key tells `AllMatching`.
|
|
41
|
+
- **`TableSelection` gains `allMatching`, `except` and `selectMatching`, all required.** In server mode a new search or condition clears the selection's keys and `allMatching`.
|
|
42
|
+
- Migration: a hand-built `TableSelection` adds the three.
|
|
43
|
+
- **In server mode a typed search is reported after a pause of 300 ms** instead of one request per letter; Enter, an empty field, `setSearch` and any other change report at once. The field, `t.search` and the view still take each letter at once.
|
|
44
|
+
- Migration: nothing to change; a test that typed and expected a request per letter commits with Enter or waits.
|
|
45
|
+
- **A column of days exports as its local day, `YYYY-MM-DD`,** in the CSV and the copy (ADR-0061, amended); other points in time stay ISO text.
|
|
46
|
+
- Migration: nothing to change; a test or a reader of the file that expected an ISO instant for a day column reads the day.
|
|
47
|
+
- **`ariaLabel` on `Table` is removed;** 0.43.0 renamed it `aria-label`.
|
|
48
|
+
- Migration: write `aria-label` (TypeScript flags every use of `ariaLabel`).
|
|
49
|
+
- **The peer range on core moves to `^0.44.0`.**
|
|
50
|
+
- Migration: install the 0.44 version of `@umriss-ui/core` beside it.
|
|
51
|
+
|
|
52
|
+
## 0.43.0 – A current row, and a table that stays in its frame (Oct. 2026)
|
|
53
|
+
|
|
54
|
+
### Added
|
|
55
|
+
|
|
56
|
+
- **A current row** (ADR-0071): `currentRow` marks the row the application holds and `onCurrentRowChange(key, row)` reports every choice, also of the row already current. A click on a body row outside its controls chooses it; in a native table the row header's content becomes a button, one tab stop per row; in grid mode Enter on a plain cell chooses its row. The row carries `aria-current="true"` and an accent bar at its inline start, which holds in forced colours. A current row set from outside comes into view - its page, the virtual window or the scroll - without moving the focus. Without a row header the development build warns once. The selection and the Active cell are untouched by it.
|
|
57
|
+
- **`useTable` returns `scrollToRow(key)` and `focusCell(key, column)`.** The first brings a row into view - its page (also in a grouped table), the window of a virtual table or the scroll; the second, in grid mode, also makes the cell the Active cell and focuses it. Both return `false` and change nothing for a key the table does not have, a row a search, condition or `preFilter` hides, a row in a folded group or branch, or a table not mounted.
|
|
58
|
+
- **A column's `format` takes Intl's options** (ADR-0069): `format={{ useGrouping: false }}` writes a year as 2024 in the cell, the filters and the group line, `format={{ style: "currency", currency: "EUR" }}` writes money. `NumberFormat` is core's shape, and the range filter drops grouping where the column does.
|
|
59
|
+
- **The search field tells the on-screen keyboard what Enter does** (`enterkeyhint`) and turns the browser's autocomplete off; a caller's own value wins.
|
|
60
|
+
|
|
61
|
+
### Changed
|
|
62
|
+
|
|
63
|
+
- **A table in a parent of definite height stays within it** (ADR-0050, amended): its frame is at most the parent's height, the toolbar and pager stay in view, and the scroll area takes what they leave - a virtual table renders a window instead of every row. In a parent without a definite height nothing changes.
|
|
64
|
+
- Migration: nothing to change; a table that used to overflow a sized pane or widget now scrolls inside it. A wrapper of your own between the two passes the height on with `height: 100%`.
|
|
65
|
+
- **`Table` is a composite root** (ADR-0068): `ref`, `className`, `style`, `id` and `data-*` reach the frame `<div>`; `aria-label`, `aria-labelledby` and `aria-describedby` reach the `<table>`. `Toolbar`, `Pagination`, `Export` and `ColumnMenu` take the attributes and the ref of the element they render, and `Search` takes an `Input`'s props.
|
|
66
|
+
- Migration: nothing to change for a class or a style; a ref now receives the frame `<div>`.
|
|
67
|
+
- **`ariaLabel` on `Table` is renamed `aria-label`.** `ariaLabel` stays as a deprecated alias and warns once in development; 0.44.0 removes it.
|
|
68
|
+
- Migration: write `aria-label`.
|
|
69
|
+
- **Under a finger no target is smaller than 24 px** (ADR-0070): the fold, the expander, the filter key and the row-header button take an invisible pad; the grouping and condition keys grow to 24 px, and their tags with them.
|
|
70
|
+
- Migration: nothing to change; under touch the grouping and condition tags stand taller. Row heights are untouched.
|
|
71
|
+
- **A number that rounds to zero no longer reads "-0".**
|
|
72
|
+
- Migration: nothing to change; a test that expected "-0" reads "0".
|
|
73
|
+
- **The peer range on core moves to `^0.43.0`.**
|
|
74
|
+
- Migration: install the 0.43 version of `@umriss-ui/core` beside it.
|
|
75
|
+
|
|
29
76
|
## 0.42.0 – Columns from the data keep their numbers (Oct. 2026)
|
|
30
77
|
|
|
31
78
|
### Added
|
package/README.md
CHANGED
|
@@ -51,7 +51,7 @@ export function Orders() {
|
|
|
51
51
|
const { Table, Column } = useTable(ORDERS, { rowKey: (o) => o.number });
|
|
52
52
|
|
|
53
53
|
return (
|
|
54
|
-
<Table
|
|
54
|
+
<Table aria-label="Orders">
|
|
55
55
|
<Column value="number" label="Order" rowHeader />
|
|
56
56
|
<Column value="customer" label="Customer" />
|
|
57
57
|
<Column value="quantity" label="Quantity" />
|
|
@@ -65,10 +65,19 @@ right-aligned in the provider's notation and sortable. `rowHeader` makes the
|
|
|
65
65
|
order number the name of the row — for a screen reader, and for the sticky
|
|
66
66
|
column.
|
|
67
67
|
|
|
68
|
+
The table is a composite (ADR-0068): `ref`, `className`, `style`, `id` and `data-*` reach its outer frame, a `<div>`, and `aria-label`, `aria-labelledby` and `aria-describedby` reach the `<table>`, so give the name there. `Toolbar`, `Pagination`, `Export` and `ColumnMenu` take the attributes and the `ref` of the element they render; `Search` is an `Input` and takes its props.
|
|
69
|
+
|
|
68
70
|
A table wider than its place scrolls in its own frame, never the page; in a
|
|
69
71
|
narrow place - a phone, beside a sidebar - the toolbar and the paging bar wrap
|
|
70
72
|
instead of running out of it.
|
|
71
73
|
|
|
74
|
+
`maxHeight` bounds the scroll area, and a `virtual` table needs a bound to render
|
|
75
|
+
only its window. A parent of definite height - a dashboard widget's body, a pane,
|
|
76
|
+
a grid cell - is such a bound without it: the table is never taller than the
|
|
77
|
+
parent, its toolbar stays in view and its rows scroll. A wrapper between the
|
|
78
|
+
two passes the height on with `height: 100%`. Where the parent has no definite
|
|
79
|
+
height, nothing changes, and `maxHeight="100%"` there bounds nothing.
|
|
80
|
+
|
|
72
81
|
## Grouped, in one option
|
|
73
82
|
|
|
74
83
|
```tsx
|
|
@@ -77,7 +86,7 @@ const { Table, Column } = useTable(orders, {
|
|
|
77
86
|
defaultGrouping: ["line", "customer"],
|
|
78
87
|
});
|
|
79
88
|
|
|
80
|
-
<Table
|
|
89
|
+
<Table aria-label="Orders by line and customer">
|
|
81
90
|
<Column value="customer" label="Customer" />
|
|
82
91
|
<Column value="number" label="Order" rowHeader />
|
|
83
92
|
<Column value="line" label="Line" />
|
|
@@ -133,9 +142,23 @@ stylesheets by hand.
|
|
|
133
142
|
* **Export and copy follow the language** (ADR-0061): the CSV takes its decimal
|
|
134
143
|
mark from the formats, yes/no from the wording and its separator from the
|
|
135
144
|
mark - English gets commas and a point, `@umriss-ui/core/wording/de` the file
|
|
136
|
-
it always had.
|
|
145
|
+
it always had. A column of days is written as `YYYY-MM-DD`, any other
|
|
146
|
+
point in time as ISO text. Ctrl or Cmd with C copies the selected rows as tab-separated
|
|
137
147
|
text (in grid mode with no selection, the Active cell), says so in a live
|
|
138
148
|
region, and `selectionAsText()` hands the same text to a button of one's own.
|
|
149
|
+
* **An Excel file** (ADR-0073): `import { xlsx } from "@umriss-ui/table/xlsx"` and
|
|
150
|
+
`<Export format={xlsx} />` write one sheet - a header line, numbers, dates,
|
|
151
|
+
booleans and text as what they are, and the table's column widths - the rows
|
|
152
|
+
and columns of the CSV, dates in the reader's local time. No styling, no
|
|
153
|
+
formulas, no group rows, no compression (a file is about the size of its XML,
|
|
154
|
+
so 100,000 rows of ten columns are tens of megabytes). A sheet over 1,048,576
|
|
155
|
+
rows or 16,384 columns throws a `RangeError`; a text over 32,767 characters is
|
|
156
|
+
cut. A text stays a text: `=1+1` opens as those characters, a leading zero
|
|
157
|
+
stays. `label` lets a CSV and an Excel button stand side by side, `onExport`
|
|
158
|
+
gets the bytes (`Uint8Array`), and `snapshot.exportAs(xlsx)` hands them to
|
|
159
|
+
code. An application that never imports the subpath does not bundle the
|
|
160
|
+
writer (about 4 kB gzipped). To read the file back, open it in a spreadsheet
|
|
161
|
+
or unzip it: it is a ZIP of XML parts.
|
|
139
162
|
* **On a row**: a detail row that stays open across a change of filter, row
|
|
140
163
|
actions that stay quiet until the row is meant, and a bulk action that always
|
|
141
164
|
receives a list.
|
|
@@ -145,6 +168,20 @@ stylesheets by hand.
|
|
|
145
168
|
the rows are one page a server answered; the table reports the request -
|
|
146
169
|
search, conditions, sort, page, page size - through `onRequest` once per
|
|
147
170
|
change and keeps the previous page, dimmed, while the next is on its way.
|
|
171
|
+
Typing in `Search` is reported after a pause of 300 ms without a keystroke
|
|
172
|
+
(the field and `t.search` take each letter at once); Enter, an emptied field,
|
|
173
|
+
`setSearch` and any other change of the request report at once.
|
|
174
|
+
`Export` writes the page; with `exportRows(request)` it writes every match
|
|
175
|
+
instead, in the table's own columns. The application caps and refuses: the
|
|
176
|
+
table asks for what the request names, and a rejection's message shows beside
|
|
177
|
+
the button. `answers` names the request the rows answer, so a late answer
|
|
178
|
+
leaves the table loading and is never shown as current; `error` shows the
|
|
179
|
+
application's message in place of the rows, with "Try again"; with a full page
|
|
180
|
+
ticked the table offers all that match, and a bulk action then receives
|
|
181
|
+
`{ request, except }` instead of rows (the one type a caller may have to
|
|
182
|
+
answer); `totals` fill the footer over every match. What stays the
|
|
183
|
+
application's: the cap on an export, the sums and the clearing of `error`.
|
|
184
|
+
Groups from the server are the next piece, with a spec of their own.
|
|
148
185
|
* **Twenty thousand rows** where it has to be: virtualisation, sticky parts,
|
|
149
186
|
columns pinned to either side and column widths that survive a view being
|
|
150
187
|
restored.
|
|
@@ -153,7 +190,10 @@ stylesheets by hand.
|
|
|
153
190
|
The sort stays and the rows stand in its order; a row keeps its place in the
|
|
154
191
|
markup by its `rowKey`; the selection holds by key (the count follows the rows
|
|
155
192
|
there are, and a key whose row is gone waits in the set and ticks again if the
|
|
156
|
-
row returns
|
|
193
|
+
row returns; an application that holds the selection outside, with
|
|
194
|
+
`useTableSelection`, stores `allMatching` and `except` with the keys - in
|
|
195
|
+
server mode a change of search or conditions clears them through `clear()`);
|
|
196
|
+
an open Row draft stays open with what was typed and shows its
|
|
157
197
|
other fields as they were when it opened, and closes only when its row is gone
|
|
158
198
|
from `rows`; the Active cell stays on its row by key when a re-sort moves it,
|
|
159
199
|
and where its row is gone the cell now at its index takes over; the scroll
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
+
import { ButtonProps } from '@umriss-ui/core';
|
|
1
2
|
import { ComponentType } from 'react';
|
|
3
|
+
import { Formats } from '@umriss-ui/core';
|
|
4
|
+
import { HTMLAttributes } from 'react';
|
|
5
|
+
import { InputProps } from '@umriss-ui/core';
|
|
2
6
|
import { JSX } from 'react';
|
|
3
7
|
import { LimitSet } from '@umriss-ui/core';
|
|
8
|
+
import { NumberOptions } from '@umriss-ui/core';
|
|
4
9
|
import { ReactNode } from 'react';
|
|
10
|
+
import { RefProp } from '@umriss-ui/core';
|
|
11
|
+
import { Wording } from '@umriss-ui/core';
|
|
5
12
|
|
|
6
13
|
/** A value that is not there: `null` or `undefined`. */
|
|
7
14
|
export declare type Absent = null | undefined;
|
|
@@ -15,7 +22,7 @@ declare interface ActionBase {
|
|
|
15
22
|
|
|
16
23
|
/** The props of `Action`: one action on a row, or with `bulk` on a list of
|
|
17
24
|
rows - then it also stands in the table toolbar for the selection. */
|
|
18
|
-
export declare type ActionProps<Z> = (ActionBase & {
|
|
25
|
+
export declare type ActionProps<Z, S extends boolean = false> = (ActionBase & {
|
|
19
26
|
bulk?: false;
|
|
20
27
|
/** Gets the row the action was triggered on. */
|
|
21
28
|
onSelect: (row: Z) => void;
|
|
@@ -24,7 +31,7 @@ export declare type ActionProps<Z> = (ActionBase & {
|
|
|
24
31
|
toolbar on the selection within the filtered set. */
|
|
25
32
|
bulk: true;
|
|
26
33
|
/** With `bulk` a list: at the row one made from it, in the table toolbar the selection. */
|
|
27
|
-
onSelect
|
|
34
|
+
onSelect(selected: S extends true ? Z[] | AllMatching : Z[]): void;
|
|
28
35
|
});
|
|
29
36
|
|
|
30
37
|
/** A column that carries an aggregate, as the pipeline needs it. */
|
|
@@ -63,6 +70,15 @@ export declare interface AggregateOptions<W, Z> {
|
|
|
63
70
|
share?: boolean;
|
|
64
71
|
}
|
|
65
72
|
|
|
73
|
+
/** What a server-mode bulk action receives, in the toolbar, while all that
|
|
74
|
+
match are selected: the request they match and the keys unticked since.
|
|
75
|
+
`Array.isArray` tells it from rows - the rows are typed as a mutable array
|
|
76
|
+
so that it narrows both ways. */
|
|
77
|
+
export declare interface AllMatching {
|
|
78
|
+
request: TableRequest;
|
|
79
|
+
except: readonly string[];
|
|
80
|
+
}
|
|
81
|
+
|
|
66
82
|
/** The table holds every row and does the work itself. */
|
|
67
83
|
declare interface AutomaticMode<Z> {
|
|
68
84
|
/** Without it the table holds every row and does the work itself. */
|
|
@@ -78,7 +94,11 @@ declare interface AutomaticMode<Z> {
|
|
|
78
94
|
defaultBranches?: readonly string[] | number;
|
|
79
95
|
rowCount?: never;
|
|
80
96
|
onRequest?: never;
|
|
97
|
+
exportRows?: never;
|
|
81
98
|
filterOptions?: never;
|
|
99
|
+
answers?: never;
|
|
100
|
+
error?: never;
|
|
101
|
+
totals?: never;
|
|
82
102
|
}
|
|
83
103
|
|
|
84
104
|
/** An edit the user committed - reported, not applied. */
|
|
@@ -229,10 +249,10 @@ export declare function columnFilter<W, B>(definition: ColumnFilter<W, B>): Colu
|
|
|
229
249
|
/** Show and hide columns and arrange them. Every control is a real control -
|
|
230
250
|
a box or a button -, so it is reachable without a pointer; after a move the
|
|
231
251
|
focus stays on the button that was pressed. */
|
|
232
|
-
export declare function ColumnMenu({ size: own, of }: ColumnMenuProps): JSX.Element | null;
|
|
252
|
+
export declare function ColumnMenu({ size: own, of, ref, ...rest }: ColumnMenuProps): JSX.Element | null;
|
|
233
253
|
|
|
234
254
|
/** The props of `ColumnMenu`. */
|
|
235
|
-
export declare interface ColumnMenuProps {
|
|
255
|
+
export declare interface ColumnMenuProps extends Omit<ButtonProps, "size" | "children" | "onClick" | "variant" | "loading"> {
|
|
236
256
|
/** The size of the part: `sm` or `md`.
|
|
237
257
|
@default the size of the toolbar it stands in, `"sm"` outside one */
|
|
238
258
|
size?: ToolbarSize;
|
|
@@ -262,6 +282,10 @@ export declare type Computed<Z, W> = ColumnBase & ValuePaths<W> & {
|
|
|
262
282
|
validate?: (value: W | null, row: Z) => string | null | undefined;
|
|
263
283
|
};
|
|
264
284
|
|
|
285
|
+
/** The CSV: the language's conventions; a column of days as its local day,
|
|
286
|
+
other points in time as ISO text. */
|
|
287
|
+
export declare const csv: ExportFormat;
|
|
288
|
+
|
|
265
289
|
/** The names of the standard presentations of a point in time. */
|
|
266
290
|
export declare type DateFormat = "date" | "time" | "dateTime";
|
|
267
291
|
|
|
@@ -293,17 +317,43 @@ export declare interface EditOptions<W, Z> {
|
|
|
293
317
|
|
|
294
318
|
/** Writes the filtered set in the visible columns and their order – with the
|
|
295
319
|
values, not with their presentation. In server mode the table holds one
|
|
296
|
-
page of the server's, so it writes that page, and its button says so
|
|
297
|
-
|
|
320
|
+
page of the server's, so it writes that page, and its button says so;
|
|
321
|
+
with `exportRows` it asks the application for every row of the current
|
|
322
|
+
request instead and writes those. */
|
|
323
|
+
export declare function Export<R = string>({ format: given, filename, onExport, label, size: own, of, ...rest }: ExportProps<R>): JSX.Element | null;
|
|
324
|
+
|
|
325
|
+
/** What a spreadsheet cell holds: numbers, booleans and points in time stay
|
|
326
|
+
what they are, an absent value is `undefined`. */
|
|
327
|
+
export declare type ExportCell = string | number | boolean | Date | undefined;
|
|
328
|
+
|
|
329
|
+
/** What the language in use hands a format. */
|
|
330
|
+
export declare interface ExportContext {
|
|
331
|
+
formats: Formats;
|
|
332
|
+
wording: Wording;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/** A way to write the export: the file's extension and MIME type, and the
|
|
336
|
+
function that turns the sheet into `R` - text or bytes. */
|
|
337
|
+
export declare interface ExportFormat<R = string> {
|
|
338
|
+
extension: string;
|
|
339
|
+
mime: string;
|
|
340
|
+
write: (sheet: ExportSheet, context: ExportContext) => R;
|
|
341
|
+
}
|
|
298
342
|
|
|
299
343
|
/** The props of `Export`: by default a CSV file is downloaded; with
|
|
300
344
|
`onExport` the text is handed over instead. */
|
|
301
|
-
export declare interface ExportProps {
|
|
345
|
+
export declare interface ExportProps<R = string> extends Omit<ButtonProps, "size" | "children" | "onClick" | "variant" | "loading"> {
|
|
346
|
+
/** What is written: `csv`, or a format of one's own.
|
|
347
|
+
@default csv */
|
|
348
|
+
format?: ExportFormat<R>;
|
|
302
349
|
/** File name of the download.
|
|
303
|
-
@default the wording's "table.csv" */
|
|
350
|
+
@default the base of the wording's "table.csv" with the format's extension */
|
|
304
351
|
filename?: string;
|
|
305
|
-
/** Gets the
|
|
306
|
-
onExport?: (
|
|
352
|
+
/** Gets what the format wrote instead of triggering a file. */
|
|
353
|
+
onExport?: (content: R) => void;
|
|
354
|
+
/** The button's text.
|
|
355
|
+
@default the wording's export label */
|
|
356
|
+
label?: ReactNode;
|
|
307
357
|
/** The size of the part: `sm` or `md`.
|
|
308
358
|
@default the size of the toolbar it stands in, `"sm"` outside one */
|
|
309
359
|
size?: ToolbarSize;
|
|
@@ -311,6 +361,18 @@ export declare interface ExportProps {
|
|
|
311
361
|
of?: TableRef;
|
|
312
362
|
}
|
|
313
363
|
|
|
364
|
+
/** What a format writes: the header labels, the widths the table holds, whether
|
|
365
|
+
a column's own `exportValue` made its values (`own`: written as they come),
|
|
366
|
+
and the rows as typed cells. A tree's level is its first column, a number. */
|
|
367
|
+
export declare interface ExportSheet {
|
|
368
|
+
columns: readonly {
|
|
369
|
+
label: string;
|
|
370
|
+
width?: number;
|
|
371
|
+
own?: true;
|
|
372
|
+
}[];
|
|
373
|
+
rows: readonly (readonly ExportCell[])[];
|
|
374
|
+
}
|
|
375
|
+
|
|
314
376
|
/** The field names of a row. */
|
|
315
377
|
export declare type Field<Z> = Extract<keyof Z, string>;
|
|
316
378
|
|
|
@@ -451,10 +513,9 @@ export declare type NumberField<Z> = {
|
|
|
451
513
|
[K in Field<Z>]: Z[K] extends number | Absent ? K : never;
|
|
452
514
|
}[Field<Z>];
|
|
453
515
|
|
|
454
|
-
/**
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
};
|
|
516
|
+
/** How a number column is written: `"percent"`, `"count"`, or Intl's number
|
|
517
|
+
options plus `decimals`; the same shape as core's `NumberFormat`. */
|
|
518
|
+
export declare type NumberFormat = "percent" | "count" | NumberOptions;
|
|
458
519
|
|
|
459
520
|
/** An aggregate of one's own: the values present and the group's rows. */
|
|
460
521
|
export declare type OwnAggregate<Z = never> = (values: readonly unknown[], rows: readonly Z[]) => unknown;
|
|
@@ -465,10 +526,10 @@ export declare type OwnAggregate<Z = never> = (values: readonly unknown[], rows:
|
|
|
465
526
|
`pageSize` holds as soon as a pagination bar stands. Whoever places it
|
|
466
527
|
outside the table puts it before the table: after it, it registers only
|
|
467
528
|
after the first frame. */
|
|
468
|
-
export declare function Pagination({ pageSizes, className, of }: PaginationProps): JSX.Element | null;
|
|
529
|
+
export declare function Pagination({ pageSizes, className, of, ...rest }: PaginationProps): JSX.Element | null;
|
|
469
530
|
|
|
470
531
|
/** The props of `Pagination`. */
|
|
471
|
-
export declare interface PaginationProps {
|
|
532
|
+
export declare interface PaginationProps extends Omit<HTMLAttributes<HTMLElement>, "children">, RefProp<HTMLElement> {
|
|
472
533
|
/** The selectable page sizes. */
|
|
473
534
|
pageSizes?: readonly number[];
|
|
474
535
|
/** Classes on the pagination bar. */
|
|
@@ -576,11 +637,13 @@ export declare interface RowSave<Z> {
|
|
|
576
637
|
|
|
577
638
|
/** The table's search field: one text over every column that searches, in
|
|
578
639
|
the table toolbar. With a search the table puts up a toolbar of its own
|
|
579
|
-
where none stands. Outside the table it needs `of`.
|
|
580
|
-
|
|
640
|
+
where none stands. Outside the table it needs `of`. In server mode typing is
|
|
641
|
+
reported to `onRequest` after a pause of 300 ms without a keystroke; Enter,
|
|
642
|
+
an emptied field, `setSearch` and any other change of the request report at once. */
|
|
643
|
+
export declare function Search({ placeholder, "aria-label": name, className, size: own, grow, of, ...rest }: SearchProps): JSX.Element | null;
|
|
581
644
|
|
|
582
645
|
/** The props of `Search`. */
|
|
583
|
-
export declare interface SearchProps {
|
|
646
|
+
export declare interface SearchProps extends Omit<InputProps, "size" | "type" | "value" | "onChange" | "clearable" | "onClear" | "children" | "invalid" | "numeric"> {
|
|
584
647
|
/** The placeholder in the field.
|
|
585
648
|
@default the wording's "Search …" */
|
|
586
649
|
placeholder?: string;
|
|
@@ -601,10 +664,12 @@ export declare interface SearchProps {
|
|
|
601
664
|
|
|
602
665
|
/** Server mode: the rows are the page a server answered for the request the
|
|
603
666
|
table reported. The table searches, filters, sorts, groups and pages nothing of
|
|
604
|
-
its own;
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
667
|
+
its own; there is no grouping. After a full page is ticked, select all
|
|
668
|
+
offers every row that matches, as a state a bulk action receives as
|
|
669
|
+
`AllMatching`; the export writes every match when `exportRows` is given and
|
|
670
|
+
the page, saying so, when it is not; the footer shows `totals` or nothing,
|
|
671
|
+
since a sum over one page would be called the sum. */
|
|
672
|
+
declare interface ServerMode<Z> {
|
|
608
673
|
/** Server mode: the rows are one page a server answered. */
|
|
609
674
|
server: true;
|
|
610
675
|
childRows?: never;
|
|
@@ -617,9 +682,38 @@ declare interface ServerMode {
|
|
|
617
682
|
the five present - a width, an order, a pin, a fold or a hidden column
|
|
618
683
|
asks the server nothing; `onViewChange` hears those. */
|
|
619
684
|
onRequest: (request: TableRequest) => void;
|
|
685
|
+
/** The request the rows answer. While it is not the table's current request
|
|
686
|
+
(compared by key) the table is busy as `loading` makes it: the rows dim,
|
|
687
|
+
take no pointer and `aria-busy` is set, while the search, the conditions
|
|
688
|
+
and the page already show the new request - so an answer that comes late
|
|
689
|
+
never stands as current. Without it the rows are taken as the current
|
|
690
|
+
answer. In development the table warns once when it has matched none of
|
|
691
|
+
the requests it reported. */
|
|
692
|
+
answers?: TableRequest;
|
|
693
|
+
/** The failure of the fetch, a message the application wrote: it stands in
|
|
694
|
+
place of the rows, in the height of a page, with "Try again", which calls
|
|
695
|
+
`onRequest` with the current request once more. With `answers` it is the
|
|
696
|
+
failure of that request and shows only while it is the current one;
|
|
697
|
+
without, as soon as it is set. It wins over `loading`. The table clears
|
|
698
|
+
nothing - the application does, usually in `onRequest`. */
|
|
699
|
+
error?: string;
|
|
700
|
+
/** By column id, the value of the column's declared `aggregate` over every
|
|
701
|
+
match - handed in beside `rows` and current when `answers` is. The footer
|
|
702
|
+
shows when this is passed and a column declares an `aggregate`; its cells
|
|
703
|
+
take the value instead of computing it, formatted with the column's
|
|
704
|
+
format (a `range` is `[min, max]`; every kind and an aggregate of one's
|
|
705
|
+
own are taken as given). A missing key shows the absent value; while the
|
|
706
|
+
table is busy the cells are skeleton. Without it there is no footer. */
|
|
707
|
+
totals?: Readonly<Record<string, unknown>>;
|
|
620
708
|
/** The values a list filter offers for a column, `null` for an absent one -
|
|
621
709
|
the table cannot count what it does not hold. */
|
|
622
710
|
filterOptions?: (column: string) => readonly unknown[];
|
|
711
|
+
/** Every row of a request, for the export: `Export` hands over the current
|
|
712
|
+
request unchanged and writes what comes back in the visible columns. The
|
|
713
|
+
application ignores `page` and `pageSize`, keeps the sort, and caps or
|
|
714
|
+
refuses a set that is too large - a rejection's message shows beside the
|
|
715
|
+
button. Without it `Export` writes the page. */
|
|
716
|
+
exportRows?: (request: TableRequest) => Promise<readonly Z[]>;
|
|
623
717
|
}
|
|
624
718
|
|
|
625
719
|
/** Sets a condition from outside. Typed at the field of the row, not at the
|
|
@@ -646,14 +740,18 @@ export declare interface SortLevel<K extends string = string> {
|
|
|
646
740
|
|
|
647
741
|
/** What `useTable` returns: the table's state, and its parts typed at the
|
|
648
742
|
row. Pass it as `of` to a part that stands outside the table. */
|
|
649
|
-
export declare interface Table<Z> extends TableSnapshot<Z> {
|
|
743
|
+
export declare interface Table<Z, S extends boolean = false> extends TableSnapshot<Z> {
|
|
650
744
|
Table: (props: TableProps<Z>) => ReactNode;
|
|
651
745
|
Column: ColumnComponent<Z>;
|
|
652
746
|
VerdictColumn: VerdictColumnComponent<Z>;
|
|
653
747
|
RowDetail: (props: RowDetailProps<Z>) => ReactNode;
|
|
654
748
|
RowActions: (props: RowActionsProps) => ReactNode;
|
|
655
|
-
Action: (props: ActionProps<Z>) => ReactNode;
|
|
749
|
+
Action: (props: ActionProps<Z, S>) => ReactNode;
|
|
656
750
|
GroupBy: GroupByComponent<Z>;
|
|
751
|
+
/** Brings the row with this key into view and returns `true`: in a paged table its page, in a scroll area, virtual or not, the scroll to it. `false`, with nothing changed, for a key the table does not have, a row a search, a condition or the `preFilter` hides, a row inside a folded group or branch, or a table not mounted; nothing is unfolded and no filter cleared. In server mode it reaches the rows of the page it holds. */
|
|
752
|
+
scrollToRow: (key: string) => boolean;
|
|
753
|
+
/** In grid mode, brings the row into view as `scrollToRow` does, makes the cell of that row and column the Active cell and moves the focus to it. Outside grid mode, for a column the table does not show, and wherever `scrollToRow` returns `false`, it returns `false` and changes nothing. */
|
|
754
|
+
focusCell: (key: string, column: string) => boolean;
|
|
657
755
|
}
|
|
658
756
|
|
|
659
757
|
/** The view's state the model computes a table from, beside its rows and
|
|
@@ -694,7 +792,7 @@ export declare interface TableInput<Z = unknown, K extends string = string> {
|
|
|
694
792
|
}
|
|
695
793
|
|
|
696
794
|
/** The options of `useTable`: automatic, or in server mode over a server's rows. */
|
|
697
|
-
export declare type TableOptions<Z> = TableOptionsCommon<Z> & (AutomaticMode<Z> | ServerMode);
|
|
795
|
+
export declare type TableOptions<Z> = TableOptionsCommon<Z> & (AutomaticMode<Z> | ServerMode<Z>);
|
|
698
796
|
|
|
699
797
|
declare interface TableOptionsCommon<Z> {
|
|
700
798
|
/** A stable key per row – the basis of selection and expansion. */
|
|
@@ -741,7 +839,7 @@ declare interface TableOptionsCommon<Z> {
|
|
|
741
839
|
|
|
742
840
|
/** The props of `Table`: how the table looks and behaves. Its state comes from
|
|
743
841
|
`useTable`, its columns from the JSX inside it. */
|
|
744
|
-
export declare interface TableProps<Z> {
|
|
842
|
+
export declare interface TableProps<Z> extends Omit<HTMLAttributes<HTMLDivElement>, "children">, RefProp<HTMLDivElement> {
|
|
745
843
|
/** Adds the selection column. "All" means: the filtered set. */
|
|
746
844
|
selectable?: boolean;
|
|
747
845
|
/** Keeps the header row visible while scrolling. */
|
|
@@ -763,10 +861,19 @@ export declare interface TableProps<Z> {
|
|
|
763
861
|
loading?: boolean;
|
|
764
862
|
/** Classes and data attributes per row. */
|
|
765
863
|
rowProps?: (row: Z) => RowAttributes;
|
|
766
|
-
/**
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
864
|
+
/** The key of the row the rest of the screen follows - the table marks it
|
|
865
|
+
with `aria-current` and an accent bar, apart from the selection. The table
|
|
866
|
+
keeps no copy: pass the key you hold, `null` for none. */
|
|
867
|
+
currentRow?: string | null;
|
|
868
|
+
/** A primary click on a row, outside its controls - the checkbox, the
|
|
869
|
+
expander, the actions and any button of yours in a cell - with the row's
|
|
870
|
+
key and the row. Also called for the row already current, so that you
|
|
871
|
+
decide whether a second click clears it. By the keyboard: in a native
|
|
872
|
+
table the content of the row-header cell becomes a button (Enter and
|
|
873
|
+
Space), so a control of your own in that cell would stand inside it; in
|
|
874
|
+
grid mode Enter on a cell with nothing to edit or enter. Without a
|
|
875
|
+
`rowHeader` column the keyboard cannot choose a row. */
|
|
876
|
+
onCurrentRowChange?: (key: string, row: Z) => void;
|
|
770
877
|
/** `false`: the user cannot group this table - the column menu offers no
|
|
771
878
|
grouping, and a grouping handed in is passed over. */
|
|
772
879
|
groupable?: boolean;
|
|
@@ -831,6 +938,15 @@ export declare interface TableSelection<T extends string | number> {
|
|
|
831
938
|
allSelected: boolean;
|
|
832
939
|
/** true when some - but not all - are selected. */
|
|
833
940
|
someSelected: boolean;
|
|
941
|
+
/** Every row that matches is selected, those on no page held included. While
|
|
942
|
+
it stands `selected` is empty and `count` is 0, and `isSelected(id)` is
|
|
943
|
+
`!except.has(id)`. Store it with the keys when the selection is held
|
|
944
|
+
outside. */
|
|
945
|
+
allMatching: boolean;
|
|
946
|
+
/** While `allMatching`: the keys unticked since. */
|
|
947
|
+
except: ReadonlySet<T>;
|
|
948
|
+
/** Selects all that match; the keys selected before are dropped. */
|
|
949
|
+
selectMatching: () => void;
|
|
834
950
|
count: number;
|
|
835
951
|
}
|
|
836
952
|
|
|
@@ -925,6 +1041,10 @@ export declare interface TableSnapshot<Z> {
|
|
|
925
1041
|
/** The filtered set in the visible columns as text for a spreadsheet - in
|
|
926
1042
|
server mode the page. */
|
|
927
1043
|
asCsv: () => string;
|
|
1044
|
+
/** The same rows and columns written by a format: `csv` for text, a format
|
|
1045
|
+
of one's own for anything else. `asCsv()` is `exportAs(csv)`. With
|
|
1046
|
+
`rows`, those rows instead of the filtered set. */
|
|
1047
|
+
exportAs<R>(format: ExportFormat<R>, rows?: readonly Z[]): R;
|
|
928
1048
|
/** The selected rows within the filtered set as tab-separated text under a
|
|
929
1049
|
header line - the text Ctrl+C writes. `""` with nothing selected. */
|
|
930
1050
|
selectionAsText: () => string;
|
|
@@ -934,6 +1054,9 @@ export declare interface TableSnapshot<Z> {
|
|
|
934
1054
|
rowCount: number;
|
|
935
1055
|
/** Whether it is in server mode: the rows are one page of a server's. */
|
|
936
1056
|
server: boolean;
|
|
1057
|
+
/** Server mode: the request `onRequest` last received, or is about to;
|
|
1058
|
+
`null` outside it. */
|
|
1059
|
+
request: TableRequest | null;
|
|
937
1060
|
}
|
|
938
1061
|
|
|
939
1062
|
/** Search, conditions, sort levels, page, page size, hidden columns, order,
|
|
@@ -969,10 +1092,10 @@ export declare interface TableView<K extends string = string> {
|
|
|
969
1092
|
rows and "reset" as long as something restricts, and the count of the
|
|
970
1093
|
selection with the bulk actions. A table with a search or a column filter
|
|
971
1094
|
has one, even where none stands; where one stands, there is no second. */
|
|
972
|
-
export declare function Toolbar({ children, className, size, of }: ToolbarProps): JSX.Element;
|
|
1095
|
+
export declare function Toolbar({ children, className, size, of, ref, ...rest }: ToolbarProps): JSX.Element;
|
|
973
1096
|
|
|
974
1097
|
/** The props of `Toolbar`. */
|
|
975
|
-
export declare interface ToolbarProps {
|
|
1098
|
+
export declare interface ToolbarProps extends Omit<HTMLAttributes<HTMLDivElement>, "children">, RefProp<HTMLDivElement> {
|
|
976
1099
|
/** Search, column menu, export – on the left in the table toolbar, before the conditions. */
|
|
977
1100
|
children?: ReactNode;
|
|
978
1101
|
/** Classes on the table toolbar. */
|
|
@@ -1015,6 +1138,10 @@ export declare interface TreeInput<Z> {
|
|
|
1015
1138
|
@returns The table's state and its parts: `Table`, `Column`,
|
|
1016
1139
|
`VerdictColumn`, `RowDetail`, `RowActions`, `Action` and `GroupBy`. Pass it
|
|
1017
1140
|
as `of` to a part that stands outside the table. */
|
|
1141
|
+
export declare function useTable<Z>(rows: readonly Z[], options: Extract<TableOptions<Z>, {
|
|
1142
|
+
server: true;
|
|
1143
|
+
}>): Table<Z, true>;
|
|
1144
|
+
|
|
1018
1145
|
export declare function useTable<Z>(rows: readonly Z[], options: TableOptions<Z>): Table<Z>;
|
|
1019
1146
|
|
|
1020
1147
|
/**
|