tttb 0.0.20

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.

Potentially problematic release.


This version of tttb might be problematic. Click here for more details.

Files changed (68) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +38 -0
  3. package/dist/es/_virtual/_plugin-vue_export-helper.js +9 -0
  4. package/dist/es/components.js +32 -0
  5. package/dist/es/directives.js +14 -0
  6. package/dist/es/hooks.js +4 -0
  7. package/dist/es/index.js +80 -0
  8. package/dist/es/node_modules/@floating-ui/core/dist/floating-ui.core.js +389 -0
  9. package/dist/es/node_modules/@floating-ui/dom/dist/floating-ui.dom.js +399 -0
  10. package/dist/es/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js +136 -0
  11. package/dist/es/node_modules/@floating-ui/utils/dist/floating-ui.utils.js +129 -0
  12. package/dist/es/node_modules/@fortawesome/fontawesome-svg-core/index.js +3074 -0
  13. package/dist/es/node_modules/@fortawesome/free-brands-svg-icons/index.js +3155 -0
  14. package/dist/es/node_modules/@fortawesome/free-regular-svg-icons/index.js +1227 -0
  15. package/dist/es/node_modules/@fortawesome/free-solid-svg-icons/index.js +9601 -0
  16. package/dist/es/node_modules/@fortawesome/vue-fontawesome/index.es.js +487 -0
  17. package/dist/es/src/components/Button/index.js +6 -0
  18. package/dist/es/src/components/Button/index.vue.js +73 -0
  19. package/dist/es/src/components/Checkbox/index.js +6 -0
  20. package/dist/es/src/components/Checkbox/index.vue.js +60 -0
  21. package/dist/es/src/components/Dialog/DialogItem.vue.js +73 -0
  22. package/dist/es/src/components/Dialog/DialogPrompt.vue.js +56 -0
  23. package/dist/es/src/components/Dialog/index.js +6 -0
  24. package/dist/es/src/components/Dialog/index.vue.js +84 -0
  25. package/dist/es/src/components/Icon/index.js +6 -0
  26. package/dist/es/src/components/Icon/index.vue.js +21 -0
  27. package/dist/es/src/components/Icon/props.js +31 -0
  28. package/dist/es/src/components/Loading/index.js +6 -0
  29. package/dist/es/src/components/Loading/index.vue.js +45 -0
  30. package/dist/es/src/components/Message/index.js +6 -0
  31. package/dist/es/src/components/Message/index.vue.js +41 -0
  32. package/dist/es/src/components/Modal/index.js +6 -0
  33. package/dist/es/src/components/Modal/index.vue.js +67 -0
  34. package/dist/es/src/components/Nav/index.js +6 -0
  35. package/dist/es/src/components/Nav/index.vue.js +83 -0
  36. package/dist/es/src/components/Pagination/index.js +6 -0
  37. package/dist/es/src/components/Pagination/index.vue.js +151 -0
  38. package/dist/es/src/components/Switch/index.js +6 -0
  39. package/dist/es/src/components/Switch/index.vue.js +80 -0
  40. package/dist/es/src/components/Table/index.js +6 -0
  41. package/dist/es/src/components/Table/index.vue.js +42 -0
  42. package/dist/es/src/components/Timer/index.js +6 -0
  43. package/dist/es/src/components/Timer/index.vue.js +30 -0
  44. package/dist/es/src/components/Tooltip/index.js +6 -0
  45. package/dist/es/src/components/Tooltip/index.vue.js +123 -0
  46. package/dist/es/src/components/Tooltip/props.js +47 -0
  47. package/dist/es/src/components/Warn/index.js +6 -0
  48. package/dist/es/src/components/Warn/index.vue.js +23 -0
  49. package/dist/es/src/components/Watermark/index.js +6 -0
  50. package/dist/es/src/components/Watermark/index.vue.js +69 -0
  51. package/dist/es/src/components/Watermark/useWatermarkBg.js +11 -0
  52. package/dist/es/src/directives/vDelayIn.js +86 -0
  53. package/dist/es/src/directives/vLazy.js +63 -0
  54. package/dist/es/src/directives/vLoading.js +39 -0
  55. package/dist/es/src/directives/vSlideIn.js +39 -0
  56. package/dist/es/src/directives/vTextJump.js +36 -0
  57. package/dist/es/src/directives/vTooltip.js +41 -0
  58. package/dist/es/src/helpers.js +7 -0
  59. package/dist/es/src/hooks/useScrollControl.js +83 -0
  60. package/dist/es/src/utils/dialog.js +34 -0
  61. package/dist/es/src/utils/localStorage.js +25 -0
  62. package/dist/es/src/utils/msg.js +27 -0
  63. package/dist/es/src/utils/tools.js +70 -0
  64. package/dist/es/tttb.css +1 -0
  65. package/dist/es/utils.js +22 -0
  66. package/dist/umd/tb-ui.css +1 -0
  67. package/dist/umd/tb-ui.umd.cjs +563 -0
  68. package/package.json +61 -0
