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