import clsx from "clsx" import type { JSX } from "react" import { Select } from "../../selection" import { PAGE_SIZE_OPTIONS } from "./constants" import type { OffsetPaginationProps } from "./OffsetPagination.types" import { Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, } from "./Pagination" import { useOffsetPagination } from "./useOffsetPagination" export const OffsetPagination = ({ currentPage, totalPages, totalItems, pageSize, onPageChange, onPageSizeChange, pageSizeOptions = PAGE_SIZE_OPTIONS, className, selectedRows = 0, totalRows = 0, nextBtnText = "", prevBtnText = "", }: OffsetPaginationProps): JSX.Element => { const { pageNumbers, handlePageChange, handlePageSizeChange, handlePreviousPage, handleNextPage, isPreviousDisabled, isNextDisabled, } = useOffsetPagination({ currentPage, totalPages, totalItems, pageSize, onPageChange, onPageSizeChange, pageSizeOptions, selectedRows, totalRows, }) return (
{pageNumbers.map((page, idx) => ( {page === "ellipsis" ? ( ) : ( handlePageChange(Number(page)) : undefined} > {page} )} ))} {onPageSizeChange && ( handlePageSizeChange(Number(value))} > {pageSizeOptions.map(size => ( {`${size} / page`} ))} )}
) }