@teammodlr/ui-kit 2.0.21 → 2.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/__storybook__/argTypes.d.ts +40 -40
- package/lib/__storybook__/createStory.d.ts +8 -8
- package/lib/__storybook__/index.d.ts +2 -2
- package/lib/components/avatar/Avatar.vue.d.ts +56 -56
- package/lib/components/avatar/style/Avatar.css.d.ts +9 -9
- package/lib/components/avatar/style/index.d.ts +1 -1
- package/lib/components/avatargroup/AvatarGroup.vue.d.ts +49 -49
- package/lib/components/avatargroup/style/AvatarGroup.css.d.ts +2 -2
- package/lib/components/avatargroup/style/index.d.ts +1 -1
- package/lib/components/avatargroup/symbol.d.ts +13 -13
- package/lib/components/badge/Badge.vue.d.ts +30 -30
- package/lib/components/badge/style/Badge.css.d.ts +4 -4
- package/lib/components/badge/style/index.d.ts +1 -1
- package/lib/components/breadcrumb/Breadcrumb.vue.d.ts +34 -34
- package/lib/components/breadcrumb/BreadcrumbItem.vue.d.ts +29 -29
- package/lib/components/breadcrumb/style/Breadcrumb.css.d.ts +4 -4
- package/lib/components/breadcrumb/style/index.d.ts +1 -1
- package/lib/components/breadcrumb/symbol.d.ts +13 -13
- package/lib/components/button/Button.vue.d.ts +141 -141
- package/lib/components/button/style/Button.css.d.ts +25 -25
- package/lib/components/button/style/index.d.ts +1 -1
- package/lib/components/buttongroup/ButtonGroup.vue.d.ts +18 -18
- package/lib/components/buttongroup/style/ButtonGroup.css.d.ts +2 -2
- package/lib/components/buttongroup/style/index.d.ts +1 -1
- package/lib/components/buttongroup/symbol.d.ts +6 -6
- package/lib/components/checkbox/Checkbox.vue.d.ts +94 -94
- package/lib/components/checkbox/style/Checkbox.css.d.ts +16 -16
- package/lib/components/checkbox/style/index.d.ts +1 -1
- package/lib/components/colorpicker/ColorPicker.vue.d.ts +77 -77
- package/lib/components/colorpicker/style/ColorPicker.css.d.ts +10 -10
- package/lib/components/colorpicker/style/index.d.ts +1 -1
- package/lib/components/colorpicker/utils.d.ts +16 -16
- package/lib/components/dropdown/Dropdown.vue.d.ts +122 -122
- package/lib/components/dropdown/DropdownItem.vue.d.ts +78 -78
- package/lib/components/dropdown/DropdownList.vue.d.ts +5 -5
- package/lib/components/dropdown/DropdownSeperator.vue.d.ts +4 -4
- package/lib/components/dropdown/DropdownWrapper.vue.d.ts +2 -2
- package/lib/components/dropdown/hooks.d.ts +2 -2
- package/lib/components/dropdown/style/Dropdown.css.d.ts +6 -6
- package/lib/components/dropdown/style/index.d.ts +1 -1
- package/lib/components/dropdown/symbol.d.ts +6 -6
- package/lib/components/form/Form.vue.d.ts +75 -75
- package/lib/components/form/style/Form.css.d.ts +4 -4
- package/lib/components/form/style/index.d.ts +2 -2
- package/lib/components/form/symbol.d.ts +9 -9
- package/lib/components/image/Image.vue.d.ts +50 -50
- package/lib/components/index.d.ts +40 -39
- package/lib/components/input/Input.vue.d.ts +142 -142
- package/lib/components/input/style/Input.css.d.ts +23 -23
- package/lib/components/input/style/index.d.ts +1 -1
- package/lib/components/link/Link.vue.d.ts +51 -51
- package/lib/components/messageprovider/Message.vue.d.ts +73 -73
- package/lib/components/messageprovider/MessageProvider.vue.d.ts +52 -52
- package/lib/components/messageprovider/style/Message.css.d.ts +12 -12
- package/lib/components/messageprovider/style/index.d.ts +1 -1
- package/lib/components/messageprovider/types.d.ts +29 -29
- package/lib/components/messageprovider/useMessage.d.ts +2 -2
- package/lib/components/modal/Modal.vue.d.ts +52 -52
- package/lib/components/modal/style/Modal.css.d.ts +21 -21
- package/lib/components/modal/style/index.d.ts +1 -1
- package/lib/components/pagination/Pagination.vue.d.ts +75 -75
- package/lib/components/pagination/style/Pagination.css.d.ts +10 -10
- package/lib/components/pagination/style/index.d.ts +1 -1
- package/lib/components/radio/Radio.vue.d.ts +85 -85
- package/lib/components/radio/style/Checkbox.css.d.ts +16 -16
- package/lib/components/radio/style/index.d.ts +1 -1
- package/lib/components/radiobutton/RadioButton.vue.d.ts +98 -98
- package/lib/components/radiobutton/style/RadioButton.css.d.ts +14 -14
- package/lib/components/radiobutton/style/index.d.ts +1 -1
- package/lib/components/radiobuttongroup/RadioButtonGroup.vue.d.ts +48 -48
- package/lib/components/radiobuttongroup/style/RadioButtonGroup.css.d.ts +3 -3
- package/lib/components/radiobuttongroup/style/index.d.ts +1 -1
- package/lib/components/radiobuttongroup/symbol.d.ts +9 -9
- package/lib/components/select/Select.vue.d.ts +194 -194
- package/lib/components/select/style/Select.css.d.ts +31 -31
- package/lib/components/select/style/index.d.ts +1 -1
- package/lib/components/skeleton/Skeleton.vue.d.ts +33 -33
- package/lib/components/skeleton/style/Skeleton.css.d.ts +8 -8
- package/lib/components/skeleton/style/index.d.ts +2 -2
- package/lib/components/slider/Slider.vue.d.ts +32 -32
- package/lib/components/slider/style/Slider.css.d.ts +4 -4
- package/lib/components/slider/style/index.d.ts +1 -1
- package/lib/components/tab/Tab.vue.d.ts +41 -41
- package/lib/components/tab/TabGroup.vue.d.ts +43 -43
- package/lib/components/table/Table.vue.d.ts +62 -62
- package/lib/components/table/TableBody.vue.d.ts +2 -2
- package/lib/components/table/TableCell.vue.d.ts +2 -2
- package/lib/components/table/TableHead.vue.d.ts +30 -30
- package/lib/components/table/TableHeadRow.vue.d.ts +2 -2
- package/lib/components/table/TableRow.vue.d.ts +2 -2
- package/lib/components/table/style/Table.css.d.ts +4 -4
- package/lib/components/table/style/index.d.ts +1 -1
- package/lib/components/table/types/index.d.ts +6 -6
- package/lib/components/tag/Tag.vue.d.ts +44 -44
- package/lib/components/tag/style/Tag.css.d.ts +11 -11
- package/lib/components/tag/style/index.d.ts +1 -1
- package/lib/components/textarea/TextArea.vue.d.ts +137 -0
- package/lib/components/textarea/style/TextArea.css.d.ts +19 -0
- package/lib/components/textarea/style/index.d.ts +1 -0
- package/lib/components/tooltip/Tooltip.vue.d.ts +71 -71
- package/lib/components/tooltip/style/Tooltip.css.d.ts +10 -10
- package/lib/components/tooltip/style/index.d.ts +1 -1
- package/lib/components/transfer/Transfer.vue.d.ts +67 -67
- package/lib/components/transfer/style/Transfer.css.d.ts +7 -7
- package/lib/components/transfer/style/index.d.ts +1 -1
- package/lib/components/virtualscroll/VirtualScroll.vue.d.ts +73 -73
- package/lib/components/virtualscroll/style/VirtualScroll.css.d.ts +1 -1
- package/lib/components/virtualscroll/style/index.d.ts +1 -1
- package/lib/composables/element.d.ts +2 -2
- package/lib/composables/index.d.ts +3 -3
- package/lib/composables/useCachedUid.d.ts +13 -13
- package/lib/composables/useEventListener.d.ts +1 -1
- package/lib/composables/useInput.d.ts +36 -36
- package/lib/composables/useInteractive.d.ts +15 -15
- package/lib/composables/useIsServer.d.ts +1 -1
- package/lib/composables/useMount.d.ts +13 -13
- package/lib/composables/usePopper.d.ts +31 -31
- package/lib/composables/useZIndex.d.ts +8 -8
- package/lib/create.d.ts +9 -9
- package/lib/index.cjs.js +4 -4
- package/lib/index.d.ts +5 -5
- package/lib/index.es.js +1733 -1578
- package/lib/install.d.ts +4 -4
- package/lib/style.css +1 -1
- package/lib/styles/theme.css.d.ts +167 -167
- package/lib/styles/typography.css.d.ts +22 -22
- package/lib/types/props.d.ts +3 -3
- package/package.json +1 -1
- package/src/components/avatargroup/AvatarGroup.vue +71 -71
- package/src/components/avatargroup/symbol.ts +16 -16
- package/src/components/breadcrumb/BreadcrumbItem.vue +72 -72
- package/src/components/breadcrumb/style/Breadcrumb.css.ts +39 -39
- package/src/components/breadcrumb/symbol.ts +16 -16
- package/src/components/button/Button.vue +203 -203
- package/src/components/buttongroup/ButtonGroup.vue +36 -36
- package/src/components/buttongroup/symbol.ts +7 -7
- package/src/components/dropdown/DropdownItem.vue +134 -134
- package/src/components/dropdown/DropdownSeperator.vue +22 -22
- package/src/components/dropdown/symbol.ts +7 -7
- package/src/components/form/style/Form.css.ts +22 -22
- package/src/components/form/style/index.ts +1 -1
- package/src/components/form/symbol.ts +10 -10
- package/src/components/index.ts +2 -1
- package/src/components/modal/examples/index.ts +2 -2
- package/src/components/pagination/Pagination.vue +229 -229
- package/src/components/pagination/examples/basic.vue +17 -17
- package/src/components/pagination/examples/index.stories.ts +14 -14
- package/src/components/pagination/style/Pagination.css.ts +87 -87
- package/src/components/pagination/style/index.ts +1 -1
- package/src/components/radiobutton/RadioButton.vue +131 -131
- package/src/components/radiobutton/style/RadioButton.css.ts +183 -183
- package/src/components/radiobutton/style/index.ts +1 -1
- package/src/components/radiobuttongroup/RadioButtonGroup.vue +74 -74
- package/src/components/radiobuttongroup/style/RadioButtonGroup.css.ts +36 -36
- package/src/components/radiobuttongroup/symbol.ts +10 -10
- package/src/components/skeleton/Skeleton.vue +55 -55
- package/src/components/skeleton/style/Skeleton.css.ts +56 -56
- package/src/components/skeleton/style/index.ts +1 -1
- package/src/components/table/style/Table.css.ts +80 -80
- package/src/components/textarea/TextArea.css +173 -0
- package/src/components/textarea/TextArea.vue +181 -0
- package/src/components/textarea/examples/basic.vue +8 -0
- package/src/components/textarea/examples/index.stories.ts +18 -0
- package/src/components/textarea/examples/index.ts +1 -0
- package/src/components/textarea/style/TextArea.css.ts +190 -0
- package/src/components/textarea/style/index.ts +1 -0
- package/src/components/tooltip/style/Tooltip.css.ts +91 -91
- package/src/components/tooltip/style/index.ts +1 -1
- package/src/components/transfer/Transfer.vue +143 -143
- package/src/components/transfer/examples/basic.vue +20 -20
- package/src/components/transfer/examples/index.stories.ts +15 -15
- package/src/components/transfer/examples/index.ts +1 -1
- package/src/components/transfer/style/Transfer.css.ts +67 -67
- package/src/components/transfer/style/index.ts +1 -1
- package/src/composables/index.ts +2 -2
- package/src/composables/useInteractive.ts +19 -19
- package/src/composables/useZIndex.ts +30 -30
- package/src/examples/cards/cards.stories.ts +9 -9
- package/src/examples/cards/sidebar.vue +262 -262
- package/src/styles/theme.css.ts +170 -170
|
@@ -1,230 +1,230 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div :class="style.pagination">
|
|
3
|
-
<!-- <div v-if="showTotal || showPageSize">-->
|
|
4
|
-
<!-- <div v-if="showTotal">-->
|
|
5
|
-
<!-- {{ page }}-->
|
|
6
|
-
<!-- </div>-->
|
|
7
|
-
<!-- </div>-->
|
|
8
|
-
|
|
9
|
-
<div :class="style.buttons">
|
|
10
|
-
<button
|
|
11
|
-
:class="style.page"
|
|
12
|
-
:tabindex="page === 1 ? undefined : '0'"
|
|
13
|
-
:disabled="page === 1"
|
|
14
|
-
aria-label="Previous"
|
|
15
|
-
role="button"
|
|
16
|
-
@click="handlePageChange(page - 1)"
|
|
17
|
-
>
|
|
18
|
-
<svg :class="style.svg" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 10 24" width="10" height="24" focusable="false"><path stroke="currentColor" fill="currentColor" fill-rule="evenodd" d="m2.462 12 7.222-6.77-1.368-1.46-8 7.5a1 1 0 0 0 0 1.46l8 7.5 1.368-1.46L2.462 12z" clip-rule="evenodd"></path></svg>
|
|
19
|
-
</button>
|
|
20
|
-
|
|
21
|
-
<div :class="style.pages">
|
|
22
|
-
<template
|
|
23
|
-
v-for="(item, index) in pageIndicatorSeries"
|
|
24
|
-
:key="index"
|
|
25
|
-
>
|
|
26
|
-
<button
|
|
27
|
-
:class="[
|
|
28
|
-
style.page,
|
|
29
|
-
{
|
|
30
|
-
[style.active]: item.current
|
|
31
|
-
},
|
|
32
|
-
]"
|
|
33
|
-
:ref="getKey(item)"
|
|
34
|
-
tabindex="0"
|
|
35
|
-
:disabled="isEmpty"
|
|
36
|
-
role="button"
|
|
37
|
-
@click="handlePageChange(item.page)"
|
|
38
|
-
:aria-label="item.current ? `Page ${item.page}` : `Goto page ${item.page}`"
|
|
39
|
-
>
|
|
40
|
-
<template v-if="item.more">
|
|
41
|
-
...
|
|
42
|
-
</template>
|
|
43
|
-
<template v-else>
|
|
44
|
-
{{ item.text }}
|
|
45
|
-
</template>
|
|
46
|
-
</button>
|
|
47
|
-
</template>
|
|
48
|
-
</div>
|
|
49
|
-
|
|
50
|
-
<button
|
|
51
|
-
:tabindex="page === pageCount ? undefined : '0'"
|
|
52
|
-
:disabled="page === pageCount || pageCount === 0"
|
|
53
|
-
aria-label="Next"
|
|
54
|
-
role="button"
|
|
55
|
-
@click="handlePageChange(page + 1)"
|
|
56
|
-
:class="style.page"
|
|
57
|
-
>
|
|
58
|
-
<svg :class="style.svg" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 10 24" width="10" height="24" focusable="false"><path stroke="currentColor" fill="currentColor" fill-rule="evenodd" d="M10 12a1 1 0 0 1-.316.73l-8 7.5-1.368-1.46L7.538 12 .316 5.23l1.368-1.46 8 7.5A1 1 0 0 1 10 12z" clip-rule="evenodd"></path></svg>
|
|
59
|
-
</button>
|
|
60
|
-
</div>
|
|
61
|
-
</div>
|
|
62
|
-
</template>
|
|
63
|
-
|
|
64
|
-
<script lang="ts">
|
|
65
|
-
import {computed, defineComponent, watch} from "vue";
|
|
66
|
-
import * as style from "./style"
|
|
67
|
-
|
|
68
|
-
const pageIndicatorLength = 7
|
|
69
|
-
const aroundIndicatorLength = 1
|
|
70
|
-
const moreIndicatorOffsetLength = 5
|
|
71
|
-
export default defineComponent({
|
|
72
|
-
name: "Pagination",
|
|
73
|
-
props: {
|
|
74
|
-
page: {
|
|
75
|
-
type: Number,
|
|
76
|
-
default: 1
|
|
77
|
-
},
|
|
78
|
-
pageSize: {
|
|
79
|
-
type: Number,
|
|
80
|
-
default: 10
|
|
81
|
-
},
|
|
82
|
-
pageSizes: {
|
|
83
|
-
type: Array
|
|
84
|
-
},
|
|
85
|
-
total: {
|
|
86
|
-
type: Number
|
|
87
|
-
},
|
|
88
|
-
showPageSize: {
|
|
89
|
-
type: Boolean,
|
|
90
|
-
default: true
|
|
91
|
-
},
|
|
92
|
-
showTotal: {
|
|
93
|
-
type: Boolean,
|
|
94
|
-
default: true
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
|
-
emits: [
|
|
98
|
-
'update:page',
|
|
99
|
-
'update:pageSize',
|
|
100
|
-
],
|
|
101
|
-
setup(props, {emit}) {
|
|
102
|
-
const realTotal = computed(() => {
|
|
103
|
-
return props.total || 0;
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
const isEmpty = computed(() => {
|
|
107
|
-
return realTotal.value === 0;
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
const realPageSizes = computed(() => {
|
|
111
|
-
const sizes = props.pageSizes == null
|
|
112
|
-
? [10, 20, 30, 40, 50]
|
|
113
|
-
: props.pageSizes;
|
|
114
|
-
|
|
115
|
-
return sizes.map((size) => ({
|
|
116
|
-
label: size,
|
|
117
|
-
value: size
|
|
118
|
-
}));
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
const pageCount = computed(() => {
|
|
122
|
-
return Math.ceil(realTotal.value / props.pageSize);
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
const pageIndicatorSeries = computed(() => {
|
|
126
|
-
let {page} = props;
|
|
127
|
-
|
|
128
|
-
if (isEmpty.value) {
|
|
129
|
-
return [getPageIndicator(1, {current: false})];
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
let continuousIndicatorLength = aroundIndicatorLength * 2 + 1
|
|
133
|
-
let boundaryIndicatorLength =
|
|
134
|
-
(pageIndicatorLength - continuousIndicatorLength - 2) / 2
|
|
135
|
-
let leftLen
|
|
136
|
-
let rightLen
|
|
137
|
-
let offsetBackward = Math.max(page - moreIndicatorOffsetLength, 1)
|
|
138
|
-
let offsetForward = Math.min(page + moreIndicatorOffsetLength, pageCount.value)
|
|
139
|
-
switch (true) {
|
|
140
|
-
case pageCount.value <= pageIndicatorLength:
|
|
141
|
-
return getPageSeries(1, pageCount.value)
|
|
142
|
-
case page <= boundaryIndicatorLength + aroundIndicatorLength + 2:
|
|
143
|
-
leftLen = pageIndicatorLength - boundaryIndicatorLength - 1
|
|
144
|
-
return getPageSeries(1, leftLen)
|
|
145
|
-
.concat(
|
|
146
|
-
getPageIndicator(offsetForward, { more: true, forward: true })
|
|
147
|
-
)
|
|
148
|
-
.concat(
|
|
149
|
-
getPageSeries(
|
|
150
|
-
pageCount.value - boundaryIndicatorLength + 1,
|
|
151
|
-
boundaryIndicatorLength
|
|
152
|
-
)
|
|
153
|
-
)
|
|
154
|
-
case page >=
|
|
155
|
-
pageCount.value - boundaryIndicatorLength - aroundIndicatorLength - 1:
|
|
156
|
-
rightLen = pageIndicatorLength - boundaryIndicatorLength - 1
|
|
157
|
-
return getPageSeries(1, boundaryIndicatorLength)
|
|
158
|
-
.concat(
|
|
159
|
-
getPageIndicator(offsetBackward, { more: true, forward: false })
|
|
160
|
-
)
|
|
161
|
-
.concat(getPageSeries(pageCount.value - rightLen + 1, rightLen))
|
|
162
|
-
default:
|
|
163
|
-
return getPageSeries(1, boundaryIndicatorLength)
|
|
164
|
-
.concat(
|
|
165
|
-
getPageIndicator(offsetBackward, { more: true, forward: false })
|
|
166
|
-
)
|
|
167
|
-
.concat(
|
|
168
|
-
getPageSeries(
|
|
169
|
-
page - aroundIndicatorLength,
|
|
170
|
-
continuousIndicatorLength
|
|
171
|
-
)
|
|
172
|
-
)
|
|
173
|
-
.concat(
|
|
174
|
-
getPageIndicator(offsetForward, { more: true, forward: true })
|
|
175
|
-
)
|
|
176
|
-
.concat(
|
|
177
|
-
getPageSeries(
|
|
178
|
-
pageCount.value - boundaryIndicatorLength + 1,
|
|
179
|
-
boundaryIndicatorLength
|
|
180
|
-
)
|
|
181
|
-
)
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
})
|
|
185
|
-
|
|
186
|
-
function getPageSeries(from: number, length: number) {
|
|
187
|
-
let series = [];
|
|
188
|
-
for (let i = 0; i < length; i++) {
|
|
189
|
-
series[i] = getPageIndicator(from + i);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
return series;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
function getPageIndicator(page: number, {more = false, forward = false, current = false} = {}) {
|
|
196
|
-
return {
|
|
197
|
-
page,
|
|
198
|
-
more,
|
|
199
|
-
forward,
|
|
200
|
-
current: !current ? page === props.page : current,
|
|
201
|
-
text: page
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
function getKey(item: any) {
|
|
206
|
-
return `page-${item.more ? (item.forward ? 'forward' : 'backward') : item.page}`
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
function handlePageChange(page: number) {
|
|
210
|
-
emit('update:page', page)
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
watch(() => props.page, (val) => {
|
|
214
|
-
emit('update:page', val)
|
|
215
|
-
}, { immediate: true })
|
|
216
|
-
|
|
217
|
-
return {
|
|
218
|
-
realTotal,
|
|
219
|
-
isEmpty,
|
|
220
|
-
realPageSizes,
|
|
221
|
-
pageCount,
|
|
222
|
-
pageIndicatorSeries,
|
|
223
|
-
getKey,
|
|
224
|
-
handlePageChange,
|
|
225
|
-
|
|
226
|
-
style
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
})
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="style.pagination">
|
|
3
|
+
<!-- <div v-if="showTotal || showPageSize">-->
|
|
4
|
+
<!-- <div v-if="showTotal">-->
|
|
5
|
+
<!-- {{ page }}-->
|
|
6
|
+
<!-- </div>-->
|
|
7
|
+
<!-- </div>-->
|
|
8
|
+
|
|
9
|
+
<div :class="style.buttons">
|
|
10
|
+
<button
|
|
11
|
+
:class="style.page"
|
|
12
|
+
:tabindex="page === 1 ? undefined : '0'"
|
|
13
|
+
:disabled="page === 1"
|
|
14
|
+
aria-label="Previous"
|
|
15
|
+
role="button"
|
|
16
|
+
@click="handlePageChange(page - 1)"
|
|
17
|
+
>
|
|
18
|
+
<svg :class="style.svg" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 10 24" width="10" height="24" focusable="false"><path stroke="currentColor" fill="currentColor" fill-rule="evenodd" d="m2.462 12 7.222-6.77-1.368-1.46-8 7.5a1 1 0 0 0 0 1.46l8 7.5 1.368-1.46L2.462 12z" clip-rule="evenodd"></path></svg>
|
|
19
|
+
</button>
|
|
20
|
+
|
|
21
|
+
<div :class="style.pages">
|
|
22
|
+
<template
|
|
23
|
+
v-for="(item, index) in pageIndicatorSeries"
|
|
24
|
+
:key="index"
|
|
25
|
+
>
|
|
26
|
+
<button
|
|
27
|
+
:class="[
|
|
28
|
+
style.page,
|
|
29
|
+
{
|
|
30
|
+
[style.active]: item.current
|
|
31
|
+
},
|
|
32
|
+
]"
|
|
33
|
+
:ref="getKey(item)"
|
|
34
|
+
tabindex="0"
|
|
35
|
+
:disabled="isEmpty"
|
|
36
|
+
role="button"
|
|
37
|
+
@click="handlePageChange(item.page)"
|
|
38
|
+
:aria-label="item.current ? `Page ${item.page}` : `Goto page ${item.page}`"
|
|
39
|
+
>
|
|
40
|
+
<template v-if="item.more">
|
|
41
|
+
...
|
|
42
|
+
</template>
|
|
43
|
+
<template v-else>
|
|
44
|
+
{{ item.text }}
|
|
45
|
+
</template>
|
|
46
|
+
</button>
|
|
47
|
+
</template>
|
|
48
|
+
</div>
|
|
49
|
+
|
|
50
|
+
<button
|
|
51
|
+
:tabindex="page === pageCount ? undefined : '0'"
|
|
52
|
+
:disabled="page === pageCount || pageCount === 0"
|
|
53
|
+
aria-label="Next"
|
|
54
|
+
role="button"
|
|
55
|
+
@click="handlePageChange(page + 1)"
|
|
56
|
+
:class="style.page"
|
|
57
|
+
>
|
|
58
|
+
<svg :class="style.svg" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 10 24" width="10" height="24" focusable="false"><path stroke="currentColor" fill="currentColor" fill-rule="evenodd" d="M10 12a1 1 0 0 1-.316.73l-8 7.5-1.368-1.46L7.538 12 .316 5.23l1.368-1.46 8 7.5A1 1 0 0 1 10 12z" clip-rule="evenodd"></path></svg>
|
|
59
|
+
</button>
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
</template>
|
|
63
|
+
|
|
64
|
+
<script lang="ts">
|
|
65
|
+
import {computed, defineComponent, watch} from "vue";
|
|
66
|
+
import * as style from "./style"
|
|
67
|
+
|
|
68
|
+
const pageIndicatorLength = 7
|
|
69
|
+
const aroundIndicatorLength = 1
|
|
70
|
+
const moreIndicatorOffsetLength = 5
|
|
71
|
+
export default defineComponent({
|
|
72
|
+
name: "Pagination",
|
|
73
|
+
props: {
|
|
74
|
+
page: {
|
|
75
|
+
type: Number,
|
|
76
|
+
default: 1
|
|
77
|
+
},
|
|
78
|
+
pageSize: {
|
|
79
|
+
type: Number,
|
|
80
|
+
default: 10
|
|
81
|
+
},
|
|
82
|
+
pageSizes: {
|
|
83
|
+
type: Array
|
|
84
|
+
},
|
|
85
|
+
total: {
|
|
86
|
+
type: Number
|
|
87
|
+
},
|
|
88
|
+
showPageSize: {
|
|
89
|
+
type: Boolean,
|
|
90
|
+
default: true
|
|
91
|
+
},
|
|
92
|
+
showTotal: {
|
|
93
|
+
type: Boolean,
|
|
94
|
+
default: true
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
emits: [
|
|
98
|
+
'update:page',
|
|
99
|
+
'update:pageSize',
|
|
100
|
+
],
|
|
101
|
+
setup(props, {emit}) {
|
|
102
|
+
const realTotal = computed(() => {
|
|
103
|
+
return props.total || 0;
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
const isEmpty = computed(() => {
|
|
107
|
+
return realTotal.value === 0;
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
const realPageSizes = computed(() => {
|
|
111
|
+
const sizes = props.pageSizes == null
|
|
112
|
+
? [10, 20, 30, 40, 50]
|
|
113
|
+
: props.pageSizes;
|
|
114
|
+
|
|
115
|
+
return sizes.map((size) => ({
|
|
116
|
+
label: size,
|
|
117
|
+
value: size
|
|
118
|
+
}));
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
const pageCount = computed(() => {
|
|
122
|
+
return Math.ceil(realTotal.value / props.pageSize);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
const pageIndicatorSeries = computed(() => {
|
|
126
|
+
let {page} = props;
|
|
127
|
+
|
|
128
|
+
if (isEmpty.value) {
|
|
129
|
+
return [getPageIndicator(1, {current: false})];
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
let continuousIndicatorLength = aroundIndicatorLength * 2 + 1
|
|
133
|
+
let boundaryIndicatorLength =
|
|
134
|
+
(pageIndicatorLength - continuousIndicatorLength - 2) / 2
|
|
135
|
+
let leftLen
|
|
136
|
+
let rightLen
|
|
137
|
+
let offsetBackward = Math.max(page - moreIndicatorOffsetLength, 1)
|
|
138
|
+
let offsetForward = Math.min(page + moreIndicatorOffsetLength, pageCount.value)
|
|
139
|
+
switch (true) {
|
|
140
|
+
case pageCount.value <= pageIndicatorLength:
|
|
141
|
+
return getPageSeries(1, pageCount.value)
|
|
142
|
+
case page <= boundaryIndicatorLength + aroundIndicatorLength + 2:
|
|
143
|
+
leftLen = pageIndicatorLength - boundaryIndicatorLength - 1
|
|
144
|
+
return getPageSeries(1, leftLen)
|
|
145
|
+
.concat(
|
|
146
|
+
getPageIndicator(offsetForward, { more: true, forward: true })
|
|
147
|
+
)
|
|
148
|
+
.concat(
|
|
149
|
+
getPageSeries(
|
|
150
|
+
pageCount.value - boundaryIndicatorLength + 1,
|
|
151
|
+
boundaryIndicatorLength
|
|
152
|
+
)
|
|
153
|
+
)
|
|
154
|
+
case page >=
|
|
155
|
+
pageCount.value - boundaryIndicatorLength - aroundIndicatorLength - 1:
|
|
156
|
+
rightLen = pageIndicatorLength - boundaryIndicatorLength - 1
|
|
157
|
+
return getPageSeries(1, boundaryIndicatorLength)
|
|
158
|
+
.concat(
|
|
159
|
+
getPageIndicator(offsetBackward, { more: true, forward: false })
|
|
160
|
+
)
|
|
161
|
+
.concat(getPageSeries(pageCount.value - rightLen + 1, rightLen))
|
|
162
|
+
default:
|
|
163
|
+
return getPageSeries(1, boundaryIndicatorLength)
|
|
164
|
+
.concat(
|
|
165
|
+
getPageIndicator(offsetBackward, { more: true, forward: false })
|
|
166
|
+
)
|
|
167
|
+
.concat(
|
|
168
|
+
getPageSeries(
|
|
169
|
+
page - aroundIndicatorLength,
|
|
170
|
+
continuousIndicatorLength
|
|
171
|
+
)
|
|
172
|
+
)
|
|
173
|
+
.concat(
|
|
174
|
+
getPageIndicator(offsetForward, { more: true, forward: true })
|
|
175
|
+
)
|
|
176
|
+
.concat(
|
|
177
|
+
getPageSeries(
|
|
178
|
+
pageCount.value - boundaryIndicatorLength + 1,
|
|
179
|
+
boundaryIndicatorLength
|
|
180
|
+
)
|
|
181
|
+
)
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
})
|
|
185
|
+
|
|
186
|
+
function getPageSeries(from: number, length: number) {
|
|
187
|
+
let series = [];
|
|
188
|
+
for (let i = 0; i < length; i++) {
|
|
189
|
+
series[i] = getPageIndicator(from + i);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
return series;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function getPageIndicator(page: number, {more = false, forward = false, current = false} = {}) {
|
|
196
|
+
return {
|
|
197
|
+
page,
|
|
198
|
+
more,
|
|
199
|
+
forward,
|
|
200
|
+
current: !current ? page === props.page : current,
|
|
201
|
+
text: page
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function getKey(item: any) {
|
|
206
|
+
return `page-${item.more ? (item.forward ? 'forward' : 'backward') : item.page}`
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function handlePageChange(page: number) {
|
|
210
|
+
emit('update:page', page)
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
watch(() => props.page, (val) => {
|
|
214
|
+
emit('update:page', val)
|
|
215
|
+
}, { immediate: true })
|
|
216
|
+
|
|
217
|
+
return {
|
|
218
|
+
realTotal,
|
|
219
|
+
isEmpty,
|
|
220
|
+
realPageSizes,
|
|
221
|
+
pageCount,
|
|
222
|
+
pageIndicatorSeries,
|
|
223
|
+
getKey,
|
|
224
|
+
handlePageChange,
|
|
225
|
+
|
|
226
|
+
style
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
})
|
|
230
230
|
</script>
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<MPagination
|
|
3
|
-
v-model:page="page"
|
|
4
|
-
:total="total"
|
|
5
|
-
@update:page="handlePage"
|
|
6
|
-
/>
|
|
7
|
-
</template>
|
|
8
|
-
|
|
9
|
-
<script setup lang="ts">
|
|
10
|
-
import { ref } from "vue";
|
|
11
|
-
const page = ref(3);
|
|
12
|
-
const total = ref(1000);
|
|
13
|
-
|
|
14
|
-
const handlePage = (page: number) => {
|
|
15
|
-
console.log(page);
|
|
16
|
-
// do axios stuff
|
|
17
|
-
};
|
|
1
|
+
<template>
|
|
2
|
+
<MPagination
|
|
3
|
+
v-model:page="page"
|
|
4
|
+
:total="total"
|
|
5
|
+
@update:page="handlePage"
|
|
6
|
+
/>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script setup lang="ts">
|
|
10
|
+
import { ref } from "vue";
|
|
11
|
+
const page = ref(3);
|
|
12
|
+
const total = ref(1000);
|
|
13
|
+
|
|
14
|
+
const handlePage = (page: number) => {
|
|
15
|
+
console.log(page);
|
|
16
|
+
// do axios stuff
|
|
17
|
+
};
|
|
18
18
|
</script>
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import MPagination from "../Pagination.vue";
|
|
2
|
-
import {
|
|
3
|
-
MPaginationBasic
|
|
4
|
-
} from "./index";
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
createStory
|
|
8
|
-
} from "../../../__storybook__";
|
|
9
|
-
|
|
10
|
-
export default {
|
|
11
|
-
component: MPagination,
|
|
12
|
-
title: 'Components/Pagination'
|
|
13
|
-
}
|
|
14
|
-
|
|
1
|
+
import MPagination from "../Pagination.vue";
|
|
2
|
+
import {
|
|
3
|
+
MPaginationBasic
|
|
4
|
+
} from "./index";
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
createStory
|
|
8
|
+
} from "../../../__storybook__";
|
|
9
|
+
|
|
10
|
+
export default {
|
|
11
|
+
component: MPagination,
|
|
12
|
+
title: 'Components/Pagination'
|
|
13
|
+
}
|
|
14
|
+
|
|
15
15
|
export const Basic = createStory(MPaginationBasic)
|