@opentiny/tiny-robot 0.3.0-alpha.0 → 0.3.0-alpha.2
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 +13 -13
- package/dist/bubble/index.js +2141 -1360
- package/dist/close.js +1 -1
- package/dist/container/index.js +7 -7
- package/dist/dropdown-menu/index.js +38 -37
- package/dist/feedback/index.js +46 -45
- package/dist/flow-layout-buttons/index.js +20 -20
- package/dist/history/index.js +34 -35
- package/dist/index.d.ts +329 -290
- package/dist/index.js +62 -59
- package/dist/index2.js +343 -394
- package/dist/index3.js +129 -3717
- package/dist/index4.js +7 -7
- package/dist/index5.js +931 -2011
- package/dist/index6.js +1020 -891
- package/dist/loading.js +4 -0
- package/dist/prompts/index.js +2 -3
- package/dist/question/index.js +59 -59
- package/dist/sender/index.js +1017 -1025
- package/dist/style.css +1 -1
- package/dist/suggestion/index.js +95 -95
- package/dist/suggestion-pills/index.js +130 -109
- package/dist/suggestion-popover/index.js +243 -127
- package/dist/tiny-robot-svgs.js +211 -488
- package/dist/utils.js +15 -4
- package/package.json +4 -3
- package/dist/attachments/index.js +0 -602
package/dist/utils.js
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
|
-
function
|
|
1
|
+
function e(t) {
|
|
2
2
|
if (typeof t == "number") return `${t}px`;
|
|
3
|
-
const
|
|
4
|
-
return
|
|
3
|
+
const o = t == null ? void 0 : t.trim();
|
|
4
|
+
return o ? /^-?\d+(\.\d+)?$/.test(o) ? `${o}px` : o : "0px";
|
|
5
|
+
}
|
|
6
|
+
function i(t) {
|
|
7
|
+
var n;
|
|
8
|
+
if (!t) return window.getSelection();
|
|
9
|
+
const o = t.getRootNode();
|
|
10
|
+
return o instanceof ShadowRoot && ((n = o.getSelection) == null ? void 0 : n.call(o)) || window.getSelection();
|
|
11
|
+
}
|
|
12
|
+
function r(t) {
|
|
13
|
+
return t.getRootNode() instanceof ShadowRoot;
|
|
5
14
|
}
|
|
6
15
|
export {
|
|
7
|
-
|
|
16
|
+
i as g,
|
|
17
|
+
r as i,
|
|
18
|
+
e as t
|
|
8
19
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentiny/tiny-robot",
|
|
3
|
-
"version": "0.3.0-alpha.
|
|
3
|
+
"version": "0.3.0-alpha.2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -20,13 +20,14 @@
|
|
|
20
20
|
"vue": "^3.3.11"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@opentiny/tiny-robot-svgs": "0.3.0-alpha.
|
|
23
|
+
"@opentiny/tiny-robot-svgs": "0.3.0-alpha.2",
|
|
24
24
|
"@opentiny/vue": "^3.21.0",
|
|
25
25
|
"@opentiny/vue-button": "^3.21.0",
|
|
26
26
|
"@opentiny/vue-icon": "^3.22.0",
|
|
27
27
|
"@opentiny/vue-input": "^3.21.0",
|
|
28
28
|
"@opentiny/vue-tooltip": "^3.22.0",
|
|
29
29
|
"@vueuse/core": "^13.1.0",
|
|
30
|
+
"dompurify": "^3.2.6",
|
|
30
31
|
"markdown-it": "^14.1.0"
|
|
31
32
|
},
|
|
32
33
|
"devDependencies": {
|
|
@@ -44,5 +45,5 @@
|
|
|
44
45
|
"vue": "^3.3.11",
|
|
45
46
|
"vue-tsc": "^2.2.8"
|
|
46
47
|
},
|
|
47
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "c2461649a17b661a1aad8ec52b50979a8b2f1fd1"
|
|
48
49
|
}
|
|
@@ -1,602 +0,0 @@
|
|
|
1
|
-
import { reactive as se, computed as k, watch as O, onBeforeUnmount as ie, defineComponent as E, ref as P, createElementBlock as d, createCommentVNode as m, openBlock as r, withModifiers as N, createElementVNode as l, normalizeClass as F, createBlock as L, resolveDynamicComponent as le, createVNode as ne, unref as I, toDisplayString as D, Fragment as z, normalizeStyle as B, renderList as J, createTextVNode as K, Transition as re, withCtx as oe, renderSlot as H, onMounted as ae, createStaticVNode as de } from "vue";
|
|
2
|
-
import { u as ce } from "../index2.js";
|
|
3
|
-
import { I as ue, W as pe, R as fe, q as ve, U as me, S as ge, J as ye, p as _e, v as he } from "../tiny-robot-svgs.js";
|
|
4
|
-
import { _ as G } from "../_plugin-vue_export-helper.js";
|
|
5
|
-
function we(p, g) {
|
|
6
|
-
const s = se({
|
|
7
|
-
active: !1,
|
|
8
|
-
isFullscreen: !1,
|
|
9
|
-
position: { x: 0, y: 0 }
|
|
10
|
-
}), n = k(() => g.drag);
|
|
11
|
-
let o = null, e, c = !1;
|
|
12
|
-
const h = (u) => u ? typeof u == "string" ? document.querySelector(u) : u : document.body, b = () => {
|
|
13
|
-
s.active = !1;
|
|
14
|
-
}, _ = () => {
|
|
15
|
-
e && (e(), e = void 0);
|
|
16
|
-
const u = n.value.mode || "container";
|
|
17
|
-
s.isFullscreen = u === "fullscreen", o = h(n == null ? void 0 : n.value.target), !o && !s.isFullscreen && (console.warn("无法找到拖拽目标元素,将使用document.body作为默认值"), o = document.body);
|
|
18
|
-
const U = (a) => {
|
|
19
|
-
if (s.isFullscreen) return !0;
|
|
20
|
-
if (!o) return !1;
|
|
21
|
-
const t = o.getBoundingClientRect();
|
|
22
|
-
return a.clientX >= t.left && a.clientX <= t.right && a.clientY >= t.top && a.clientY <= t.bottom;
|
|
23
|
-
}, C = {
|
|
24
|
-
dragover: (a) => {
|
|
25
|
-
a.preventDefault(), s.position = { x: a.clientX, y: a.clientY };
|
|
26
|
-
const t = U(a);
|
|
27
|
-
s.active = t;
|
|
28
|
-
},
|
|
29
|
-
drop: (a) => {
|
|
30
|
-
var t;
|
|
31
|
-
if (a.preventDefault(), a.stopPropagation(), U(a) && (t = a.dataTransfer) != null && t.files && a.dataTransfer.files.length > 0) {
|
|
32
|
-
const v = Array.from(a.dataTransfer.files);
|
|
33
|
-
p.onDrop(v);
|
|
34
|
-
}
|
|
35
|
-
b();
|
|
36
|
-
},
|
|
37
|
-
dragleave: (a) => {
|
|
38
|
-
(a.clientX <= 0 || a.clientY <= 0 || a.clientX >= window.innerWidth || a.clientY >= window.innerHeight) && b();
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
return Object.entries(C).forEach(([a, t]) => {
|
|
42
|
-
document.addEventListener(a, t);
|
|
43
|
-
}), c = !0, () => {
|
|
44
|
-
Object.entries(C).forEach(([a, t]) => {
|
|
45
|
-
document.removeEventListener(a, t);
|
|
46
|
-
}), c = !1;
|
|
47
|
-
};
|
|
48
|
-
}, y = (u) => {
|
|
49
|
-
e && (e(), e = void 0), u && !c && (e = _());
|
|
50
|
-
};
|
|
51
|
-
return O(() => p.enabled, y, { immediate: !0 }), O(
|
|
52
|
-
() => n.value,
|
|
53
|
-
() => {
|
|
54
|
-
p.enabled && y(!0);
|
|
55
|
-
},
|
|
56
|
-
{ deep: !0 }
|
|
57
|
-
), ie(() => {
|
|
58
|
-
e && (e(), e = void 0);
|
|
59
|
-
}), {
|
|
60
|
-
dragState: s,
|
|
61
|
-
dropZone: () => o,
|
|
62
|
-
initDrag: () => {
|
|
63
|
-
!c && p.enabled && y(!0);
|
|
64
|
-
},
|
|
65
|
-
cleanupDrag: () => y(!1)
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
const be = {
|
|
69
|
-
// 图片类型
|
|
70
|
-
png: "image",
|
|
71
|
-
jpg: "image",
|
|
72
|
-
jpeg: "image",
|
|
73
|
-
gif: "image",
|
|
74
|
-
webp: "image",
|
|
75
|
-
bmp: "image",
|
|
76
|
-
svg: "image",
|
|
77
|
-
// 文档类型
|
|
78
|
-
pdf: "pdf",
|
|
79
|
-
doc: "word",
|
|
80
|
-
docx: "word",
|
|
81
|
-
xls: "excel",
|
|
82
|
-
xlsx: "excel",
|
|
83
|
-
ppt: "ppt",
|
|
84
|
-
pptx: "ppt",
|
|
85
|
-
// 文件夹
|
|
86
|
-
folder: "folder"
|
|
87
|
-
}, ke = {
|
|
88
|
-
"image/": "image",
|
|
89
|
-
"application/pdf": "pdf",
|
|
90
|
-
"application/msword": "word",
|
|
91
|
-
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": "word",
|
|
92
|
-
"application/vnd.ms-excel": "excel",
|
|
93
|
-
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "excel",
|
|
94
|
-
"application/vnd.ms-powerpoint": "ppt",
|
|
95
|
-
"application/vnd.openxmlformats-officedocument.presentationml.presentation": "ppt"
|
|
96
|
-
};
|
|
97
|
-
function Q() {
|
|
98
|
-
const p = (e) => {
|
|
99
|
-
var h;
|
|
100
|
-
if (typeof e != "string") {
|
|
101
|
-
for (const [b, _] of Object.entries(ke))
|
|
102
|
-
if (e.type.startsWith(b))
|
|
103
|
-
return _;
|
|
104
|
-
e = e.name;
|
|
105
|
-
}
|
|
106
|
-
const c = ((h = e.split(".").pop()) == null ? void 0 : h.toLowerCase()) || "";
|
|
107
|
-
return be[c] || "other";
|
|
108
|
-
}, g = () => Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15), s = (e) => e < 1024 ? e + " B" : e < 1048576 ? (e / 1024).toFixed(2) + " KB" : (e / 1048576).toFixed(2) + " MB", n = (e) => e.type.startsWith("image/") ? URL.createObjectURL(e) : "";
|
|
109
|
-
return {
|
|
110
|
-
detectFileType: p,
|
|
111
|
-
generateUID: g,
|
|
112
|
-
formatFileSize: s,
|
|
113
|
-
createPreviewUrl: n,
|
|
114
|
-
createAttachments: (e) => e.map((c) => ({
|
|
115
|
-
uid: g(),
|
|
116
|
-
name: c.name,
|
|
117
|
-
status: "success",
|
|
118
|
-
fileType: p(c),
|
|
119
|
-
rawFile: c,
|
|
120
|
-
size: c.size,
|
|
121
|
-
previewUrl: n(c)
|
|
122
|
-
}))
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
const W = {
|
|
126
|
-
image: ye,
|
|
127
|
-
pdf: ge,
|
|
128
|
-
word: me,
|
|
129
|
-
excel: ve,
|
|
130
|
-
ppt: fe,
|
|
131
|
-
folder: pe,
|
|
132
|
-
other: ue
|
|
133
|
-
};
|
|
134
|
-
function Ue(p) {
|
|
135
|
-
return {
|
|
136
|
-
getIconComponent: (s = "other") => k(() => p != null && p[s] ? p[s] : W == null ? void 0 : W[s])
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
const De = { class: "tr-image-preview__content" }, Ce = ["src"], Z = 0.1, Te = /* @__PURE__ */ E({
|
|
140
|
-
__name: "ImagePreview",
|
|
141
|
-
props: {
|
|
142
|
-
visible: { type: Boolean },
|
|
143
|
-
imageUrl: {}
|
|
144
|
-
},
|
|
145
|
-
emits: ["close", "download"],
|
|
146
|
-
setup(p, { emit: g }) {
|
|
147
|
-
const s = g, n = P(1);
|
|
148
|
-
function o() {
|
|
149
|
-
n.value += Z, h();
|
|
150
|
-
}
|
|
151
|
-
function e() {
|
|
152
|
-
n.value > Z && (n.value -= Z, h());
|
|
153
|
-
}
|
|
154
|
-
function c() {
|
|
155
|
-
n.value = 1, h();
|
|
156
|
-
}
|
|
157
|
-
function h() {
|
|
158
|
-
const y = document.querySelector(".tr-image-preview__image");
|
|
159
|
-
y && (y.style.transform = `scale(${n.value})`);
|
|
160
|
-
}
|
|
161
|
-
function b() {
|
|
162
|
-
s("close");
|
|
163
|
-
}
|
|
164
|
-
function _() {
|
|
165
|
-
s("download");
|
|
166
|
-
}
|
|
167
|
-
return (y, u) => y.visible ? (r(), d("div", {
|
|
168
|
-
key: 0,
|
|
169
|
-
class: "tr-image-preview",
|
|
170
|
-
onClick: N(b, ["self"])
|
|
171
|
-
}, [
|
|
172
|
-
l("div", De, [
|
|
173
|
-
l("img", {
|
|
174
|
-
src: y.imageUrl,
|
|
175
|
-
alt: "预览图片",
|
|
176
|
-
class: "tr-image-preview__image"
|
|
177
|
-
}, null, 8, Ce),
|
|
178
|
-
l("div", { class: "tr-image-preview__tools" }, [
|
|
179
|
-
l("button", {
|
|
180
|
-
class: "tr-image-preview__btn",
|
|
181
|
-
onClick: o
|
|
182
|
-
}, u[0] || (u[0] = [
|
|
183
|
-
l("span", null, "+", -1)
|
|
184
|
-
])),
|
|
185
|
-
l("button", {
|
|
186
|
-
class: "tr-image-preview__btn",
|
|
187
|
-
onClick: c
|
|
188
|
-
}, u[1] || (u[1] = [
|
|
189
|
-
l("span", null, "100%", -1)
|
|
190
|
-
])),
|
|
191
|
-
l("button", {
|
|
192
|
-
class: "tr-image-preview__btn",
|
|
193
|
-
onClick: e
|
|
194
|
-
}, u[2] || (u[2] = [
|
|
195
|
-
l("span", null, "-", -1)
|
|
196
|
-
])),
|
|
197
|
-
l("button", {
|
|
198
|
-
class: "tr-image-preview__btn tr-image-preview__btn--download",
|
|
199
|
-
onClick: _
|
|
200
|
-
}, u[3] || (u[3] = [
|
|
201
|
-
l("span", null, "下载", -1)
|
|
202
|
-
]))
|
|
203
|
-
]),
|
|
204
|
-
l("button", {
|
|
205
|
-
class: "tr-image-preview__close",
|
|
206
|
-
onClick: b
|
|
207
|
-
}, "×")
|
|
208
|
-
])
|
|
209
|
-
])) : m("", !0);
|
|
210
|
-
}
|
|
211
|
-
}), Fe = /* @__PURE__ */ G(Te, [["__scopeId", "data-v-d04daa2e"]]), Re = ["data-file-type"], Le = { class: "tr-file-card__icon-wrapper" }, Se = {
|
|
212
|
-
key: 0,
|
|
213
|
-
class: "tr-file-card__overlay"
|
|
214
|
-
}, $e = {
|
|
215
|
-
key: 0,
|
|
216
|
-
class: "tr-file-card__loading-icon"
|
|
217
|
-
}, ze = { class: "tr-file-card__content" }, Ie = { class: "tr-file-card__info" }, Be = ["title"], Pe = {
|
|
218
|
-
key: 0,
|
|
219
|
-
class: "tr-file-card__status"
|
|
220
|
-
}, Ae = { class: "tr-file-card__file-type" }, Oe = {
|
|
221
|
-
key: 0,
|
|
222
|
-
class: "tr-file-card__file-size"
|
|
223
|
-
}, je = {
|
|
224
|
-
key: 1,
|
|
225
|
-
class: "tr-file-card__progress"
|
|
226
|
-
}, Ee = { class: "tr-file-card__progress-text" }, Me = { class: "tr-file-card__progress-bar" }, We = {
|
|
227
|
-
key: 2,
|
|
228
|
-
class: "tr-file-card__actions"
|
|
229
|
-
}, Ze = ["onClick"], Ne = { class: "tr-file-card__action-icon" }, Ve = {
|
|
230
|
-
key: 0,
|
|
231
|
-
class: "tr-file-card__retry"
|
|
232
|
-
}, Xe = { key: 0 }, Ye = { key: 1 }, qe = { key: 2 }, He = { key: 3 }, Je = { key: 4 }, Ke = { key: 5 }, Ge = /* @__PURE__ */ E({
|
|
233
|
-
__name: "FileCard",
|
|
234
|
-
props: {
|
|
235
|
-
file: {},
|
|
236
|
-
fileIcons: {},
|
|
237
|
-
disabled: { type: Boolean, default: !1 },
|
|
238
|
-
showPreview: { type: Boolean, default: !0 },
|
|
239
|
-
showStatus: { type: Boolean, default: !0 },
|
|
240
|
-
statusType: { default: "info" },
|
|
241
|
-
customActions: {}
|
|
242
|
-
},
|
|
243
|
-
emits: ["remove", "preview", "action", "retry", "download"],
|
|
244
|
-
setup(p, { emit: g }) {
|
|
245
|
-
const s = p, n = g, { formatFileSize: o } = Q(), e = P(!1), c = P(""), { getIconComponent: h } = Ue(s.fileIcons), b = k(() => h(s.file.fileType).value), _ = k(() => s.file.fileType === "image"), y = k(() => s.file.status === "uploading" || s.file.isUploading), u = k(() => s.file.status === "error"), U = () => {
|
|
246
|
-
_.value && s.file.previewUrl ? (c.value = s.file.previewUrl, e.value = !0) : _.value && s.file.rawFile ? (c.value = URL.createObjectURL(s.file.rawFile), e.value = !0) : n("preview", s.file);
|
|
247
|
-
}, A = () => {
|
|
248
|
-
e.value = !1, c.value && c.value.startsWith("blob:") && URL.revokeObjectURL(c.value);
|
|
249
|
-
}, S = () => {
|
|
250
|
-
if (s.file.previewUrl) {
|
|
251
|
-
const t = document.createElement("a");
|
|
252
|
-
t.href = s.file.previewUrl, t.download = s.file.name, t.target = "_blank", document.body.appendChild(t), t.click(), document.body.removeChild(t);
|
|
253
|
-
} else if (s.file.rawFile) {
|
|
254
|
-
const t = URL.createObjectURL(s.file.rawFile), v = document.createElement("a");
|
|
255
|
-
v.href = t, v.download = s.file.name, v.target = "_blank", document.body.appendChild(v), v.click(), document.body.removeChild(v), URL.revokeObjectURL(t);
|
|
256
|
-
}
|
|
257
|
-
n("download", s.file);
|
|
258
|
-
}, $ = () => {
|
|
259
|
-
n("remove", s.file);
|
|
260
|
-
}, C = (t) => {
|
|
261
|
-
t.handler && t.handler(s.file), t.type === "preview" && _.value ? U() : t.type === "download" && _.value ? S() : n("action", { action: t, file: s.file });
|
|
262
|
-
}, a = () => {
|
|
263
|
-
n("retry", s.file);
|
|
264
|
-
};
|
|
265
|
-
return (t, v) => {
|
|
266
|
-
var T;
|
|
267
|
-
return r(), d("div", {
|
|
268
|
-
class: F(["tr-file-card", [
|
|
269
|
-
`tr-file-card--${t.file.fileType || "other"}`,
|
|
270
|
-
t.file.status,
|
|
271
|
-
{
|
|
272
|
-
"tr-file-card--uploading": y.value,
|
|
273
|
-
"tr-file-card--error": u.value
|
|
274
|
-
}
|
|
275
|
-
]]),
|
|
276
|
-
"data-file-type": t.file.fileType || "other"
|
|
277
|
-
}, [
|
|
278
|
-
t.disabled ? m("", !0) : (r(), d("button", {
|
|
279
|
-
key: 0,
|
|
280
|
-
type: "button",
|
|
281
|
-
class: "tr-file-card__close",
|
|
282
|
-
onClick: $,
|
|
283
|
-
"aria-label": "移除文件"
|
|
284
|
-
}, v[1] || (v[1] = [
|
|
285
|
-
l("span", { class: "tr-file-card__close-icon" }, "×", -1)
|
|
286
|
-
]))),
|
|
287
|
-
l("div", {
|
|
288
|
-
class: F(["tr-file-card__icon", { "tr-file-card__icon--preview": _.value && t.showPreview }]),
|
|
289
|
-
onClick: v[0] || (v[0] = (R) => _.value && t.showPreview ? U() : null)
|
|
290
|
-
}, [
|
|
291
|
-
l("div", Le, [
|
|
292
|
-
(r(), L(le(b.value))),
|
|
293
|
-
y.value || u.value ? (r(), d("div", Se, [
|
|
294
|
-
y.value ? (r(), d("div", $e, [
|
|
295
|
-
ne(I(_e), {
|
|
296
|
-
width: 24,
|
|
297
|
-
height: 24
|
|
298
|
-
})
|
|
299
|
-
])) : m("", !0),
|
|
300
|
-
u.value ? (r(), L(I(he), {
|
|
301
|
-
key: 1,
|
|
302
|
-
width: 24,
|
|
303
|
-
height: 24
|
|
304
|
-
})) : m("", !0)
|
|
305
|
-
])) : m("", !0)
|
|
306
|
-
])
|
|
307
|
-
], 2),
|
|
308
|
-
l("div", ze, [
|
|
309
|
-
l("div", Ie, [
|
|
310
|
-
l("span", {
|
|
311
|
-
class: "tr-file-card__name",
|
|
312
|
-
title: t.file.name
|
|
313
|
-
}, D(t.file.name), 9, Be),
|
|
314
|
-
t.showStatus ? (r(), d("div", Pe, [
|
|
315
|
-
t.statusType === "info" ? (r(), d(z, { key: 0 }, [
|
|
316
|
-
l("span", Ae, D(((T = t.file.fileType) == null ? void 0 : T.toUpperCase()) || "FILE"), 1),
|
|
317
|
-
t.file.size ? (r(), d("span", Oe, D(I(o)(t.file.size)), 1)) : m("", !0)
|
|
318
|
-
], 64)) : t.statusType === "progress" && t.file.progress !== void 0 ? (r(), d("div", je, [
|
|
319
|
-
l("div", Ee, D(t.file.status || "处理中...") + " " + D(t.file.progress) + "%", 1),
|
|
320
|
-
l("div", Me, [
|
|
321
|
-
l("div", {
|
|
322
|
-
class: "tr-file-card__progress-inner",
|
|
323
|
-
style: B({ width: `${t.file.progress}%` })
|
|
324
|
-
}, null, 4)
|
|
325
|
-
])
|
|
326
|
-
])) : t.statusType === "operate" ? (r(), d("div", We, [
|
|
327
|
-
(r(!0), d(z, null, J(t.customActions, (R, M) => (r(), d("span", {
|
|
328
|
-
key: M,
|
|
329
|
-
class: F(["tr-file-card__action", `tr-file-card__action--${R.type}`]),
|
|
330
|
-
onClick: (V) => C(R)
|
|
331
|
-
}, [
|
|
332
|
-
l("span", Ne, D(R.label), 1)
|
|
333
|
-
], 10, Ze))), 128))
|
|
334
|
-
])) : t.statusType === "message" ? (r(), d(z, { key: 3 }, [
|
|
335
|
-
t.file.messageType === "error" && t.file.status === "error" ? (r(), d("div", Ve, [
|
|
336
|
-
v[2] || (v[2] = l("span", { class: "tr-file-card__error-text" }, "上传失败", -1)),
|
|
337
|
-
l("button", {
|
|
338
|
-
class: "tr-file-card__retry-btn",
|
|
339
|
-
onClick: a
|
|
340
|
-
}, "重试")
|
|
341
|
-
])) : (r(), d("div", {
|
|
342
|
-
key: 1,
|
|
343
|
-
class: F(["tr-file-card__message", `tr-file-card__message--${t.file.messageType || "info"}`])
|
|
344
|
-
}, [
|
|
345
|
-
t.file.messageType === "error" ? (r(), d("span", Xe, "上传失败")) : m("", !0),
|
|
346
|
-
t.file.messageType === "warning" ? (r(), d("span", Ye, "上传警告")) : m("", !0),
|
|
347
|
-
t.file.messageType === "success" ? (r(), d("span", qe, "上传成功")) : m("", !0),
|
|
348
|
-
t.file.messageType === "info" ? (r(), d("span", He, "处理中...")) : m("", !0),
|
|
349
|
-
t.file.messageType === "uploading" ? (r(), d("span", Je, "上传中...")) : m("", !0),
|
|
350
|
-
t.file.messageType ? m("", !0) : (r(), d("span", Ke, D(t.file.status || "状态信息"), 1))
|
|
351
|
-
], 2))
|
|
352
|
-
], 64)) : (r(), d(z, { key: 4 }, [
|
|
353
|
-
K(D(t.file.status), 1)
|
|
354
|
-
], 64))
|
|
355
|
-
])) : m("", !0)
|
|
356
|
-
])
|
|
357
|
-
]),
|
|
358
|
-
_.value ? (r(), L(Fe, {
|
|
359
|
-
key: 1,
|
|
360
|
-
visible: e.value,
|
|
361
|
-
"image-url": c.value,
|
|
362
|
-
onClose: A,
|
|
363
|
-
onDownload: S
|
|
364
|
-
}, null, 8, ["visible", "image-url"])) : m("", !0)
|
|
365
|
-
], 10, Re);
|
|
366
|
-
};
|
|
367
|
-
}
|
|
368
|
-
}), Qe = { class: "tr-fullscreen-overlay__content" }, xe = { class: "tr-fullscreen-overlay__text" }, et = { class: "tr-fullscreen-overlay__title" }, tt = { class: "tr-fullscreen-overlay__description" }, st = /* @__PURE__ */ E({
|
|
369
|
-
__name: "FullscreenOverlay",
|
|
370
|
-
props: {
|
|
371
|
-
visible: { type: Boolean },
|
|
372
|
-
config: {}
|
|
373
|
-
},
|
|
374
|
-
setup(p) {
|
|
375
|
-
const g = p, s = k(() => {
|
|
376
|
-
var o, e, c;
|
|
377
|
-
return {
|
|
378
|
-
zIndex: ((o = g.config) == null ? void 0 : o.zIndex) || 1e3,
|
|
379
|
-
"--enter-delay": `${((e = g.config) == null ? void 0 : e.enterDelay) || 200}ms`,
|
|
380
|
-
"--leave-delay": `${((c = g.config) == null ? void 0 : c.leaveDelay) || 200}ms`
|
|
381
|
-
};
|
|
382
|
-
}), n = k(() => {
|
|
383
|
-
var o;
|
|
384
|
-
return ((o = g.config) == null ? void 0 : o.className) || "";
|
|
385
|
-
});
|
|
386
|
-
return (o, e) => (r(), L(re, { name: "tr-fade" }, {
|
|
387
|
-
default: oe(() => [
|
|
388
|
-
o.visible ? (r(), d("div", {
|
|
389
|
-
key: 0,
|
|
390
|
-
class: F(["tr-fullscreen-overlay", [n.value]]),
|
|
391
|
-
style: B(s.value)
|
|
392
|
-
}, [
|
|
393
|
-
l("div", Qe, [
|
|
394
|
-
e[3] || (e[3] = l("div", { class: "tr-fullscreen-overlay__icon" }, [
|
|
395
|
-
l("svg", {
|
|
396
|
-
width: "64",
|
|
397
|
-
height: "64",
|
|
398
|
-
viewBox: "0 0 24 24",
|
|
399
|
-
fill: "currentColor"
|
|
400
|
-
}, [
|
|
401
|
-
l("path", { d: "M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM14 13v4h-4v-4H7l5-5 5 5h-3z" })
|
|
402
|
-
])
|
|
403
|
-
], -1)),
|
|
404
|
-
l("div", xe, [
|
|
405
|
-
l("div", et, [
|
|
406
|
-
H(o.$slots, "header", {}, () => [
|
|
407
|
-
e[0] || (e[0] = K(" 将附件拖到此处完成上传 "))
|
|
408
|
-
], !0)
|
|
409
|
-
]),
|
|
410
|
-
l("div", tt, [
|
|
411
|
-
H(o.$slots, "description", {}, () => [
|
|
412
|
-
e[1] || (e[1] = l("span", null, "总计最多上传50个附件(每个100MB以内)", -1)),
|
|
413
|
-
e[2] || (e[2] = l("span", null, "支持附件格式 PDF/Word/Excel/PPT/Markdown", -1))
|
|
414
|
-
], !0)
|
|
415
|
-
])
|
|
416
|
-
])
|
|
417
|
-
])
|
|
418
|
-
], 6)) : m("", !0)
|
|
419
|
-
]),
|
|
420
|
-
_: 3
|
|
421
|
-
}));
|
|
422
|
-
}
|
|
423
|
-
}), it = /* @__PURE__ */ G(st, [["__scopeId", "data-v-dcd22813"]]), lt = {
|
|
424
|
-
key: 1,
|
|
425
|
-
class: "tr-attachments__empty"
|
|
426
|
-
}, j = /* @__PURE__ */ E({
|
|
427
|
-
__name: "index",
|
|
428
|
-
props: {
|
|
429
|
-
items: {},
|
|
430
|
-
disabled: { type: Boolean, default: !1 },
|
|
431
|
-
overflow: { default: "wrap" },
|
|
432
|
-
drag: { type: [Boolean, Object] },
|
|
433
|
-
fileIcons: {},
|
|
434
|
-
rootClass: {},
|
|
435
|
-
styles: {},
|
|
436
|
-
statusType: { default: "info" },
|
|
437
|
-
customActions: {},
|
|
438
|
-
triggerUpload: { default: 0 }
|
|
439
|
-
},
|
|
440
|
-
emits: [
|
|
441
|
-
"update:items",
|
|
442
|
-
"files-dropped",
|
|
443
|
-
"file-remove",
|
|
444
|
-
"file-preview",
|
|
445
|
-
"file-download",
|
|
446
|
-
"file-retry",
|
|
447
|
-
"action"
|
|
448
|
-
],
|
|
449
|
-
setup(p, { expose: g, emit: s }) {
|
|
450
|
-
const n = p, o = s, e = P(n.items || []), { detectFileType: c, generateUID: h, formatFileSize: b, createPreviewUrl: _, createAttachments: y } = Q(), u = P(null), {
|
|
451
|
-
open: U,
|
|
452
|
-
reset: A,
|
|
453
|
-
onChange: S
|
|
454
|
-
} = ce({
|
|
455
|
-
multiple: !0,
|
|
456
|
-
accept: "*",
|
|
457
|
-
reset: !0
|
|
458
|
-
});
|
|
459
|
-
S((i) => {
|
|
460
|
-
if (i && i.length > 0) {
|
|
461
|
-
const f = Array.from(i);
|
|
462
|
-
v(f);
|
|
463
|
-
}
|
|
464
|
-
});
|
|
465
|
-
const $ = k(() => !!n.drag && !n.disabled), C = k(() => typeof n.drag == "object" && n.drag.mode === "fullscreen"), { dragState: a, initDrag: t } = we(
|
|
466
|
-
{
|
|
467
|
-
enabled: $.value,
|
|
468
|
-
onDrop: v
|
|
469
|
-
},
|
|
470
|
-
n
|
|
471
|
-
);
|
|
472
|
-
function v(i) {
|
|
473
|
-
if (n.disabled) return;
|
|
474
|
-
const f = i.map(
|
|
475
|
-
(w) => ({
|
|
476
|
-
uid: h(),
|
|
477
|
-
name: w.name,
|
|
478
|
-
status: "uploading",
|
|
479
|
-
fileType: c(w),
|
|
480
|
-
rawFile: w,
|
|
481
|
-
size: w.size,
|
|
482
|
-
previewUrl: _(w)
|
|
483
|
-
})
|
|
484
|
-
);
|
|
485
|
-
e.value = [...e.value, ...f], o("files-dropped", f), o("update:items", e.value);
|
|
486
|
-
}
|
|
487
|
-
function T() {
|
|
488
|
-
n.disabled || U();
|
|
489
|
-
}
|
|
490
|
-
function R(i) {
|
|
491
|
-
if (n.disabled) return;
|
|
492
|
-
const f = e.value.findIndex((w) => w.uid === i.uid);
|
|
493
|
-
f !== -1 && (i.previewUrl && i.previewUrl.startsWith("blob:") && URL.revokeObjectURL(i.previewUrl), e.value.splice(f, 1), o("file-remove", i), o("update:items", e.value));
|
|
494
|
-
}
|
|
495
|
-
function M(i) {
|
|
496
|
-
o("file-preview", i);
|
|
497
|
-
}
|
|
498
|
-
function V(i) {
|
|
499
|
-
o("file-download", i);
|
|
500
|
-
}
|
|
501
|
-
function x(i) {
|
|
502
|
-
const f = e.value.findIndex((w) => w.uid === i.uid);
|
|
503
|
-
f !== -1 && (e.value[f].status = "uploading", e.value[f].messageType = void 0, e.value[f].isUploading = !0, o("file-retry", i), o("update:items", e.value));
|
|
504
|
-
}
|
|
505
|
-
function ee(i) {
|
|
506
|
-
o("action", i);
|
|
507
|
-
}
|
|
508
|
-
O(
|
|
509
|
-
() => n.items,
|
|
510
|
-
(i) => {
|
|
511
|
-
i && (e.value = i);
|
|
512
|
-
},
|
|
513
|
-
{ deep: !0 }
|
|
514
|
-
), O(
|
|
515
|
-
() => n.triggerUpload,
|
|
516
|
-
(i, f) => {
|
|
517
|
-
i && i !== f && T();
|
|
518
|
-
}
|
|
519
|
-
);
|
|
520
|
-
const te = () => {
|
|
521
|
-
e.value.forEach((i) => {
|
|
522
|
-
i.previewUrl && i.previewUrl.startsWith("blob:") && URL.revokeObjectURL(i.previewUrl);
|
|
523
|
-
}), e.value = [], A(), o("update:items", e.value);
|
|
524
|
-
};
|
|
525
|
-
return ae(() => {
|
|
526
|
-
u.value && $.value && setTimeout(() => {
|
|
527
|
-
t();
|
|
528
|
-
}, 0);
|
|
529
|
-
}), g({
|
|
530
|
-
triggerUpload: T,
|
|
531
|
-
addFiles: v,
|
|
532
|
-
clearFiles: te,
|
|
533
|
-
getFiles: () => e.value,
|
|
534
|
-
getFileCount: () => e.value.length,
|
|
535
|
-
hasFiles: () => e.value.length > 0,
|
|
536
|
-
formatFileSize: b,
|
|
537
|
-
createAttachments: y
|
|
538
|
-
}), (i, f) => {
|
|
539
|
-
var w, X;
|
|
540
|
-
return r(), d("div", {
|
|
541
|
-
class: F(["tr-attachments", [i.rootClass, { "tr-attachments--dragging": I(a).active && !C.value }]]),
|
|
542
|
-
style: B((w = i.styles) == null ? void 0 : w.root)
|
|
543
|
-
}, [
|
|
544
|
-
l("div", {
|
|
545
|
-
ref_key: "dropZoneRef",
|
|
546
|
-
ref: u,
|
|
547
|
-
class: "tr-attachments__dropzone",
|
|
548
|
-
onClick: T
|
|
549
|
-
}, [
|
|
550
|
-
e.value.length > 0 ? (r(), d("div", {
|
|
551
|
-
key: 0,
|
|
552
|
-
class: F(["tr-attachments__file-list", `tr-attachments__file-list--${i.overflow}`]),
|
|
553
|
-
onClick: f[0] || (f[0] = N(() => {
|
|
554
|
-
}, ["stop"]))
|
|
555
|
-
}, [
|
|
556
|
-
(r(!0), d(z, null, J(e.value, (Y) => {
|
|
557
|
-
var q;
|
|
558
|
-
return r(), L(Ge, {
|
|
559
|
-
key: Y.uid,
|
|
560
|
-
file: Y,
|
|
561
|
-
"file-icons": i.fileIcons,
|
|
562
|
-
disabled: i.disabled,
|
|
563
|
-
style: B((q = i.styles) == null ? void 0 : q.card),
|
|
564
|
-
"status-type": i.statusType,
|
|
565
|
-
"custom-actions": i.customActions,
|
|
566
|
-
"show-status": !0,
|
|
567
|
-
onRemove: R,
|
|
568
|
-
onPreview: M,
|
|
569
|
-
onDownload: V,
|
|
570
|
-
onRetry: x,
|
|
571
|
-
onAction: ee
|
|
572
|
-
}, null, 8, ["file", "file-icons", "disabled", "style", "status-type", "custom-actions"]);
|
|
573
|
-
}), 128)),
|
|
574
|
-
i.disabled ? m("", !0) : (r(), d("div", {
|
|
575
|
-
key: 0,
|
|
576
|
-
class: "tr-attachments__add-button",
|
|
577
|
-
onClick: N(T, ["stop"])
|
|
578
|
-
}, f[1] || (f[1] = [
|
|
579
|
-
l("div", { class: "tr-attachments__add-icon" }, "+", -1)
|
|
580
|
-
])))
|
|
581
|
-
], 2)) : (r(), d("div", lt, f[2] || (f[2] = [
|
|
582
|
-
de('<div class="tr-attachments__empty-icon"><svg width="24" height="24" viewBox="0 0 24 24" fill="#bdbdbd"><path d="M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM14 13v4h-4v-4H7l5-5 5 5h-3z"></path></svg></div><div class="tr-attachments__empty-text">暂无文件</div><div class="tr-attachments__empty-hint">将文件拖拽到此处,或点击上传</div>', 3)
|
|
583
|
-
])))
|
|
584
|
-
], 512),
|
|
585
|
-
C.value ? (r(), L(it, {
|
|
586
|
-
key: 0,
|
|
587
|
-
visible: I(a).active,
|
|
588
|
-
config: typeof i.drag == "object" ? i.drag.overlay : void 0,
|
|
589
|
-
style: B((X = i.styles) == null ? void 0 : X.overlay)
|
|
590
|
-
}, null, 8, ["visible", "config", "style"])) : m("", !0)
|
|
591
|
-
], 6);
|
|
592
|
-
};
|
|
593
|
-
}
|
|
594
|
-
});
|
|
595
|
-
j.name = "TrAttachments";
|
|
596
|
-
const nt = function(p) {
|
|
597
|
-
p.component(j.name, j);
|
|
598
|
-
};
|
|
599
|
-
j.install = nt;
|
|
600
|
-
export {
|
|
601
|
-
j as default
|
|
602
|
-
};
|