import * as React from 'react'; import RcPagination from 'rc-pagination'; import enUS from 'rc-pagination/lib/locale/en_US'; import classNames from 'classnames'; import LeftOutlined from '@ant-design/icons/LeftOutlined'; import RightOutlined from '@ant-design/icons/RightOutlined'; import DoubleLeftOutlined from '@ant-design/icons/DoubleLeftOutlined'; import DoubleRightOutlined from '@ant-design/icons/DoubleRightOutlined'; import MiniSelect from './MiniSelect'; import Select from '../select'; import LocaleReceiver from '../locale-provider/LocaleReceiver'; import { ConfigContext } from '../config-provider'; import useBreakpoint from '../grid/hooks/useBreakpoint'; export interface PaginationProps { total?: number; defaultCurrent?: number; disabled?: boolean; current?: number; defaultPageSize?: number; pageSize?: number; onChange?: (page: number, pageSize?: number) => void; hideOnSinglePage?: boolean; showSizeChanger?: boolean; pageSizeOptions?: string[]; onShowSizeChange?: (current: number, size: number) => void; showQuickJumper?: boolean | { goButton?: React.ReactNode }; showTitle?: boolean; showTotal?: (total: number, range: [number, number]) => React.ReactNode; size?: 'default' | 'small'; responsive?: boolean; simple?: boolean; style?: React.CSSProperties; locale?: Object; className?: string; prefixCls?: string; selectPrefixCls?: string; itemRender?: ( page: number, type: 'page' | 'prev' | 'next' | 'jump-prev' | 'jump-next', originalElement: React.ReactElement, ) => React.ReactNode; role?: string; showLessItems?: boolean; } export type PaginationPosition = 'top' | 'bottom' | 'both'; export interface PaginationConfig extends PaginationProps { position?: PaginationPosition; } export type PaginationLocale = any; const Pagination: React.FC = ({ prefixCls: customizePrefixCls, selectPrefixCls: customizeSelectPrefixCls, className, size, locale: customLocale, ...restProps }) => { const { xs } = useBreakpoint(); const { getPrefixCls, direction } = React.useContext(ConfigContext); const prefixCls = getPrefixCls('pagination', customizePrefixCls); const getIconsProps = () => { let prevIcon = ( ); let nextIcon = ( ); let jumpPrevIcon = ( {/* You can use transition effects in the container :) */}
•••
); let jumpNextIcon = ( {/* You can use transition effects in the container :) */}
•••
); // change arrows direction in right-to-left direction if (direction === 'rtl') { let temp: any; temp = prevIcon; prevIcon = nextIcon; nextIcon = temp; temp = jumpPrevIcon; jumpPrevIcon = jumpNextIcon; jumpNextIcon = temp; } return { prevIcon, nextIcon, jumpPrevIcon, jumpNextIcon, }; }; const renderPagination = (contextLocale: PaginationLocale) => { const locale = { ...contextLocale, ...customLocale }; const isSmall = size === 'small' || !!(xs && !size && restProps.responsive); const selectPrefixCls = getPrefixCls('select', customizeSelectPrefixCls); const extendedClassName = classNames(className, { mini: isSmall, [`${prefixCls}-rtl`]: direction === 'rtl', }); return ( ); }; return ( {renderPagination} ); }; export default Pagination;