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