disguise-ui 0.2.9 → 0.3.1

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,320 +0,0 @@
1
- import { t as e } from "./i18n-DejVnxC8.js";
2
- import { t } from "./_plugin-vue_export-helper-Djzt4Yr7.js";
3
- import { t as n } from "./use-image-url-Bs5WMZ6L.js";
4
- import { n as r, t as ee } from "./use-multiple-file-upload-BYN5Ddr9.js";
5
- import { Fragment as te, computed as i, createBlock as a, createCommentVNode as o, createElementBlock as s, createElementVNode as c, createVNode as l, defineComponent as u, normalizeClass as d, normalizeStyle as f, onBeforeUnmount as ne, openBlock as p, ref as m, renderList as re, toRefs as h, unref as g, watch as ie, withCtx as _, withModifiers as v } from "vue";
6
- import { ElIcon as y, ElImageViewer as ae, ElMessage as b, ElProgress as x, ElUpload as S } from "element-plus";
7
- import { Close as C, Download as w, Plus as T, ZoomIn as oe } from "@element-plus/icons-vue";
8
- // src/components/picture-upload/picture-upload.vue?vue&type=script&setup=true&lang.ts
9
- var se = { class: "picture-upload" }, ce = { class: "picture-upload__multiple-grid" }, le = ["src"], ue = ["aria-label", "onClick"], de = { class: "picture-upload__actions" }, fe = ["aria-label", "onClick"], pe = ["aria-label", "onClick"], me = ["src"], he = ["aria-label"], ge = { class: "picture-upload__actions" }, _e = ["aria-label"], ve = ["aria-label"], E = /*#__PURE__*/ t(/* @__PURE__ */ u({
10
- __name: "picture-upload",
11
- props: {
12
- modelValue: { default: "" },
13
- disabled: {
14
- type: Boolean,
15
- default: !1
16
- },
17
- maxSize: { default: 5 },
18
- accept: { default: () => ["image/*"] },
19
- width: { default: 96 },
20
- height: { default: 96 },
21
- showPreview: {
22
- type: Boolean,
23
- default: !0
24
- },
25
- showDownload: {
26
- type: Boolean,
27
- default: !0
28
- },
29
- showRemove: {
30
- type: Boolean,
31
- default: !0
32
- },
33
- selected: {
34
- type: Boolean,
35
- default: !1
36
- },
37
- errorMessage: { default: "" },
38
- baseFolder: { default: "" },
39
- addWatermark: { type: Boolean },
40
- maxCount: { default: 1 }
41
- },
42
- emits: [
43
- "update:modelValue",
44
- "uploadSuccess",
45
- "uploadError",
46
- "remove",
47
- "preview",
48
- "download"
49
- ],
50
- setup(t, { emit: u }) {
51
- let E = t, D = u, { resolveImageUrl: O } = n(), { accept: k, errorMessage: A, maxSize: j } = h(E), M = i(() => E.maxCount > 1 || Array.isArray(E.modelValue)), N = i(() => Array.isArray(E.modelValue) && E.modelValue.every((e) => typeof e == "string")), ye = (e) => typeof e == "string" ? { url: e } : e, P = i(() => Array.isArray(E.modelValue) ? E.modelValue.map(ye) : []), F = (e) => e ? N.value ? e.map((e) => e.fileUrl || e.url || "") : e : N.value ? [] : void 0, I = m(!1), L = m(""), R = m(!1), z = r({
52
- modelValue: i(() => {
53
- if (!M.value) return E.modelValue || void 0;
54
- }),
55
- maxSize: j,
56
- accept: k,
57
- errorMessage: A,
58
- baseFolder: i(() => E.baseFolder || void 0),
59
- addWatermark: i(() => E.addWatermark),
60
- onUpdate: (e) => {
61
- D("update:modelValue", e);
62
- },
63
- onUploadSuccess: (e) => {
64
- D("uploadSuccess", e);
65
- },
66
- onUploadError: (e) => {
67
- D("uploadError", e);
68
- },
69
- onRemove: (e) => {
70
- D("remove", e);
71
- },
72
- onPreview: (e) => {
73
- D("preview", e);
74
- },
75
- onDownload: (e) => {
76
- D("download", e);
77
- }
78
- }), B = ee({
79
- modelValue: i(() => M.value ? P.value : void 0),
80
- maxSize: j,
81
- accept: k,
82
- maxCount: h(E).maxCount,
83
- errorMessage: A,
84
- baseFolder: i(() => E.baseFolder || void 0),
85
- addWatermark: i(() => E.addWatermark),
86
- onUpdate: (e) => D("update:modelValue", F(e)),
87
- onUploadSuccess: (e) => D("uploadSuccess", e),
88
- onUploadError: (e) => D("uploadError", e),
89
- onRemove: (e) => D("remove", e),
90
- onPreview: (e) => D("preview", e),
91
- onDownload: (e) => D("download", e)
92
- }), V = i(() => ({
93
- width: `${E.width}px`,
94
- height: `${E.height}px`
95
- })), H = i(() => O(z.fileData.value?.fileUrl || z.fileData.value?.url || z.fileUrl.value || "")), U = i(() => P.value.map((e) => O(e.fileUrl || e.url || e.name || "")));
96
- ie(H, () => {
97
- R.value = !1;
98
- });
99
- let W = i(() => R.value && L.value ? L.value : H.value || L.value), G = m([]), K = m(0);
100
- function q() {
101
- L.value.startsWith("blob:") && (URL.revokeObjectURL(L.value), L.value = "");
102
- }
103
- function be() {
104
- L.value && W.value !== L.value && (R.value = !0);
105
- }
106
- ne(q);
107
- let J = i(() => M.value ? P.value.length === 0 && !B.loading.value : !W.value && !z.loading.value), Y = i(() => M.value ? B.acceptAttr.value : z.acceptAttr.value), X = i(() => M.value ? B.isError.value : z.isError.value), Z = i(() => ({
108
- "picture-upload__uploader--selected": E.selected && !J.value && !X.value,
109
- "picture-upload__uploader--error": X.value,
110
- "is-disabled": E.disabled
111
- }));
112
- function Q(e) {
113
- return M.value ? B.handleUpload(e) : (q(), L.value = URL.createObjectURL(e.file), R.value = !1, z.handleUpload(e));
114
- }
115
- function $(e) {
116
- return M.value ? B.beforeUpload(e) : z.beforeUpload(e);
117
- }
118
- function xe() {
119
- W.value && E.showPreview && (I.value = !0, z.fileData.value && D("preview", z.fileData.value));
120
- }
121
- function Se(e) {
122
- if (!E.showPreview || !U.value[e]) return;
123
- G.value = U.value, K.value = e, I.value = !0;
124
- let t = P.value[e];
125
- t && D("preview", t);
126
- }
127
- function Ce() {
128
- E.showDownload && (!W.value || !z.fileData.value ? b.error(e("components.fileUpload.fileDownloadError")) : z.handleDownload());
129
- }
130
- function we(t) {
131
- if (!E.showDownload) return;
132
- let n = O(t.fileUrl || t.url || t.name || "");
133
- if (!n) {
134
- b.error(e("components.fileUpload.fileDownloadError"));
135
- return;
136
- }
137
- let r = document.createElement("a");
138
- r.href = n, r.download = t.name || "image", r.click(), D("download", t);
139
- }
140
- function Te() {
141
- M.value || E.showRemove && !E.disabled && (q(), R.value = !1, z.handleRemove());
142
- }
143
- function Ee(e) {
144
- if (!E.showRemove || E.disabled) return;
145
- let t = e.fileUrl || e.url || e.name || "", n = P.value.filter((e) => (e.fileUrl || e.url || e.name || "") !== t);
146
- D("update:modelValue", F(n)), D("remove", e);
147
- }
148
- return (t, n) => (p(), s("div", se, [M.value ? (p(), a(g(S), {
149
- key: 0,
150
- class: d(["picture-upload__uploader picture-upload__uploader--multiple", Z.value]),
151
- "show-file-list": !1,
152
- multiple: !0,
153
- "before-upload": $,
154
- "http-request": Q,
155
- disabled: E.disabled || g(B).loading.value || E.maxCount > 1 && P.value.length >= E.maxCount,
156
- accept: Y.value
157
- }, {
158
- default: _(() => [c("div", ce, [
159
- (p(!0), s(te, null, re(P.value, (t, n) => (p(), s("div", {
160
- key: t.fileUrl || t.url || t.name || n,
161
- class: "picture-upload__image-wrap",
162
- style: f(V.value)
163
- }, [
164
- c("img", {
165
- class: "picture-upload__image",
166
- src: U.value[n],
167
- alt: "",
168
- referrerpolicy: "no-referrer"
169
- }, null, 8, le),
170
- E.showRemove && !E.disabled ? (p(), s("button", {
171
- key: 0,
172
- type: "button",
173
- class: "picture-upload__remove",
174
- "aria-label": g(e)("components.fileUpload.remove"),
175
- onClick: v((e) => Ee(t), ["stop", "prevent"])
176
- }, [l(g(y), { size: 12 }, {
177
- default: _(() => [l(g(C))]),
178
- _: 1
179
- })], 8, ue)) : o("", !0),
180
- c("div", de, [E.showPreview ? (p(), s("button", {
181
- key: 0,
182
- type: "button",
183
- class: "picture-upload__action",
184
- "aria-label": g(e)("components.fileUpload.preview"),
185
- onClick: v((e) => Se(n), ["stop", "prevent"])
186
- }, [l(g(y), {
187
- size: 20,
188
- color: "#fff"
189
- }, {
190
- default: _(() => [l(g(oe))]),
191
- _: 1
192
- })], 8, fe)) : o("", !0), E.showDownload ? (p(), s("button", {
193
- key: 1,
194
- type: "button",
195
- class: "picture-upload__action",
196
- "aria-label": g(e)("components.fileUpload.download"),
197
- onClick: v((e) => we(t), ["stop", "prevent"])
198
- }, [l(g(y), {
199
- size: 20,
200
- color: "#fff"
201
- }, {
202
- default: _(() => [l(g(w))]),
203
- _: 1
204
- })], 8, pe)) : o("", !0)])
205
- ], 4))), 128)),
206
- g(B).loading.value ? (p(), s("div", {
207
- key: 0,
208
- class: "picture-upload__loading",
209
- style: f(V.value)
210
- }, [l(g(x), {
211
- type: "circle",
212
- width: Math.min(E.width, E.height, 72),
213
- percentage: g(B).totalProgress.value
214
- }, null, 8, ["width", "percentage"])], 4)) : o("", !0),
215
- E.maxCount <= 1 || P.value.length < E.maxCount ? (p(), s("div", {
216
- key: 1,
217
- class: "picture-upload__placeholder",
218
- style: f(V.value)
219
- }, [l(g(y), {
220
- class: "picture-upload__placeholder-icon",
221
- size: 28
222
- }, {
223
- default: _(() => [l(g(T))]),
224
- _: 1
225
- })], 4)) : o("", !0)
226
- ])]),
227
- _: 1
228
- }, 8, [
229
- "class",
230
- "disabled",
231
- "accept"
232
- ])) : (p(), a(g(S), {
233
- key: 1,
234
- class: d(["picture-upload__uploader", Z.value]),
235
- "show-file-list": !1,
236
- "before-upload": $,
237
- "http-request": Q,
238
- disabled: E.disabled || g(z).loading.value,
239
- accept: Y.value
240
- }, {
241
- default: _(() => [g(z).loading.value ? (p(), s("div", {
242
- key: 0,
243
- class: "picture-upload__loading",
244
- style: f(V.value)
245
- }, [l(g(x), {
246
- type: "circle",
247
- width: Math.min(E.width, E.height, 72),
248
- percentage: g(z).uploadProgress.value
249
- }, null, 8, ["width", "percentage"])], 4)) : J.value ? (p(), s("div", {
250
- key: 2,
251
- class: "picture-upload__placeholder",
252
- style: f(V.value)
253
- }, [l(g(y), {
254
- class: "picture-upload__placeholder-icon",
255
- size: 28
256
- }, {
257
- default: _(() => [l(g(T))]),
258
- _: 1
259
- })], 4)) : (p(), s("div", {
260
- key: 1,
261
- class: "picture-upload__image-wrap",
262
- style: f(V.value)
263
- }, [
264
- c("img", {
265
- class: "picture-upload__image",
266
- src: W.value,
267
- alt: "",
268
- referrerpolicy: "no-referrer",
269
- onError: be
270
- }, null, 40, me),
271
- E.showRemove && !E.disabled ? (p(), s("button", {
272
- key: 0,
273
- type: "button",
274
- class: "picture-upload__remove",
275
- "aria-label": g(e)("components.fileUpload.remove"),
276
- onClick: v(Te, ["stop", "prevent"])
277
- }, [l(g(y), { size: 12 }, {
278
- default: _(() => [l(g(C))]),
279
- _: 1
280
- })], 8, he)) : o("", !0),
281
- c("div", ge, [E.showPreview ? (p(), s("button", {
282
- key: 0,
283
- type: "button",
284
- class: "picture-upload__action",
285
- "aria-label": g(e)("components.fileUpload.preview"),
286
- onClick: v(xe, ["stop", "prevent"])
287
- }, [l(g(y), {
288
- size: 20,
289
- color: "#fff"
290
- }, {
291
- default: _(() => [l(g(oe))]),
292
- _: 1
293
- })], 8, _e)) : o("", !0), E.showDownload ? (p(), s("button", {
294
- key: 1,
295
- type: "button",
296
- class: "picture-upload__action",
297
- "aria-label": g(e)("components.fileUpload.download"),
298
- onClick: v(Ce, ["stop", "prevent"])
299
- }, [l(g(y), {
300
- size: 20,
301
- color: "#fff"
302
- }, {
303
- default: _(() => [l(g(w))]),
304
- _: 1
305
- })], 8, ve)) : o("", !0)])
306
- ], 4))]),
307
- _: 1
308
- }, 8, [
309
- "class",
310
- "disabled",
311
- "accept"
312
- ])), I.value ? (p(), a(g(ae), {
313
- key: 2,
314
- "url-list": M.value ? G.value : [W.value],
315
- "initial-index": M.value ? K.value : 0,
316
- onClose: n[0] ||= (e) => I.value = !1
317
- }, null, 8, ["url-list", "initial-index"])) : o("", !0)]));
318
- }
319
- }), [["__scopeId", "data-v-ca80cce7"]]);
320
- export { E as t };