ant-design-x-vue
Version:
Craft AI-driven interfaces effortlessly
68 lines (67 loc) • 1.74 kB
JavaScript
import { defineComponent as g, computed as o, createVNode as r } from "vue";
import { Dropdown as k } from "ant-design-vue";
import "../x-provider/index.mjs";
import x from "../x-provider/hooks/use-x-provider-context.mjs";
import { E as h } from "../chunks/module-chunk.mjs";
const E = /* @__PURE__ */ g({
name: "AXActionMenu",
__name: "ActionMenu",
props: {
item: null,
prefixCls: null
},
emits: ["click"],
setup(u, {
emit: p
}) {
const t = u, a = p, c = (i, n) => {
const s = i[0];
for (const e of n)
if (e.key === s) {
if (i.length === 1) return e;
if ("children" in e && e.children)
return c(i.slice(1), e.children);
}
return null;
}, {
getPrefixCls: f
} = x(), l = f("actions", t.prefixCls), d = o(() => {
var i;
return ((i = t.item) == null ? void 0 : i.icon) ?? r(h, null, null);
}), m = o(() => t.item.children || []), v = o(() => t.item.triggerSubMenuAction || "hover"), C = o(() => ({
items: m.value,
onClick: ({
key: i,
keyPath: n,
domEvent: s
}) => {
const e = c(n, m.value);
if (e != null && e.onItemClick) {
e.onItemClick(e);
return;
}
a("click", {
key: i,
keyPath: [...n, t.item.key],
domEvent: s,
item: e
});
}
}));
return () => r(k, {
menu: C.value,
overlayClassName: `${l}-sub-item`,
arrow: !0,
trigger: [v.value]
}, {
default: () => [r("div", {
class: `${l}-list-item`
}, [r("div", {
class: `${l}-list-item-icon`
}, [d.value])])]
});
}
});
export {
E as default
};