@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.
Files changed (120) hide show
  1. package/Attachment/Attachment.vue.d.ts +121 -0
  2. package/Attachment/attachment-types.d.ts +103 -0
  3. package/Attachment/drop-area.vue.d.ts +13 -0
  4. package/Attachment/index.css +1 -1
  5. package/Attachment/index.d.ts +2 -0
  6. package/Attachment/index.js +211 -311
  7. package/Attachment/uploader.d.ts +11 -0
  8. package/Attachment/use-upload.d.ts +8 -0
  9. package/Bubble/Bubble.vue.d.ts +75 -0
  10. package/Bubble/BubbleLoading.vue.d.ts +3 -0
  11. package/Bubble/bubble-constants.d.ts +4 -0
  12. package/Bubble/bubble-types.d.ts +38 -0
  13. package/Bubble/components/Avatar.vue.d.ts +57 -0
  14. package/Bubble/components/AvatarBodyIcon.vue.d.ts +24 -0
  15. package/Bubble/components/AvatarNoBodyIcon.vue.d.ts +24 -0
  16. package/Bubble/components/avatar-types.d.ts +25 -0
  17. package/Bubble/index.css +1 -1
  18. package/Bubble/index.d.ts +2 -0
  19. package/Bubble/index.js +142 -148
  20. package/FileList/FileIcon/CodeFile.vue.d.ts +10 -0
  21. package/FileList/FileIcon/CompressedFile.vue.d.ts +10 -0
  22. package/FileList/FileIcon/DefaultFileIcon.vue.d.ts +10 -0
  23. package/FileList/FileIcon/Document.vue.d.ts +10 -0
  24. package/FileList/FileIcon/DrawingBoard.vue.d.ts +10 -0
  25. package/FileList/FileIcon/EmailFile.vue.d.ts +10 -0
  26. package/FileList/FileIcon/Excel.vue.d.ts +10 -0
  27. package/FileList/FileIcon/FlowChart.vue.d.ts +10 -0
  28. package/FileList/FileIcon/FolderClosed.vue.d.ts +10 -0
  29. package/FileList/FileIcon/FolderOpen.vue.d.ts +10 -0
  30. package/FileList/FileIcon/Image.vue.d.ts +10 -0
  31. package/FileList/FileIcon/Markdown.vue.d.ts +10 -0
  32. package/FileList/FileIcon/Mind.vue.d.ts +10 -0
  33. package/FileList/FileIcon/Mp4.vue.d.ts +10 -0
  34. package/FileList/FileIcon/MultidimentionalTable.vue.d.ts +10 -0
  35. package/FileList/FileIcon/Page.vue.d.ts +10 -0
  36. package/FileList/FileIcon/Pdf.vue.d.ts +10 -0
  37. package/FileList/FileIcon/Ppt.vue.d.ts +10 -0
  38. package/FileList/FileIcon/Unknown.vue.d.ts +10 -0
  39. package/FileList/FileIcon/Wrong.vue.d.ts +10 -0
  40. package/FileList/FileList.vue.d.ts +36 -0
  41. package/FileList/fileList-types.d.ts +21 -0
  42. package/FileList/index.d.ts +2 -0
  43. package/FileList/index.js +220 -228
  44. package/Header/Header.vue.d.ts +47 -0
  45. package/Header/header-types.d.ts +14 -0
  46. package/Header/index.d.ts +2 -0
  47. package/Header/index.js +0 -1
  48. package/Input/Input.vue.d.ts +165 -0
  49. package/Input/components/EditableBlock.vue.d.ts +101 -0
  50. package/Input/components/InputTag.vue.d.ts +30 -0
  51. package/Input/components/LoadingIcon.vue.d.ts +3 -0
  52. package/Input/components/SendIcon.vue.d.ts +3 -0
  53. package/Input/components/button.vue.d.ts +3 -0
  54. package/Input/components/textarea-utils.d.ts +17 -0
  55. package/Input/components/textarea.vue.d.ts +3 -0
  56. package/Input/components/use-textarea-autosize.d.ts +12 -0
  57. package/Input/components/util.d.ts +3 -0
  58. package/Input/index.css +1 -1
  59. package/Input/index.d.ts +2 -0
  60. package/Input/index.js +114 -252
  61. package/Input/input-types.d.ts +118 -0
  62. package/Introduction/Introduction.vue.d.ts +88 -0
  63. package/Introduction/index.css +1 -1
  64. package/Introduction/index.d.ts +2 -0
  65. package/Introduction/index.js +8 -9
  66. package/Introduction/introduction-types.d.ts +37 -0
  67. package/Layout/Aside.vue.d.ts +13 -0
  68. package/Layout/Content.vue.d.ts +13 -0
  69. package/Layout/Header.vue.d.ts +13 -0
  70. package/Layout/Layout.vue.d.ts +13 -0
  71. package/Layout/Sender.vue.d.ts +13 -0
  72. package/Layout/index.d.ts +6 -0
  73. package/Layout/index.js +0 -1
  74. package/List/List.vue.d.ts +98 -0
  75. package/List/const.d.ts +5 -0
  76. package/List/index.css +1 -1
  77. package/List/index.d.ts +3 -0
  78. package/List/index.js +51 -54
  79. package/List/list-types.d.ts +52 -0
  80. package/List/use-list.d.ts +13 -0
  81. package/Locale/i18n.d.ts +21 -0
  82. package/Locale/index.d.ts +7 -0
  83. package/Locale/index.js +35 -103
  84. package/Locale/lang/en-us.d.ts +34 -0
  85. package/Locale/lang/zh-cn.d.ts +34 -0
  86. package/MarkdownCard/CodeBlock.vue.d.ts +76 -0
  87. package/MarkdownCard/MDCardParser.d.ts +12 -0
  88. package/MarkdownCard/MDCardService.d.ts +14 -0
  89. package/MarkdownCard/MermaidService.d.ts +22 -0
  90. package/MarkdownCard/index.css +1 -1
  91. package/MarkdownCard/index.d.ts +2 -0
  92. package/MarkdownCard/index.js +205 -559
  93. package/MarkdownCard/mdCard.types.d.ts +88 -0
  94. package/MarkdownCard/mdCard.vue.d.ts +29 -0
  95. package/Mention/Mention.vue.d.ts +51 -0
  96. package/Mention/const.d.ts +4 -0
  97. package/Mention/index.d.ts +2 -0
  98. package/Mention/index.js +0 -1
  99. package/Mention/mention-types.d.ts +24 -0
  100. package/Mention/use-mention.d.ts +10 -0
  101. package/Prompt/Prompt.vue.d.ts +38 -0
  102. package/Prompt/PromptItem.vue.d.ts +11 -0
  103. package/Prompt/components/Icon.vue.d.ts +42 -0
  104. package/Prompt/components/icon-types.d.ts +18 -0
  105. package/Prompt/index.d.ts +2 -0
  106. package/Prompt/prompt-types.d.ts +33 -0
  107. package/README.md +12 -8
  108. package/Toolbar/Toolbar.vue.d.ts +68 -0
  109. package/Toolbar/icon/CopyIcon.vue.d.ts +42 -0
  110. package/Toolbar/icon/DeleteIcon.vue.d.ts +42 -0
  111. package/Toolbar/icon/DislikeIcon.vue.d.ts +46 -0
  112. package/Toolbar/icon/LikeIcon.vue.d.ts +46 -0
  113. package/Toolbar/icon/RefreshIcon.vue.d.ts +42 -0
  114. package/Toolbar/icon/ShareIcon.vue.d.ts +42 -0
  115. package/Toolbar/index.css +1 -0
  116. package/Toolbar/index.d.ts +8 -0
  117. package/Toolbar/index.js +519 -0
  118. package/Toolbar/toolbar.types.d.ts +60 -0
  119. package/mate-chat.js +0 -6
  120. package/package.json +4 -1
