ant-design/components/pagination/Pagination.tsx

55 lines
1.5 KiB
TypeScript
Raw Normal View History

2016-09-21 11:54:53 +08:00
import React from 'react';
2016-03-31 17:46:35 +08:00
import RcPagination from 'rc-pagination';
import zhCN from 'rc-pagination/lib/locale/zh_CN';
import classNames from 'classnames';
import injectLocale from '../locale-provider/injectLocale';
2016-03-31 17:46:35 +08:00
import Select from '../select';
import MiniSelect from './MiniSelect';
export interface PaginationProps {
total: number;
defaultCurrent?: number;
current?: number;
defaultPageSize?: number;
pageSize?: number;
onChange?: (page: number, pageSize: number) => void;
showSizeChanger?: boolean;
pageSizeOptions?: string[];
onShowSizeChange?: (current: number, size: number) => void;
showQuickJumper?: boolean;
showTotal?: (total: number) => React.ReactNode;
size?: string;
simple?: boolean;
style?: React.CSSProperties;
locale?: Object;
className?: string;
prefixCls?: string;
selectPrefixCls?: string;
}
abstract class Pagination extends React.Component<PaginationProps, any> {
2016-03-31 17:46:35 +08:00
static defaultProps = {
prefixCls: 'ant-pagination',
selectPrefixCls: 'ant-select',
2016-07-13 11:14:24 +08:00
};
2016-03-31 17:46:35 +08:00
abstract getLocale()
2016-03-31 17:46:35 +08:00
render() {
const { className, size, ...restProps } = this.props;
const locale = this.getLocale();
const isSmall = size === 'small';
2016-03-31 17:46:35 +08:00
return (
<RcPagination
{...restProps}
className={classNames(className, { mini: isSmall })}
selectComponentClass={isSmall ? MiniSelect : Select}
2016-03-31 17:46:35 +08:00
locale={locale}
/>
2016-03-31 17:46:35 +08:00
);
}
}
const injectPaginationLocale = injectLocale('Pagination', zhCN);
export default injectPaginationLocale<PaginationProps>(Pagination as any);