UNPKG

ant-design-x-vue-next

Version:

Ant Design X for Vue — community continuation aligned with @ant-design/x

87 lines (86 loc) 2.52 kB
import { defineComponent as _, computed as i, createVNode as c, mergeProps as $ } from "vue"; import { Dropdown as h } from "ant-design-vue"; import { E, b as C } from "../chunks/module-chunk.mjs"; import "../x-provider/index.mjs"; import { useActionsContextInject as X } from "./context.mjs"; import { getItemChildren as g } from "./getItemChildren.mjs"; import j from "../x-provider/hooks/use-x-provider-context.mjs"; const G = /* @__PURE__ */ _({ name: "AXActionMenu", __name: "ActionMenu", props: { item: null, prefixCls: null, dropdownProps: null }, emits: ["click"], setup(y, { emit: w }) { const o = y, x = w, a = (t, n) => { const r = t[0]; for (const e of n) if (e.key === r) { if (t.length === 1) return e; const s = g(e); if (s != null && s.length) return a(t.slice(1), s); } return null; }, { getPrefixCls: k } = j(), l = k("actions", o.prefixCls), m = X(), N = i(() => { var t; return ((t = o.item) == null ? void 0 : t.icon) ?? c(E, null, null); }), u = i(() => g(o.item) || []), A = i(() => o.item.triggerSubMenuAction || "hover"), D = i(() => o.dropdownProps || {}), P = i(() => ({ items: u.value, onClick: ({ key: t, keyPath: n, domEvent: r }) => { const e = a(n, u.value); if (e != null && e.onItemClick) { e.onItemClick(e); return; } x("click", { key: t, keyPath: [...n, o.item.key], domEvent: r, item: e }); } })); return () => { var p, d, f, v; const { overlayClassName: t, overlayStyle: n, arrow: r, trigger: e, ...s } = D.value, S = (p = m.value.classNames) == null ? void 0 : p.item, b = (d = m.value.styles) == null ? void 0 : d.item, I = (f = m.value.classNames) == null ? void 0 : f.itemDropdown, M = (v = m.value.styles) == null ? void 0 : v.itemDropdown; return c(h, $(s, { menu: P.value, overlayClassName: C(`${l}-sub-item`, `${l}-dropdown`, I, t), overlayStyle: { ...M, ...n }, arrow: r ?? !0, trigger: e ?? [A.value] }), { default: () => [c("div", { class: C(`${l}-list-item`, S), style: b }, [c("div", { class: `${l}-list-item-icon` }, [N.value])])] }); }; } }); export { G as default };