ant-design/components/pagination/Pagination.tsx
Benjy Cui 829b5f87bf feat: make default locale to enUS (#7553)
* feat: make default locale to enUS

* test: fix CI

* docs: update getting started
2017-09-26 23:12:47 +08:00

56 lines
1.7 KiB
TypeScript

import React from 'react';
import RcPagination from 'rc-pagination';
import enUS from 'rc-pagination/lib/locale/en_US';
import classNames from 'classnames';
import injectLocale from '../locale-provider/injectLocale';
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, range: [number, number]) => React.ReactNode;
size?: string;
simple?: boolean;
style?: React.CSSProperties;
locale?: Object;
className?: string;
prefixCls?: string;
selectPrefixCls?: string;
itemRender?: (page: number, type: 'page' | 'prev' | 'next' | 'jump-prev' | 'jump-next') => React.ReactNode;
}
abstract class Pagination extends React.Component<PaginationProps, any> {
static defaultProps = {
prefixCls: 'ant-pagination',
selectPrefixCls: 'ant-select',
};
abstract getLocale();
render() {
const { className, size, ...restProps } = this.props;
const locale = this.getLocale();
const isSmall = size === 'small';
return (
<RcPagination
{...restProps}
className={classNames(className, { mini: isSmall })}
selectComponentClass={isSmall ? MiniSelect : Select}
locale={locale}
/>
);
}
}
const injectPaginationLocale = injectLocale('Pagination', enUS);
export default injectPaginationLocale<PaginationProps>(Pagination as any);