@zl-ui-kit/components 0.20.1 → 0.21.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/README.md +161 -44
- package/dist/components/ZlAction/List.vue.mjs +2 -2
- package/dist/components/ZlAppMenu/AppMenu3.vue.mjs +1 -1
- package/dist/components/ZlBreadcrumb/index.css +1 -0
- package/dist/components/ZlBreadcrumb/index.vue.d.ts +32 -0
- package/dist/components/ZlBreadcrumb/index.vue.mjs +58 -0
- package/dist/components/ZlBreadcrumb/index3.vue.mjs +6 -0
- package/dist/components/ZlBreadcrumb/types.d.ts +16 -0
- package/dist/components/ZlMenu/index3.vue.mjs +1 -1
- package/dist/components/ZlUpload/index.css +1 -1
- package/dist/components/ZlUpload/index.vue.d.ts +44 -3
- package/dist/components/ZlUpload/index.vue.mjs +2 -2
- package/dist/components/ZlUpload/index2.vue.mjs +119 -79
- package/dist/index.d.ts +2 -0
- package/dist/index.mjs +136 -132
- package/package.json +9 -9
- /package/dist/components/{ZlAppMenu/AppMenu.css → ZlMenu/index.css} +0 -0
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { useZlT as
|
|
3
|
-
import { joinFilePrefix as
|
|
4
|
-
import { ElMessage as
|
|
5
|
-
import
|
|
6
|
-
const
|
|
1
|
+
import { defineComponent as I, computed as n, useModel as N, ref as h, useAttrs as Z, resolveComponent as O, resolveDirective as W, withDirectives as G, openBlock as f, createElementBlock as m, createVNode as b, mergeProps as H, withCtx as g, renderSlot as w, createElementVNode as z, normalizeProps as J, guardReactiveProps as Q, toDisplayString as $, createCommentVNode as x, mergeModels as X } from "vue";
|
|
2
|
+
import { useZlT as Y } from "@zl-ui-kit/composables";
|
|
3
|
+
import { joinFilePrefix as ee } from "@zl-ui-kit/utils";
|
|
4
|
+
import { ElMessage as B } from "element-plus";
|
|
5
|
+
import R from "../ZlIcon/index.vue.mjs";
|
|
6
|
+
const te = { class: "zl-upload" }, le = { class: "zl-upload__trigger" }, oe = {
|
|
7
|
+
key: 1,
|
|
8
|
+
class: "zl-upload__item"
|
|
9
|
+
}, ae = ["src", "onClick"], ie = ["title"], se = ["href", "download"], re = {
|
|
7
10
|
key: 0,
|
|
8
11
|
class: "zl-upload__tip"
|
|
9
|
-
},
|
|
12
|
+
}, fe = /* @__PURE__ */ I({
|
|
10
13
|
name: "ZlUpload",
|
|
11
14
|
inheritAttrs: !1,
|
|
12
15
|
__name: "index",
|
|
13
|
-
props: /* @__PURE__ */
|
|
16
|
+
props: /* @__PURE__ */ X({
|
|
14
17
|
request: {},
|
|
15
18
|
modelValue: { default: "" },
|
|
16
19
|
accept: {},
|
|
@@ -23,133 +26,170 @@ const Q = { class: "zl-upload" }, X = { class: "zl-upload__trigger" }, Y = { cla
|
|
|
23
26
|
tipVisible: { type: Boolean, default: void 0 },
|
|
24
27
|
showDownloadButton: { type: Boolean, default: void 0 },
|
|
25
28
|
showTip: { type: Boolean, default: void 0 },
|
|
26
|
-
verifySpace: { type: Boolean, default: !1 }
|
|
29
|
+
verifySpace: { type: Boolean, default: !1 },
|
|
30
|
+
listType: { default: "picture" },
|
|
31
|
+
disabled: { type: Boolean, default: void 0 },
|
|
32
|
+
drag: { type: Boolean, default: void 0 },
|
|
33
|
+
directory: { type: Boolean, default: void 0 },
|
|
34
|
+
multiple: { type: Boolean, default: void 0 },
|
|
35
|
+
showFileList: { type: Boolean, default: !0 },
|
|
36
|
+
autoUpload: { type: Boolean, default: !0 },
|
|
37
|
+
beforeRemove: {}
|
|
27
38
|
}, {
|
|
28
39
|
modelValue: { default: "" },
|
|
29
40
|
modelModifiers: {}
|
|
30
41
|
}),
|
|
31
42
|
emits: ["update:modelValue"],
|
|
32
|
-
setup(
|
|
33
|
-
const { t:
|
|
43
|
+
setup(S, { expose: L }) {
|
|
44
|
+
const { t: d } = Y(), t = S, k = n(() => t.downloadButtonVisible ?? t.showDownloadButton ?? !0), P = n(() => t.tipVisible ?? t.showTip ?? !0), u = N(S, "modelValue"), v = h([]);
|
|
34
45
|
function C(e) {
|
|
35
|
-
return e.split(t.separator).filter((
|
|
36
|
-
const
|
|
46
|
+
return e.split(t.separator).filter((l) => !!l).map((l) => {
|
|
47
|
+
const a = v.value.filter((i) => i.status === "success").find((i) => i.response?.[t.responseUrlKey] === l);
|
|
37
48
|
return {
|
|
38
|
-
url:
|
|
39
|
-
name: (
|
|
40
|
-
isImage: /\.(?:jpe?g|png|gif|bmp|webp)$/i.test(
|
|
49
|
+
url: a ? a.url : ee(l),
|
|
50
|
+
name: (l.match(/[^/\\]+$/)?.[0] ?? l).split("-").pop() ?? l,
|
|
51
|
+
isImage: /\.(?:jpe?g|png|gif|bmp|webp)$/i.test(l),
|
|
41
52
|
response: {
|
|
42
|
-
[t.responseUrlKey]:
|
|
53
|
+
[t.responseUrlKey]: l
|
|
43
54
|
},
|
|
44
55
|
status: "success"
|
|
45
56
|
};
|
|
46
57
|
});
|
|
47
58
|
}
|
|
48
|
-
function
|
|
49
|
-
return e.filter((
|
|
59
|
+
function T(e) {
|
|
60
|
+
return e.filter((l) => l.status === "success").map((l) => l.response?.[t.responseUrlKey]).filter(Boolean).join(t.separator);
|
|
50
61
|
}
|
|
51
|
-
const
|
|
62
|
+
const U = n({
|
|
52
63
|
get() {
|
|
53
|
-
return typeof
|
|
64
|
+
return typeof u.value == "string" ? [...C(u.value), ...v.value.filter((e) => e.status !== "success")] : u.value;
|
|
54
65
|
},
|
|
55
66
|
set(e) {
|
|
56
|
-
|
|
67
|
+
u.value = typeof u.value == "string" ? T(e) : e, v.value = e;
|
|
57
68
|
}
|
|
58
|
-
}),
|
|
59
|
-
function
|
|
60
|
-
const { file:
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
},
|
|
64
|
-
return
|
|
65
|
-
|
|
66
|
-
}).catch((
|
|
67
|
-
|
|
69
|
+
}), V = Z(), j = n(() => t.accept ? t.accept.split(",") : []);
|
|
70
|
+
function D(e) {
|
|
71
|
+
const { file: l, onSuccess: a, onError: i, onProgress: o } = e, y = new AbortController(), K = (s) => {
|
|
72
|
+
const q = s.total > 0 ? s.loaded / s.total * 90 : 0;
|
|
73
|
+
o({ percent: q });
|
|
74
|
+
}, F = new FormData();
|
|
75
|
+
return F.append("file", l), t.request?.(F, { signal: y.signal, onUploadProgress: K }).then((s) => {
|
|
76
|
+
a({ ...s.data });
|
|
77
|
+
}).catch((s) => {
|
|
78
|
+
i(s);
|
|
68
79
|
}), {
|
|
69
80
|
abort() {
|
|
70
|
-
|
|
81
|
+
y.abort();
|
|
71
82
|
}
|
|
72
83
|
};
|
|
73
84
|
}
|
|
74
85
|
const c = n(() => {
|
|
75
86
|
const e = {};
|
|
76
|
-
return t.accept && (e.accept =
|
|
77
|
-
}),
|
|
87
|
+
return t.accept && (e.accept = d("zl.upload.accept", `仅支持${t.accept}格式的文件`, { accept: t.accept })), t.limit && (e.limit = d("zl.upload.limit", `最多可上传${t.limit}个`, { limit: t.limit })), t.maxSize && (e.maxSize = d("zl.upload.maxSize", `大小不超过${t.maxSize}MB`, { maxSize: t.maxSize })), e;
|
|
88
|
+
}), _ = n(() => {
|
|
78
89
|
const e = [t.tip, ...Object.values(c.value)].filter(Boolean).join(", ");
|
|
79
90
|
return {
|
|
80
91
|
accept: t.accept,
|
|
81
92
|
limit: t.limit,
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
93
|
+
listType: t.listType,
|
|
94
|
+
disabled: t.disabled,
|
|
95
|
+
drag: t.drag,
|
|
96
|
+
directory: t.directory,
|
|
97
|
+
showFileList: t.showFileList,
|
|
98
|
+
autoUpload: t.autoUpload,
|
|
99
|
+
beforeRemove: t.beforeRemove,
|
|
100
|
+
multiple: t.multiple ?? (t.limit ? t.limit > 1 : !0),
|
|
101
|
+
httpRequest: D,
|
|
102
|
+
fileList: U.value,
|
|
103
|
+
"onUpdate:fileList": (l) => U.value = l,
|
|
104
|
+
...V,
|
|
87
105
|
// tip 不透传 el-upload(无此属性),由组件尾部渲染
|
|
88
106
|
tip: void 0,
|
|
89
|
-
__tip:
|
|
107
|
+
__tip: P.value ? e : ""
|
|
90
108
|
};
|
|
91
109
|
});
|
|
92
|
-
function P(e) {
|
|
93
|
-
return D.value.some((o) => o.includes("/") ? e.type.startsWith(o.replace(/\*$/, "")) : e.name.endsWith(o));
|
|
94
|
-
}
|
|
95
110
|
function A(e) {
|
|
96
|
-
return
|
|
111
|
+
return j.value.some((l) => l.includes("/") ? e.type.startsWith(l.replace(/\*$/, "")) : e.name.endsWith(l));
|
|
112
|
+
}
|
|
113
|
+
async function M(e) {
|
|
114
|
+
const l = V.beforeUpload;
|
|
115
|
+
if (typeof l == "function")
|
|
116
|
+
try {
|
|
117
|
+
if (await l(e) === !1) return !1;
|
|
118
|
+
} catch {
|
|
119
|
+
return !1;
|
|
120
|
+
}
|
|
121
|
+
return t.verifySpace && /\s/.test(e.name) ? (B.warning(d("zl.upload.nameSpace", "文件名中不得包含空格")), !1) : c.value.accept && !A(e) ? (B.warning(c.value.accept), !1) : t.maxSize && e.size > t.maxSize * 1024 * 1024 ? (B.warning(c.value.maxSize), !1) : !0;
|
|
97
122
|
}
|
|
98
|
-
const p =
|
|
99
|
-
function
|
|
100
|
-
e.status === "success" && (p.value = !0, fetch(e.url ?? "").then((
|
|
123
|
+
const p = h(!1);
|
|
124
|
+
function E(e) {
|
|
125
|
+
e.status === "success" && (p.value = !0, fetch(e.url ?? "").then((l) => l.blob()).then((l) => {
|
|
101
126
|
p.value = !1;
|
|
102
|
-
const
|
|
103
|
-
window.open(
|
|
127
|
+
const a = URL.createObjectURL(l);
|
|
128
|
+
window.open(a);
|
|
104
129
|
}).catch(() => {
|
|
105
130
|
p.value = !1;
|
|
106
131
|
}));
|
|
107
132
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
133
|
+
const r = h();
|
|
134
|
+
return L({
|
|
135
|
+
/** 取消(中止)正在进行的上传请求 */
|
|
136
|
+
abort: () => r.value?.abort(),
|
|
137
|
+
/** 手动提交文件列表,配合 `auto-upload=false` 使用 */
|
|
138
|
+
submit: () => r.value?.submit(),
|
|
139
|
+
/** 清空文件列表;可传状态数组只清指定状态(如 `['ready']`) */
|
|
140
|
+
clearFiles: (e) => r.value?.clearFiles(e),
|
|
141
|
+
/** 手动把文件加入上传列表(等价于用户选择文件) */
|
|
142
|
+
handleStart: (e) => r.value?.handleStart(e),
|
|
143
|
+
/** 手动从列表移除某个文件 */
|
|
144
|
+
handleRemove: (e) => r.value?.handleRemove(e)
|
|
145
|
+
}), (e, l) => {
|
|
146
|
+
const a = O("el-upload"), i = W("loading");
|
|
147
|
+
return G((f(), m("div", te, [
|
|
148
|
+
b(a, H({
|
|
149
|
+
ref_key: "uploadRef",
|
|
150
|
+
ref: r
|
|
151
|
+
}, _.value, { "before-upload": M }), {
|
|
152
|
+
file: g((o) => [
|
|
153
|
+
e.$slots.file ? w(e.$slots, "file", J(Q(o)), void 0, !0, 0) : (f(), m("div", oe, [
|
|
154
|
+
z("img", {
|
|
118
155
|
class: "zl-upload__item-thumbnail",
|
|
119
|
-
src:
|
|
120
|
-
onClick: (
|
|
121
|
-
}, null, 8,
|
|
122
|
-
|
|
156
|
+
src: o.file.url,
|
|
157
|
+
onClick: (y) => E(o.file)
|
|
158
|
+
}, null, 8, ae),
|
|
159
|
+
z("span", {
|
|
123
160
|
class: "zl-upload__item-name",
|
|
124
|
-
title:
|
|
125
|
-
},
|
|
126
|
-
|
|
161
|
+
title: o.file.name
|
|
162
|
+
}, $(o.file.name), 9, ie),
|
|
163
|
+
k.value && o.file.status === "success" && o.file.url ? (f(), m("a", {
|
|
127
164
|
key: 0,
|
|
128
165
|
class: "zl-upload__item-op",
|
|
129
|
-
href:
|
|
130
|
-
download:
|
|
166
|
+
href: o.file.url,
|
|
167
|
+
download: o.file.name
|
|
131
168
|
}, [
|
|
132
|
-
|
|
133
|
-
], 8,
|
|
134
|
-
])
|
|
169
|
+
b(R, { icon: "zl:download" })
|
|
170
|
+
], 8, se)) : x("", !0)
|
|
171
|
+
]))
|
|
172
|
+
]),
|
|
173
|
+
tip: g(() => [
|
|
174
|
+
w(e.$slots, "tip", {}, void 0, !0)
|
|
135
175
|
]),
|
|
136
|
-
default:
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
176
|
+
default: g(() => [
|
|
177
|
+
w(e.$slots, "default", {}, () => [
|
|
178
|
+
z("div", le, [
|
|
179
|
+
b(R, { icon: "zl:add" })
|
|
140
180
|
])
|
|
141
181
|
], !0)
|
|
142
182
|
]),
|
|
143
183
|
_: 3
|
|
144
184
|
}, 16),
|
|
145
|
-
|
|
185
|
+
_.value.__tip && !e.$slots.tip ? (f(), m("div", re, $(_.value.__tip), 1)) : x("", !0)
|
|
146
186
|
])), [
|
|
147
|
-
[
|
|
187
|
+
[i, p.value]
|
|
148
188
|
]);
|
|
149
189
|
};
|
|
150
190
|
}
|
|
151
191
|
});
|
|
152
192
|
export {
|
|
153
|
-
|
|
193
|
+
fe as default
|
|
154
194
|
};
|
|
155
195
|
//# sourceMappingURL=index2.vue.mjs.map
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export { default as ZlAppSlogan } from './components/ZlAppSlogan/index.vue';
|
|
|
8
8
|
export { default as ZlAutoTooltip } from './components/ZlAutoTooltip/index.vue';
|
|
9
9
|
export { default as ZlAvatar } from './components/ZlAvatar/index.vue';
|
|
10
10
|
export { default as ZlAvatarGroup } from './components/ZlAvatar/Group.vue';
|
|
11
|
+
export { default as ZlBreadcrumb } from './components/ZlBreadcrumb/index.vue';
|
|
11
12
|
export { default as ZlCard } from './components/ZlCard/index.vue';
|
|
12
13
|
export { default as ZlCardPage } from './components/ZlCardPage/index.vue';
|
|
13
14
|
export { default as ZlCheckAll } from './components/ZlCheckAll/index.vue';
|
|
@@ -64,6 +65,7 @@ export { usePermission, usePermissionProvider } from './components/ZlPermission/
|
|
|
64
65
|
export type { MenuItem } from './components/ZlAppMenu/AppMenu.vue';
|
|
65
66
|
export type { MenuOption } from './components/ZlMenu/types';
|
|
66
67
|
export type { StepItem } from './components/ZlStep/index.vue';
|
|
68
|
+
export type { BreadcrumbItem } from './components/ZlBreadcrumb/types';
|
|
67
69
|
export type { ActionItem, FormItem, SearchItem, TableColumn } from './types';
|
|
68
70
|
export type { IGridItem } from './components/ZlGrid/types';
|
|
69
71
|
export type { IComponent, IComponentSlot, VForSlot, VModelSlot, ComponentOrSlot, } from './components/ZlDynamicComponent/types';
|