"use client"; import type { Table } from "@tanstack/react-table"; import { ChevronLeft, ChevronRight, ChevronsLeft, ChevronsRight } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select"; export interface DataTablePaginationLabels { selectedRows: (selected: number, total: number) => string; rowsPerPage: string; currentPage: (current: number, total: number) => string; goToFirstPage: string; goToPreviousPage: string; goToNextPage: string; goToLastPage: string; } const DEFAULT_LABELS: DataTablePaginationLabels = { selectedRows: (selected, total) => `${selected} of ${total} selected`, rowsPerPage: "Rows per page", currentPage: (current, total) => `Page ${current} of ${total}`, goToFirstPage: "Go to first page", goToPreviousPage: "Go to previous page", goToNextPage: "Go to next page", goToLastPage: "Go to last page", }; interface DataTablePaginationProps { table: Table; labels?: Partial; pageSizeOptions?: number[]; } export function DataTablePagination({ table, labels, pageSizeOptions = [10, 20, 30, 40, 50], }: DataTablePaginationProps) { const t = { ...DEFAULT_LABELS, ...labels }; return (
{t.selectedRows( table.getFilteredSelectedRowModel().rows.length, table.getFilteredRowModel().rows.length, )}

{t.rowsPerPage}

{t.currentPage(table.getState().pagination.pageIndex + 1, table.getPageCount())}
); }