import { ActionIcon, Flex, Pagination, Select, Text, type Sx, } from '@mantine/core'; import {type MRT_TableInstance} from '../types'; interface Props = {}> { position?: 'top' | 'bottom'; table: MRT_TableInstance; } const commonActionButtonStyles: Sx = { userSelect: 'none', '&:disabled': { backgroundColor: 'transparent', border: 'none', }, }; export const MRT_TablePagination = = {}>({table}: Props) => { const { getPrePaginationRowModel, getState, setPageIndex, setPageSize, options: { icons: { IconChevronLeftPipe, IconChevronRightPipe, IconChevronLeft, IconChevronRight, }, localization, mantinePaginationProps, paginationDisplayMode, rowCount, }, } = table; const { pagination: {pageSize = 10, pageIndex = 0}, } = getState(); const paginationProps = mantinePaginationProps instanceof Function ? mantinePaginationProps({table}) : mantinePaginationProps; const totalRowCount = rowCount ?? getPrePaginationRowModel().rows.length; const numberOfPages = Math.ceil(totalRowCount / pageSize); const showFirstLastPageButtons = numberOfPages > 2 && paginationProps?.withEdges !== false; const firstRowIndex = pageIndex * pageSize; const lastRowIndex = Math.min(pageIndex * pageSize + pageSize, totalRowCount); return ( {paginationProps?.showRowsPerPage !== false && (