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