@element-plus-ui/pro-button
Version:
🏆 Use Element Plus Button like a Pro!
123 lines (122 loc) • 3.44 kB
JavaScript
import "element-plus/theme-chalk/index.css";
import { defineComponent as E, unref as n, openBlock as y, createBlock as g, mergeProps as a, isRef as S, withCtx as c, createVNode as V, withModifiers as B, renderSlot as k, createTextVNode as b, toDisplayString as v } from "vue";
import { WarningFilled as $ } from "@element-plus/icons-vue";
import { isObject as C } from "@vueuse/core";
import { ElPopconfirm as I, ElButton as T, ElMessageBox as M } from "element-plus";
import { ref as N, computed as P } from "vue-demi";
const R = /* @__PURE__ */ E({
__name: "Button",
props: {
size: {},
disabled: { type: Boolean },
type: {},
icon: {},
nativeType: {},
loading: { type: Boolean },
loadingIcon: {},
plain: { type: Boolean },
text: { type: Boolean },
link: { type: Boolean },
bg: { type: Boolean },
autofocus: { type: Boolean },
round: { type: Boolean },
circle: { type: Boolean },
color: {},
dark: { type: Boolean },
autoInsertSpace: { type: Boolean },
tag: {},
tip: {},
title: {}
},
emits: ["click"],
setup(x, { emit: w }) {
const l = w, e = x, p = N(!1), s = P(() => {
var t, o;
return typeof e.tip == "string" ? "message-box" : (o = (t = e.tip) == null ? void 0 : t.mode) != null ? o : "message-box";
}), f = () => {
var i, u, m, d;
if (!e.tip)
return l("click");
let t = !0, o = typeof e.tip == "string" ? e.tip : "";
if (C(e.tip)) {
const r = e.tip;
o = s.value === "popconfirm" ? r.title : r.message, t = (m = (u = (i = e.tip) == null ? void 0 : i.before) == null ? void 0 : u.call(i)) != null ? m : !0;
}
if (!o)
return l("click");
if (t === !0) {
if (s.value == "popconfirm") {
p.value = !0;
return;
}
const r = C(e.tip) ? e.tip : {};
M.confirm(o, (d = e.tip.title) != null ? d : "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
message: o,
...r
}).then(() => {
l("click");
});
}
};
return (t, o) => n(s) == "popconfirm" && t.tip.title ? (y(), g(n(I), a({ key: 0 }, t.tip, {
visible: n(p),
"onUpdate:visible": o[0] || (o[0] = (i) => S(p) ? p.value = i : null),
title: t.tip.title,
icon: n($),
trigger: "",
onConfirm: o[1] || (o[1] = (i) => l("click"))
}), {
reference: c(() => [
V(
n(T),
a(e, {
onClick: B(f, ["stop"])
}),
{
default: c(() => [
k(t.$slots, "default", {}, () => [
b(
v(t.title),
1
/* TEXT */
)
])
]),
_: 3
/* FORWARDED */
},
16
/* FULL_PROPS */
)
]),
_: 3
/* FORWARDED */
}, 16, ["visible", "title", "icon"])) : (y(), g(
n(T),
a({ key: 1 }, e, {
onClick: B(f, ["stop"])
}),
{
default: c(() => [
k(t.$slots, "default", {}, () => [
b(
v(t.title),
1
/* TEXT */
)
])
]),
_: 3
/* FORWARDED */
},
16
/* FULL_PROPS */
));
}
});
export {
R as default
};