v-page 3.3.0 → 3.5.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/dist/v-page.js CHANGED
@@ -1,41 +1,35 @@
1
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 { defineComponent as T, toRefs as w, ref as h, computed as b, watch as F, onMounted as C, provide as G, createVNode as n, inject as d, isVNode as k } from "vue";
3
- const g = 1, D = 5, L = 10, V = [L, 20, 50, 100], A = 0, [X, Y, x] = ["left", "center", "right"], s = Symbol("pagination"), [
4
- U,
5
- S,
6
- Z,
7
- H,
8
- J
9
- ] = ["cn", "en", "de", "jp", "pt"], B = {
10
- [U]: {
2
+ import { inject as f, createVNode as t, Fragment as B, isVNode as Z, defineComponent as H, toRefs as J, ref as b, computed as d, watch as w, onMounted as K, provide as q } from "vue";
3
+ const r = 1, Q = 5, _ = 10, F = [_, 20, 50, 100], A = 0, [pe, ve, W] = ["left", "center", "right"], p = /* @__PURE__ */ Symbol("pagination-internal"), C = /* @__PURE__ */ Symbol("pagination-options"), [X, v, Y, $, ee] = ["cn", "en", "de", "jp", "pt"], O = {
4
+ [X]: {
11
5
  pageLength: "每页记录数",
12
6
  pageInfo: "第 #pageNumber#/#totalPage# 页(共#totalRow#条记录)",
13
7
  first: "首页",
14
8
  last: "尾页",
15
9
  all: "全部"
16
10
  },
17
- [S]: {
11
+ [v]: {
18
12
  pageLength: "Per page",
19
13
  pageInfo: "Page #pageNumber#/#totalPage# (total #totalRow# records)",
20
14
  first: "First",
21
15
  last: "Last",
22
16
  all: "All"
23
17
  },
24
- [Z]: {
18
+ [Y]: {
25
19
  pageLength: "Seitenlänge",
26
20
  pageInfo: "Aktuell #pageNumber#/#totalPage# (gesamt #totalRow# Aufzeichnungen)",
27
21
  first: "Zuerst",
28
22
  last: "Letzte",
29
23
  all: "Alle"
30
24
  },
31
- [H]: {
25
+ [$]: {
32
26
  pageLength: "ページごとの記録数",
33
27
  pageInfo: "現在の第 #pageNumber#/#totalPage# ページ(全部で #totalRow# 条の記録)",
34
28
  first: "トップページ",
35
29
  last: "尾のページ",
36
30
  all: "すべて"
37
31
  },
38
- [J]: {
32
+ [ee]: {
39
33
  pageLength: "Resultados por página",
40
34
  pageInfo: "#pageNumber#/#totalPage# (total de #totalRow#)",
41
35
  first: "Início",
@@ -43,20 +37,163 @@ const g = 1, D = 5, L = 10, V = [L, 20, 50, 100], A = 0, [X, Y, x] = ["left", "c
43
37
  all: "Todos"
44
38
  }
45
39
  };
46
- function q(e, a, t) {
47
- if (a <= t) return g;
48
- const i = Math.floor(t / 2), u = a - t + 1, l = e - i;
49
- return l < g ? g : l > u ? u : l;
40
+ function ae(e, a, n) {
41
+ if (a <= n) return r;
42
+ const u = Math.floor(n / 2), l = a - n + 1, s = e - u;
43
+ return s < r ? r : s > l ? l : s;
50
44
  }
51
- function K(e, a, t) {
52
- const i = q(e, a, t);
53
- return Array.from({ length: t }).map((u, l) => i + l).filter((u) => u >= g && u <= a);
45
+ function te(e, a, n) {
46
+ const u = ae(e, a, n);
47
+ return Array.from({ length: n }).map((l, s) => u + s).filter((l) => l >= r && l <= a);
54
48
  }
55
- function Q(e = S) {
49
+ function ne(e = v) {
56
50
  const a = String(e).toLowerCase();
57
- return B[Object.hasOwn(B, a) ? a : S];
51
+ return O[Object.hasOwn(O, a) ? a : v];
58
52
  }
59
- const N = /* @__PURE__ */ T({
53
+ function T(e) {
54
+ return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !Z(e);
55
+ }
56
+ function L(e, {
57
+ slots: a
58
+ }) {
59
+ return t("a", {
60
+ href: "javascript:void(0)"
61
+ }, [a?.default?.()]);
62
+ }
63
+ function y({
64
+ classes: e,
65
+ pageNumberValue: a,
66
+ name: n
67
+ }) {
68
+ const {
69
+ changePageNumber: u
70
+ } = f(p);
71
+ return t("li", {
72
+ class: ["v-pagination__item", ...e]
73
+ }, [t(L, {
74
+ onClick: () => u(a)
75
+ }, T(n) ? n : {
76
+ default: () => [n]
77
+ })]);
78
+ }
79
+ function le() {
80
+ const {
81
+ lang: e,
82
+ sizeList: a,
83
+ pageSize: n,
84
+ disabled: u,
85
+ displayAll: l,
86
+ changePageSize: s
87
+ } = f(p), P = () => t(B, null, [a.value.map((i) => t("option", {
88
+ key: i,
89
+ value: i,
90
+ selected: n.value === i
91
+ }, [i]))]), g = () => l.value ? t("option", {
92
+ value: A,
93
+ selected: n.value === A
94
+ }, [e.value.all]) : null, N = (i) => {
95
+ const S = i.target;
96
+ s(Number(S.value));
97
+ };
98
+ return t("li", {
99
+ class: "v-pagination__list"
100
+ }, [t(L, null, {
101
+ default: () => [t("span", null, [e.value.pageLength]), t("select", {
102
+ disabled: u.value,
103
+ onChange: N
104
+ }, [t(P, null, null), t(g, null, null)])]
105
+ })]);
106
+ }
107
+ function ue() {
108
+ const {
109
+ lang: e,
110
+ current: a,
111
+ totalPage: n,
112
+ totalRow: u
113
+ } = f(p), l = e.value.pageInfo.replace("#pageNumber#", String(a.value)).replace("#totalPage#", String(n.value)).replace("#totalRow#", String(u.value));
114
+ return t("li", {
115
+ class: "v-pagination__info"
116
+ }, [t(L, null, T(l) ? l : {
117
+ default: () => [l]
118
+ })]);
119
+ }
120
+ function de(e, {
121
+ slots: a
122
+ }) {
123
+ return t("li", {
124
+ class: "v-pagination__slot"
125
+ }, [t(L, null, {
126
+ default: () => [a?.default?.()]
127
+ })]);
128
+ }
129
+ function ie() {
130
+ const {
131
+ pageNumbers: e,
132
+ current: a
133
+ } = f(p);
134
+ return t(B, null, [e.value.map((n) => t(y, {
135
+ key: n,
136
+ classes: [{
137
+ active: n === a.value
138
+ }],
139
+ pageNumberValue: n,
140
+ name: n
141
+ }, null))]);
142
+ }
143
+ function oe() {
144
+ const {
145
+ isFirst: e,
146
+ lang: a
147
+ } = f(p);
148
+ return t(y, {
149
+ classes: ["v-pagination__first", {
150
+ disabled: e.value
151
+ }],
152
+ pageNumberValue: r,
153
+ name: a.value.first
154
+ }, null);
155
+ }
156
+ function re() {
157
+ const {
158
+ isFirst: e,
159
+ current: a
160
+ } = f(p);
161
+ return t(y, {
162
+ classes: ["v-pagination__previous", {
163
+ disabled: e.value
164
+ }],
165
+ pageNumberValue: a.value - 1,
166
+ name: "«"
167
+ }, null);
168
+ }
169
+ function ge() {
170
+ const {
171
+ isLast: e,
172
+ current: a
173
+ } = f(p);
174
+ return t(y, {
175
+ classes: ["v-pagination__next", {
176
+ disabled: e.value
177
+ }],
178
+ pageNumberValue: a.value + 1,
179
+ name: "»"
180
+ }, null);
181
+ }
182
+ function se() {
183
+ const {
184
+ isLast: e,
185
+ totalPage: a,
186
+ lang: n
187
+ } = f(p);
188
+ return t(y, {
189
+ classes: ["v-pagination__last", {
190
+ disabled: e.value
191
+ }],
192
+ pageNumberValue: a.value,
193
+ name: n.value.last
194
+ }, null);
195
+ }
196
+ const V = /* @__PURE__ */ H({
60
197
  name: "PaginationBar",
61
198
  props: {
62
199
  modelValue: {
@@ -65,7 +202,7 @@ const N = /* @__PURE__ */ T({
65
202
  },
66
203
  pageSize: {
67
204
  type: Number,
68
- default: L
205
+ default: _
69
206
  },
70
207
  totalRow: {
71
208
  type: Number,
@@ -73,7 +210,7 @@ const N = /* @__PURE__ */ T({
73
210
  },
74
211
  language: {
75
212
  type: String,
76
- default: S
213
+ default: v
77
214
  },
78
215
  /**
79
216
  * Pagination alignment direction
@@ -81,12 +218,12 @@ const N = /* @__PURE__ */ T({
81
218
  */
82
219
  align: {
83
220
  type: String,
84
- default: x
221
+ default: W
85
222
  },
86
223
  /** Page size list */
87
224
  pageSizeMenu: {
88
225
  type: [Array],
89
- default: () => V
226
+ default: () => F
90
227
  },
91
228
  disabled: {
92
229
  type: Boolean,
@@ -117,243 +254,100 @@ const N = /* @__PURE__ */ T({
117
254
  default: !1
118
255
  }
119
256
  },
120
- emits: ["update:modelValue", "update:pageSize", "change"],
257
+ emits: {
258
+ "update:modelValue": (e) => typeof e == "number",
259
+ "update:pageSize": (e) => typeof e == "number",
260
+ change: (e) => typeof e < "u"
261
+ },
262
+ slots: Object,
121
263
  setup(e, {
122
264
  emit: a,
123
- slots: t
265
+ slots: n
124
266
  }) {
125
267
  const {
126
- pageSizeMenu: i,
127
- totalRow: u
128
- } = w(e), l = h(0), v = h(D), o = h(e.pageSize ?? L), f = b(() => {
129
- const r = Array.from(Array.isArray(i.value) && i.value.length > 0 ? i.value : V);
130
- return o.value !== 0 && !r.includes(o.value) && r.push(o.value), r.sort((p, M) => p - M);
131
- }), c = b(() => o.value === A ? g : Math.ceil(u.value / o.value)), P = b(() => K(l.value, c.value, v.value)), j = b(() => ({
268
+ pageSizeMenu: u,
269
+ totalRow: l,
270
+ displayAll: s,
271
+ disabled: P
272
+ } = J(e), g = b(0), N = b(Q), i = b(e.pageSize ?? _), S = f(C, b("")), j = () => e.language !== v ? e.language : S.value ? S.value : v, k = d(() => ne(j())), G = d(() => {
273
+ const o = Array.from(Array.isArray(u.value) && u.value.length > 0 ? u.value : F);
274
+ return i.value !== 0 && !o.includes(i.value) && o.push(i.value), o.sort((m, U) => m - U);
275
+ }), c = d(() => i.value === A ? r : Math.ceil(l.value / i.value)), M = d(() => te(g.value, c.value, N.value)), D = d(() => ({
132
276
  "v-pagination": !0,
133
277
  "v-pagination--right": e.align === "right",
134
278
  "v-pagination--center": e.align === "center",
135
- "v-pagination--disabled": e.disabled,
279
+ "v-pagination--disabled": P.value,
136
280
  "v-pagination--border": e.border,
137
281
  "v-pagination--circle": !e.border && e.circle
138
- })), z = b(() => l.value === g), E = b(() => l.value === c.value);
139
- F(() => e.modelValue, y), F(() => e.pageSize, R);
140
- function y(r = g) {
141
- if (e.disabled || typeof r != "number") return;
142
- let p = r < g ? g : r;
143
- r > c.value && c.value > 0 && (p = c.value), p !== l.value && (l.value = p, a("update:modelValue", l.value), I());
282
+ })), E = d(() => g.value === r), I = d(() => g.value === c.value);
283
+ w(() => e.modelValue, h), w(() => e.pageSize, R);
284
+ function h(o = r) {
285
+ if (P.value || typeof o != "number") return;
286
+ let m = o < r ? r : o;
287
+ o > c.value && c.value > 0 && (m = c.value), m !== g.value && (g.value = m, a("update:modelValue", g.value), z());
144
288
  }
145
- function R(r) {
146
- if (typeof r == "number" && !(r < 0) && r !== o.value) {
147
- if (o.value = r, a("update:pageSize", o.value), l.value === g)
148
- return I();
149
- y(g);
289
+ function R(o) {
290
+ if (typeof o == "number" && !(o < 0) && o !== i.value) {
291
+ if (i.value = o, a("update:pageSize", i.value), g.value === r)
292
+ return z();
293
+ h(r);
150
294
  }
151
295
  }
152
- function I() {
296
+ function z() {
153
297
  a("change", {
154
- pageNumber: l.value,
155
- pageSize: Number(o.value),
298
+ pageNumber: g.value,
299
+ pageSize: Number(i.value),
156
300
  totalPage: c.value
157
301
  });
158
302
  }
159
- return C(() => y(e.modelValue || g)), G(s, {
160
- lang: Q(e.language),
161
- pageSize: o,
162
- sizeList: f,
163
- pageNumbers: P,
164
- isFirst: z,
165
- isLast: E,
166
- current: l,
303
+ function x() {
304
+ return n.default ? t("ul", null, [n.default({
305
+ pageNumber: g.value,
306
+ pageSize: i.value,
307
+ totalPage: c.value,
308
+ totalRow: l.value,
309
+ isFirst: E.value,
310
+ isLast: I.value
311
+ })]) : t("ul", null, [t(le, null, null), t(ue, null, null), t(oe, null, null), t(re, null, null), t(ie, null, null), t(ge, null, null), t(se, null, null)]);
312
+ }
313
+ return K(() => h(e.modelValue || r)), q(p, {
314
+ lang: k,
315
+ pageSize: i,
316
+ sizeList: G,
317
+ pageNumbers: M,
318
+ isFirst: E,
319
+ isLast: I,
320
+ current: g,
167
321
  totalPage: c,
168
- changePageNumber: y,
322
+ changePageNumber: h,
169
323
  changePageSize: R,
170
- ...w(e)
171
- }), () => {
172
- var p;
173
- if (e.hideOnSinglePage && c.value <= 1) return null;
174
- const r = {
175
- pageNumber: l.value,
176
- pageSize: o.value,
177
- totalPage: c.value,
178
- totalRow: u.value,
179
- isFirst: z.value,
180
- isLast: E.value
181
- };
182
- return n("div", {
183
- class: j.value
184
- }, [n("ul", null, [(p = t == null ? void 0 : t.default) == null ? void 0 : p.call(t, r)])]);
185
- };
324
+ totalRow: l,
325
+ displayAll: s,
326
+ disabled: P
327
+ }), () => e.hideOnSinglePage && c.value <= 1 ? null : t("div", {
328
+ class: D.value
329
+ }, [t(x, null, null)]);
186
330
  }
187
- });
188
- function O(e) {
189
- return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !k(e);
190
- }
191
- function _(e, {
192
- slots: a
193
- }) {
194
- var t;
195
- return n("a", {
196
- href: "javascript:void(0)"
197
- }, [(t = a == null ? void 0 : a.default) == null ? void 0 : t.call(a)]);
198
- }
199
- function m({
200
- classes: e,
201
- pageNumberValue: a,
202
- name: t
203
- }) {
204
- const {
205
- changePageNumber: i
206
- } = d(s);
207
- return n("li", {
208
- class: ["v-pagination__item", ...e]
209
- }, [n(_, {
210
- onClick: () => i(a)
211
- }, O(t) ? t : {
212
- default: () => [t]
213
- })]);
214
- }
215
- function $() {
216
- const {
217
- lang: e,
218
- sizeList: a,
219
- pageSize: t,
220
- disabled: i,
221
- displayAll: u,
222
- changePageSize: l
223
- } = d(s), v = () => a.value.map((f) => n("option", {
224
- key: f,
225
- value: f,
226
- selected: t.value === f
227
- }, [f])), o = () => u.value ? n("option", {
228
- value: A,
229
- selected: t.value === A
230
- }, [e.all]) : null;
231
- return n("li", {
232
- class: "v-pagination__list"
233
- }, [n(_, null, {
234
- default: () => [n("span", null, [e.pageLength]), n("select", {
235
- disabled: i.value,
236
- onChange: (f) => l(Number(f.target.value))
237
- }, [n(v, null, null), n(o, null, null)])]
238
- })]);
239
- }
240
- function ee() {
241
- const {
242
- lang: e,
243
- current: a,
244
- totalPage: t,
245
- totalRow: i
246
- } = d(s), u = e.pageInfo.replace("#pageNumber#", a.value).replace("#totalPage#", t.value).replace("#totalRow#", i.value);
247
- return n("li", {
248
- class: "v-pagination__info"
249
- }, [n(_, null, O(u) ? u : {
250
- default: () => [u]
251
- })]);
252
- }
253
- function ae(e, {
254
- slots: a
255
- }) {
256
- return n("li", {
257
- class: "v-pagination__slot"
258
- }, [n(_, null, {
259
- default: () => {
260
- var t;
261
- return [(t = a == null ? void 0 : a.default) == null ? void 0 : t.call(a)];
331
+ }), ce = () => {
332
+ const e = b(v), a = {
333
+ install(u, l) {
334
+ u.provide(C, e), l?.language && n(l.language), l?.register && u.component(V.name, V);
262
335
  }
263
- })]);
264
- }
265
- function te() {
266
- const {
267
- pageNumbers: e,
268
- current: a
269
- } = d(s);
270
- return e.value.map((t) => n(m, {
271
- key: t,
272
- classes: [{
273
- active: t === a.value
274
- }],
275
- pageNumberValue: t,
276
- name: t
277
- }, null));
278
- }
279
- function ne() {
280
- const {
281
- isFirst: e,
282
- lang: a
283
- } = d(s);
284
- return n(m, {
285
- classes: ["v-pagination__first", {
286
- disabled: e.value
287
- }],
288
- pageNumberValue: g,
289
- name: a.first
290
- }, null);
291
- }
292
- function le() {
293
- const {
294
- isFirst: e,
295
- current: a
296
- } = d(s);
297
- return n(m, {
298
- classes: ["v-pagination__previous", {
299
- disabled: e.value
300
- }],
301
- pageNumberValue: a.value - 1,
302
- name: "«"
303
- }, null);
304
- }
305
- function ue() {
306
- const {
307
- isLast: e,
308
- current: a
309
- } = d(s);
310
- return n(m, {
311
- classes: ["v-pagination__next", {
312
- disabled: e.value
313
- }],
314
- pageNumberValue: a.value + 1,
315
- name: "»"
316
- }, null);
317
- }
318
- function ie() {
319
- const {
320
- isLast: e,
321
- totalPage: a,
322
- lang: t
323
- } = d(s);
324
- return n(m, {
325
- classes: ["v-pagination__last", {
326
- disabled: e.value
327
- }],
328
- pageNumberValue: a.value,
329
- name: t.last
330
- }, null);
331
- }
332
- N.install = (e, a = {}) => {
333
- if (Object.keys(a).length) {
334
- const { props: t } = N, {
335
- language: i,
336
- align: u,
337
- info: l,
338
- border: v,
339
- pageNumber: o,
340
- first: f,
341
- last: c,
342
- pageSizeMenu: P
343
- } = a;
344
- i && (t.language.default = i), u && (t.align.default = u), typeof l == "boolean" && (t.info.default = l), typeof v == "boolean" && (t.border.default = v), typeof o == "boolean" && (t.pageNumber.default = o), typeof f == "boolean" && (t.first.default = f), typeof c == "boolean" && (t.last.default = c), typeof P < "u" && (t.pageSizeMenu.default = P);
345
- }
346
- e.component(N.name, N);
347
- };
336
+ }, n = (u) => {
337
+ e.value = u || v;
338
+ };
339
+ return { PaginationPlugin: a, setLanguage: n };
340
+ }, { PaginationPlugin: Pe, setLanguage: me } = ce();
348
341
  export {
349
- N as PaginationBar,
350
- ne as PaginationFirstPage,
351
- ee as PaginationInfo,
352
- ie as PaginationLastPage,
353
- ue as PaginationNextPage,
354
- te as PaginationPageNumbers,
355
- $ as PaginationPageSizeOptions,
356
- ae as PaginationPanel,
357
- le as PaginationPreviousPage,
358
- N as default
342
+ V as PaginationBar,
343
+ oe as PaginationFirstPage,
344
+ ue as PaginationInfo,
345
+ se as PaginationLastPage,
346
+ ge as PaginationNextPage,
347
+ ie as PaginationPageNumbers,
348
+ le as PaginationPageSizes,
349
+ de as PaginationPanel,
350
+ re as PaginationPreviousPage,
351
+ Pe as default,
352
+ me as setLanguage
359
353
  };