@artmate/chat
Version:
**开箱即用的AI组件库(基于 Vue3 + ElementPlus)**
130 lines (129 loc) • 4.59 kB
JavaScript
import { defineComponent as P, useSlots as z, computed as B, resolveComponent as D, createElementBlock as o, openBlock as i, normalizeStyle as r, normalizeClass as a, unref as l, createCommentVNode as n, createElementVNode as p, renderSlot as m, createTextVNode as b, toDisplayString as u, Fragment as F, renderList as T, createVNode as j, withCtx as q, createBlock as w, resolveDynamicComponent as x } from "vue";
import { ElIcon as A } from "element-plus";
import { useNamespace as G } from "../hooks/useNamespace.js";
const H = ["onClick"], Q = /* @__PURE__ */ P({
name: "Prompts",
__name: "index",
props: {
title: {},
className: {},
rootClassName: {},
direction: {},
style: {},
classNames: {},
wrap: { type: Boolean },
vertical: { type: Boolean },
styles: {},
items: {},
onItemClick: {}
},
setup(L) {
const e = L, t = G("prompts"), d = z(), S = B(() => [
e.className,
e.rootClassName,
{
[t.b("rtl")]: e.direction === "rtl"
}
]), V = B(() => {
var c;
return [
t.b("list"),
(c = e.classNames) == null ? void 0 : c.list,
{ [t.b("list-wrap")]: e.wrap },
{ [t.b("list-vertical")]: e.vertical }
];
});
return (c, J) => {
var y;
const $ = D("Prompts");
return i(), o("div", {
class: a([l(t).b(), S.value]),
style: r({ ...e.style })
}, [
l(d).title || e.title ? (i(), o("h5", {
key: 0,
class: a([l(t).b("title")])
}, [
m(c.$slots, "title", {}, () => [
b(u(e.title), 1)
])
], 2)) : n("", !0),
p("div", {
class: a(V.value),
style: r({ ...(y = e.styles) == null ? void 0 : y.list })
}, [
(i(!0), o(F, null, T(e.items, (s, E) => {
var C, h, k, N, v, g, I, _;
return i(), o("div", {
key: E,
class: a([
l(t).b("item"),
(C = e.classNames) == null ? void 0 : C.item,
{
[l(t).b("item-disabled")]: s.disabled,
[l(t).b("item-has-nest")]: s.children && s.children.length > 0
}
]),
style: r({ ...(h = e.styles) == null ? void 0 : h.item }),
onClick: () => {
!(s.children && s.children.length > 0) && e.onItemClick && e.onItemClick({ data: s });
}
}, [
l(d).icon || s.icon ? (i(), o("div", {
key: 0,
class: a([l(t).b("icon")])
}, [
m(c.$slots, "icon", { info: s }, () => [
j(l(A), null, {
default: q(() => [
(i(), w(x(s.icon)))
]),
_: 2
}, 1024)
])
], 2)) : n("", !0),
p("div", {
class: a([l(t).b("content"), (k = e.classNames) == null ? void 0 : k.itemContent]),
style: r({ ...(N = e.styles) == null ? void 0 : N.itemContent })
}, [
l(d).label || s.label ? (i(), o("h6", {
key: 0,
class: a([l(t).b("label")])
}, [
m(c.$slots, "label", { info: s }, () => [
b(u(s.label), 1)
])
], 2)) : n("", !0),
p("p", {
class: a([l(t).b("desc")])
}, [
m(c.$slots, "description", { info: s }, () => [
b(u(s.description), 1)
])
], 2),
s.children && s.children.length > 0 ? (i(), w($, {
key: 1,
class: a([l(t).b("nested")]),
"class-names": {
list: (v = e.classNames) == null ? void 0 : v.subList,
item: (g = e.classNames) == null ? void 0 : g.subItem
},
items: s.children,
"on-item-click": c.onItemClick,
styles: {
list: (I = e.styles) == null ? void 0 : I.subList,
item: (_ = e.styles) == null ? void 0 : _.subItem
},
vertical: ""
}, null, 8, ["class", "class-names", "items", "on-item-click", "styles"])) : n("", !0)
], 6)
], 14, H);
}), 128))
], 6)
], 6);
};
}
});
export {
Q as default
};