@opentiny/tiny-robot 0.3.0-alpha.9 → 0.3.0-rc.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,7 +1,7 @@
1
- import { defineComponent as $, useSlots as H, computed as i, ref as f, watch as N, nextTick as W, createElementBlock as _, openBlock as o, createBlock as v, createCommentVNode as R, Fragment as G, renderList as I, unref as h, withCtx as S, createElementVNode as w, resolveDynamicComponent as x, renderSlot as L, createVNode as E, Transition as j, withDirectives as q, normalizeClass as J, withModifiers as K, toDisplayString as Q, vShow as U } from "vue";
2
- import { c as Y } from "../tiny-robot-svgs.js";
3
- import { T as M } from "../index5.js";
4
- import { o as Z, b as ee } from "../index2.js";
1
+ import { defineComponent as $, useSlots as H, computed as i, ref as f, watch as I, nextTick as W, createElementBlock as _, openBlock as o, createBlock as v, createCommentVNode as N, Fragment as R, renderList as G, unref as h, withCtx as S, createElementVNode as w, resolveDynamicComponent as x, renderSlot as L, createVNode as E, Transition as j, withDirectives as q, normalizeClass as J, withModifiers as K, toDisplayString as Q, vShow as U } from "vue";
2
+ import { IconMenu as Y } from "@opentiny/tiny-robot-svgs";
3
+ import { TinyTooltip as M } from "@opentiny/vue";
4
+ import { o as Z, c as ee } from "../index2.js";
5
5
  import te from "../icon-button/index.js";
6
6
  import { _ as oe } from "../_plugin-vue_export-helper.js";
7
7
  const ne = { class: "tr-action-group" }, re = ["onClick"], le = ["onClick"], ae = { class: "tr-action-group__dropdown-item-text" }, ce = /* @__PURE__ */ $({
@@ -17,10 +17,10 @@ const ne = { class: "tr-action-group" }, re = ["onClick"], le = ["onClick"], ae
17
17
  var a, t;
18
18
  const e = F.default();
19
19
  return Array.isArray(e) ? e.length === 1 && ((a = e[0].type) == null ? void 0 : a.toString()) === "Symbol(v-fgt)" ? e[0].children : e : ((t = e.type) == null ? void 0 : t.toString()) === "Symbol(v-fgt)" ? e.children : [e];
20
- }), b = i(() => {
20
+ }), y = i(() => {
21
21
  const e = l.maxNum ?? Number.MAX_SAFE_INTEGER;
22
22
  return e > 0 ? e : Number.MAX_SAFE_INTEGER;
23
- }), y = i(() => p.value.length > b.value), V = i(() => y.value ? p.value.slice(0, b.value) : p.value), z = i(() => y.value ? p.value.slice(b.value) : []), m = f(null), d = f(null), n = f(!1), P = () => {
23
+ }), b = i(() => p.value.length > y.value), V = i(() => b.value ? p.value.slice(0, y.value) : p.value), z = i(() => b.value ? p.value.slice(y.value) : []), m = f(null), d = f(null), n = f(!1), P = () => {
24
24
  n.value = !n.value;
25
25
  };
26
26
  Z(
@@ -38,14 +38,14 @@ const ne = { class: "tr-action-group" }, re = ["onClick"], le = ["onClick"], ae
38
38
  const e = d.value.getBoundingClientRect(), a = m.value.getBoundingClientRect();
39
39
  B.value = a.bottom + e.height + 16 > D.value ? "placement-top" : "placement-bottom";
40
40
  };
