Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/table-checkbox-selection.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@human-kit/ui': minor
---

Table: add `selectionBehavior="checkbox"`. A press on a row only performs its action, even while rows are selected; the selection changes only through the selection checkbox, `Space` and the select-all shortcut.
2 changes: 1 addition & 1 deletion packages/ui/src/lib/table/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ and `TableCheckboxIndicatorProps`.

- Use `Table.Root` as the stateful container for focus, selection, and sorting state.
- Use `keyboardNavigation` to choose how far the roving tab stop reaches into the body: `'grid'` (default) makes every body cell a focus target, `'row'` makes the row the only one, and `'none'` leaves the body inert. The cell navigation has a cost: one focus registration and one focus state for each cell. A virtualized table does this again for each row that it makes. Use `'row'` when the body is a list, and not a surface where the user works. Use `'none'` only when nothing in the body does an action. The header keeps its own navigation in every mode.
- Use `selectionBehavior="toggle"` to let the user remove the selection of a selected row. Use `selectionBehavior="replace"` to keep a selected row selected when the user presses it again.
- Use `selectionBehavior="toggle"` to let the user remove the selection of a selected row. Use `selectionBehavior="replace"` to keep a selected row selected when the user presses it again. Use `selectionBehavior="checkbox"` when a press on the row should only perform its action: then only the selection checkbox, `Space` or the select-all shortcut change the selection.
- `Table.Column` is a logical-only wrapper for column metadata; it does not render DOM by itself and should wrap a single `Table.ColumnHeaderCell`.
- Wrap each header cell in `Table.Column` so the table can register stable column metadata.
- Add `Table.ColumnResizer` inside `Table.ColumnHeaderCell` to make the owning `Table.Column` resizable.
Expand Down
56 changes: 28 additions & 28 deletions packages/ui/src/lib/table/root/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,34 @@ Description: State container for interactive table behavior, including roving fo

Public prop type: `TableRootProps`

