@skdx/react 0.32.0 → 0.34.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/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/primitives/table.cjs +1 -1
- package/dist/primitives/table.js +1 -1
- package/dist/table/Table.cjs +1 -1
- package/dist/table/Table.d.cts +5 -5
- package/dist/table/Table.d.ts +5 -5
- package/dist/table/Table.js +1 -1
- package/dist/table/TableAnatomy.d.cts +6 -1
- package/dist/table/TableAnatomy.d.ts +6 -1
- package/dist/table/TableCell.d.cts +1 -1
- package/dist/table/TableCell.d.ts +1 -1
- package/dist/table/TableColumnPinTrigger.d.cts +17 -0
- package/dist/table/TableColumnPinTrigger.d.ts +17 -0
- package/dist/table/TableColumnReorderTrigger.d.cts +17 -0
- package/dist/table/TableColumnReorderTrigger.d.ts +17 -0
- package/dist/table/TableGroupRow.d.cts +14 -0
- package/dist/table/TableGroupRow.d.ts +14 -0
- package/dist/table/TableHeaderCell.d.cts +1 -1
- package/dist/table/TableHeaderCell.d.ts +1 -1
- package/dist/table/TableRow.d.cts +1 -1
- package/dist/table/TableRow.d.ts +1 -1
- package/dist/table/TableTreeTrigger.d.cts +17 -0
- package/dist/table/TableTreeTrigger.d.ts +17 -0
- package/dist/table/index.d.cts +1 -1
- package/dist/table/index.d.ts +1 -1
- package/dist/table/primitives.d.cts +6 -2
- package/dist/table/primitives.d.ts +6 -2
- package/dist/table/types.d.cts +206 -0
- package/dist/table/types.d.ts +206 -0
- package/dist/table/useColumnOrder.d.cts +12 -0
- package/dist/table/useColumnOrder.d.ts +12 -0
- package/dist/table/useIdSet.d.cts +2 -0
- package/dist/table/useIdSet.d.ts +2 -0
- package/dist/table/useTableSelection.d.cts +13 -0
- package/dist/table/useTableSelection.d.ts +13 -0
- package/dist/table/useTableSort.d.cts +5 -0
- package/dist/table/useTableSort.d.ts +5 -0
- package/package.json +5 -5
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import type { TableTreeTriggerProps } from './types.cjs';
|
|
3
|
+
/**
|
|
4
|
+
* Disclosure button in a tree parent's first cell that reveals its child rows, drawing a chevron by default.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* <TableCell>
|
|
9
|
+
* <TableTreeTrigger rowId={row.id} aria-label={`Children of ${row.name}`} />
|
|
10
|
+
* {row.name}
|
|
11
|
+
* </TableCell>
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare const TableTreeTrigger: {
|
|
15
|
+
({ rowId, ref: forwardedRef, ...props }: TableTreeTriggerProps): React.ReactNode;
|
|
16
|
+
displayName: string;
|
|
17
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import type { TableTreeTriggerProps } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Disclosure button in a tree parent's first cell that reveals its child rows, drawing a chevron by default.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* <TableCell>
|
|
9
|
+
* <TableTreeTrigger rowId={row.id} aria-label={`Children of ${row.name}`} />
|
|
10
|
+
* {row.name}
|
|
11
|
+
* </TableCell>
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare const TableTreeTrigger: {
|
|
15
|
+
({ rowId, ref: forwardedRef, ...props }: TableTreeTriggerProps): React.ReactNode;
|
|
16
|
+
displayName: string;
|
|
17
|
+
};
|
package/dist/table/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { Table, useTableContext } from './Table.cjs';
|
|
2
2
|
export { TableRow } from './TableRow.cjs';
|
|
3
3
|
export { TableCell } from './TableCell.cjs';
|
|
4
|
-
export type { TableColumn, TableColumnWidths, TableContextValue, TableProps, TableRowProps, TableCellProps, TableSort, TableSortState, TableFilterState, SortDirection, TableSelectionMode, } from './types.cjs';
|
|
4
|
+
export type { TableColumn, TableColumnPins, TableColumnWidths, TableContextValue, TableProps, TableRowProps, TableCellProps, TableSort, TableSortState, TableFilterState, SortDirection, TableSelectionMode, } from './types.cjs';
|
package/dist/table/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { Table, useTableContext } from './Table.js';
|
|
2
2
|
export { TableRow } from './TableRow.js';
|
|
3
3
|
export { TableCell } from './TableCell.js';
|
|
4
|
-
export type { TableColumn, TableColumnWidths, TableContextValue, TableProps, TableRowProps, TableCellProps, TableSort, TableSortState, TableFilterState, SortDirection, TableSelectionMode, } from './types.js';
|
|
4
|
+
export type { TableColumn, TableColumnPins, TableColumnWidths, TableContextValue, TableProps, TableRowProps, TableCellProps, TableSort, TableSortState, TableFilterState, SortDirection, TableSelectionMode, } from './types.js';
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* </TableRoot>
|
|
22
22
|
* ```
|
|
23
23
|
*/
|
|
24
|
-
export { TableRoot, useTableContext, defaultGetSortLabel } from './Table.cjs';
|
|
24
|
+
export { TableRoot, useTableContext, defaultGetSortLabel, defaultGetMoveLabel } from './Table.cjs';
|
|
25
25
|
export { TableHeader } from './TableHeader.cjs';
|
|
26
26
|
export { TableBody } from './TableBody.cjs';
|
|
27
27
|
export { TableFooter } from './TableFooter.cjs';
|
|
@@ -38,4 +38,8 @@ export { TableSortIndicator } from './TableSortIndicator.cjs';
|
|
|
38
38
|
export { TableSelectAllCheckbox, defaultSelectAllLabel } from './TableSelectAllCheckbox.cjs';
|
|
39
39
|
export { TableRowSelectCheckbox } from './TableRowSelectCheckbox.cjs';
|
|
40
40
|
export { TableColumnResizeTrigger } from './TableColumnResizeTrigger.cjs';
|
|
41
|
-
export
|
|
41
|
+
export { TableColumnReorderTrigger } from './TableColumnReorderTrigger.cjs';
|
|
42
|
+
export { TableColumnPinTrigger } from './TableColumnPinTrigger.cjs';
|
|
43
|
+
export { TableGroupRow } from './TableGroupRow.cjs';
|
|
44
|
+
export { TableTreeTrigger } from './TableTreeTrigger.cjs';
|
|
45
|
+
export type { TableRootProps, TableHeaderProps, TableBodyProps, TableFooterProps, TableRowProps, TableHeaderCellProps, TableCellProps, TableCaptionProps, TableSortState, TableSort, SortDirection, TableSelectionMode, TableColumnWidths, TableContextValue, TableExpandTriggerProps, TableExpandedRowProps, TableEmptyProps, TableColumnHeaderSortTriggerProps, TableColumnHeaderFilterInputProps, TableFilterState, TableSortIndicatorProps, TableSelectAllCheckboxProps, TableSelectAllScope, TableRowSelectCheckboxProps, TableColumnResizeTriggerProps, TableColumnReorderTriggerProps, TableColumnPinTriggerProps, TableColumnPins, TableGroupRowProps, TableTreeTriggerProps, } from './types.cjs';
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* </TableRoot>
|
|
22
22
|
* ```
|
|
23
23
|
*/
|
|
24
|
-
export { TableRoot, useTableContext, defaultGetSortLabel } from './Table.js';
|
|
24
|
+
export { TableRoot, useTableContext, defaultGetSortLabel, defaultGetMoveLabel } from './Table.js';
|
|
25
25
|
export { TableHeader } from './TableHeader.js';
|
|
26
26
|
export { TableBody } from './TableBody.js';
|
|
27
27
|
export { TableFooter } from './TableFooter.js';
|
|
@@ -38,4 +38,8 @@ export { TableSortIndicator } from './TableSortIndicator.js';
|
|
|
38
38
|
export { TableSelectAllCheckbox, defaultSelectAllLabel } from './TableSelectAllCheckbox.js';
|
|
39
39
|
export { TableRowSelectCheckbox } from './TableRowSelectCheckbox.js';
|
|
40
40
|
export { TableColumnResizeTrigger } from './TableColumnResizeTrigger.js';
|
|
41
|
-
export
|
|
41
|
+
export { TableColumnReorderTrigger } from './TableColumnReorderTrigger.js';
|
|
42
|
+
export { TableColumnPinTrigger } from './TableColumnPinTrigger.js';
|
|
43
|
+
export { TableGroupRow } from './TableGroupRow.js';
|
|
44
|
+
export { TableTreeTrigger } from './TableTreeTrigger.js';
|
|
45
|
+
export type { TableRootProps, TableHeaderProps, TableBodyProps, TableFooterProps, TableRowProps, TableHeaderCellProps, TableCellProps, TableCaptionProps, TableSortState, TableSort, SortDirection, TableSelectionMode, TableColumnWidths, TableContextValue, TableExpandTriggerProps, TableExpandedRowProps, TableEmptyProps, TableColumnHeaderSortTriggerProps, TableColumnHeaderFilterInputProps, TableFilterState, TableSortIndicatorProps, TableSelectAllCheckboxProps, TableSelectAllScope, TableRowSelectCheckboxProps, TableColumnResizeTriggerProps, TableColumnReorderTriggerProps, TableColumnPinTriggerProps, TableColumnPins, TableGroupRowProps, TableTreeTriggerProps, } from './types.js';
|
package/dist/table/types.d.cts
CHANGED
|
@@ -18,6 +18,8 @@ export type TableSelectAllScope = 'page' | 'all';
|
|
|
18
18
|
export type TableSelectionMode = 'single' | 'multiple' | 'none';
|
|
19
19
|
/** Per-column pixel widths keyed by `columnKey`. */
|
|
20
20
|
export type TableColumnWidths = Record<string, number>;
|
|
21
|
+
/** Pinned columns keyed by `columnKey`; an unpinned column is absent from the map. */
|
|
22
|
+
export type TableColumnPins = Record<string, 'start' | 'end'>;
|
|
21
23
|
/** Shared sort/selection state distributed from `Table` to its parts. */
|
|
22
24
|
export interface TableContextValue {
|
|
23
25
|
/** Unique per-table id for stable detail row `id`/`aria-controls` pairs. */
|
|
@@ -50,6 +52,28 @@ export interface TableContextValue {
|
|
|
50
52
|
headerCellCount: number;
|
|
51
53
|
/** @internal Counts a mounted `TableHeaderCell` into `headerCellCount`; the returned callback removes it. */
|
|
52
54
|
registerHeaderCell: () => () => void;
|
|
55
|
+
/** @internal Display order of column keys; keys left out follow in source order. */
|
|
56
|
+
columnOrder: string[];
|
|
57
|
+
/** @internal Moves one column to `toIndex` in header DOM order and announces the new position. */
|
|
58
|
+
moveColumn: (columnKey: string, toIndex: number, columnLabel?: string) => void;
|
|
59
|
+
/** @internal Which columns are pinned, and to which edge of the table. */
|
|
60
|
+
columnPins: TableColumnPins;
|
|
61
|
+
/** @internal Pins a column to one edge, or unpins it when given `null`. */
|
|
62
|
+
setColumnPin: (columnKey: string, side: 'start' | 'end' | null) => void;
|
|
63
|
+
/** @internal Measured sticky offset in pixels for each pinned column. */
|
|
64
|
+
pinOffsets: Record<string, number>;
|
|
65
|
+
/** @internal Group keys whose rows are currently hidden by their group row. */
|
|
66
|
+
collapsedGroups: Set<string>;
|
|
67
|
+
/** @internal Collapses an expanded group, or expands a collapsed one. */
|
|
68
|
+
toggleGroup: (groupKey: string) => void;
|
|
69
|
+
/** @internal Whether this group's rows are hidden right now. */
|
|
70
|
+
isGroupCollapsed: (groupKey: string) => boolean;
|
|
71
|
+
/** @internal Row ids of the tree parents whose children are rendered. */
|
|
72
|
+
expandedNodes: Set<string>;
|
|
73
|
+
/** @internal Expands a collapsed tree parent, or collapses an expanded one. */
|
|
74
|
+
toggleNode: (rowId: string) => void;
|
|
75
|
+
/** @internal Whether this tree parent currently renders its child rows. */
|
|
76
|
+
isNodeExpanded: (rowId: string) => boolean;
|
|
53
77
|
/** Deselect all or select all given row ids. */
|
|
54
78
|
toggleAll: (allIds: string[]) => void;
|
|
55
79
|
isAllSelected: (allIds: string[]) => boolean;
|
|
@@ -68,6 +92,12 @@ export interface TableHeaderCellContextValue {
|
|
|
68
92
|
maxWidth?: number | undefined;
|
|
69
93
|
resizeLabel?: string | undefined;
|
|
70
94
|
resizeStep?: number | undefined;
|
|
95
|
+
/** Whether this column can be moved by its reorder trigger. */
|
|
96
|
+
reorderable?: boolean | undefined;
|
|
97
|
+
/** Whether this column can be pinned by its pin trigger. */
|
|
98
|
+
pinnable?: boolean | undefined;
|
|
99
|
+
reorderLabel?: string | undefined;
|
|
100
|
+
pinLabel?: string | undefined;
|
|
71
101
|
}
|
|
72
102
|
/** Props for `TableRoot`, a native table with optional sorting and selection state. */
|
|
73
103
|
export interface TableRootProps extends Omit<PrimitivePropsWithRef<'table'>, 'onChange'> {
|
|
@@ -181,6 +211,71 @@ export interface TableRootProps extends Omit<PrimitivePropsWithRef<'table'>, 'on
|
|
|
181
211
|
* @default undefined
|
|
182
212
|
*/
|
|
183
213
|
onColumnWidthsCommit?: ((widths: TableColumnWidths) => void) | undefined;
|
|
214
|
+
/**
|
|
215
|
+
* Display order of column keys for controlled usage; keys left out follow in source order.
|
|
216
|
+
* @default undefined
|
|
217
|
+
*/
|
|
218
|
+
columnOrder?: string[] | undefined;
|
|
219
|
+
/**
|
|
220
|
+
* Initial display order of column keys for uncontrolled usage.
|
|
221
|
+
* @default []
|
|
222
|
+
*/
|
|
223
|
+
defaultColumnOrder?: string[] | undefined;
|
|
224
|
+
/**
|
|
225
|
+
* Fires with the full column order whenever a reorder trigger moves a column.
|
|
226
|
+
* @default undefined
|
|
227
|
+
*/
|
|
228
|
+
onColumnOrderChange?: ((columnOrder: string[]) => void) | undefined;
|
|
229
|
+
/**
|
|
230
|
+
* Pinned columns keyed by `columnKey` for controlled usage, each pinned to one edge.
|
|
231
|
+
* @default undefined
|
|
232
|
+
*/
|
|
233
|
+
columnPins?: TableColumnPins | undefined;
|
|
234
|
+
/**
|
|
235
|
+
* Initially pinned columns for uncontrolled usage, keyed by `columnKey`.
|
|
236
|
+
* @default {}
|
|
237
|
+
*/
|
|
238
|
+
defaultColumnPins?: TableColumnPins | undefined;
|
|
239
|
+
/**
|
|
240
|
+
* Fires with the full pin map whenever a pin trigger is activated.
|
|
241
|
+
* @default undefined
|
|
242
|
+
*/
|
|
243
|
+
onColumnPinsChange?: ((columnPins: TableColumnPins) => void) | undefined;
|
|
244
|
+
/**
|
|
245
|
+
* Format the message announced after a column is moved, given its 1-based position.
|
|
246
|
+
* @default defaultGetMoveLabel
|
|
247
|
+
*/
|
|
248
|
+
getMoveLabel?: ((column: string, position: number, count: number) => string) | undefined;
|
|
249
|
+
/**
|
|
250
|
+
* Group keys whose rows are hidden for controlled usage; groups start expanded.
|
|
251
|
+
* @default undefined
|
|
252
|
+
*/
|
|
253
|
+
collapsedGroups?: string[] | undefined;
|
|
254
|
+
/**
|
|
255
|
+
* Initially collapsed group keys for uncontrolled usage.
|
|
256
|
+
* @default []
|
|
257
|
+
*/
|
|
258
|
+
defaultCollapsedGroups?: string[] | undefined;
|
|
259
|
+
/**
|
|
260
|
+
* Fires with the collapsed group keys whenever a group row is toggled.
|
|
261
|
+
* @default undefined
|
|
262
|
+
*/
|
|
263
|
+
onCollapsedGroupsChange?: ((groupKeys: string[]) => void) | undefined;
|
|
264
|
+
/**
|
|
265
|
+
* Tree parents whose child rows are rendered, for controlled usage.
|
|
266
|
+
* @default undefined
|
|
267
|
+
*/
|
|
268
|
+
expandedNodeIds?: string[] | undefined;
|
|
269
|
+
/**
|
|
270
|
+
* Initially expanded tree parents for uncontrolled usage.
|
|
271
|
+
* @default []
|
|
272
|
+
*/
|
|
273
|
+
defaultExpandedNodeIds?: string[] | undefined;
|
|
274
|
+
/**
|
|
275
|
+
* Fires with the expanded tree parents whenever a tree trigger is activated.
|
|
276
|
+
* @default undefined
|
|
277
|
+
*/
|
|
278
|
+
onExpandedNodeIdsChange?: ((rowIds: string[]) => void) | undefined;
|
|
184
279
|
/**
|
|
185
280
|
* Spacing rung the skin packs the cells by, mirrored to `data-density`.
|
|
186
281
|
* @default undefined — the skin's own default spacing.
|
|
@@ -221,6 +316,16 @@ export interface TableColumn<T extends object = object> {
|
|
|
221
316
|
* @default inherits root's `filterable`
|
|
222
317
|
*/
|
|
223
318
|
filterable?: boolean | undefined;
|
|
319
|
+
/**
|
|
320
|
+
* Override the root's `reorderable` for this column alone.
|
|
321
|
+
* @default inherits root's `reorderable`
|
|
322
|
+
*/
|
|
323
|
+
reorderable?: boolean | undefined;
|
|
324
|
+
/**
|
|
325
|
+
* Override the root's `pinnable` for this column alone.
|
|
326
|
+
* @default inherits root's `pinnable`
|
|
327
|
+
*/
|
|
328
|
+
pinnable?: boolean | undefined;
|
|
224
329
|
/** @default 40 */
|
|
225
330
|
minWidth?: number | undefined;
|
|
226
331
|
/** @default 1000 */
|
|
@@ -262,6 +367,31 @@ export interface TableProps<T extends object = object> extends Omit<TableRootPro
|
|
|
262
367
|
* @default false
|
|
263
368
|
*/
|
|
264
369
|
filterable?: boolean | undefined;
|
|
370
|
+
/**
|
|
371
|
+
* Default `reorderable` for every column that doesn't set its own, deriving a reorder trigger.
|
|
372
|
+
* @default false
|
|
373
|
+
*/
|
|
374
|
+
reorderable?: boolean | undefined;
|
|
375
|
+
/**
|
|
376
|
+
* Default `pinnable` for every column that doesn't set its own, deriving a pin trigger.
|
|
377
|
+
* @default false
|
|
378
|
+
*/
|
|
379
|
+
pinnable?: boolean | undefined;
|
|
380
|
+
/**
|
|
381
|
+
* Column key to group rows by, emitting one collapsible group row per distinct value.
|
|
382
|
+
* @default no grouping
|
|
383
|
+
*/
|
|
384
|
+
groupBy?: (Extract<keyof T, string> | (string & {})) | undefined;
|
|
385
|
+
/**
|
|
386
|
+
* Render one derived group row's label from its key and rows.
|
|
387
|
+
* @default `${groupKey} (${rows.length})`
|
|
388
|
+
*/
|
|
389
|
+
renderGroupHeader?: ((groupKey: string, rows: T[]) => React.ReactNode) | undefined;
|
|
390
|
+
/**
|
|
391
|
+
* Return a row's child rows to render the data as an expandable tree.
|
|
392
|
+
* @default no tree rows
|
|
393
|
+
*/
|
|
394
|
+
getSubRows?: ((row: T) => T[] | undefined) | undefined;
|
|
265
395
|
/**
|
|
266
396
|
* Content for a derived empty row shown when data is empty.
|
|
267
397
|
* @default no empty row
|
|
@@ -309,6 +439,11 @@ export interface TableRowProps extends PrimitivePropsWithRef<'tr'> {
|
|
|
309
439
|
* @default undefined
|
|
310
440
|
*/
|
|
311
441
|
rowId?: string | undefined;
|
|
442
|
+
/**
|
|
443
|
+
* Tree depth of this row, `0` at the top level, published for the skin to indent by.
|
|
444
|
+
* @default undefined — the row carries no depth.
|
|
445
|
+
*/
|
|
446
|
+
level?: number | undefined;
|
|
312
447
|
}
|
|
313
448
|
/** Props for a column header cell, optionally sortable and resizable. */
|
|
314
449
|
export interface TableHeaderCellProps extends PrimitivePropsWithRef<'th'> {
|
|
@@ -357,6 +492,26 @@ export interface TableHeaderCellProps extends PrimitivePropsWithRef<'th'> {
|
|
|
357
492
|
* @default 8
|
|
358
493
|
*/
|
|
359
494
|
resizeStep?: number | undefined;
|
|
495
|
+
/**
|
|
496
|
+
* Renders a reorder trigger after the label, moved with the arrow keys or dragged.
|
|
497
|
+
* @default false
|
|
498
|
+
*/
|
|
499
|
+
reorderable?: boolean | undefined;
|
|
500
|
+
/**
|
|
501
|
+
* Renders a pin trigger after the label, sticking this column to one edge.
|
|
502
|
+
* @default false
|
|
503
|
+
*/
|
|
504
|
+
pinnable?: boolean | undefined;
|
|
505
|
+
/**
|
|
506
|
+
* Accessible name for the derived reorder trigger.
|
|
507
|
+
* @default 'Move column'
|
|
508
|
+
*/
|
|
509
|
+
reorderLabel?: string | undefined;
|
|
510
|
+
/**
|
|
511
|
+
* Accessible name for the derived pin trigger.
|
|
512
|
+
* @default 'Pin column'
|
|
513
|
+
*/
|
|
514
|
+
pinLabel?: string | undefined;
|
|
360
515
|
}
|
|
361
516
|
/** Props for the button inside a header cell that cycles column sort. */
|
|
362
517
|
export interface TableColumnHeaderSortTriggerProps extends PrimitivePropsWithRef<'button'> {
|
|
@@ -431,8 +586,59 @@ export interface TableColumnResizeTriggerProps extends PrimitivePropsWithRef<'sp
|
|
|
431
586
|
*/
|
|
432
587
|
label?: string | undefined;
|
|
433
588
|
}
|
|
589
|
+
/** Props for the button that moves its column left or right. */
|
|
590
|
+
export interface TableColumnReorderTriggerProps extends PrimitivePropsWithRef<'button'> {
|
|
591
|
+
/**
|
|
592
|
+
* Column this trigger moves, inherited from the enclosing `TableHeaderCell`'s `columnKey`.
|
|
593
|
+
* @default enclosing `TableHeaderCell`'s `columnKey`
|
|
594
|
+
*/
|
|
595
|
+
columnKey?: string | undefined;
|
|
596
|
+
/**
|
|
597
|
+
* Accessible name for the trigger, which draws only a drag glyph by default.
|
|
598
|
+
* @default enclosing `TableHeaderCell`'s `reorderLabel` or `'Move column'`
|
|
599
|
+
*/
|
|
600
|
+
label?: string | undefined;
|
|
601
|
+
}
|
|
602
|
+
/** Props for the toggle button that pins its column to one edge. */
|
|
603
|
+
export interface TableColumnPinTriggerProps extends PrimitivePropsWithRef<'button'> {
|
|
604
|
+
/**
|
|
605
|
+
* Column this trigger pins, inherited from the enclosing `TableHeaderCell`'s `columnKey`.
|
|
606
|
+
* @default enclosing `TableHeaderCell`'s `columnKey`
|
|
607
|
+
*/
|
|
608
|
+
columnKey?: string | undefined;
|
|
609
|
+
/**
|
|
610
|
+
* Which edge of the table this trigger pins its column to.
|
|
611
|
+
* @default 'start'
|
|
612
|
+
*/
|
|
613
|
+
side?: 'start' | 'end' | undefined;
|
|
614
|
+
/**
|
|
615
|
+
* Accessible name for the trigger, which draws only a pin glyph by default.
|
|
616
|
+
* @default enclosing `TableHeaderCell`'s `pinLabel` or `'Pin column'`
|
|
617
|
+
*/
|
|
618
|
+
label?: string | undefined;
|
|
619
|
+
}
|
|
620
|
+
/** Props for the row that heads and collapses one group of rows. */
|
|
621
|
+
export interface TableGroupRowProps extends PrimitivePropsWithRef<'tr'> {
|
|
622
|
+
/** Key of the group this row heads, as it appears in `collapsedGroups`. */
|
|
623
|
+
groupKey: string;
|
|
624
|
+
/**
|
|
625
|
+
* How many columns the group cell spans.
|
|
626
|
+
* @default undefined — the table's own header cell count, so a column added later still spans.
|
|
627
|
+
*/
|
|
628
|
+
colSpan?: number | undefined;
|
|
629
|
+
}
|
|
630
|
+
/** Props for the disclosure button that reveals a tree row's children. */
|
|
631
|
+
export interface TableTreeTriggerProps extends PrimitivePropsWithRef<'button'> {
|
|
632
|
+
/** Id of the parent row whose child rows this trigger reveals. */
|
|
633
|
+
rowId: string;
|
|
634
|
+
}
|
|
434
635
|
/** Props for a single body cell. */
|
|
435
636
|
export interface TableCellProps extends PrimitivePropsWithRef<'td'> {
|
|
637
|
+
/**
|
|
638
|
+
* Column this cell belongs to, so it follows that column's pinning.
|
|
639
|
+
* @default undefined — the cell never pins.
|
|
640
|
+
*/
|
|
641
|
+
columnKey?: string | undefined;
|
|
436
642
|
}
|
|
437
643
|
/** Props for the table caption. */
|
|
438
644
|
export interface TableCaptionProps extends PrimitivePropsWithRef<'caption'> {
|
package/dist/table/types.d.ts
CHANGED
|
@@ -18,6 +18,8 @@ export type TableSelectAllScope = 'page' | 'all';
|
|
|
18
18
|
export type TableSelectionMode = 'single' | 'multiple' | 'none';
|
|
19
19
|
/** Per-column pixel widths keyed by `columnKey`. */
|
|
20
20
|
export type TableColumnWidths = Record<string, number>;
|
|
21
|
+
/** Pinned columns keyed by `columnKey`; an unpinned column is absent from the map. */
|
|
22
|
+
export type TableColumnPins = Record<string, 'start' | 'end'>;
|
|
21
23
|
/** Shared sort/selection state distributed from `Table` to its parts. */
|
|
22
24
|
export interface TableContextValue {
|
|
23
25
|
/** Unique per-table id for stable detail row `id`/`aria-controls` pairs. */
|
|
@@ -50,6 +52,28 @@ export interface TableContextValue {
|
|
|
50
52
|
headerCellCount: number;
|
|
51
53
|
/** @internal Counts a mounted `TableHeaderCell` into `headerCellCount`; the returned callback removes it. */
|
|
52
54
|
registerHeaderCell: () => () => void;
|
|
55
|
+
/** @internal Display order of column keys; keys left out follow in source order. */
|
|
56
|
+
columnOrder: string[];
|
|
57
|
+
/** @internal Moves one column to `toIndex` in header DOM order and announces the new position. */
|
|
58
|
+
moveColumn: (columnKey: string, toIndex: number, columnLabel?: string) => void;
|
|
59
|
+
/** @internal Which columns are pinned, and to which edge of the table. */
|
|
60
|
+
columnPins: TableColumnPins;
|
|
61
|
+
/** @internal Pins a column to one edge, or unpins it when given `null`. */
|
|
62
|
+
setColumnPin: (columnKey: string, side: 'start' | 'end' | null) => void;
|
|
63
|
+
/** @internal Measured sticky offset in pixels for each pinned column. */
|
|
64
|
+
pinOffsets: Record<string, number>;
|
|
65
|
+
/** @internal Group keys whose rows are currently hidden by their group row. */
|
|
66
|
+
collapsedGroups: Set<string>;
|
|
67
|
+
/** @internal Collapses an expanded group, or expands a collapsed one. */
|
|
68
|
+
toggleGroup: (groupKey: string) => void;
|
|
69
|
+
/** @internal Whether this group's rows are hidden right now. */
|
|
70
|
+
isGroupCollapsed: (groupKey: string) => boolean;
|
|
71
|
+
/** @internal Row ids of the tree parents whose children are rendered. */
|
|
72
|
+
expandedNodes: Set<string>;
|
|
73
|
+
/** @internal Expands a collapsed tree parent, or collapses an expanded one. */
|
|
74
|
+
toggleNode: (rowId: string) => void;
|
|
75
|
+
/** @internal Whether this tree parent currently renders its child rows. */
|
|
76
|
+
isNodeExpanded: (rowId: string) => boolean;
|
|
53
77
|
/** Deselect all or select all given row ids. */
|
|
54
78
|
toggleAll: (allIds: string[]) => void;
|
|
55
79
|
isAllSelected: (allIds: string[]) => boolean;
|
|
@@ -68,6 +92,12 @@ export interface TableHeaderCellContextValue {
|
|
|
68
92
|
maxWidth?: number | undefined;
|
|
69
93
|
resizeLabel?: string | undefined;
|
|
70
94
|
resizeStep?: number | undefined;
|
|
95
|
+
/** Whether this column can be moved by its reorder trigger. */
|
|
96
|
+
reorderable?: boolean | undefined;
|
|
97
|
+
/** Whether this column can be pinned by its pin trigger. */
|
|
98
|
+
pinnable?: boolean | undefined;
|
|
99
|
+
reorderLabel?: string | undefined;
|
|
100
|
+
pinLabel?: string | undefined;
|
|
71
101
|
}
|
|
72
102
|
/** Props for `TableRoot`, a native table with optional sorting and selection state. */
|
|
73
103
|
export interface TableRootProps extends Omit<PrimitivePropsWithRef<'table'>, 'onChange'> {
|
|
@@ -181,6 +211,71 @@ export interface TableRootProps extends Omit<PrimitivePropsWithRef<'table'>, 'on
|
|
|
181
211
|
* @default undefined
|
|
182
212
|
*/
|
|
183
213
|
onColumnWidthsCommit?: ((widths: TableColumnWidths) => void) | undefined;
|
|
214
|
+
/**
|
|
215
|
+
* Display order of column keys for controlled usage; keys left out follow in source order.
|
|
216
|
+
* @default undefined
|
|
217
|
+
*/
|
|
218
|
+
columnOrder?: string[] | undefined;
|
|
219
|
+
/**
|
|
220
|
+
* Initial display order of column keys for uncontrolled usage.
|
|
221
|
+
* @default []
|
|
222
|
+
*/
|
|
223
|
+
defaultColumnOrder?: string[] | undefined;
|
|
224
|
+
/**
|
|
225
|
+
* Fires with the full column order whenever a reorder trigger moves a column.
|
|
226
|
+
* @default undefined
|
|
227
|
+
*/
|
|
228
|
+
onColumnOrderChange?: ((columnOrder: string[]) => void) | undefined;
|
|
229
|
+
/**
|
|
230
|
+
* Pinned columns keyed by `columnKey` for controlled usage, each pinned to one edge.
|
|
231
|
+
* @default undefined
|
|
232
|
+
*/
|
|
233
|
+
columnPins?: TableColumnPins | undefined;
|
|
234
|
+
/**
|
|
235
|
+
* Initially pinned columns for uncontrolled usage, keyed by `columnKey`.
|
|
236
|
+
* @default {}
|
|
237
|
+
*/
|
|
238
|
+
defaultColumnPins?: TableColumnPins | undefined;
|
|
239
|
+
/**
|
|
240
|
+
* Fires with the full pin map whenever a pin trigger is activated.
|
|
241
|
+
* @default undefined
|
|
242
|
+
*/
|
|
243
|
+
onColumnPinsChange?: ((columnPins: TableColumnPins) => void) | undefined;
|
|
244
|
+
/**
|
|
245
|
+
* Format the message announced after a column is moved, given its 1-based position.
|
|
246
|
+
* @default defaultGetMoveLabel
|
|
247
|
+
*/
|
|
248
|
+
getMoveLabel?: ((column: string, position: number, count: number) => string) | undefined;
|
|
249
|
+
/**
|
|
250
|
+
* Group keys whose rows are hidden for controlled usage; groups start expanded.
|
|
251
|
+
* @default undefined
|
|
252
|
+
*/
|
|
253
|
+
collapsedGroups?: string[] | undefined;
|
|
254
|
+
/**
|
|
255
|
+
* Initially collapsed group keys for uncontrolled usage.
|
|
256
|
+
* @default []
|
|
257
|
+
*/
|
|
258
|
+
defaultCollapsedGroups?: string[] | undefined;
|
|
259
|
+
/**
|
|
260
|
+
* Fires with the collapsed group keys whenever a group row is toggled.
|
|
261
|
+
* @default undefined
|
|
262
|
+
*/
|
|
263
|
+
onCollapsedGroupsChange?: ((groupKeys: string[]) => void) | undefined;
|
|
264
|
+
/**
|
|
265
|
+
* Tree parents whose child rows are rendered, for controlled usage.
|
|
266
|
+
* @default undefined
|
|
267
|
+
*/
|
|
268
|
+
expandedNodeIds?: string[] | undefined;
|
|
269
|
+
/**
|
|
270
|
+
* Initially expanded tree parents for uncontrolled usage.
|
|
271
|
+
* @default []
|
|
272
|
+
*/
|
|
273
|
+
defaultExpandedNodeIds?: string[] | undefined;
|
|
274
|
+
/**
|
|
275
|
+
* Fires with the expanded tree parents whenever a tree trigger is activated.
|
|
276
|
+
* @default undefined
|
|
277
|
+
*/
|
|
278
|
+
onExpandedNodeIdsChange?: ((rowIds: string[]) => void) | undefined;
|
|
184
279
|
/**
|
|
185
280
|
* Spacing rung the skin packs the cells by, mirrored to `data-density`.
|
|
186
281
|
* @default undefined — the skin's own default spacing.
|
|
@@ -221,6 +316,16 @@ export interface TableColumn<T extends object = object> {
|
|
|
221
316
|
* @default inherits root's `filterable`
|
|
222
317
|
*/
|
|
223
318
|
filterable?: boolean | undefined;
|
|
319
|
+
/**
|
|
320
|
+
* Override the root's `reorderable` for this column alone.
|
|
321
|
+
* @default inherits root's `reorderable`
|
|
322
|
+
*/
|
|
323
|
+
reorderable?: boolean | undefined;
|
|
324
|
+
/**
|
|
325
|
+
* Override the root's `pinnable` for this column alone.
|
|
326
|
+
* @default inherits root's `pinnable`
|
|
327
|
+
*/
|
|
328
|
+
pinnable?: boolean | undefined;
|
|
224
329
|
/** @default 40 */
|
|
225
330
|
minWidth?: number | undefined;
|
|
226
331
|
/** @default 1000 */
|
|
@@ -262,6 +367,31 @@ export interface TableProps<T extends object = object> extends Omit<TableRootPro
|
|
|
262
367
|
* @default false
|
|
263
368
|
*/
|
|
264
369
|
filterable?: boolean | undefined;
|
|
370
|
+
/**
|
|
371
|
+
* Default `reorderable` for every column that doesn't set its own, deriving a reorder trigger.
|
|
372
|
+
* @default false
|
|
373
|
+
*/
|
|
374
|
+
reorderable?: boolean | undefined;
|
|
375
|
+
/**
|
|
376
|
+
* Default `pinnable` for every column that doesn't set its own, deriving a pin trigger.
|
|
377
|
+
* @default false
|
|
378
|
+
*/
|
|
379
|
+
pinnable?: boolean | undefined;
|
|
380
|
+
/**
|
|
381
|
+
* Column key to group rows by, emitting one collapsible group row per distinct value.
|
|
382
|
+
* @default no grouping
|
|
383
|
+
*/
|
|
384
|
+
groupBy?: (Extract<keyof T, string> | (string & {})) | undefined;
|
|
385
|
+
/**
|
|
386
|
+
* Render one derived group row's label from its key and rows.
|
|
387
|
+
* @default `${groupKey} (${rows.length})`
|
|
388
|
+
*/
|
|
389
|
+
renderGroupHeader?: ((groupKey: string, rows: T[]) => React.ReactNode) | undefined;
|
|
390
|
+
/**
|
|
391
|
+
* Return a row's child rows to render the data as an expandable tree.
|
|
392
|
+
* @default no tree rows
|
|
393
|
+
*/
|
|
394
|
+
getSubRows?: ((row: T) => T[] | undefined) | undefined;
|
|
265
395
|
/**
|
|
266
396
|
* Content for a derived empty row shown when data is empty.
|
|
267
397
|
* @default no empty row
|
|
@@ -309,6 +439,11 @@ export interface TableRowProps extends PrimitivePropsWithRef<'tr'> {
|
|
|
309
439
|
* @default undefined
|
|
310
440
|
*/
|
|
311
441
|
rowId?: string | undefined;
|
|
442
|
+
/**
|
|
443
|
+
* Tree depth of this row, `0` at the top level, published for the skin to indent by.
|
|
444
|
+
* @default undefined — the row carries no depth.
|
|
445
|
+
*/
|
|
446
|
+
level?: number | undefined;
|
|
312
447
|
}
|
|
313
448
|
/** Props for a column header cell, optionally sortable and resizable. */
|
|
314
449
|
export interface TableHeaderCellProps extends PrimitivePropsWithRef<'th'> {
|
|
@@ -357,6 +492,26 @@ export interface TableHeaderCellProps extends PrimitivePropsWithRef<'th'> {
|
|
|
357
492
|
* @default 8
|
|
358
493
|
*/
|
|
359
494
|
resizeStep?: number | undefined;
|
|
495
|
+
/**
|
|
496
|
+
* Renders a reorder trigger after the label, moved with the arrow keys or dragged.
|
|
497
|
+
* @default false
|
|
498
|
+
*/
|
|
499
|
+
reorderable?: boolean | undefined;
|
|
500
|
+
/**
|
|
501
|
+
* Renders a pin trigger after the label, sticking this column to one edge.
|
|
502
|
+
* @default false
|
|
503
|
+
*/
|
|
504
|
+
pinnable?: boolean | undefined;
|
|
505
|
+
/**
|
|
506
|
+
* Accessible name for the derived reorder trigger.
|
|
507
|
+
* @default 'Move column'
|
|
508
|
+
*/
|
|
509
|
+
reorderLabel?: string | undefined;
|
|
510
|
+
/**
|
|
511
|
+
* Accessible name for the derived pin trigger.
|
|
512
|
+
* @default 'Pin column'
|
|
513
|
+
*/
|
|
514
|
+
pinLabel?: string | undefined;
|
|
360
515
|
}
|
|
361
516
|
/** Props for the button inside a header cell that cycles column sort. */
|
|
362
517
|
export interface TableColumnHeaderSortTriggerProps extends PrimitivePropsWithRef<'button'> {
|
|
@@ -431,8 +586,59 @@ export interface TableColumnResizeTriggerProps extends PrimitivePropsWithRef<'sp
|
|
|
431
586
|
*/
|
|
432
587
|
label?: string | undefined;
|
|
433
588
|
}
|
|
589
|
+
/** Props for the button that moves its column left or right. */
|
|
590
|
+
export interface TableColumnReorderTriggerProps extends PrimitivePropsWithRef<'button'> {
|
|
591
|
+
/**
|
|
592
|
+
* Column this trigger moves, inherited from the enclosing `TableHeaderCell`'s `columnKey`.
|
|
593
|
+
* @default enclosing `TableHeaderCell`'s `columnKey`
|
|
594
|
+
*/
|
|
595
|
+
columnKey?: string | undefined;
|
|
596
|
+
/**
|
|
597
|
+
* Accessible name for the trigger, which draws only a drag glyph by default.
|
|
598
|
+
* @default enclosing `TableHeaderCell`'s `reorderLabel` or `'Move column'`
|
|
599
|
+
*/
|
|
600
|
+
label?: string | undefined;
|
|
601
|
+
}
|
|
602
|
+
/** Props for the toggle button that pins its column to one edge. */
|
|
603
|
+
export interface TableColumnPinTriggerProps extends PrimitivePropsWithRef<'button'> {
|
|
604
|
+
/**
|
|
605
|
+
* Column this trigger pins, inherited from the enclosing `TableHeaderCell`'s `columnKey`.
|
|
606
|
+
* @default enclosing `TableHeaderCell`'s `columnKey`
|
|
607
|
+
*/
|
|
608
|
+
columnKey?: string | undefined;
|
|
609
|
+
/**
|
|
610
|
+
* Which edge of the table this trigger pins its column to.
|
|
611
|
+
* @default 'start'
|
|
612
|
+
*/
|
|
613
|
+
side?: 'start' | 'end' | undefined;
|
|
614
|
+
/**
|
|
615
|
+
* Accessible name for the trigger, which draws only a pin glyph by default.
|
|
616
|
+
* @default enclosing `TableHeaderCell`'s `pinLabel` or `'Pin column'`
|
|
617
|
+
*/
|
|
618
|
+
label?: string | undefined;
|
|
619
|
+
}
|
|
620
|
+
/** Props for the row that heads and collapses one group of rows. */
|
|
621
|
+
export interface TableGroupRowProps extends PrimitivePropsWithRef<'tr'> {
|
|
622
|
+
/** Key of the group this row heads, as it appears in `collapsedGroups`. */
|
|
623
|
+
groupKey: string;
|
|
624
|
+
/**
|
|
625
|
+
* How many columns the group cell spans.
|
|
626
|
+
* @default undefined — the table's own header cell count, so a column added later still spans.
|
|
627
|
+
*/
|
|
628
|
+
colSpan?: number | undefined;
|
|
629
|
+
}
|
|
630
|
+
/** Props for the disclosure button that reveals a tree row's children. */
|
|
631
|
+
export interface TableTreeTriggerProps extends PrimitivePropsWithRef<'button'> {
|
|
632
|
+
/** Id of the parent row whose child rows this trigger reveals. */
|
|
633
|
+
rowId: string;
|
|
634
|
+
}
|
|
434
635
|
/** Props for a single body cell. */
|
|
435
636
|
export interface TableCellProps extends PrimitivePropsWithRef<'td'> {
|
|
637
|
+
/**
|
|
638
|
+
* Column this cell belongs to, so it follows that column's pinning.
|
|
639
|
+
* @default undefined — the cell never pins.
|
|
640
|
+
*/
|
|
641
|
+
columnKey?: string | undefined;
|
|
436
642
|
}
|
|
437
643
|
/** Props for the table caption. */
|
|
438
644
|
export interface TableCaptionProps extends PrimitivePropsWithRef<'caption'> {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { TableColumnPins } from './types.cjs';
|
|
3
|
+
/** Default `getMoveLabel`: `"Amount moved to position 2 of 5"`, counting from one. */
|
|
4
|
+
export declare function defaultGetMoveLabel(column: string, position: number, count: number): string;
|
|
5
|
+
/** Controlled-or-uncontrolled column order plus the announcing move handler TableRoot publishes. */
|
|
6
|
+
export declare function useColumnOrder(tableRef: React.RefObject<HTMLTableElement | null>, prop: string[] | undefined, defaultProp: string[] | undefined, onChange: ((columnOrder: string[]) => void) | undefined, getMoveLabel?: (column: string, position: number, count: number) => string): [string[], (columnKey: string, toIndex: number, columnLabel?: string) => void];
|
|
7
|
+
/** Controlled-or-uncontrolled column pins plus the sticky offsets measured from the pinned header cells. */
|
|
8
|
+
export declare function useColumnPins(tableRef: React.RefObject<HTMLTableElement | null>, prop: TableColumnPins | undefined, defaultProp: TableColumnPins | undefined, onChange: ((columnPins: TableColumnPins) => void) | undefined): [
|
|
9
|
+
TableColumnPins,
|
|
10
|
+
(columnKey: string, side: 'start' | 'end' | null) => void,
|
|
11
|
+
Record<string, number>
|
|
12
|
+
];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { TableColumnPins } from './types.js';
|
|
3
|
+
/** Default `getMoveLabel`: `"Amount moved to position 2 of 5"`, counting from one. */
|
|
4
|
+
export declare function defaultGetMoveLabel(column: string, position: number, count: number): string;
|
|
5
|
+
/** Controlled-or-uncontrolled column order plus the announcing move handler TableRoot publishes. */
|
|
6
|
+
export declare function useColumnOrder(tableRef: React.RefObject<HTMLTableElement | null>, prop: string[] | undefined, defaultProp: string[] | undefined, onChange: ((columnOrder: string[]) => void) | undefined, getMoveLabel?: (column: string, position: number, count: number) => string): [string[], (columnKey: string, toIndex: number, columnLabel?: string) => void];
|
|
7
|
+
/** Controlled-or-uncontrolled column pins plus the sticky offsets measured from the pinned header cells. */
|
|
8
|
+
export declare function useColumnPins(tableRef: React.RefObject<HTMLTableElement | null>, prop: TableColumnPins | undefined, defaultProp: TableColumnPins | undefined, onChange: ((columnPins: TableColumnPins) => void) | undefined): [
|
|
9
|
+
TableColumnPins,
|
|
10
|
+
(columnKey: string, side: 'start' | 'end' | null) => void,
|
|
11
|
+
Record<string, number>
|
|
12
|
+
];
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/** Controlled-or-uncontrolled id list as a Set, with the toggle and membership test TableRoot publishes. */
|
|
2
|
+
export declare function useIdSet(prop: string[] | undefined, defaultProp: string[] | undefined, onChange: ((ids: string[]) => void) | undefined): [Set<string>, (id: string) => void, (id: string) => boolean];
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/** Controlled-or-uncontrolled id list as a Set, with the toggle and membership test TableRoot publishes. */
|
|
2
|
+
export declare function useIdSet(prop: string[] | undefined, defaultProp: string[] | undefined, onChange: ((ids: string[]) => void) | undefined): [Set<string>, (id: string) => void, (id: string) => boolean];
|