@zl-ui-kit/components 0.22.1 → 0.24.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.
@@ -1,53 +1,79 @@
1
- import { defineComponent as v, useAttrs as h, computed as r, ref as l, watch as p, resolveComponent as _, openBlock as d, createBlock as S, mergeProps as C, createCommentVNode as N } from "vue";
2
- import { usePagination as P } from "./usePagination.mjs";
3
- const B = /* @__PURE__ */ v({
1
+ import { defineComponent as A, useAttrs as U, computed as t, ref as S, watch as N, resolveComponent as B, openBlock as T, createBlock as V, mergeProps as b, createSlots as j, withCtx as M, createElementVNode as r, renderSlot as R, createTextVNode as c, toDisplayString as v, createCommentVNode as $ } from "vue";
2
+ import { normalizePaginationAttrs as D, usePagination as E } from "./usePagination.mjs";
3
+ const Z = { class: "el-pagination__total zl-pagination__total" }, q = { class: "zl-pagination__total-num" }, F = { class: "zl-pagination__total-num" }, J = /* @__PURE__ */ A({
4
4
  name: "ZlPagination",
5
5
  inheritAttrs: !1,
6
6
  __name: "index",
7
7
  emits: ["change", "page-change", "page-size-change"],
8
- setup(k, { emit: s }) {
9
- const t = s, a = h(), n = P(() => a), c = r(() => a.align ?? "right"), i = l(
10
- a.pageNum ?? (n.value === !1 ? void 0 : n.value.currentPage) ?? 1
11
- ), g = l(
12
- a.pageSize ?? (n.value === !1 ? void 0 : n.value.pageSize) ?? 30
8
+ setup(G, { emit: y }) {
9
+ const s = y, C = U(), n = t(() => D(C)), a = E(() => n.value), P = t(() => n.value.align ?? "right"), m = t(
10
+ () => a.value === !1 ? [] : String(a.value.layout ?? "").split(",").map((e) => e.trim()).filter(Boolean)
11
+ ), f = t(() => !m.value.includes("jumper")), z = t(() => m.value.includes("total") && !f.value), k = t(() => n.value.totalUnit ?? "资源"), g = t(() => a.value === !1 ? 0 : Number(a.value.total ?? 0)), l = S(
12
+ n.value.pageNum ?? (a.value === !1 ? void 0 : a.value.currentPage) ?? 1
13
+ ), o = S(
14
+ n.value.pageSize ?? (a.value === !1 ? void 0 : a.value.pageSize) ?? 30
13
15
  );
14
- p(
15
- () => a.pageNum ?? a.currentPage,
16
+ N(
17
+ () => n.value.pageNum ?? n.value.currentPage,
16
18
  (e) => {
17
- e != null && (i.value = e);
19
+ e != null && (l.value = e);
18
20
  }
19
- ), p(
20
- () => a.pageSize,
21
+ ), N(
22
+ () => n.value.pageSize,
21
23
  (e) => {
22
- e != null && (g.value = e);
24
+ e != null && (o.value = e);
23
25
  }
24
26
  );
25
- function m(e) {
26
- i.value = e, t("change", { pageNum: e, pageSize: g.value }), t("page-change", e);
27
+ function w(e) {
28
+ l.value = e, s("change", { pageNum: e, pageSize: o.value }), s("page-change", e);
27
29
  }
28
- function f(e) {
29
- g.value = e, i.value = 1, t("change", { pageNum: 1, pageSize: e }), t("page-size-change", e);
30
+ function x(e) {
31
+ o.value = e, l.value = 1, s("change", { pageNum: 1, pageSize: e }), s("page-size-change", e);
30
32
  }
31
- const u = r(() => {
32
- if (n.value === !1) return !1;
33
- const { currentPage: e, pageSize: z, ...o } = n.value;
34
- return delete o.align, o;
33
+ const _ = t(() => {
34
+ const e = o.value || 1;
35
+ return Math.min(e, Math.max(g.value - (l.value - 1) * e, 0));
36
+ }), d = t(() => {
37
+ if (a.value === !1) return !1;
38
+ const { currentPage: e, pageSize: i, totalUnit: h, ...u } = a.value;
39
+ return delete u.align, z.value && typeof u.layout == "string" && (u.layout = u.layout.split(",").map((p) => p.trim()).map((p) => p === "total" ? "slot" : p).join(", ")), u;
35
40
  });
36
- return (e, z) => {
37
- const o = _("el-pagination");
38
- return u.value !== !1 ? (d(), S(o, C({
41
+ return (e, i) => {
42
+ const h = B("el-pagination");
43
+ return d.value !== !1 ? (T(), V(h, b({
39
44
  key: 0,
40
- class: ["zl-pagination", `zl-pagination--${c.value}`]
41
- }, u.value, {
42
- "current-page": i.value,
43
- "page-size": g.value,
44
- onCurrentChange: m,
45
- onSizeChange: f
46
- }), null, 16, ["class", "current-page", "page-size"])) : N("", !0);
45
+ class: ["zl-pagination", [`zl-pagination--${P.value}`, f.value ? "zl-pagination--simple" : "zl-pagination--full"]]
46
+ }, d.value, {
47
+ "current-page": l.value,
48
+ "page-size": o.value,
49
+ onCurrentChange: w,
50
+ onSizeChange: x
51
+ }), j({ _: 2 }, [
52
+ z.value ? {
53
+ name: "default",
54
+ fn: M(() => [
55
+ r("span", Z, [
56
+ R(e.$slots, "total", {
57
+ total: g.value,
58
+ pageRows: _.value,
59
+ pageNum: l.value,
60
+ pageSize: o.value
61
+ }, () => [
62
+ i[0] || (i[0] = c(" 共 ", -1)),
63
+ r("span", q, v(g.value), 1),
64
+ c(" 条" + v(k.value) + ",当前筛选命中 ", 1),
65
+ r("span", F, v(_.value), 1),
66
+ i[1] || (i[1] = c(" 条,每页 ", -1))
67
+ ], !0)
68
+ ])
69
+ ]),
70
+ key: "0"
71
+ } : void 0
72
+ ]), 1040, ["class", "current-page", "page-size"])) : $("", !0);
47
73
  };
48
74
  }
49
75
  });
50
76
  export {
51
- B as default
77
+ J as default
52
78
  };
53
79
  //# sourceMappingURL=index2.vue.mjs.map
@@ -23,6 +23,7 @@ export interface PaginationProps {
23
23
  simple?: boolean;
24
24
  [key: string]: any;
25
25
  }
26
+ export declare function normalizePaginationAttrs(attrs: Record<string, any>): Record<string, any>;
26
27
  export declare function usePagination(props: Ref<PaginationProps | false> | (() => PaginationProps | false)): import('vue').ComputedRef<false | {
27
28
  layout: string;
28
29
  currentPage: number;
@@ -1,47 +1,64 @@
1
- import { computed as w, toValue as y } from "vue";
2
- function b(i) {
3
- return w(() => {
4
- const o = y(i);
1
+ import { computed as V, toValue as k } from "vue";
2
+ const _ = [
3
+ "pageNum",
4
+ "pageSize",
5
+ "pageSizeOptions",
6
+ "totalVisible",
7
+ "pageSizeVisible",
8
+ "showTotal",
9
+ "showPageSize",
10
+ "currentPage",
11
+ "pageSizes",
12
+ "totalUnit"
13
+ ], v = (e) => e.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`);
14
+ function K(e) {
15
+ const t = { ...e };
16
+ for (const o of _) {
17
+ const i = v(o);
18
+ i !== o && (t[o] === void 0 && e[i] !== void 0 && (t[o] = e[i]), delete t[i]);
19
+ }
20
+ return t;
21
+ }
22
+ function j(e) {
23
+ return V(() => {
24
+ const o = k(e);
5
25
  if (o === !1)
6
26
  return !1;
7
27
  const {
8
28
  // 对外名优先,EP 名回落:上层已归一化时只会有 EP 名
9
- pageSizeOptions: s,
10
- pageSizes: n,
11
- pageSize: t = 30,
12
- pageNum: r,
13
- currentPage: l,
14
- layout: p,
15
- size: u,
16
- simple: a = !0,
17
- totalVisible: g,
18
- pageSizeVisible: c,
29
+ pageSizeOptions: i,
30
+ pageSizes: r,
31
+ pageSize: s = 30,
32
+ pageNum: p,
33
+ currentPage: g,
34
+ layout: u,
35
+ size: c,
36
+ simple: l = !1,
37
+ totalVisible: f,
38
+ pageSizeVisible: z,
19
39
  // 旧名回落:新名优先,两者都没给才用默认值
20
- showTotal: z,
21
- showPageSize: f,
22
- ...m
23
- } = o || {}, S = g ?? z ?? !0, e = (s ?? n ?? [10, 30, 50]).slice();
24
- e.includes(t) || e.push(t);
25
- const h = p ?? [
26
- S ? "total" : "",
27
- c ?? f ?? e.length > 0 ? "sizes" : "",
28
- "prev",
29
- "pager",
30
- "next",
31
- a ? "" : "jumper"
32
- ].filter(Boolean).join(", ");
40
+ showTotal: S,
41
+ showPageSize: m,
42
+ ...b
43
+ } = o || {}, h = f ?? S ?? !0, n = l === !0 || l === "", a = (i ?? r ?? [10, 30, 50]).slice();
44
+ a.includes(s) || a.push(s);
45
+ const d = [
46
+ h ? "total" : "",
47
+ z ?? m ?? a.length > 0 ? "sizes" : ""
48
+ ].filter(Boolean), P = ["prev", "pager", "next", n ? "" : "jumper"].filter(Boolean), w = u ?? [...d, ...n ? [] : ["->"], ...P].join(", ");
33
49
  return {
34
50
  // EP 2.7+ 官方推荐 size(原 arco simple/mini 语义映射为小尺寸)
35
- size: u ?? (a ? "small" : "default"),
36
- ...m,
37
- layout: h,
38
- currentPage: r ?? l ?? 1,
39
- pageSize: t,
40
- pageSizes: e.sort((d, P) => d - P)
51
+ size: c ?? (n ? "small" : "default"),
52
+ ...b,
53
+ layout: w,
54
+ currentPage: p ?? g ?? 1,
55
+ pageSize: s,
56
+ pageSizes: a.sort((y, T) => y - T)
41
57
  };
42
58
  });
43
59
  }
44
60
  export {
45
- b as usePagination
61
+ K as normalizePaginationAttrs,
62
+ j as usePagination
46
63
  };
47
64
  //# sourceMappingURL=usePagination.mjs.map
@@ -1,10 +1,11 @@
1
- import { defineComponent as B, computed as d, ref as x, resolveComponent as _, openBlock as u, createBlock as y, mergeProps as $, withCtx as t, createElementVNode as n, createVNode as r, createElementBlock as g, renderSlot as s, createTextVNode as c, toDisplayString as l, createCommentVNode as N } from "vue";
1
+ import { defineComponent as T, computed as f, ref as B, resolveComponent as x, openBlock as d, createBlock as $, mergeProps as y, withCtx as t, createElementVNode as n, createVNode as r, createElementBlock as g, renderSlot as s, createTextVNode as c, toDisplayString as l, createCommentVNode as N } from "vue";
2
2
  import { useZlT as V } from "@zl-ui-kit/composables";
3
+ import _ from "../ZlButton/index.vue.mjs";
3
4
  import Z from "../ZlIcon/index.vue.mjs";
4
- const b = { class: "zl-popconfirm-panel" }, w = { class: "zl-popconfirm-panel__main" }, E = {
5
+ const w = { class: "zl-popconfirm-panel" }, E = { class: "zl-popconfirm-panel__main" }, P = {
5
6
  key: 0,
6
7
  class: "zl-popconfirm-panel__title"
7
- }, P = { class: "zl-popconfirm-panel__content" }, R = { class: "zl-popconfirm-panel__actions" }, j = /* @__PURE__ */ B({
8
+ }, R = { class: "zl-popconfirm-panel__content" }, S = { class: "zl-popconfirm-panel__actions" }, q = /* @__PURE__ */ T({
8
9
  name: "ZlPopconfirm",
9
10
  inheritAttrs: !1,
10
11
  __name: "index",
@@ -15,17 +16,17 @@ const b = { class: "zl-popconfirm-panel" }, w = { class: "zl-popconfirm-panel__m
15
16
  cancelButtonText: {}
16
17
  },
17
18
  emits: ["confirm", "cancel"],
18
- setup(o, { emit: v }) {
19
- const a = o, { t: p } = V(), z = d(() => a.confirmButtonText ?? p("zl.popconfirm.confirm", "确定")), h = d(() => a.cancelButtonText ?? p("zl.popconfirm.cancel", "取消")), i = x(null), m = v;
20
- function k() {
21
- i.value?.hide?.(), m("confirm");
19
+ setup(o, { emit: u }) {
20
+ const a = o, { t: m } = V(), v = f(() => a.confirmButtonText ?? m("zl.popconfirm.confirm", "确定")), z = f(() => a.cancelButtonText ?? m("zl.popconfirm.cancel", "取消")), i = B(null), p = u;
21
+ function h() {
22
+ i.value?.hide?.(), p("confirm");
22
23
  }
23
- function C() {
24
- i.value?.hide?.(), m("cancel");
24
+ function k() {
25
+ i.value?.hide?.(), p("cancel");
25
26
  }
26
- return (e, S) => {
27
- const f = _("el-button"), T = _("el-popover");
28
- return u(), y(T, $({
27
+ return (e, A) => {
28
+ const C = x("el-popover");
29
+ return d(), $(C, y({
29
30
  ref_key: "popoverRef",
30
31
  ref: i,
31
32
  class: "zl-popconfirm"
@@ -34,39 +35,39 @@ const b = { class: "zl-popconfirm-panel" }, w = { class: "zl-popconfirm-panel__m
34
35
  s(e.$slots, "default")
35
36
  ]),
36
37
  default: t(() => [
37
- n("div", b, [
38
+ n("div", w, [
38
39
  r(Z, {
39
40
  class: "zl-popconfirm-panel__icon",
40
41
  icon: "zl:information-color"
41
42
  }),
42
- n("div", w, [
43
- e.$slots.title || o.title ? (u(), g("div", E, [
43
+ n("div", E, [
44
+ e.$slots.title || o.title ? (d(), g("div", P, [
44
45
  s(e.$slots, "title", {}, () => [
45
46
  c(l(o.title), 1)
46
47
  ])
47
48
  ])) : N("", !0),
48
- n("div", P, [
49
+ n("div", R, [
49
50
  s(e.$slots, "content", {}, () => [
50
51
  c(l(o.content), 1)
51
52
  ])
52
53
  ]),
53
- n("div", R, [
54
- r(f, {
54
+ n("div", S, [
55
+ r(_, {
55
56
  size: "small",
56
- onClick: C
57
+ onClick: k
57
58
  }, {
58
59
  default: t(() => [
59
- c(l(h.value), 1)
60
+ c(l(z.value), 1)
60
61
  ]),
61
62
  _: 1
62
63
  }),
63
- r(f, {
64
+ r(_, {
64
65
  size: "small",
65
66
  type: "primary",
66
- onClick: k
67
+ onClick: h
67
68
  }, {
68
69
  default: t(() => [
69
- c(l(z.value), 1)
70
+ c(l(v.value), 1)
70
71
  ]),
71
72
  _: 1
72
73
  })
@@ -80,6 +81,6 @@ const b = { class: "zl-popconfirm-panel" }, w = { class: "zl-popconfirm-panel__m
80
81
  }
81
82
  });
82
83
  export {
83
- j as default
84
+ q as default
84
85
  };
85
86
  //# sourceMappingURL=index.vue.mjs.map