@teammodlr/ui-kit 2.1.41 → 2.1.43
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/env.d.ts +1 -1
- package/lib/components/checkbox/Checkbox.vue.d.ts +1 -0
- package/lib/components/checkbox/style/Checkbox.css.d.ts +1 -0
- package/lib/index.cjs.js +8 -8
- package/lib/index.es.js +1352 -1342
- package/lib/nuxt.js +35 -35
- package/lib/nuxt.plugin.js +8 -8
- package/lib/style.css +1 -1
- package/package.json +89 -89
- package/src/__storybook__/argTypes.ts +53 -53
- package/src/__storybook__/createStory.ts +15 -15
- package/src/__storybook__/index.ts +2 -2
- package/src/call.ts +34 -34
- package/src/components/avatar/Avatar.vue +110 -110
- package/src/components/avatar/examples/basic.vue +6 -6
- package/src/components/avatar/examples/custom-size.vue +7 -7
- package/src/components/avatar/examples/index.ts +5 -5
- package/src/components/avatar/examples/sizes.vue +33 -33
- package/src/components/avatar/examples/slots.vue +8 -8
- package/src/components/avatar/examples/variants.vue +18 -18
- package/src/components/avatar/style/Avatar.css.ts +92 -92
- package/src/components/avatar/style/index.ts +1 -1
- package/src/components/avatargroup/AvatarGroup.vue +72 -72
- package/src/components/avatargroup/examples/basic.vue +37 -37
- package/src/components/avatargroup/examples/index.ts +1 -1
- package/src/components/avatargroup/style/AvatarGroup.css.ts +26 -26
- package/src/components/avatargroup/style/index.ts +1 -1
- package/src/components/avatargroup/symbol.ts +17 -17
- package/src/components/badge/Badge.vue +43 -43
- package/src/components/badge/examples/basic.vue +10 -10
- package/src/components/badge/examples/index.ts +1 -1
- package/src/components/badge/style/Badge.css.ts +135 -135
- package/src/components/badge/style/index.ts +1 -1
- package/src/components/breadcrumb/Breadcrumb.vue +54 -54
- package/src/components/breadcrumb/BreadcrumbItem.vue +72 -72
- package/src/components/breadcrumb/examples/basic.vue +7 -7
- package/src/components/breadcrumb/examples/index.ts +1 -1
- package/src/components/breadcrumb/style/Breadcrumb.css.ts +40 -40
- package/src/components/breadcrumb/style/index.ts +1 -1
- package/src/components/breadcrumb/symbol.ts +18 -18
- package/src/components/button/Button.vue +203 -203
- package/src/components/button/examples/basic.vue +3 -3
- package/src/components/button/examples/disabled.vue +3 -3
- package/src/components/button/examples/icon-left.vue +12 -12
- package/src/components/button/examples/icon.vue +9 -9
- package/src/components/button/examples/index.ts +9 -9
- package/src/components/button/examples/link.vue +3 -3
- package/src/components/button/examples/rounded.vue +7 -7
- package/src/components/button/examples/size.vue +7 -7
- package/src/components/button/examples/variants-secondary.vue +10 -10
- package/src/components/button/examples/variants.vue +10 -10
- package/src/components/button/style/Button.css.ts +695 -695
- package/src/components/button/style/index.ts +1 -1
- package/src/components/buttongroup/ButtonGroup.vue +36 -36
- package/src/components/buttongroup/examples/basic.vue +9 -9
- package/src/components/buttongroup/examples/icon-group.vue +21 -21
- package/src/components/buttongroup/examples/index.ts +2 -2
- package/src/components/buttongroup/style/ButtonGroup.css.ts +42 -42
- package/src/components/buttongroup/style/index.ts +1 -1
- package/src/components/buttongroup/symbol.ts +9 -9
- package/src/components/checkbox/Checkbox.vue +149 -145
- package/src/components/checkbox/examples/basic.vue +9 -9
- package/src/components/checkbox/examples/index.ts +2 -2
- package/src/components/checkbox/examples/slot.vue +14 -11
- package/src/components/checkbox/style/Checkbox.css.ts +178 -161
- package/src/components/checkbox/style/index.ts +1 -1
- package/src/components/colorpicker/ColorPicker.vue +333 -333
- package/src/components/colorpicker/examples/basic.vue +2 -2
- package/src/components/colorpicker/examples/index.ts +1 -1
- package/src/components/colorpicker/style/ColorPicker.css.ts +127 -127
- package/src/components/colorpicker/style/index.ts +1 -1
- package/src/components/colorpicker/utils.ts +206 -206
- package/src/components/confirm/Confirm.vue +65 -65
- package/src/components/confirm/ConfirmProvider.vue +83 -83
- package/src/components/confirm/examples/basic.vue +48 -48
- package/src/components/confirm/examples/index.ts +1 -1
- package/src/components/confirm/examples/wrapper.vue +9 -9
- package/src/components/confirm/props.ts +24 -24
- package/src/components/confirm/providerProps.ts +10 -10
- package/src/components/confirm/types.ts +33 -33
- package/src/components/confirm/useConfirm.ts +14 -14
- package/src/components/dialog/Dialog.vue +118 -118
- package/src/components/dialog/examples/basic.vue +16 -16
- package/src/components/dialog/examples/index.ts +1 -1
- package/src/components/dialog/style/Dialog.css.ts +100 -100
- package/src/components/dialog/style/index.ts +1 -1
- package/src/components/dropdown/Dropdown.vue +308 -308
- package/src/components/dropdown/DropdownHeading.vue +23 -23
- package/src/components/dropdown/DropdownItem.vue +151 -151
- package/src/components/dropdown/DropdownList.vue +20 -20
- package/src/components/dropdown/DropdownSeperator.vue +22 -22
- package/src/components/dropdown/DropdownWrapper.vue +18 -18
- package/src/components/dropdown/examples/basic.vue +119 -119
- package/src/components/dropdown/examples/context.vue +71 -71
- package/src/components/dropdown/examples/index.ts +3 -3
- package/src/components/dropdown/hooks.ts +30 -30
- package/src/components/dropdown/style/Dropdown.css.ts +158 -158
- package/src/components/dropdown/style/index.ts +1 -1
- package/src/components/dropdown/symbol.ts +9 -9
- package/src/components/form/Form.vue +153 -153
- package/src/components/form/examples/basic.vue +75 -75
- package/src/components/form/examples/index.ts +1 -1
- package/src/components/form/style/Form.css.ts +28 -28
- package/src/components/form/style/index.ts +2 -2
- package/src/components/form/symbol.ts +16 -16
- package/src/components/image/Image.vue +71 -71
- package/src/components/image/examples/basic.vue +5 -5
- package/src/components/image/examples/index.ts +1 -1
- package/src/components/index.ts +47 -47
- package/src/components/input/Input.vue +233 -233
- package/src/components/input/examples/basic.vue +21 -21
- package/src/components/input/examples/index.ts +6 -6
- package/src/components/input/examples/left-icon.vue +9 -9
- package/src/components/input/examples/prefix.vue +5 -5
- package/src/components/input/examples/right-icon.vue +9 -9
- package/src/components/input/examples/sizes.vue +9 -9
- package/src/components/input/examples/suffix.vue +7 -7
- package/src/components/input/style/Input.css.ts +294 -294
- package/src/components/input/style/index.ts +1 -1
- package/src/components/link/Link.vue +53 -53
- package/src/components/link/examples/basic.vue +3 -3
- package/src/components/link/examples/index.ts +1 -1
- package/src/components/messageprovider/Message.vue +135 -135
- package/src/components/messageprovider/MessageProvider.vue +156 -156
- package/src/components/messageprovider/examples/basic.vue +70 -70
- package/src/components/messageprovider/examples/index.ts +2 -2
- package/src/components/messageprovider/examples/update.vue +34 -34
- package/src/components/messageprovider/examples/wrapper.vue +9 -9
- package/src/components/messageprovider/style/Message.css.ts +111 -111
- package/src/components/messageprovider/style/index.ts +1 -1
- package/src/components/messageprovider/types.ts +56 -56
- package/src/components/messageprovider/useMessage.ts +14 -14
- package/src/components/modal/Modal.vue +310 -310
- package/src/components/modal/examples/basic.vue +80 -80
- package/src/components/modal/examples/index.ts +3 -3
- package/src/components/modal/examples/modal-form.vue +99 -99
- package/src/components/modal/examples/sidebar.vue +79 -79
- package/src/components/modal/style/Modal.css.ts +318 -318
- package/src/components/modal/style/index.ts +1 -1
- package/src/components/pagination/Pagination.vue +296 -296
- package/src/components/pagination/examples/basic.vue +17 -17
- package/src/components/pagination/examples/index.ts +1 -1
- package/src/components/pagination/style/Pagination.css.ts +93 -93
- package/src/components/pagination/style/index.ts +1 -1
- package/src/components/radio/Radio.vue +136 -136
- package/src/components/radio/examples/basic.vue +8 -8
- package/src/components/radio/examples/group.vue +15 -15
- package/src/components/radio/examples/index.ts +2 -2
- package/src/components/radio/style/Checkbox.css.ts +130 -130
- package/src/components/radio/style/index.ts +1 -1
- package/src/components/radiobutton/RadioButton.vue +131 -131
- package/src/components/radiobutton/style/RadioButton.css.ts +189 -189
- package/src/components/radiobutton/style/index.ts +1 -1
- package/src/components/radiobuttongroup/RadioButtonGroup.vue +74 -74
- package/src/components/radiobuttongroup/examples/basic.vue +16 -16
- package/src/components/radiobuttongroup/examples/index.ts +1 -1
- package/src/components/radiobuttongroup/style/RadioButtonGroup.css.ts +37 -37
- package/src/components/radiobuttongroup/style/index.ts +1 -1
- package/src/components/radiobuttongroup/symbol.ts +12 -12
- package/src/components/renderer/examlpes/basic.vue +23 -23
- package/src/components/renderer/examlpes/index.ts +1 -1
- package/src/components/renderer/props.ts +14 -14
- package/src/components/renderer/renderer.ts +16 -16
- package/src/components/select/Select.vue +781 -781
- package/src/components/select/examples/basic.vue +21 -21
- package/src/components/select/examples/index.ts +3 -3
- package/src/components/select/examples/multiple.vue +21 -21
- package/src/components/select/examples/searchable.vue +20 -20
- package/src/components/select/style/Select.css.ts +368 -368
- package/src/components/select/style/index.ts +1 -1
- package/src/components/skeleton/Skeleton.vue +55 -55
- package/src/components/skeleton/examples/basic.vue +3 -3
- package/src/components/skeleton/examples/index.ts +2 -2
- package/src/components/skeleton/examples/post.vue +8 -8
- package/src/components/skeleton/style/Skeleton.css.ts +72 -72
- package/src/components/skeleton/style/index.ts +2 -2
- package/src/components/slider/Slider.vue +76 -76
- package/src/components/slider/style/Slider.css.ts +50 -50
- package/src/components/slider/style/index.ts +1 -1
- package/src/components/switch/Switch.vue +132 -132
- package/src/components/switch/examples/basic.vue +9 -9
- package/src/components/switch/examples/index.ts +2 -2
- package/src/components/switch/examples/slot.vue +11 -11
- package/src/components/switch/style/Switch.css.ts +135 -135
- package/src/components/switch/style/index.ts +1 -1
- package/src/components/tab/Tab.css +113 -113
- package/src/components/tab/Tab.vue +98 -98
- package/src/components/tab/TabGroup.vue +90 -90
- package/src/components/tab/examples/basic.vue +19 -19
- package/src/components/tab/examples/index.ts +2 -2
- package/src/components/tab/examples/vertical.vue +19 -19
- package/src/components/table/Table.vue +198 -198
- package/src/components/table/TableBody.vue +13 -13
- package/src/components/table/TableCell.vue +13 -13
- package/src/components/table/TableHead.vue +46 -46
- package/src/components/table/TableHeadRow.vue +15 -15
- package/src/components/table/TableRow.vue +19 -19
- package/src/components/table/examples/basic.vue +61 -61
- package/src/components/table/examples/empty.vue +44 -44
- package/src/components/table/examples/index.ts +3 -3
- package/src/components/table/examples/selected.vue +68 -68
- package/src/components/table/style/Table.css.ts +62 -62
- package/src/components/table/style/index.ts +1 -1
- package/src/components/table/types/index.ts +6 -6
- package/src/components/tag/Tag.vue +72 -72
- package/src/components/tag/examples/basic.vue +5 -5
- package/src/components/tag/examples/index.ts +1 -1
- package/src/components/tag/style/Tag.css.ts +83 -83
- package/src/components/tag/style/index.ts +1 -1
- package/src/components/textarea/Textarea.vue +180 -180
- package/src/components/textarea/examples/basic.vue +8 -8
- package/src/components/textarea/examples/index.ts +1 -1
- package/src/components/textarea/style/Textarea.css.ts +191 -191
- package/src/components/textarea/style/index.ts +1 -1
- package/src/components/tooltip/Tooltip.vue +196 -196
- package/src/components/tooltip/examples/basic.vue +5 -5
- package/src/components/tooltip/examples/index.ts +2 -2
- package/src/components/tooltip/examples/placement.vue +9 -9
- package/src/components/tooltip/style/Tooltip.css.ts +90 -90
- package/src/components/tooltip/style/index.ts +1 -1
- package/src/components/transfer/Transfer.vue +145 -145
- package/src/components/transfer/examples/basic.vue +21 -21
- package/src/components/transfer/examples/index.ts +1 -1
- package/src/components/transfer/style/Transfer.css.ts +81 -81
- package/src/components/transfer/style/index.ts +1 -1
- package/src/components/tree/Tree.vue +138 -138
- package/src/components/tree/TreeNode.vue +109 -109
- package/src/components/tree/TreeNodeToggle.vue +48 -48
- package/src/components/tree/examples/basic.vue +458 -458
- package/src/components/tree/examples/index.ts +1 -1
- package/src/components/tree/props.ts +97 -97
- package/src/components/tree/style/Tree.css.ts +75 -75
- package/src/components/tree/style/index.ts +1 -1
- package/src/components/tree/types.ts +103 -103
- package/src/components/virtualscroll/VirtualScroll.css +13 -13
- package/src/components/virtualscroll/VirtualScroll.vue +166 -166
- package/src/components/virtualscroll/examples/basic.vue +31 -31
- package/src/components/virtualscroll/examples/index.ts +1 -1
- package/src/components/virtualscroll/style/VirtualScroll.css.ts +17 -17
- package/src/components/virtualscroll/style/index.ts +1 -1
- package/src/composables/element.ts +13 -13
- package/src/composables/index.ts +4 -4
- package/src/composables/useCachedUid.ts +49 -49
- package/src/composables/useEventListener.ts +19 -19
- package/src/composables/useInput.ts +151 -151
- package/src/composables/useInteractive.ts +19 -19
- package/src/composables/useIsServer.ts +7 -7
- package/src/composables/useMergedState.ts +18 -18
- package/src/composables/useMount.ts +43 -43
- package/src/composables/usePopper.ts +215 -215
- package/src/composables/useZIndex.ts +33 -33
- package/src/create.ts +38 -38
- package/src/css/components.css +16 -16
- package/src/css/index.css +4 -4
- package/src/css/transitions.css +40 -40
- package/src/css/variables.css +80 -80
- package/src/examples/cards/sidebar.vue +262 -262
- package/src/examples/modal/modal.vue +52 -52
- package/src/exports/nuxt.js +35 -35
- package/src/exports/nuxt.plugin.js +8 -8
- package/src/index.ts +5 -5
- package/src/install.ts +8 -8
- package/src/shims-vue.d.ts +6 -6
- package/src/styles/theme.css.ts +181 -181
- package/src/styles/transitions.css.ts +97 -97
- package/src/types/props.ts +19 -19
- package/src/utils/injection.ts +5 -5
- package/volar.d.ts +16 -16
|
@@ -1,296 +1,296 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div :class="style.pagination">
|
|
3
|
-
<div v-if="showTotal">
|
|
4
|
-
<div v-if="showTotal">
|
|
5
|
-
Showing <strong>{{ (page - 1) * pageSize + 1 }}</strong> to
|
|
6
|
-
<strong>{{ Math.min(page * pageSize, realTotal) }}</strong> of
|
|
7
|
-
<strong>{{ realTotal }}</strong>
|
|
8
|
-
</div>
|
|
9
|
-
</div>
|
|
10
|
-
|
|
11
|
-
<div :class="style.buttons">
|
|
12
|
-
<button
|
|
13
|
-
:class="style.page"
|
|
14
|
-
:tabindex="page === 1 ? undefined : '0'"
|
|
15
|
-
:disabled="page === 1"
|
|
16
|
-
aria-label="Previous"
|
|
17
|
-
role="button"
|
|
18
|
-
@click="handlePageChange(page - 1)">
|
|
19
|
-
<svg
|
|
20
|
-
:class="style.svg"
|
|
21
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
22
|
-
fill="none"
|
|
23
|
-
viewBox="0 0 10 24"
|
|
24
|
-
width="10"
|
|
25
|
-
height="24"
|
|
26
|
-
focusable="false">
|
|
27
|
-
<path
|
|
28
|
-
stroke="currentColor"
|
|
29
|
-
fill="currentColor"
|
|
30
|
-
fill-rule="evenodd"
|
|
31
|
-
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"
|
|
32
|
-
clip-rule="evenodd"></path>
|
|
33
|
-
</svg>
|
|
34
|
-
</button>
|
|
35
|
-
|
|
36
|
-
<div :class="style.pages">
|
|
37
|
-
<template
|
|
38
|
-
v-for="(item, index) in pageIndicatorSeries"
|
|
39
|
-
:key="index">
|
|
40
|
-
<button
|
|
41
|
-
:class="[
|
|
42
|
-
style.page,
|
|
43
|
-
{
|
|
44
|
-
[style.active]: item.current
|
|
45
|
-
}
|
|
46
|
-
]"
|
|
47
|
-
:ref="getKey(item)"
|
|
48
|
-
tabindex="0"
|
|
49
|
-
:disabled="isEmpty"
|
|
50
|
-
role="button"
|
|
51
|
-
@click="handlePageChange(item.page)"
|
|
52
|
-
:aria-label="
|
|
53
|
-
item.current
|
|
54
|
-
? `Page ${item.page}`
|
|
55
|
-
: `Goto page ${item.page}`
|
|
56
|
-
">
|
|
57
|
-
<template v-if="item.more"> ... </template>
|
|
58
|
-
<template v-else>
|
|
59
|
-
{{ item.text }}
|
|
60
|
-
</template>
|
|
61
|
-
</button>
|
|
62
|
-
</template>
|
|
63
|
-
</div>
|
|
64
|
-
|
|
65
|
-
<button
|
|
66
|
-
:tabindex="page === pageCount ? undefined : '0'"
|
|
67
|
-
:disabled="page === pageCount || pageCount === 0"
|
|
68
|
-
aria-label="Next"
|
|
69
|
-
role="button"
|
|
70
|
-
@click="handlePageChange(page + 1)"
|
|
71
|
-
:class="style.page">
|
|
72
|
-
<svg
|
|
73
|
-
:class="style.svg"
|
|
74
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
75
|
-
fill="none"
|
|
76
|
-
viewBox="0 0 10 24"
|
|
77
|
-
width="10"
|
|
78
|
-
height="24"
|
|
79
|
-
focusable="false">
|
|
80
|
-
<path
|
|
81
|
-
stroke="currentColor"
|
|
82
|
-
fill="currentColor"
|
|
83
|
-
fill-rule="evenodd"
|
|
84
|
-
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"
|
|
85
|
-
clip-rule="evenodd"></path>
|
|
86
|
-
</svg>
|
|
87
|
-
</button>
|
|
88
|
-
</div>
|
|
89
|
-
</div>
|
|
90
|
-
</template>
|
|
91
|
-
|
|
92
|
-
<script lang="ts">
|
|
93
|
-
import { computed, defineComponent, watch } from 'vue';
|
|
94
|
-
import * as style from './style';
|
|
95
|
-
|
|
96
|
-
const pageIndicatorLength = 7;
|
|
97
|
-
const aroundIndicatorLength = 1;
|
|
98
|
-
const moreIndicatorOffsetLength = 5;
|
|
99
|
-
export default defineComponent({
|
|
100
|
-
name: 'Pagination',
|
|
101
|
-
props: {
|
|
102
|
-
page: {
|
|
103
|
-
type: Number,
|
|
104
|
-
default: 1
|
|
105
|
-
},
|
|
106
|
-
pageSize: {
|
|
107
|
-
type: Number,
|
|
108
|
-
default: 10
|
|
109
|
-
},
|
|
110
|
-
pageSizes: {
|
|
111
|
-
type: Array
|
|
112
|
-
},
|
|
113
|
-
total: {
|
|
114
|
-
type: Number
|
|
115
|
-
},
|
|
116
|
-
showPageSize: {
|
|
117
|
-
type: Boolean,
|
|
118
|
-
default: true
|
|
119
|
-
},
|
|
120
|
-
showTotal: {
|
|
121
|
-
type: Boolean,
|
|
122
|
-
default: true
|
|
123
|
-
},
|
|
124
|
-
loading: {
|
|
125
|
-
type: Boolean,
|
|
126
|
-
default: false
|
|
127
|
-
}
|
|
128
|
-
},
|
|
129
|
-
emits: ['update:page', 'update:pageSize'],
|
|
130
|
-
setup(props, { emit }) {
|
|
131
|
-
const realTotal = computed(() => {
|
|
132
|
-
return props.total || 0;
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
const isEmpty = computed(() => {
|
|
136
|
-
return realTotal.value === 0;
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
const realPageSizes = computed(() => {
|
|
140
|
-
const sizes =
|
|
141
|
-
props.pageSizes == null
|
|
142
|
-
? [10, 20, 30, 40, 50]
|
|
143
|
-
: props.pageSizes;
|
|
144
|
-
|
|
145
|
-
return sizes.map(size => ({
|
|
146
|
-
label: size,
|
|
147
|
-
value: size
|
|
148
|
-
}));
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
const pageCount = computed(() => {
|
|
152
|
-
return Math.ceil(realTotal.value / props.pageSize);
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
const pageIndicatorSeries = computed(() => {
|
|
156
|
-
let { page } = props;
|
|
157
|
-
|
|
158
|
-
if (isEmpty.value) {
|
|
159
|
-
return [getPageIndicator(1, { current: false })];
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
let continuousIndicatorLength = aroundIndicatorLength * 2 + 1;
|
|
163
|
-
let boundaryIndicatorLength =
|
|
164
|
-
(pageIndicatorLength - continuousIndicatorLength - 2) / 2;
|
|
165
|
-
let leftLen;
|
|
166
|
-
let rightLen;
|
|
167
|
-
let offsetBackward = Math.max(page - moreIndicatorOffsetLength, 1);
|
|
168
|
-
let offsetForward = Math.min(
|
|
169
|
-
page + moreIndicatorOffsetLength,
|
|
170
|
-
pageCount.value
|
|
171
|
-
);
|
|
172
|
-
switch (true) {
|
|
173
|
-
case pageCount.value <= pageIndicatorLength:
|
|
174
|
-
return getPageSeries(1, pageCount.value);
|
|
175
|
-
case page <=
|
|
176
|
-
boundaryIndicatorLength + aroundIndicatorLength + 2:
|
|
177
|
-
leftLen = pageIndicatorLength - boundaryIndicatorLength - 1;
|
|
178
|
-
return getPageSeries(1, leftLen)
|
|
179
|
-
.concat(
|
|
180
|
-
getPageIndicator(offsetForward, {
|
|
181
|
-
more: true,
|
|
182
|
-
forward: true
|
|
183
|
-
})
|
|
184
|
-
)
|
|
185
|
-
.concat(
|
|
186
|
-
getPageSeries(
|
|
187
|
-
pageCount.value - boundaryIndicatorLength + 1,
|
|
188
|
-
boundaryIndicatorLength
|
|
189
|
-
)
|
|
190
|
-
);
|
|
191
|
-
case page >=
|
|
192
|
-
pageCount.value -
|
|
193
|
-
boundaryIndicatorLength -
|
|
194
|
-
aroundIndicatorLength -
|
|
195
|
-
1:
|
|
196
|
-
rightLen =
|
|
197
|
-
pageIndicatorLength - boundaryIndicatorLength - 1;
|
|
198
|
-
return getPageSeries(1, boundaryIndicatorLength)
|
|
199
|
-
.concat(
|
|
200
|
-
getPageIndicator(offsetBackward, {
|
|
201
|
-
more: true,
|
|
202
|
-
forward: false
|
|
203
|
-
})
|
|
204
|
-
)
|
|
205
|
-
.concat(
|
|
206
|
-
getPageSeries(
|
|
207
|
-
pageCount.value - rightLen + 1,
|
|
208
|
-
rightLen
|
|
209
|
-
)
|
|
210
|
-
);
|
|
211
|
-
default:
|
|
212
|
-
return getPageSeries(1, boundaryIndicatorLength)
|
|
213
|
-
.concat(
|
|
214
|
-
getPageIndicator(offsetBackward, {
|
|
215
|
-
more: true,
|
|
216
|
-
forward: false
|
|
217
|
-
})
|
|
218
|
-
)
|
|
219
|
-
.concat(
|
|
220
|
-
getPageSeries(
|
|
221
|
-
page - aroundIndicatorLength,
|
|
222
|
-
continuousIndicatorLength
|
|
223
|
-
)
|
|
224
|
-
)
|
|
225
|
-
.concat(
|
|
226
|
-
getPageIndicator(offsetForward, {
|
|
227
|
-
more: true,
|
|
228
|
-
forward: true
|
|
229
|
-
})
|
|
230
|
-
)
|
|
231
|
-
.concat(
|
|
232
|
-
getPageSeries(
|
|
233
|
-
pageCount.value - boundaryIndicatorLength + 1,
|
|
234
|
-
boundaryIndicatorLength
|
|
235
|
-
)
|
|
236
|
-
);
|
|
237
|
-
}
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
function getPageSeries(from: number, length: number) {
|
|
241
|
-
let series = [];
|
|
242
|
-
for (let i = 0; i < length; i++) {
|
|
243
|
-
series[i] = getPageIndicator(from + i);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
return series;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
function getPageIndicator(
|
|
250
|
-
page: number,
|
|
251
|
-
{ more = false, forward = false, current = false } = {}
|
|
252
|
-
) {
|
|
253
|
-
return {
|
|
254
|
-
page,
|
|
255
|
-
more,
|
|
256
|
-
forward,
|
|
257
|
-
current: !current ? page === props.page : current,
|
|
258
|
-
text: page
|
|
259
|
-
};
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
function getKey(item: any) {
|
|
263
|
-
return `page-${
|
|
264
|
-
item.more ? (item.forward ? 'forward' : 'backward') : item.page
|
|
265
|
-
}`;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
function handlePageChange(page: number) {
|
|
269
|
-
if (props.loading) {
|
|
270
|
-
return;
|
|
271
|
-
}
|
|
272
|
-
emit('update:page', page);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
watch(
|
|
276
|
-
() => props.page,
|
|
277
|
-
val => {
|
|
278
|
-
emit('update:page', val);
|
|
279
|
-
},
|
|
280
|
-
{ immediate: true }
|
|
281
|
-
);
|
|
282
|
-
|
|
283
|
-
return {
|
|
284
|
-
realTotal,
|
|
285
|
-
isEmpty,
|
|
286
|
-
realPageSizes,
|
|
287
|
-
pageCount,
|
|
288
|
-
pageIndicatorSeries,
|
|
289
|
-
getKey,
|
|
290
|
-
handlePageChange,
|
|
291
|
-
|
|
292
|
-
style
|
|
293
|
-
};
|
|
294
|
-
}
|
|
295
|
-
});
|
|
296
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="style.pagination">
|
|
3
|
+
<div v-if="showTotal">
|
|
4
|
+
<div v-if="showTotal">
|
|
5
|
+
Showing <strong>{{ (page - 1) * pageSize + 1 }}</strong> to
|
|
6
|
+
<strong>{{ Math.min(page * pageSize, realTotal) }}</strong> of
|
|
7
|
+
<strong>{{ realTotal }}</strong>
|
|
8
|
+
</div>
|
|
9
|
+
</div>
|
|
10
|
+
|
|
11
|
+
<div :class="style.buttons">
|
|
12
|
+
<button
|
|
13
|
+
:class="style.page"
|
|
14
|
+
:tabindex="page === 1 ? undefined : '0'"
|
|
15
|
+
:disabled="page === 1"
|
|
16
|
+
aria-label="Previous"
|
|
17
|
+
role="button"
|
|
18
|
+
@click="handlePageChange(page - 1)">
|
|
19
|
+
<svg
|
|
20
|
+
:class="style.svg"
|
|
21
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
22
|
+
fill="none"
|
|
23
|
+
viewBox="0 0 10 24"
|
|
24
|
+
width="10"
|
|
25
|
+
height="24"
|
|
26
|
+
focusable="false">
|
|
27
|
+
<path
|
|
28
|
+
stroke="currentColor"
|
|
29
|
+
fill="currentColor"
|
|
30
|
+
fill-rule="evenodd"
|
|
31
|
+
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"
|
|
32
|
+
clip-rule="evenodd"></path>
|
|
33
|
+
</svg>
|
|
34
|
+
</button>
|
|
35
|
+
|
|
36
|
+
<div :class="style.pages">
|
|
37
|
+
<template
|
|
38
|
+
v-for="(item, index) in pageIndicatorSeries"
|
|
39
|
+
:key="index">
|
|
40
|
+
<button
|
|
41
|
+
:class="[
|
|
42
|
+
style.page,
|
|
43
|
+
{
|
|
44
|
+
[style.active]: item.current
|
|
45
|
+
}
|
|
46
|
+
]"
|
|
47
|
+
:ref="getKey(item)"
|
|
48
|
+
tabindex="0"
|
|
49
|
+
:disabled="isEmpty"
|
|
50
|
+
role="button"
|
|
51
|
+
@click="handlePageChange(item.page)"
|
|
52
|
+
:aria-label="
|
|
53
|
+
item.current
|
|
54
|
+
? `Page ${item.page}`
|
|
55
|
+
: `Goto page ${item.page}`
|
|
56
|
+
">
|
|
57
|
+
<template v-if="item.more"> ... </template>
|
|
58
|
+
<template v-else>
|
|
59
|
+
{{ item.text }}
|
|
60
|
+
</template>
|
|
61
|
+
</button>
|
|
62
|
+
</template>
|
|
63
|
+
</div>
|
|
64
|
+
|
|
65
|
+
<button
|
|
66
|
+
:tabindex="page === pageCount ? undefined : '0'"
|
|
67
|
+
:disabled="page === pageCount || pageCount === 0"
|
|
68
|
+
aria-label="Next"
|
|
69
|
+
role="button"
|
|
70
|
+
@click="handlePageChange(page + 1)"
|
|
71
|
+
:class="style.page">
|
|
72
|
+
<svg
|
|
73
|
+
:class="style.svg"
|
|
74
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
75
|
+
fill="none"
|
|
76
|
+
viewBox="0 0 10 24"
|
|
77
|
+
width="10"
|
|
78
|
+
height="24"
|
|
79
|
+
focusable="false">
|
|
80
|
+
<path
|
|
81
|
+
stroke="currentColor"
|
|
82
|
+
fill="currentColor"
|
|
83
|
+
fill-rule="evenodd"
|
|
84
|
+
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"
|
|
85
|
+
clip-rule="evenodd"></path>
|
|
86
|
+
</svg>
|
|
87
|
+
</button>
|
|
88
|
+
</div>
|
|
89
|
+
</div>
|
|
90
|
+
</template>
|
|
91
|
+
|
|
92
|
+
<script lang="ts">
|
|
93
|
+
import { computed, defineComponent, watch } from 'vue';
|
|
94
|
+
import * as style from './style';
|
|
95
|
+
|
|
96
|
+
const pageIndicatorLength = 7;
|
|
97
|
+
const aroundIndicatorLength = 1;
|
|
98
|
+
const moreIndicatorOffsetLength = 5;
|
|
99
|
+
export default defineComponent({
|
|
100
|
+
name: 'Pagination',
|
|
101
|
+
props: {
|
|
102
|
+
page: {
|
|
103
|
+
type: Number,
|
|
104
|
+
default: 1
|
|
105
|
+
},
|
|
106
|
+
pageSize: {
|
|
107
|
+
type: Number,
|
|
108
|
+
default: 10
|
|
109
|
+
},
|
|
110
|
+
pageSizes: {
|
|
111
|
+
type: Array
|
|
112
|
+
},
|
|
113
|
+
total: {
|
|
114
|
+
type: Number
|
|
115
|
+
},
|
|
116
|
+
showPageSize: {
|
|
117
|
+
type: Boolean,
|
|
118
|
+
default: true
|
|
119
|
+
},
|
|
120
|
+
showTotal: {
|
|
121
|
+
type: Boolean,
|
|
122
|
+
default: true
|
|
123
|
+
},
|
|
124
|
+
loading: {
|
|
125
|
+
type: Boolean,
|
|
126
|
+
default: false
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
emits: ['update:page', 'update:pageSize'],
|
|
130
|
+
setup(props, { emit }) {
|
|
131
|
+
const realTotal = computed(() => {
|
|
132
|
+
return props.total || 0;
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
const isEmpty = computed(() => {
|
|
136
|
+
return realTotal.value === 0;
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
const realPageSizes = computed(() => {
|
|
140
|
+
const sizes =
|
|
141
|
+
props.pageSizes == null
|
|
142
|
+
? [10, 20, 30, 40, 50]
|
|
143
|
+
: props.pageSizes;
|
|
144
|
+
|
|
145
|
+
return sizes.map(size => ({
|
|
146
|
+
label: size,
|
|
147
|
+
value: size
|
|
148
|
+
}));
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
const pageCount = computed(() => {
|
|
152
|
+
return Math.ceil(realTotal.value / props.pageSize);
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
const pageIndicatorSeries = computed(() => {
|
|
156
|
+
let { page } = props;
|
|
157
|
+
|
|
158
|
+
if (isEmpty.value) {
|
|
159
|
+
return [getPageIndicator(1, { current: false })];
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
let continuousIndicatorLength = aroundIndicatorLength * 2 + 1;
|
|
163
|
+
let boundaryIndicatorLength =
|
|
164
|
+
(pageIndicatorLength - continuousIndicatorLength - 2) / 2;
|
|
165
|
+
let leftLen;
|
|
166
|
+
let rightLen;
|
|
167
|
+
let offsetBackward = Math.max(page - moreIndicatorOffsetLength, 1);
|
|
168
|
+
let offsetForward = Math.min(
|
|
169
|
+
page + moreIndicatorOffsetLength,
|
|
170
|
+
pageCount.value
|
|
171
|
+
);
|
|
172
|
+
switch (true) {
|
|
173
|
+
case pageCount.value <= pageIndicatorLength:
|
|
174
|
+
return getPageSeries(1, pageCount.value);
|
|
175
|
+
case page <=
|
|
176
|
+
boundaryIndicatorLength + aroundIndicatorLength + 2:
|
|
177
|
+
leftLen = pageIndicatorLength - boundaryIndicatorLength - 1;
|
|
178
|
+
return getPageSeries(1, leftLen)
|
|
179
|
+
.concat(
|
|
180
|
+
getPageIndicator(offsetForward, {
|
|
181
|
+
more: true,
|
|
182
|
+
forward: true
|
|
183
|
+
})
|
|
184
|
+
)
|
|
185
|
+
.concat(
|
|
186
|
+
getPageSeries(
|
|
187
|
+
pageCount.value - boundaryIndicatorLength + 1,
|
|
188
|
+
boundaryIndicatorLength
|
|
189
|
+
)
|
|
190
|
+
);
|
|
191
|
+
case page >=
|
|
192
|
+
pageCount.value -
|
|
193
|
+
boundaryIndicatorLength -
|
|
194
|
+
aroundIndicatorLength -
|
|
195
|
+
1:
|
|
196
|
+
rightLen =
|
|
197
|
+
pageIndicatorLength - boundaryIndicatorLength - 1;
|
|
198
|
+
return getPageSeries(1, boundaryIndicatorLength)
|
|
199
|
+
.concat(
|
|
200
|
+
getPageIndicator(offsetBackward, {
|
|
201
|
+
more: true,
|
|
202
|
+
forward: false
|
|
203
|
+
})
|
|
204
|
+
)
|
|
205
|
+
.concat(
|
|
206
|
+
getPageSeries(
|
|
207
|
+
pageCount.value - rightLen + 1,
|
|
208
|
+
rightLen
|
|
209
|
+
)
|
|
210
|
+
);
|
|
211
|
+
default:
|
|
212
|
+
return getPageSeries(1, boundaryIndicatorLength)
|
|
213
|
+
.concat(
|
|
214
|
+
getPageIndicator(offsetBackward, {
|
|
215
|
+
more: true,
|
|
216
|
+
forward: false
|
|
217
|
+
})
|
|
218
|
+
)
|
|
219
|
+
.concat(
|
|
220
|
+
getPageSeries(
|
|
221
|
+
page - aroundIndicatorLength,
|
|
222
|
+
continuousIndicatorLength
|
|
223
|
+
)
|
|
224
|
+
)
|
|
225
|
+
.concat(
|
|
226
|
+
getPageIndicator(offsetForward, {
|
|
227
|
+
more: true,
|
|
228
|
+
forward: true
|
|
229
|
+
})
|
|
230
|
+
)
|
|
231
|
+
.concat(
|
|
232
|
+
getPageSeries(
|
|
233
|
+
pageCount.value - boundaryIndicatorLength + 1,
|
|
234
|
+
boundaryIndicatorLength
|
|
235
|
+
)
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
function getPageSeries(from: number, length: number) {
|
|
241
|
+
let series = [];
|
|
242
|
+
for (let i = 0; i < length; i++) {
|
|
243
|
+
series[i] = getPageIndicator(from + i);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
return series;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function getPageIndicator(
|
|
250
|
+
page: number,
|
|
251
|
+
{ more = false, forward = false, current = false } = {}
|
|
252
|
+
) {
|
|
253
|
+
return {
|
|
254
|
+
page,
|
|
255
|
+
more,
|
|
256
|
+
forward,
|
|
257
|
+
current: !current ? page === props.page : current,
|
|
258
|
+
text: page
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function getKey(item: any) {
|
|
263
|
+
return `page-${
|
|
264
|
+
item.more ? (item.forward ? 'forward' : 'backward') : item.page
|
|
265
|
+
}`;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function handlePageChange(page: number) {
|
|
269
|
+
if (props.loading) {
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
emit('update:page', page);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
watch(
|
|
276
|
+
() => props.page,
|
|
277
|
+
val => {
|
|
278
|
+
emit('update:page', val);
|
|
279
|
+
},
|
|
280
|
+
{ immediate: true }
|
|
281
|
+
);
|
|
282
|
+
|
|
283
|
+
return {
|
|
284
|
+
realTotal,
|
|
285
|
+
isEmpty,
|
|
286
|
+
realPageSizes,
|
|
287
|
+
pageCount,
|
|
288
|
+
pageIndicatorSeries,
|
|
289
|
+
getKey,
|
|
290
|
+
handlePageChange,
|
|
291
|
+
|
|
292
|
+
style
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
</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 +1 @@
|
|
|
1
|
-
export { default as MPaginationBasic } from './basic.vue';
|
|
1
|
+
export { default as MPaginationBasic } from './basic.vue';
|