diff --git a/.changeset/clear-kites-select.md b/.changeset/clear-kites-select.md new file mode 100644 index 000000000..b6bd62c55 --- /dev/null +++ b/.changeset/clear-kites-select.md @@ -0,0 +1,13 @@ +--- +"@tailor-platform/app-shell": minor +--- + +Add controlled and uncontrolled row selection through `useDataTable`'s `rowSelection` option. Pass `selectedIds` with `onChange` to control selection, or `defaultSelectedIds` to initialize table-owned selection. The existing `onSelectionChange` callback is deprecated in favor of `rowSelection.onChange`, but remains supported for compatibility. + +```tsx +const table = useDataTable({ + columns, + data, + rowSelection: { selectedIds, onChange: setSelectedIds }, +}); +``` diff --git a/docs-manifest.json b/docs-manifest.json index 06036a7e7..6181d4702 100644 --- a/docs-manifest.json +++ b/docs-manifest.json @@ -421,6 +421,7 @@ "PageInfo", "PaginationVariables", "RowAction", + "RowSelectionOptions", "SelectOption", "SelectionAction", "SelectionActionHelpers", @@ -446,10 +447,10 @@ "withURLCollectionState" ], "hashes": { - "typeSurface": "fe43108015be4a00", - "outline": "dc0b82256114191b", + "typeSurface": "6420153668673350", + "outline": "8a885df3785f3a03", "snapshot": null, - "outputMd": "3e8474e4d1437c91", + "outputMd": "8848cda0fe63b441", "examples": null } }, @@ -1693,7 +1694,7 @@ "packages/core/skills/app-shell-patterns/references/components/combobox.md": "dfb775c7c4307409", "packages/core/skills/app-shell-patterns/references/components/command-palette.md": "7e5bc675a593791a", "packages/core/skills/app-shell-patterns/references/components/csv-importer.md": "53d3c795ca21b9dc", - "packages/core/skills/app-shell-patterns/references/components/data-table.md": "3e8474e4d1437c91", + "packages/core/skills/app-shell-patterns/references/components/data-table.md": "8848cda0fe63b441", "packages/core/skills/app-shell-patterns/references/components/date-picker.md": "f39002ad79625dc4", "packages/core/skills/app-shell-patterns/references/components/default-header.md": "375e55f4b12fa2be", "packages/core/skills/app-shell-patterns/references/components/default-sidebar.md": "3422388a0cc78571", diff --git a/docs-src/components/data-table.docs.outline.md b/docs-src/components/data-table.docs.outline.md index 8e4b23a06..1cb633898 100644 --- a/docs-src/components/data-table.docs.outline.md +++ b/docs-src/components/data-table.docs.outline.md @@ -30,6 +30,7 @@ import { type DataTablePaginationProps, type DataTableAction, type RowAction, + type RowSelectionOptions, type SelectionAction, type UseDataTableOptions, type UseDataTableReturn, @@ -228,7 +229,7 @@ By default `DataTable.Filters` renders the active filter chips plus the **Add fi | Rows selected and `total` is not provided | `Y row(s) selected` | | No selection enabled and no `total` | _(nothing displayed)_ | -Row selection is enabled by providing `onSelectionChange` or `selectionActions` to `useDataTable`. The `total` value comes from `DataTableData.total`. While the footer shows the bulk-action bar (see [Selection actions](#selection-actions)), the bar owns the selection count and this text is omitted. +Row selection is enabled by providing `rowSelection`, `onSelectionChange`, or a non-empty `selectionActions` array to `useDataTable`. The `total` value comes from `DataTableData.total`. While the footer shows the bulk-action bar (see [Selection actions](#selection-actions)), the bar owns the selection count and this text is omitted. When pagination changes page or page size, `DataTable.Table` resets its own scroll container to the top automatically. That applies whether navigation comes from the built-in `DataTable.Pagination` or from custom controls using the same table context. @@ -376,9 +377,45 @@ The trigger is a native `