@aplus-frontend/ui
Version:
74 lines (73 loc) • 2.82 kB
JavaScript
import { defineComponent as A, useSlots as F, createPropsRestProxy as N, ref as S, computed as d, unref as t, renderSlot as y, createElementBlock as u, createCommentVNode as f, openBlock as l, mergeProps as g, createVNode as v, normalizeClass as V, withCtx as I, createElementVNode as L, createBlock as k, resolveDynamicComponent as b, isVNode as P, toDisplayString as $ } from "vue";
import { Tooltip as w } from "@aplus-frontend/antdv";
import x from "@aplus-frontend/antdv/es/button/LoadingIcon";
import "../../config-provider/index.mjs";
import D from "../style/index.mjs";
import { useNamespace as E } from "../../config-provider/hooks/use-namespace.mjs";
const T = { key: 1 }, K = /* @__PURE__ */ A({
name: "ApActionItem",
__name: "index",
props: {
text: {},
color: { default: "primary" },
disabled: { type: Boolean, default: !1 },
visible: { type: Boolean, default: !0 },
onAction: { type: Function },
onClick: { type: Function },
loading: { type: Boolean, default: !1 },
icon: {},
iconFirst: { type: Boolean, default: !1 },
tooltip: { default: () => ({}) }
},
setup(o) {
const a = F(), s = N(o, ["color", "disabled", "visible", "loading", "iconFirst", "icon", "tooltip"]), { b: m, m: n, e: C } = E("action-item"), r = S(!1), c = d(() => o.iconFirst && !!(o.icon || a.icon)), B = D("action-item");
function p(e) {
t(i) || o.disabled || (s.onClick?.(e), s.onAction && (r.value = !0, s.onAction(e).finally(() => r.value = !1)));
}
const i = d(() => o.loading || t(r)), h = d(() => [
B.value,
m(),
n(o.color),
c.value ? n("icon-first") : null,
o.disabled ? n("disabled") : null,
i.value ? n("loading") : null
].filter(Boolean));
return (e, z) => y(e.$slots, "trigger", {
loading: i.value,
disabled: e.disabled,
onClick: p
}, () => [
e.visible ? (l(), u("span", g({ key: 0 }, e.$attrs, {
class: h.value,
onClick: p
}), [
v(t(x), {
"prefix-cls": t(m)(),
"exist-icon": !1,
loading: i.value
}, null, 8, ["prefix-cls", "loading"]),
e.icon || a.icon ? (l(), u("span", {
key: 0,
class: V(t(C)("icon-wrapper"))
}, [
v(t(w), g({
title: c.value ? e.text : null
}, e.tooltip), {
default: I(() => [
L("span", null, [
(l(), k(b(e.icon || a.icon)))
])
]),
_: 1
}, 16, ["title"])
], 2)) : f("", !0),
c.value ? f("", !0) : y(e.$slots, "default", { key: 1 }, () => [
P(e.text) ? (l(), k(b(e.text), { key: 0 })) : (l(), u("span", T, $(e.text || ""), 1))
])
], 16)) : f("", !0)
]);
}
});
export {
K as default
};