ant-design/components/pagination/index.jsx

50 lines
1.1 KiB
React
Raw Normal View History

import React from 'react';
import RcPagination 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 {
static Option = Select.Option;
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
export default class Pagination extends React.Component {
static defaultProps = {
locale: zhCN,
className: '',
prefixCls: 'ant-pagination',
}
static contextTypes = {
antLocale: React.PropTypes.object,
}
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 (
<RcPagination 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
}
}