UNPKG

@artmate/chat

Version:

**开箱即用的AI组件库(基于 Vue3 + ElementPlus)**

108 lines (107 loc) 3.49 kB
import { defineComponent as $, useSlots as z, ref as B, createElementBlock as i, openBlock as d, normalizeClass as t, unref as s, createVNode as h, createElementVNode as E, createCommentVNode as p, withCtx as w, renderSlot as l, mergeProps as K } from "vue"; import { ElInput as P } from "element-plus"; import I from "../collapseTransition/index.vue.js"; /* empty css */ import { useNamespace as R } from "../hooks/useNamespace.js"; const j = /* @__PURE__ */ $({ __name: "index", props: { modelValue: {}, classNames: { default: void 0 }, placeholder: { default: "" }, disabled: { type: Boolean, default: !1 }, loading: { type: Boolean, default: !1 }, readOnly: { type: Boolean }, rootClassName: { default: "" }, submitType: { type: [String, Boolean], default: "enter" }, autoSize: {} }, emits: ["update:modelValue", "submit", "change", "keyPress"], setup(k, { expose: v, emit: N }) { const n = k, r = N, u = z(), a = R("sender"), f = B(); function V(e) { r("change", e); } function C(e) { V(e); } function c() { n.modelValue && !n.loading && r("submit"); } function S(e) { const o = e.key === "Enter"; switch (n.submitType) { case "enter": { o && !e.shiftKey && (e.preventDefault(), c()); break; } case "shiftEnter": { o && e.shiftKey && (e.preventDefault(), c()); break; } } r("keyPress", e); } return v({ inputRef: f }), (e, o) => { var y, b; return d(), i("div", { class: t([s(a).b(), e.disabled && s(a).b("disabled"), e.rootClassName]) }, [ h(I, null, { default: w(() => [ l(e.$slots, "header") ]), _: 3 }), E("div", { class: t(s(a).b("content")) }, [ u.prefix ? (d(), i("div", { key: 0, class: t([s(a).b("prefix"), (y = e.classNames) == null ? void 0 : y.prefix]) }, [ l(e.$slots, "prefix") ], 2)) : p("", !0), l(e.$slots, "components", {}, () => { var g; return [ h(s(P), K({ ref_key: "inputRef", ref: f, autosize: e.autoSize || { maxRows: 8 }, class: [s(a).b("input"), (g = e.classNames) == null ? void 0 : g.input], disabled: e.disabled, "model-value": e.modelValue, readonly: e.readOnly, placeholder: n.placeholder, resize: "none", type: "textarea" }, e.$attrs, { onChange: C, onKeydown: o[0] || (o[0] = (m) => S(m)), "onUpdate:modelValue": o[1] || (o[1] = (m) => r("update:modelValue", m)) }), null, 16, ["autosize", "class", "disabled", "model-value", "readonly", "placeholder"]) ]; }), u.actions ? (d(), i("div", { key: 1, class: t([s(a).b("actions-list"), (b = e.classNames) == null ? void 0 : b.actions]) }, [ l(e.$slots, "actions") ], 2)) : p("", !0) ], 2), u.footer ? (d(), i("div", { key: 0, class: t(s(a).b("footer")) }, [ l(e.$slots, "footer") ], 2)) : p("", !0) ], 2); }; } }); export { j as default };