@zl-ui-kit/components 0.7.2 → 0.8.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,16 +1,16 @@
1
- import { defineComponent as E, useModel as I, ref as b, computed as p, useAttrs as K, resolveComponent as T, resolveDirective as q, withDirectives as N, openBlock as g, createElementBlock as z, createVNode as h, mergeProps as R, withCtx as x, renderSlot as Z, createElementVNode as d, toDisplayString as B, createCommentVNode as U, mergeModels as O } from "vue";
2
- import { useZlT as W } from "@zl-ui-kit/composables";
3
- import { joinFilePrefix as G } from "@zl-ui-kit/utils";
4
- import { ElMessage as w } from "element-plus";
5
- import $ from "../ZlIcon/index.vue.mjs";
6
- const H = { class: "zl-upload" }, J = { class: "zl-upload__trigger" }, Q = { class: "zl-upload__item" }, X = ["src", "onClick"], Y = ["title"], ee = ["href", "download"], te = {
1
+ import { defineComponent as K, computed as n, useModel as T, ref as S, useAttrs as q, resolveComponent as N, resolveDirective as R, withDirectives as Z, openBlock as v, createElementBlock as g, createVNode as w, mergeProps as O, withCtx as B, renderSlot as W, createElementVNode as d, toDisplayString as x, createCommentVNode as V, mergeModels as G } from "vue";
2
+ import { useZlT as H } from "@zl-ui-kit/composables";
3
+ import { joinFilePrefix as J } from "@zl-ui-kit/utils";
4
+ import { ElMessage as z } from "element-plus";
5
+ import U from "../ZlIcon/index.vue.mjs";
6
+ const Q = { class: "zl-upload" }, X = { class: "zl-upload__trigger" }, Y = { class: "zl-upload__item" }, ee = ["src", "onClick"], te = ["title"], oe = ["href", "download"], le = {
7
7
  key: 0,
8
8
  class: "zl-upload__tip"
9
- }, ie = /* @__PURE__ */ E({
9
+ }, ue = /* @__PURE__ */ K({
10
10
  name: "ZlUpload",
11
11
  inheritAttrs: !1,
12
12
  __name: "index",
13
- props: /* @__PURE__ */ O({
13
+ props: /* @__PURE__ */ G({
14
14
  request: {},
15
15
  modelValue: { default: "" },
16
16
  accept: {},
@@ -19,21 +19,25 @@ const H = { class: "zl-upload" }, J = { class: "zl-upload__trigger" }, Q = { cla
19
19
  tip: {},
20
20
  separator: { default: ";" },
21
21
  responseUrlKey: { default: "meta" },
22
- showDownloadButton: { type: Boolean, default: !0 },
23
- showTip: { type: Boolean, default: !0 },
22
+ downloadButtonVisible: { type: Boolean, default: void 0 },
23
+ tipVisible: { type: Boolean, default: void 0 },
24
+ showDownloadButton: { type: Boolean, default: void 0 },
25
+ showTip: { type: Boolean, default: void 0 },
24
26
  verifySpace: { type: Boolean, default: !1 }
25
27
  }, {
26
28
  modelValue: { default: "" },
27
29
  modelModifiers: {}
28
30
  }),
29
31
  emits: ["update:modelValue"],
30
- setup(m) {
31
- const { t: n } = W(), t = m, i = I(m, "modelValue"), f = b([]);
32
- function V(e) {
32
+ setup(h) {
33
+ const { t: u } = H(), t = h, $ = n(
34
+ () => t.downloadButtonVisible ?? t.showDownloadButton ?? !0
35
+ ), j = n(() => t.tipVisible ?? t.showTip ?? !0), r = T(h, "modelValue"), m = S([]);
36
+ function C(e) {
33
37
  return e.split(t.separator).filter((o) => !!o).map((o) => {
34
- const l = f.value.filter((a) => a.status === "success").find((a) => a.response?.[t.responseUrlKey] === o);
38
+ const s = m.value.filter((a) => a.status === "success").find((a) => a.response?.[t.responseUrlKey] === o);
35
39
  return {
36
- url: l ? l.url : G(o),
40
+ url: s ? s.url : J(o),
37
41
  name: (o.match(/[^/\\]+$/)?.[0] ?? o).split("-").pop() ?? o,
38
42
  isImage: /\.(?:jpe?g|png|gif|bmp|webp)$/i.test(o),
39
43
  response: {
@@ -43,111 +47,111 @@ const H = { class: "zl-upload" }, J = { class: "zl-upload__trigger" }, Q = { cla
43
47
  };
44
48
  });
45
49
  }
46
- function j(e) {
50
+ function F(e) {
47
51
  return e.filter((o) => o.status === "success").map((o) => o.response?.[t.responseUrlKey]).filter(Boolean).join(t.separator);
48
52
  }
49
- const y = p({
53
+ const b = n({
50
54
  get() {
51
- return typeof i.value == "string" ? [...V(i.value), ...f.value.filter((e) => e.status !== "success")] : i.value;
55
+ return typeof r.value == "string" ? [...C(r.value), ...m.value.filter((e) => e.status !== "success")] : r.value;
52
56
  },
53
57
  set(e) {
54
- i.value = typeof i.value == "string" ? j(e) : e, f.value = e;
58
+ r.value = typeof r.value == "string" ? F(e) : e, m.value = e;
55
59
  }
56
- }), C = K(), F = p(() => t.accept ? t.accept.split(",") : []);
57
- function k(e) {
58
- const { file: o, onSuccess: l, onError: a, onProgress: s } = e, v = new AbortController(), A = (r) => {
59
- const M = r.total > 0 ? r.loaded / r.total * 90 : 0;
60
- s({ percent: M });
61
- }, S = new FormData();
62
- return S.append("file", o), t.request?.(S, { signal: v.signal, onUploadProgress: A }).then((r) => {
63
- l({ ...r.data });
64
- }).catch((r) => {
65
- a(r);
60
+ }), k = q(), D = n(() => t.accept ? t.accept.split(",") : []);
61
+ function L(e) {
62
+ const { file: o, onSuccess: s, onError: a, onProgress: l } = e, _ = new AbortController(), E = (i) => {
63
+ const I = i.total > 0 ? i.loaded / i.total * 90 : 0;
64
+ l({ percent: I });
65
+ }, y = new FormData();
66
+ return y.append("file", o), t.request?.(y, { signal: _.signal, onUploadProgress: E }).then((i) => {
67
+ s({ ...i.data });
68
+ }).catch((i) => {
69
+ a(i);
66
70
  }), {
67
71
  abort() {
68
- v.abort();
72
+ _.abort();
69
73
  }
70
74
  };
71
75
  }
72
- const c = p(() => {
76
+ const c = n(() => {
73
77
  const e = {};
74
- return t.accept && (e.accept = n("zl.upload.accept", `仅支持${t.accept}格式的文件`, { accept: t.accept })), t.limit && (e.limit = n("zl.upload.limit", `最多可上传${t.limit}个`, { limit: t.limit })), t.maxSize && (e.maxSize = n("zl.upload.maxSize", `大小不超过${t.maxSize}MB`, { maxSize: t.maxSize })), e;
75
- }), _ = p(() => {
78
+ return t.accept && (e.accept = u("zl.upload.accept", `仅支持${t.accept}格式的文件`, { accept: t.accept })), t.limit && (e.limit = u("zl.upload.limit", `最多可上传${t.limit}个`, { limit: t.limit })), t.maxSize && (e.maxSize = u("zl.upload.maxSize", `大小不超过${t.maxSize}MB`, { maxSize: t.maxSize })), e;
79
+ }), f = n(() => {
76
80
  const e = [t.tip, ...Object.values(c.value)].filter(Boolean).join(", ");
77
81
  return {
78
82
  accept: t.accept,
79
83
  limit: t.limit,
80
84
  multiple: t.limit ? t.limit > 1 : !0,
81
- httpRequest: k,
82
- fileList: y.value,
83
- "onUpdate:fileList": (o) => y.value = o,
84
- ...C,
85
+ httpRequest: L,
86
+ fileList: b.value,
87
+ "onUpdate:fileList": (o) => b.value = o,
88
+ ...k,
85
89
  // tip 不透传 el-upload(无此属性),由组件尾部渲染
86
90
  tip: void 0,
87
- __tip: t.showTip ? e : ""
91
+ __tip: j.value ? e : ""
88
92
  };
89
93
  });
90
- function D(e) {
91
- return F.value.some((o) => o.includes("/") ? e.type.startsWith(o.replace(/\*$/, "")) : e.name.endsWith(o));
94
+ function P(e) {
95
+ return D.value.some((o) => o.includes("/") ? e.type.startsWith(o.replace(/\*$/, "")) : e.name.endsWith(o));
92
96
  }
93
- function L(e) {
94
- return t.verifySpace && /\s/.test(e.name) ? (w.warning(n("zl.upload.nameSpace", "文件名中不得包含空格")), !1) : c.value.accept && !D(e) ? (w.warning(c.value.accept), !1) : t.maxSize && e.size > t.maxSize * 1024 * 1024 ? (w.warning(c.value.maxSize), !1) : !0;
97
+ function A(e) {
98
+ return t.verifySpace && /\s/.test(e.name) ? (z.warning(u("zl.upload.nameSpace", "文件名中不得包含空格")), !1) : c.value.accept && !P(e) ? (z.warning(c.value.accept), !1) : t.maxSize && e.size > t.maxSize * 1024 * 1024 ? (z.warning(c.value.maxSize), !1) : !0;
95
99
  }
96
- const u = b(!1);
97
- function P(e) {
98
- e.status === "success" && (u.value = !0, fetch(e.url ?? "").then((o) => o.blob()).then((o) => {
99
- u.value = !1;
100
- const l = URL.createObjectURL(o);
101
- window.open(l);
100
+ const p = S(!1);
101
+ function M(e) {
102
+ e.status === "success" && (p.value = !0, fetch(e.url ?? "").then((o) => o.blob()).then((o) => {
103
+ p.value = !1;
104
+ const s = URL.createObjectURL(o);
105
+ window.open(s);
102
106
  }).catch(() => {
103
- u.value = !1;
107
+ p.value = !1;
104
108
  }));
105
109
  }
106
110
  return (e, o) => {
107
- const l = T("el-upload"), a = q("loading");
108
- return N((g(), z("div", H, [
109
- h(l, R(_.value, {
110
- "before-upload": L,
111
+ const s = N("el-upload"), a = R("loading");
112
+ return Z((v(), g("div", Q, [
113
+ w(s, O(f.value, {
114
+ "before-upload": A,
111
115
  "list-type": "picture"
112
116
  }), {
113
- file: x(({ file: s }) => [
114
- d("div", Q, [
117
+ file: B(({ file: l }) => [
118
+ d("div", Y, [
115
119
  d("img", {
116
120
  class: "zl-upload__item-thumbnail",
117
- src: (s.isImage !== !1 && /\.(?:jpe?g|png|gif|bmp|webp)$/i.test(s.name), s.url),
118
- onClick: (v) => P(s)
119
- }, null, 8, X),
121
+ src: (l.isImage !== !1 && /\.(?:jpe?g|png|gif|bmp|webp)$/i.test(l.name), l.url),
122
+ onClick: (_) => M(l)
123
+ }, null, 8, ee),
120
124
  d("span", {
121
125
  class: "zl-upload__item-name",
122
- title: s.name
123
- }, B(s.name), 9, Y),
124
- m.showDownloadButton && s.status === "success" && s.url ? (g(), z("a", {
126
+ title: l.name
127
+ }, x(l.name), 9, te),
128
+ $.value && l.status === "success" && l.url ? (v(), g("a", {
125
129
  key: 0,
126
130
  class: "zl-upload__item-op",
127
- href: s.url,
128
- download: s.name
131
+ href: l.url,
132
+ download: l.name
129
133
  }, [
130
- h($, { icon: "zl:download" })
131
- ], 8, ee)) : U("", !0)
134
+ w(U, { icon: "zl:download" })
135
+ ], 8, oe)) : V("", !0)
132
136
  ])
133
137
  ]),
134
- default: x(() => [
135
- Z(e.$slots, "default", {}, () => [
136
- d("div", J, [
137
- h($, { icon: "zl:add" })
138
+ default: B(() => [
139
+ W(e.$slots, "default", {}, () => [
140
+ d("div", X, [
141
+ w(U, { icon: "zl:add" })
138
142
  ])
139
143
  ], !0)
140
144
  ]),
141
145
  _: 3
142
146
  }, 16),
143
- _.value.__tip ? (g(), z("div", te, B(_.value.__tip), 1)) : U("", !0)
147
+ f.value.__tip ? (v(), g("div", le, x(f.value.__tip), 1)) : V("", !0)
144
148
  ])), [
145
- [a, u.value]
149
+ [a, p.value]
146
150
  ]);
147
151
  };
148
152
  }
149
153
  });
150
154
  export {
151
- ie as default
155
+ ue as default
152
156
  };
153
157
  //# sourceMappingURL=index2.vue.mjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zl-ui-kit/components",
3
- "version": "0.7.2",
3
+ "version": "0.8.0",
4
4
  "type": "module",
5
5
  "description": "ZL UI 业务组件库(Element Plus 体系,Zl 前缀)——首批:Icon/AutoTooltip/Tag/CornerTag/Text/Title/Copy/Empty/Pagination/DictTag",
6
6
  "license": "MIT",
@@ -39,9 +39,9 @@
39
39
  "file-type": "^20.4.1",
40
40
  "dt-sql-parser": "^4.3.1",
41
41
  "sql-formatter": "^15.4.2",
42
- "@zl-ui-kit/utils": "0.7.2",
43
- "@zl-ui-kit/icons": "0.7.2",
44
- "@zl-ui-kit/composables": "0.7.2"
42
+ "@zl-ui-kit/icons": "0.8.0",
43
+ "@zl-ui-kit/composables": "0.8.0",
44
+ "@zl-ui-kit/utils": "0.8.0"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "@vueuse/core": "^12.3.0",
@@ -98,10 +98,10 @@
98
98
  "@vue-office/pdf": "^2.0.10",
99
99
  "@vue-office/pptx": "1.0.1",
100
100
  "echarts": "^5.6.0",
101
- "@jichuang/eslint-config": "1.0.0",
102
101
  "@jichuang/tsconfig": "1.0.0",
103
- "@zl-ui-kit/theme": "0.7.2",
104
- "@jichuang/vite-config": "1.0.0"
102
+ "@jichuang/eslint-config": "1.0.0",
103
+ "@jichuang/vite-config": "1.0.0",
104
+ "@zl-ui-kit/theme": "0.8.0"
105
105
  },
106
106
  "repository": {
107
107
  "type": "git",