@@ -1,10 +1,10 @@
1
1
  import "./index.css";
2
- import { createApp as $, h as H, defineComponent as P, ref as D, onMounted as R, createBlock as j, openBlock as v, Transition as L, withCtx as W, createElementBlock as F, createCommentVNode as E, normalizeClass as S, createElementVNode as g, toDisplayString as _, computed as Y, onUnmounted as X, mergeModels as M, useModel as G, Fragment as N, unref as u, renderSlot as J, Teleport as K, createTextVNode as V } from "vue";
3
- import { useMcI18n as q } from "@matechat/core/Locale";
4
- const Q = {
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
- setup(e) {
86
- const s = e, t = D(!1);
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
- function oe(e) {
137
- const { file: s, options: t, onProgress: l, onSuccess: m, onError: f } = e, a = new XMLHttpRequest();
138
- a.upload.onprogress = (i) => {
139
- if (i.lengthComputable) {
140
- const h = Math.round(i.loaded * 100 / i.total);
141
- l(h);
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
- }, a.onerror = () => {
144
- f({
58
+ }, t.onerror = () => {
59
+ p({
145
60
  message: "Upload failed due to a network error.",
146
- status: a.status,
147
- statusText: a.statusText
61
+ status: t.status,
62
+ statusText: t.statusText
148
63
  });
149
- }, a.onload = () => {
150
- if (a.status >= 200 && a.status < 300) {
151
- const i = t.responseType === "text" || !a.response ? a.responseText : a.response;
152
- m(i);
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
- f({
155
- message: `Upload failed with status: ${a.status}`,
156
- status: a.status,
157
- statusText: a.statusText,
158
- response: a.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 p = new FormData(), b = t.fileFieldName || "file";
162
- if (p.append(b, s, s.name), t.additionalParameter)
163
- for (const i of Object.keys(t.additionalParameter))
164
- p.append(i, t.additionalParameter[i]);
165
- if (a.open(t.method || "POST", t.uri, !0), t.withCredentials && (a.withCredentials = !0), t.responseType && (a.responseType = t.responseType), t.headers)
166
- for (const i of Object.keys(t.headers))
167
- a.setRequestHeader(i, t.headers[i]);
168
- if (t.authToken) {
169
- const i = t.authTokenHeader || "Authorization";
170
- a.setRequestHeader(i, t.authToken);
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
- a.send(p);
87
+ t.send(c);
173
88
  }
174
- let re = Date.now();
175
- function le(e, s, t, l) {
176
- const { t: m } = q(), f = D(!1);
177
- let a = 0;
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: re++,
182
- name: n.name,
183
- size: n.size,
184
- type: n.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
- }, i = async (n) => {
191
- if (n.length === 0) return;
192
- if (l.value.length + n.length > e.maxCount) {
193
- z({
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 = [], c = [];
203
- for (const o of n) {
204
- let r = !0;
205
- if (e.accept && e.accept !== "*") {
206
- const C = e.accept.split(",").map((y) => y.trim().toLowerCase()), k = o.type.toLowerCase(), B = o.name.toLowerCase();
207
- C.some((y) => y.endsWith("/*") ? k.startsWith(y.slice(0, -1)) : y.startsWith(".") ? B.endsWith(y) : k === y) || (c.push(
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 (r && o.size / 1024 / 1024 > e.maxSize && (c.push(
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(e.beforeUpload(o)) === !1 && (c.push(
219
- m("Attachment.uploadRejected", { fileName: o.name })
220
- ), r = !1);
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
- r && d.push(o);
122
+ e && d.push(n);
231
123
  }
232
- if (c.length > 0 && z({
233
- type: "error",
234
- title: m("Attachment.uploadFailedTitle"),
235
- message: c.join(`
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
- }, h = (n, d) => {
243
- const c = () => l.value.findIndex((o) => o.uid === d.uid);
244
- oe({
245
- file: n,
246
- options: e.uploadOptions,
247
- onProgress: (o) => {
248
- const r = c();
249
- r > -1 && (l.value[r].percentage = o, s("progress", n, [...l.value]));
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: (o) => {
252
- const r = c();
253
- r > -1 && (l.value[r].status = "success", l.value[r].response = o, s("success", n, o, [...l.value]));
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: (o) => {
256
- const r = c();
257
- r > -1 && (l.value[r].status = "uploadError", l.value[r].error = o, s("error", n, o, [...l.value]));
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 R(() => {
279
- e.draggable && (document.body.addEventListener("dragenter", T), document.body.addEventListener("dragover", I), document.body.addEventListener("dragleave", U), document.body.addEventListener("drop", w));
280
- }), X(() => {
281
- e.draggable && (document.body.removeEventListener("dragenter", T), document.body.removeEventListener("dragover", I), document.body.removeEventListener("dragleave", U), document.body.removeEventListener("drop", w));
282
- }), {
283
- isDragging: f,
284
- isDisabled: p,
285
- handleClick: A,
286
- handleFileChange: x
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 ie = ["disabled"], de = ["accept", "multiple", "disabled"], O = /* @__PURE__ */ P({
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__ */ M(Q, {
224
+ props: /* @__PURE__ */ x(K, {
293
225
  modelValue: { default: [] },
294
226
  modelModifiers: {}
295
227
  }),
296
- emits: /* @__PURE__ */ M(Z, ["update:modelValue"]),
297
- setup(e, { emit: s }) {
298
- const t = e, l = s, m = G(e, "modelValue"), { t: f } = q(), a = D(), { handleClick: p, handleFileChange: b, isDragging: i, isDisabled: h } = le(
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
- l,
301
- a,
302
- m
236
+ h
303
237
  );
304
- return (x, A) => (v(), F(
305
- N,
306
- null,
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
- g(
309
- "div",
310
- {
311
- class: S(["mc-attachment", { "is-disabled": u(h) }]),
312
- onClick: A[1] || (A[1] = //@ts-ignore
313
- (...T) => u(p) && u(p)(...T))
314
- },
315
- [
316
- E(" 使用插槽允许用户自定义触发器内容,例如按钮或文本 "),
317
- J(x.$slots, "default", {}, () => [
318
- g("button", {
319
- class: "mc-attachment-default-trigger",
320
- disabled: u(h)
321
- }, " + " + _(u(f)("Attachment.attachFile")), 9, ie)
322
- ]),
323
- g("input", {
324
- ref_key: "inputRef",
325
- ref: a,
326
- type: "file",
327
- class: "mc-attachment-file",
328
- accept: x.accept,
329
- multiple: x.multiple,
330
- disabled: u(h),
331
- onChange: A[0] || (A[0] = //@ts-ignore
332
- (...T) => u(b) && u(b)(...T))
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
- 64
378
- /* STABLE_FRAGMENT */
277
+ 2
278
+ /* CLASS */
379
279
  ));
380
280
  }
381
281
  });
382
- O.install = (e) => {
383
- e.component("McAttachment", O);
282
+ F.install = (a) => {
283
+ a.component("McAttachment", F);
384
284
  };
385
285
  export {
386
- O as McAttachment
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
+ };