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
16 changes: 16 additions & 0 deletions .changeset/witty-mice-drum.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
"@tailor-platform/app-shell": minor
---

Add `useURLCollectionVariables` for wiring collection state (filters, sort, page size) to the URL query string in a single call. It seeds initial state from the current router search params and writes changes back as the user filters, sorts, or pages.

```tsx
const { variables, control } = useURLCollectionVariables({
tableMetadata,
params: { pageSize: 20 },
});
```

For cases that need URL persistence without react-router's `useSearchParams` (e.g. a custom binding), the pure `withURLCollectionState(options, [searchParams, setSearchParams])` decorator is also exported and can be composed with `useCollectionVariables` directly.

`useCollectionVariables` now reports state updates through `onParamsChange` using the same `params` shape it accepts.
4 changes: 2 additions & 2 deletions examples/nextjs-app/src/modules/pages/data-table-demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
defineResource,
DataTable,
useDataTable,
useCollectionVariables,
useURLCollectionVariables,
createColumnHelper,
Layout,
type RowAction,
Expand Down Expand Up @@ -140,7 +140,7 @@ const productRowActions: RowAction<Product>[] = [
// ---------------------------------------------------------------------------

const DataTableDemoPage = () => {
const { variables, control } = useCollectionVariables({
const { variables, control } = useURLCollectionVariables({
params: { pageSize: 5 },
tableMetadata: productMetadata,
});
Expand Down
1 change: 1 addition & 0 deletions examples/vite-app/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const App = () => {
<SidebarGroup title={labels.t("navMain")}>
<SidebarItem to="/dashboard" activeMatch="exact" />
<SidebarItem to="/dashboard/orders" />
<SidebarItem to="/dashboard/products" />
</SidebarGroup>
<SidebarItem to="/settings" />
</DefaultSidebar>
Expand Down
Loading
Loading