41
- return N(n, (e) => {
41
+ return I(n, (e) => {
42
42
  e && W(() => {
43
43
  T();
44
44
  });
45
- }), N(D, () => {
45
+ }), I(D, () => {
46
46
  n.value && T();
47
47
  }), (e, a) => (o(), _("div", ne, [
48
- (o(!0), _(G, null, I(V.value, (t, C) => {
48
+ (o(!0), _(R, null, G(V.value, (t, C) => {
49
49
  var c;
50
50
  return o(), v(h(M), {
51
51
  key: C,
@@ -69,7 +69,7 @@ const ne = { class: "tr-action-group" }, re = ["onClick"], le = ["onClick"], ae
69
69
  _: 2
70
70
  }, 1032, ["content", "disabled"]);
71
71
  }), 128)),
72
- y.value ? (o(), v(h(M), {
72
+ b.value ? (o(), v(h(M), {
73
73
  key: 0,
74
74
  content: "更多",
75
75
  effect: "dark",
@@ -94,7 +94,7 @@ const ne = { class: "tr-action-group" }, re = ["onClick"], le = ["onClick"], ae
94
94
  ref: d,
95
95
  class: J(["tr-action-group__dropdown", B.value])
96
96
  }, [
97
- (o(!0), _(G, null, I(z.value, (t, C) => {
97
+ (o(!0), _(R, null, G(z.value, (t, C) => {
98
98
  var c;
99
99
  return o(), _("li", {
100
100
  class: "tr-action-group__dropdown-item",
@@ -104,7 +104,7 @@ const ne = { class: "tr-action-group" }, re = ["onClick"], le = ["onClick"], ae
104
104
  return A((s = t.props) == null ? void 0 : s.name);
105
105
  }, ["stop"])
106
106
  }, [
107
- l.dropDownShowLabelOnly ? R("", !0) : (o(), v(x(t), { key: 0 })),
107
+ l.dropDownShowLabelOnly ? N("", !0) : (o(), v(x(t), { key: 0 })),
108
108
  w("span", ae, Q((c = t.props) == null ? void 0 : c.label), 1)
109
109
  ], 8, le);
110
110
  }), 128))
@@ -117,10 +117,10 @@ const ne = { class: "tr-action-group" }, re = ["onClick"], le = ["onClick"], ae
117
117
  ], 512)
118
118
  ]),
119
119
  _: 3
120
- }, 8, ["disabled"])) : R("", !0)
120
+ }, 8, ["disabled"])) : N("", !0)
121
121
  ]));
122
122
  }
123
- }), g = /* @__PURE__ */ oe(ce, [["__scopeId", "data-v-f8531261"]]), u = /* @__PURE__ */ $({
123
+ }), g = /* @__PURE__ */ oe(ce, [["__scopeId", "data-v-f0173895"]]), u = /* @__PURE__ */ $({
124
124
  __name: "ActionGroupItem",
125
125
  props: {
126
126
  name: {},
@@ -0,0 +1,526 @@
1
+ import { computed as C, ref as R, onUnmounted as Y, defineComponent as B, mergeModels as W, useModel as Z, createElementBlock as d, openBlock as o, withModifiers as P, createElementVNode as p, createVNode as F, unref as f, Fragment as z, renderList as D, normalizeClass as U, h as ee, createCommentVNode as k, createBlock as L, toDisplayString as x, withCtx as te, resolveDynamicComponent as O, watch as ne } from "vue";
2
+ import { IconFileOther as re, IconFileFolder as V, IconFilePpt as q, IconFileExcel as K, IconFileWord as G, IconFilePdf as H, IconFileImage as J, IconClose as se, IconArrowLeft as ae, IconArrowRight as oe, IconFileRemove as ie, IconImageLoading as j, IconImageWarning as E } from "@opentiny/tiny-robot-svgs";
3
+ import { _ as S } from "../_plugin-vue_export-helper.js";
4
+ import { TinyTooltip as le } from "@opentiny/vue";
5
+ const A = {
6
+ image: J,
7
+ pdf: H,
8
+ word: G,
9
+ excel: K,
10
+ ppt: q,
11
+ folder: V,
12
+ other: re
13
+ }, N = [
14
+ {
15
+ type: "image",
16
+ matcher: (t) => {
17
+ var n, u;
18
+ if (typeof t != "string")
19
+ return ((n = t.type) == null ? void 0 : n.startsWith("image/")) || !1;
20
+ const s = ((u = t.split(".").pop()) == null ? void 0 : u.toLowerCase()) || "";
21
+ return ["png", "jpg", "jpeg", "gif", "webp", "bmp", "svg"].includes(s);
22
+ },
23
+ icon: J
24
+ },
25
+ {
26
+ type: "pdf",
27
+ matcher: (t) => typeof t != "string" ? t.type === "application/pdf" : t.toLowerCase().endsWith(".pdf"),
28
+ icon: H
29
+ },
30
+ {
31
+ type: "word",
32
+ matcher: (t) => {
33
+ var n;
34
+ if (typeof t != "string")
35
+ return t.type === "application/msword" || t.type === "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
36
+ const s = ((n = t.split(".").pop()) == null ? void 0 : n.toLowerCase()) || "";
37
+ return ["doc", "docx"].includes(s);
38
+ },
39
+ icon: G
40
+ },
41
+ {
42
+ type: "excel",
43
+ matcher: (t) => {
44
+ var n;
45
+ if (typeof t != "string")
46
+ return t.type === "application/vnd.ms-excel" || t.type === "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
47
+ const s = ((n = t.split(".").pop()) == null ? void 0 : n.toLowerCase()) || "";
48
+ return ["xls", "xlsx"].includes(s);
49
+ },
50
+ icon: K
51
+ },
52
+ {
53
+ type: "ppt",
54
+ matcher: (t) => {
55
+ var n;
56
+ if (typeof t != "string")
57
+ return t.type === "application/vnd.ms-powerpoint" || t.type === "application/vnd.openxmlformats-officedocument.presentationml.presentation";
58
+ const s = ((n = t.split(".").pop()) == null ? void 0 : n.toLowerCase()) || "";
59
+ return ["ppt", "pptx"].includes(s);
60
+ },
61
+ icon: q
62
+ },
63
+ {
64
+ type: "folder",
65
+ matcher: (t) => typeof t != "string" ? !1 : t.toLowerCase().endsWith("folder"),
66
+ icon: V
67
+ }
68
+ ];
69
+ function Q(t = {}) {
70
+ const { customIcons: s, fileMatchers: n } = t, u = () => {
71
+ let e = [];
72
+ return n ? e = n.concat(N) : e = N, e;
73
+ }, i = (e = "other") => C(() => {
74
+ if (s != null && s[e])
75
+ return s[e];
76
+ const r = u().find((_) => _.type === e);
77
+ return r != null && r.icon ? r.icon : A[e] ? A[e] : A.other;
78
+ }), v = (e) => {
79
+ const a = u();
80
+ for (const r of a)
81
+ if (r.matcher(e))
82
+ return r.type;
83
+ return "other";
84
+ }, g = () => Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15), I = (e) => e < 1024 ? e + " B" : e < 1024 * 1024 ? (e / 1024).toFixed(2) + " KB" : (e / (1024 * 1024)).toFixed(2) + " MB", b = (e) => typeof e.url == "string" && !!e.url && typeof e.size == "number", w = (e) => e.rawFile instanceof File, l = (e) => e.map((a) => {
85
+ if (b(a))
86
+ return c(a);
87
+ if (w(a))
88
+ return m(a);
89
+ }), h = (e) => ({
90
+ id: e.id || g(),
91
+ name: e.name || "",
92
+ status: e.status || "success",
93
+ message: e.message || ""
94
+ }), c = (e) => {
95
+ const a = h(e), r = e.url, _ = e.size, M = r.split("/").pop() || "";
96
+ return {
97
+ ...a,
98
+ name: a.name || M,
99
+ fileType: v(M),
100
+ size: _,
101
+ url: r
102
+ };
103
+ }, m = (e) => {
104
+ const a = h(e), r = e.rawFile;
105
+ return {
106
+ ...a,
107
+ name: a.name || r.name,
108
+ fileType: v(r),
109
+ rawFile: r,
110
+ size: e.size || r.size,
111
+ url: e.url
112
+ };
113
+ };
114
+ return {
115
+ detectFileType: v,
116
+ generateID: g,
117
+ formatFileSize: I,
118
+ normalizeAttachments: l,
119
+ getIconComponent: i
120
+ };
121
+ }
122
+ const ce = (t, s) => {
123
+ if (t.startsWith("blob:") || t.startsWith("data:")) {
124
+ const n = document.createElement("a");
125
+ n.href = t, n.download = s, document.body.appendChild(n), requestAnimationFrame(() => {
126
+ n.click(), document.body.removeChild(n), URL.revokeObjectURL(t);
127
+ });
128
+ }
129
+ };
130
+ function de(t, s) {
131
+ const n = R([]), u = C(() => t.file.fileType === "image"), i = (l) => {
132
+ const h = URL.createObjectURL(l);
133
+ return n.value.push(h), h;
134
+ }, v = (l) => {
135
+ s("preview", l, t.file);
136
+ }, g = (l) => {
137
+ if (s("download", l, t.file), !l.defaultPrevented && t.file.rawFile && !t.file.url) {
138
+ const h = i(t.file.rawFile);
139
+ ce(h, t.file.name || t.file.rawFile.name);
140
+ }
141
+ }, I = () => {
142
+ s("remove", t.file);
143
+ }, b = () => {
144
+ s("retry", t.file);
145
+ }, w = (l, h) => {
146
+ h.stopPropagation(), l.handler && l.handler(t.file), l.type === "preview" ? v(h) : l.type === "download" ? g(h) : s("action", { action: l, file: t.file });
147
+ };
148
+ return Y(() => {
149
+ n.value.forEach((l) => {
150
+ URL.revokeObjectURL(l);
151
+ }), n.value = [];
152
+ }), {
153
+ isImage: u,
154
+ handlePreview: v,
155
+ downloadFile: g,
156
+ handleRemove: I,
157
+ handleRetry: b,
158
+ handleCustomAction: w
159
+ };
160
+ }
161
+ const ue = { class: "tr-image-preview__main" }, fe = ["disabled"], pe = { class: "tr-image-preview__content" }, me = ["src", "alt"], _e = ["disabled"], ve = { class: "tr-image-preview__footer" }, he = { class: "tr-image-preview__thumbnails" }, ge = ["onClick"], ye = ["src", "alt"], we = /* @__PURE__ */ B({
162
+ __name: "ImagePreview",
163
+ props: /* @__PURE__ */ W({
164
+ images: {}
165
+ }, {
166
+ currentIndex: { required: !0 },
167
+ currentIndexModifiers: {}
168
+ }),
169
+ emits: /* @__PURE__ */ W(["close"], ["update:currentIndex"]),
170
+ setup(t, { emit: s }) {
171
+ const n = t, u = s, i = Z(t, "currentIndex"), v = C(() => n.images[i.value]), g = () => {
172
+ i.value > 0 && i.value--;
173
+ }, I = () => {
174
+ i.value < n.images.length - 1 && i.value++;
175
+ }, b = (l) => {
176
+ i.value = l;
177
+ };
178
+ function w() {
179
+ u("close");
180
+ }
181
+ return (l, h) => {
182
+ var c, m;
183
+ return o(), d("div", {
184
+ class: "tr-image-preview",
185
+ onClick: P(w, ["self"])
186
+ }, [
187
+ p("button", {
188
+ class: "tr-image-preview__close",
189
+ onClick: w
190
+ }, [
191
+ F(f(se))
192
+ ]),
193
+ p("div", ue, [
194
+ p("button", {
195
+ class: "tr-image-preview__nav tr-image-preview__nav--left",
196
+ onClick: P(g, ["stop"]),
197
+ disabled: i.value === 0
198
+ }, [
199
+ F(f(ae))
200
+ ], 8, fe),
201
+ p("div", pe, [
202
+ p("img", {
203
+ src: (c = v.value) == null ? void 0 : c.url,
204
+ alt: (m = v.value) == null ? void 0 : m.name,
205
+ class: "tr-image-preview__image"
206
+ }, null, 8, me)
207
+ ]),
208
+ p("button", {
209
+ class: "tr-image-preview__nav tr-image-preview__nav--right",
210
+ onClick: P(I, ["stop"]),
211
+ disabled: i.value === l.images.length - 1
212
+ }, [
213
+ F(f(oe))
214
+ ], 8, _e)
215
+ ]),
216
+ p("div", ve, [
217
+ p("div", he, [
218
+ (o(!0), d(z, null, D(l.images, (e, a) => (o(), d("div", {
219
+ key: e.id,
220
+ class: U(["tr-image-preview__thumbnail", { "tr-image-preview__thumbnail--active": a === i.value }]),
221
+ onClick: (r) => b(a)
222
+ }, [
223
+ p("img", {
224
+ src: e.url,
225
+ alt: e.name
226
+ }, null, 8, ye)
227
+ ], 10, ge))), 128))
228
+ ])
229
+ ])
230
+ ]);
231
+ };
232
+ }
233
+ }), Ie = /* @__PURE__ */ S(we, [["__scopeId", "data-v-027af77c"]]);
234
+ function be(t, s, n = {}) {
235
+ const u = R(!1), i = R([]), v = R(0), g = (c) => {
236
+ v.value = c;
237
+ }, I = (c) => {
238
+ const m = t.value.findIndex((e) => e.id === c.id);
239
+ if (m !== -1 && c.url && t.value.splice(m, 1, c), c.fileType === "image") {
240
+ i.value = t.value.filter(
241
+ (a) => a.fileType === "image" && a.status !== "error" && a.status !== "uploading"
242
+ );
243
+ const e = i.value.findIndex((a) => a.id === c.id);
244
+ e !== -1 && (v.value = e, u.value = !0);
245
+ }
246
+ }, b = (c, m) => {
247
+ s("preview", c, m), !c.defaultPrevented && I(m);
248
+ }, w = () => {
249
+ u.value = !1;
250
+ }, l = (c, m) => {
251
+ n.onDownload ? n.onDownload(c, m) : s("download", c, m);
252
+ };
253
+ return {
254
+ // 显示预览
255
+ handlePreview: b,
256
+ // 渲染预览组件
257
+ renderPreview: () => u.value ? ee(Ie, {
258
+ images: i.value,
259
+ currentIndex: v.value,
260
+ "onUpdate:currentIndex": g,
261
+ onClose: w,
262
+ onDownload: l
263
+ }) : null
264
+ };
265
+ }
266
+ function ke(t, s) {
267
+ return {
268
+ actualListType: C(() => s && s !== "auto" ? s : t.value.length === 0 ? "card" : t.value.every((i) => i.fileType === "image") ? "picture" : "card")
269
+ };
270
+ }
271
+ const Ce = ["data-file-type"], Fe = {
272
+ key: 1,
273
+ class: "tr-file-card__picture-container"
274
+ }, xe = ["src", "alt"], Pe = {
275
+ key: 0,
276
+ class: "tr-file-card__picture-overlay"
277
+ }, Me = {
278
+ key: 1,
279
+ class: "tr-file-card__status-overlay tr-file-card__status-overlay--picture"
280
+ }, Re = {
281
+ key: 0,
282
+ class: "tr-file-card__status-icon tr-file-card__status-icon--loading"
283
+ }, Ue = {
284
+ key: 0,
285
+ class: "tr-file-card__status-icon--loading-text"
286
+ }, Le = {
287
+ key: 2,
288
+ class: "tr-file-card__default-container"
289
+ }, $e = { class: "tr-file-card__icon-wrapper" }, Te = {
290
+ key: 0,
291
+ class: "tr-file-card__status-overlay tr-file-card__status-overlay--icon"
292
+ }, Ae = {
293
+ key: 0,
294
+ class: "tr-file-card__status-icon tr-file-card__status-icon--loading"
295
+ }, Be = { class: "tr-file-card__content" }, ze = { class: "tr-file-card__info" }, De = ["title"], Se = {
296
+ key: 0,
297
+ class: "tr-file-card__status"
298
+ }, We = {
299
+ key: 0,
300
+ class: "tr-file-card__status-success"
301
+ }, je = { class: "tr-file-card__status-info" }, Ee = { class: "tr-file-card__file-type" }, Ne = {
302
+ key: 0,
303
+ class: "tr-file-card__file-size"
304
+ }, Oe = {
305
+ key: 0,
306
+ class: "tr-file-card__actions"
307
+ }, Ve = ["href", "target", "onClick"], qe = ["onClick"], Ke = {
308
+ key: 1,
309
+ class: "tr-file-card__status-uploading"
310
+ }, Ge = {
311
+ key: 2,
312
+ class: "tr-file-card__status-error"
313
+ }, He = /* @__PURE__ */ B({
314
+ __name: "FileCard",
315
+ props: {
316
+ file: {},
317
+ variant: { default: "card" },
318
+ showStatus: { type: Boolean, default: !0 },
319
+ fileIcons: {},
320
+ disabled: { type: Boolean },
321
+ actions: {},
322
+ fileMatchers: {}
323
+ },
324
+ emits: ["remove", "preview", "action", "retry", "download"],
325
+ setup(t, { emit: s }) {
326
+ const n = t, u = s, { formatFileSize: i, getIconComponent: v } = Q({
327
+ customIcons: n.fileIcons,
328
+ fileMatchers: n.fileMatchers
329
+ }), { isImage: g, handlePreview: I, handleRemove: b, handleCustomAction: w, handleRetry: l } = de(n, u), h = C(() => v(n.file.fileType).value), c = C(() => n.file.status === "uploading"), m = C(() => n.file.status === "success"), e = C(() => n.file.status === "error"), a = C(() => [
330
+ n.variant === "picture" ? "tr-file-card--picture" : "tr-file-card",
331
+ `tr-file-card--${n.file.fileType || "other"}`,
332
+ {
333
+ "tr-file-card--uploading": c.value,
334
+ "tr-file-card--error": e.value,
335
+ "tr-file-card--success": m.value
336
+ }
337
+ ]);
338
+ return (r, _) => {
339
+ var M;
340
+ return o(), d("div", {
341
+ class: U(a.value),
342
+ "data-file-type": r.file.fileType || "other",
343
+ onClick: _[3] || (_[3] = (y) => r.variant === "picture" ? f(I)(y) : void 0)
344
+ }, [
345
+ r.disabled ? k("", !0) : (o(), d("button", {
346
+ key: 0,
347
+ class: "tr-file-card__close-btn",
348
+ onClick: _[0] || (_[0] = P(
349
+ //@ts-ignore
350
+ (...y) => f(b) && f(b)(...y),
351
+ ["stop"]
352
+ )),
353
+ "aria-label": "移除文件"
354
+ }, [
355
+ F(f(ie))
356
+ ])),
357
+ r.variant === "picture" ? (o(), d("div", Fe, [
358
+ p("img", {
359
+ src: r.file.url,
360
+ alt: r.file.name,
361
+ class: "tr-file-card__picture-img"
362
+ }, null, 8, xe),
363
+ m.value ? (o(), d("div", Pe, _[4] || (_[4] = [
364
+ p("span", { class: "tr-file-card__picture-overlay-text" }, "预览", -1)
365
+ ]))) : k("", !0),
366
+ c.value || e.value ? (o(), d("div", Me, [
367
+ c.value ? (o(), d("div", Re, [
368
+ F(f(j)),
369
+ r.file.message ? (o(), d("span", Ue, x(r.file.message), 1)) : k("", !0)
370
+ ])) : e.value ? (o(), L(f(le), {
371
+ key: 1,
372
+ content: "解析失败",
373
+ placement: "top",
374
+ effect: "light"
375
+ }, {
376
+ default: te(() => [
377
+ F(f(E), { class: "tr-file-card__status-icon tr-file-card__status-icon--error" })
378
+ ]),
379
+ _: 1
380
+ })) : k("", !0)
381
+ ])) : k("", !0)
382
+ ])) : (o(), d("div", Le, [
383
+ p("div", {
384
+ class: U(["tr-file-card__icon", { "tr-file-card__icon--clickable": f(g) }]),
385
+ onClick: _[1] || (_[1] = P((y) => f(g) ? f(I)(y) : null, ["stop"]))
386
+ }, [
387
+ p("div", $e, [
388
+ (o(), L(O(h.value), { class: "tr-file-card__file-icon" })),
389
+ c.value || e.value ? (o(), d("div", Te, [
390
+ c.value ? (o(), d("div", Ae, [
391
+ F(f(j))
392
+ ])) : e.value ? (o(), L(f(E), {
393
+ key: 1,
394
+ class: "tr-file-card__status-icon tr-file-card__status-icon--error"
395
+ })) : k("", !0)
396
+ ])) : k("", !0)
397
+ ])
398
+ ], 2),
399
+ p("div", Be, [
400
+ p("div", ze, [
401
+ p("div", {
402
+ class: "tr-file-card__name",
403
+ title: r.file.name
404
+ }, x(r.file.name), 9, De),
405
+ r.showStatus ? (o(), d("div", Se, [
406
+ m.value ? (o(), d("div", We, [
407
+ p("div", je, [
408
+ p("span", Ee, x(((M = r.file.fileType) == null ? void 0 : M.toUpperCase()) || "FILE"), 1),
409
+ r.file.size ? (o(), d("span", Ne, x(f(i)(r.file.size)), 1)) : k("", !0)
410
+ ]),
411
+ r.actions ? (o(), d("div", Oe, [
412
+ (o(!0), d(z, null, D(r.actions, (y, X) => (o(), d("div", {
413
+ key: X,
414
+ class: "tr-file-card__action-btn"
415
+ }, [
416
+ y.type === "download" ? (o(), d("a", {
417
+ key: 0,
418
+ class: "tr-file-card__action-btn--download",
419
+ href: r.file.url ?? "javascript:void(0)",
420
+ target: r.file.url ? "_blank" : "_self",
421
+ onClick: (T) => f(w)(y, T)
422
+ }, x(y.label), 9, Ve)) : (o(), d("button", {
423
+ key: 1,
424
+ class: U(`tr-file-card__action-btn--${y.type}`),
425
+ onClick: (T) => f(w)(y, T)
426
+ }, x(y.label), 11, qe))
427
+ ]))), 128))
428
+ ])) : k("", !0)
429
+ ])) : c.value ? (o(), d("div", Ke, _[5] || (_[5] = [
430
+ p("span", { class: "tr-file-card__uploading-text" }, "上传中...", -1)
431
+ ]))) : e.value ? (o(), d("div", Ge, [
432
+ _[6] || (_[6] = p("span", { class: "tr-file-card__error-text" }, "上传失败", -1)),
433
+ p("button", {
434
+ class: "tr-file-card__retry-btn",
435
+ onClick: _[2] || (_[2] = //@ts-ignore
436
+ (...y) => f(l) && f(l)(...y))
437
+ }, "重试")
438
+ ])) : k("", !0)
439
+ ])) : k("", !0)
440
+ ])
441
+ ])
442
+ ]))
443
+ ], 10, Ce);
444
+ };
445
+ }
446
+ }), Je = /* @__PURE__ */ S(He, [["__scopeId", "data-v-a569c028"]]), Qe = { class: "tr-attachments" }, Xe = /* @__PURE__ */ B({
447
+ __name: "index",
448
+ props: {
449
+ items: {},
450
+ disabled: { type: Boolean },
451
+ wrap: { type: Boolean },
452
+ fileIcons: {},
453
+ actions: { default: () => [
454
+ {
455
+ label: "下载",
456
+ type: "download"
457
+ },
458
+ {
459
+ label: "预览",
460
+ type: "preview"
461
+ }
462
+ ] },
463
+ variant: { default: "auto" },
464
+ fileMatchers: { default: () => [] }
465
+ },
466
+ emits: ["update:items", "remove", "download", "retry", "preview", "action"],
467
+ setup(t, { emit: s }) {
468
+ const n = t, u = s, i = R(n.items || []), { actualListType: v } = ke(i, n.variant), { handlePreview: g, renderPreview: I } = be(i, u, { enableDownload: !0 });
469
+ function b(e) {
470
+ if (n.disabled) return;
471
+ const a = i.value.findIndex((r) => r.id === e.id);
472
+ a !== -1 && (i.value.splice(a, 1), u("remove", e), u("update:items", i.value));
473
+ }
474
+ function w(e, a) {
475
+ u("download", e, a);
476
+ }
477
+ function l(e) {
478
+ u("retry", e);
479
+ }
480
+ function h(e) {
481
+ u("action", e);
482
+ }
483
+ const c = C(() => n.wrap ? "wrap" : "no-wrap"), { normalizeAttachments: m } = Q({
484
+ fileMatchers: n.fileMatchers
485
+ });
486
+ return ne(
487
+ () => n.items,
488
+ (e) => {
489
+ e && e.length > 0 && (i.value = m(e));
490
+ },
491
+ { deep: !0, immediate: !0 }
492
+ ), (e, a) => (o(), d("div", Qe, [
493
+ i.value.length > 0 ? (o(), d("div", {
494
+ key: 0,
495
+ class: U(["tr-attachments__file-list", c.value]),
496
+ onClick: a[0] || (a[0] = P(() => {
497
+ }, ["stop"]))
498
+ }, [
499
+ (o(!0), d(z, null, D(i.value, (r) => (o(), L(Je, {
500
+ key: r.id,
501
+ file: r,
502
+ variant: f(v),
503
+ "file-icons": e.fileIcons,
504
+ disabled: e.disabled,
505
+ actions: e.actions,
506
+ "show-status": !0,
507
+ "file-matchers": e.fileMatchers,
508
+ onRemove: b,
509
+ onPreview: f(g),
510
+ onDownload: w,
511
+ onRetry: l,
512
+ onAction: h
513
+ }, null, 8, ["file", "variant", "file-icons", "disabled", "actions", "file-matchers", "onPreview"]))), 128))
514
+ ], 2)) : k("", !0),
515
+ (o(), L(O(f(I)())))
516
+ ]));
517
+ }
518
+ }), $ = /* @__PURE__ */ S(Xe, [["__scopeId", "data-v-e09559ac"]]);
519
+ $.name = "TrAttachments";
520
+ const Ye = function(t) {
521
+ t.component($.name, $);
522
+ };
523
+ $.install = Ye;
524
+ export {
525
+ $ as default
526
+ };