UNPKG

@aplus-frontend/ui

Version:

62 lines (61 loc) 2.35 kB
import { defineComponent as C, useSlots as B, createPropsRestProxy as A, ref as F, computed as d, unref as l, renderSlot as y, createElementBlock as u, createCommentVNode as a, openBlock as n, mergeProps as h, createBlock as f, normalizeClass as L, resolveDynamicComponent as g, isVNode as N, toDisplayString as P } from "vue"; import "../../config-provider/index.mjs"; import S from "@aplus-frontend/antdv/es/button/LoadingIcon"; import { useNamespace as $ } from "../../config-provider/hooks/use-namespace.mjs"; const D = { key: 1 }, E = /* @__PURE__ */ C({ 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 } }, setup(o) { const s = B(), r = A(o, ["color", "disabled", "visible", "loading", "iconFirst", "icon"]), { b: k, m: t, e: b } = $("action-item"), c = F(!1), m = d(() => o.iconFirst && (o.icon || s.icon)); function p(e) { l(i) || o.disabled || (r.onClick?.(e), r.onAction && (c.value = !0, r.onAction(e).finally(() => c.value = !1))); } const i = d(() => o.loading || l(c)), v = d(() => [ k(), t(o.color), m.value ? t("icon-first") : null, o.disabled ? t("disabled") : null, i.value ? t("loading") : null ].filter(Boolean)); return (e, I) => y(e.$slots, "trigger", { loading: i.value, disabled: e.disabled, onClick: p }, () => [ e.visible ? (n(), u("span", h({ key: 0 }, e.$attrs, { class: v.value, onClick: p }), [ i.value ? (n(), f(l(S), { key: 0, "prefix-cls": "btn", "exist-icon": !1, loading: "" })) : a("", !0), e.icon || s.icon ? (n(), u("span", { key: 1, class: L(l(b)("icon-wrapper")) }, [ (n(), f(g(e.icon || s.icon))) ], 2)) : a("", !0), m.value ? a("", !0) : y(e.$slots, "default", { key: 2 }, () => [ N(e.text) ? (n(), f(g(e.text), { key: 0 })) : (n(), u("span", D, P(e.text || ""), 1)) ]) ], 16)) : a("", !0) ]); } }); export { E as default };