@douyinfe/semi-ui
Version:
A modern, comprehensive, flexible design system and UI library. Connect DesignOps & DevOps. Quickly build beautiful React apps. Maintained by Douyin-fe team.
107 lines (106 loc) • 4.37 kB
TypeScript
import React from 'react';
import PropTypes from 'prop-types';
import { PageList, PaginationAdapter } from '@douyinfe/semi-foundation/lib/es/pagination/foundation';
import '@douyinfe/semi-foundation/lib/es/pagination/pagination.css';
import { ContextValue } from '../configProvider/context';
import { Locale } from '../locale/interface';
import BaseComponent from '../_base/baseComponent';
import { Position } from '../tooltip';
export interface PaginationProps {
total?: number;
showTotal?: boolean;
pageSize?: number;
pageSizeOpts?: Array<number>;
size?: 'small' | 'default';
currentPage?: number;
defaultCurrentPage?: number;
onPageChange?: (currentPage: number) => void;
onPageSizeChange?: (newPageSize: number) => void;
onChange?: (currentPage: number, pageSize: number) => void;
prevText?: React.ReactNode;
nextText?: React.ReactNode;
showSizeChanger?: boolean;
showQuickJumper?: boolean;
popoverZIndex?: number;
popoverPosition?: PopoverPosition;
style?: React.CSSProperties;
className?: string;
hideOnSinglePage?: boolean;
hoverShowPageSelect?: boolean;
disabled?: boolean;
}
export interface PaginationState {
total: number;
showTotal: boolean;
currentPage: number;
pageSize: number;
pageList: PageList;
prevDisabled: boolean;
quickJumpPage: string | number;
nextDisabled: boolean;
restLeftPageList: number[];
restRightPageList: number[];
allPageNumbers: number[];
}
export type PaginationLocale = Locale['Pagination'];
export type PopoverPosition = Position;
export type { PageList };
export default class Pagination extends BaseComponent<PaginationProps, PaginationState> {
static contextType: React.Context<ContextValue>;
static propTypes: {
total: PropTypes.Requireable<number>;
showTotal: PropTypes.Requireable<boolean>;
pageSize: PropTypes.Requireable<number>;
pageSizeOpts: PropTypes.Requireable<any[]>;
size: PropTypes.Requireable<string>;
currentPage: PropTypes.Requireable<number>;
defaultCurrentPage: PropTypes.Requireable<number>;
onPageChange: PropTypes.Requireable<(...args: any[]) => any>;
onPageSizeChange: PropTypes.Requireable<(...args: any[]) => any>;
onChange: PropTypes.Requireable<(...args: any[]) => any>;
prevText: PropTypes.Requireable<PropTypes.ReactNodeLike>;
nextText: PropTypes.Requireable<PropTypes.ReactNodeLike>;
showSizeChanger: PropTypes.Requireable<boolean>;
popoverZIndex: PropTypes.Requireable<number>;
popoverPosition: PropTypes.Requireable<string>;
style: PropTypes.Requireable<object>;
className: PropTypes.Requireable<string>;
hideOnSinglePage: PropTypes.Requireable<boolean>;
hoverShowPageSelect: PropTypes.Requireable<boolean>;
showQuickJumper: PropTypes.Requireable<boolean>;
disabled: PropTypes.Requireable<boolean>;
};
static defaultProps: {
total: number;
popoverZIndex: number;
showTotal: boolean;
pageSize: null;
pageSizeOpts: readonly [10, 20, 40, 100];
defaultCurrentPage: number;
size: string;
onPageChange: (...args: any[]) => void;
onPageSizeChange: (...args: any[]) => void;
onChange: (...args: any[]) => void;
showSizeChanger: boolean;
className: string;
hideOnSinglePage: boolean;
showQuickJumper: boolean;
disabled: boolean;
};
constructor(props: PaginationProps);
context: ContextValue;
get adapter(): PaginationAdapter<PaginationProps, PaginationState>;
componentDidMount(): void;
componentWillUnmount(): void;
componentDidUpdate(prevProps: PaginationProps): void;
renderPrevBtn(): React.JSX.Element;
renderNextBtn(): React.JSX.Element;
renderPageSizeSwitch(locale: PaginationLocale): React.JSX.Element;
renderQuickJump(locale: PaginationLocale): React.JSX.Element;
renderPageList(): React.JSX.Element[];
renderRestPageList(restList: ('...' | number)[]): React.JSX.Element;
renderSmallPageSelect(content: React.ReactNode): React.JSX.Element;
renderSmallPage(locale: PaginationLocale): React.JSX.Element;
renderDefaultPage(locale: PaginationLocale): React.JSX.Element;
render(): React.JSX.Element;
}