| Prop | Type | Default | Description |
| ------------------------ | ------------------------------------------------------------ | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| `selectionMode` | `'none' \| 'single' \| 'multiple'` | `'none'` | Controls row selection behavior. |
| `selectionBehavior` | `'toggle' \| 'replace'` | `'toggle'` | `toggle` uses checkbox-style selection. `replace` makes click replace selection, vertical arrows move selection, and `Shift+ArrowUp/Down` extend it. |
| `disabledBehavior` | `'selection' \| 'all'` | `'all'` | Controls whether disabled rows only block selection or block both selection and row actions. |
| `disallowEmptySelection` | `boolean` | `false` | Prevents the internal selection state from becoming empty when selection is enabled. |
| `hiddenColumns` | `Iterable<string>` | `undefined` | Controlled hidden column ids. Supports `bind:hiddenColumns`. |
| `defaultHiddenColumns` | `Iterable<string>` | `undefined` | Initial hidden column ids for uncontrolled usage. |
| `selectedKeys` | `Iterable<string \| number>` | `undefined` | Controlled selected row ids. Supports `bind:selectedKeys`. |
| `defaultSelectedKeys` | `Iterable<string \| number>` | `undefined` | Initial selected row ids for uncontrolled usage. When `selectionMode` later becomes `none`, the internal selection is cleared. |
| `sortDescriptor` | `{ column: string; direction: 'ascending' \| 'descending' }` | `undefined` | Controlled sort state. Supports `bind:sortDescriptor`. Setting it back to `undefined` clears the sort. |
| `defaultSortDescriptor` | `{ column: string; direction: 'ascending' \| 'descending' }` | `undefined` | Initial sort state for uncontrolled usage. |
| `columnWidths` | `Map<string, TableColumnWidth>` | `undefined` | Controlled column width state. Supports px, `%`, and `fr` specs via `bind:columnWidths`. |
| `defaultColumnWidths` | `Iterable<[string, TableColumnWidth]>` | `undefined` | Initial uncontrolled column widths using px, `%`, or `fr` specs. |
| `disabledKeys` | `Iterable<string \| number>` | `undefined` | Row ids that should be non-selectable. |
| `onRowAction` | `(id: string \| number) => void` | `undefined` | Called when a row action is triggered for an actionable row. |
| `onSelectionChange` | `(keys: Set<string \| number>) => void` | `undefined` | Called when row selection changes. |
| `onSortChange` | `(descriptor) => void` | `undefined` | Called when sortable header state changes. |
| `onColumnWidthsChange` | `(widths: Map<string, TableColumnWidth>) => void` | `undefined` | Called when resize interactions update managed column widths. |
| `onHiddenColumnsChange` | `(columnIds: string[]) => void` | `undefined` | Called when hidden column state changes. |
| `onColumnResizeStart` | `(columnId: string) => void` | `undefined` | Called when a column resize drag starts. |
| `onColumnResizeEnd` | `(widths: Map<string, TableColumnWidth>) => void` | `undefined` | Called when a column resize drag ends. |
| `aria-label` | `string` | `undefined` | Accessible name when no external label is present. |
| `aria-labelledby` | `string` | `undefined` | Id reference for an external label. |
| `class` | `string` | `''` | Class names for the root table element. |
| `context` | `TableContext` | `undefined` | Bindable reference to the active internal table context instance. |
| `element` | `HTMLTableElement` | `undefined` | A bindable reference to the table element. |
| `children` | `Snippet` | `undefined` | Composed table parts. |
| Prop | Type | Default | Description |
| ------------------------ | ------------------------------------------------------------ | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `selectionMode` | `'none' \| 'single' \| 'multiple'` | `'none'` | Controls row selection behavior. |
| `selectionBehavior` | `'toggle' \| 'replace' \| 'checkbox'` | `'toggle'` | `toggle` uses checkbox-style selection. `replace` makes click replace selection, vertical arrows move selection, and `Shift+ArrowUp/Down` extend it. `checkbox` leaves the selection to the checkbox and `Space`: a press only performs the row action. |
| `disabledBehavior` | `'selection' \| 'all'` | `'all'` | Controls whether disabled rows only block selection or block both selection and row actions. |
| `disallowEmptySelection` | `boolean` | `false` | Prevents the internal selection state from becoming empty when selection is enabled. |
| `hiddenColumns` | `Iterable<string>` | `undefined` | Controlled hidden column ids. Supports `bind:hiddenColumns`. |
| `defaultHiddenColumns` | `Iterable<string>` | `undefined` | Initial hidden column ids for uncontrolled usage. |
| `selectedKeys` | `Iterable<string \| number>` | `undefined` | Controlled selected row ids. Supports `bind:selectedKeys`. |
| `defaultSelectedKeys` | `Iterable<string \| number>` | `undefined` | Initial selected row ids for uncontrolled usage. When `selectionMode` later becomes `none`, the internal selection is cleared. |
| `sortDescriptor` | `{ column: string; direction: 'ascending' \| 'descending' }` | `undefined` | Controlled sort state. Supports `bind:sortDescriptor`. Setting it back to `undefined` clears the sort. |
| `defaultSortDescriptor` | `{ column: string; direction: 'ascending' \| 'descending' }` | `undefined` | Initial sort state for uncontrolled usage. |
| `columnWidths` | `Map<string, TableColumnWidth>` | `undefined` | Controlled column width state. Supports px, `%`, and `fr` specs via `bind:columnWidths`. |
| `defaultColumnWidths` | `Iterable<[string, TableColumnWidth]>` | `undefined` | Initial uncontrolled column widths using px, `%`, or `fr` specs. |
| `disabledKeys` | `Iterable<string \| number>` | `undefined` | Row ids that should be non-selectable. |
| `onRowAction` | `(id: string \| number) => void` | `undefined` | Called when a row action is triggered for an actionable row. |
| `onSelectionChange` | `(keys: Set<string \| number>) => void` | `undefined` | Called when row selection changes. |
| `onSortChange` | `(descriptor) => void` | `undefined` | Called when sortable header state changes. |
| `onColumnWidthsChange` | `(widths: Map<string, TableColumnWidth>) => void` | `undefined` | Called when resize interactions update managed column widths. |
| `onHiddenColumnsChange` | `(columnIds: string[]) => void` | `undefined` | Called when hidden column state changes. |
| `onColumnResizeStart` | `(columnId: string) => void` | `undefined` | Called when a column resize drag starts. |
| `onColumnResizeEnd` | `(widths: Map<string, TableColumnWidth>) => void` | `undefined` | Called when a column resize drag ends. |
| `aria-label` | `string` | `undefined` | Accessible name when no external label is present. |
| `aria-labelledby` | `string` | `undefined` | Id reference for an external label. |
| `class` | `string` | `''` | Class names for the root table element. |
| `context` | `TableContext` | `undefined` | Bindable reference to the active internal table context instance. |
| `element` | `HTMLTableElement` | `undefined` | A bindable reference to the table element. |
| `children` | `Snippet` | `undefined` | Composed table parts. |

### Behavior notes

Expand Down
Loading
Loading