123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
- import _extends from 'babel-runtime/helpers/extends';
- import PropTypes from '../_util/vue-types';
- import VcSelect from '../select';
- import MiniSelect from './MiniSelect';
- import LocaleReceiver from '../locale-provider/LocaleReceiver';
- import { getOptionProps, getListeners } from '../_util/props-util';
- import VcPagination from '../vc-pagination';
- import enUS from '../vc-pagination/locale/en_US';
- import Icon from '../icon';
- import { ConfigConsumerProps } from '../config-provider/configConsumerProps';
- export var PaginationProps = function PaginationProps() {
- return {
- total: PropTypes.number,
- defaultCurrent: PropTypes.number,
- disabled: PropTypes.bool,
- current: PropTypes.number,
- defaultPageSize: PropTypes.number,
- pageSize: PropTypes.number,
- hideOnSinglePage: PropTypes.bool,
- showSizeChanger: PropTypes.bool,
- pageSizeOptions: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])),
- buildOptionText: PropTypes.func,
- showSizeChange: PropTypes.func,
- showQuickJumper: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]),
- showTotal: PropTypes.any,
- size: PropTypes.string,
- simple: PropTypes.bool,
- locale: PropTypes.object,
- prefixCls: PropTypes.string,
- selectPrefixCls: PropTypes.string,
- itemRender: PropTypes.any,
- role: PropTypes.string,
- showLessItems: PropTypes.bool
- };
- };
- export var PaginationConfig = function PaginationConfig() {
- return _extends({}, PaginationProps(), {
- position: PropTypes.oneOf(['top', 'bottom', 'both'])
- });
- };
- export default {
- name: 'APagination',
- model: {
- prop: 'current',
- event: 'change.current'
- },
- props: _extends({}, PaginationProps()),
- inject: {
- configProvider: { 'default': function _default() {
- return ConfigConsumerProps;
- } }
- },
- methods: {
- getIconsProps: function getIconsProps(prefixCls) {
- var h = this.$createElement;
- var prevIcon = h(
- 'a',
- { 'class': prefixCls + '-item-link' },
- [h(Icon, {
- attrs: { type: 'left' }
- })]
- );
- var nextIcon = h(
- 'a',
- { 'class': prefixCls + '-item-link' },
- [h(Icon, {
- attrs: { type: 'right' }
- })]
- );
- var jumpPrevIcon = h(
- 'a',
- { 'class': prefixCls + '-item-link' },
- [h(
- 'div',
- { 'class': prefixCls + '-item-container' },
- [h(Icon, { 'class': prefixCls + '-item-link-icon', attrs: { type: 'double-left' }
- }), h(
- 'span',
- { 'class': prefixCls + '-item-ellipsis' },
- ['\u2022\u2022\u2022']
- )]
- )]
- );
- var jumpNextIcon = h(
- 'a',
- { 'class': prefixCls + '-item-link' },
- [h(
- 'div',
- { 'class': prefixCls + '-item-container' },
- [h(Icon, { 'class': prefixCls + '-item-link-icon', attrs: { type: 'double-right' }
- }), h(
- 'span',
- { 'class': prefixCls + '-item-ellipsis' },
- ['\u2022\u2022\u2022']
- )]
- )]
- );
- return {
- prevIcon: prevIcon,
- nextIcon: nextIcon,
- jumpPrevIcon: jumpPrevIcon,
- jumpNextIcon: jumpNextIcon
- };
- },
- renderPagination: function renderPagination(contextLocale) {
- var h = this.$createElement;
- var _getOptionProps = getOptionProps(this),
- customizePrefixCls = _getOptionProps.prefixCls,
- customizeSelectPrefixCls = _getOptionProps.selectPrefixCls,
- buildOptionText = _getOptionProps.buildOptionText,
- size = _getOptionProps.size,
- customLocale = _getOptionProps.locale,
- restProps = _objectWithoutProperties(_getOptionProps, ['prefixCls', 'selectPrefixCls', 'buildOptionText', 'size', 'locale']);
- var getPrefixCls = this.configProvider.getPrefixCls;
- var prefixCls = getPrefixCls('pagination', customizePrefixCls);
- var selectPrefixCls = getPrefixCls('select', customizeSelectPrefixCls);
- var isSmall = size === 'small';
- var paginationProps = {
- props: _extends({
- prefixCls: prefixCls,
- selectPrefixCls: selectPrefixCls
- }, restProps, this.getIconsProps(prefixCls), {
- selectComponentClass: isSmall ? MiniSelect : VcSelect,
- locale: _extends({}, contextLocale, customLocale),
- buildOptionText: buildOptionText || this.$scopedSlots.buildOptionText
- }),
- 'class': {
- mini: isSmall
- },
- on: getListeners(this)
- };
- return h(VcPagination, paginationProps);
- }
- },
- render: function render() {
- var h = arguments[0];
- return h(LocaleReceiver, {
- attrs: {
- componentName: 'Pagination',
- defaultLocale: enUS
- },
- scopedSlots: { 'default': this.renderPagination }
- });
- }
- };
|