UNPKG

@matechat/core

Version:

前端智能化场景解决方案UI库,轻松构建你的AI应用。

158 lines (157 loc) 4.21 kB
import "./index.css"; import { defineComponent as a, computed as v, resolveDynamicComponent as P, openBlock as n, createElementBlock as s, createBlock as C, unref as z, normalizeStyle as y, normalizeClass as b, createElementVNode as S, normalizeProps as I, mergeProps as $, createCommentVNode as l, toDisplayString as h, createVNode as k, withCtx as V } from "vue"; import { ListVariant as N, ListDirection as B, McList as D } from "@matechat/core/List"; const L = { name: { type: String, default: "" }, size: { type: [Number, String], default: "inherit" }, color: { type: String, default: "inherit" }, component: { type: Object, default: null } }, M = { class: "mc-prompt-icon" }, O = ["src", "alt"], j = /* @__PURE__ */ a({ __name: "Icon", props: L, setup(r) { const t = r, i = v(() => typeof t.size == "number" ? `${t.size}px` : t.size), o = v(() => /^icon-/.test(t.name) ? t.name : ""), p = t.component && P(t.component); function c(e) { return /^((http|https):)?\/\//.test(e); } return (e, m) => (n(), s("div", M, [ e.component ? (n(), C(z(p), { key: 0, name: e.name, color: e.color, size: i.value }, null, 8, ["name", "color", "size"])) : c(t.name) ? (n(), s("img", { key: 1, src: e.name, alt: t.name.split("/")[t.name.split("/").length - 1], style: y({ width: i.value || "", verticalAlign: "middle" }) }, null, 12, O)) : (n(), s( "i", { key: 2, class: b(o.value), style: y({ fontSize: i.value, color: e.color }) }, null, 6 /* CLASS, STYLE */ )) ])); } }), w = { direction: { type: String, default: B.Vertical }, list: { type: Array, default: () => [] }, variant: { type: String, default: N.Filled } }, A = { prompt: { type: Object } }, E = { class: "mc-prompt-item" }, F = { key: 0, class: "mc-prompt-item-content" }, U = { key: 0, class: "mc-prompt-item-label" }, q = { key: 1, class: "mc-prompt-item-description" }, G = /* @__PURE__ */ a({ __name: "PromptItem", props: A, setup(r) { return (t, i) => { var o, p, c, e, m, d, u, f, _; return n(), s("div", E, [ S( "div", { class: b(["mc-prompt-item-icon", { "no-description": !((o = t.prompt) != null && o.desc) }]) }, [ (p = t.prompt) != null && p.iconConfig ? (n(), C( j, I($({ key: 0 }, (c = t.prompt) == null ? void 0 : c.iconConfig)), null, 16 /* FULL_PROPS */ )) : l("v-if", !0) ], 2 /* CLASS */ ), (e = t.prompt) != null && e.label || (m = t.prompt) != null && m.desc ? (n(), s("div", F, [ (d = t.prompt) != null && d.label ? (n(), s( "div", U, h((u = t.prompt) == null ? void 0 : u.label), 1 /* TEXT */ )) : l("v-if", !0), (f = t.prompt) != null && f.desc ? (n(), s( "div", q, h((_ = t.prompt) == null ? void 0 : _.desc), 1 /* TEXT */ )) : l("v-if", !0) ])) : l("v-if", !0) ]); }; } }), H = (r, t) => { const i = r.__vccOpts || r; for (const [o, p] of t) i[o] = p; return i; }, J = /* @__PURE__ */ H(G, [["__scopeId", "data-v-f03be430"]]), K = { class: "mc-prompt" }, g = /* @__PURE__ */ a({ __name: "Prompt", props: w, emits: ["itemClick"], setup(r, { emit: t }) { const i = t, o = r; return (p, c) => (n(), s("div", K, [ k(z(D), { data: o.list, direction: o.direction, variant: o.variant, selectable: !1 }, { item: V(({ item: e }) => [ k(J, { prompt: e, onClick: (m) => i("itemClick", e) }, null, 8, ["prompt", "onClick"]) ]), _: 1 /* STABLE */ }, 8, ["data", "direction", "variant"]) ])); } }); g.install = (r) => { r.component("McPrompt", g); }; export { g as McPrompt };