import { Table } from '@tanstack/react-table'; import { useCallback } from 'react'; import { GotoFirstIcon, GotoLastIcon, GotoNextIcon, GotoPrevIcon } from '../Icons'; interface PaginationToolsProps { table: Table paginationOptions: number[] onChangePaginationOption?: (newValue: number) => void } function PaginationTools({ table, paginationOptions, onChangePaginationOption }: PaginationToolsProps) { const handlePaginationOptionsChange = useCallback( (event: React.ChangeEvent) => { const perPage = Number(event.target.value); table.setPageSize(perPage); if (onChangePaginationOption) { onChangePaginationOption(perPage); } }, [onChangePaginationOption, table]); return (
{table.getState().pagination.pageIndex * table.getState().pagination.pageSize + 1} - {Math.min(table.getFilteredRowModel().rows.length, (table.getState().pagination.pageIndex + 1) * table.getState().pagination.pageSize)}
из
{table.getFilteredRowModel().rows.length}
{ const page = event.target.value ? Number(event.target.value) - 1 : 0; if (page + 1 <= table.getPageCount()) { table.setPageIndex(page); } }} />
); } export default PaginationTools;