@seekalfred/primitives 0.7.3 → 0.8.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/README.md +315 -4
- package/dist/alert/alert.d.ts +2 -2
- package/dist/alert/alert.js +1 -1
- package/dist/alert/alert.js.map +1 -1
- package/dist/alert-dialog/alert-dialog.d.ts +14 -0
- package/dist/alert-dialog/alert-dialog.js +52 -27
- package/dist/alert-dialog/alert-dialog.js.map +1 -1
- package/dist/announcement-bar/announcement-bar.d.ts +15 -4
- package/dist/announcement-bar/announcement-bar.js +31 -6
- package/dist/announcement-bar/announcement-bar.js.map +1 -1
- package/dist/avatar/avatar.d.ts +7 -0
- package/dist/avatar/avatar.js +33 -12
- package/dist/avatar/avatar.js.map +1 -1
- package/dist/badge/badge.d.ts +16 -1
- package/dist/badge/badge.js +12 -5
- package/dist/badge/badge.js.map +1 -1
- package/dist/bar-chart/bar-chart-series.d.ts +75 -0
- package/dist/bar-chart/bar-chart-series.js +401 -0
- package/dist/bar-chart/bar-chart-series.js.map +1 -0
- package/dist/bar-chart/bar-chart.d.ts +25 -1
- package/dist/bar-chart/bar-chart.js +26 -1
- package/dist/bar-chart/bar-chart.js.map +1 -1
- package/dist/bar-chart/index.d.ts +2 -1
- package/dist/button/button.d.ts +24 -2
- package/dist/button/button.js +62 -13
- package/dist/button/button.js.map +1 -1
- package/dist/card/card.js +1 -1
- package/dist/card/card.js.map +1 -1
- package/dist/checkbox/checkbox.d.ts +25 -1
- package/dist/checkbox/checkbox.js +103 -28
- package/dist/checkbox/checkbox.js.map +1 -1
- package/dist/checkbox/index.d.ts +2 -2
- package/dist/checkbox/index.js +2 -2
- package/dist/chip-group/chip-group.d.ts +11 -0
- package/dist/chip-group/chip-group.js +50 -34
- package/dist/chip-group/chip-group.js.map +1 -1
- package/dist/chip-group/index.d.ts +2 -2
- package/dist/code-block/code-block.d.ts +45 -0
- package/dist/code-block/code-block.js +74 -0
- package/dist/code-block/code-block.js.map +1 -0
- package/dist/code-block/index.d.ts +2 -0
- package/dist/code-block/index.js +2 -0
- package/dist/command-palette/command-palette.d.ts +128 -0
- package/dist/command-palette/command-palette.js +371 -0
- package/dist/command-palette/command-palette.js.map +1 -0
- package/dist/command-palette/index.d.ts +2 -0
- package/dist/command-palette/index.js +2 -0
- package/dist/copy-button/copy-button.d.ts +19 -3
- package/dist/copy-button/copy-button.js +7 -4
- package/dist/copy-button/copy-button.js.map +1 -1
- package/dist/dialog/dialog.js +1 -1
- package/dist/dialog/dialog.js.map +1 -1
- package/dist/empty-state/empty-state.d.ts +17 -0
- package/dist/empty-state/empty-state.js +9 -7
- package/dist/empty-state/empty-state.js.map +1 -1
- package/dist/file-drop-zone/file-drop-zone.d.ts +29 -3
- package/dist/file-drop-zone/file-drop-zone.js +26 -8
- package/dist/file-drop-zone/file-drop-zone.js.map +1 -1
- package/dist/gauge/gauge.d.ts +18 -1
- package/dist/gauge/gauge.js +35 -21
- package/dist/gauge/gauge.js.map +1 -1
- package/dist/gauge/index.d.ts +2 -2
- package/dist/index.d.ts +14 -9
- package/dist/index.js +14 -10
- package/dist/info-tooltip/index.d.ts +2 -0
- package/dist/info-tooltip/index.js +2 -0
- package/dist/info-tooltip/info-tooltip.d.ts +35 -0
- package/dist/info-tooltip/info-tooltip.js +49 -0
- package/dist/info-tooltip/info-tooltip.js.map +1 -0
- package/dist/input/input.d.ts +7 -0
- package/dist/input/input.js +4 -2
- package/dist/input/input.js.map +1 -1
- package/dist/lib/field-shell.js +2 -6
- package/dist/lib/field-shell.js.map +1 -1
- package/dist/lib/required-marker.js +20 -0
- package/dist/lib/required-marker.js.map +1 -0
- package/dist/lib/selection-control.js +32 -1
- package/dist/lib/selection-control.js.map +1 -1
- package/dist/line-chart/index.d.ts +2 -2
- package/dist/line-chart/line-chart.d.ts +106 -3
- package/dist/line-chart/line-chart.js +185 -46
- package/dist/line-chart/line-chart.js.map +1 -1
- package/dist/mention-input/mention-input.js +1 -1
- package/dist/money-input/index.d.ts +2 -2
- package/dist/money-input/money-input.d.ts +14 -0
- package/dist/money-input/money-input.js +17 -7
- package/dist/money-input/money-input.js.map +1 -1
- package/dist/morph-select/morph-select.d.ts +8 -1
- package/dist/morph-select/morph-select.js +8 -5
- package/dist/morph-select/morph-select.js.map +1 -1
- package/dist/multi-select/multi-select.d.ts +31 -0
- package/dist/multi-select/multi-select.js +123 -6
- package/dist/multi-select/multi-select.js.map +1 -1
- package/dist/number-field/number-field.js +1 -1
- package/dist/password-field/password-field.js +1 -1
- package/dist/password-strength/password-strength.js +1 -1
- package/dist/phone-input/phone-input.js +1 -1
- package/dist/popover/popover.js +1 -1
- package/dist/popover/popover.js.map +1 -1
- package/dist/progress/index.d.ts +2 -2
- package/dist/progress/index.js +2 -2
- package/dist/progress/progress.d.ts +53 -2
- package/dist/progress/progress.js +146 -36
- package/dist/progress/progress.js.map +1 -1
- package/dist/radio-group/radio-group.d.ts +12 -3
- package/dist/radio-group/radio-group.js +62 -52
- package/dist/radio-group/radio-group.js.map +1 -1
- package/dist/rich-text-editor/rich-text-editor.js +1 -1
- package/dist/scroll-area/scroll-area.d.ts +1 -1
- package/dist/scrub-input/scrub-input.d.ts +11 -1
- package/dist/scrub-input/scrub-input.js +22 -10
- package/dist/scrub-input/scrub-input.js.map +1 -1
- package/dist/search-field/search-field.js +1 -1
- package/dist/select/select.d.ts +10 -1
- package/dist/select/select.js +4 -3
- package/dist/select/select.js.map +1 -1
- package/dist/separator/separator.d.ts +1 -1
- package/dist/shortcut-recorder/shortcut-recorder.js +1 -1
- package/dist/sparkline/sparkline.d.ts +27 -2
- package/dist/sparkline/sparkline.js +115 -18
- package/dist/sparkline/sparkline.js.map +1 -1
- package/dist/stat-card/index.d.ts +2 -2
- package/dist/stat-card/index.js +2 -2
- package/dist/stat-card/stat-card.d.ts +32 -1
- package/dist/stat-card/stat-card.js +52 -9
- package/dist/stat-card/stat-card.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/table/index.d.ts +2 -2
- package/dist/table/index.js +2 -2
- package/dist/table/table.d.ts +211 -3
- package/dist/table/table.js +473 -93
- package/dist/table/table.js.map +1 -1
- package/dist/tabs/tabs.d.ts +4 -2
- package/dist/tabs/tabs.js +7 -5
- package/dist/tabs/tabs.js.map +1 -1
- package/dist/tag-input/tag-input.js +1 -1
- package/dist/text-shimmer/text-shimmer.d.ts +18 -2
- package/dist/text-shimmer/text-shimmer.js +5 -2
- package/dist/text-shimmer/text-shimmer.js.map +1 -1
- package/dist/textarea/textarea.d.ts +7 -0
- package/dist/textarea/textarea.js +4 -2
- package/dist/textarea/textarea.js.map +1 -1
- package/dist/toast/toast.d.ts +2 -2
- package/dist/toggle-button/index.d.ts +2 -0
- package/dist/toggle-button/index.js +2 -0
- package/dist/toggle-button/toggle-button.d.ts +93 -0
- package/dist/toggle-button/toggle-button.js +199 -0
- package/dist/toggle-button/toggle-button.js.map +1 -0
- package/package.json +19 -3
package/dist/table/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Column, RowKey, Table, TableProps, createColumns, tableCardVariants, tableCellVariants, tableColumnVariants, tableEmptyVariants, tableFooterVariants, tableHeaderVariants, tablePaginationVariants, tableRowVariants, tableScrollVariants, tableSelectionBarVariants, tableStickyCellVariants, tableVariants } from "./table.js";
|
|
2
|
-
export { type Column, type RowKey, Table, type TableProps, createColumns, tableCardVariants, tableCellVariants, tableColumnVariants, tableEmptyVariants, tableFooterVariants, tableHeaderVariants, tablePaginationVariants, tableRowVariants, tableScrollVariants, tableSelectionBarVariants, tableStickyCellVariants, tableVariants };
|
|
1
|
+
import { Column, RowAttributes, RowKey, Table, TableProps, createColumns, tableCardVariants, tableCellVariants, tableColumnVariants, tableDetailCellVariants, tableDetailRowVariants, tableEmptyVariants, tableExpandButtonVariants, tableFooterVariants, tableGroupRowVariants, tableHeaderVariants, tablePaginationVariants, tableRowVariants, tableScrollVariants, tableSelectionBarVariants, tableSortButtonVariants, tableStickyCellVariants, tableVariants } from "./table.js";
|
|
2
|
+
export { type Column, type RowAttributes, type RowKey, Table, type TableProps, createColumns, tableCardVariants, tableCellVariants, tableColumnVariants, tableDetailCellVariants, tableDetailRowVariants, tableEmptyVariants, tableExpandButtonVariants, tableFooterVariants, tableGroupRowVariants, tableHeaderVariants, tablePaginationVariants, tableRowVariants, tableScrollVariants, tableSelectionBarVariants, tableSortButtonVariants, tableStickyCellVariants, tableVariants };
|
package/dist/table/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Table, createColumns, tableCardVariants, tableCellVariants, tableColumnVariants, tableEmptyVariants, tableFooterVariants, tableHeaderVariants, tablePaginationVariants, tableRowVariants, tableScrollVariants, tableSelectionBarVariants, tableStickyCellVariants, tableVariants } from "./table.js";
|
|
2
|
-
export { Table, createColumns, tableCardVariants, tableCellVariants, tableColumnVariants, tableEmptyVariants, tableFooterVariants, tableHeaderVariants, tablePaginationVariants, tableRowVariants, tableScrollVariants, tableSelectionBarVariants, tableStickyCellVariants, tableVariants };
|
|
1
|
+
import { Table, createColumns, tableCardVariants, tableCellVariants, tableColumnVariants, tableDetailCellVariants, tableDetailRowVariants, tableEmptyVariants, tableExpandButtonVariants, tableFooterVariants, tableGroupRowVariants, tableHeaderVariants, tablePaginationVariants, tableRowVariants, tableScrollVariants, tableSelectionBarVariants, tableSortButtonVariants, tableStickyCellVariants, tableVariants } from "./table.js";
|
|
2
|
+
export { Table, createColumns, tableCardVariants, tableCellVariants, tableColumnVariants, tableDetailCellVariants, tableDetailRowVariants, tableEmptyVariants, tableExpandButtonVariants, tableFooterVariants, tableGroupRowVariants, tableHeaderVariants, tablePaginationVariants, tableRowVariants, tableScrollVariants, tableSelectionBarVariants, tableSortButtonVariants, tableStickyCellVariants, tableVariants };
|
package/dist/table/table.d.ts
CHANGED
|
@@ -64,11 +64,13 @@ import { Selection, SortDescriptor } from "react-aria-components";
|
|
|
64
64
|
* shadow stays off and the sticky column's own divider does that job.
|
|
65
65
|
*/
|
|
66
66
|
export declare const tableCardVariants: (props?: ({
|
|
67
|
-
frame?: "
|
|
67
|
+
frame?: "card" | "none" | null | undefined;
|
|
68
68
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
69
69
|
/** The horizontal scroll container. The table owns it; 5 of 6 consumers built one by hand. */
|
|
70
70
|
export declare const tableScrollVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
71
|
-
export declare const tableVariants: (props?:
|
|
71
|
+
export declare const tableVariants: (props?: ({
|
|
72
|
+
density?: "default" | "compact" | null | undefined;
|
|
73
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
72
74
|
/**
|
|
73
75
|
* The header is near-white, not a grey band.
|
|
74
76
|
*
|
|
@@ -99,8 +101,45 @@ export declare const tableEmptyVariants: (props?: import("class-variance-authori
|
|
|
99
101
|
export declare const tableFooterVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
100
102
|
export declare const tableColumnVariants: (props?: ({
|
|
101
103
|
align?: "center" | "start" | "end" | null | undefined;
|
|
104
|
+
density?: "default" | "compact" | null | undefined;
|
|
105
|
+
hidden?: boolean | null | undefined;
|
|
102
106
|
headerType?: "sentence" | "caps" | null | undefined;
|
|
103
107
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
108
|
+
/**
|
|
109
|
+
* The disclosure button that opens a row's sub-rows (`getSubRows`).
|
|
110
|
+
*
|
|
111
|
+
* A real button in the first cell, named by that cell's own content and
|
|
112
|
+
* carrying `aria-expanded`, so a reader hears "Meta, button, collapsed"
|
|
113
|
+
* without the library inventing copy. 24px square: the WCAG 2.2 target-size
|
|
114
|
+
* floor (2.5.8), and the step each level of sub-rows is indented by, so a
|
|
115
|
+
* child's text lines up one button-width in from its parent's. The chevron
|
|
116
|
+
* turns a quarter when the row opens; with reduced motion it simply flips.
|
|
117
|
+
*/
|
|
118
|
+
export declare const tableExpandButtonVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
119
|
+
/**
|
|
120
|
+
* A group header row (`isGroupRow`): one cell spanning the row, naming the rows
|
|
121
|
+
* under it ("Mobile" / "Desktop"). The header band's fill and label type, so it
|
|
122
|
+
* reads as a heading of the rows that follow rather than as one of them.
|
|
123
|
+
*/
|
|
124
|
+
export declare const tableGroupRowVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
125
|
+
/**
|
|
126
|
+
* A detail row (`renderExpandedRow`): one cell spanning the row, under the row it
|
|
127
|
+
* belongs to. Not interactive, so it takes no hover, focus or selection fill and
|
|
128
|
+
* no rule of its own: it reads as part of the row above, and the next row's rule
|
|
129
|
+
* closes it.
|
|
130
|
+
*/
|
|
131
|
+
export declare const tableDetailRowVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
132
|
+
/** The cell of a detail row. The table's own inset, so the content is not flush against the edge. */
|
|
133
|
+
export declare const tableDetailCellVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
134
|
+
/**
|
|
135
|
+
* The sort control of a column header in a plain table (`keyboardModel="table"`).
|
|
136
|
+
*
|
|
137
|
+
* In the grid the header cell is the control; in a plain table a cell cannot
|
|
138
|
+
* take focus, so the label sits in a real button that Tab reaches. It wears
|
|
139
|
+
* the header's own type and colour, and is at least 24px tall so a compact
|
|
140
|
+
* header still clears the WCAG 2.2 target size (2.5.8).
|
|
141
|
+
*/
|
|
142
|
+
export declare const tableSortButtonVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
104
143
|
export declare const tableRowVariants: (props?: ({
|
|
105
144
|
variant?: "plain" | "lined" | null | undefined;
|
|
106
145
|
striped?: boolean | null | undefined;
|
|
@@ -108,6 +147,7 @@ export declare const tableRowVariants: (props?: ({
|
|
|
108
147
|
export declare const tableCellVariants: (props?: ({
|
|
109
148
|
align?: "center" | "start" | "end" | null | undefined;
|
|
110
149
|
numeric?: boolean | null | undefined;
|
|
150
|
+
density?: "default" | "compact" | null | undefined;
|
|
111
151
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
112
152
|
/**
|
|
113
153
|
* The first cell of every row, held in place while the rest scroll under it
|
|
@@ -150,11 +190,26 @@ type Column$1<T, V = unknown> = {
|
|
|
150
190
|
* bivariantly, which is precisely the semantics a heterogeneous collection
|
|
151
191
|
* needs. The alternative is `Column<T, any>`, and this package has no
|
|
152
192
|
* eslint-disable in it anywhere.
|
|
193
|
+
*
|
|
194
|
+
* `index` is the row's position among its siblings (on the current page, in
|
|
195
|
+
* the current sort order), so with `getSubRows` a sub-row counts from 0 under
|
|
196
|
+
* its parent and opening a row never renumbers the rows below it.
|
|
153
197
|
*/
|
|
154
198
|
cell?(ctx: {
|
|
155
199
|
value: V;
|
|
156
200
|
row: T;
|
|
157
201
|
index: number;
|
|
202
|
+
/**
|
|
203
|
+
* Whether the row is in the table's expanded set (`expandedKeys`). True for a
|
|
204
|
+
* row opened onto sub-rows or onto a detail row (`renderExpandedRow`).
|
|
205
|
+
*/
|
|
206
|
+
isExpanded: boolean;
|
|
207
|
+
/**
|
|
208
|
+
* Opens the row if it is closed and closes it if it is open, through the same
|
|
209
|
+
* set as `expandedKeys` / `onExpandedChange`. For a trigger of your own in a
|
|
210
|
+
* cell (a "History" button), which is how a detail row is opened.
|
|
211
|
+
*/
|
|
212
|
+
toggleExpanded: () => void;
|
|
158
213
|
}): ReactNode;
|
|
159
214
|
/**
|
|
160
215
|
* Value to string. Deliberately separate from `cell`: this is what CSV
|
|
@@ -186,13 +241,60 @@ type Column$1<T, V = unknown> = {
|
|
|
186
241
|
numeric?: boolean;
|
|
187
242
|
/** Opts this column into sorting. Off by default. */
|
|
188
243
|
sortable?: boolean;
|
|
244
|
+
/**
|
|
245
|
+
* Makes this cell span the columns after it, per row: return how many columns
|
|
246
|
+
* the row's cell in this column covers (1 or nothing is the usual single
|
|
247
|
+
* cell). The cells it covers are not rendered, so `cell` renders for THIS
|
|
248
|
+
* column alone and its content is what fills the span ("No impressions yet"
|
|
249
|
+
* across clicks and CTR; "Not enough data" across five figure columns).
|
|
250
|
+
*
|
|
251
|
+
* The span is clamped to the columns that are left, so it can never run past
|
|
252
|
+
* the row. A row's span never touches the header, which keeps one cell per
|
|
253
|
+
* column, so columns stay named and sortable. It is ignored on the first
|
|
254
|
+
* column while `stickyFirstColumn` is on (the frozen pane stays one column
|
|
255
|
+
* wide) and on group rows (`isGroupRow`), whose first cell already spans the
|
|
256
|
+
* row.
|
|
257
|
+
*
|
|
258
|
+
* Method syntax, for the same reason as `cell`.
|
|
259
|
+
*/
|
|
260
|
+
colSpan?(row: T): number | undefined;
|
|
261
|
+
/**
|
|
262
|
+
* Content after the header label that is NOT part of the sort control: an
|
|
263
|
+
* info icon with a tooltip, a help link. It sits beside the label, so on a
|
|
264
|
+
* sortable column clicking or pressing Enter or Space on it does not sort,
|
|
265
|
+
* and in a plain table (`keyboardModel="table"`) it is a sibling of the sort
|
|
266
|
+
* button rather than inside it. It must name itself (`aria-label`) and be at
|
|
267
|
+
* least 24px square, like any control. Not rendered with `headerHidden`.
|
|
268
|
+
*/
|
|
269
|
+
headerAddon?: ReactNode;
|
|
270
|
+
/**
|
|
271
|
+
* Marks this column as the one to look at (the latest run, the current
|
|
272
|
+
* plan): its header and every cell wear the library's highlight tint and
|
|
273
|
+
* carry `data-highlighted`, and the header takes the stronger text colour.
|
|
274
|
+
* The tint is not the message, so the column should say why in its own
|
|
275
|
+
* content, as with `isRowHighlighted`. Off by default.
|
|
276
|
+
*/
|
|
277
|
+
highlighted?: boolean;
|
|
189
278
|
};
|
|
279
|
+
/**
|
|
280
|
+
* What `getRowProps` may return: `data-*` attributes. Anything else is ignored.
|
|
281
|
+
*
|
|
282
|
+
* Not `aria-*`: React Aria's Row filters its props down to `data-*` and its own
|
|
283
|
+
* labelling, so an `aria-current` handed to a grid row is dropped with no error
|
|
284
|
+
* -- the same silent loss as `Column.width`. A type that allowed it would lie.
|
|
285
|
+
* Not `onClick` either -- see `onRowAction`.
|
|
286
|
+
*/
|
|
287
|
+
export type RowAttributes = { [K in `data-${string}`]?: string | number | boolean | undefined; };
|
|
190
288
|
export interface TableProps<T> extends VariantProps<typeof tableRowVariants> {
|
|
191
289
|
/** The rows to render. */
|
|
192
290
|
data: readonly T[];
|
|
193
291
|
/** The columns, in display order. */
|
|
194
292
|
columns: readonly Column$1<T, unknown>[];
|
|
195
|
-
/**
|
|
293
|
+
/**
|
|
294
|
+
* Stable identity for a row. Used as its key and to resolve `onRowAction`.
|
|
295
|
+
* Pass a stable reference (a module-level function or `useCallback`): the row
|
|
296
|
+
* index is memoised on it, so an inline arrow recomputes it every render.
|
|
297
|
+
*/
|
|
196
298
|
getRowId: (row: T) => RowKey;
|
|
197
299
|
/**
|
|
198
300
|
* Required. React Aria's Table renders no `<caption>`, so this is the
|
|
@@ -230,6 +332,22 @@ export interface TableProps<T> extends VariantProps<typeof tableRowVariants> {
|
|
|
230
332
|
isRowHighlighted?: (row: T) => boolean;
|
|
231
333
|
/** Extra classes per row, for styling that depends on row DATA. */
|
|
232
334
|
rowClassName?: (row: T) => string;
|
|
335
|
+
/**
|
|
336
|
+
* Extra `data-*` attributes per row, for what depends on row DATA and has to
|
|
337
|
+
* reach the `<tr>`: a `data-testid`, a `data-name` for a script. Only `data-*`
|
|
338
|
+
* keys are read (React Aria's grid row drops any `aria-*`). The library's own
|
|
339
|
+
* attributes (`data-slot`, `data-highlighted`, `data-depth`, `data-flip`, the
|
|
340
|
+
* row id and the grid's own roles and states) are applied after yours and
|
|
341
|
+
* win a clash.
|
|
342
|
+
*
|
|
343
|
+
* There is deliberately no `onClick`. In the grid a row is a React Aria
|
|
344
|
+
* control and its press is `onRowAction`, which receives the row; in a plain
|
|
345
|
+
* table a row is not a control, so put the action in a cell.
|
|
346
|
+
*
|
|
347
|
+
* Applies to data rows, not to a detail row. Called on every render for every
|
|
348
|
+
* shown row, so keep it cheap.
|
|
349
|
+
*/
|
|
350
|
+
getRowProps?: (row: T) => RowAttributes | undefined;
|
|
233
351
|
/**
|
|
234
352
|
* Rendered in place of the rows when `data` is empty.
|
|
235
353
|
*
|
|
@@ -358,6 +476,96 @@ export interface TableProps<T> extends VariantProps<typeof tableRowVariants> {
|
|
|
358
476
|
* real footer rather than one more row of data, so it is announced as one.
|
|
359
477
|
*/
|
|
360
478
|
totalRow?: (column: Column$1<T, unknown>) => ReactNode;
|
|
479
|
+
/**
|
|
480
|
+
* The rows nested under a row, shown while it is expanded. Return nothing
|
|
481
|
+
* (or an empty array) for a row with none. Sub-rows are rows like any other
|
|
482
|
+
* -- the same columns, `getRowId`, `onRowAction` and selection -- and may
|
|
483
|
+
* have sub-rows of their own.
|
|
484
|
+
*
|
|
485
|
+
* A row with sub-rows gets a disclosure button in its first cell, named by
|
|
486
|
+
* that cell's content and carrying `aria-expanded`; every row's first cell
|
|
487
|
+
* is indented one step per level. Sorting orders each level on its own, so
|
|
488
|
+
* sub-rows stay under their parent, and `pageSize` counts top-level rows,
|
|
489
|
+
* so a group is never split across pages.
|
|
490
|
+
*
|
|
491
|
+
* Pass a stable reference (a module-level function or `useCallback`) so the
|
|
492
|
+
* row index is memoised; an inline arrow function recomputes it on every
|
|
493
|
+
* render.
|
|
494
|
+
*/
|
|
495
|
+
getSubRows?: (row: T) => readonly T[] | null | undefined;
|
|
496
|
+
/**
|
|
497
|
+
* A full-width row under a row, shown while the row is expanded: arbitrary
|
|
498
|
+
* content (a history, a log, a form) rather than more rows. Return nothing
|
|
499
|
+
* (null, undefined or false) for a row that has no detail.
|
|
500
|
+
*
|
|
501
|
+
* This is NOT `getSubRows`. Sub-rows are data rows with the table's own
|
|
502
|
+
* columns, selection and actions, drawn with a disclosure button; a detail row
|
|
503
|
+
* is one cell spanning every column, holds anything, is never selected,
|
|
504
|
+
* sorted, counted or acted on, and has no built-in button. Open it with a
|
|
505
|
+
* trigger of your own in a cell, using `toggleExpanded` and `isExpanded` from
|
|
506
|
+
* the `cell` context (give it `aria-expanded`), or with `defaultExpandedKeys`
|
|
507
|
+
* / `expandedKeys`. It uses the same expanded set as `getSubRows`, so a row
|
|
508
|
+
* with both opens both: the detail row comes first, directly under its row,
|
|
509
|
+
* then the sub-rows.
|
|
510
|
+
*
|
|
511
|
+
* Called only for expanded rows, never for collapsed ones. Still return elements
|
|
512
|
+
* rather than doing work here, as it runs on every render while a row is open.
|
|
513
|
+
*/
|
|
514
|
+
renderExpandedRow?: (row: T) => ReactNode;
|
|
515
|
+
/** The expanded rows, CONTROLLED: their `getRowId` values. */
|
|
516
|
+
expandedKeys?: Iterable<RowKey>;
|
|
517
|
+
/** The rows expanded at the start, when uncontrolled. Nothing is, by default. */
|
|
518
|
+
defaultExpandedKeys?: Iterable<RowKey>;
|
|
519
|
+
/** Fires with the new set of expanded rows, controlled or not. */
|
|
520
|
+
onExpandedChange?: (keys: Set<RowKey>) => void;
|
|
521
|
+
/**
|
|
522
|
+
* Marks a row as a group header: its first column's content spans the
|
|
523
|
+
* whole row, in the header's type, and its other cells are not rendered.
|
|
524
|
+
* For grouped tables ("Mobile" / "Desktop") whose groups are headed rather
|
|
525
|
+
* than summed; a group with totals is a row with `getSubRows` instead.
|
|
526
|
+
* Combine the two for a group that opens and closes.
|
|
527
|
+
*
|
|
528
|
+
* A group header only heads the rows under it, so it is not actionable:
|
|
529
|
+
* `onRowAction` does not fire for it and it shows no pointer cursor.
|
|
530
|
+
*/
|
|
531
|
+
isGroupRow?: (row: T) => boolean;
|
|
532
|
+
/**
|
|
533
|
+
* Row height and type size. `default` takes its padding from the ambient
|
|
534
|
+
* density scope (`--density-row-pad-y`) in body type; `compact` is the
|
|
535
|
+
* product's tight report table, `py-2` rows in small type.
|
|
536
|
+
*/
|
|
537
|
+
density?: "default" | "compact";
|
|
538
|
+
/**
|
|
539
|
+
* Hides the header row from sight and keeps it for assistive tech, for a
|
|
540
|
+
* key/value table whose first column already says what each row is
|
|
541
|
+
* ("Plan" | "Growth"). Every column still needs a `header`: it is the
|
|
542
|
+
* column's accessible name, announced as a reader moves across a row.
|
|
543
|
+
*
|
|
544
|
+
* The header cells keep their widths, so `Column.width` still lays the
|
|
545
|
+
* columns out. A hidden header has no sort control, so `sortable` is
|
|
546
|
+
* ignored here (`defaultSortDescriptor` still orders the rows). In the grid
|
|
547
|
+
* a header cell opens up while it holds keyboard focus; with
|
|
548
|
+
* `keyboardModel="table"` nothing in it is focusable.
|
|
549
|
+
*/
|
|
550
|
+
headerHidden?: boolean;
|
|
551
|
+
/**
|
|
552
|
+
* How the keyboard moves through the table.
|
|
553
|
+
*
|
|
554
|
+
* `grid` (the default) is React Aria's grid: a composite widget with a
|
|
555
|
+
* tab stop of its own, where the arrow keys move focus between rows and
|
|
556
|
+
* cells and a screen reader switches to its application/grid handling.
|
|
557
|
+
* Row selection and `onRowAction` need it, because the row itself is the
|
|
558
|
+
* control.
|
|
559
|
+
*
|
|
560
|
+
* `table` renders a plain `role="table"`: no row or cell takes focus, the
|
|
561
|
+
* arrow keys are left to the browser and the screen reader's own table
|
|
562
|
+
* commands, and Tab goes straight from one link or button in a cell to the
|
|
563
|
+
* next, in reading order. For tables whose cells hold the actions. A
|
|
564
|
+
* sortable header becomes a button in that Tab order, with `aria-sort` on
|
|
565
|
+
* its column header. A row cannot be a control here, so `selectionMode`
|
|
566
|
+
* and `onRowAction` are ignored: put a link or button in a cell instead.
|
|
567
|
+
*/
|
|
568
|
+
keyboardModel?: "grid" | "table";
|
|
361
569
|
/** Extra classes for the table. Merged last, so they win conflicts with ours. */
|
|
362
570
|
className?: string;
|
|
363
571
|
}
|