@matechat/core 1.10.0 → 1.11.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Attachment/Attachment.vue.d.ts +121 -0
- package/Attachment/attachment-types.d.ts +103 -0
- package/Attachment/drop-area.vue.d.ts +13 -0
- package/Attachment/index.css +1 -1
- package/Attachment/index.d.ts +2 -0
- package/Attachment/index.js +211 -311
- package/Attachment/uploader.d.ts +11 -0
- package/Attachment/use-upload.d.ts +8 -0
- package/Bubble/Bubble.vue.d.ts +75 -0
- package/Bubble/BubbleLoading.vue.d.ts +3 -0
- package/Bubble/bubble-constants.d.ts +4 -0
- package/Bubble/bubble-types.d.ts +38 -0
- package/Bubble/components/Avatar.vue.d.ts +57 -0
- package/Bubble/components/AvatarBodyIcon.vue.d.ts +24 -0
- package/Bubble/components/AvatarNoBodyIcon.vue.d.ts +24 -0
- package/Bubble/components/avatar-types.d.ts +25 -0
- package/Bubble/index.css +1 -1
- package/Bubble/index.d.ts +2 -0
- package/Bubble/index.js +142 -148
- package/FileList/FileIcon/CodeFile.vue.d.ts +10 -0
- package/FileList/FileIcon/CompressedFile.vue.d.ts +10 -0
- package/FileList/FileIcon/DefaultFileIcon.vue.d.ts +10 -0
- package/FileList/FileIcon/Document.vue.d.ts +10 -0
- package/FileList/FileIcon/DrawingBoard.vue.d.ts +10 -0
- package/FileList/FileIcon/EmailFile.vue.d.ts +10 -0
- package/FileList/FileIcon/Excel.vue.d.ts +10 -0
- package/FileList/FileIcon/FlowChart.vue.d.ts +10 -0
- package/FileList/FileIcon/FolderClosed.vue.d.ts +10 -0
- package/FileList/FileIcon/FolderOpen.vue.d.ts +10 -0
- package/FileList/FileIcon/Image.vue.d.ts +10 -0
- package/FileList/FileIcon/Markdown.vue.d.ts +10 -0
- package/FileList/FileIcon/Mind.vue.d.ts +10 -0
- package/FileList/FileIcon/Mp4.vue.d.ts +10 -0
- package/FileList/FileIcon/MultidimentionalTable.vue.d.ts +10 -0
- package/FileList/FileIcon/Page.vue.d.ts +10 -0
- package/FileList/FileIcon/Pdf.vue.d.ts +10 -0
- package/FileList/FileIcon/Ppt.vue.d.ts +10 -0
- package/FileList/FileIcon/Unknown.vue.d.ts +10 -0
- package/FileList/FileIcon/Wrong.vue.d.ts +10 -0
- package/FileList/FileList.vue.d.ts +36 -0
- package/FileList/fileList-types.d.ts +21 -0
- package/FileList/index.d.ts +2 -0
- package/FileList/index.js +220 -228
- package/Header/Header.vue.d.ts +47 -0
- package/Header/header-types.d.ts +14 -0
- package/Header/index.d.ts +2 -0
- package/Header/index.js +0 -1
- package/Input/Input.vue.d.ts +165 -0
- package/Input/components/EditableBlock.vue.d.ts +101 -0
- package/Input/components/InputTag.vue.d.ts +30 -0
- package/Input/components/LoadingIcon.vue.d.ts +3 -0
- package/Input/components/SendIcon.vue.d.ts +3 -0
- package/Input/components/button.vue.d.ts +3 -0
- package/Input/components/textarea-utils.d.ts +17 -0
- package/Input/components/textarea.vue.d.ts +3 -0
- package/Input/components/use-textarea-autosize.d.ts +12 -0
- package/Input/components/util.d.ts +3 -0
- package/Input/index.css +1 -1
- package/Input/index.d.ts +2 -0
- package/Input/index.js +114 -252
- package/Input/input-types.d.ts +118 -0
- package/Introduction/Introduction.vue.d.ts +88 -0
- package/Introduction/index.css +1 -1
- package/Introduction/index.d.ts +2 -0
- package/Introduction/index.js +8 -9
- package/Introduction/introduction-types.d.ts +37 -0
- package/Layout/Aside.vue.d.ts +13 -0
- package/Layout/Content.vue.d.ts +13 -0
- package/Layout/Header.vue.d.ts +13 -0
- package/Layout/Layout.vue.d.ts +13 -0
- package/Layout/Sender.vue.d.ts +13 -0
- package/Layout/index.d.ts +6 -0
- package/Layout/index.js +0 -1
- package/List/List.vue.d.ts +98 -0
- package/List/const.d.ts +5 -0
- package/List/index.css +1 -1
- package/List/index.d.ts +3 -0
- package/List/index.js +51 -54
- package/List/list-types.d.ts +52 -0
- package/List/use-list.d.ts +13 -0
- package/Locale/i18n.d.ts +21 -0
- package/Locale/index.d.ts +7 -0
- package/Locale/index.js +35 -103
- package/Locale/lang/en-us.d.ts +34 -0
- package/Locale/lang/zh-cn.d.ts +34 -0
- package/MarkdownCard/CodeBlock.vue.d.ts +76 -0
- package/MarkdownCard/MDCardParser.d.ts +12 -0
- package/MarkdownCard/MDCardService.d.ts +14 -0
- package/MarkdownCard/MermaidService.d.ts +22 -0
- package/MarkdownCard/index.css +1 -1
- package/MarkdownCard/index.d.ts +2 -0
- package/MarkdownCard/index.js +205 -559
- package/MarkdownCard/mdCard.types.d.ts +88 -0
- package/MarkdownCard/mdCard.vue.d.ts +29 -0
- package/Mention/Mention.vue.d.ts +51 -0
- package/Mention/const.d.ts +4 -0
- package/Mention/index.d.ts +2 -0
- package/Mention/index.js +0 -1
- package/Mention/mention-types.d.ts +24 -0
- package/Mention/use-mention.d.ts +10 -0
- package/Prompt/Prompt.vue.d.ts +38 -0
- package/Prompt/PromptItem.vue.d.ts +11 -0
- package/Prompt/components/Icon.vue.d.ts +42 -0
- package/Prompt/components/icon-types.d.ts +18 -0
- package/Prompt/index.d.ts +2 -0
- package/Prompt/prompt-types.d.ts +33 -0
- package/README.md +12 -8
- package/Toolbar/Toolbar.vue.d.ts +68 -0
- package/Toolbar/icon/CopyIcon.vue.d.ts +42 -0
- package/Toolbar/icon/DeleteIcon.vue.d.ts +42 -0
- package/Toolbar/icon/DislikeIcon.vue.d.ts +46 -0
- package/Toolbar/icon/LikeIcon.vue.d.ts +46 -0
- package/Toolbar/icon/RefreshIcon.vue.d.ts +42 -0
- package/Toolbar/icon/ShareIcon.vue.d.ts +42 -0
- package/Toolbar/index.css +1 -0
- package/Toolbar/index.d.ts +8 -0
- package/Toolbar/index.js +519 -0
- package/Toolbar/toolbar.types.d.ts +60 -0
- package/mate-chat.js +0 -6
- package/package.json +4 -1
package/Attachment/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import "./index.css";
|
|
2
|
-
import {
|
|
3
|
-
import { useMcI18n as
|
|
4
|
-
const
|
|
2
|
+
import { computed as P, defineComponent as E, inject as U, ref as b, watch as N, onMounted as S, onBeforeUnmount as R, createBlock as k, openBlock as T, Teleport as V, withDirectives as M, createElementVNode as w, renderSlot as A, vShow as O, mergeModels as x, useSlots as B, useModel as $, provide as j, createElementBlock as z, unref as g, normalizeClass as _, createCommentVNode as H, withCtx as L, createTextVNode as W, toDisplayString as q } from "vue";
|
|
3
|
+
import { useMcI18n as Y } from "@matechat/core/Locale";
|
|
4
|
+
const K = {
|
|
5
5
|
uploadOptions: {
|
|
6
6
|
type: Object,
|
|
7
|
-
default: {}
|
|
7
|
+
default: () => ({})
|
|
8
8
|
},
|
|
9
9
|
disabled: {
|
|
10
10
|
type: Boolean,
|
|
@@ -14,6 +14,9 @@ const Q = {
|
|
|
14
14
|
type: String,
|
|
15
15
|
default: ""
|
|
16
16
|
},
|
|
17
|
+
dropPlaceholder: {
|
|
18
|
+
type: String
|
|
19
|
+
},
|
|
17
20
|
maxCount: {
|
|
18
21
|
type: Number,
|
|
19
22
|
default: Number.POSITIVE_INFINITY
|
|
@@ -33,355 +36,252 @@ const Q = {
|
|
|
33
36
|
beforeUpload: {
|
|
34
37
|
type: Function,
|
|
35
38
|
default: null
|
|
36
|
-
}
|
|
37
|
-
}, Z = {
|
|
38
|
-
change: (e, s) => e instanceof File && Array.isArray(s),
|
|
39
|
-
success: (e, s, t) => e instanceof File && Array.isArray(t),
|
|
40
|
-
error: (e, s, t) => e instanceof File && Array.isArray(t),
|
|
41
|
-
progress: (e, s) => e instanceof File && Array.isArray(s),
|
|
42
|
-
drop: (e) => Array.isArray(e)
|
|
43
|
-
}, ee = { class: "mc-alert__header" }, te = { class: "mc-alert__title" }, ae = { class: "mc-alert__content" }, ne = { class: "mc-alert__message" };
|
|
44
|
-
function z(e) {
|
|
45
|
-
const s = document.createElement("div");
|
|
46
|
-
document.body.appendChild(s);
|
|
47
|
-
const t = $({
|
|
48
|
-
render() {
|
|
49
|
-
return H(se, {
|
|
50
|
-
...e,
|
|
51
|
-
// 这个函数将作为 'onClose' prop 传递给 AlertComponent 实例
|
|
52
|
-
onClose: () => {
|
|
53
|
-
t.unmount(), s.parentNode && s.parentNode.removeChild(s);
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
t.mount(s);
|
|
59
|
-
}
|
|
60
|
-
const se = /* @__PURE__ */ P({
|
|
61
|
-
__name: "Alert",
|
|
62
|
-
props: {
|
|
63
|
-
type: {
|
|
64
|
-
type: String,
|
|
65
|
-
default: "info"
|
|
66
|
-
},
|
|
67
|
-
title: {
|
|
68
|
-
type: String,
|
|
69
|
-
required: !0
|
|
70
|
-
},
|
|
71
|
-
message: {
|
|
72
|
-
type: String,
|
|
73
|
-
required: !0
|
|
74
|
-
},
|
|
75
|
-
duration: {
|
|
76
|
-
type: Number,
|
|
77
|
-
default: 4500
|
|
78
|
-
},
|
|
79
|
-
// 这个 prop 由上面的 showAlert 函数传入
|
|
80
|
-
onClose: {
|
|
81
|
-
type: Function,
|
|
82
|
-
required: !0
|
|
83
|
-
}
|
|
84
39
|
},
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
R(() => {
|
|
88
|
-
t.value = !0, s.duration > 0 && setTimeout(l, s.duration);
|
|
89
|
-
});
|
|
90
|
-
function l() {
|
|
91
|
-
t.value = !1, setTimeout(() => {
|
|
92
|
-
s.onClose();
|
|
93
|
-
}, 300);
|
|
94
|
-
}
|
|
95
|
-
return (m, f) => (v(), j(L, { name: "mc-alert-fade" }, {
|
|
96
|
-
default: W(() => [
|
|
97
|
-
t.value ? (v(), F(
|
|
98
|
-
"div",
|
|
99
|
-
{
|
|
100
|
-
key: 0,
|
|
101
|
-
class: S(["mc-alert", `mc-alert--${e.type}`])
|
|
102
|
-
},
|
|
103
|
-
[
|
|
104
|
-
g("div", ee, [
|
|
105
|
-
g(
|
|
106
|
-
"span",
|
|
107
|
-
te,
|
|
108
|
-
_(e.title),
|
|
109
|
-
1
|
|
110
|
-
/* TEXT */
|
|
111
|
-
),
|
|
112
|
-
g("button", {
|
|
113
|
-
class: "mc-alert__close-btn",
|
|
114
|
-
onClick: l
|
|
115
|
-
}, "✕")
|
|
116
|
-
]),
|
|
117
|
-
g("div", ae, [
|
|
118
|
-
g(
|
|
119
|
-
"pre",
|
|
120
|
-
ne,
|
|
121
|
-
_(e.message),
|
|
122
|
-
1
|
|
123
|
-
/* TEXT */
|
|
124
|
-
)
|
|
125
|
-
])
|
|
126
|
-
],
|
|
127
|
-
2
|
|
128
|
-
/* CLASS */
|
|
129
|
-
)) : E("v-if", !0)
|
|
130
|
-
]),
|
|
131
|
-
_: 1
|
|
132
|
-
/* STABLE */
|
|
133
|
-
}));
|
|
40
|
+
getDropContainer: {
|
|
41
|
+
type: Function
|
|
134
42
|
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
a
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
43
|
+
}, X = {
|
|
44
|
+
change: (a, s) => a instanceof File && Array.isArray(s),
|
|
45
|
+
success: (a, s, o) => a instanceof File && Array.isArray(o),
|
|
46
|
+
error: (a, s, o) => a instanceof File && Array.isArray(o),
|
|
47
|
+
progress: (a, s) => a instanceof File && Array.isArray(s),
|
|
48
|
+
drop: (a) => Array.isArray(a),
|
|
49
|
+
validChange: (a) => Array.isArray(a)
|
|
50
|
+
}, I = "mc-attachment";
|
|
51
|
+
function G(a) {
|
|
52
|
+
const { file: s, options: o, onProgress: i, onSuccess: h, onError: p } = a, t = new XMLHttpRequest();
|
|
53
|
+
t.upload.onprogress = (l) => {
|
|
54
|
+
if (l.lengthComputable) {
|
|
55
|
+
const r = Math.round(l.loaded * 100 / l.total);
|
|
56
|
+
i(r);
|
|
142
57
|
}
|
|
143
|
-
},
|
|
144
|
-
|
|
58
|
+
}, t.onerror = () => {
|
|
59
|
+
p({
|
|
145
60
|
message: "Upload failed due to a network error.",
|
|
146
|
-
status:
|
|
147
|
-
statusText:
|
|
61
|
+
status: t.status,
|
|
62
|
+
statusText: t.statusText
|
|
148
63
|
});
|
|
149
|
-
},
|
|
150
|
-
if (
|
|
151
|
-
const
|
|
152
|
-
|
|
64
|
+
}, t.onload = () => {
|
|
65
|
+
if (t.status >= 200 && t.status < 300) {
|
|
66
|
+
const l = o.responseType === "text" || !t.response ? t.responseText : t.response;
|
|
67
|
+
h(l);
|
|
153
68
|
} else
|
|
154
|
-
|
|
155
|
-
message: `Upload failed with status: ${
|
|
156
|
-
status:
|
|
157
|
-
statusText:
|
|
158
|
-
response:
|
|
69
|
+
p({
|
|
70
|
+
message: `Upload failed with status: ${t.status}`,
|
|
71
|
+
status: t.status,
|
|
72
|
+
statusText: t.statusText,
|
|
73
|
+
response: t.response
|
|
159
74
|
});
|
|
160
75
|
};
|
|
161
|
-
const
|
|
162
|
-
if (
|
|
163
|
-
for (const
|
|
164
|
-
|
|
165
|
-
if (
|
|
166
|
-
for (const
|
|
167
|
-
|
|
168
|
-
if (
|
|
169
|
-
const
|
|
170
|
-
|
|
76
|
+
const c = new FormData(), m = o.fileFieldName || "file";
|
|
77
|
+
if (c.append(m, s, s.name), o.additionalParameter)
|
|
78
|
+
for (const l of Object.keys(o.additionalParameter))
|
|
79
|
+
c.append(l, o.additionalParameter[l]);
|
|
80
|
+
if (t.open(o.method || "POST", o.uri, !0), o.withCredentials && (t.withCredentials = !0), o.responseType && (t.responseType = o.responseType), o.headers)
|
|
81
|
+
for (const l of Object.keys(o.headers))
|
|
82
|
+
t.setRequestHeader(l, o.headers[l]);
|
|
83
|
+
if (o.authToken) {
|
|
84
|
+
const l = o.authTokenHeader || "Authorization";
|
|
85
|
+
t.setRequestHeader(l, o.authToken);
|
|
171
86
|
}
|
|
172
|
-
|
|
87
|
+
t.send(c);
|
|
173
88
|
}
|
|
174
|
-
let
|
|
175
|
-
function
|
|
176
|
-
const
|
|
177
|
-
|
|
178
|
-
const p = Y(() => e.disabled || l.value.length >= e.maxCount), b = (n) => {
|
|
179
|
-
const d = URL.createObjectURL(n);
|
|
89
|
+
let J = Date.now();
|
|
90
|
+
function Q(a, s, o, i) {
|
|
91
|
+
const h = P(() => a.disabled || i.value.length >= a.maxCount), p = (r) => {
|
|
92
|
+
const d = URL.createObjectURL(r);
|
|
180
93
|
return {
|
|
181
|
-
uid:
|
|
182
|
-
name:
|
|
183
|
-
size:
|
|
184
|
-
type:
|
|
94
|
+
uid: J++,
|
|
95
|
+
name: r.name,
|
|
96
|
+
size: r.size,
|
|
97
|
+
type: r.type,
|
|
185
98
|
status: "uploading",
|
|
186
99
|
percentage: 0,
|
|
187
100
|
url: d,
|
|
188
101
|
thumbUrl: d
|
|
189
102
|
};
|
|
190
|
-
},
|
|
191
|
-
if (
|
|
192
|
-
if (
|
|
193
|
-
|
|
194
|
-
type: "error",
|
|
195
|
-
title: m("Attachment.exceedCountTitle"),
|
|
196
|
-
message: m("Attachment.exceedCountMessage", {
|
|
197
|
-
maxCount: e.maxCount
|
|
198
|
-
})
|
|
199
|
-
});
|
|
103
|
+
}, t = async (r) => {
|
|
104
|
+
if (r.length === 0) return;
|
|
105
|
+
if (i.value.length + r.length > a.maxCount) {
|
|
106
|
+
s("validChange", [{ type: "exceedCount" }]);
|
|
200
107
|
return;
|
|
201
108
|
}
|
|
202
|
-
const d = [],
|
|
203
|
-
for (const
|
|
204
|
-
let
|
|
205
|
-
if (
|
|
206
|
-
const
|
|
207
|
-
|
|
208
|
-
m("Attachment.unsupportedFileType", { fileName: o.name })
|
|
209
|
-
), r = !1);
|
|
109
|
+
const d = [], u = [];
|
|
110
|
+
for (const n of r) {
|
|
111
|
+
let e = !0;
|
|
112
|
+
if (a.accept && a.accept !== "*") {
|
|
113
|
+
const f = a.accept.split(",").map((y) => y.trim().toLowerCase()), v = n.type.toLowerCase(), C = n.name.toLowerCase();
|
|
114
|
+
f.some((y) => y.endsWith("/*") ? v.startsWith(y.slice(0, -1)) : y.startsWith(".") ? C.endsWith(y) : v === y) || (u.push({ type: "unsupportedFileType", file: n }), e = !1);
|
|
210
115
|
}
|
|
211
|
-
if (
|
|
212
|
-
m("Attachment.exceedSizeLimit", {
|
|
213
|
-
fileName: o.name,
|
|
214
|
-
maxSize: e.maxSize
|
|
215
|
-
})
|
|
216
|
-
), r = !1), r && e.beforeUpload)
|
|
116
|
+
if (e && n.size / 1024 / 1024 > a.maxSize && (u.push({ type: "exceedSizeLimit", file: n }), e = !1), e && a.beforeUpload)
|
|
217
117
|
try {
|
|
218
|
-
await Promise.resolve(
|
|
219
|
-
|
|
220
|
-
),
|
|
221
|
-
} catch (C) {
|
|
222
|
-
const k = C instanceof Error ? C.message : String(C);
|
|
223
|
-
c.push(
|
|
224
|
-
m("Attachment.beforeUploadFailed", {
|
|
225
|
-
fileName: o.name,
|
|
226
|
-
errorMsg: k
|
|
227
|
-
})
|
|
228
|
-
), r = !1;
|
|
118
|
+
await Promise.resolve(a.beforeUpload(n)) === !1 && (u.push({ type: "beforeUploadRejected", file: n }), e = !1);
|
|
119
|
+
} catch {
|
|
120
|
+
u.push({ type: "beforeUploadRejected", file: n }), e = !1;
|
|
229
121
|
}
|
|
230
|
-
|
|
122
|
+
e && d.push(n);
|
|
231
123
|
}
|
|
232
|
-
if (
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
`)
|
|
237
|
-
}), d.length !== 0)
|
|
238
|
-
for (const o of d) {
|
|
239
|
-
const r = b(o);
|
|
240
|
-
l.value.push(r), s("change", o, [...l.value]), h(o, r);
|
|
124
|
+
if (u.length > 0 && s("validChange", u), d.length !== 0)
|
|
125
|
+
for (const n of d) {
|
|
126
|
+
const e = p(n);
|
|
127
|
+
i.value.push(e), s("change", n, [...i.value]), c(n, e);
|
|
241
128
|
}
|
|
242
|
-
},
|
|
243
|
-
const
|
|
244
|
-
|
|
245
|
-
file:
|
|
246
|
-
options:
|
|
247
|
-
onProgress: (
|
|
248
|
-
const
|
|
249
|
-
|
|
129
|
+
}, c = (r, d) => {
|
|
130
|
+
const u = () => i.value.findIndex((n) => n.uid === d.uid);
|
|
131
|
+
G({
|
|
132
|
+
file: r,
|
|
133
|
+
options: a.uploadOptions,
|
|
134
|
+
onProgress: (n) => {
|
|
135
|
+
const e = u();
|
|
136
|
+
e > -1 && (i.value[e].percentage = n, s("progress", r, [...i.value]));
|
|
250
137
|
},
|
|
251
|
-
onSuccess: (
|
|
252
|
-
const
|
|
253
|
-
|
|
138
|
+
onSuccess: (n) => {
|
|
139
|
+
const e = u();
|
|
140
|
+
e > -1 && (i.value[e].status = "success", i.value[e].response = n, s("success", r, n, [...i.value]));
|
|
254
141
|
},
|
|
255
|
-
onError: (
|
|
256
|
-
const
|
|
257
|
-
|
|
142
|
+
onError: (n) => {
|
|
143
|
+
const e = u();
|
|
144
|
+
e > -1 && (i.value[e].status = "uploadError", i.value[e].error = n, s("error", r, n, [...i.value]));
|
|
258
145
|
}
|
|
259
146
|
});
|
|
260
|
-
}, x = (n) => {
|
|
261
|
-
const d = n.target.files;
|
|
262
|
-
d && i(Array.from(d));
|
|
263
|
-
}, A = () => {
|
|
264
|
-
var n;
|
|
265
|
-
p.value || (n = t.value) == null || n.click();
|
|
266
|
-
}, T = (n) => {
|
|
267
|
-
n.preventDefault(), a++, a === 1 && (f.value = !0);
|
|
268
|
-
}, I = (n) => {
|
|
269
|
-
n.preventDefault();
|
|
270
|
-
}, U = (n) => {
|
|
271
|
-
n.preventDefault(), a--, a === 0 && (f.value = !1);
|
|
272
|
-
}, w = (n) => {
|
|
273
|
-
var c;
|
|
274
|
-
if (n.preventDefault(), f.value = !1, a = 0, p.value) return;
|
|
275
|
-
const d = Array.from(((c = n.dataTransfer) == null ? void 0 : c.files) || []);
|
|
276
|
-
d.length > 0 && (s("drop", d), i(d));
|
|
277
147
|
};
|
|
278
|
-
return
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
148
|
+
return {
|
|
149
|
+
isDisabled: h,
|
|
150
|
+
handleClick: () => {
|
|
151
|
+
var r;
|
|
152
|
+
h.value || (r = o.value) == null || r.click();
|
|
153
|
+
},
|
|
154
|
+
handleFileChange: (r) => {
|
|
155
|
+
const d = r.target.files;
|
|
156
|
+
d && t(Array.from(d));
|
|
157
|
+
},
|
|
158
|
+
uploadFiles: t
|
|
287
159
|
};
|
|
288
160
|
}
|
|
289
|
-
const
|
|
161
|
+
const Z = /* @__PURE__ */ E({
|
|
162
|
+
__name: "drop-area",
|
|
163
|
+
setup(a) {
|
|
164
|
+
const { rootProps: s, rootEmits: o, isDisabled: i, uploadFiles: h } = U(
|
|
165
|
+
I
|
|
166
|
+
), p = b(), t = b(), c = b(!1);
|
|
167
|
+
let m = 0;
|
|
168
|
+
N(
|
|
169
|
+
() => s.getDropContainer,
|
|
170
|
+
(e) => {
|
|
171
|
+
if (e) {
|
|
172
|
+
const f = e();
|
|
173
|
+
p.value !== f && (p.value = f);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
);
|
|
177
|
+
const l = (e) => {
|
|
178
|
+
if (e.preventDefault(), m++, m === 1 && (c.value = !0), p.value && t.value)
|
|
179
|
+
if (p.value === document.body)
|
|
180
|
+
t.value.style.inset = "0";
|
|
181
|
+
else {
|
|
182
|
+
const { x: f, y: v, width: C, height: D } = p.value.getBoundingClientRect();
|
|
183
|
+
t.value.style.width = `${C}px`, t.value.style.height = `${D}px`, t.value.style.top = `${v}px`, t.value.style.left = `${f}px`;
|
|
184
|
+
}
|
|
185
|
+
}, r = (e) => {
|
|
186
|
+
e.preventDefault();
|
|
187
|
+
}, d = (e) => {
|
|
188
|
+
e.preventDefault(), m--, m === 0 && (c.value = !1);
|
|
189
|
+
}, u = (e) => {
|
|
190
|
+
var v;
|
|
191
|
+
if (e.preventDefault(), c.value = !1, m = 0, i.value) return;
|
|
192
|
+
const f = Array.from(((v = e.dataTransfer) == null ? void 0 : v.files) || []);
|
|
193
|
+
f.length > 0 && (o("drop", f), h(f));
|
|
194
|
+
};
|
|
195
|
+
function n(e) {
|
|
196
|
+
e.preventDefault(), c.value = !1, m = 0;
|
|
197
|
+
}
|
|
198
|
+
return S(() => {
|
|
199
|
+
s.getDropContainer && (p.value = s.getDropContainer()), document.body.addEventListener("dragenter", l), document.body.addEventListener("dragover", r), document.body.addEventListener("dragleave", d), document.body.addEventListener("drop", n);
|
|
200
|
+
}), R(() => {
|
|
201
|
+
document.body.removeEventListener("dragenter", l), document.body.removeEventListener("dragover", r), document.body.removeEventListener("dragleave", d), document.body.removeEventListener("drop", n);
|
|
202
|
+
}), (e, f) => (T(), k(V, { to: "body" }, [
|
|
203
|
+
M(w(
|
|
204
|
+
"div",
|
|
205
|
+
{
|
|
206
|
+
ref_key: "dropAreaEl",
|
|
207
|
+
ref: t,
|
|
208
|
+
class: "mc-attachment-drop-area",
|
|
209
|
+
onDrop: u
|
|
210
|
+
},
|
|
211
|
+
[
|
|
212
|
+
A(e.$slots, "default")
|
|
213
|
+
],
|
|
214
|
+
544
|
|
215
|
+
/* NEED_HYDRATION, NEED_PATCH */
|
|
216
|
+
), [
|
|
217
|
+
[O, c.value]
|
|
218
|
+
])
|
|
219
|
+
]));
|
|
220
|
+
}
|
|
221
|
+
}), ee = ["accept", "multiple", "disabled"], F = /* @__PURE__ */ E({
|
|
290
222
|
name: "McAttachment",
|
|
291
223
|
__name: "Attachment",
|
|
292
|
-
props: /* @__PURE__ */
|
|
224
|
+
props: /* @__PURE__ */ x(K, {
|
|
293
225
|
modelValue: { default: [] },
|
|
294
226
|
modelModifiers: {}
|
|
295
227
|
}),
|
|
296
|
-
emits: /* @__PURE__ */
|
|
297
|
-
setup(
|
|
298
|
-
const
|
|
228
|
+
emits: /* @__PURE__ */ x(X, ["update:modelValue"]),
|
|
229
|
+
setup(a, { emit: s }) {
|
|
230
|
+
const o = a, i = s;
|
|
231
|
+
B();
|
|
232
|
+
const h = $(a, "modelValue"), { t: p } = Y(), t = b(), { handleClick: c, handleFileChange: m, isDisabled: l, uploadFiles: r } = Q(
|
|
233
|
+
o,
|
|
234
|
+
i,
|
|
299
235
|
t,
|
|
300
|
-
|
|
301
|
-
a,
|
|
302
|
-
m
|
|
236
|
+
h
|
|
303
237
|
);
|
|
304
|
-
return (
|
|
305
|
-
|
|
306
|
-
|
|
238
|
+
return j(I, {
|
|
239
|
+
rootProps: o,
|
|
240
|
+
rootEmits: i,
|
|
241
|
+
isDisabled: l,
|
|
242
|
+
uploadFiles: r
|
|
243
|
+
}), (d, u) => (T(), z(
|
|
244
|
+
"div",
|
|
245
|
+
{
|
|
246
|
+
class: _(["mc-attachment", { "is-disabled": g(l) }]),
|
|
247
|
+
onClick: u[1] || (u[1] = //@ts-ignore
|
|
248
|
+
(...n) => g(c) && g(c)(...n))
|
|
249
|
+
},
|
|
307
250
|
[
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
}, null, 40, de)
|
|
334
|
-
],
|
|
335
|
-
2
|
|
336
|
-
/* CLASS */
|
|
337
|
-
),
|
|
338
|
-
(v(), j(K, { to: "body" }, [
|
|
339
|
-
u(i) ? (v(), F(
|
|
340
|
-
"div",
|
|
341
|
-
{
|
|
342
|
-
key: 0,
|
|
343
|
-
class: S(["mc-attachment-drag-modal", { "is-disabled": u(h) }])
|
|
344
|
-
},
|
|
345
|
-
[
|
|
346
|
-
u(h) ? (v(), F(
|
|
347
|
-
N,
|
|
348
|
-
{ key: 0 },
|
|
349
|
-
[
|
|
350
|
-
V(
|
|
351
|
-
_(u(f)("Attachment.disabledUpload")),
|
|
352
|
-
1
|
|
353
|
-
/* TEXT */
|
|
354
|
-
)
|
|
355
|
-
],
|
|
356
|
-
64
|
|
357
|
-
/* STABLE_FRAGMENT */
|
|
358
|
-
)) : (v(), F(
|
|
359
|
-
N,
|
|
360
|
-
{ key: 1 },
|
|
361
|
-
[
|
|
362
|
-
V(
|
|
363
|
-
_(u(f)("Attachment.dragToUpload")),
|
|
364
|
-
1
|
|
365
|
-
/* TEXT */
|
|
366
|
-
)
|
|
367
|
-
],
|
|
368
|
-
64
|
|
369
|
-
/* STABLE_FRAGMENT */
|
|
370
|
-
))
|
|
371
|
-
],
|
|
372
|
-
2
|
|
373
|
-
/* CLASS */
|
|
374
|
-
)) : E("v-if", !0)
|
|
375
|
-
]))
|
|
251
|
+
A(d.$slots, "default"),
|
|
252
|
+
w("input", {
|
|
253
|
+
ref_key: "inputRef",
|
|
254
|
+
ref: t,
|
|
255
|
+
type: "file",
|
|
256
|
+
class: "mc-attachment-file",
|
|
257
|
+
accept: d.accept,
|
|
258
|
+
multiple: d.multiple,
|
|
259
|
+
disabled: g(l),
|
|
260
|
+
onChange: u[0] || (u[0] = //@ts-ignore
|
|
261
|
+
(...n) => g(m) && g(m)(...n))
|
|
262
|
+
}, null, 40, ee),
|
|
263
|
+
d.draggable ? (T(), k(Z, { key: 0 }, {
|
|
264
|
+
default: L(() => [
|
|
265
|
+
A(d.$slots, "dropPlaceholder", {}, () => [
|
|
266
|
+
W(
|
|
267
|
+
q(d.dropPlaceholder ?? g(p)("Attachment.dragToUpload")),
|
|
268
|
+
1
|
|
269
|
+
/* TEXT */
|
|
270
|
+
)
|
|
271
|
+
])
|
|
272
|
+
]),
|
|
273
|
+
_: 3
|
|
274
|
+
/* FORWARDED */
|
|
275
|
+
})) : H("v-if", !0)
|
|
376
276
|
],
|
|
377
|
-
|
|
378
|
-
/*
|
|
277
|
+
2
|
|
278
|
+
/* CLASS */
|
|
379
279
|
));
|
|
380
280
|
}
|
|
381
281
|
});
|
|
382
|
-
|
|
383
|
-
|
|
282
|
+
F.install = (a) => {
|
|
283
|
+
a.component("McAttachment", F);
|
|
384
284
|
};
|
|
385
285
|
export {
|
|
386
|
-
|
|
286
|
+
F as McAttachment
|
|
387
287
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FileItem, UploadOptions } from './attachment-types';
|
|
2
|
+
interface UploaderOptions {
|
|
3
|
+
file: File;
|
|
4
|
+
fileItem: FileItem;
|
|
5
|
+
options: UploadOptions;
|
|
6
|
+
onProgress: (percentage: number) => void;
|
|
7
|
+
onSuccess: (response: unknown) => void;
|
|
8
|
+
onError: (error: unknown) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare function upload(config: UploaderOptions): void;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Ref } from "vue";
|
|
2
|
+
import type { AttachmentEmits, AttachmentProps, FileItem } from "./attachment-types";
|
|
3
|
+
export declare function useUpload(props: AttachmentProps, emit: AttachmentEmits, inputRef: Ref<HTMLInputElement | undefined>, fileList: Ref<FileItem[]>): {
|
|
4
|
+
isDisabled: import("vue").ComputedRef<boolean>;
|
|
5
|
+
handleClick: () => void;
|
|
6
|
+
handleFileChange: (e: Event) => void;
|
|
7
|
+
uploadFiles: (files: File[]) => Promise<void>;
|
|
8
|
+
};
|