ant-design-x-vue
Version:
Craft AI-driven interfaces effortlessly
101 lines (100 loc) • 2.46 kB
JavaScript
import { defineComponent as P, computed as i, createVNode as r, mergeProps as p, isVNode as $ } from "vue";
import { Tooltip as j } from "ant-design-vue";
import { b as c } from "../chunks/module-chunk.mjs";
import A from "../_util/pick-attrs.mjs";
import V from "../_util/hooks/use-x-component-config.mjs";
import "../x-provider/index.mjs";
import X from "./ActionMenu.mjs";
import O from "./style/index.mjs";
import T from "../x-provider/hooks/use-x-provider-context.mjs";
function w(s) {
return typeof s == "function" || Object.prototype.toString.call(s) === "[object Object]" && !$(s);
}
const J = /* @__PURE__ */ P({
name: "AXActions",
__name: "Actions",
props: {
items: {
default: () => []
},
rootClassName: {
default: ""
},
block: {
type: Boolean,
default: !1
},
onClick: {
type: Function
},
style: null,
variant: {
default: "borderless"
},
prefixCls: null
},
emits: ["click"],
setup(s, {
emit: f
}) {
const o = s, a = f, {
getPrefixCls: d,
direction: C
} = T(), l = d("actions", o.prefixCls), m = V("actions"), [k, y, v] = O(l), b = i(() => c(l, m.value.className, o.rootClassName, v, y.value, {
[`${l}-rtl`]: C.value === "rtl"
})), g = i(() => ({
...m.value.style,
...typeof o.style == "object" ? o.style : {}
})), x = (t, e, n) => e ? r(j, p(n, {
title: e
}), w(t) ? t : {
default: () => [t]
}) : t, h = (t, e, n) => {
if (e.onItemClick) {
e.onItemClick(e);
return;
}
a("click", {
key: t,
item: e,
keyPath: [t],
domEvent: n
});
}, S = (t) => {
a("click", t);
}, _ = (t) => {
const {
icon: e,
label: n,
key: u
} = t;
return r("div", {
class: c(`${l}-list-item`),
onClick: (I) => h(u, t, I),
key: u
}, [x(r("div", {
class: `${l}-list-item-icon`
}, [e]), n)]);
}, N = i(() => A(o, {
aria: !0,
data: !0
}));
return () => k(r("div", p({
class: b.value
}, N.value, {
style: g.value
}), [r("div", {
class: c(`${l}-list`, o.variant, {
block: o.block
})
}, [o.items.map((t) => "children" in t && t.children ? r(X, {
key: t.key,
item: t,
prefixCls: l,
onClick: S
}, null) : _(t))])]));
}
});
export {
J as default
};