import { Table } from '@tanstack/react-table'; import { ChevronLeft, ChevronRight, ChevronsLeft, ChevronsRight } from 'lucide-react'; import { match } from 'ts-pattern'; import { Button } from './button'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from './select'; interface DataTablePaginationProps { table: Table; /** * The type of information to show on the left hand side of the pagination. * * Defaults to 'VisibleCount'. */ additionalInformation?: 'SelectedCount' | 'VisibleCount' | 'None'; } export function DataTablePagination({ table, additionalInformation = 'VisibleCount', }: DataTablePaginationProps) { return (
{match(additionalInformation) .with('SelectedCount', () => ( {table.getFilteredSelectedRowModel().rows.length} of{' '} {table.getFilteredRowModel().rows.length} row(s) selected. )) .with('VisibleCount', () => { const visibleRows = table.getFilteredRowModel().rows.length; return ( Showing {visibleRows} result{visibleRows > 1 && 's'}. ); }) .with('None', () => null) .exhaustive()}

Rows per page

Page {table.getState().pagination.pageIndex + 1} of {table.getPageCount()}
); }