@artmate/chat
Version:
**开箱即用的AI组件库(基于 Vue3 + ElementPlus)**
93 lines (92 loc) • 2.81 kB
JavaScript
import { defineComponent as _, computed as h, createElementBlock as c, openBlock as o, normalizeClass as s, createElementVNode as p, unref as l, Fragment as u, renderList as B, createBlock as a, withCtx as d, renderSlot as k, createVNode as f, resolveDynamicComponent as C, createCommentVNode as E } from "vue";
import { ElIcon as b, ElTooltip as I } from "element-plus";
import { useNamespace as N } from "../hooks/useNamespace.js";
import $ from "./ActionMenu.vue.js";
/* empty css */
const V = ["onClick"], S = /* @__PURE__ */ _({
__name: "index",
props: {
items: {},
block: { type: Boolean },
variant: {},
trigger: { default: "hover" },
placement: { default: "top" }
},
emits: ["click"],
setup(w, { emit: g }) {
const m = g, i = N("actions"), v = h(() => [
i.b()
]);
function y(n, t) {
if (t.onItemClick) {
t.onItemClick(t);
return;
}
m("click", {
item: t,
key: n,
keyPath: [n]
});
}
return (n, t) => (o(), c("div", {
class: s(v.value)
}, [
p("div", {
class: s([l(i).b("list"), n.variant, n.block])
}, [
(o(!0), c(u, null, B(n.items, (e) => (o(), c(u, {
key: e.key
}, [
"children" in e ? (o(), a($, {
key: e.key,
item: e,
trigger: n.trigger,
onClick: t[0] || (t[0] = (r) => m("click", r))
}, {
icon: d(({ info: r }) => [
k(n.$slots, "icon", { info: r }, () => [
f(l(b), null, {
default: d(() => [
(o(), a(C(r.icon)))
]),
_: 2
}, 1024)
], !0)
]),
_: 2
}, 1032, ["item", "trigger"])) : (o(), c("div", {
key: 1,
class: s(l(i).b("list-item")),
onClick: (r) => y(e.key, e)
}, [
p("div", {
class: s(l(i).b("list-item-icon"))
}, [
k(n.$slots, "icon", { info: e }, () => [
e.icon ? (o(), a(l(I), {
key: 0,
content: e.label,
disabled: !e.label,
placement: n.placement
}, {
default: d(() => [
f(l(b), null, {
default: d(() => [
(o(), a(C(e.icon)))
]),
_: 2
}, 1024)
]),
_: 2
}, 1032, ["content", "disabled", "placement"])) : E("", !0)
], !0)
], 2)
], 10, V))
], 64))), 128))
], 2)
], 2));
}
});
export {
S as default
};