Skip to content

Commit f2b051b

Browse files
Fix build error and improve data table component
1 parent 835242a commit f2b051b

3 files changed

Lines changed: 19 additions & 10 deletions

File tree

apps/docs/src/remix-hook-form/data-table-router-form.stories.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ function DataTableRouterFormExample() {
136136
}
137137

138138
const handleDataFetch = async ({ request }: ActionFunctionArgs) => {
139+
// Add a small delay to simulate network latency
140+
await new Promise(resolve => setTimeout(resolve, 300));
141+
139142
const url = request.url ? new URL(request.url) : new URL('http://localhost');
140143
const params = url.searchParams;
141144

@@ -192,6 +195,9 @@ const handleDataFetch = async ({ request }: ActionFunctionArgs) => {
192195
const start = safePage * safePageSize;
193196
const paginatedData = filteredData.slice(start, start + safePageSize);
194197

198+
// Log the data being returned for debugging
199+
console.log(`Returning ${paginatedData.length} items, page ${safePage}, total ${filteredData.length}`);
200+
195201
return {
196202
data: paginatedData,
197203
meta: {
@@ -216,6 +222,7 @@ const meta = {
216222
path: '/',
217223
Component: DataTableRouterFormExample,
218224
loader: handleDataFetch,
225+
action: handleDataFetch, // Add action to handle form submissions
219226
},
220227
],
221228
}),

apps/docs/vite.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ export default defineConfig({
2424
historyApiFallback: true,
2525
},
2626
optimizeDeps: {
27-
include: ['nuqs'],
27+
include: [],
2828
},
2929
});

packages/components/src/ui/data-table/data-table-pagination.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ export function DataTablePagination({ pageCount, onPaginationChange }: DataTable
2222
};
2323

2424
return (
25-
<div className="flex items-center justify-between px-2">
26-
<div className="flex-1 text-sm text-muted-foreground">{pageSize} rows per page</div>
27-
<div className="flex items-center space-x-6 lg:space-x-8">
28-
<div className="flex items-center space-x-2">
29-
<p className="text-sm font-medium">Rows per page</p>
25+
<div className="flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between px-2 py-2">
26+
<div className="flex-1 text-sm text-muted-foreground">
27+
{pageSize} rows per page
28+
</div>
29+
<div className="flex flex-col sm:flex-row items-center gap-4 sm:gap-6 lg:gap-8">
30+
<div className="flex items-center gap-2">
31+
<p className="text-sm font-medium whitespace-nowrap">Rows per page</p>
3032
<Select
3133
value={pageSize.toString()}
3234
onValueChange={(value) => {
@@ -41,13 +43,13 @@ export function DataTablePagination({ pageCount, onPaginationChange }: DataTable
4143
]}
4244
/>
4345
</div>
44-
<div className="flex w-[100px] items-center justify-center text-sm font-medium">
46+
<div className="flex w-full sm:w-auto justify-center text-sm font-medium">
4547
Page {page + 1} of {pageCount}
4648
</div>
47-
<div className="flex items-center space-x-2">
49+
<div className="flex items-center justify-center gap-2">
4850
<Button
4951
variant="outline"
50-
className="hidden h-8 w-8 p-0 lg:flex"
52+
className="h-8 w-8 p-0"
5153
onClick={() => updateParams(0, pageSize)}
5254
disabled={page === 0}
5355
>
@@ -74,7 +76,7 @@ export function DataTablePagination({ pageCount, onPaginationChange }: DataTable
7476
</Button>
7577
<Button
7678
variant="outline"
77-
className="hidden h-8 w-8 p-0 lg:flex"
79+
className="h-8 w-8 p-0"
7880
onClick={() => updateParams(pageCount - 1, pageSize)}
7981
disabled={page === pageCount - 1}
8082
>

0 commit comments

Comments
 (0)