ant-design/components/pagination/index.jsx

52 lines
1.1 KiB
React
Raw Normal View History

import React from 'react';
import Pagination from 'rc-pagination';
2015-12-04 14:19:06 +08:00
import Select from '../select';
2015-11-16 14:10:42 +08:00
import zhCN from './locale/zh_CN';
2015-07-13 01:04:05 +08:00
2015-12-04 14:37:30 +08:00
class MiniSelect extends React.Component {
2015-12-04 14:19:06 +08:00
render() {
return <Select size="small" {...this.props} />;
}
2015-12-04 14:37:30 +08:00
}
2015-12-04 14:19:06 +08:00
MiniSelect.Option = Select.Option;
2015-11-16 14:10:42 +08:00
class AntPagination extends React.Component {
2015-07-13 01:04:05 +08:00
render() {
let className = this.props.className;
2015-12-05 13:34:55 +08:00
let selectComponentClass = Select;
2015-12-04 14:19:06 +08:00
2016-03-03 16:28:02 +08:00
let locale;
2016-03-05 16:39:27 +08:00
if (this.context.antLocale && this.context.antLocale.Pagination) {
locale = this.context.antLocale.Pagination;
2016-03-03 16:28:02 +08:00
} else {
locale = this.props.locale;
}
if (this.props.size === 'small') {
className += ' mini';
2015-12-05 13:34:55 +08:00
selectComponentClass = MiniSelect;
}
2015-12-04 14:19:06 +08:00
return (
<Pagination selectComponentClass={selectComponentClass}
selectPrefixCls="ant-select"
{...this.props}
2016-03-03 16:28:02 +08:00
locale={locale}
className={className} />
);
2015-07-13 01:04:05 +08:00
}
}
2015-11-16 14:10:42 +08:00
AntPagination.defaultProps = {
locale: zhCN,
2015-12-04 14:19:06 +08:00
className: '',
2015-12-05 13:34:55 +08:00
prefixCls: 'ant-pagination',
2015-11-16 14:10:42 +08:00
};
2016-03-03 16:28:02 +08:00
AntPagination.contextTypes = {
2016-03-05 16:39:27 +08:00
antLocale: React.PropTypes.object,
2016-03-03 16:28:02 +08:00
};
2015-11-16 14:10:42 +08:00
export default AntPagination;