@qynpm/ui 1.0.35 → 1.0.36

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.
Files changed (65) hide show
  1. package/README.md +63 -28
  2. package/dist/index.cjs +4 -3
  3. package/dist/index.mjs +60 -58
  4. package/dist/qy-action-bar/index.cjs +1 -1
  5. package/dist/qy-action-bar/index.mjs +1 -1
  6. package/dist/qy-dialog/index.cjs +1 -1
  7. package/dist/qy-dialog/index.mjs +1 -1
  8. package/dist/qy-drawer/index.cjs +1 -1
  9. package/dist/qy-drawer/index.mjs +1 -1
  10. package/dist/qy-file-picker/index.cjs +1 -1
  11. package/dist/qy-file-picker/index.mjs +1 -1
  12. package/dist/qy-form-section/index.cjs +1 -1
  13. package/dist/qy-form-section/index.mjs +1 -1
  14. package/dist/qy-image-upload/index.cjs +1 -1
  15. package/dist/qy-image-upload/index.mjs +1 -1
  16. package/dist/qy-input-number/index.cjs +1 -1
  17. package/dist/qy-input-number/index.mjs +1 -1
  18. package/dist/qy-input-tag/index.cjs +1 -0
  19. package/dist/qy-input-tag/index.mjs +7 -0
  20. package/dist/qy-legacy-selection-dialog/index.cjs +1 -1
  21. package/dist/qy-legacy-selection-dialog/index.mjs +1 -1
  22. package/dist/qy-money-input/index.cjs +1 -1
  23. package/dist/qy-money-input/index.mjs +5 -2
  24. package/dist/qy-record-quote-search/index.cjs +1 -1
  25. package/dist/qy-record-quote-search/index.mjs +1 -1
  26. package/dist/qy-remark-image/index.cjs +1 -1
  27. package/dist/qy-remark-image/index.mjs +1 -1
  28. package/dist/qy-remote-select/index.cjs +1 -1
  29. package/dist/qy-remote-select/index.mjs +1 -1
  30. package/dist/qy-search-input/index.cjs +1 -1
  31. package/dist/qy-search-input/index.mjs +1 -1
  32. package/dist/qy-selection-dialog/index.cjs +1 -1
  33. package/dist/qy-selection-dialog/index.mjs +1 -1
  34. package/dist/qy-upload/index.cjs +1 -1
  35. package/dist/qy-upload/index.mjs +5 -2
  36. package/dist/shared/index-BYX0biqw.mjs +766 -0
  37. package/dist/shared/index-BxxwEr52.mjs +107 -0
  38. package/dist/shared/index-C1i-hd-W.cjs +1 -0
  39. package/dist/shared/index-D654b42n.mjs +2754 -0
  40. package/dist/shared/index-DnNIseRJ.cjs +1 -0
  41. package/dist/shared/index-aIqtIYsu.cjs +1 -0
  42. package/dist/shared/index.vue_vue_type_script_setup_true_lang-BiIgNax-.cjs +1 -0
  43. package/dist/shared/index.vue_vue_type_script_setup_true_lang-DIWWHODS.mjs +197 -0
  44. package/dist/shared/index.vue_vue_type_script_setup_true_lang-DwFGEW4B.mjs +143 -0
  45. package/dist/shared/index.vue_vue_type_script_setup_true_lang-ccFLNRry.cjs +1 -0
  46. package/dist/shared/index.vue_vue_type_style_index_0_lang-B1FgJZbw.mjs +148 -0
  47. package/dist/shared/index.vue_vue_type_style_index_0_lang-DVXf-yUs.cjs +1 -0
  48. package/index.d.ts +82 -25
  49. package/package.json +489 -483
  50. package/qy-file-picker/index.d.ts +4 -1
  51. package/qy-image-preview/index.d.ts +0 -1
  52. package/qy-image-upload/index.d.ts +69 -12
  53. package/qy-input/index.d.ts +76 -18
  54. package/qy-input-number/index.d.ts +64 -30
  55. package/qy-input-tag/index.d.ts +69 -0
  56. package/qy-money-input/index.d.ts +87 -12
  57. package/qy-upload/index.d.ts +99 -5
  58. package/dist/shared/index-BekN1g_r.mjs +0 -3541
  59. package/dist/shared/index-BkX9xlbI.cjs +0 -1
  60. package/dist/shared/index-C_1KP3l9.mjs +0 -129
  61. package/dist/shared/index-Ce_hvR--.cjs +0 -1
  62. package/dist/shared/index.vue_vue_type_style_index_0_lang-B0CXLnL1.mjs +0 -132
  63. package/dist/shared/index.vue_vue_type_style_index_0_lang-DccRGtZE.cjs +0 -1
  64. /package/dist/shared/{index.vue_vue_type_script_setup_true_lang-q37rBg6Z.mjs → index.vue_vue_type_script_setup_true_lang-CGsXVhJy.mjs} +0 -0
  65. /package/dist/shared/{index.vue_vue_type_script_setup_true_lang-CglCPcj-.cjs → index.vue_vue_type_script_setup_true_lang-Dk83TGiU.cjs} +0 -0
