@opentiny/tiny-robot 0.4.2-alpha.2 → 0.4.2-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/action-group/index.js +3 -3
- package/dist/anchor/index.js +44 -44
- package/dist/attachments/index.js +326 -269
- package/dist/container/index.js +13 -13
- package/dist/drag-overlay/index.js +1 -1
- package/dist/dropdown-menu/index.js +1 -1
- package/dist/index.d.ts +21 -2
- package/dist/index.js +2 -2
- package/dist/index2.js +152 -126
- package/dist/index3.js +1 -1
- package/dist/index4.js +13 -13
- package/dist/index6.js +19 -19
- package/dist/index7.js +30 -30
- package/dist/index8.js +8 -8
- package/dist/mcp-server-picker/index.js +160 -162
- package/dist/sender/index.js +178 -164
- package/dist/sender-actions/index.js +1 -1
- package/dist/style.css +1 -1
- package/dist/suggestion-pills/index.js +1 -1
- package/dist/suggestion-popover/index.js +113 -116
- package/dist/useSlotRefs.js +1 -1
- package/dist/utils.js +1 -1
- package/package.json +3 -3
- package/dist/no-data.js +0 -4
|
@@ -1,31 +1,93 @@
|
|
|
1
|
-
import { computed as
|
|
2
|
-
import { IconFileOther as
|
|
3
|
-
import { _ as
|
|
4
|
-
import { TinyTooltip as
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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,
|
|
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
|
|
21
|
-
return ["png", "jpg", "jpeg", "gif", "webp", "bmp", "svg"].includes(
|
|
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:
|
|
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:
|
|
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
|
|
37
|
-
return ["doc", "docx"].includes(
|
|
98
|
+
const r = ((n = e.split(".").pop()) == null ? void 0 : n.toLowerCase()) || "";
|
|
99
|
+
return ["doc", "docx"].includes(r);
|
|
38
100
|
},
|
|
39
|
-
icon:
|
|
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
|
|
48
|
-
return ["xls", "xlsx"].includes(
|
|
109
|
+
const r = ((n = e.split(".").pop()) == null ? void 0 : n.toLowerCase()) || "";
|
|
110
|
+
return ["xls", "xlsx"].includes(r);
|
|
49
111
|
},
|
|
50
|
-
icon:
|
|
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
|
|
59
|
-
return ["ppt", "pptx"].includes(
|
|
120
|
+
const r = ((n = e.split(".").pop()) == null ? void 0 : n.toLowerCase()) || "";
|
|
121
|
+
return ["ppt", "pptx"].includes(r);
|
|
60
122
|
},
|
|
61
|
-
icon:
|
|
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:
|
|
128
|
+
icon: Z
|
|
67
129
|
}
|
|
68
130
|
];
|
|
69
|
-
function
|
|
70
|
-
const { customIcons:
|
|
131
|
+
function re(e = {}) {
|
|
132
|
+
const { customIcons: r, fileMatchers: n } = e, a = () => {
|
|
71
133
|
let t = [];
|
|
72
|
-
return n ? t = n.concat(
|
|
73
|
-
},
|
|
74
|
-
if (
|
|
75
|
-
return
|
|
76
|
-
const
|
|
77
|
-
return
|
|
78
|
-
}),
|
|
79
|
-
const
|
|
80
|
-
for (const
|
|
81
|
-
if (
|
|
82
|
-
return
|
|
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
|
-
},
|
|
85
|
-
|
|
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
|
-
}),
|
|
95
|
-
const
|
|
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
|
-
...
|
|
98
|
-
name:
|
|
99
|
-
fileType:
|
|
100
|
-
size:
|
|
101
|
-
url:
|
|
154
|
+
...i,
|
|
155
|
+
name: x,
|
|
156
|
+
fileType: t.fileType ?? $,
|
|
157
|
+
size: t.size,
|
|
158
|
+
url: l
|
|
102
159
|
};
|
|
103
|
-
},
|
|
104
|
-
const
|
|
160
|
+
}, h = (t) => {
|
|
161
|
+
const i = g(t), l = t.rawFile;
|
|
105
162
|
return {
|
|
106
|
-
...
|
|
107
|
-
name:
|
|
108
|
-
fileType:
|
|
109
|
-
rawFile:
|
|
110
|
-
size: t.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:
|
|
172
|
+
detectFileType: p,
|
|
173
|
+
generateID: _,
|
|
117
174
|
formatFileSize: I,
|
|
118
|
-
normalizeAttachments:
|
|
119
|
-
getIconComponent:
|
|
175
|
+
normalizeAttachments: d,
|
|
176
|
+
getIconComponent: s
|
|
120
177
|
};
|
|
121
178
|
}
|
|
122
|
-
const
|
|
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 =
|
|
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
|
|
131
|
-
const n =
|
|
132
|
-
const
|
|
133
|
-
return n.value.push(
|
|
134
|
-
},
|
|
135
|
-
|
|
136
|
-
},
|
|
137
|
-
if (
|
|
138
|
-
const
|
|
139
|
-
|
|
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
|
-
|
|
199
|
+
r("remove", e.file);
|
|
143
200
|
}, b = () => {
|
|
144
|
-
|
|
145
|
-
}, w = (
|
|
146
|
-
|
|
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
|
|
149
|
-
n.value.forEach((
|
|
150
|
-
URL.revokeObjectURL(
|
|
205
|
+
return ae(() => {
|
|
206
|
+
n.value.forEach((d) => {
|
|
207
|
+
URL.revokeObjectURL(d);
|
|
151
208
|
}), n.value = [];
|
|
152
209
|
}), {
|
|
153
|
-
isImage:
|
|
154
|
-
handlePreview:
|
|
155
|
-
downloadFile:
|
|
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
|
|
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__ */
|
|
220
|
+
props: /* @__PURE__ */ j({
|
|
164
221
|
images: {}
|
|
165
222
|
}, {
|
|
166
223
|
currentIndex: { required: !0 },
|
|
167
224
|
currentIndexModifiers: {}
|
|
168
225
|
}),
|
|
169
|
-
emits: /* @__PURE__ */
|
|
170
|
-
setup(e, { emit:
|
|
171
|
-
const n = e,
|
|
172
|
-
|
|
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
|
-
|
|
175
|
-
}, b = (
|
|
176
|
-
|
|
231
|
+
s.value < n.images.length - 1 && s.value++;
|
|
232
|
+
}, b = (d) => {
|
|
233
|
+
s.value = d;
|
|
177
234
|
};
|
|
178
235
|
function w() {
|
|
179
|
-
|
|
236
|
+
a("close");
|
|
180
237
|
}
|
|
181
|
-
return (
|
|
182
|
-
var
|
|
183
|
-
return
|
|
238
|
+
return (d, g) => {
|
|
239
|
+
var c, h;
|
|
240
|
+
return o(), u("div", {
|
|
184
241
|
class: "tr-image-preview",
|
|
185
|
-
onClick:
|
|
242
|
+
onClick: R(w, ["self"])
|
|
186
243
|
}, [
|
|
187
|
-
|
|
244
|
+
v("button", {
|
|
188
245
|
class: "tr-image-preview__close",
|
|
189
246
|
onClick: w
|
|
190
247
|
}, [
|
|
191
|
-
|
|
248
|
+
F(m(de))
|
|
192
249
|
]),
|
|
193
|
-
|
|
194
|
-
|
|
250
|
+
v("div", we, [
|
|
251
|
+
v("button", {
|
|
195
252
|
class: "tr-image-preview__nav tr-image-preview__nav--left",
|
|
196
|
-
onClick:
|
|
197
|
-
disabled:
|
|
253
|
+
onClick: R(_, ["stop"]),
|
|
254
|
+
disabled: s.value === 0
|
|
198
255
|
}, [
|
|
199
|
-
|
|
200
|
-
], 8,
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
src: (
|
|
204
|
-
alt: (
|
|
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,
|
|
263
|
+
}, null, 8, Ce)
|
|
207
264
|
]),
|
|
208
|
-
|
|
265
|
+
v("button", {
|
|
209
266
|
class: "tr-image-preview__nav tr-image-preview__nav--right",
|
|
210
|
-
onClick:
|
|
211
|
-
disabled:
|
|
267
|
+
onClick: R(I, ["stop"]),
|
|
268
|
+
disabled: s.value === e.images.length - 1
|
|
212
269
|
}, [
|
|
213
|
-
|
|
214
|
-
], 8,
|
|
270
|
+
F(m(fe))
|
|
271
|
+
], 8, ke)
|
|
215
272
|
]),
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
(
|
|
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:
|
|
221
|
-
onClick: (
|
|
277
|
+
class: T(["tr-image-preview__thumbnail", { "tr-image-preview__thumbnail--active": i === s.value }]),
|
|
278
|
+
onClick: (l) => b(i)
|
|
222
279
|
}, [
|
|
223
|
-
|
|
280
|
+
v("img", {
|
|
224
281
|
src: t.url,
|
|
225
282
|
alt: t.name
|
|
226
|
-
}, null, 8,
|
|
227
|
-
], 10,
|
|
283
|
+
}, null, 8, Pe)
|
|
284
|
+
], 10, Ue))), 128))
|
|
228
285
|
])
|
|
229
286
|
])
|
|
230
287
|
]);
|
|
231
288
|
};
|
|
232
289
|
}
|
|
233
|
-
}),
|
|
234
|
-
function
|
|
235
|
-
const
|
|
236
|
-
|
|
237
|
-
}, I = (
|
|
238
|
-
const
|
|
239
|
-
if (
|
|
240
|
-
|
|
241
|
-
(
|
|
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 =
|
|
244
|
-
t !== -1 && (
|
|
300
|
+
const t = s.value.findIndex((i) => i.id === c.id);
|
|
301
|
+
t !== -1 && (p.value = t, a.value = !0);
|
|
245
302
|
}
|
|
246
|
-
}, b = (
|
|
247
|
-
|
|
303
|
+
}, b = (c, h) => {
|
|
304
|
+
r("preview", c, h), !c.defaultPrevented && I(h);
|
|
248
305
|
}, w = () => {
|
|
249
|
-
|
|
250
|
-
},
|
|
251
|
-
n.onDownload ? n.onDownload(
|
|
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: () =>
|
|
258
|
-
images:
|
|
259
|
-
currentIndex:
|
|
260
|
-
"onUpdate:currentIndex":
|
|
314
|
+
renderPreview: () => a.value ? ie(Le, {
|
|
315
|
+
images: s.value,
|
|
316
|
+
currentIndex: p.value,
|
|
317
|
+
"onUpdate:currentIndex": _,
|
|
261
318
|
onClose: w,
|
|
262
|
-
onDownload:
|
|
319
|
+
onDownload: d
|
|
263
320
|
}) : null
|
|
264
321
|
};
|
|
265
322
|
}
|
|
266
|
-
function
|
|
323
|
+
function Me(e, r) {
|
|
267
324
|
return {
|
|
268
|
-
actualListType:
|
|
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
|
|
328
|
+
const Ee = ["data-file-type"], Se = {
|
|
272
329
|
key: 1,
|
|
273
330
|
class: "tr-file-card__picture-container"
|
|
274
|
-
},
|
|
331
|
+
}, Ae = ["src", "alt"], $e = {
|
|
275
332
|
key: 0,
|
|
276
333
|
class: "tr-file-card__picture-overlay"
|
|
277
|
-
},
|
|
334
|
+
}, De = {
|
|
278
335
|
key: 1,
|
|
279
336
|
class: "tr-file-card__status-overlay tr-file-card__status-overlay--picture"
|
|
280
|
-
},
|
|
337
|
+
}, Be = {
|
|
281
338
|
key: 0,
|
|
282
339
|
class: "tr-file-card__status-icon tr-file-card__status-icon--loading"
|
|
283
|
-
},
|
|
340
|
+
}, ze = {
|
|
284
341
|
key: 0,
|
|
285
342
|
class: "tr-file-card__status-icon--loading-text"
|
|
286
|
-
},
|
|
343
|
+
}, Oe = {
|
|
287
344
|
key: 2,
|
|
288
345
|
class: "tr-file-card__default-container"
|
|
289
|
-
},
|
|
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
|
-
},
|
|
349
|
+
}, je = {
|
|
293
350
|
key: 0,
|
|
294
351
|
class: "tr-file-card__status-icon tr-file-card__status-icon--loading"
|
|
295
|
-
},
|
|
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
|
-
},
|
|
355
|
+
}, Ye = {
|
|
299
356
|
key: 0,
|
|
300
357
|
class: "tr-file-card__status-success"
|
|
301
|
-
},
|
|
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
|
-
},
|
|
361
|
+
}, Qe = {
|
|
305
362
|
key: 0,
|
|
306
363
|
class: "tr-file-card__actions"
|
|
307
|
-
},
|
|
364
|
+
}, Xe = ["href", "target", "onClick"], et = ["onClick"], tt = {
|
|
308
365
|
key: 1,
|
|
309
366
|
class: "tr-file-card__status-uploading"
|
|
310
|
-
},
|
|
367
|
+
}, nt = {
|
|
311
368
|
key: 2,
|
|
312
369
|
class: "tr-file-card__status-error"
|
|
313
|
-
},
|
|
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:
|
|
326
|
-
const n = e,
|
|
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:
|
|
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":
|
|
390
|
+
"tr-file-card--uploading": c.value,
|
|
334
391
|
"tr-file-card--error": t.value,
|
|
335
|
-
"tr-file-card--success":
|
|
392
|
+
"tr-file-card--success": h.value
|
|
336
393
|
}
|
|
337
394
|
]);
|
|
338
|
-
return (
|
|
339
|
-
var
|
|
340
|
-
return
|
|
341
|
-
class:
|
|
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:
|
|
400
|
+
onClick: f[3] || (f[3] = (y) => e.variant === "picture" ? m(I)(y) : void 0)
|
|
344
401
|
}, [
|
|
345
|
-
e.disabled ?
|
|
402
|
+
e.disabled ? C("", !0) : (o(), u("button", {
|
|
346
403
|
key: 0,
|
|
347
404
|
class: "tr-file-card__close-btn",
|
|
348
|
-
onClick:
|
|
405
|
+
onClick: f[0] || (f[0] = R(
|
|
349
406
|
//@ts-ignore
|
|
350
|
-
(...y) =>
|
|
407
|
+
(...y) => m(b) && m(b)(...y),
|
|
351
408
|
["stop"]
|
|
352
409
|
)),
|
|
353
410
|
"aria-label": "移除文件"
|
|
354
411
|
}, [
|
|
355
|
-
|
|
412
|
+
F(m(me))
|
|
356
413
|
])),
|
|
357
|
-
e.variant === "picture" ? (
|
|
358
|
-
|
|
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,
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
])])) :
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
e.file.message ? (
|
|
370
|
-
])) : t.value ? (
|
|
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:
|
|
377
|
-
|
|
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
|
-
})) :
|
|
381
|
-
])) :
|
|
382
|
-
])) : (
|
|
383
|
-
|
|
384
|
-
class:
|
|
385
|
-
onClick:
|
|
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
|
-
|
|
388
|
-
(
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
])) : t.value ? (
|
|
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
|
-
})) :
|
|
396
|
-
])) :
|
|
452
|
+
})) : C("", !0)
|
|
453
|
+
])) : C("", !0)
|
|
397
454
|
])
|
|
398
455
|
], 2),
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
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
|
-
},
|
|
405
|
-
e.showStatus ? (
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
e.file.size ? (
|
|
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 ? (
|
|
412
|
-
(
|
|
413
|
-
key:
|
|
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" ? (
|
|
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: (
|
|
422
|
-
},
|
|
478
|
+
onClick: (D) => m(w)(y, D)
|
|
479
|
+
}, U(y.label), 9, Xe)) : (o(), u("button", {
|
|
423
480
|
key: 1,
|
|
424
|
-
class:
|
|
425
|
-
onClick: (
|
|
426
|
-
},
|
|
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
|
-
])) :
|
|
429
|
-
])) :
|
|
430
|
-
|
|
431
|
-
])])) : t.value ? (
|
|
432
|
-
|
|
433
|
-
|
|
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:
|
|
436
|
-
(...y) =>
|
|
492
|
+
onClick: f[2] || (f[2] = //@ts-ignore
|
|
493
|
+
(...y) => m(d) && m(d)(...y))
|
|
437
494
|
}, "重试")
|
|
438
|
-
])) :
|
|
439
|
-
])) :
|
|
495
|
+
])) : C("", !0)
|
|
496
|
+
])) : C("", !0)
|
|
440
497
|
])
|
|
441
498
|
])
|
|
442
499
|
]))
|
|
443
|
-
], 10,
|
|
500
|
+
], 10, Ee);
|
|
444
501
|
};
|
|
445
502
|
}
|
|
446
|
-
}),
|
|
503
|
+
}), at = /* @__PURE__ */ V(rt, [["__scopeId", "data-v-e11420c5"]]), 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:
|
|
468
|
-
const n = e,
|
|
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
|
|
472
|
-
|
|
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,
|
|
475
|
-
|
|
531
|
+
function w(t, i) {
|
|
532
|
+
a("download", t, i);
|
|
476
533
|
}
|
|
477
|
-
function
|
|
478
|
-
|
|
534
|
+
function d(t) {
|
|
535
|
+
a("retry", t);
|
|
479
536
|
}
|
|
480
|
-
function
|
|
481
|
-
|
|
537
|
+
function g(t) {
|
|
538
|
+
a("action", t);
|
|
482
539
|
}
|
|
483
|
-
const
|
|
540
|
+
const c = k(() => n.wrap ? "wrap" : "no-wrap"), { normalizeAttachments: h } = re({
|
|
484
541
|
fileMatchers: n.fileMatchers
|
|
485
542
|
});
|
|
486
|
-
return
|
|
543
|
+
return le(
|
|
487
544
|
() => n.items,
|
|
488
545
|
(t) => {
|
|
489
|
-
|
|
546
|
+
s.value = h(t || []);
|
|
490
547
|
},
|
|
491
548
|
{ deep: !0, immediate: !0 }
|
|
492
|
-
), (t,
|
|
493
|
-
|
|
549
|
+
), (t, i) => (o(), u("div", st, [
|
|
550
|
+
s.value.length > 0 ? (o(), u("div", {
|
|
494
551
|
key: 0,
|
|
495
|
-
class:
|
|
496
|
-
onClick:
|
|
552
|
+
class: T(["tr-attachments__file-list", c.value]),
|
|
553
|
+
onClick: i[0] || (i[0] = R(() => {
|
|
497
554
|
}, ["stop"]))
|
|
498
555
|
}, [
|
|
499
|
-
(
|
|
500
|
-
key:
|
|
501
|
-
file:
|
|
502
|
-
variant:
|
|
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:
|
|
566
|
+
onPreview: m(_),
|
|
510
567
|
onDownload: w,
|
|
511
|
-
onRetry:
|
|
512
|
-
onAction:
|
|
568
|
+
onRetry: d,
|
|
569
|
+
onAction: g
|
|
513
570
|
}, null, 8, ["file", "variant", "file-icons", "disabled", "actions", "file-matchers", "onPreview"]))), 128))
|
|
514
|
-
], 2)) :
|
|
515
|
-
(
|
|
571
|
+
], 2)) : C("", !0),
|
|
572
|
+
(o(), M(Y(m(I)())))
|
|
516
573
|
]));
|
|
517
574
|
}
|
|
518
|
-
}),
|
|
519
|
-
|
|
520
|
-
const
|
|
521
|
-
e.component(
|
|
575
|
+
}), A = /* @__PURE__ */ V(it, [["__scopeId", "data-v-4c01337e"]]);
|
|
576
|
+
A.name = "TrAttachments";
|
|
577
|
+
const ot = function(e) {
|
|
578
|
+
e.component(A.name, A);
|
|
522
579
|
};
|
|
523
|
-
|
|
580
|
+
A.install = ot;
|
|
524
581
|
export {
|
|
525
|
-
|
|
582
|
+
A as default
|
|
526
583
|
};
|