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

80 lines
2.0 KiB
Vue
Raw Normal View History

2018-03-19 10:16:27 +08:00
2018-03-05 19:06:44 +08:00
import PropTypes from '../_util/vue-types'
import VcSelect from '../select'
2018-03-06 15:40:42 +08:00
import MiniSelect from './MiniSelect'
2018-03-05 19:06:44 +08: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 22:08:04 +08:00
export const PaginationProps = () => ({
2018-03-05 19:06:44 +08: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 15:40:42 +08:00
buildOptionText: PropTypes.func,
2018-03-05 19:06:44 +08: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 22:08:04 +08:00
})
2018-01-22 21:27:37 +08:00
export default {
2018-04-08 21:17:20 +08:00
name: 'APagination',
2018-01-22 21:27:37 +08:00
props: {
2018-03-29 22:08:04 +08:00
...PaginationProps(),
2018-03-05 19:06:44 +08:00
prefixCls: PropTypes.string.def('ant-pagination'),
selectPrefixCls: PropTypes.string.def('ant-select'),
2018-01-22 21:27:37 +08:00
},
model: {
prop: 'current',
2018-03-09 18:52:31 +08:00
event: 'change',
2018-01-22 21:27:37 +08:00
},
methods: {
2018-03-05 19:06:44 +08:00
renderPagination (locale) {
2018-03-06 15:40:42 +08:00
const { buildOptionText, size, ...restProps } = getOptionProps(this)
2018-03-05 19:06:44 +08:00
const isSmall = size === 'small'
const paginationProps = {
props: {
...restProps,
2018-03-06 15:40:42 +08:00
selectComponentClass: (isSmall ? MiniSelect : VcSelect),
2018-03-05 19:06:44 +08:00
locale,
2018-03-06 15:40:42 +08:00
buildOptionText: buildOptionText || this.$scopedSlots.buildOptionText,
2018-03-05 19:06:44 +08:00
},
class: {
'mini': isSmall,
},
on: this.$listeners,
2018-01-22 21:27:37 +08:00
}
return (
2018-03-05 19:06:44 +08:00
<VcPagination
{...paginationProps}
2018-01-22 21:27:37 +08:00
/>
)
2018-03-05 19:06:44 +08:00
},
},
render () {
2018-01-22 21:27:37 +08:00
return (
2018-03-05 19:06:44 +08:00
<LocaleReceiver
componentName='Pagination'
defaultLocale={enUS}
children={this.renderPagination}
/>
2018-01-22 21:27:37 +08:00
)
},
}
2018-03-19 10:16:27 +08:00