forked from vueComponent/ant-design-vue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPagination.jsx
133 lines (126 loc) · 4.16 KB
/
Pagination.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import PropTypes from '../_util/vue-types';
import VcSelect from '../select';
import MiniSelect from './MiniSelect';
import LocaleReceiver from '../locale-provider/LocaleReceiver';
import { getOptionProps } from '../_util/props-util';
import VcPagination from '../vc-pagination';
import enUS from '../vc-pagination/locale/en_US';
import LeftOutlined from '@ant-design/icons-vue/LeftOutlined';
import RightOutlined from '@ant-design/icons-vue/RightOutlined';
import DoubleLeftOutlined from '@ant-design/icons-vue/DoubleLeftOutlined';
import DoubleRightOutlined from '@ant-design/icons-vue/DoubleRightOutlined';
import { ConfigConsumerProps } from '../config-provider';
import { inject } from 'vue';
import classNames from 'classnames';
export const PaginationProps = () => ({
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 const PaginationConfig = () => ({
...PaginationProps(),
position: PropTypes.oneOf(['top', 'bottom', 'both']),
});
export default {
name: 'APagination',
inheritAttrs: false,
props: {
...PaginationProps(),
},
setup() {
return {
configProvider: inject('configProvider', ConfigConsumerProps),
};
},
methods: {
getIconsProps(prefixCls) {
const prevIcon = (
<a class={`${prefixCls}-item-link`}>
<LeftOutlined />
</a>
);
const nextIcon = (
<a class={`${prefixCls}-item-link`}>
<RightOutlined />
</a>
);
const jumpPrevIcon = (
<a class={`${prefixCls}-item-link`}>
{/* You can use transition effects in the container :) */}
<div class={`${prefixCls}-item-container`}>
<DoubleLeftOutlined class={`${prefixCls}-item-link-icon`} />
<span class={`${prefixCls}-item-ellipsis`}>•••</span>
</div>
</a>
);
const jumpNextIcon = (
<a class={`${prefixCls}-item-link`}>
{/* You can use transition effects in the container :) */}
<div class={`${prefixCls}-item-container`}>
<DoubleRightOutlined class={`${prefixCls}-item-link-icon`} />
<span class={`${prefixCls}-item-ellipsis`}>•••</span>
</div>
</a>
);
return {
prevIcon,
nextIcon,
jumpPrevIcon,
jumpNextIcon,
};
},
renderPagination(contextLocale) {
const {
prefixCls: customizePrefixCls,
selectPrefixCls: customizeSelectPrefixCls,
buildOptionText,
size,
locale: customLocale,
...restProps
} = getOptionProps(this);
const getPrefixCls = this.configProvider.getPrefixCls;
const prefixCls = getPrefixCls('pagination', customizePrefixCls);
const selectPrefixCls = getPrefixCls('select', customizeSelectPrefixCls);
const isSmall = size === 'small';
const paginationProps = {
prefixCls,
selectPrefixCls,
...restProps,
...this.getIconsProps(prefixCls),
selectComponentClass: isSmall ? MiniSelect : VcSelect,
locale: { ...contextLocale, ...customLocale },
buildOptionText: buildOptionText || this.$slots.buildOptionText?.(),
...this.$attrs,
class: classNames({ mini: isSmall }, this.$attrs.class),
};
return <VcPagination {...paginationProps} />;
},
},
render() {
return (
<LocaleReceiver
componentName="Pagination"
defaultLocale={enUS}
slots={{ default: this.renderPagination }}
></LocaleReceiver>
);
},
};