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