import { Plural, Trans } from '@lingui/macro'; import type { 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 ( ); }) .with('None', () => null) .exhaustive()}

Rows per page

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