@@ -0,0 +1,766 @@
1
+ import { ElUpload as Ge, ElIcon as Ye, ElPopover as Ze, ElInput as Ee, ElImageViewer as et, ElDialog as tt } from "element-plus/es";
2
+ import { ref as m, onMounted as lt, computed as h, watch as le, toRaw as Ue, nextTick as nt, onBeforeUnmount as at, openBlock as w, createElementBlock as V, normalizeStyle as it, normalizeClass as ne, createElementVNode as b, createVNode as F, createSlots as ot, withCtx as j, withModifiers as v, unref as ke, Fragment as ae, toDisplayString as P, createCommentVNode as B, renderSlot as st, createBlock as ut, createTextVNode as W } from "vue";
3
+ import { Plus as rt, InfoFilled as dt } from "@element-plus/icons-vue";
4
+ import { ElMessage as U, ElLoading as ct } from "element-plus";
5
+ import { _ as pt } from "./_plugin-vue_export-helper-CHgC5LLL.mjs";
6
+ /*! js-cookie v3.0.8 | MIT */
7
+ function H(o) {
8
+ for (var R = 1; R < arguments.length; R++) {
9
+ var S = arguments[R];
10
+ for (var n in S)
11
+ n !== "__proto__" && (o[n] = S[n]);
12
+ }
13
+ return o;
14
+ }
15
+ var ft = {
16
+ read: function(o) {
17
+ return o[0] === '"' && (o = o.slice(1, -1)), o.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent);
18
+ },
19
+ write: function(o) {
20
+ return encodeURIComponent(o).replace(
21
+ /%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,
22
+ decodeURIComponent
23
+ );
24
+ }
25
+ };
26
+ function ie(o, R) {
27
+ function S(u, C, p) {
28
+ if (!(typeof document > "u")) {
29
+ p = H({}, R, p), typeof p.expires == "number" && (p.expires = new Date(Date.now() + p.expires * 864e5)), p.expires && (p.expires = p.expires.toUTCString()), u = encodeURIComponent(u).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape);
30
+ var y = "";
31
+ for (var s in p)
32
+ p[s] && (y += "; " + s, p[s] !== !0 && (y += "=" + p[s].split(";")[0]));
33
+ return document.cookie = u + "=" + o.write(C, u) + y;
34
+ }
35
+ }
36
+ function n(u) {
37
+ if (!(typeof document > "u" || arguments.length && !u)) {
38
+ for (var C = document.cookie ? document.cookie.split("; ") : [], p = {}, y = 0; y < C.length; y++) {
39
+ var s = C[y].split("="), _ = s.slice(1).join("=");
40
+ try {
41
+ var D = decodeURIComponent(s[0]);
42
+ if (D in p || (p[D] = o.read(_, D)), u === D)
43
+ break;
44
+ } catch {
45
+ }
46
+ }
47
+ return u ? p[u] : p;
48
+ }
49
+ }
50
+ return Object.create(
51
+ {
52
+ set: S,
53
+ get: n,
54
+ remove: function(u, C) {
55
+ S(
56
+ u,
57
+ "",
58
+ H({}, C, {
59
+ expires: -1
60
+ })
61
+ );
62
+ },
63
+ withAttributes: function(u) {
64
+ return ie(this.converter, H({}, this.attributes, u));
65
+ },
66
+ withConverter: function(u) {
67
+ return ie(H({}, this.converter, u), this.attributes);
68
+ }
69
+ },
70
+ {
71
+ attributes: { value: Object.freeze(R) },
72
+ converter: { value: Object.freeze(o) }
73
+ }
74
+ );
75
+ }
76
+ var mt = ie(ft, { path: "/" });
77
+ const vt = "Admin-Token";
78
+ function gt(o = vt) {
79
+ return mt.get(o);
80
+ }
81
+ const yt = ["accept", "multiple", "disabled"], xt = ["disabled"], ht = { class: "qy-upload__hint" }, wt = ["placeholder", "disabled"], bt = ["src"], Ut = {
82
+ key: 1,
83
+ class: "qy-upload__tip"
84
+ }, kt = { class: "error" }, Vt = { class: "error" }, Rt = /* @__PURE__ */ Object.assign({
85
+ name: "QyUpload"
86
+ }, {
87
+ __name: "index",
88
+ props: {
89
+ /**
90
+ * 受控值。valueFormat 为 object 时结构为 { files, text },
91
+ * array 时为 string[],string 时为逗号分隔 URL。
92
+ */
93
+ modelValue: { type: [Object, Array, String], default: void 0 },
94
+ /** 已选择的浏览器本地文件,不与上传完成后的远程值混用。 */
95
+ selectedFiles: { type: Array, default: () => [] },
96
+ /** 是否在选择后立即上传;false 时只维护 selectedFiles。 */
97
+ autoUpload: { type: Boolean, default: !0 },
98
+ /** Qy 展示模式:media-card | file-list。 */
99
+ variant: { type: String, default: "media-card" },
100
+ /**
101
+ * 初始值,结构为 { files: '逗号分隔的URL', text: '文字内容' }
102
+ * 非受控模式,仅初始化时读取一次
103
+ */
104
+ defaultValue: { type: Object, default: () => ({ files: "", text: "" }) },
105
+ /** v-model 输出格式:object | array | string */
106
+ valueFormat: { type: String, default: "object" },
107
+ /** 是否显示底部文字备注区 */
108
+ showText: { type: Boolean, default: !0 },
109
+ /** 是否显示纯粘贴输入条,不保存文字,仅用于承接 Ctrl+V 图片 */
110
+ showPasteInput: { type: Boolean, default: !1 },
111
+ /** 文字区占位文案,也用于凭证上传的粘贴提示 */
112
+ pastePlaceholder: { type: String, default: "输入文字" },
113
+ /** 是否多选 */
114
+ multiple: { type: Boolean, default: !0 },
115
+ /** 是否禁用 */
116
+ disabled: { type: Boolean, default: !1 },
117
+ /** 允许的文件类型后缀(如 ['jpg', 'mp4']) */
118
+ fileType: { type: Array, default: () => [] },
119
+ /** 单个文件大小限制(MB) */
120
+ fileSize: { type: Number, default: 10 },
121
+ /** 文件数量限制 */
122
+ limit: { type: Number, default: 9 },
123
+ /** 是否显示格式/大小提示 */
124
+ isShowTip: { type: Boolean, default: !1 },
125
+ /** 接口路径 */
126
+ api: { type: String, default: "/permission-api/common/uploads" },
127
+ /** FormData 中文件字段名 */
128
+ name: { type: String, default: "file" },
129
+ /** token 读取 key,对应 utils/auth 中的存储字段 */
130
+ tokenKey: { type: String, default: "Admin-Token" },
131
+ /** 是否支持视频模式(强制 limit=1) */
132
+ supportVideo: { type: Boolean, default: !1 },
133
+ /**
134
+ * 卡片尺寸
135
+ * 预设:'large'(160px) | 'default'(140px) | 'small'(80px)
136
+ * 自定义:任意 CSS 单位,如 '60px'、'8vw'
137
+ */
138
+ size: { type: String, default: "default" },
139
+ /** 禁用拖拽(默认在触发区开启) */
140
+ disableDrag: { type: Boolean, default: !1 },
141
+ /** 成功回调(用于复杂业务联动) */
142
+ callBack: { type: Function, default: null },
143
+ /** 上传时附加的额外 FormData 字段 */
144
+ extraData: { type: Object, default: () => ({}) },
145
+ /** 自定义上传请求,用于接入宿主项目 request / 鉴权 / baseURL。 */
146
+ uploadRequest: { type: Function, default: null }
147
+ },
148
+ emits: [
149
+ "update:modelValue",
150
+ "update:selectedFiles",
151
+ "selectedFilesChange",
152
+ "change",
153
+ "success",
154
+ "error",
155
+ "remove",
156
+ "invalid"
157
+ ],
158
+ setup(o, { expose: R, emit: S }) {
159
+ const n = o, u = S, C = m(null), p = m(null), y = m(null), s = m([]), _ = m(null), D = m(null), T = [], oe = /* @__PURE__ */ new WeakMap();
160
+ let X = Date.now(), J = !1;
161
+ const Q = m(!1), G = m([]), se = m(0), q = m(!1), ue = m(""), re = m(""), O = /* @__PURE__ */ new Set(), M = m(!1), x = m(""), Y = m(!1);
162
+ lt(() => {
163
+ n.modelValue !== void 0 || !n.autoUpload || pe(n.defaultValue);
164
+ });
165
+ const Ve = h(() => ({ large: "160px", default: "140px", small: "80px" })[n.size] ?? n.size), $ = h(() => n.disabled), Re = h(
166
+ () => s.value.some((e) => e.status === "uploading")
167
+ ), Ce = h(
168
+ () => n.variant === "file-list" || n.supportVideo ? "text" : "picture-card"
169
+ ), Fe = h(() => n.supportVideo ? 1 : !n.autoUpload && !n.multiple ? 2 : n.limit), Be = h(
170
+ () => {
171
+ var e;
172
+ return n.isShowTip && (n.fileSize || ((e = k.value) == null ? void 0 : e.length));
173
+ }
174
+ ), k = h(() => {
175
+ var e;
176
+ return (e = n.fileType) != null && e.length ? n.fileType.map((t) => String(t).trim().replace(/^\./, "").toLowerCase()).filter(Boolean) : n.variant === "file-list" ? [] : n.supportVideo ? ["mp4", "mov", "avi"] : ["jpg", "jpeg", "png", "gif", "webp"];
177
+ }), N = h(() => {
178
+ if (!n.autoUpload && !n.multiple) return !1;
179
+ const e = n.supportVideo ? 1 : n.limit;
180
+ return s.value.length >= e;
181
+ }), de = h(
182
+ () => k.value.map((e) => `.${e}`).join(",")
183
+ ), Se = h(() => ({
184
+ "qy-upload--reached-limit": N.value,
185
+ "qy-upload--disabled": n.disabled,
186
+ "qy-upload--video": n.supportVideo,
187
+ "qy-upload--without-text": !n.showText && !n.showPasteInput
188
+ }));
189
+ le(x, () => {
190
+ J || L();
191
+ }), le(
192
+ () => n.modelValue,
193
+ (e) => {
194
+ n.autoUpload && e !== void 0 && pe(e);
195
+ },
196
+ { immediate: !0, deep: !0 }
197
+ ), le(
198
+ () => [n.autoUpload, n.selectedFiles],
199
+ ([e, t]) => {
200
+ e || (s.value = z(t));
201
+ },
202
+ { immediate: !0, deep: !0 }
203
+ );
204
+ function ce(e) {
205
+ return Array.isArray(e) ? e.filter(Boolean) : e ? String(e).split(",").filter(Boolean) : [];
206
+ }
207
+ function je(e) {
208
+ return Array.isArray(e) ? { files: e, text: "" } : typeof e == "string" ? { files: ce(e), text: "" } : e && typeof e == "object" ? {
209
+ files: ce(e.files),
210
+ text: e.text ?? ""
211
+ } : { files: [], text: "" };
212
+ }
213
+ function De(e = []) {
214
+ return e.map((t, l) => ({
215
+ name: String(t).split("/").pop() || `file-${l}`,
216
+ url: t,
217
+ status: "success",
218
+ uid: Date.now() + l
219
+ }));
220
+ }
221
+ function z(e = []) {
222
+ return e.filter(Boolean).map((t, l) => {
223
+ const a = Ue(t);
224
+ return {
225
+ name: a.name,
226
+ raw: a,
227
+ status: "ready",
228
+ uid: Te(a, l)
229
+ };
230
+ });
231
+ }
232
+ function Te(e, t) {
233
+ if (e.uid != null) return e.uid;
234
+ const l = oe.get(e);
235
+ return l ?? (X += t + 1, oe.set(e, X), X);
236
+ }
237
+ function Z(e = s.value) {
238
+ return e.map((t) => {
239
+ const l = t.raw ?? (t instanceof File ? t : null);
240
+ return l ? Ue(l) : null;
241
+ }).filter(Boolean);
242
+ }
243
+ function K(e) {
244
+ u("update:selectedFiles", e), u("selectedFilesChange", e);
245
+ }
246
+ function qe(e, t) {
247
+ if (n.autoUpload) return;
248
+ const l = e == null ? void 0 : e.raw;
249
+ if (l && !E(l)) {
250
+ s.value = z(n.selectedFiles);
251
+ return;
252
+ }
253
+ const a = Z(t);
254
+ l && !a.includes(l) && a.push(l);
255
+ const i = n.multiple ? a : a.slice(-1);
256
+ s.value = z(i), K(i);
257
+ }
258
+ function ze(e) {
259
+ const t = new Set(e.map((a) => a.url)), l = s.value.filter(
260
+ (a) => a.status === "uploading" && !t.has(a.url)
261
+ );
262
+ return [...e, ...l];
263
+ }
264
+ function pe(e) {
265
+ const t = je(e);
266
+ J = !0, x.value = t.text, s.value = ze(De(t.files)), nt(() => {
267
+ J = !1;
268
+ });
269
+ }
270
+ function fe(e) {
271
+ return n.valueFormat === "array" ? e.files : n.valueFormat === "string" ? e.files.join(",") : e;
272
+ }
273
+ function Le() {
274
+ var e;
275
+ (e = _.value) == null || e.focus();
276
+ }
277
+ function Ie(e) {
278
+ e.target.value = "";
279
+ }
280
+ function L(e) {
281
+ const a = { files: (e ?? s.value).filter((i) => i.status === "success" && i.url).map((i) => i.url), text: x.value };
282
+ u("update:modelValue", fe(a)), u("change", a), n.callBack && n.callBack(a);
283
+ }
284
+ function Ae(e, t) {
285
+ if (!n.autoUpload) {
286
+ const l = Z(t);
287
+ s.value = z(l), K(l), u("remove", e, t);
288
+ return;
289
+ }
290
+ L(t), u("remove", e, t);
291
+ }
292
+ function me(e) {
293
+ var l;
294
+ const t = (e == null ? void 0 : e.name) || "";
295
+ return t.includes(".") && ((l = t.split(".").pop()) == null ? void 0 : l.toLowerCase()) || "";
296
+ }
297
+ function ve(e) {
298
+ var i, r, c;
299
+ const t = ((r = (i = e == null ? void 0 : e.type) == null ? void 0 : i.toLowerCase) == null ? void 0 : r.call(i)) || "", l = {
300
+ "image/jpeg": ["jpg", "jpeg"],
301
+ "image/png": ["png"],
302
+ "image/gif": ["gif"],
303
+ "image/bmp": ["bmp"],
304
+ "image/webp": ["webp"],
305
+ "video/mp4": ["mp4"],
306
+ "video/quicktime": ["mov"],
307
+ "video/x-msvideo": ["avi"],
308
+ "video/webm": ["webm"]
309
+ };
310
+ if (l[t]) return l[t];
311
+ const a = (c = t.split("/")[1]) == null ? void 0 : c.split("+")[0];
312
+ return a ? [a] : [];
313
+ }
314
+ function Pe(e) {
315
+ if (!k.value.length) return !0;
316
+ const t = me(e), l = ve(e);
317
+ return [t, ...l].some(
318
+ (a) => k.value.includes(a)
319
+ );
320
+ }
321
+ function E(e) {
322
+ if (n.fileSize > 0 && e.size > n.fileSize * 1024 * 1024) {
323
+ const l = {
324
+ code: "size",
325
+ file: e,
326
+ message: `文件大小不能超过${n.fileSize}M`
327
+ };
328
+ return U.warning(l.message), u("invalid", l), !1;
329
+ }
330
+ if (!Pe(e)) {
331
+ const l = {
332
+ code: "extension",
333
+ file: e,
334
+ message: `格式不支持,仅允许: ${k.value.join("/")}`
335
+ };
336
+ return U.warning(l.message), u("invalid", l), !1;
337
+ }
338
+ return !0;
339
+ }
340
+ async function _e(e, t, l, a) {
341
+ const i = ge(e);
342
+ try {
343
+ const r = await n.uploadRequest({
344
+ file: e,
345
+ formData: i,
346
+ api: n.api,
347
+ name: n.name,
348
+ tokenKey: n.tokenKey,
349
+ extraData: n.extraData
350
+ }), c = Oe(r);
351
+ if (!c) {
352
+ const d = new Error("上传失败,未返回文件地址");
353
+ U.error(d.message), u("error", d), l == null || l(d);
354
+ return;
355
+ }
356
+ U.success("上传成功"), t == null || t({ ...typeof r == "object" && r ? r : {}, url: c });
357
+ } catch (r) {
358
+ U.error("上传失败"), u("error", r), l == null || l(r);
359
+ } finally {
360
+ a.close();
361
+ }
362
+ }
363
+ function ge(e) {
364
+ const t = new FormData();
365
+ return t.append(n.name, e), n.extraData && Object.entries(n.extraData).forEach(([l, a]) => t.append(l, a)), t;
366
+ }
367
+ function Oe(e) {
368
+ var a, i;
369
+ if (typeof e == "string") return e;
370
+ const t = e || {}, l = t.urls ?? t.url ?? ((a = t.data) == null ? void 0 : a.urls) ?? ((i = t.data) == null ? void 0 : i.url) ?? "";
371
+ return Array.isArray(l) ? l[0] || "" : l || "";
372
+ }
373
+ function ye(e, t, l, a) {
374
+ const i = ct.service({
375
+ target: p.value,
376
+ text: "上传中",
377
+ background: "rgba(255,255,255,0.7)"
378
+ });
379
+ if (n.uploadRequest) {
380
+ _e(e, l, a, i);
381
+ return;
382
+ }
383
+ const r = n.api.startsWith("http") ? n.api : window.location.origin + n.api.replace(/^([^/])/, "/$1"), c = ge(e), d = new XMLHttpRequest();
384
+ T.push(d);
385
+ const A = () => {
386
+ const f = T.indexOf(d);
387
+ f !== -1 && T.splice(f, 1), i.close();
388
+ };
389
+ d.open("POST", r);
390
+ const g = gt(n.tokenKey);
391
+ g && d.setRequestHeader("Authorization", `Bearer ${g}`), d.upload.onprogress = (f) => {
392
+ f.total > 0 && (t == null || t({ percent: f.loaded / f.total * 100 }));
393
+ }, d.onload = () => {
394
+ if (A(), d.status < 200 || d.status >= 300) {
395
+ const f = `上传失败 (HTTP ${d.status})`;
396
+ U.error(f), u("error", { msg: f, status: d.status }), a == null || a(new Error(f));
397
+ return;
398
+ }
399
+ try {
400
+ const f = JSON.parse(d.responseText);
401
+ f.code === 200 && f.urls ? (U.success("上传成功"), l == null || l({ ...f, url: f.urls })) : (U.error(f.msg || "上传失败"), u("error", f), a == null || a(f));
402
+ } catch {
403
+ U.error("上传失败,响应格式错误"), u("error", new Error("Response parse error")), a == null || a(new Error("Response parse error"));
404
+ }
405
+ }, d.onerror = () => {
406
+ A(), U.error("上传失败,网络异常"), u("error", new Error("Network error")), a == null || a(new Error("Network error"));
407
+ }, d.send(c);
408
+ }
409
+ function xe(e) {
410
+ return n.disabled ? !1 : E(e);
411
+ }
412
+ function Me(e, t) {
413
+ const l = s.value.find(
414
+ (a) => {
415
+ var i;
416
+ return a.uid === (e == null ? void 0 : e.uid) || ((i = a.raw) == null ? void 0 : i.uid) === (e == null ? void 0 : e.uid);
417
+ }
418
+ );
419
+ l && (l.url = t, l.status = "success");
420
+ }
421
+ function $e(e) {
422
+ ye(
423
+ e.file,
424
+ e.onProgress,
425
+ (t) => {
426
+ Me(e.file, t.url), e.onSuccess(t), L(), u("success", t);
427
+ },
428
+ (t) => e.onError(t)
429
+ );
430
+ }
431
+ function Ne(e) {
432
+ var a;
433
+ if (!e.url) return;
434
+ const t = ((a = e.url.split(".").pop()) == null ? void 0 : a.toLowerCase()) || "";
435
+ if (["mp4", "mov", "avi", "webm"].includes(t)) {
436
+ ue.value = e.url, re.value = e.name || "视频预览", q.value = !0;
437
+ return;
438
+ }
439
+ const l = s.value.filter(
440
+ (i) => {
441
+ var r;
442
+ return i.status === "success" && i.url && !["mp4", "mov", "avi", "webm"].includes(
443
+ (r = i.url.split(".").pop()) == null ? void 0 : r.toLowerCase()
444
+ );
445
+ }
446
+ );
447
+ G.value = l.map((i) => i.url), se.value = l.findIndex((i) => i.uid === e.uid) || 0, Q.value = !0;
448
+ }
449
+ function Ke() {
450
+ Q.value = !1, G.value = [];
451
+ }
452
+ function We(e, t) {
453
+ if (e.name && me(e)) return e;
454
+ const l = ve(e).find(
455
+ (a) => k.value.includes(a)
456
+ );
457
+ return l ? new File([e], `paste-${Date.now() + t}.${l}`, {
458
+ type: e.type,
459
+ lastModified: e.lastModified
460
+ }) : e;
461
+ }
462
+ function ee(e) {
463
+ if (!n.autoUpload) {
464
+ const t = Z(), l = e.filter((i) => E(i));
465
+ if (!l.length) return;
466
+ const a = n.multiple ? [...t, ...l].slice(0, n.limit) : l.slice(-1);
467
+ s.value = z(a), K(a);
468
+ return;
469
+ }
470
+ for (let t = 0; t < e.length; t++) {
471
+ const l = We(e[t], t);
472
+ if (!xe(l)) continue;
473
+ const a = Date.now() + t, i = URL.createObjectURL(l);
474
+ O.add(i), s.value.push({
475
+ uid: a,
476
+ name: l.name || `file-${a}`,
477
+ status: "uploading",
478
+ percentage: 0,
479
+ url: i
480
+ }), ye(
481
+ l,
482
+ (r) => {
483
+ const c = s.value.find((d) => d.uid === a);
484
+ c && (c.percentage = r.percent);
485
+ },
486
+ (r) => {
487
+ const c = s.value.find((d) => d.uid === a);
488
+ c && (c.status = "success", c.url = r.url, L(), u("success", r));
489
+ },
490
+ () => Je(a)
491
+ );
492
+ }
493
+ }
494
+ function He(e) {
495
+ const t = e.target, l = Array.from(t.files || []);
496
+ if (t.value = "", n.disabled || !l.length) return;
497
+ const a = n.supportVideo || !n.multiple ? l.slice(0, 1) : l;
498
+ ee(a);
499
+ }
500
+ function Xe(e) {
501
+ const t = Array.from((e == null ? void 0 : e.files) || []).filter(
502
+ (r) => {
503
+ var c;
504
+ return (c = r.type) == null ? void 0 : c.startsWith("image/");
505
+ }
506
+ );
507
+ if (t.length) return t;
508
+ const l = e == null ? void 0 : e.items;
509
+ if (!l) return [];
510
+ const a = [], i = /* @__PURE__ */ new Set();
511
+ for (let r = 0; r < l.length; r++) {
512
+ const c = l[r];
513
+ if (c.kind === "file" && c.type.startsWith("image/")) {
514
+ const d = c.getAsFile();
515
+ d && !i.has(d) && (i.add(d), a.push(d));
516
+ }
517
+ }
518
+ return a;
519
+ }
520
+ function I(e) {
521
+ if (n.disabled) return;
522
+ const t = Xe(e.clipboardData);
523
+ t.length && (e.preventDefault(), ee(t));
524
+ }
525
+ function he() {
526
+ n.disabled || n.disableDrag || (M.value = !0);
527
+ }
528
+ function we() {
529
+ M.value = !1;
530
+ }
531
+ function be(e) {
532
+ var l;
533
+ if (M.value = !1, n.disabled || n.disableDrag || N.value) return;
534
+ const t = Array.from(((l = e.dataTransfer) == null ? void 0 : l.files) || []);
535
+ t.length && ee(t);
536
+ }
537
+ function Je(e) {
538
+ var l;
539
+ const t = s.value.findIndex((a) => a.uid === e);
540
+ t !== -1 && ((l = s.value[t].url) != null && l.startsWith("blob:") && (URL.revokeObjectURL(s.value[t].url), O.delete(s.value[t].url)), s.value.splice(t, 1));
541
+ }
542
+ at(() => {
543
+ T.forEach((e) => e.abort()), T.length = 0, O.forEach((e) => URL.revokeObjectURL(e)), O.clear();
544
+ });
545
+ function te() {
546
+ var e;
547
+ n.disabled || N.value || (e = y.value) == null || e.click();
548
+ }
549
+ function Qe() {
550
+ s.value = [], x.value = "", K([]), n.autoUpload && L();
551
+ }
552
+ return R({
553
+ /** 主动打开文件选择框,供表单或快捷操作调用 */
554
+ openFileDialog: te,
555
+ /** 获取已上传成功的文件 URL 列表 */
556
+ getPathList: () => s.value.filter((e) => e.status === "success").map((e) => e.url),
557
+ /** 清空文件和文字,并同步 change 事件 */
558
+ clearFiles: Qe,
559
+ /** 获取完整值,结构与 change 事件保持一致 */
560
+ getValue: () => ({
561
+ files: s.value.filter((e) => e.status === "success" && e.url).map((e) => e.url),
562
+ text: x.value
563
+ }),
564
+ /** 获取按 valueFormat 输出的值,便于外部不走 v-model 时读取 */
565
+ getModelValue: () => fe({
566
+ files: s.value.filter((e) => e.status === "success" && e.url).map((e) => e.url),
567
+ text: x.value
568
+ })
569
+ }), (e, t) => {
570
+ var A;
571
+ const l = Ye, a = Ee, i = Ze, r = Ge, c = et, d = tt;
572
+ return w(), V("div", {
573
+ ref_key: "rootRef",
574
+ ref: p,
575
+ class: ne(["qy-upload", Se.value]),
576
+ style: it({ "--qy-upload-size": Ve.value })
577
+ }, [
578
+ b("input", {
579
+ ref_key: "nativeInputRef",
580
+ ref: y,
581
+ class: "qy-upload__native-input",
582
+ type: "file",
583
+ accept: de.value,
584
+ multiple: o.supportVideo ? !1 : o.multiple,
585
+ disabled: $.value,
586
+ onChange: He
587
+ }, null, 40, yt),
588
+ F(r, {
589
+ ref_key: "uploadRef",
590
+ ref: C,
591
+ "file-list": s.value,
592
+ "onUpdate:fileList": t[7] || (t[7] = (g) => s.value = g),
593
+ action: "#",
594
+ multiple: o.supportVideo ? !1 : o.multiple,
595
+ limit: Fe.value,
596
+ "auto-upload": o.autoUpload,
597
+ "list-type": Ce.value,
598
+ accept: de.value,
599
+ disabled: $.value,
600
+ "http-request": $e,
601
+ "before-upload": xe,
602
+ "on-change": qe,
603
+ "on-preview": Ne,
604
+ "on-remove": Ae
605
+ }, ot({
606
+ default: j(() => [
607
+ o.variant !== "file-list" && !N.value ? (w(), V("div", {
608
+ key: 0,
609
+ class: ne(["qy-upload__trigger", { "is-dragover": M.value }]),
610
+ onPaste: I,
611
+ onDragover: v(he, ["prevent"]),
612
+ onDragleave: v(we, ["prevent"]),
613
+ onDrop: v(be, ["prevent"])
614
+ }, [
615
+ F(l, { class: "qy-upload__icon" }, {
616
+ default: j(() => [
617
+ F(ke(rt))
618
+ ]),
619
+ _: 1
620
+ }),
621
+ o.supportVideo ? (w(), V(ae, { key: 0 }, [
622
+ t[10] || (t[10] = b("span", { class: "qy-upload__label" }, "点击上传视频", -1)),
623
+ b("span", ht, "支持 " + P(k.value.join(" / ")) + ",不超过 " + P(o.fileSize) + "MB", 1)
624
+ ], 64)) : B("", !0),
625
+ o.showText ? (w(), V("div", {
626
+ key: 1,
627
+ class: "qy-upload__text",
628
+ onClick: t[4] || (t[4] = v(() => {
629
+ }, ["stop"])),
630
+ onPaste: v(I, ["stop"])
631
+ }, [
632
+ F(i, {
633
+ visible: Y.value,
634
+ "onUpdate:visible": t[3] || (t[3] = (g) => Y.value = g),
635
+ placement: "bottom-start",
636
+ width: 220,
637
+ trigger: "click",
638
+ "popper-class": "qy-upload__text-popover",
639
+ onAfterEnter: Le
640
+ }, {
641
+ reference: j(() => [
642
+ b("div", {
643
+ class: ne(["qy-upload__text-preview", { "is-placeholder": !x.value }])
644
+ }, P(x.value || o.pastePlaceholder), 3)
645
+ ]),
646
+ default: j(() => [
647
+ F(a, {
648
+ ref_key: "inputRef",
649
+ ref: _,
650
+ modelValue: x.value,
651
+ "onUpdate:modelValue": t[1] || (t[1] = (g) => x.value = g),
652
+ type: "textarea",
653
+ autosize: { minRows: 2, maxRows: 5 },
654
+ placeholder: o.pastePlaceholder,
655
+ disabled: o.disabled,
656
+ onBlur: t[2] || (t[2] = (g) => Y.value = !1),
657
+ onPaste: v(I, ["stop"])
658
+ }, null, 8, ["modelValue", "placeholder", "disabled"])
659
+ ]),
660
+ _: 1
661
+ }, 8, ["visible"])
662
+ ], 32)) : o.showPasteInput ? (w(), V("div", {
663
+ key: 2,
664
+ class: "qy-upload__text",
665
+ onClick: t[6] || (t[6] = v(() => {
666
+ }, ["stop"])),
667
+ onPaste: v(I, ["stop"])
668
+ }, [
669
+ b("input", {
670
+ ref_key: "pasteInputRef",
671
+ ref: D,
672
+ class: "qy-upload__paste-input",
673
+ placeholder: o.pastePlaceholder,
674
+ disabled: o.disabled,
675
+ onPaste: v(I, ["stop"]),
676
+ onInput: Ie,
677
+ onClick: t[5] || (t[5] = v(() => {
678
+ }, ["stop"]))
679
+ }, null, 40, wt)
680
+ ], 32)) : B("", !0)
681
+ ], 34)) : B("", !0)
682
+ ]),
683
+ _: 2
684
+ }, [
685
+ o.variant === "file-list" ? {
686
+ name: "trigger",
687
+ fn: j(() => [
688
+ b("div", {
689
+ class: "qy-upload__file-trigger",
690
+ onClick: t[0] || (t[0] = v(() => {
691
+ }, ["stop"])),
692
+ onDragover: v(he, ["prevent"]),
693
+ onDragleave: v(we, ["prevent"]),
694
+ onDrop: v(be, ["prevent"])
695
+ }, [
696
+ st(e.$slots, "trigger", {
697
+ open: te,
698
+ disabled: $.value,
699
+ uploading: Re.value
700
+ }, () => [
701
+ b("button", {
702
+ class: "qy-upload__file-button",
703
+ type: "button",
704
+ disabled: $.value,
705
+ onClick: te
706
+ }, " 选择文件 ", 8, xt)
707
+ ], !0)
708
+ ], 32)
709
+ ]),
710
+ key: "0"
711
+ } : void 0
712
+ ]), 1032, ["file-list", "multiple", "limit", "auto-upload", "list-type", "accept", "disabled"]),
713
+ Q.value ? (w(), ut(c, {
714
+ key: 0,
715
+ "url-list": G.value,
716
+ "initial-index": se.value,
717
+ onClose: Ke
718
+ }, null, 8, ["url-list", "initial-index"])) : B("", !0),
719
+ F(d, {
720
+ modelValue: q.value,
721
+ "onUpdate:modelValue": t[8] || (t[8] = (g) => q.value = g),
722
+ title: re.value,
723
+ width: "640px",
724
+ "append-to-body": "",
725
+ "destroy-on-close": "",
726
+ onClose: t[9] || (t[9] = (g) => q.value = !1)
727
+ }, {
728
+ default: j(() => [
729
+ q.value ? (w(), V("video", {
730
+ key: 0,
731
+ src: ue.value,
732
+ controls: "",
733
+ autoplay: "",
734
+ style: { width: "100%", "max-height": "400px", "border-radius": "4px" }
735
+ }, null, 8, bt)) : B("", !0)
736
+ ]),
737
+ _: 1
738
+ }, 8, ["modelValue", "title"]),
739
+ Be.value ? (w(), V("div", Ut, [
740
+ F(l, null, {
741
+ default: j(() => [
742
+ F(ke(dt))
743
+ ]),
744
+ _: 1
745
+ }),
746
+ b("span", null, [
747
+ t[13] || (t[13] = W(" 请上传 ", -1)),
748
+ o.fileSize ? (w(), V(ae, { key: 0 }, [
749
+ t[11] || (t[11] = W("大小不超过 ", -1)),
750
+ b("b", kt, P(o.fileSize) + "MB", 1)
751
+ ], 64)) : B("", !0),
752
+ (A = k.value) != null && A.length ? (w(), V(ae, { key: 1 }, [
753
+ t[12] || (t[12] = W(",格式为 ", -1)),
754
+ b("b", Vt, P(k.value.join("/")), 1)
755
+ ], 64)) : B("", !0),
756
+ t[14] || (t[14] = W(" 的文件。 ", -1))
757
+ ])
758
+ ])) : B("", !0)
759
+ ], 6);
760
+ };
761
+ }
762
+ }), Dt = /* @__PURE__ */ pt(Rt, [["__scopeId", "data-v-3f7a045b"]]);
763
+ export {
764
+ Dt as U,
765
+ mt as a
766
+ };