v-page 3.0.0 → 3.2.0
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/README.md +7 -6
- package/dist/v-page.js +298 -187
- package/dist/v-page.umd.cjs +2 -2
- package/package.json +15 -16
- package/types/index.d.ts +33 -18
package/README.md
CHANGED
|
@@ -47,7 +47,7 @@ app.use(PaginationBar, {
|
|
|
47
47
|
app.mount('#app')
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
Use `v-page` as a locally component
|
|
51
51
|
|
|
52
52
|
```vue
|
|
53
53
|
<template>
|
|
@@ -70,15 +70,16 @@ import { PaginationBar } from 'v-page'
|
|
|
70
70
|
/>
|
|
71
71
|
</template>
|
|
72
72
|
|
|
73
|
-
<script setup>
|
|
73
|
+
<script setup lang='ts'>
|
|
74
74
|
import { ref } from 'vue'
|
|
75
75
|
import { PaginationBar } from 'v-page'
|
|
76
|
+
import type { PageInfo } from 'v-page'
|
|
76
77
|
// set default page to 3
|
|
77
|
-
const pageNumber = ref(3)
|
|
78
|
-
const totalRow = ref(100)
|
|
78
|
+
const pageNumber = ref<number>(3)
|
|
79
|
+
const totalRow = ref<number>(100)
|
|
79
80
|
// respond for pagination change
|
|
80
|
-
function paginationChange (data) {
|
|
81
|
-
console.log(data) // { pageNumber: 1, pageSize: 10 }
|
|
81
|
+
function paginationChange (data: PageInfo): void {
|
|
82
|
+
console.log(data) // { pageNumber: 1, pageSize: 10, totalPage: 10 }
|
|
82
83
|
}
|
|
83
84
|
</script>
|
|
84
85
|
```
|
package/dist/v-page.js
CHANGED
|
@@ -1,228 +1,339 @@
|
|
|
1
|
-
(function(){"use strict";try{if(typeof document<"u"){var i=document.createElement("style");i.appendChild(document.createTextNode(".v-pagination{display:flex;justify-content:flex-start;box-sizing:border-box}.v-pagination--right{justify-content:flex-end}.v-pagination--center{justify-content:center}.v-pagination.v-pagination--disabled a,.v-pagination.v-pagination--disabled select{color:#
|
|
2
|
-
import {
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var i=document.createElement("style");i.appendChild(document.createTextNode(".v-pagination{display:flex;justify-content:flex-start;box-sizing:border-box}.v-pagination--right{justify-content:flex-end}.v-pagination--center{justify-content:center}.v-pagination.v-pagination--disabled a,.v-pagination.v-pagination--disabled select{color:#ddd!important}.v-pagination.v-pagination--disabled .v-pagination__item a{cursor:default!important}.v-pagination.v-pagination--disabled .v-pagination__item a:hover{background-color:transparent}.v-pagination.v-pagination--disabled.v-pagination--border ul{background-color:#fafafa}.v-pagination.v-pagination--circle .v-pagination__item a{border-radius:50rem;border:1px solid transparent}.v-pagination.v-pagination--circle .v-pagination__item a:hover{border:1px solid #f7f7f7}.v-pagination.v-pagination--circle .v-pagination__item.disabled a:hover{border:1px solid transparent}.v-pagination.v-pagination--circle .v-pagination__item.active a{border:1px solid #ddd!important;background-color:transparent!important;box-shadow:0 1px 3px #0000001a}.v-pagination ul{margin:0;padding:0;display:flex}.v-pagination ul li{list-style:none;display:flex}.v-pagination ul li a{padding:.3rem .6rem;text-decoration:none;line-height:1.3;font-size:14px;margin:0;outline:0;color:#333;border-radius:.5rem;display:inline-flex;align-items:center;cursor:default;transition:all .3s}.v-pagination ul li.v-pagination__list a,.v-pagination ul li.v-pagination__info a{color:#888}.v-pagination ul li.active a,.v-pagination ul li.disabled a{cursor:default!important}.v-pagination ul li.v-pagination__item a:hover{background-color:#f7f7f7;cursor:pointer}.v-pagination ul li.active a{background-color:#eee!important;color:#aaa}.v-pagination ul li.disabled a{color:#ddd!important}.v-pagination ul li.disabled a:hover{background-color:transparent}.v-pagination ul li select{width:auto!important;font-size:12px;padding:0;outline:0;margin:0 0 0 5px;border:1px solid #ccc;color:#333;border-radius:.3rem}.v-pagination.v-pagination--border ul{box-shadow:0 1px 2px #0000000d;border-radius:.5rem}.v-pagination.v-pagination--border ul li a{border:1px solid #DEE2E6;border-left:0;border-radius:0}.v-pagination.v-pagination--border ul li:first-child>a{border-bottom-left-radius:.5rem;border-top-left-radius:.5rem;border-left:1px solid #DEE2E6}.v-pagination.v-pagination--border ul li:last-child>a{border-top-right-radius:.5rem;border-bottom-right-radius:.5rem}.v-pagination.v-pagination--border ul li.active a{color:#aaa;background-color:#eee}")),document.head.appendChild(i)}}catch(a){console.error("vite-plugin-css-injected-by-js",a)}})();
|
|
2
|
+
import { toRefs as Z, ref as A, computed as b, watch as w, onMounted as k, createVNode as a, defineComponent as H } from "vue";
|
|
3
3
|
const [
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
] = ["cn", "en", "de", "jp", "pt"],
|
|
10
|
-
[
|
|
11
|
-
pageLength: "每页记录数
|
|
12
|
-
pageInfo: "
|
|
4
|
+
J,
|
|
5
|
+
y,
|
|
6
|
+
q,
|
|
7
|
+
K,
|
|
8
|
+
Q
|
|
9
|
+
] = ["cn", "en", "de", "jp", "pt"], O = {
|
|
10
|
+
[J]: {
|
|
11
|
+
pageLength: "每页记录数",
|
|
12
|
+
pageInfo: "第 #pageNumber#/#totalPage# 页(共#totalRow#条记录)",
|
|
13
13
|
first: "首页",
|
|
14
|
-
previous: "«",
|
|
15
|
-
next: "»",
|
|
16
14
|
last: "尾页",
|
|
17
15
|
all: "全部"
|
|
18
16
|
},
|
|
19
|
-
[
|
|
20
|
-
pageLength: "
|
|
21
|
-
pageInfo: "
|
|
17
|
+
[y]: {
|
|
18
|
+
pageLength: "Per page",
|
|
19
|
+
pageInfo: "Page #pageNumber#/#totalPage# (total #totalRow# records)",
|
|
22
20
|
first: "First",
|
|
23
|
-
previous: "«",
|
|
24
|
-
next: "»",
|
|
25
21
|
last: "Last",
|
|
26
22
|
all: "All"
|
|
27
23
|
},
|
|
28
|
-
[
|
|
29
|
-
pageLength: "Seitenlänge
|
|
30
|
-
pageInfo: "Aktuell #pageNumber
|
|
24
|
+
[q]: {
|
|
25
|
+
pageLength: "Seitenlänge",
|
|
26
|
+
pageInfo: "Aktuell #pageNumber#/#totalPage# (gesamt #totalRow# Aufzeichnungen)",
|
|
31
27
|
first: "Zuerst",
|
|
32
|
-
previous: "«",
|
|
33
|
-
next: "»",
|
|
34
28
|
last: "Letzte",
|
|
35
29
|
all: "Alle"
|
|
36
30
|
},
|
|
37
|
-
[
|
|
31
|
+
[K]: {
|
|
38
32
|
pageLength: "ページごとの記録数",
|
|
39
|
-
pageInfo: "現在の第 #pageNumber
|
|
33
|
+
pageInfo: "現在の第 #pageNumber#/#totalPage# ページ(全部で #totalRow# 条の記録)",
|
|
40
34
|
first: "トップページ",
|
|
41
|
-
previous: "«",
|
|
42
|
-
next: "»",
|
|
43
35
|
last: "尾のページ",
|
|
44
36
|
all: "すべて"
|
|
45
37
|
},
|
|
46
|
-
[
|
|
47
|
-
pageLength: "Resultados por página
|
|
48
|
-
pageInfo: "#pageNumber
|
|
38
|
+
[Q]: {
|
|
39
|
+
pageLength: "Resultados por página",
|
|
40
|
+
pageInfo: "#pageNumber#/#totalPage# (total de #totalRow#)",
|
|
49
41
|
first: "Início",
|
|
50
|
-
previous: "<",
|
|
51
|
-
next: ">",
|
|
52
42
|
last: "Fim",
|
|
53
43
|
all: "Todos"
|
|
54
44
|
}
|
|
55
|
-
},
|
|
56
|
-
function
|
|
57
|
-
if (
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return o < r ? r : o > n ? n : o;
|
|
45
|
+
}, s = 1, W = 5, E = 10, F = [E, 20, 50, 100], z = 0, [le, ne, X] = ["left", "center", "right"];
|
|
46
|
+
function Y(e, u, l) {
|
|
47
|
+
if (u <= l) return s;
|
|
48
|
+
const f = Math.floor(l / 2), i = u - l + 1, r = e - f;
|
|
49
|
+
return r < s ? s : r > i ? i : r;
|
|
61
50
|
}
|
|
62
|
-
function
|
|
63
|
-
const
|
|
64
|
-
return Array.from({ length:
|
|
51
|
+
function $(e, u, l) {
|
|
52
|
+
const f = Y(e, u, l);
|
|
53
|
+
return Array.from({ length: l }).map((i, r) => f + r).filter((i) => i >= s && i <= u);
|
|
65
54
|
}
|
|
66
|
-
|
|
55
|
+
function ee(e = y) {
|
|
56
|
+
const u = String(e).toLowerCase();
|
|
57
|
+
return O[Object.hasOwn(O, u) ? u : y];
|
|
58
|
+
}
|
|
59
|
+
function ae(e, u, l) {
|
|
60
|
+
const {
|
|
61
|
+
pageSizeOptions: f,
|
|
62
|
+
pageSizeMenu: i,
|
|
63
|
+
totalRow: r
|
|
64
|
+
} = Z(e), n = A(0), v = A(W), o = A(e.pageSize ?? E), c = ee(e.language), m = b(() => {
|
|
65
|
+
if (!f.value) return [];
|
|
66
|
+
const t = Array.isArray(i.value) && i.value.length > 0 ? i.value : F, d = new Set(t);
|
|
67
|
+
return d.add(o.value), [...d].sort((p, L) => p - L);
|
|
68
|
+
}), g = b(() => o.value === z ? s : Math.ceil(r.value / o.value)), N = b(() => $(n.value, g.value, v.value)), V = b(() => ({
|
|
69
|
+
"v-pagination": !0,
|
|
70
|
+
"v-pagination--right": e.align === "right",
|
|
71
|
+
"v-pagination--center": e.align === "center",
|
|
72
|
+
"v-pagination--disabled": e.disabled,
|
|
73
|
+
"v-pagination--border": e.border,
|
|
74
|
+
"v-pagination--circle": !e.border && e.circle
|
|
75
|
+
})), I = b(() => n.value === s), _ = b(() => n.value === g.value);
|
|
76
|
+
w(() => e.modelValue, h), w(() => e.pageSize, R);
|
|
77
|
+
function h(t = s) {
|
|
78
|
+
if (e.disabled || typeof t != "number") return;
|
|
79
|
+
let d = t < s ? s : t;
|
|
80
|
+
t > g.value && g.value > 0 && (d = g.value), d !== n.value && (n.value = d, u("update:modelValue", n.value), B());
|
|
81
|
+
}
|
|
82
|
+
function R(t) {
|
|
83
|
+
if (!(t < 0) && t !== o.value) {
|
|
84
|
+
if (o.value = t, u("update:pageSize", o.value), n.value === s)
|
|
85
|
+
return B();
|
|
86
|
+
h(s);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function B() {
|
|
90
|
+
u("change", {
|
|
91
|
+
pageNumber: n.value,
|
|
92
|
+
pageSize: Number(o.value),
|
|
93
|
+
totalPage: g.value
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
function C() {
|
|
97
|
+
if (!f.value) return null;
|
|
98
|
+
const t = () => m.value.map((p) => a("option", {
|
|
99
|
+
value: p,
|
|
100
|
+
selected: o.value === p
|
|
101
|
+
}, [p])), d = () => e.displayAll ? a("option", {
|
|
102
|
+
value: z,
|
|
103
|
+
selected: o.value === z
|
|
104
|
+
}, [c.all]) : null;
|
|
105
|
+
return a("li", {
|
|
106
|
+
class: "v-pagination__list"
|
|
107
|
+
}, [a("a", {
|
|
108
|
+
href: "javascript:void(0)"
|
|
109
|
+
}, [a("span", null, [c.pageLength]), a("select", {
|
|
110
|
+
disabled: e.disabled,
|
|
111
|
+
onChange: (p) => R(Number(p.target.value))
|
|
112
|
+
}, [a(t, null, null), a(d, null, null)])])]);
|
|
113
|
+
}
|
|
114
|
+
function M() {
|
|
115
|
+
if (!e.info) return null;
|
|
116
|
+
const t = c.pageInfo.replace("#pageNumber#", n.value).replace("#totalPage#", g.value).replace("#totalRow#", r.value);
|
|
117
|
+
return a("li", {
|
|
118
|
+
class: "v-pagination__info"
|
|
119
|
+
}, [a("a", {
|
|
120
|
+
href: "javascript:void(0)"
|
|
121
|
+
}, [t])]);
|
|
122
|
+
}
|
|
123
|
+
function T() {
|
|
124
|
+
if (!Object.hasOwn(l, "default")) return null;
|
|
125
|
+
const t = {
|
|
126
|
+
pageNumber: n.value,
|
|
127
|
+
pageSize: o.value,
|
|
128
|
+
totalPage: g.value,
|
|
129
|
+
totalRow: r.value,
|
|
130
|
+
isFirst: I.value,
|
|
131
|
+
isLast: _.value
|
|
132
|
+
};
|
|
133
|
+
return a("li", {
|
|
134
|
+
class: "v-pagination__slot"
|
|
135
|
+
}, [a("a", {
|
|
136
|
+
href: "javascript:void(0)"
|
|
137
|
+
}, [l.default(t)])]);
|
|
138
|
+
}
|
|
139
|
+
function P({
|
|
140
|
+
classes: t,
|
|
141
|
+
pageNumberValue: d,
|
|
142
|
+
name: p,
|
|
143
|
+
hasItem: L = !0
|
|
144
|
+
}) {
|
|
145
|
+
return L ? a("li", {
|
|
146
|
+
class: ["v-pagination__item", ...t]
|
|
147
|
+
}, [a("a", {
|
|
148
|
+
href: "javascript:void(0)",
|
|
149
|
+
onClick: () => h(d)
|
|
150
|
+
}, [p])]) : null;
|
|
151
|
+
}
|
|
152
|
+
function j() {
|
|
153
|
+
return e.pageNumber ? N.value.map((t) => a(P, {
|
|
154
|
+
classes: [{
|
|
155
|
+
active: t === n.value
|
|
156
|
+
}],
|
|
157
|
+
pageNumberValue: t,
|
|
158
|
+
name: t
|
|
159
|
+
}, null)) : null;
|
|
160
|
+
}
|
|
161
|
+
function G() {
|
|
162
|
+
return a(P, {
|
|
163
|
+
classes: ["v-pagination__first", {
|
|
164
|
+
disabled: I.value
|
|
165
|
+
}],
|
|
166
|
+
pageNumberValue: s,
|
|
167
|
+
name: c.first,
|
|
168
|
+
hasItem: e.first
|
|
169
|
+
}, null);
|
|
170
|
+
}
|
|
171
|
+
function D() {
|
|
172
|
+
return a(P, {
|
|
173
|
+
classes: ["v-pagination__previous", {
|
|
174
|
+
disabled: I.value
|
|
175
|
+
}],
|
|
176
|
+
pageNumberValue: n.value - 1,
|
|
177
|
+
name: "«"
|
|
178
|
+
}, null);
|
|
179
|
+
}
|
|
180
|
+
function x() {
|
|
181
|
+
return a(P, {
|
|
182
|
+
classes: ["v-pagination__next", {
|
|
183
|
+
disabled: _.value
|
|
184
|
+
}],
|
|
185
|
+
pageNumberValue: n.value + 1,
|
|
186
|
+
name: "»"
|
|
187
|
+
}, null);
|
|
188
|
+
}
|
|
189
|
+
function U() {
|
|
190
|
+
return a(P, {
|
|
191
|
+
classes: ["v-pagination__last", {
|
|
192
|
+
disabled: _.value
|
|
193
|
+
}],
|
|
194
|
+
pageNumberValue: g.value,
|
|
195
|
+
name: c.last,
|
|
196
|
+
hasItem: e.last
|
|
197
|
+
}, null);
|
|
198
|
+
}
|
|
199
|
+
return k(() => h(e.modelValue || s)), {
|
|
200
|
+
containerClasses: V,
|
|
201
|
+
totalPage: g,
|
|
202
|
+
current: n,
|
|
203
|
+
pageNumbers: N,
|
|
204
|
+
PageSizeOptions: C,
|
|
205
|
+
PageInformation: M,
|
|
206
|
+
PageSlot: T,
|
|
207
|
+
PageNumberItems: j,
|
|
208
|
+
FirstPageItem: G,
|
|
209
|
+
PreviousPageItem: D,
|
|
210
|
+
NextPageItem: x,
|
|
211
|
+
LastPageItem: U
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
const S = /* @__PURE__ */ H({
|
|
67
215
|
name: "PaginationBar",
|
|
68
216
|
props: {
|
|
69
|
-
modelValue: {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
type:
|
|
79
|
-
default:
|
|
217
|
+
modelValue: {
|
|
218
|
+
type: Number,
|
|
219
|
+
default: 0
|
|
220
|
+
},
|
|
221
|
+
pageSize: {
|
|
222
|
+
type: Number,
|
|
223
|
+
default: E
|
|
224
|
+
},
|
|
225
|
+
totalRow: {
|
|
226
|
+
type: Number,
|
|
227
|
+
default: 0
|
|
228
|
+
},
|
|
229
|
+
language: {
|
|
230
|
+
type: String,
|
|
231
|
+
default: y
|
|
80
232
|
},
|
|
81
233
|
/**
|
|
82
234
|
* Pagination alignment direction
|
|
83
235
|
* `left`, `center` and `right`(default)
|
|
84
236
|
*/
|
|
85
|
-
align: {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
237
|
+
align: {
|
|
238
|
+
type: String,
|
|
239
|
+
default: X
|
|
240
|
+
},
|
|
241
|
+
/** Page size list */
|
|
242
|
+
pageSizeMenu: {
|
|
243
|
+
type: [Array],
|
|
244
|
+
default: () => F
|
|
245
|
+
},
|
|
246
|
+
/** Display page size menu panel */
|
|
247
|
+
pageSizeOptions: {
|
|
248
|
+
type: Boolean,
|
|
249
|
+
default: !0
|
|
250
|
+
},
|
|
251
|
+
disabled: {
|
|
252
|
+
type: Boolean,
|
|
253
|
+
default: !1
|
|
254
|
+
},
|
|
255
|
+
/** Round style page number button */
|
|
256
|
+
circle: {
|
|
257
|
+
type: Boolean,
|
|
258
|
+
default: !1
|
|
259
|
+
},
|
|
260
|
+
border: {
|
|
261
|
+
type: Boolean,
|
|
262
|
+
default: !1
|
|
263
|
+
},
|
|
264
|
+
info: {
|
|
265
|
+
type: Boolean,
|
|
266
|
+
default: !0
|
|
267
|
+
},
|
|
268
|
+
pageNumber: {
|
|
269
|
+
type: Boolean,
|
|
270
|
+
default: !0
|
|
271
|
+
},
|
|
90
272
|
/** first page button */
|
|
91
|
-
first: {
|
|
273
|
+
first: {
|
|
274
|
+
type: Boolean,
|
|
275
|
+
default: !0
|
|
276
|
+
},
|
|
92
277
|
/** last page button */
|
|
93
|
-
last: {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
})), A = b(() => l.value === r), L = b(() => l.value === p.value);
|
|
112
|
-
k(
|
|
113
|
-
() => e.modelValue,
|
|
114
|
-
(a) => {
|
|
115
|
-
typeof a == "number" && a > 0 && h(a, !1);
|
|
116
|
-
}
|
|
117
|
-
);
|
|
118
|
-
function h(a = r, P = !0) {
|
|
119
|
-
if (e.disabled || typeof a != "number")
|
|
120
|
-
return;
|
|
121
|
-
let c = a < r ? r : a;
|
|
122
|
-
a > p.value && p.value > 0 && (c = p.value), !(c === l.value && f.value === m.value) && (l.value = c, P && s("update:modelValue", l.value), m.value = f.value, w());
|
|
123
|
-
}
|
|
124
|
-
function w() {
|
|
125
|
-
s("change", {
|
|
126
|
-
pageNumber: l.value,
|
|
127
|
-
pageSize: Number(f.value)
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
function y(a, P, c) {
|
|
131
|
-
return u("li", { class: a }, [u("a", {
|
|
132
|
-
href: "javascript:void(0)",
|
|
133
|
-
onClick: () => h(P)
|
|
134
|
-
}, c)]);
|
|
278
|
+
last: {
|
|
279
|
+
type: Boolean,
|
|
280
|
+
default: !0
|
|
281
|
+
},
|
|
282
|
+
/**
|
|
283
|
+
* Display all records
|
|
284
|
+
*
|
|
285
|
+
* will add `all` option in page size list
|
|
286
|
+
* and the page size will be 0
|
|
287
|
+
*/
|
|
288
|
+
displayAll: {
|
|
289
|
+
type: Boolean,
|
|
290
|
+
default: !1
|
|
291
|
+
},
|
|
292
|
+
/** Hide pagination when only have one page */
|
|
293
|
+
hideOnSinglePage: {
|
|
294
|
+
type: Boolean,
|
|
295
|
+
default: !1
|
|
135
296
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
);
|
|
158
|
-
const E = u("li", { class: "v-pagination__list" }, [
|
|
159
|
-
u("a", { href: "javascript:void(0)" }, [
|
|
160
|
-
u("span", g.value.pageLength),
|
|
161
|
-
u("select", i, d)
|
|
162
|
-
])
|
|
163
|
-
]);
|
|
164
|
-
a.push(E);
|
|
165
|
-
}
|
|
166
|
-
if (e.info && a.push(
|
|
167
|
-
u("li", { class: "v-pagination__info" }, [
|
|
168
|
-
u("a", { href: "javascript:void(0)" }, M.value)
|
|
169
|
-
])
|
|
170
|
-
), "default" in t) {
|
|
171
|
-
const i = {
|
|
172
|
-
pageNumber: l.value,
|
|
173
|
-
pageSize: f.value,
|
|
174
|
-
totalPage: p.value,
|
|
175
|
-
totalRow: o.value,
|
|
176
|
-
isFirst: A.value,
|
|
177
|
-
isLast: L.value
|
|
178
|
-
}, d = u("li", { class: "v-pagination__slot" }, [
|
|
179
|
-
u("a", t.default(i))
|
|
180
|
-
]);
|
|
181
|
-
a.push(d);
|
|
182
|
-
}
|
|
183
|
-
if (e.first) {
|
|
184
|
-
const i = ["v-pagination__first", { disabled: A.value }];
|
|
185
|
-
a.push(y(i, r, g.value.first));
|
|
186
|
-
}
|
|
187
|
-
const P = ["v-pagination__previous", { disabled: A.value }];
|
|
188
|
-
a.push(
|
|
189
|
-
y(P, l.value - 1, g.value.previous)
|
|
190
|
-
), e.pageNumber && a.push(
|
|
191
|
-
...C.value.map((i) => {
|
|
192
|
-
const d = { active: i === l.value };
|
|
193
|
-
return y(d, i, i);
|
|
194
|
-
})
|
|
195
|
-
);
|
|
196
|
-
const c = ["v-pagination__next", { disabled: L.value }];
|
|
197
|
-
if (a.push(
|
|
198
|
-
y(c, l.value + 1, g.value.next)
|
|
199
|
-
), e.last) {
|
|
200
|
-
const i = ["v-pagination__last", { disabled: L.value }];
|
|
201
|
-
a.push(
|
|
202
|
-
y(i, p.value, g.value.last)
|
|
203
|
-
);
|
|
204
|
-
}
|
|
205
|
-
return u("div", { class: j.value }, [u("ul", a)]);
|
|
206
|
-
};
|
|
297
|
+
},
|
|
298
|
+
emits: ["update:modelValue", "update:pageSize", "change"],
|
|
299
|
+
setup(e, {
|
|
300
|
+
emit: u,
|
|
301
|
+
slots: l
|
|
302
|
+
}) {
|
|
303
|
+
const {
|
|
304
|
+
containerClasses: f,
|
|
305
|
+
totalPage: i,
|
|
306
|
+
PageSizeOptions: r,
|
|
307
|
+
PageInformation: n,
|
|
308
|
+
PageSlot: v,
|
|
309
|
+
PageNumberItems: o,
|
|
310
|
+
FirstPageItem: c,
|
|
311
|
+
PreviousPageItem: m,
|
|
312
|
+
NextPageItem: g,
|
|
313
|
+
LastPageItem: N
|
|
314
|
+
} = ae(e, u, l);
|
|
315
|
+
return () => e.hideOnSinglePage && i.value <= 1 ? null : a("div", {
|
|
316
|
+
class: f.value
|
|
317
|
+
}, [a("ul", null, [a(r, null, null), a(n, null, null), a(v, null, null), a(c, null, null), a(m, null, null), a(o, null, null), a(g, null, null), a(N, null, null)])]);
|
|
207
318
|
}
|
|
208
319
|
});
|
|
209
|
-
|
|
210
|
-
if (Object.keys(
|
|
211
|
-
const { props:
|
|
212
|
-
language:
|
|
213
|
-
align:
|
|
214
|
-
info:
|
|
215
|
-
border:
|
|
216
|
-
pageNumber:
|
|
217
|
-
first:
|
|
218
|
-
last:
|
|
320
|
+
S.install = (e, u = {}) => {
|
|
321
|
+
if (Object.keys(u).length) {
|
|
322
|
+
const { props: l } = S, {
|
|
323
|
+
language: f,
|
|
324
|
+
align: i,
|
|
325
|
+
info: r,
|
|
326
|
+
border: n,
|
|
327
|
+
pageNumber: v,
|
|
328
|
+
first: o,
|
|
329
|
+
last: c,
|
|
219
330
|
pageSizeMenu: m
|
|
220
|
-
} =
|
|
221
|
-
|
|
331
|
+
} = u;
|
|
332
|
+
f && (l.language.default = f), i && (l.align.default = i), typeof r == "boolean" && (l.info.default = r), typeof n == "boolean" && (l.border.default = n), typeof v == "boolean" && (l.pageNumber.default = v), typeof o == "boolean" && (l.first.default = o), typeof c == "boolean" && (l.last.default = c), typeof m < "u" && (l.pageSizeMenu.default = m);
|
|
222
333
|
}
|
|
223
|
-
e.component(
|
|
334
|
+
e.component(S.name, S);
|
|
224
335
|
};
|
|
225
336
|
export {
|
|
226
|
-
|
|
227
|
-
|
|
337
|
+
S as PaginationBar,
|
|
338
|
+
S as default
|
|
228
339
|
};
|
package/dist/v-page.umd.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(){"use strict";try{if(typeof document<"u"){var i=document.createElement("style");i.appendChild(document.createTextNode(".v-pagination{display:flex;justify-content:flex-start;box-sizing:border-box}.v-pagination--right{justify-content:flex-end}.v-pagination--center{justify-content:center}.v-pagination.v-pagination--disabled a,.v-pagination.v-pagination--disabled select{color:#
|
|
2
|
-
(function(
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var i=document.createElement("style");i.appendChild(document.createTextNode(".v-pagination{display:flex;justify-content:flex-start;box-sizing:border-box}.v-pagination--right{justify-content:flex-end}.v-pagination--center{justify-content:center}.v-pagination.v-pagination--disabled a,.v-pagination.v-pagination--disabled select{color:#ddd!important}.v-pagination.v-pagination--disabled .v-pagination__item a{cursor:default!important}.v-pagination.v-pagination--disabled .v-pagination__item a:hover{background-color:transparent}.v-pagination.v-pagination--disabled.v-pagination--border ul{background-color:#fafafa}.v-pagination.v-pagination--circle .v-pagination__item a{border-radius:50rem;border:1px solid transparent}.v-pagination.v-pagination--circle .v-pagination__item a:hover{border:1px solid #f7f7f7}.v-pagination.v-pagination--circle .v-pagination__item.disabled a:hover{border:1px solid transparent}.v-pagination.v-pagination--circle .v-pagination__item.active a{border:1px solid #ddd!important;background-color:transparent!important;box-shadow:0 1px 3px #0000001a}.v-pagination ul{margin:0;padding:0;display:flex}.v-pagination ul li{list-style:none;display:flex}.v-pagination ul li a{padding:.3rem .6rem;text-decoration:none;line-height:1.3;font-size:14px;margin:0;outline:0;color:#333;border-radius:.5rem;display:inline-flex;align-items:center;cursor:default;transition:all .3s}.v-pagination ul li.v-pagination__list a,.v-pagination ul li.v-pagination__info a{color:#888}.v-pagination ul li.active a,.v-pagination ul li.disabled a{cursor:default!important}.v-pagination ul li.v-pagination__item a:hover{background-color:#f7f7f7;cursor:pointer}.v-pagination ul li.active a{background-color:#eee!important;color:#aaa}.v-pagination ul li.disabled a{color:#ddd!important}.v-pagination ul li.disabled a:hover{background-color:transparent}.v-pagination ul li select{width:auto!important;font-size:12px;padding:0;outline:0;margin:0 0 0 5px;border:1px solid #ccc;color:#333;border-radius:.3rem}.v-pagination.v-pagination--border ul{box-shadow:0 1px 2px #0000000d;border-radius:.5rem}.v-pagination.v-pagination--border ul li a{border:1px solid #DEE2E6;border-left:0;border-radius:0}.v-pagination.v-pagination--border ul li:first-child>a{border-bottom-left-radius:.5rem;border-top-left-radius:.5rem;border-left:1px solid #DEE2E6}.v-pagination.v-pagination--border ul li:last-child>a{border-top-right-radius:.5rem;border-bottom-right-radius:.5rem}.v-pagination.v-pagination--border ul li.active a{color:#aaa;background-color:#eee}")),document.head.appendChild(i)}}catch(a){console.error("vite-plugin-css-injected-by-js",a)}})();
|
|
2
|
+
(function(m,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(m=typeof globalThis<"u"?globalThis:m||self,e(m.VPage={},m.Vue))})(this,function(m,e){"use strict";const[w,h,O,T,F]=["cn","en","de","jp","pt"],z={[w]:{pageLength:"每页记录数",pageInfo:"第 #pageNumber#/#totalPage# 页(共#totalRow#条记录)",first:"首页",last:"尾页",all:"全部"},[h]:{pageLength:"Per page",pageInfo:"Page #pageNumber#/#totalPage# (total #totalRow# records)",first:"First",last:"Last",all:"All"},[O]:{pageLength:"Seitenlänge",pageInfo:"Aktuell #pageNumber#/#totalPage# (gesamt #totalRow# Aufzeichnungen)",first:"Zuerst",last:"Letzte",all:"Alle"},[T]:{pageLength:"ページごとの記録数",pageInfo:"現在の第 #pageNumber#/#totalPage# ページ(全部で #totalRow# 条の記録)",first:"トップページ",last:"尾のページ",all:"すべて"},[F]:{pageLength:"Resultados por página",pageInfo:"#pageNumber#/#totalPage# (total de #totalRow#)",first:"Início",last:"Fim",all:"Todos"}},s=1,M=5,S=10,E=[S,20,50,100],_=0,[X,Y,j]=["left","center","right"];function C(a,o,l){if(o<=l)return s;const c=Math.floor(l/2),u=o-l+1,r=a-c;return r<s?s:r>u?u:r}function G(a,o,l){const c=C(a,o,l);return Array.from({length:l}).map((u,r)=>c+r).filter(u=>u>=s&&u<=o)}function D(a=h){const o=String(a).toLowerCase();return z[Object.hasOwn(z,o)?o:h]}function x(a,o,l){const{pageSizeOptions:c,pageSizeMenu:u,totalRow:r}=e.toRefs(a),n=e.ref(0),b=e.ref(M),i=e.ref(a.pageSize??S),f=D(a.language),P=e.computed(()=>{if(!c.value)return[];const t=Array.isArray(u.value)&&u.value.length>0?u.value:E,d=new Set(t);return d.add(i.value),[...d].sort((p,A)=>p-A)}),g=e.computed(()=>i.value===_?s:Math.ceil(r.value/i.value)),v=e.computed(()=>G(n.value,g.value,b.value)),U=e.computed(()=>({"v-pagination":!0,"v-pagination--right":a.align==="right","v-pagination--center":a.align==="center","v-pagination--disabled":a.disabled,"v-pagination--border":a.border,"v-pagination--circle":!a.border&&a.circle})),I=e.computed(()=>n.value===s),L=e.computed(()=>n.value===g.value);e.watch(()=>a.modelValue,y),e.watch(()=>a.pageSize,R);function y(t=s){if(a.disabled||typeof t!="number")return;let d=t<s?s:t;t>g.value&&g.value>0&&(d=g.value),d!==n.value&&(n.value=d,o("update:modelValue",n.value),B())}function R(t){if(!(t<0)&&t!==i.value){if(i.value=t,o("update:pageSize",i.value),n.value===s)return B();y(s)}}function B(){o("change",{pageNumber:n.value,pageSize:Number(i.value),totalPage:g.value})}function Z(){if(!c.value)return null;const t=()=>P.value.map(p=>e.createVNode("option",{value:p,selected:i.value===p},[p])),d=()=>a.displayAll?e.createVNode("option",{value:_,selected:i.value===_},[f.all]):null;return e.createVNode("li",{class:"v-pagination__list"},[e.createVNode("a",{href:"javascript:void(0)"},[e.createVNode("span",null,[f.pageLength]),e.createVNode("select",{disabled:a.disabled,onChange:p=>R(Number(p.target.value))},[e.createVNode(t,null,null),e.createVNode(d,null,null)])])])}function k(){if(!a.info)return null;const t=f.pageInfo.replace("#pageNumber#",n.value).replace("#totalPage#",g.value).replace("#totalRow#",r.value);return e.createVNode("li",{class:"v-pagination__info"},[e.createVNode("a",{href:"javascript:void(0)"},[t])])}function q(){if(!Object.hasOwn(l,"default"))return null;const t={pageNumber:n.value,pageSize:i.value,totalPage:g.value,totalRow:r.value,isFirst:I.value,isLast:L.value};return e.createVNode("li",{class:"v-pagination__slot"},[e.createVNode("a",{href:"javascript:void(0)"},[l.default(t)])])}function V({classes:t,pageNumberValue:d,name:p,hasItem:A=!0}){return A?e.createVNode("li",{class:["v-pagination__item",...t]},[e.createVNode("a",{href:"javascript:void(0)",onClick:()=>y(d)},[p])]):null}function H(){return a.pageNumber?v.value.map(t=>e.createVNode(V,{classes:[{active:t===n.value}],pageNumberValue:t,name:t},null)):null}function J(){return e.createVNode(V,{classes:["v-pagination__first",{disabled:I.value}],pageNumberValue:s,name:f.first,hasItem:a.first},null)}function K(){return e.createVNode(V,{classes:["v-pagination__previous",{disabled:I.value}],pageNumberValue:n.value-1,name:"«"},null)}function Q(){return e.createVNode(V,{classes:["v-pagination__next",{disabled:L.value}],pageNumberValue:n.value+1,name:"»"},null)}function W(){return e.createVNode(V,{classes:["v-pagination__last",{disabled:L.value}],pageNumberValue:g.value,name:f.last,hasItem:a.last},null)}return e.onMounted(()=>y(a.modelValue||s)),{containerClasses:U,totalPage:g,current:n,pageNumbers:v,PageSizeOptions:Z,PageInformation:k,PageSlot:q,PageNumberItems:H,FirstPageItem:J,PreviousPageItem:K,NextPageItem:Q,LastPageItem:W}}const N=e.defineComponent({name:"PaginationBar",props:{modelValue:{type:Number,default:0},pageSize:{type:Number,default:S},totalRow:{type:Number,default:0},language:{type:String,default:h},align:{type:String,default:j},pageSizeMenu:{type:[Array],default:()=>E},pageSizeOptions:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},circle:{type:Boolean,default:!1},border:{type:Boolean,default:!1},info:{type:Boolean,default:!0},pageNumber:{type:Boolean,default:!0},first:{type:Boolean,default:!0},last:{type:Boolean,default:!0},displayAll:{type:Boolean,default:!1},hideOnSinglePage:{type:Boolean,default:!1}},emits:["update:modelValue","update:pageSize","change"],setup(a,{emit:o,slots:l}){const{containerClasses:c,totalPage:u,PageSizeOptions:r,PageInformation:n,PageSlot:b,PageNumberItems:i,FirstPageItem:f,PreviousPageItem:P,NextPageItem:g,LastPageItem:v}=x(a,o,l);return()=>a.hideOnSinglePage&&u.value<=1?null:e.createVNode("div",{class:c.value},[e.createVNode("ul",null,[e.createVNode(r,null,null),e.createVNode(n,null,null),e.createVNode(b,null,null),e.createVNode(f,null,null),e.createVNode(P,null,null),e.createVNode(i,null,null),e.createVNode(g,null,null),e.createVNode(v,null,null)])])}});N.install=(a,o={})=>{if(Object.keys(o).length){const{props:l}=N,{language:c,align:u,info:r,border:n,pageNumber:b,first:i,last:f,pageSizeMenu:P}=o;c&&(l.language.default=c),u&&(l.align.default=u),typeof r=="boolean"&&(l.info.default=r),typeof n=="boolean"&&(l.border.default=n),typeof b=="boolean"&&(l.pageNumber.default=b),typeof i=="boolean"&&(l.first.default=i),typeof f=="boolean"&&(l.last.default=f),typeof P<"u"&&(l.pageSizeMenu.default=P)}a.component(N.name,N)},m.PaginationBar=N,m.default=N,Object.defineProperties(m,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "v-page",
|
|
3
3
|
"description": "A simple pagination bar",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.2.0",
|
|
5
5
|
"author": "TerryZ <terry5@foxmail.com>",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
|
@@ -47,27 +47,26 @@
|
|
|
47
47
|
"pagination"
|
|
48
48
|
],
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"vue": "^3.
|
|
50
|
+
"vue": "^3.4.0"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"vue": "^3.
|
|
53
|
+
"vue": "^3.5.12"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@rushstack/eslint-patch": "^1.
|
|
57
|
-
"@vitejs/plugin-vue": "^
|
|
58
|
-
"@vitejs/plugin-vue-jsx": "^
|
|
56
|
+
"@rushstack/eslint-patch": "^1.10.4",
|
|
57
|
+
"@vitejs/plugin-vue": "^5.1.4",
|
|
58
|
+
"@vitejs/plugin-vue-jsx": "^4.0.1",
|
|
59
|
+
"@vitest/coverage-v8": "^2.1.3",
|
|
59
60
|
"@vue/eslint-config-standard": "^8.0.1",
|
|
60
|
-
"@vue/test-utils": "^2.4.
|
|
61
|
-
"bootstrap": "^5.3.
|
|
62
|
-
"c8": "^8.0.1",
|
|
61
|
+
"@vue/test-utils": "^2.4.6",
|
|
62
|
+
"bootstrap": "^5.3.3",
|
|
63
63
|
"eslint": "^8.49.0",
|
|
64
64
|
"eslint-plugin-vue": "^9.17.0",
|
|
65
|
-
"jsdom": "^
|
|
66
|
-
"sass": "^1.
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"vite": "^
|
|
70
|
-
"
|
|
71
|
-
"vitest": "^0.34.4"
|
|
65
|
+
"jsdom": "^25.0.1",
|
|
66
|
+
"sass": "^1.80.2",
|
|
67
|
+
"typescript": "^5.6.3",
|
|
68
|
+
"vite": "^5.4.9",
|
|
69
|
+
"vite-plugin-css-injected-by-js": "^3.5.2",
|
|
70
|
+
"vitest": "^2.1.3"
|
|
72
71
|
}
|
|
73
72
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
export declare interface PageInfo {
|
|
9
9
|
pageNumber: number
|
|
10
10
|
pageSize: number
|
|
11
|
+
totalPage: number
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
export declare interface PageSlotData {
|
|
@@ -31,21 +32,31 @@ declare interface Props {
|
|
|
31
32
|
* The number of total record
|
|
32
33
|
*/
|
|
33
34
|
totalRow: number
|
|
35
|
+
/**
|
|
36
|
+
* The number of page size
|
|
37
|
+
* @default 10
|
|
38
|
+
*/
|
|
39
|
+
pageSize?: number
|
|
34
40
|
/**
|
|
35
41
|
* v-page language
|
|
36
42
|
* @default `en`
|
|
37
43
|
*/
|
|
38
|
-
language?:
|
|
44
|
+
language?: 'cn' | 'en' | 'de' | 'jp' | 'pt'
|
|
39
45
|
/**
|
|
40
46
|
* Page size list
|
|
41
47
|
* @default [10, 20, 50, 100]
|
|
42
48
|
*/
|
|
43
|
-
pageSizeMenu?:
|
|
49
|
+
pageSizeMenu?: number[]
|
|
50
|
+
/**
|
|
51
|
+
* Whether to display page size list panel
|
|
52
|
+
* @default true
|
|
53
|
+
*/
|
|
54
|
+
pageSizeOptions?: boolean
|
|
44
55
|
/**
|
|
45
56
|
* Alignment direction
|
|
46
57
|
* @default `right`
|
|
47
58
|
*/
|
|
48
|
-
align?:
|
|
59
|
+
align?: 'left' | 'right' | 'center'
|
|
49
60
|
/**
|
|
50
61
|
* Disabled the pagination
|
|
51
62
|
* @default false
|
|
@@ -57,7 +68,12 @@ declare interface Props {
|
|
|
57
68
|
*/
|
|
58
69
|
border?: boolean
|
|
59
70
|
/**
|
|
60
|
-
*
|
|
71
|
+
* Round style page number button
|
|
72
|
+
* @default false
|
|
73
|
+
*/
|
|
74
|
+
circle?: boolean
|
|
75
|
+
/**
|
|
76
|
+
* Whether to display page information panel
|
|
61
77
|
* @default true
|
|
62
78
|
*/
|
|
63
79
|
info?: boolean
|
|
@@ -81,25 +97,24 @@ declare interface Props {
|
|
|
81
97
|
* @default false
|
|
82
98
|
*/
|
|
83
99
|
displayAll?: boolean
|
|
100
|
+
/**
|
|
101
|
+
* Hide pagination when only have one page
|
|
102
|
+
* @default false
|
|
103
|
+
*/
|
|
104
|
+
hideOnSinglePage?: boolean
|
|
84
105
|
}
|
|
85
106
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
// declare interface Methods extends MethodOptions {
|
|
94
|
-
// /** Go to the specified page */
|
|
95
|
-
// goPage: (pageNumber: number) => void
|
|
96
|
-
// /** Re-emit `change` event and output pagination states data */
|
|
97
|
-
// reload: () => void
|
|
98
|
-
// }
|
|
107
|
+
/** Update pageNumber value */
|
|
108
|
+
type EmitUpdateModelValue = (event: "update:modelValue", value: number) => void
|
|
109
|
+
/** Update pageSize value */
|
|
110
|
+
type EmitUpdatePageSize = (event: "update:pageSize", value: number) => void
|
|
111
|
+
/** The event respond pageNumber or pageSize change */
|
|
112
|
+
type EmitChange = (event: "change", value: PageInfo) => void
|
|
99
113
|
|
|
100
114
|
declare interface PaginationBar {
|
|
101
115
|
new (): {
|
|
102
|
-
$props: AllowedComponentProps & ComponentCustomProps & VNodeProps & Props
|
|
116
|
+
$props: AllowedComponentProps & ComponentCustomProps & VNodeProps & Props
|
|
117
|
+
$emit: EmitUpdateModelValue & EmitUpdatePageSize & EmitChange
|
|
103
118
|
$slots: {
|
|
104
119
|
default?: (defaultSlotData: PageSlotData) => VNode[]
|
|
105
120
|
}
|