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