@matechat/core 0.0.1-alpha

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/index.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ import type { App } from 'vue';
2
+ declare function install(app: App): void
3
+ declare const _default: {
4
+ install: typeof install;
5
+ version: string;
6
+ };
7
+ export default _default;
package/mate-chat.css ADDED
@@ -0,0 +1 @@
1
+ .mc-header[data-v-706d836c]{display:flex;justify-content:space-between;padding:8px 12px;align-items:center}.mc-header .mc-header-logo-container[data-v-706d836c]{display:flex;align-items:center;gap:4px}.mc-header .mc-header-logo-container.clickable[data-v-706d836c]{cursor:pointer}.mc-header .mc-header-logo-container .mc-header-title[data-v-706d836c]{letter-spacing:1px;font-weight:500;font-size:20px}.mc-bubble-loading[data-v-f976c7b6]{display:flex;align-items:center;gap:8px}.mc-bubble-loading .loading-dot[data-v-f976c7b6]{width:8px;height:8px;border-radius:5px;background-color:#9880ff}.mc-bubble-loading .loading-dot.dot-start[data-v-f976c7b6]{animation:dotFlashing-f976c7b6 1s infinite linear alternate;animation-delay:0s}.mc-bubble-loading .loading-dot.dot-middle[data-v-f976c7b6]{animation:dotFlashing-f976c7b6 1s infinite linear alternate;animation-delay:.5s}.mc-bubble-loading .loading-dot.dot-end[data-v-f976c7b6]{animation:dotFlashing-f976c7b6 1s infinite linear alternate;animation-delay:1s}@keyframes dotFlashing-f976c7b6{0%{background-color:#9880ff}to{background-color:#ebe6ff}}.mc-bubble[data-v-817ff41e]{display:flex;gap:4px}.mc-bubble .mc-bubble-content[data-v-817ff41e]{word-wrap:break-word}.mc-bubble .mc-bubble-content.filled[data-v-817ff41e],.mc-bubble .mc-bubble-content.bordered[data-v-817ff41e]{padding:12px 16px;border-radius:12px}.mc-bubble .mc-bubble-content.filled[data-v-817ff41e]{background-color:var(--devui-global-bg, #f6f6f8)}.mc-bubble .mc-bubble-content.bordered[data-v-817ff41e]{border:1px solid var(--devui-dividing-line, #f2f2f3)}.mc-bubble .mc-bubble-avatar[data-v-817ff41e]{flex-shrink:0;display:flex;gap:4px}.mc-bubble .mc-bubble-avatar .mc-bubble-avatar-name[data-v-817ff41e]{font-size:14px}.mc-bubble .mc-bubble-avatar.empty-avatar[data-v-817ff41e]{visibility:hidden}.mc-bubble.mc-bubble-avatar-top .mc-bubble-avatar[data-v-817ff41e]{align-items:center}.mc-bubble .mc-bubble-content-container[data-v-817ff41e]{max-width:100%}.mc-bubble.mc-bubble-avatar-top[data-v-817ff41e]{flex-direction:column}.mc-bubble.mc-bubble-loading.mc-bubble-avatar-side[data-v-817ff41e]{align-items:center}.mc-bubble.mc-bubble-avatar-side.mc-bubble-right[data-v-817ff41e]{flex-direction:row-reverse;justify-content:end}.mc-bubble.mc-bubble-avatar-top .mc-bubble-avatar[data-v-817ff41e],.mc-bubble.mc-bubble-avatar-top .mc-bubble-content-container[data-v-817ff41e]{display:flex}.mc-bubble.mc-bubble-avatar-top.mc-bubble-right .mc-bubble-avatar[data-v-817ff41e],.mc-bubble.mc-bubble-avatar-top.mc-bubble-right .mc-bubble-content-container[data-v-817ff41e]{justify-content:end}.mc-bubble.mc-bubble-avatar-top.mc-bubble-right .mc-bubble-avatar[data-v-817ff41e]{flex-direction:row-reverse}.mc-textarea.devui-textarea{height:64px;padding-left:0;padding-right:0;border:none}.mc-textarea.devui-textarea.mc-textarea-simple{height:32px}.mc-textarea.devui-textarea::placeholder{color:var(--devui-placeholder, #babbc0)}.mc-button.devui-button[data-v-75e80f2d]{border:none}.mc-button.devui-button.mc-button-loading[data-v-75e80f2d] i{animation:rotating-75e80f2d 1s linear infinite}@keyframes rotating-75e80f2d{0%{transform:rotate(0)}to{transform:rotate(180deg)}}.mc-input{display:flex;flex-direction:column;width:100%;padding:4px 0;border:1px solid var(--devui-form-control-line, #d7d8da);border-radius:14px;box-sizing:border-box}.mc-input.mc-input-disabled{background-color:var(--devui-disabled-bg, #f5f5f5);cursor:not-allowed}.mc-input .mc-input-content{display:flex;align-items:flex-end;padding:0 8px}.mc-input .mc-input-foot{display:flex;justify-content:space-between;align-items:center;height:32px;padding:0 8px}.mc-input .mc-input-foot .mc-input-foot-left{flex:1;height:100%;display:flex;align-items:center}.mc-input .mc-input-foot .mc-input-foot-left .mc-input-foot-count{margin-left:8px;color:var(--devui-text, #252b3a);font-size:var(--devui-font-size, 12px)}.mc-introduction[data-v-48b255c7]{display:flex;gap:12px;flex-direction:column;color:var(--devui-text, #252b3a)}.mc-introduction .mc-introduction-logo-container[data-v-48b255c7]{display:flex;align-items:center;gap:8px}.mc-introduction .mc-introduction-logo-container .mc-introduction-title[data-v-48b255c7]{font-weight:700;font-size:32px;letter-spacing:1px}.mc-introduction .mc-introduction-sub-title[data-v-48b255c7]{font-weight:500;font-size:18px}.mc-introduction .mc-introduction-description[data-v-48b255c7]{font-size:var(--devui-font-size-sm, 12px)}.mc-introduction .mc-introduction-description>div[data-v-48b255c7]{line-height:1.5}.mc-introduction.filled[data-v-48b255c7]{background-color:var(--devui-global-bg, #f6f6f8);border-radius:8px;padding:8px 12px}.mc-introduction.center[data-v-48b255c7]{align-items:center}.mc-introduction.center .mc-introduction-description[data-v-48b255c7]{text-align:center}.mc-introduction.left[data-v-48b255c7]{align-items:flex-start}.mc-introduction.left .mc-introduction-description[data-v-48b255c7]{text-align:left}.mc-introduction.right[data-v-48b255c7]{align-items:flex-end}.mc-introduction.right .mc-introduction-description[data-v-48b255c7]{text-align:right}.mc-list[data-v-adad50a4]{width:100%;max-height:300px;box-sizing:border-box;overflow:auto}.mc-list.mc-list-horizontal .mc-list-item[data-v-adad50a4]{width:unset}.mc-list:not(.mc-list-horizontal) .mc-list-item[data-v-adad50a4]:not(:first-child){margin-top:4px}.mc-list .mc-list-item[data-v-adad50a4]{width:100%;line-height:20px;padding:8px;color:var(--devui-text, #252b3a);font-size:var(--devui-font-size, 12px);border-radius:var(--devui-border-radius, 2px);box-sizing:border-box;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;cursor:pointer;transition:color var(--devui-animation-duration-fast, .1s) var(--devui-animation-ease-in-out-smooth, cubic-bezier(.645, .045, .355, 1)),background-color var(--devui-animation-duration-fast, .1s) var(--devui-animation-ease-in-out-smooth, cubic-bezier(.645, .045, .355, 1))}.mc-list .mc-list-item.filled[data-v-adad50a4]{background-color:var(--devui-gray-form-control-bg, #f5f5f5)}.mc-list .mc-list-item.bordered[data-v-adad50a4]{border:1px solid var(--devui-dividing-line, #f2f2f3)}.mc-list .mc-list-item[data-v-adad50a4]:hover,.mc-list .mc-list-item.mc-list-item-pre-selection[data-v-adad50a4]{color:var(--devui-list-item-hover-text, #252b3a);background-color:var(--devui-list-item-hover-bg, #f2f2f3)}.mc-list .mc-list-item.mc-list-item-active[data-v-adad50a4]{color:var(--devui-list-item-active-text, #252b3a);background-color:var(--devui-list-item-active-bg, #f2f5fc)}.mc-list .mc-list-item.mc-list-item-disabled[data-v-adad50a4]{color:var(--devui-disabled-text, #cfd0d3);background-color:var(--devui-disabled-bg, #f5f5f5);cursor:not-allowed}.mc-list-horizontal[data-v-adad50a4]{display:flex;flex-wrap:wrap;gap:12px}.mc-list-horizontal.mc-list-nowrap[data-v-adad50a4]{flex-wrap:nowrap}.mc-list-horizontal.mc-list-nowrap .mc-list-item[data-v-adad50a4]{flex:none}.mc-prompt-item[data-v-5f016595]{display:flex;gap:8px}.mc-prompt-item .mc-prompt-item-icon.no-description[data-v-5f016595]{display:flex;align-items:center}.mc-prompt-item .mc-prompt-item-content[data-v-5f016595]{display:flex;flex-direction:column;gap:4px}.mc-prompt-item .mc-prompt-item-content .mc-prompt-item-label[data-v-5f016595]{font-weight:700}.mc-prompt-item .mc-prompt-item-content .mc-prompt-item-description[data-v-5f016595]{color:var(--devui-aide-text, #71757f)}.mc-mention[data-v-196371c8]{position:fixed;max-height:300px;border-radius:var(--devui-border-radius, 2px);background-color:var(--devui-connected-overlay-bg, #ffffff);box-shadow:var(--devui-shadow-length-connected-overlay, 0 2px 12px 0) var(--devui-shadow, rgba(37, 43, 58, .24));transform-origin:0% 100%;z-index:1000}.mc-mention-fade-enter-from[data-v-196371c8],.mc-mention-fade-leave-to[data-v-196371c8]{opacity:.8;transform:scaleY(.8) translateY(4px)}.mc-mention-fade-enter-to[data-v-196371c8],.mc-mention-fade-leave-from[data-v-196371c8]{opacity:1;transform:scaleY(.9999) translateY(0)}.mc-mention-fade-enter-active[data-v-196371c8]{transition:transform .2s cubic-bezier(.16,.75,.5,1),opacity .2s cubic-bezier(.16,.75,.5,1)}.mc-mention-fade-leave-active[data-v-196371c8]{transition:transform .2s cubic-bezier(.5,0,.84,.25),opacity .2s cubic-bezier(.5,0,.84,.25)}.mc-layout[data-v-f08e803e]{display:flex;flex:auto;flex-direction:column}.mc-layout-aside[data-v-f08e803e]{flex-direction:row}.mc-layout-content[data-v-74f98b9a]{flex:auto;min-height:0}.mc-layout-header[data-v-cfa1505b]{flex:0 0 auto;min-height:40px}
package/mate-chat.js ADDED
@@ -0,0 +1,725 @@
1
+ import "./mate-chat.css";
2
+ import { defineComponent as C, openBlock as l, createElementBlock as c, createElementVNode as S, normalizeClass as b, createCommentVNode as y, toDisplayString as k, renderSlot as v, useSlots as ve, computed as H, createVNode as E, unref as d, normalizeProps as te, guardReactiveProps as ge, createTextVNode as U, inject as oe, createBlock as R, isRef as ye, nextTick as ne, withCtx as O, ref as w, watch as se, provide as he, Fragment as V, renderList as ae, onMounted as re, mergeProps as _e, Comment as be, Text as $e, h as Se, withDirectives as ke, cloneVNode as Ce, reactive as Ee, onBeforeUnmount as Ie, Teleport as we, Transition as Le, normalizeStyle as Te } from "vue";
3
+ import { Avatar as Ae } from "vue-devui/avatar";
4
+ import "vue-devui/avatar/style.css";
5
+ import { Textarea as Pe } from "vue-devui/textarea";
6
+ import "vue-devui/textarea/style.css";
7
+ import { Button as Me } from "vue-devui/button";
8
+ import "vue-devui/button/style.css";
9
+ import { Icon as Be } from "vue-devui/icon";
10
+ import "vue-devui/icon/style.css";
11
+ import { isObject as Ve } from "@vue/shared";
12
+ import { computePosition as Ke, offset as He } from "@floating-ui/dom";
13
+ import { debounce as Oe, isObject as Ne } from "lodash";
14
+ const Re = {
15
+ logoImg: {
16
+ type: String,
17
+ default: ""
18
+ },
19
+ title: {
20
+ type: String,
21
+ default: ""
22
+ },
23
+ logoClickable: {
24
+ type: Boolean,
25
+ default: !1
26
+ }
27
+ }, ze = { class: "mc-header" }, De = ["src", "alt"], je = { class: "mc-header-title" }, Fe = { class: "mc-header-operation" }, Ue = /* @__PURE__ */ C({
28
+ __name: "Header",
29
+ props: Re,
30
+ emits: ["logoClicked"],
31
+ setup(e, { emit: t }) {
32
+ const n = t, a = e, u = () => {
33
+ a.logoClickable && n("logoClicked");
34
+ };
35
+ return (o, s) => (l(), c("div", ze, [
36
+ S("div", {
37
+ class: b(["mc-header-logo-container", { clickable: o.logoClickable }]),
38
+ onClick: u
39
+ }, [
40
+ o.logoImg ? (l(), c("img", {
41
+ key: 0,
42
+ class: "mc-header-logo",
43
+ src: o.logoImg,
44
+ alt: o.logoImg
45
+ }, null, 8, De)) : y("", !0),
46
+ S("div", je, k(o.title), 1)
47
+ ], 2),
48
+ S("div", Fe, [
49
+ v(o.$slots, "operationArea", {}, void 0, !0)
50
+ ])
51
+ ]));
52
+ }
53
+ }), $ = (e, t) => {
54
+ const n = e.__vccOpts || e;
55
+ for (const [a, u] of t)
56
+ n[a] = u;
57
+ return n;
58
+ }, We = /* @__PURE__ */ $(Ue, [["__scopeId", "data-v-706d836c"]]), qe = {
59
+ content: {
60
+ type: String,
61
+ default: ""
62
+ },
63
+ loading: {
64
+ type: Boolean,
65
+ default: !1
66
+ },
67
+ align: {
68
+ type: String,
69
+ default: "left"
70
+ },
71
+ avatarPosition: {
72
+ type: String,
73
+ default: "side"
74
+ },
75
+ variant: {
76
+ type: String,
77
+ default: "filled"
78
+ },
79
+ avatarConfig: {
80
+ type: Object
81
+ }
82
+ }, Ge = 36, Xe = 36, Je = "name", Qe = "imgSrc", Ye = {}, Ze = { class: "mc-bubble-loading" };
83
+ function xe(e, t) {
84
+ return l(), c("div", Ze, t[0] || (t[0] = [
85
+ S("div", { class: "loading-dot dot-start" }, null, -1),
86
+ S("div", { class: "loading-dot dot-middle" }, null, -1),
87
+ S("div", { class: "loading-dot dot-end" }, null, -1)
88
+ ]));
89
+ }
90
+ const et = /* @__PURE__ */ $(Ye, [["render", xe], ["__scopeId", "data-v-f976c7b6"]]), tt = {
91
+ key: 0,
92
+ class: "mc-bubble-avatar-name"
93
+ }, ot = {
94
+ key: 1,
95
+ class: "loading-container"
96
+ }, nt = /* @__PURE__ */ C({
97
+ __name: "Bubble",
98
+ props: qe,
99
+ setup(e) {
100
+ const t = ve(), n = e, a = H(() => [
101
+ `mc-bubble-avatar-${n.avatarPosition}`,
102
+ `mc-bubble-${n.align}`,
103
+ n.loading ? "mc-bubble-loading" : ""
104
+ ]), u = H(() => {
105
+ if (n.avatarConfig) {
106
+ const o = Object.keys(n.avatarConfig), s = o.some((r) => r === Je || r === Qe);
107
+ return o.length < 1 || !s;
108
+ } else
109
+ return !0;
110
+ });
111
+ return (o, s) => {
112
+ var r, i, p;
113
+ return l(), c("div", {
114
+ class: b(["mc-bubble", a.value])
115
+ }, [
116
+ o.avatarConfig ? (l(), c("div", {
117
+ key: 0,
118
+ class: b(["mc-bubble-avatar", { "empty-avatar": u.value }])
119
+ }, [
120
+ E(d(Ae), te(ge(
121
+ u.value ? {
122
+ width: ((r = o.avatarConfig) == null ? void 0 : r.width) || d(Ge),
123
+ height: ((i = o.avatarConfig) == null ? void 0 : i.height) || d(Xe)
124
+ } : o.avatarConfig
125
+ )), null, 16),
126
+ o.avatarPosition === "top" ? (l(), c("span", tt, k((p = o.avatarConfig) == null ? void 0 : p.displayName), 1)) : y("", !0)
127
+ ], 2)) : y("", !0),
128
+ S("div", {
129
+ class: b(["mc-bubble-content-container", { "with-avatar": o.avatarConfig }])
130
+ }, [
131
+ o.loading ? y("", !0) : v(o.$slots, "top", { key: 0 }, void 0, !0),
132
+ o.loading ? (l(), c("div", ot, [
133
+ v(o.$slots, "loadingTpl", {}, () => [
134
+ E(et)
135
+ ], !0)
136
+ ])) : y("", !0),
137
+ (d(t).default || o.content) && !o.loading ? (l(), c("div", {
138
+ key: 2,
139
+ class: b(["mc-bubble-content", [o.variant]])
140
+ }, [
141
+ v(o.$slots, "default", {}, () => [
142
+ U(k(o.content), 1)
143
+ ], !0)
144
+ ], 2)) : y("", !0),
145
+ o.loading ? y("", !0) : v(o.$slots, "bottom", { key: 3 }, void 0, !0)
146
+ ], 2)
147
+ ], 2);
148
+ };
149
+ }
150
+ }), st = /* @__PURE__ */ $(nt, [["__scopeId", "data-v-817ff41e"]]);
151
+ var N = /* @__PURE__ */ ((e) => (e.Simple = "simple", e.Full = "full", e))(N || {}), B = /* @__PURE__ */ ((e) => (e.Enter = "enter", e.ShiftEnter = "shiftEnter", e))(B || {});
152
+ const at = {
153
+ value: {
154
+ type: String,
155
+ default: ""
156
+ },
157
+ placeholder: {
158
+ type: String
159
+ },
160
+ disabled: {
161
+ type: Boolean,
162
+ default: !1
163
+ },
164
+ displayType: {
165
+ type: String,
166
+ default: "full"
167
+ /* Full */
168
+ },
169
+ loading: {
170
+ type: Boolean,
171
+ default: !1
172
+ },
173
+ showCount: {
174
+ type: Boolean,
175
+ default: !1
176
+ },
177
+ maxLength: {
178
+ type: Number
179
+ },
180
+ submitShortKey: {
181
+ type: [String, null],
182
+ default: "enter"
183
+ /* Enter */
184
+ }
185
+ }, rt = ["change", "submit", "cancel"], W = "mc-input", lt = /* @__PURE__ */ C({
186
+ __name: "textarea",
187
+ setup(e) {
188
+ const { inputValue: t, rootProps: n, rootEmits: a } = oe(W), u = H(() => {
189
+ let f = "", _ = "";
190
+ return n.submitShortKey === B.Enter && (f = "Enter", _ = "Shift + Enter"), n.submitShortKey === B.ShiftEnter && (f = "Shift + Enter", _ = "Enter"), n.placeholder ?? (f ? `请输入您的问题,并按${f}发送,按${_}换行` : "请输入您的问题...");
191
+ });
192
+ let o = !1;
193
+ const s = () => {
194
+ ne(() => {
195
+ a("change", t.value);
196
+ });
197
+ }, r = () => {
198
+ o || s();
199
+ }, i = () => {
200
+ o = !0;
201
+ }, p = () => {
202
+ o = !1, s();
203
+ }, g = (f) => {
204
+ if (n.submitShortKey === null)
205
+ return;
206
+ (n.submitShortKey === B.Enter ? !f.shiftKey : n.submitShortKey === B.ShiftEnter ? f.shiftKey : !1) && f.code === "Enter" && (f.preventDefault(), a("submit", t.value), t.value = "");
207
+ };
208
+ return (f, _) => (l(), R(d(Pe), {
209
+ modelValue: d(t),
210
+ "onUpdate:modelValue": _[0] || (_[0] = (L) => ye(t) ? t.value = L : null),
211
+ placeholder: u.value,
212
+ showGlowStyle: !1,
213
+ disabled: d(n).disabled,
214
+ maxlength: d(n).maxLength,
215
+ class: b(["mc-textarea", { "mc-textarea-simple": d(n).displayType === d(N).Simple }]),
216
+ onInput: r,
217
+ onCompositionstart: i,
218
+ onCompositionend: p,
219
+ onKeydown: g
220
+ }, null, 8, ["modelValue", "placeholder", "disabled", "maxlength", "class"]));
221
+ }
222
+ }), it = /* @__PURE__ */ C({
223
+ __name: "button",
224
+ setup(e) {
225
+ const { inputValue: t, rootProps: n, rootEmits: a } = oe(W), u = () => {
226
+ n.loading ? a("cancel") : (a("submit", t.value), t.value = "");
227
+ };
228
+ return (o, s) => (l(), R(d(Me), {
229
+ variant: "solid",
230
+ icon: d(n).loading ? "icon-loading-2" : "publish-new",
231
+ shape: "round",
232
+ disabled: d(n).disabled || !d(n).loading && !d(t),
233
+ class: b(["mc-button", { "mc-button-loading": d(n).loading }]),
234
+ onClick: u
235
+ }, {
236
+ default: O(() => [
237
+ U(k(d(n).loading ? "暂停回答" : "发送"), 1)
238
+ ]),
239
+ _: 1
240
+ }, 8, ["icon", "disabled", "class"]));
241
+ }
242
+ }), x = /* @__PURE__ */ $(it, [["__scopeId", "data-v-75e80f2d"]]), ct = { class: "mc-input-content" }, ut = {
243
+ key: 0,
244
+ class: "mc-input-foot"
245
+ }, dt = { class: "mc-input-foot-left" }, mt = {
246
+ key: 0,
247
+ class: "mc-input-foot-count"
248
+ }, pt = /* @__PURE__ */ C({
249
+ __name: "Input",
250
+ props: at,
251
+ emits: rt,
252
+ setup(e, { expose: t, emit: n }) {
253
+ const a = e, u = n, o = w(""), s = () => {
254
+ o.value = "";
255
+ }, r = () => o.value;
256
+ return se(
257
+ () => a.value,
258
+ () => {
259
+ o.value = a.value;
260
+ },
261
+ { immediate: !0 }
262
+ ), t({ clearInput: s, getInput: r }), he(W, { inputValue: o, rootProps: a, rootEmits: u }), (i, p) => (l(), c("div", {
263
+ class: b(["mc-input", { "mc-input-disabled": i.disabled }])
264
+ }, [
265
+ v(i.$slots, "head"),
266
+ S("div", ct, [
267
+ v(i.$slots, "prefix"),
268
+ E(lt),
269
+ i.displayType === d(N).Simple ? v(i.$slots, "button", { key: 0 }, () => [
270
+ E(x)
271
+ ]) : y("", !0)
272
+ ]),
273
+ i.displayType === d(N).Full ? (l(), c("div", ut, [
274
+ S("div", dt, [
275
+ v(i.$slots, "extra"),
276
+ i.showCount ? (l(), c("span", mt, k(o.value.length) + k(i.maxLength ?? !1 ? `/${i.maxLength}` : ""), 1)) : y("", !0)
277
+ ]),
278
+ v(i.$slots, "button", {}, () => [
279
+ E(x)
280
+ ])
281
+ ])) : y("", !0)
282
+ ], 2));
283
+ }
284
+ }), ft = {
285
+ logoImg: {
286
+ type: String,
287
+ default: ""
288
+ },
289
+ title: {
290
+ type: String,
291
+ default: ""
292
+ },
293
+ subTitle: {
294
+ type: String,
295
+ default: ""
296
+ },
297
+ description: {
298
+ type: Array,
299
+ default: () => []
300
+ },
301
+ background: {
302
+ type: String,
303
+ default: "transparent"
304
+ },
305
+ align: {
306
+ type: String,
307
+ default: "center"
308
+ }
309
+ }, vt = { class: "mc-introduction-logo-container" }, gt = ["src", "alt"], yt = { class: "mc-introduction-title" }, ht = {
310
+ key: 0,
311
+ class: "mc-introduction-sub-title"
312
+ }, _t = {
313
+ key: 1,
314
+ class: "mc-introduction-description"
315
+ }, bt = /* @__PURE__ */ C({
316
+ __name: "Introduction",
317
+ props: ft,
318
+ setup(e) {
319
+ return (t, n) => (l(), c("div", {
320
+ class: b(["mc-introduction", [t.align, t.background]])
321
+ }, [
322
+ S("div", vt, [
323
+ t.logoImg ? (l(), c("img", {
324
+ key: 0,
325
+ src: t.logoImg,
326
+ alt: t.title
327
+ }, null, 8, gt)) : y("", !0),
328
+ S("div", yt, k(t.title), 1)
329
+ ]),
330
+ t.subTitle ? (l(), c("div", ht, k(t.subTitle), 1)) : y("", !0),
331
+ t.description.length ? (l(), c("div", _t, [
332
+ (l(!0), c(V, null, ae(t.description, (a, u) => (l(), c("div", { key: u }, k(a), 1))), 128))
333
+ ])) : y("", !0),
334
+ v(t.$slots, "default", {}, void 0, !0)
335
+ ], 2));
336
+ }
337
+ }), $t = /* @__PURE__ */ $(bt, [["__scopeId", "data-v-48b255c7"]]);
338
+ var K = /* @__PURE__ */ ((e) => (e.Horizontal = "horizontal", e.Vertical = "vertical", e))(K || {}), q = /* @__PURE__ */ ((e) => (e.Transparent = "transparent", e.Filled = "filled", e.Bordered = "bordered", e.None = "none", e))(q || {});
339
+ const St = {
340
+ direction: {
341
+ type: String,
342
+ default: "vertical"
343
+ /* Vertical */
344
+ },
345
+ autoWrap: {
346
+ type: Boolean,
347
+ default: !0
348
+ },
349
+ variant: {
350
+ type: String,
351
+ default: "transparent"
352
+ /* Transparent */
353
+ },
354
+ enableLazyLoad: {
355
+ type: Boolean,
356
+ default: !1
357
+ },
358
+ data: {
359
+ type: Array,
360
+ default: () => []
361
+ },
362
+ enableShortKey: {
363
+ type: Boolean,
364
+ default: !1
365
+ },
366
+ inputEl: {
367
+ type: Object
368
+ },
369
+ selectable: {
370
+ type: Boolean,
371
+ default: !0
372
+ }
373
+ }, kt = 50, Ct = ["TEXTAREA", "INPUT"], Et = "ArrowUp", It = "ArrowDown", wt = "Enter";
374
+ function Lt(e, t) {
375
+ const n = w(e.enableShortKey ? 0 : -1), a = (s) => {
376
+ if (!s.disabled) {
377
+ if (e.selectable)
378
+ for (let r = 0; r < e.data.length; r++)
379
+ e.data[r].active = e.data[r].value === s.value;
380
+ t("select", { ...s });
381
+ }
382
+ }, u = (s) => {
383
+ if (!e.enableLazyLoad || e.direction !== K.Vertical)
384
+ return;
385
+ const r = s.target, i = r.scrollHeight, p = r.clientHeight, g = r.scrollTop;
386
+ i - p - g < kt && t("loadMore", s);
387
+ }, o = (s) => {
388
+ s.code === Et && (n.value = n.value === 0 ? e.data.length - 1 : n.value - 1), s.code === It && (n.value = n.value === e.data.length - 1 ? 0 : n.value + 1), s.code === wt && (e.selectable && (e.data[n.value].active = !0), t("select", { ...e.data[n.value] }));
389
+ };
390
+ return re(() => {
391
+ let s;
392
+ if (e.inputEl) {
393
+ const r = e.inputEl.$el ?? e.inputEl;
394
+ Ct.includes(r.tagName) ? s = r : s = r.querySelector("textarea") || r.querySelector("input") || document;
395
+ } else
396
+ s = document;
397
+ e.enableShortKey && s.addEventListener("keydown", o);
398
+ }), { preSelectIndex: n, onItemClick: a, onListScroll: u };
399
+ }
400
+ function Tt(e) {
401
+ return { listClasses: H(() => ({
402
+ "mc-list": !0,
403
+ "mc-list-horizontal": e.direction === K.Horizontal,
404
+ "mc-list-nowrap": e.direction === K.Horizontal && !e.autoWrap
405
+ })) };
406
+ }
407
+ const At = ["onClick"], Pt = /* @__PURE__ */ C({
408
+ __name: "List",
409
+ props: St,
410
+ emits: ["select", "loadMore"],
411
+ setup(e, { emit: t }) {
412
+ const n = e, a = t, { listClasses: u } = Tt(n), { preSelectIndex: o, onItemClick: s, onListScroll: r } = Lt(n, a);
413
+ return (i, p) => (l(), c("div", {
414
+ class: b(d(u)),
415
+ onScroll: p[0] || (p[0] = //@ts-ignore
416
+ (...g) => d(r) && d(r)(...g))
417
+ }, [
418
+ (l(!0), c(V, null, ae(i.data, (g, f) => (l(), c(V, { key: f }, [
419
+ i.variant === d(q).None ? v(i.$slots, "item", {
420
+ key: 0,
421
+ item: g
422
+ }, void 0, !0) : (l(), c("div", {
423
+ key: 1,
424
+ class: b([
425
+ "mc-list-item",
426
+ {
427
+ "mc-list-item-disabled": g.disabled,
428
+ "mc-list-item-active": g.active,
429
+ "mc-list-item-pre-selection": f === d(o)
430
+ },
431
+ i.variant
432
+ ]),
433
+ onClick: () => d(s)(g)
434
+ }, [
435
+ v(i.$slots, "item", { item: g }, () => [
436
+ U(k(g.label), 1)
437
+ ], !0)
438
+ ], 10, At))
439
+ ], 64))), 128))
440
+ ], 34));
441
+ }
442
+ }), le = /* @__PURE__ */ $(Pt, [["__scopeId", "data-v-adad50a4"]]), Mt = {
443
+ direction: {
444
+ type: String,
445
+ default: K.Vertical
446
+ },
447
+ list: {
448
+ type: Array,
449
+ default: () => []
450
+ },
451
+ variant: {
452
+ type: String,
453
+ default: q.Filled
454
+ }
455
+ }, Bt = {
456
+ prompt: {
457
+ type: Object
458
+ }
459
+ }, Vt = { class: "mc-prompt-item" }, Kt = {
460
+ key: 0,
461
+ class: "mc-prompt-item-content"
462
+ }, Ht = {
463
+ key: 0,
464
+ class: "mc-prompt-item-label"
465
+ }, Ot = {
466
+ key: 1,
467
+ class: "mc-prompt-item-description"
468
+ }, Nt = /* @__PURE__ */ C({
469
+ __name: "PromptItem",
470
+ props: Bt,
471
+ setup(e) {
472
+ return (t, n) => {
473
+ var a, u, o, s, r, i, p, g, f;
474
+ return l(), c("div", Vt, [
475
+ S("div", {
476
+ class: b(["mc-prompt-item-icon", { "no-description": !((a = t.prompt) != null && a.desc) }])
477
+ }, [
478
+ (u = t.prompt) != null && u.iconConfig ? (l(), R(d(Be), te(_e({ key: 0 }, (o = t.prompt) == null ? void 0 : o.iconConfig)), null, 16)) : y("", !0)
479
+ ], 2),
480
+ (s = t.prompt) != null && s.label || (r = t.prompt) != null && r.desc ? (l(), c("div", Kt, [
481
+ (i = t.prompt) != null && i.label ? (l(), c("div", Ht, k((p = t.prompt) == null ? void 0 : p.label), 1)) : y("", !0),
482
+ (g = t.prompt) != null && g.desc ? (l(), c("div", Ot, k((f = t.prompt) == null ? void 0 : f.desc), 1)) : y("", !0)
483
+ ])) : y("", !0)
484
+ ]);
485
+ };
486
+ }
487
+ }), Rt = /* @__PURE__ */ $(Nt, [["__scopeId", "data-v-5f016595"]]), zt = { class: "mc-prompt" }, Dt = /* @__PURE__ */ C({
488
+ __name: "Prompt",
489
+ props: Mt,
490
+ emits: ["itemClick"],
491
+ setup(e, { emit: t }) {
492
+ const n = t, a = e;
493
+ return (u, o) => (l(), c("div", zt, [
494
+ E(le, {
495
+ data: a.list,
496
+ direction: a.direction,
497
+ variant: a.variant,
498
+ selectable: !1
499
+ }, {
500
+ item: O(({ item: s }) => [
501
+ E(Rt, {
502
+ prompt: s,
503
+ onClick: (r) => n("itemClick", s)
504
+ }, null, 8, ["prompt", "onClick"])
505
+ ]),
506
+ _: 1
507
+ }, 8, ["data", "direction", "variant"])
508
+ ]));
509
+ }
510
+ });
511
+ function ee(e) {
512
+ return Se("span", {}, e);
513
+ }
514
+ function ie(e) {
515
+ for (const t of e) {
516
+ if (Ve(t)) {
517
+ if (t.type === be)
518
+ continue;
519
+ return t.type === "svg" || t.type === $e ? ee(t) : t.type === V ? ie(t.children) : t;
520
+ }
521
+ return ee(t);
522
+ }
523
+ return null;
524
+ }
525
+ const jt = /* @__PURE__ */ C({
526
+ setup(e, t) {
527
+ const {
528
+ slots: n,
529
+ attrs: a,
530
+ expose: u
531
+ } = t, o = w();
532
+ return u({
533
+ triggerEl: o
534
+ }), () => {
535
+ var i;
536
+ const s = (i = n.default) == null ? void 0 : i.call(n, a);
537
+ if (!s)
538
+ return null;
539
+ const r = ie(s);
540
+ return r ? ke(Ce(r, a), [[{
541
+ mounted(p) {
542
+ o.value = p;
543
+ },
544
+ updated(p) {
545
+ o.value = p;
546
+ },
547
+ unmounted() {
548
+ o.value = null;
549
+ }
550
+ }]]) : null;
551
+ };
552
+ }
553
+ }), Ft = {
554
+ modelValue: {
555
+ type: Boolean,
556
+ default: !1
557
+ },
558
+ prefix: {
559
+ type: Array,
560
+ default: () => []
561
+ },
562
+ fitHostWidth: {
563
+ type: Boolean,
564
+ default: !0
565
+ },
566
+ menuClass: {
567
+ type: String
568
+ }
569
+ }, Ut = ["update:modelValue", "searchChange", "toggleChange"], F = " ", Wt = "ArrowLeft", qt = "ArrowRight", Gt = "Escape";
570
+ function Xt(e, t) {
571
+ const n = w(), a = w(), u = w(), o = Ee({ top: "0px", left: "0px", width: "" });
572
+ let s, r, i, p, g = "", f, _;
573
+ const L = async () => {
574
+ if (!a.value || !u.value)
575
+ return;
576
+ const { x: m, y: h } = await Ke(a.value, u.value, {
577
+ strategy: "fixed",
578
+ placement: "top-start",
579
+ middleware: [He(4)]
580
+ });
581
+ o.top = `${h}px`, o.left = `${m}px`;
582
+ }, ce = () => {
583
+ const { width: m } = a.value.getBoundingClientRect();
584
+ o.width = `${m}px`, L();
585
+ }, ue = () => {
586
+ e.fitHostWidth && typeof window < "u" && a.value && (_ = new window.ResizeObserver(ce), _.observe(a.value));
587
+ }, G = () => {
588
+ a.value && (_ == null || _.unobserve(a.value));
589
+ };
590
+ se(
591
+ () => e.modelValue,
592
+ (m, h) => {
593
+ m ? (ne(L), ue(), window.addEventListener("scroll", D, !0)) : (G(), window.removeEventListener("scroll", D, !0)), h !== void 0 && t("toggleChange", m);
594
+ },
595
+ { immediate: !0 }
596
+ );
597
+ const X = () => {
598
+ r = null, i = -1, p = -1, g = "";
599
+ }, T = (m) => {
600
+ t("update:modelValue", m);
601
+ }, de = () => {
602
+ if (!s)
603
+ return;
604
+ const m = s.value.replace(/[\r\n]/g, F) || "", h = s.selectionStart;
605
+ if (!m.trim() || !h) {
606
+ X();
607
+ return;
608
+ }
609
+ for (let I = 0; I < e.prefix.length; I++) {
610
+ const A = e.prefix[I];
611
+ let P = "", Z = !1;
612
+ if (typeof A == "string")
613
+ P = A;
614
+ else if (Ne(A))
615
+ P = A.key, Z = !!A.onlyInputStart;
616
+ else
617
+ continue;
618
+ const M = m.lastIndexOf(P, h), pe = m.lastIndexOf(F, h), j = m.substring(M, h), fe = j.charAt(j.length - 1);
619
+ if (M < 0 || M > 0 && Z || M < pe || fe === F)
620
+ X();
621
+ else {
622
+ r = P, i = M, p = h, g = j.slice(P.length);
623
+ return;
624
+ }
625
+ }
626
+ }, z = () => {
627
+ if (de(), !r) {
628
+ T(!1);
629
+ return;
630
+ }
631
+ t("searchChange", { value: g, trigger: r, triggerIndex: i, cursorIndex: p }), T(!0);
632
+ }, J = Oe(z, 300), Q = (m) => {
633
+ (m.code === Wt || m.code === qt) && (f = setTimeout(() => {
634
+ z(), f && (f = void 0, clearTimeout(f));
635
+ })), m.code === Gt && T(!1);
636
+ }, Y = (m) => {
637
+ var h, I;
638
+ e.modelValue ? (h = a.value) != null && h.contains(m.target) || T(!1) : (I = a.value) != null && I.contains(m.target) && z();
639
+ };
640
+ function D(m) {
641
+ const h = m.target;
642
+ h != null && h.contains(a.value) && L();
643
+ }
644
+ const me = () => {
645
+ a.value && (s = a.value.querySelector("textarea") || a.value.querySelector("input"), s && (s.addEventListener("input", J), s.addEventListener("keydown", Q))), document.addEventListener("click", Y);
646
+ };
647
+ return re(() => {
648
+ const m = n.value.triggerEl;
649
+ a.value = m.$el ?? m, me();
650
+ }), Ie(() => {
651
+ T(!1), s == null || s.removeEventListener("input", J), s == null || s.removeEventListener("keydown", Q), document.removeEventListener("click", Y), window.removeEventListener("scroll", D, !0), G();
652
+ }), { popperTriggerEl: n, overlayEl: u, overlayStyle: o };
653
+ }
654
+ const Jt = /* @__PURE__ */ C({
655
+ __name: "Mention",
656
+ props: Ft,
657
+ emits: Ut,
658
+ setup(e, { emit: t }) {
659
+ const n = e, a = t, { popperTriggerEl: u, overlayEl: o, overlayStyle: s } = Xt(n, a);
660
+ return (r, i) => (l(), c(V, null, [
661
+ E(d(jt), {
662
+ ref_key: "popperTriggerEl",
663
+ ref: u
664
+ }, {
665
+ default: O(() => [
666
+ v(r.$slots, "default", {}, void 0, !0)
667
+ ]),
668
+ _: 3
669
+ }, 512),
670
+ (l(), R(we, { to: "body" }, [
671
+ E(Le, { name: "mc-mention-fade" }, {
672
+ default: O(() => [
673
+ r.modelValue ? (l(), c("div", {
674
+ key: 0,
675
+ ref_key: "overlayEl",
676
+ ref: o,
677
+ class: b(["mc-mention", r.menuClass]),
678
+ style: Te(d(s))
679
+ }, [
680
+ v(r.$slots, "menu", {}, void 0, !0)
681
+ ], 6)) : y("", !0)
682
+ ]),
683
+ _: 3
684
+ })
685
+ ]))
686
+ ], 64));
687
+ }
688
+ }), Qt = /* @__PURE__ */ $(Jt, [["__scopeId", "data-v-196371c8"]]), Yt = {}, Zt = { class: "mc-layout" };
689
+ function xt(e, t) {
690
+ return l(), c("div", Zt, [
691
+ v(e.$slots, "default", {}, void 0, !0)
692
+ ]);
693
+ }
694
+ const eo = /* @__PURE__ */ $(Yt, [["render", xt], ["__scopeId", "data-v-f08e803e"]]), to = {}, oo = { class: "mc-layout-content" };
695
+ function no(e, t) {
696
+ return l(), c("div", oo, [
697
+ v(e.$slots, "default", {}, void 0, !0)
698
+ ]);
699
+ }
700
+ const so = /* @__PURE__ */ $(to, [["render", no], ["__scopeId", "data-v-74f98b9a"]]), ao = {}, ro = { class: "mc-layout-header" };
701
+ function lo(e, t) {
702
+ return l(), c("div", ro, [
703
+ v(e.$slots, "default", {}, void 0, !0)
704
+ ]);
705
+ }
706
+ const io = /* @__PURE__ */ $(ao, [["render", lo], ["__scopeId", "data-v-cfa1505b"]]), co = {}, uo = { class: "mc-layout-aside" };
707
+ function mo(e, t) {
708
+ return l(), c("div", uo, [
709
+ v(e.$slots, "default")
710
+ ]);
711
+ }
712
+ const po = /* @__PURE__ */ $(co, [["render", mo]]), fo = {}, vo = { class: "mc-layout-sender" };
713
+ function go(e, t) {
714
+ return l(), c("div", vo, [
715
+ v(e.$slots, "default")
716
+ ]);
717
+ }
718
+ const yo = /* @__PURE__ */ $(fo, [["render", go]]), Ao = {
719
+ install(e) {
720
+ e.component("McHeader", We), e.component("McBubble", st), e.component("McInput", pt), e.component("McIntroduction", $t), e.component("McPrompt", Dt), e.component("McList", le), e.component("McMention", Qt), e.component("McLayout", eo), e.component("McLayoutContent", so), e.component("McLayoutHeader", io), e.component("McLayoutAside", po), e.component("McLayoutSender", yo);
721
+ }
722
+ };
723
+ export {
724
+ Ao as default
725
+ };
package/package.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "@matechat/core",
3
+ "version": "0.0.1-alpha",
4
+ "module": "mate-chat.js",
5
+ "style": "mate-chat.css",
6
+ "types": "index.d.ts",
7
+ "dependencies": {
8
+ "@devui-design/icons": "^1.4.0",
9
+ "@floating-ui/dom": "^1.6.12",
10
+ "@vue/shared": "^3.5.13",
11
+ "devui-theme": "^0.0.7",
12
+ "lodash": "^4.17.21",
13
+ "vue-devui": "^1.6.29"
14
+ },
15
+ "peerDependencies": {
16
+ "vue": "^3.5.13"
17
+ },
18
+ "publishConfig": {
19
+ "access": "public",
20
+ "registry": "https://registry.npmjs.org/"
21
+ }
22
+ }