@matechat/core 1.0.0 → 1.1.0-alpha.1

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/mate-chat.js CHANGED
@@ -1,869 +1,43 @@
1
- import "./mate-chat.css";
2
- import { defineComponent as T, openBlock as l, createElementBlock as d, createElementVNode as _, normalizeClass as $, createCommentVNode as h, toDisplayString as S, renderSlot as y, useSlots as Se, computed as U, createVNode as I, unref as u, normalizeProps as ue, guardReactiveProps as ke, createTextVNode as fe, inject as me, createBlock as B, isRef as Te, nextTick as pe, withCtx as x, ref as j, watch as ge, provide as we, Fragment as D, renderList as ve, onMounted as ye, mergeProps as Ee, Comment as Ie, Text as Me, h as Ae, withDirectives as Pe, cloneVNode as Oe, reactive as Be, onBeforeUnmount as je, Teleport as Ve, Transition as He, normalizeStyle as Ke } from "vue";
3
- import { Avatar as Ne } from "vue-devui/avatar";
4
- import "vue-devui/avatar/style.css";
5
- import { Textarea as Re } from "vue-devui/textarea";
6
- import "vue-devui/textarea/style.css";
7
- import { Button as Ze } from "vue-devui/button";
8
- import "vue-devui/button/style.css";
9
- import { Icon as ze } from "vue-devui/icon";
10
- import "vue-devui/icon/style.css";
11
- import { isObject as De } from "@vue/shared";
12
- import { computePosition as We, offset as Fe } from "@floating-ui/dom";
13
- const Ue = {
14
- logoImg: {
15
- type: String,
16
- default: ""
17
- },
18
- title: {
19
- type: String,
20
- default: ""
21
- },
22
- logoClickable: {
23
- type: Boolean,
24
- default: !1
25
- }
26
- }, xe = { class: "mc-header" }, Ge = ["src", "alt"], qe = { class: "mc-header-title" }, Xe = { class: "mc-header-operation" }, Je = /* @__PURE__ */ T({
27
- __name: "Header",
28
- props: Ue,
29
- emits: ["logoClicked"],
30
- setup(e, { emit: t }) {
31
- const n = t, i = e, c = () => {
32
- i.logoClickable && n("logoClicked");
33
- };
34
- return (o, r) => (l(), d("div", xe, [
35
- _("div", {
36
- class: $(["mc-header-logo-container", { clickable: o.logoClickable }]),
37
- onClick: c
38
- }, [
39
- o.logoImg ? (l(), d("img", {
40
- key: 0,
41
- class: "mc-header-logo",
42
- src: o.logoImg,
43
- alt: o.logoImg
44
- }, null, 8, Ge)) : h("", !0),
45
- _("div", qe, S(o.title), 1)
46
- ], 2),
47
- _("div", Xe, [
48
- y(o.$slots, "operationArea", {}, void 0, !0)
49
- ])
50
- ]));
51
- }
52
- }), L = (e, t) => {
53
- const n = e.__vccOpts || e;
54
- for (const [i, c] of t)
55
- n[i] = c;
56
- return n;
57
- }, Qe = /* @__PURE__ */ L(Je, [["__scopeId", "data-v-2eda62d1"]]), Ye = {
58
- content: {
59
- type: String,
60
- default: ""
61
- },
62
- loading: {
63
- type: Boolean,
64
- default: !1
65
- },
66
- align: {
67
- type: String,
68
- default: "left"
69
- },
70
- avatarPosition: {
71
- type: String,
72
- default: "side"
73
- },
74
- variant: {
75
- type: String,
76
- default: "filled"
77
- },
78
- avatarConfig: {
79
- type: Object
80
- }
81
- }, et = 36, tt = 36, nt = "name", ot = "imgSrc", rt = {}, it = { class: "mc-bubble-loading" };
82
- function at(e, t) {
83
- return l(), d("div", it, t[0] || (t[0] = [
84
- _("div", { class: "loading-dot dot-start" }, null, -1),
85
- _("div", { class: "loading-dot dot-middle" }, null, -1),
86
- _("div", { class: "loading-dot dot-end" }, null, -1)
87
- ]));
88
- }
89
- const st = /* @__PURE__ */ L(rt, [["render", at], ["__scopeId", "data-v-f976c7b6"]]), lt = {
90
- key: 0,
91
- class: "mc-bubble-avatar-name"
92
- }, ct = {
93
- key: 1,
94
- class: "loading-container"
95
- }, dt = /* @__PURE__ */ T({
96
- __name: "Bubble",
97
- props: Ye,
98
- setup(e) {
99
- const t = Se(), n = e, i = U(() => [
100
- `mc-bubble-avatar-${n.avatarPosition}`,
101
- `mc-bubble-${n.align}`,
102
- n.loading ? "mc-bubble-loading" : ""
103
- ]), c = U(() => {
104
- if (n.avatarConfig) {
105
- const o = Object.keys(n.avatarConfig), r = o.some((a) => a === nt || a === ot);
106
- return o.length < 1 || !r;
107
- } else
108
- return !0;
109
- });
110
- return (o, r) => {
111
- var a, s, f;
112
- return l(), d("div", {
113
- class: $(["mc-bubble", i.value])
114
- }, [
115
- o.avatarConfig ? (l(), d("div", {
116
- key: 0,
117
- class: $(["mc-bubble-avatar", { "empty-avatar": c.value }])
118
- }, [
119
- I(u(Ne), ue(ke(
120
- c.value ? {
121
- width: ((a = o.avatarConfig) == null ? void 0 : a.width) || u(et),
122
- height: ((s = o.avatarConfig) == null ? void 0 : s.height) || u(tt)
123
- } : o.avatarConfig
124
- )), null, 16),
125
- o.avatarPosition === "top" ? (l(), d("span", lt, S((f = o.avatarConfig) == null ? void 0 : f.displayName), 1)) : h("", !0)
126
- ], 2)) : h("", !0),
127
- _("div", {
128
- class: $(["mc-bubble-content-container", { "with-avatar": o.avatarConfig }])
129
- }, [
130
- o.loading ? h("", !0) : y(o.$slots, "top", { key: 0 }, void 0, !0),
131
- o.loading ? (l(), d("div", ct, [
132
- y(o.$slots, "loadingTpl", {}, () => [
133
- I(st)
134
- ], !0)
135
- ])) : h("", !0),
136
- (u(t).default || o.content) && !o.loading ? (l(), d("div", {
137
- key: 2,
138
- class: $(["mc-bubble-content", [o.variant]])
139
- }, [
140
- y(o.$slots, "default", {}, () => [
141
- fe(S(o.content), 1)
142
- ], !0)
143
- ], 2)) : h("", !0),
144
- o.loading ? h("", !0) : y(o.$slots, "bottom", { key: 3 }, void 0, !0)
145
- ], 2)
146
- ], 2);
147
- };
148
- }
149
- }), ut = /* @__PURE__ */ L(dt, [["__scopeId", "data-v-817ff41e"]]);
150
- var G = /* @__PURE__ */ ((e) => (e.Simple = "simple", e.Full = "full", e))(G || {}), z = /* @__PURE__ */ ((e) => (e.Enter = "enter", e.ShiftEnter = "shiftEnter", e))(z || {});
151
- const ft = {
152
- value: {
153
- type: String,
154
- default: ""
155
- },
156
- placeholder: {
157
- type: String
158
- },
159
- disabled: {
160
- type: Boolean,
161
- default: !1
162
- },
163
- displayType: {
164
- type: String,
165
- default: "full"
166
- /* Full */
167
- },
168
- loading: {
169
- type: Boolean,
170
- default: !1
171
- },
172
- showCount: {
173
- type: Boolean,
174
- default: !1
175
- },
176
- maxLength: {
177
- type: Number
178
- },
179
- submitShortKey: {
180
- type: [String, null],
181
- default: "enter"
182
- /* Enter */
183
- }
184
- }, mt = ["change", "submit", "cancel"], oe = "mc-input", pt = /* @__PURE__ */ T({
185
- __name: "textarea",
186
- setup(e) {
187
- const { inputValue: t, rootProps: n, rootEmits: i } = me(oe), c = U(() => {
188
- let m = "", b = "";
189
- return n.submitShortKey === z.Enter && (m = "Enter", b = "Shift + Enter"), n.submitShortKey === z.ShiftEnter && (m = "Shift + Enter", b = "Enter"), n.placeholder ?? (m ? `请输入您的问题,并按${m}发送,按${b}换行` : "请输入您的问题...");
190
- });
191
- let o = !1;
192
- const r = () => {
193
- pe(() => {
194
- i("change", t.value);
195
- });
196
- }, a = () => {
197
- o || r();
198
- }, s = () => {
199
- o = !0;
200
- }, f = () => {
201
- o = !1, r();
202
- }, g = (m) => {
203
- if (n.submitShortKey === null)
204
- return;
205
- (n.submitShortKey === z.Enter ? !m.shiftKey : n.submitShortKey === z.ShiftEnter ? m.shiftKey : !1) && m.code === "Enter" && (m.preventDefault(), i("submit", t.value), t.value = "");
206
- };
207
- return (m, b) => (l(), B(u(Re), {
208
- modelValue: u(t),
209
- "onUpdate:modelValue": b[0] || (b[0] = (w) => Te(t) ? t.value = w : null),
210
- placeholder: c.value,
211
- showGlowStyle: !1,
212
- disabled: u(n).disabled,
213
- maxlength: u(n).maxLength,
214
- class: $(["mc-textarea", { "mc-textarea-simple": u(n).displayType === u(G).Simple }]),
215
- onInput: a,
216
- onCompositionstart: s,
217
- onCompositionend: f,
218
- onKeydown: g
219
- }, null, 8, ["modelValue", "placeholder", "disabled", "maxlength", "class"]));
220
- }
221
- }), gt = {}, vt = {
222
- width: "16px",
223
- height: "16px",
224
- viewBox: "0 0 16 16",
225
- version: "1.1",
226
- xmlns: "http://www.w3.org/2000/svg"
227
- };
228
- function yt(e, t) {
229
- return l(), d("svg", vt, t[0] || (t[0] = [
230
- _("g", {
231
- stroke: "none",
232
- "stroke-width": "1",
233
- fill: "none",
234
- "fill-rule": "evenodd"
235
- }, [
236
- _("path", { d: "M8,12 C8.27614237,12 8.5,12.2238576 8.5,12.5 L8.5,14.5 C8.5,14.7761424 8.27614237,15 8,15 C7.72385763,15 7.5,14.7761424 7.5,14.5 L7.5,12.5 C7.5,12.2238576 7.72385763,12 8,12 Z M11.0495421,11.3466838 L12.2251126,12.9647178 C12.3874251,13.1881217 12.3379006,13.5008065 12.1144968,13.663119 C11.8910929,13.8254314 11.5784081,13.775907 11.4160956,13.5525031 L10.2405251,11.9344691 C10.0782127,11.7110652 10.1277371,11.3983804 10.351141,11.236068 C10.5745449,11.0737556 10.8872297,11.12328 11.0495421,11.3466838 Z M5.64885899,11.236068 C5.87226287,11.3983804 5.92178728,11.7110652 5.75947486,11.9344691 L4.58390436,13.5525031 C4.42159194,13.775907 4.10890711,13.8254314 3.88550323,13.663119 C3.66209936,13.5008065 3.61257495,13.1881217 3.77488736,12.9647178 L4.95045787,11.3466838 C5.11277028,11.12328 5.42545512,11.0737556 5.64885899,11.236068 Z M12.4342628,8.91504822 L14.3363759,9.53308221 C14.5990029,9.61841489 14.7427283,9.90049196 14.6573956,10.163119 C14.5720629,10.425746 14.2899859,10.5694714 14.0273589,10.4841387 L12.1252458,9.86610473 C11.8626188,9.78077205 11.7188934,9.49869498 11.8042261,9.23606798 C11.8895588,8.97344097 12.1716358,8.82971553 12.4342628,8.91504822 Z M4.19577393,9.23606798 C4.28110662,9.49869498 4.13738118,9.78077205 3.87475417,9.86610473 L1.97264114,10.4841387 C1.71001414,10.5694714 1.42793707,10.425746 1.34260439,10.163119 C1.2572717,9.90049196 1.40099714,9.61841489 1.66362415,9.53308221 L3.56573718,8.91504822 C3.82836418,8.82971553 4.11044125,8.97344097 4.19577393,9.23606798 Z M14.6573956,5.83688104 C14.7427283,6.09950804 14.5990029,6.38158511 14.3363759,6.46691779 L12.4342628,7.08495178 C12.1716358,7.17028447 11.8895588,7.02655903 11.8042261,6.76393202 C11.7188934,6.50130502 11.8626188,6.21922795 12.1252458,6.13389527 L14.0273589,5.51586128 C14.2899859,5.43052859 14.5720629,5.57425403 14.6573956,5.83688104 Z M1.97264114,5.51586128 L3.87475417,6.13389527 C4.13738118,6.21922795 4.28110662,6.50130502 4.19577393,6.76393202 C4.11044125,7.02655903 3.82836418,7.17028447 3.56573718,7.08495178 L1.66362415,6.46691779 C1.40099714,6.38158511 1.2572717,6.09950804 1.34260439,5.83688104 C1.42793707,5.57425403 1.71001414,5.43052859 1.97264114,5.51586128 Z M12.1144968,2.33688104 C12.3379006,2.49919345 12.3874251,2.81187829 12.2251126,3.03528216 L11.0495421,4.65331615 C10.8872297,4.87672003 10.5745449,4.92624444 10.351141,4.76393202 C10.1277371,4.60161961 10.0782127,4.28893477 10.2405251,4.0655309 L11.4160956,2.44749691 C11.5784081,2.22409304 11.8910929,2.17456862 12.1144968,2.33688104 Z M4.58390436,2.44749691 L5.75947486,4.0655309 C5.92178728,4.28893477 5.87226287,4.60161961 5.64885899,4.76393202 C5.42545512,4.92624444 5.11277028,4.87672003 4.95045787,4.65331615 L3.77488736,3.03528216 C3.61257495,2.81187829 3.66209936,2.49919345 3.88550323,2.33688104 C4.10890711,2.17456862 4.42159194,2.22409304 4.58390436,2.44749691 Z M8,1 C8.27614237,1 8.5,1.22385763 8.5,1.5 L8.5,3.5 C8.5,3.77614237 8.27614237,4 8,4 C7.72385763,4 7.5,3.77614237 7.5,3.5 L7.5,1.5 C7.5,1.22385763 7.72385763,1 8,1 Z" })
237
- ], -1)
238
- ]));
239
- }
240
- const ht = /* @__PURE__ */ L(gt, [["render", yt]]), bt = {}, _t = {
241
- width: "16px",
242
- height: "16px",
243
- viewBox: "0 0 16 16",
244
- version: "1.1",
245
- xmlns: "http://www.w3.org/2000/svg"
1
+ import { McBubble } from './Bubble';
2
+ import { McHeader } from './Header';
3
+ import { McInput } from './Input';
4
+ import { McIntroduction } from './Introduction';
5
+ import { McLayoutAside, McLayoutContent, McLayoutHeader, McLayout, McLayoutSender } from './Layout';
6
+ import { McList } from './List';
7
+ import { McMarkdownCard } from './MarkdownCard';
8
+ import { McMention } from './Mention';
9
+ import { McPrompt } from './Prompt';
10
+
11
+ const installs = [
12
+ McBubble,
13
+ McHeader,
14
+ McInput,
15
+ McIntroduction,
16
+ McLayout,
17
+ McList,
18
+ McMarkdownCard,
19
+ McMention,
20
+ McPrompt
21
+ ];
22
+
23
+ export {
24
+ McBubble,
25
+ McHeader,
26
+ McInput,
27
+ McIntroduction,
28
+ McLayoutAside,
29
+ McLayoutContent,
30
+ McLayoutHeader,
31
+ McLayout,
32
+ McLayoutSender,
33
+ McList,
34
+ McMarkdownCard,
35
+ McMention,
36
+ McPrompt
246
37
  };
247
- function Ct(e, t) {
248
- return l(), d("svg", _t, t[0] || (t[0] = [
249
- _("g", {
250
- stroke: "none",
251
- "stroke-width": "1",
252
- fill: "none",
253
- "fill-rule": "evenodd"
254
- }, [
255
- _("path", { d: "M13.5105149,2.56164948 C14.1211149,2.35546948 14.7829149,2.68328948 14.9892149,3.29376948 C15.0349149,3.42925948 15.0552149,3.57159948 15.0495149,3.71368948 L15.0495149,3.71368948 L15.0351149,3.85546948 L13.6575149,12.2717195 C13.5237149,13.0892195 12.7524149,13.6435195 11.9348149,13.5097195 C11.8542149,13.4965195 11.7751149,13.4768195 11.6980149,13.4508195 L11.6980149,13.4508195 L11.5840149,13.4071195 L9.3049349,12.4260195 L8.4482449,13.5422195 C8.1958049,13.8708195 7.8205549,14.0786195 7.4128449,14.1207195 L7.4128449,14.1207195 L7.2585449,14.1286195 C6.4787649,14.1286195 5.8381349,13.5337195 5.7653849,12.7731195 L5.7653849,12.7731195 L5.7585449,12.6286195 L5.7602549,10.5258195 L5.7756349,10.4384195 L5.7944349,10.3824195 L5.8266649,10.3168995 L5.8735349,10.2503695 L5.9177249,10.2039195 L12.6909149,3.89392948 L2.3403349,7.38903948 C2.2329149,7.42529948 2.1418449,7.49676948 2.0808149,7.59063948 L2.0808149,7.59063948 L2.0412649,7.66497948 C1.9440949,7.89044948 2.0258749,8.14788948 2.2236349,8.27917948 L2.2236349,8.27917948 L2.3029749,8.32214948 L4.4799849,9.26177948 C4.7333949,9.37121948 4.8503449,9.66546948 4.7409649,9.91894948 C4.6435549,10.1443495 4.4003949,10.2616595 4.1694349,10.2081295 L4.1694349,10.2081295 L4.0837449,10.1798795 L1.9072249,9.24047948 C1.1462449,8.91284948 0.795166898,8.03039948 1.1225549,7.26953948 C1.2700249,6.92755948 1.5380849,6.65435948 1.8730449,6.50018948 L1.8730449,6.50018948 L2.0205049,6.44158948 Z M6.7578149,11.3299195 L6.7585449,12.6286195 L6.7666013,12.7185103 C6.80894095,12.9517898 7.0131049,13.1286195 7.2585449,13.1286195 C7.3828149,13.1286195 7.5014649,13.0824195 7.5925349,13.0008195 L7.5925349,13.0008195 L7.6550349,12.9332195 L8.3569349,12.0179195 L6.7578149,11.3299195 Z M13.9888149,4.05090948 L7.1599149,10.4129195 L11.9795149,12.4886195 C11.9980149,12.4966195 12.0173149,12.5035195 12.0369149,12.5093195 L12.0369149,12.5093195 L12.0964149,12.5228195 C12.3386149,12.5624195 12.5686149,12.4209195 12.6482149,12.1975195 L12.6482149,12.1975195 L12.6706149,12.1101195 L13.9888149,4.05090948 Z" })
256
- ], -1)
257
- ]));
258
- }
259
- const Lt = /* @__PURE__ */ L(bt, [["render", Ct]]), $t = /* @__PURE__ */ T({
260
- __name: "button",
261
- setup(e) {
262
- const { inputValue: t, rootProps: n, rootEmits: i } = me(oe), c = () => {
263
- n.loading ? i("cancel") : (i("submit", t.value), t.value = "");
264
- };
265
- return (o, r) => (l(), B(u(Ze), {
266
- variant: "solid",
267
- shape: "round",
268
- disabled: u(n).disabled || !u(n).loading && !u(t),
269
- class: $(["mc-button", { "mc-button-loading": u(n).loading }]),
270
- onClick: c
271
- }, {
272
- default: x(() => [
273
- u(n).loading ? (l(), B(ht, { key: 0 })) : (l(), B(Lt, { key: 1 })),
274
- _("span", null, S(u(n).loading ? "暂停回答" : "发送"), 1)
275
- ]),
276
- _: 1
277
- }, 8, ["disabled", "class"]));
278
- }
279
- }), ae = /* @__PURE__ */ L($t, [["__scopeId", "data-v-4b65a940"]]), St = { class: "mc-input-content" }, kt = {
280
- key: 0,
281
- class: "mc-input-foot"
282
- }, Tt = { class: "mc-input-foot-left" }, wt = {
283
- key: 0,
284
- class: "mc-input-foot-count"
285
- }, Et = /* @__PURE__ */ T({
286
- __name: "Input",
287
- props: ft,
288
- emits: mt,
289
- setup(e, { expose: t, emit: n }) {
290
- const i = e, c = n, o = j(""), r = () => {
291
- o.value = "";
292
- }, a = () => o.value;
293
- return ge(
294
- () => i.value,
295
- () => {
296
- o.value = i.value;
297
- },
298
- { immediate: !0 }
299
- ), t({ clearInput: r, getInput: a }), we(oe, { inputValue: o, rootProps: i, rootEmits: c }), (s, f) => (l(), d("div", {
300
- class: $(["mc-input", { "mc-input-disabled": s.disabled }])
301
- }, [
302
- y(s.$slots, "head"),
303
- _("div", St, [
304
- y(s.$slots, "prefix"),
305
- I(pt),
306
- s.displayType === u(G).Simple ? y(s.$slots, "button", { key: 0 }, () => [
307
- I(ae)
308
- ]) : h("", !0)
309
- ]),
310
- s.displayType === u(G).Full ? (l(), d("div", kt, [
311
- _("div", Tt, [
312
- y(s.$slots, "extra"),
313
- s.showCount ? (l(), d("span", wt, S(o.value.length) + S(s.maxLength ?? !1 ? `/${s.maxLength}` : ""), 1)) : h("", !0)
314
- ]),
315
- y(s.$slots, "button", {}, () => [
316
- I(ae)
317
- ])
318
- ])) : h("", !0)
319
- ], 2));
320
- }
321
- }), It = {
322
- logoImg: {
323
- type: String,
324
- default: ""
325
- },
326
- title: {
327
- type: String,
328
- default: ""
329
- },
330
- subTitle: {
331
- type: String,
332
- default: ""
333
- },
334
- description: {
335
- type: Array,
336
- default: () => []
337
- },
338
- background: {
339
- type: String,
340
- default: "transparent"
341
- },
342
- align: {
343
- type: String,
344
- default: "center"
345
- }
346
- }, Mt = { class: "mc-introduction-logo-container" }, At = ["src", "alt"], Pt = { class: "mc-introduction-title" }, Ot = {
347
- key: 0,
348
- class: "mc-introduction-sub-title"
349
- }, Bt = {
350
- key: 1,
351
- class: "mc-introduction-description"
352
- }, jt = /* @__PURE__ */ T({
353
- __name: "Introduction",
354
- props: It,
355
- setup(e) {
356
- return (t, n) => (l(), d("div", {
357
- class: $(["mc-introduction", [t.align, t.background]])
358
- }, [
359
- _("div", Mt, [
360
- t.logoImg ? (l(), d("img", {
361
- key: 0,
362
- src: t.logoImg,
363
- alt: t.title
364
- }, null, 8, At)) : h("", !0),
365
- _("div", Pt, S(t.title), 1)
366
- ]),
367
- t.subTitle ? (l(), d("div", Ot, S(t.subTitle), 1)) : h("", !0),
368
- t.description.length ? (l(), d("div", Bt, [
369
- (l(!0), d(D, null, ve(t.description, (i, c) => (l(), d("div", { key: c }, S(i), 1))), 128))
370
- ])) : h("", !0),
371
- y(t.$slots, "default", {}, void 0, !0)
372
- ], 2));
373
- }
374
- }), Vt = /* @__PURE__ */ L(jt, [["__scopeId", "data-v-48b255c7"]]);
375
- var W = /* @__PURE__ */ ((e) => (e.Horizontal = "horizontal", e.Vertical = "vertical", e))(W || {}), re = /* @__PURE__ */ ((e) => (e.Transparent = "transparent", e.Filled = "filled", e.Bordered = "bordered", e.None = "none", e))(re || {});
376
- const Ht = {
377
- direction: {
378
- type: String,
379
- default: "vertical"
380
- /* Vertical */
381
- },
382
- autoWrap: {
383
- type: Boolean,
384
- default: !0
385
- },
386
- variant: {
387
- type: String,
388
- default: "transparent"
389
- /* Transparent */
390
- },
391
- enableLazyLoad: {
392
- type: Boolean,
393
- default: !1
394
- },
395
- data: {
396
- type: Array,
397
- default: () => []
398
- },
399
- enableShortKey: {
400
- type: Boolean,
401
- default: !1
402
- },
403
- inputEl: {
404
- type: Object
405
- },
406
- selectable: {
407
- type: Boolean,
408
- default: !0
409
- }
410
- }, Kt = 50, Nt = ["TEXTAREA", "INPUT"], Rt = "ArrowUp", Zt = "ArrowDown", zt = "Enter";
411
- function Dt(e, t) {
412
- const n = j(e.enableShortKey ? 0 : -1), i = (r) => {
413
- if (!r.disabled) {
414
- if (e.selectable)
415
- for (let a = 0; a < e.data.length; a++)
416
- e.data[a].active = e.data[a].value === r.value;
417
- t("select", { ...r });
418
- }
419
- }, c = (r) => {
420
- if (!e.enableLazyLoad || e.direction !== W.Vertical)
421
- return;
422
- const a = r.target, s = a.scrollHeight, f = a.clientHeight, g = a.scrollTop;
423
- s - f - g < Kt && t("loadMore", r);
424
- }, o = (r) => {
425
- r.code === Rt && (n.value = n.value === 0 ? e.data.length - 1 : n.value - 1), r.code === Zt && (n.value = n.value === e.data.length - 1 ? 0 : n.value + 1), r.code === zt && (e.selectable && (e.data[n.value].active = !0), t("select", { ...e.data[n.value] }));
426
- };
427
- return ye(() => {
428
- let r;
429
- if (e.inputEl) {
430
- const a = e.inputEl.$el ?? e.inputEl;
431
- Nt.includes(a.tagName) ? r = a : r = a.querySelector("textarea") || a.querySelector("input") || document;
432
- } else
433
- r = document;
434
- e.enableShortKey && r.addEventListener("keydown", o);
435
- }), { preSelectIndex: n, onItemClick: i, onListScroll: c };
436
- }
437
- function Wt(e) {
438
- return { listClasses: U(() => ({
439
- "mc-list": !0,
440
- "mc-list-horizontal": e.direction === W.Horizontal,
441
- "mc-list-nowrap": e.direction === W.Horizontal && !e.autoWrap
442
- })) };
443
- }
444
- const Ft = ["onClick"], Ut = /* @__PURE__ */ T({
445
- __name: "List",
446
- props: Ht,
447
- emits: ["select", "loadMore"],
448
- setup(e, { emit: t }) {
449
- const n = e, i = t, { listClasses: c } = Wt(n), { preSelectIndex: o, onItemClick: r, onListScroll: a } = Dt(n, i);
450
- return (s, f) => (l(), d("div", {
451
- class: $(u(c)),
452
- onScroll: f[0] || (f[0] = //@ts-ignore
453
- (...g) => u(a) && u(a)(...g))
454
- }, [
455
- (l(!0), d(D, null, ve(s.data, (g, m) => (l(), d(D, { key: m }, [
456
- s.variant === u(re).None ? y(s.$slots, "item", {
457
- key: 0,
458
- item: g
459
- }, void 0, !0) : (l(), d("div", {
460
- key: 1,
461
- class: $([
462
- "mc-list-item",
463
- {
464
- "mc-list-item-disabled": g.disabled,
465
- "mc-list-item-active": g.active,
466
- "mc-list-item-pre-selection": m === u(o)
467
- },
468
- s.variant
469
- ]),
470
- onClick: () => u(r)(g)
471
- }, [
472
- y(s.$slots, "item", { item: g }, () => [
473
- fe(S(g.label), 1)
474
- ], !0)
475
- ], 10, Ft))
476
- ], 64))), 128))
477
- ], 34));
478
- }
479
- }), he = /* @__PURE__ */ L(Ut, [["__scopeId", "data-v-adad50a4"]]), xt = {
480
- direction: {
481
- type: String,
482
- default: W.Vertical
483
- },
484
- list: {
485
- type: Array,
486
- default: () => []
487
- },
488
- variant: {
489
- type: String,
490
- default: re.Filled
491
- }
492
- }, Gt = {
493
- prompt: {
494
- type: Object
495
- }
496
- }, qt = { class: "mc-prompt-item" }, Xt = {
497
- key: 0,
498
- class: "mc-prompt-item-content"
499
- }, Jt = {
500
- key: 0,
501
- class: "mc-prompt-item-label"
502
- }, Qt = {
503
- key: 1,
504
- class: "mc-prompt-item-description"
505
- }, Yt = /* @__PURE__ */ T({
506
- __name: "PromptItem",
507
- props: Gt,
508
- setup(e) {
509
- return (t, n) => {
510
- var i, c, o, r, a, s, f, g, m;
511
- return l(), d("div", qt, [
512
- _("div", {
513
- class: $(["mc-prompt-item-icon", { "no-description": !((i = t.prompt) != null && i.desc) }])
514
- }, [
515
- (c = t.prompt) != null && c.iconConfig ? (l(), B(u(ze), ue(Ee({ key: 0 }, (o = t.prompt) == null ? void 0 : o.iconConfig)), null, 16)) : h("", !0)
516
- ], 2),
517
- (r = t.prompt) != null && r.label || (a = t.prompt) != null && a.desc ? (l(), d("div", Xt, [
518
- (s = t.prompt) != null && s.label ? (l(), d("div", Jt, S((f = t.prompt) == null ? void 0 : f.label), 1)) : h("", !0),
519
- (g = t.prompt) != null && g.desc ? (l(), d("div", Qt, S((m = t.prompt) == null ? void 0 : m.desc), 1)) : h("", !0)
520
- ])) : h("", !0)
521
- ]);
522
- };
523
- }
524
- }), en = /* @__PURE__ */ L(Yt, [["__scopeId", "data-v-5f016595"]]), tn = { class: "mc-prompt" }, nn = /* @__PURE__ */ T({
525
- __name: "Prompt",
526
- props: xt,
527
- emits: ["itemClick"],
528
- setup(e, { emit: t }) {
529
- const n = t, i = e;
530
- return (c, o) => (l(), d("div", tn, [
531
- I(he, {
532
- data: i.list,
533
- direction: i.direction,
534
- variant: i.variant,
535
- selectable: !1
536
- }, {
537
- item: x(({ item: r }) => [
538
- I(en, {
539
- prompt: r,
540
- onClick: (a) => n("itemClick", r)
541
- }, null, 8, ["prompt", "onClick"])
542
- ]),
543
- _: 1
544
- }, 8, ["data", "direction", "variant"])
545
- ]));
546
- }
547
- });
548
- function se(e) {
549
- return Ae("span", {}, e);
550
- }
551
- function be(e) {
552
- for (const t of e) {
553
- if (De(t)) {
554
- if (t.type === Ie)
555
- continue;
556
- return t.type === "svg" || t.type === Me ? se(t) : t.type === D ? be(t.children) : t;
557
- }
558
- return se(t);
38
+
39
+ export default {
40
+ install(app) {
41
+ installs.forEach((p) => app.use(p));
559
42
  }
560
- return null;
561
- }
562
- const on = /* @__PURE__ */ T({
563
- setup(e, t) {
564
- const {
565
- slots: n,
566
- attrs: i,
567
- expose: c
568
- } = t, o = j();
569
- return c({
570
- triggerEl: o
571
- }), () => {
572
- var s;
573
- const r = (s = n.default) == null ? void 0 : s.call(n, i);
574
- if (!r)
575
- return null;
576
- const a = be(r);
577
- return a ? Pe(Oe(a, i), [[{
578
- mounted(f) {
579
- o.value = f;
580
- },
581
- updated(f) {
582
- o.value = f;
583
- },
584
- unmounted() {
585
- o.value = null;
586
- }
587
- }]]) : null;
588
- };
589
- }
590
- }), rn = {
591
- modelValue: {
592
- type: Boolean,
593
- default: !1
594
- },
595
- prefix: {
596
- type: Array,
597
- default: () => []
598
- },
599
- fitHostWidth: {
600
- type: Boolean,
601
- default: !0
602
- },
603
- menuClass: {
604
- type: String
605
- }
606
- }, an = ["update:modelValue", "searchChange", "toggleChange"];
607
- var sn = typeof global == "object" && global && global.Object === Object && global, ln = typeof self == "object" && self && self.Object === Object && self, _e = sn || ln || Function("return this")(), q = _e.Symbol, Ce = Object.prototype, cn = Ce.hasOwnProperty, dn = Ce.toString, Z = q ? q.toStringTag : void 0;
608
- function un(e) {
609
- var t = cn.call(e, Z), n = e[Z];
610
- try {
611
- e[Z] = void 0;
612
- var i = !0;
613
- } catch {
614
- }
615
- var c = dn.call(e);
616
- return i && (t ? e[Z] = n : delete e[Z]), c;
617
- }
618
- var fn = Object.prototype, mn = fn.toString;
619
- function pn(e) {
620
- return mn.call(e);
621
- }
622
- var gn = "[object Null]", vn = "[object Undefined]", le = q ? q.toStringTag : void 0;
623
- function yn(e) {
624
- return e == null ? e === void 0 ? vn : gn : le && le in Object(e) ? un(e) : pn(e);
625
- }
626
- function hn(e) {
627
- return e != null && typeof e == "object";
628
- }
629
- var bn = "[object Symbol]";
630
- function _n(e) {
631
- return typeof e == "symbol" || hn(e) && yn(e) == bn;
632
- }
633
- var Cn = /\s/;
634
- function Ln(e) {
635
- for (var t = e.length; t-- && Cn.test(e.charAt(t)); )
636
- ;
637
- return t;
638
- }
639
- var $n = /^\s+/;
640
- function Sn(e) {
641
- return e && e.slice(0, Ln(e) + 1).replace($n, "");
642
- }
643
- function X(e) {
644
- var t = typeof e;
645
- return e != null && (t == "object" || t == "function");
646
- }
647
- var ce = NaN, kn = /^[-+]0x[0-9a-f]+$/i, Tn = /^0b[01]+$/i, wn = /^0o[0-7]+$/i, En = parseInt;
648
- function de(e) {
649
- if (typeof e == "number")
650
- return e;
651
- if (_n(e))
652
- return ce;
653
- if (X(e)) {
654
- var t = typeof e.valueOf == "function" ? e.valueOf() : e;
655
- e = X(t) ? t + "" : t;
656
- }
657
- if (typeof e != "string")
658
- return e === 0 ? e : +e;
659
- e = Sn(e);
660
- var n = Tn.test(e);
661
- return n || wn.test(e) ? En(e.slice(2), n ? 2 : 8) : kn.test(e) ? ce : +e;
662
- }
663
- var te = function() {
664
- return _e.Date.now();
665
- }, In = "Expected a function", Mn = Math.max, An = Math.min;
666
- function Pn(e, t, n) {
667
- var i, c, o, r, a, s, f = 0, g = !1, m = !1, b = !0;
668
- if (typeof e != "function")
669
- throw new TypeError(In);
670
- t = de(t) || 0, X(n) && (g = !!n.leading, m = "maxWait" in n, o = m ? Mn(de(n.maxWait) || 0, t) : o, b = "trailing" in n ? !!n.trailing : b);
671
- function w(v) {
672
- var k = i, E = c;
673
- return i = c = void 0, f = v, r = e.apply(E, k), r;
674
- }
675
- function J(v) {
676
- return f = v, a = setTimeout(A, t), g ? w(v) : r;
677
- }
678
- function Q(v) {
679
- var k = v - s, E = v - f, F = t - k;
680
- return m ? An(F, o - E) : F;
681
- }
682
- function V(v) {
683
- var k = v - s, E = v - f;
684
- return s === void 0 || k >= t || k < 0 || m && E >= o;
685
- }
686
- function A() {
687
- var v = te();
688
- if (V(v))
689
- return M(v);
690
- a = setTimeout(A, Q(v));
691
- }
692
- function M(v) {
693
- return a = void 0, b && i ? w(v) : (i = c = void 0, r);
694
- }
695
- function Y() {
696
- a !== void 0 && clearTimeout(a), f = 0, i = s = c = a = void 0;
697
- }
698
- function H() {
699
- return a === void 0 ? r : M(te());
700
- }
701
- function P() {
702
- var v = te(), k = V(v);
703
- if (i = arguments, c = this, s = v, k) {
704
- if (a === void 0)
705
- return J(s);
706
- if (m)
707
- return clearTimeout(a), a = setTimeout(A, t), w(s);
708
- }
709
- return a === void 0 && (a = setTimeout(A, t)), r;
710
- }
711
- return P.cancel = Y, P.flush = H, P;
712
- }
713
- const ne = " ", On = "ArrowLeft", Bn = "ArrowRight", jn = "Escape";
714
- function Vn(e, t) {
715
- const n = j(), i = j(), c = j(), o = Be({ top: "0px", left: "0px", width: "" });
716
- let r, a, s, f, g = "", m, b;
717
- const w = async () => {
718
- if (!i.value || !c.value)
719
- return;
720
- const { x: p, y: C } = await We(i.value, c.value, {
721
- strategy: "fixed",
722
- placement: "top-start",
723
- middleware: [Fe(4)]
724
- });
725
- o.top = `${C}px`, o.left = `${p}px`;
726
- }, J = () => {
727
- const { width: p } = i.value.getBoundingClientRect();
728
- o.width = `${p}px`, w();
729
- }, Q = () => {
730
- e.fitHostWidth && typeof window < "u" && i.value && (b = new window.ResizeObserver(J), b.observe(i.value));
731
- }, V = () => {
732
- i.value && (b == null || b.unobserve(i.value));
733
- };
734
- ge(
735
- () => e.modelValue,
736
- (p, C) => {
737
- p ? (pe(w), Q(), typeof window < "u" && window.addEventListener("scroll", E, !0)) : (V(), typeof window < "u" && window.removeEventListener("scroll", E, !0)), C !== void 0 && t("toggleChange", p);
738
- },
739
- { immediate: !0 }
740
- );
741
- const A = () => {
742
- a = null, s = -1, f = -1, g = "";
743
- }, M = (p) => {
744
- t("update:modelValue", p);
745
- }, Y = () => {
746
- if (!r)
747
- return;
748
- const p = r.value.replace(/[\r\n]/g, ne) || "", C = r.selectionStart;
749
- if (!p.trim() || !C) {
750
- A();
751
- return;
752
- }
753
- for (let O = 0; O < e.prefix.length; O++) {
754
- const K = e.prefix[O];
755
- let N = "", ie = !1;
756
- if (typeof K == "string")
757
- N = K;
758
- else if (X(K))
759
- N = K.key, ie = !!K.onlyInputStart;
760
- else
761
- continue;
762
- const R = p.lastIndexOf(N, C), Le = p.lastIndexOf(ne, C), ee = p.substring(R, C), $e = ee.charAt(ee.length - 1);
763
- if (R < 0 || R > 0 && ie || R < Le || $e === ne)
764
- A();
765
- else {
766
- a = N, s = R, f = C, g = ee.slice(N.length);
767
- return;
768
- }
769
- }
770
- }, H = () => {
771
- if (Y(), !a) {
772
- M(!1);
773
- return;
774
- }
775
- t("searchChange", { value: g, trigger: a, triggerIndex: s, cursorIndex: f }), M(!0);
776
- }, P = Pn(H, 300), v = (p) => {
777
- (p.code === On || p.code === Bn) && (m = setTimeout(() => {
778
- H(), m && (m = void 0, clearTimeout(m));
779
- })), p.code === jn && M(!1);
780
- }, k = (p) => {
781
- var C, O;
782
- e.modelValue ? (C = i.value) != null && C.contains(p.target) || M(!1) : (O = i.value) != null && O.contains(p.target) && H();
783
- };
784
- function E(p) {
785
- const C = p.target;
786
- C != null && C.contains(i.value) && w();
787
- }
788
- const F = () => {
789
- i.value && (r = i.value.querySelector("textarea") || i.value.querySelector("input"), r && (r.addEventListener("input", P), r.addEventListener("keydown", v))), document.addEventListener("click", k);
790
- };
791
- return ye(() => {
792
- const p = n.value.triggerEl;
793
- i.value = p.$el ?? p, F();
794
- }), je(() => {
795
- M(!1), r == null || r.removeEventListener("input", P), r == null || r.removeEventListener("keydown", v), document.removeEventListener("click", k), typeof window < "u" && window.removeEventListener("scroll", E, !0), V();
796
- }), { popperTriggerEl: n, overlayEl: c, overlayStyle: o };
797
- }
798
- const Hn = /* @__PURE__ */ T({
799
- __name: "Mention",
800
- props: rn,
801
- emits: an,
802
- setup(e, { emit: t }) {
803
- const n = e, i = t, { popperTriggerEl: c, overlayEl: o, overlayStyle: r } = Vn(n, i);
804
- return (a, s) => (l(), d(D, null, [
805
- I(u(on), {
806
- ref_key: "popperTriggerEl",
807
- ref: c
808
- }, {
809
- default: x(() => [
810
- y(a.$slots, "default", {}, void 0, !0)
811
- ]),
812
- _: 3
813
- }, 512),
814
- (l(), B(Ve, { to: "body" }, [
815
- I(He, { name: "mc-mention-fade" }, {
816
- default: x(() => [
817
- a.modelValue ? (l(), d("div", {
818
- key: 0,
819
- ref_key: "overlayEl",
820
- ref: o,
821
- class: $(["mc-mention", a.menuClass]),
822
- style: Ke(u(r))
823
- }, [
824
- y(a.$slots, "menu", {}, void 0, !0)
825
- ], 6)) : h("", !0)
826
- ]),
827
- _: 3
828
- })
829
- ]))
830
- ], 64));
831
- }
832
- }), Kn = /* @__PURE__ */ L(Hn, [["__scopeId", "data-v-196371c8"]]), Nn = {}, Rn = { class: "mc-layout" };
833
- function Zn(e, t) {
834
- return l(), d("div", Rn, [
835
- y(e.$slots, "default", {}, void 0, !0)
836
- ]);
837
- }
838
- const zn = /* @__PURE__ */ L(Nn, [["render", Zn], ["__scopeId", "data-v-f08e803e"]]), Dn = {}, Wn = { class: "mc-layout-content" };
839
- function Fn(e, t) {
840
- return l(), d("div", Wn, [
841
- y(e.$slots, "default", {}, void 0, !0)
842
- ]);
843
- }
844
- const Un = /* @__PURE__ */ L(Dn, [["render", Fn], ["__scopeId", "data-v-74f98b9a"]]), xn = {}, Gn = { class: "mc-layout-header" };
845
- function qn(e, t) {
846
- return l(), d("div", Gn, [
847
- y(e.$slots, "default", {}, void 0, !0)
848
- ]);
849
- }
850
- const Xn = /* @__PURE__ */ L(xn, [["render", qn], ["__scopeId", "data-v-cfa1505b"]]), Jn = {}, Qn = { class: "mc-layout-aside" };
851
- function Yn(e, t) {
852
- return l(), d("div", Qn, [
853
- y(e.$slots, "default")
854
- ]);
855
- }
856
- const eo = /* @__PURE__ */ L(Jn, [["render", Yn]]), to = {}, no = { class: "mc-layout-sender" };
857
- function oo(e, t) {
858
- return l(), d("div", no, [
859
- y(e.$slots, "default")
860
- ]);
861
- }
862
- const ro = /* @__PURE__ */ L(to, [["render", oo]]), yo = {
863
- install(e) {
864
- e.component("McHeader", Qe), e.component("McBubble", ut), e.component("McInput", Et), e.component("McIntroduction", Vt), e.component("McPrompt", nn), e.component("McList", he), e.component("McMention", Kn), e.component("McLayout", zn), e.component("McLayoutContent", Un), e.component("McLayoutHeader", Xn), e.component("McLayoutAside", eo), e.component("McLayoutSender", ro);
865
- }
866
- };
867
- export {
868
- yo as default
869
43
  };