import clsx from "clsx"; import { useI18n } from "../../hooks/useI18n.js"; import type { FormOptions } from "../../interfaces/index.js"; import { getComponent, registerComponent } from "../../registries/components"; import type { Select as DefaultSelect } from "../forms/select/Select"; import type { PaginationButton as DefaultPaginationButton } from "./PaginationButton"; import { getPageNumbers, LEFT_PAGE, RIGHT_PAGE } from "./utils/getPageNumbers.js"; export interface PaginationProps { className?: string; pageSizes?: number[]; canPreviousPage: boolean; canNextPage: boolean; pageCount: number; pageIndex: number; pageOptions?: number[]; pageSize: number; rowCount?: number; layout?: "html5" | "react" | "choicesjs"; i18n?: FormOptions["i18n"]; onPageIndexChange: (pageIndex: number) => void; onClickPreviousPage: () => void; onClickNextPage: () => void; onPageSizeChange: (pageSize: number) => void; } export function Pagination(props: PaginationProps) { const { className, pageSizes = [10, 25, 50, 100], onPageIndexChange, canPreviousPage, onClickPreviousPage, onClickNextPage, canNextPage, pageCount, pageIndex = 1, pageOptions, pageSize, onPageSizeChange, rowCount } = props; const { t } = useI18n(props.i18n); const pageNumbers = getPageNumbers({ currentPage: pageIndex, // pageNeighbours, totalPages: pageCount }); const options: any[] = pageSizes.map((value) => ({ value, label: value })); const Select = getComponent("Select"); const PaginationButton = getComponent("PaginationButton"); return ( ); } registerComponent("Pagination", Pagination);