ant-design-vue/components/pagination/Pagination.jsx

80 lines
2.0 KiB
React
Raw Normal View History

2018-03-19 02:16:27 +00:00
2018-03-05 11:06:44 +00:00
import PropTypes from '../_util/vue-types'
import VcSelect from '../select'
2018-03-06 07:40:42 +00:00
import MiniSelect from './MiniSelect'
2018-03-05 11:06:44 +00:00
import enUS from '../vc-pagination/locale/en_US'
import LocaleReceiver from '../locale-provider/LocaleReceiver'
import { getOptionProps } from '../_util/props-util'
import VcPagination from '../vc-pagination'
2018-03-29 14:08:04 +00:00
export const PaginationProps = () => ({
2018-03-05 11:06:44 +00:00
total: PropTypes.number,
defaultCurrent: PropTypes.number,
current: PropTypes.number,
defaultPageSize: PropTypes.number,
pageSize: PropTypes.number,
hideOnSinglePage: PropTypes.bool,
showSizeChanger: PropTypes.bool,
pageSizeOptions: PropTypes.arrayOf(PropTypes.oneOfType([
PropTypes.number,
PropTypes.string,
])),
2018-03-06 07:40:42 +00:00
buildOptionText: PropTypes.func,
2018-03-05 11:06:44 +00:00
showSizeChange: PropTypes.func,
showQuickJumper: PropTypes.bool,
showTotal: PropTypes.any,
size: PropTypes.string,
simple: PropTypes.bool,
locale: PropTypes.object,
prefixCls: PropTypes.string,
selectPrefixCls: PropTypes.string,
itemRender: PropTypes.any,
2018-03-29 14:08:04 +00:00
})
2018-01-22 13:27:37 +00:00
export default {
2018-04-08 13:17:20 +00:00
name: 'APagination',
2018-01-22 13:27:37 +00:00
props: {
2018-03-29 14:08:04 +00:00
...PaginationProps(),
2018-03-05 11:06:44 +00:00
prefixCls: PropTypes.string.def('ant-pagination'),
selectPrefixCls: PropTypes.string.def('ant-select'),
2018-01-22 13:27:37 +00:00
},
model: {
prop: 'current',
2018-03-09 10:52:31 +00:00
event: 'change',
2018-01-22 13:27:37 +00:00
},
methods: {
2018-03-05 11:06:44 +00:00
renderPagination (locale) {
2018-03-06 07:40:42 +00:00
const { buildOptionText, size, ...restProps } = getOptionProps(this)
2018-03-05 11:06:44 +00:00
const isSmall = size === 'small'
const paginationProps = {
props: {
...restProps,
2018-03-06 07:40:42 +00:00
selectComponentClass: (isSmall ? MiniSelect : VcSelect),
2018-03-05 11:06:44 +00:00
locale,
2018-03-06 07:40:42 +00:00
buildOptionText: buildOptionText || this.$scopedSlots.buildOptionText,
2018-03-05 11:06:44 +00:00
},
class: {
'mini': isSmall,
},
on: this.$listeners,
2018-01-22 13:27:37 +00:00
}
return (
2018-03-05 11:06:44 +00:00
<VcPagination
{...paginationProps}
2018-01-22 13:27:37 +00:00
/>
)
2018-03-05 11:06:44 +00:00
},
},
render () {
2018-01-22 13:27:37 +00:00
return (
2018-03-05 11:06:44 +00:00
<LocaleReceiver
componentName='Pagination'
defaultLocale={enUS}
children={this.renderPagination}
/>
2018-01-22 13:27:37 +00:00
)
},
}
2018-03-19 02:16:27 +00:00