mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
* fix: add page size selector to CardsWithPagination Add an optional pageSizeOptions prop to CardsWithPagination that renders a "Cards per page" dropdown selector, consistent with the existing TablePaginationSize pattern used in DataTable. - New PaginationSize component (standalone, no TanStack Table dependency) - CardsWithPagination: manage pageSize as state, reset to page 1 on change - Project databases page: increase default from 6 to 20, add selector [10, 20, 50] - Projects list page: increase default from 9 to 12, add selector [12, 24, 48] - Fully backward compatible: without pageSizeOptions, behavior is unchanged Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: address CodeRabbit review feedback - Validate pageSize in handlePageSizeChange (reject 0/negative/NaN) - Guard empty pageSizeOptions array from rendering empty selector - Restore className on PaginationNavigation for backward compatibility - Add aria-label to SelectTrigger for accessibility on small screens Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(pagination-size): fallback to pageSizeOptions[0] when pageSize not in options Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(pagination-size): fix pageSize is not defined (placeholder ref) --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
36 lines
1.4 KiB
TypeScript
36 lines
1.4 KiB
TypeScript
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
|
import { cn } from "@/lib/utils";
|
|
|
|
export type PaginationSizeProps = {
|
|
className?: string;
|
|
pageSize: number;
|
|
onPageSizeChange: (size: number) => void;
|
|
pageSizeOptions?: number[];
|
|
};
|
|
|
|
export const PaginationSize = (props: PaginationSizeProps) => {
|
|
const { className, onPageSizeChange, pageSizeOptions = [10, 20, 30, 40, 50] } = props;
|
|
const effectivePageSize = pageSizeOptions.includes(props.pageSize) ? props.pageSize : pageSizeOptions[0];
|
|
|
|
return (
|
|
<div className={cn("flex items-center justify-end sm:justify-center space-x-2", className)}>
|
|
<p className="whitespace-nowrap text-sm font-medium hidden md:block">Cards per page</p>
|
|
<Select
|
|
value={`${effectivePageSize}`}
|
|
onValueChange={(value) => onPageSizeChange(Number(value))}
|
|
>
|
|
<SelectTrigger className="h-8 w-[4.5rem]" aria-label="Cards per page">
|
|
<SelectValue placeholder={effectivePageSize} />
|
|
</SelectTrigger>
|
|
<SelectContent side="top">
|
|
{pageSizeOptions.map((size) => (
|
|
<SelectItem key={size} value={`${size}`}>
|
|
{size}
|
|
</SelectItem>
|
|
))}
|
|
</SelectContent>
|
|
</Select>
|
|
</div>
|
|
);
|
|
};
|