import classNames from 'classnames'; import { FC, WebCellProps } from 'web-cell'; import { buildURLData, parseURLData } from 'web-utility'; import { FormControl } from '../Form/Form'; export interface PaginationProps extends WebCellProps { size?: 'sm' | 'lg'; } export const Pagination: FC = ({ size, children, ...props }) => ( ); export interface PaginationItemProps extends WebCellProps { href?: string; active?: boolean; disabled?: boolean; } export const PaginationItem: FC = ({ className, href, active, disabled, children, ...props }) => (
  • {children}
  • ); export type PageMeta = Record<'pageSize' | 'pageIndex', number>; export interface PagerProps extends PageMeta { pageCount: number; onChange?: (meta: PageMeta) => any; } export const Pager: FC = ({ pageSize, pageIndex, pageCount, onChange }) => { function propsOf(pageIndex = 1) { const pagination = { pageSize, pageIndex }; return { href: `?${buildURLData({ ...parseURLData(), ...pagination })}`, onClick: onChange && ((event: MouseEvent) => { event.preventDefault(); onChange(pagination); }) }; } return (
    event.preventDefault())} > { const input = currentTarget as HTMLInputElement; input.reportValidity(); onChange?.({ pageSize: +input.value, pageIndex }); }} /> x { const input = currentTarget as HTMLInputElement; input.reportValidity(); onChange?.({ pageSize, pageIndex: +input.value }); }} /> {pageIndex > 1 && ( 1 )} {pageIndex > 3 && ...} {pageIndex > 2 && ( {pageIndex - 1} )} {pageIndex} {pageCount - pageIndex > 1 && ( {pageIndex + 1} )} {pageCount - pageIndex > 2 && ( ... )} {pageIndex < pageCount && ( {pageCount} )} ); };