@@ -0,0 +1,56 @@
1
+ import { createElementBlock as s, openBlock as c, withDirectives as p, Fragment as y, renderList as x, normalizeClass as b, createElementVNode as o, vModelDynamic as k, createVNode as u, unref as m, vShow as v, toDisplayString as d, createTextVNode as D } from "vue";
2
+ import h from "../Icon/index.js";
3
+ /* empty css */
4
+ import I from "../../../_virtual/_plugin-vue_export-helper.js";
5
+ const V = { class: "input-inner" }, A = ["type", "onUpdate:modelValue", "name", "placeholder", "onInput"], C = { class: "label" }, N = { class: "msg" }, w = { class: "total-err" }, B = {
6
+ __name: "DialogPrompt",
7
+ props: {
8
+ content: Array,
9
+ options: Object
10
+ },
11
+ emits: ["update:totalErr"],
12
+ setup(a, { expose: _, emit: f }) {
13
+ const l = a, i = f, E = (t) => {
14
+ t.msg = t.validate?.(t.value), i("update:totalErr", "");
15
+ };
16
+ return _({ validateAll: () => {
17
+ if (l.content.forEach((e) => e.msg = e.validate(e.value)), l.content.some((e) => e.msg)) return !1;
18
+ const n = l.options.validateAll?.(...l.content);
19
+ return i("update:totalErr", n), !n;
20
+ } }), (t, n) => (c(), s("form", null, [
21
+ (c(!0), s(y, null, x(a.content, (e, g) => (c(), s("label", {
22
+ key: g,
23
+ class: b(["input-item", { error: e.msg }])
24
+ }, [
25
+ o("div", V, [
26
+ p(o("input", {
27
+ type: e.type,
28
+ "onUpdate:modelValue": (r) => e.value = r,
29
+ name: e.label,
30
+ placeholder: e.placeholder,
31
+ onInput: (r) => E(e)
32
+ }, null, 40, A), [
33
+ [k, e.value]
34
+ ]),
35
+ p(u(m(h), {
36
+ icon: "close",
37
+ onClick: (r) => e.value = ""
38
+ }, null, 8, ["onClick"]), [
39
+ [v, e.value !== ""]
40
+ ])
41
+ ]),
42
+ o("span", C, d(e.label), 1),
43
+ o("span", N, d(e.msg), 1)
44
+ ], 2))), 128)),
45
+ p(o("p", w, [
46
+ u(m(h), { icon: "circle-exclamation" }),
47
+ D(" " + d(a.options.totalErr), 1)
48
+ ], 512), [
49
+ [v, a.options.totalErr]
50
+ ])
51
+ ]));
52
+ }
53
+ }, z = /* @__PURE__ */ I(B, [["__scopeId", "data-v-dae7d3f6"]]);
54
+ export {
55
+ z as default
56
+ };
@@ -0,0 +1,6 @@
1
+ import o from "./index.vue.js";
2
+ import { withInstall as t } from "../../helpers.js";
3
+ const l = t(o);
4
+ export {
5
+ l as default
6
+ };
@@ -0,0 +1,84 @@
1
+ import { ref as f, computed as p, createBlock as v, openBlock as n, Transition as E, withCtx as s, withDirectives as D, createVNode as _, unref as S, mergeProps as I, withModifiers as O, TransitionGroup as R, createElementBlock as B, Fragment as P, renderList as A, vShow as L } from "vue";
2
+ import M from "../Modal/index.js";
3
+ import N from "./DialogItem.vue.js";
4
+ import { getId as $ } from "../../utils/tools.js";
5
+ /* empty css */
6
+ import j from "../../../_virtual/_plugin-vue_export-helper.js";
7
+ const i = 300, F = /* @__PURE__ */ Object.assign({ name: "Dialog" }, {
8
+ __name: "index",
9
+ emits: ["destroy"],
10
+ setup(G, { expose: h, emit: g }) {
11
+ const c = g, l = f([]), u = f([]), r = p(() => l.value.at(-1)), y = p(() => {
12
+ const e = u.value?.at(-1)?.contentRef;
13
+ return e?.$el || e;
14
+ });
15
+ let a;
16
+ const w = (e) => (clearTimeout(a), new Promise((t) => {
17
+ const o = b(e, t);
18
+ o.type === "prompt" && k(o), l.value.push(o);
19
+ })), x = (e) => {
20
+ r.value.resolve(e), d();
21
+ }, m = () => {
22
+ r.value.resolve(!1), d();
23
+ }, C = () => {
24
+ r.value && !r.value.modal && m();
25
+ }, d = () => {
26
+ l.value.pop(), l.value.length === 0 && (a = setTimeout(() => c("destroy"), i));
27
+ }, T = () => {
28
+ l.value.forEach((e) => e.resolve(!1)), l.value = [], a = setTimeout(() => c("destroy"), i);
29
+ }, b = (e, t) => ({
30
+ title: "",
31
+ content: "",
32
+ textColor: "",
33
+ tip: "",
34
+ type: "",
35
+ // alert, confirm, prompt
36
+ confirmText: e.type === "alert" ? "我知道了" : "确定",
37
+ confirmColor: "",
38
+ cancelText: "取消",
39
+ modal: !1,
40
+ id: $(),
41
+ ...e,
42
+ resolve: t
43
+ }), k = (e) => {
44
+ e.content.forEach((t) => {
45
+ t.value = t.value ?? "", t.validate = t.validate ?? ((o) => o === "" ? `请输入${t.label}` : "");
46
+ }), e.totalErr = "";
47
+ };
48
+ return h({ open: w, destroyAll: T }), (e, t) => (n(), v(E, { name: "modal" }, {
49
+ default: s(() => [
50
+ D(_(S(M), I({
51
+ class: "dialog-container",
52
+ duration: i,
53
+ disableScroll: !0,
54
+ allowScrollEl: y.value,
55
+ onClick: O(C, ["self"])
56
+ }, r.value?.modal ? { blur: 2 } : { bg: "rgba(0, 0, 0, 0.3)" }), {
57
+ default: s(() => [
58
+ _(R, { name: "area" }, {
59
+ default: s(() => [
60
+ (n(!0), B(P, null, A(l.value, (o) => (n(), v(N, {
61
+ key: o.id,
62
+ item: o,
63
+ ref_for: !0,
64
+ ref_key: "itemRefs",
65
+ ref: u,
66
+ onConfirm: x,
67
+ onCancel: m
68
+ }, null, 8, ["item"]))), 128))
69
+ ]),
70
+ _: 1
71
+ })
72
+ ]),
73
+ _: 1
74
+ }, 16, ["allowScrollEl"]), [
75
+ [L, r.value]
76
+ ])
77
+ ]),
78
+ _: 1
79
+ }));
80
+ }
81
+ }), K = /* @__PURE__ */ j(F, [["__scopeId", "data-v-4a59b93e"]]);
82
+ export {
83
+ K as default
84
+ };
@@ -0,0 +1,6 @@
1
+ import o from "./index.vue.js";
2
+ import { withInstall as t } from "../../helpers.js";
3
+ const a = t(o);
4
+ export {
5
+ a as default
6
+ };
@@ -0,0 +1,21 @@
1
+ import { createElementBlock as r, openBlock as e, createVNode as a, unref as s, normalizeProps as n, guardReactiveProps as t } from "vue";
2
+ import { FontAwesomeIcon as i } from "../../../node_modules/@fortawesome/vue-fontawesome/index.es.js";
3
+ import m from "./props.js";
4
+ import { library as p } from "../../../node_modules/@fortawesome/fontawesome-svg-core/index.js";
5
+ import { fas as c } from "../../../node_modules/@fortawesome/free-solid-svg-icons/index.js";
6
+ import { far as f } from "../../../node_modules/@fortawesome/free-regular-svg-icons/index.js";
7
+ import { fab as l } from "../../../node_modules/@fortawesome/free-brands-svg-icons/index.js";
8
+ const _ = { class: "icon-container" }, y = /* @__PURE__ */ Object.assign({
9
+ name: "Icon"
10
+ }, {
11
+ __name: "index",
12
+ props: m,
13
+ setup(d) {
14
+ return p.add(c, f, l), (o, u) => (e(), r("i", _, [
15
+ a(s(i), n(t(o.$props)), null, 16)
16
+ ]));
17
+ }
18
+ });
19
+ export {
20
+ y as default
21
+ };
@@ -0,0 +1,31 @@
1
+ const e = {
2
+ // 图标
3
+ icon: {
4
+ type: String,
5
+ required: !0
6
+ },
7
+ // 大小
8
+ size: {
9
+ type: String
10
+ },
11
+ // 旋转
12
+ rotation: {
13
+ type: [Number, String]
14
+ },
15
+ // 翻转
16
+ flip: {
17
+ type: [Number, String]
18
+ },
19
+ // 下面是动画效果相关的属性
20
+ beat: Boolean,
21
+ beatFade: Boolean,
22
+ bounce: Boolean,
23
+ fade: Boolean,
24
+ shake: Boolean,
25
+ spin: Boolean,
26
+ spinReverse: Boolean,
27
+ spinPulse: Boolean
28
+ };
29
+ export {
30
+ e as default
31
+ };
@@ -0,0 +1,6 @@
1
+ import o from "./index.vue.js";
2
+ import { withInstall as t } from "../../helpers.js";
3
+ const r = t(o);
4
+ export {
5
+ r as default
6
+ };
@@ -0,0 +1,45 @@
1
+ import { createElementBlock as n, openBlock as o, normalizeStyle as a, createElementVNode as r, createCommentVNode as i } from "vue";
2
+ /* empty css */
3
+ import s from "../../../_virtual/_plugin-vue_export-helper.js";
4
+ const l = ["innerHTML"], c = /* @__PURE__ */ Object.assign({
5
+ name: "Loading"
6
+ }, {
7
+ __name: "index",
8
+ props: {
9
+ size: {
10
+ type: Number,
11
+ default: 42
12
+ },
13
+ text: {
14
+ type: String,
15
+ default: ""
16
+ }
17
+ },
18
+ setup(e) {
19
+ return (d, t) => (o(), n("div", {
20
+ class: "loading-container",
21
+ style: a({ "--size": e.size + "px" })
22
+ }, [
23
+ t[0] || (t[0] = r("svg", {
24
+ viewBox: "0 0 50 50",
25
+ class: "loading-svg"
26
+ }, [
27
+ r("circle", {
28
+ class: "path",
29
+ cx: "25",
30
+ cy: "25",
31
+ r: "20",
32
+ fill: "none",
33
+ stroke: "currentColor"
34
+ })
35
+ ], -1)),
36
+ e.text ? (o(), n("p", {
37
+ key: 0,
38
+ innerHTML: e.text
39
+ }, null, 8, l)) : i("", !0)
40
+ ], 4));
41
+ }
42
+ }), x = /* @__PURE__ */ s(c, [["__scopeId", "data-v-557da3ef"]]);
43
+ export {
44
+ x as default
45
+ };
@@ -0,0 +1,6 @@
1
+ import s from "./index.vue.js";
2
+ import { withInstall as t } from "../../helpers.js";
3
+ const a = t(s);
4
+ export {
5
+ a as default
6
+ };
@@ -0,0 +1,41 @@
1
+ import { ref as p, createBlock as c, openBlock as n, TransitionGroup as _, withCtx as f, createElementBlock as o, Fragment as v, renderList as y, normalizeClass as g, resolveDynamicComponent as T } from "vue";
2
+ import { getId as h } from "../../utils/tools.js";
3
+ /* empty css */
4
+ import x from "../../../_virtual/_plugin-vue_export-helper.js";
5
+ const k = ["innerHTML"], M = 3e3, L = 3, b = /* @__PURE__ */ Object.assign({
6
+ name: "Message"
7
+ }, {
8
+ __name: "index",
9
+ emits: ["destroy"],
10
+ setup(B, { expose: m, emit: l }) {
11
+ const u = l, t = p([]);
12
+ let s;
13
+ const r = () => {
14
+ clearTimeout(t.value[0]?.timer), t.value.shift(), !t.value.length && (s = setTimeout(() => u("destroy"), 500));
15
+ };
16
+ return m({ add: (a, i) => {
17
+ clearTimeout(s), t.value.length >= L && r();
18
+ const e = h(), d = setTimeout(() => r(), M);
19
+ t.value.push({ id: e, content: a, type: i, timer: d });
20
+ } }), (a, i) => (n(), c(_, {
21
+ tag: "div",
22
+ class: "message-container"
23
+ }, {
24
+ default: f(() => [
25
+ (n(!0), o(v, null, y(t.value, (e) => (n(), o("div", {
26
+ key: e.id,
27
+ class: g(["item", [e.type]])
28
+ }, [
29
+ typeof e.content == "string" ? (n(), o("span", {
30
+ key: 0,
31
+ innerHTML: e.content
32
+ }, null, 8, k)) : (n(), c(T(e.content), { key: 1 }))
33
+ ], 2))), 128))
34
+ ]),
35
+ _: 1
36
+ }));
37
+ }
38
+ }), z = /* @__PURE__ */ x(b, [["__scopeId", "data-v-b11505b8"]]);
39
+ export {
40
+ z as default
41
+ };
@@ -0,0 +1,6 @@
1
+ import o from "./index.vue.js";
2
+ import { withInstall as t } from "../../helpers.js";
3
+ const r = t(o);
4
+ export {
5
+ r as default
6
+ };
@@ -0,0 +1,67 @@
1
+ import { toRefs as r, watchEffect as n, createBlock as i, openBlock as d, Transition as c, withCtx as s, withDirectives as u, createElementVNode as m, normalizeStyle as b, renderSlot as f, vShow as p } from "vue";
2
+ import { useScrollControl as S } from "../../hooks/useScrollControl.js";
3
+ /* empty css */
4
+ import y from "../../../_virtual/_plugin-vue_export-helper.js";
5
+ const x = /* @__PURE__ */ Object.assign({
6
+ name: "Modal"
7
+ }, {
8
+ __name: "index",
9
+ props: {
10
+ visible: {
11
+ type: Boolean,
12
+ default: !0
13
+ },
14
+ bg: {
15
+ type: String
16
+ },
17
+ blur: {
18
+ type: Number
19
+ },
20
+ zIndex: {
21
+ type: Number
22
+ },
23
+ duration: {
24
+ type: Number,
25
+ default: 300
26
+ },
27
+ disableScroll: {
28
+ type: Boolean,
29
+ default: !1
30
+ },
31
+ allowScrollEl: {
32
+ type: [Object, HTMLElement, Array],
33
+ default: null
34
+ }
35
+ },
36
+ setup(e) {
37
+ const l = e, { disableScroll: t, enableScroll: a } = S({
38
+ allowedElements: r(l).allowScrollEl
39
+ });
40
+ return n(() => {
41
+ l.disableScroll && l.visible ? t() : a();
42
+ }), (o, v) => (d(), i(c, {
43
+ name: "modal",
44
+ appear: ""
45
+ }, {
46
+ default: s(() => [
47
+ u(m("div", {
48
+ class: "modal-container",
49
+ style: b({
50
+ "--bg": e.bg,
51
+ "--blur": e.blur ? `${e.blur}px` : "",
52
+ "--z-index": e.zIndex,
53
+ "--duration": `${e.duration}ms`
54
+ })
55
+ }, [
56
+ f(o.$slots, "default", {}, void 0, !0)
57
+ ], 4), [
58
+ [p, e.visible]
59
+ ])
60
+ ]),
61
+ _: 3
62
+ }));
63
+ }
64
+ }), z = /* @__PURE__ */ y(x, [["__scopeId", "data-v-567b02a5"]]);
65
+ export {
66
+ z as default
67
+ };
@@ -0,0 +1,6 @@
1
+ import t from "./index.vue.js";
2
+ import { withInstall as o } from "../../helpers.js";
3
+ const i = o(t);
4
+ export {
5
+ i as default
6
+ };
@@ -0,0 +1,83 @@
1
+ import { inject as g, provide as k, reactive as w, resolveComponent as p, createElementBlock as s, openBlock as o, normalizeStyle as N, unref as a, Fragment as x, renderList as C, createVNode as h, createBlock as l, createCommentVNode as c, withCtx as v, createElementVNode as E, toDisplayString as L, normalizeClass as b, Transition as B, mergeProps as H, toHandlers as S, withDirectives as V, vShow as j } from "vue";
2
+ import m from "../Icon/index.js";
3
+ /* empty css */
4
+ import z from "../../../_virtual/_plugin-vue_export-helper.js";
5
+ const A = { class: "text" }, D = /* @__PURE__ */ Object.assign({ name: "Nav" }, {
6
+ __name: "index",
7
+ props: {
8
+ list: {
9
+ type: Array,
10
+ default: () => []
11
+ }
12
+ },
13
+ setup(i) {
14
+ const u = i, y = g("layer", 0);
15
+ k("layer", y + 1);
16
+ const n = w(u.list.map(() => !0)), d = {
17
+ beforeEnter(e) {
18
+ e.style.height = "0", e.style.opacity = "0", e.style.overflow = "hidden";
19
+ },
20
+ enter(e) {
21
+ e.style.height = e.scrollHeight + "px", e.style.opacity = "1";
22
+ },
23
+ afterEnter(e) {
24
+ e.style.height = "", e.style.overflow = "", e.style.opacity = "";
25
+ },
26
+ beforeLeave(e) {
27
+ e.style.height = e.scrollHeight + "px", e.style.opacity = "0", e.style.overflow = "hidden";
28
+ },
29
+ leave(e) {
30
+ e.style.height = "0", e.style.opacity = "0";
31
+ },
32
+ afterLeave(e) {
33
+ e.style.height = "", e.style.overflow = "", e.style.opacity = "";
34
+ }
35
+ };
36
+ return (e, I) => {
37
+ const f = p("RouterLink"), _ = p("Nav");
38
+ return o(), s("ul", {
39
+ class: "nav-container",
40
+ style: N({ "--layer": a(y) })
41
+ }, [
42
+ (o(!0), s(x, null, C(i.list, (t, r) => (o(), s("li", {
43
+ class: "nav-item",
44
+ key: t.path
45
+ }, [
46
+ h(f, {
47
+ class: "link",
48
+ to: { name: t.name },
49
+ "exact-active-class": "active"
50
+ }, {
51
+ default: v(() => [
52
+ t.meta?.icon ? (o(), l(a(m), {
53
+ key: 0,
54
+ icon: t.meta.icon
55
+ }, null, 8, ["icon"])) : c("", !0),
56
+ E("span", A, L(t.meta?.title), 1),
57
+ t.children?.length ? (o(), l(a(m), {
58
+ key: 1,
59
+ icon: "chevron-down",
60
+ class: b(["arrow-icon", n[r] ? "" : "right"]),
61
+ onClick: (O) => n[r] = !n[r]
62
+ }, null, 8, ["class", "onClick"])) : c("", !0)
63
+ ]),
64
+ _: 2
65
+ }, 1032, ["to"]),
66
+ t.children?.length ? (o(), l(B, H({ key: 0 }, S(d)), {
67
+ default: v(() => [
68
+ V(h(_, {
69
+ list: t.children
70
+ }, null, 8, ["list"]), [
71
+ [j, n[r]]
72
+ ])
73
+ ]),
74
+ _: 2
75
+ }, 1040)) : c("", !0)
76
+ ]))), 128))
77
+ ], 4);
78
+ };
79
+ }
80
+ }), $ = /* @__PURE__ */ z(D, [["__scopeId", "data-v-997e3fe4"]]);
81
+ export {
82
+ $ as default
83
+ };
@@ -0,0 +1,6 @@
1
+ import t from "./index.vue.js";
2
+ import { withInstall as o } from "../../helpers.js";
3
+ const n = o(t);
4
+ export {
5
+ n as default
6
+ };
@@ -0,0 +1,151 @@
1
+ import { mergeModels as j, useModel as z, ref as D, watch as k, computed as N, createElementBlock as r, createCommentVNode as M, openBlock as p, createElementVNode as m, createVNode as C, unref as P, Fragment as x, renderList as V, normalizeClass as E, toDisplayString as f, withDirectives as q, vModelSelect as K, withKeys as R, vModelText as U } from "vue";
2
+ import B from "../Icon/index.js";
3
+ import { useRouter as A, useRoute as F } from "vue-router";
4
+ import "../../utils/dialog.js";
5
+ import "../../utils/localStorage.js";
6
+ import { msg as J } from "../../utils/msg.js";
7
+ /* empty css */
8
+ import L from "../../../_virtual/_plugin-vue_export-helper.js";
9
+ const O = {
10
+ key: 0,
11
+ class: "pagination-container"
12
+ }, T = {
13
+ key: 0,
14
+ class: "controls"
15
+ }, G = ["disabled"], H = ["onClick"], Q = ["disabled"], W = { class: "meta" }, X = ["value"], Y = ["max"], Z = /* @__PURE__ */ Object.assign({ name: "Pagination" }, {
16
+ __name: "index",
17
+ props: /* @__PURE__ */ j({
18
+ total: { type: Number, default: 0 },
19
+ // 共有多少条数据
20
+ pageSizes: { type: Array, default: () => [10, 20, 50, 100] },
21
+ // 可选的每页条数
22
+ maxButtonCount: { type: Number, default: 7 }
23
+ // 最大显示多少个页码按钮
24
+ }, {
25
+ modelValue: { type: Number, default: 1 },
26
+ modelModifiers: {},
27
+ pageSize: { type: Number, default: 10 },
28
+ pageSizeModifiers: {}
29
+ }),
30
+ emits: ["update:modelValue", "update:pageSize"],
31
+ setup(i) {
32
+ const $ = A(), b = F(), l = z(i, "modelValue"), n = z(i, "pageSize"), c = i, d = D("");
33
+ k(n, () => {
34
+ l.value > u.value && s(u.value);
35
+ });
36
+ const u = N(() => !c.total || n.value <= 0 ? 0 : Math.max(0, Math.ceil(c.total / n.value)));
37
+ function s(t) {
38
+ const e = Math.min(Math.max(1, Math.floor(t || 1)), Math.max(1, u.value || 1));
39
+ e !== l.value && (l.value = e);
40
+ }
41
+ function S() {
42
+ let t = Number(d.value);
43
+ if (!t || isNaN(t) || t < 1 || t > u.value) {
44
+ d.value = "", J.warning("请输入有效页码");
45
+ return;
46
+ }
47
+ s(t), d.value = "";
48
+ }
49
+ function w(t) {
50
+ if (t)
51
+ if (t.ellipsis) {
52
+ const e = Math.max(3, Math.min(u.value, Math.max(5, c.maxButtonCount) - 2));
53
+ t.key === "left" ? s(l.value - e) : s(l.value + e);
54
+ } else t.page && s(t.page);
55
+ }
56
+ const _ = N(() => {
57
+ const t = [], e = u.value, a = Math.max(5, c.maxButtonCount), v = l.value;
58
+ if (e <= a) {
59
+ for (let o = 1; o <= e; o++) t.push({ key: `p${o}`, page: o, label: o });
60
+ return t;
61
+ }
62
+ const g = Math.floor((a - 1) / 2);
63
+ let y = Math.max(2, v - g), h = Math.min(e - 1, v + g);
64
+ v - 1 <= g && (y = 2, h = a - 1), e - v <= g && (y = e - (a - 2), h = e - 1), t.push({ key: "p1", page: 1, label: 1 }), y > 2 && t.push({ key: "left", ellipsis: !0, label: "..." });
65
+ for (let o = y; o <= h; o++)
66
+ t.push({ key: `p${o}`, page: o, label: o });
67
+ return h < e - 1 && t.push({ key: "right", ellipsis: !0, label: "..." }), t.push({ key: `p${e}`, page: e, label: e }), t;
68
+ }), I = k(
69
+ () => c.total,
70
+ (t) => {
71
+ if (!t) return;
72
+ const e = +b.query.page, a = +b.query.pageSize;
73
+ a && !isNaN(a) && c.pageSizes.includes(a) && (n.value = a), e <= u.value && (s(e), I());
74
+ },
75
+ { immediate: !0 }
76
+ );
77
+ return k([l, n], () => {
78
+ $.replace({
79
+ query: {
80
+ ...b.query,
81
+ page: l.value,
82
+ pageSize: n.value
83
+ }
84
+ });
85
+ }), (t, e) => i.total ? (p(), r("div", O, [
86
+ i.total > n.value ? (p(), r("ul", T, [
87
+ m("button", {
88
+ disabled: l.value === 1,
89
+ onClick: e[0] || (e[0] = (a) => s(l.value - 1)),
90
+ class: "item"
91
+ }, [
92
+ C(P(B), { icon: "angle-left" })
93
+ ], 8, G),
94
+ (p(!0), r(x, null, V(_.value, (a) => (p(), r("li", {
95
+ key: a.key,
96
+ class: E([{ active: a.page === l.value }, "item"]),
97
+ onClick: (v) => w(a)
98
+ }, f(a.label), 11, H))), 128)),
99
+ m("button", {
100
+ disabled: l.value === u.value || !u.value,
101
+ onClick: e[1] || (e[1] = (a) => s(l.value + 1)),
102
+ class: "item"
103
+ }, [
104
+ C(P(B), { icon: "angle-right" })
105
+ ], 8, Q)
106
+ ])) : M("", !0),
107
+ m("div", W, [
108
+ m("p", null, "共" + f(i.total) + "条,第" + f(l.value) + " / " + f(u.value || 1) + "页", 1),
109
+ q(m("select", {
110
+ "onUpdate:modelValue": e[2] || (e[2] = (a) => n.value = a)
111
+ }, [
112
+ (p(!0), r(x, null, V(i.pageSizes, (a) => (p(), r("option", {
113
+ key: a,
114
+ value: a
115
+ }, f(a) + " / 页", 9, X))), 128))
116
+ ], 512), [
117
+ [
118
+ K,
119
+ n.value,
120
+ void 0,
121
+ { number: !0 }
122
+ ]
123
+ ]),
124
+ i.total > n.value ? (p(), r(x, { key: 0 }, [
125
+ q(m("input", {
126
+ type: "number",
127
+ "onUpdate:modelValue": e[3] || (e[3] = (a) => d.value = a),
128
+ min: "1",
129
+ max: u.value || 1,
130
+ onKeyup: R(S, ["enter"]),
131
+ placeholder: "页码"
132
+ }, null, 40, Y), [
133
+ [
134
+ U,
135
+ d.value,
136
+ void 0,
137
+ { number: !0 }
138
+ ]
139
+ ]),
140
+ m("button", {
141
+ onClick: S,
142
+ class: "item"
143
+ }, "跳转")
144
+ ], 64)) : M("", !0)
145
+ ])
146
+ ])) : M("", !0);
147
+ }
148
+ }), se = /* @__PURE__ */ L(Z, [["__scopeId", "data-v-377aabe8"]]);
149
+ export {
150
+ se as default
151
+ };
@@ -0,0 +1,6 @@
1
+ import t from "./index.vue.js";
2
+ import { withInstall as o } from "../../helpers.js";
3
+ const m = o(t);
4
+ export {
5
+ m as default
6
+ };