UNPKG

tdesign-pro-component

Version:

ProComponents tdesign-vue-next + Vue3 + TS

114 lines (113 loc) 3 kB
import { g as i, w as V } from "./utils-DU1amZow.js"; import { defineComponent as S, useSlots as w, openBlock as k, createBlock as P, createVNode as l, Fragment as H, resolveComponent as s, mergeProps as u } from "vue"; import { u as O } from "./hooks-9GWkbKry.js"; const R = /* @__PURE__ */ S({ name: "ProButton", __name: "ProBotton", props: { theme: { default: "button" }, action: { default: "dialog" }, visible: { type: Boolean, default: !1 }, content: {}, title: {}, dialogProps: {}, popupProps: {}, confirmBtn: {}, cancelBtn: {}, buttonProps: {}, linkProps: {}, colorTheme: { default: "primary" }, linkHover: { default: "color" }, size: {} }, emits: ["click", "open", "close", "confirm", "cancel", "update:visible"], setup(b, { expose: g, emit: x }) { const e = b, n = w(), c = x, t = O(e, "visible", c, e.visible), f = i(n, e, "content"), I = i(n, e, "title"), a = i(n, e, "confirmBtn"), r = i(n, e, "cancelBtn"), _ = i(n, e, "suffixIcon"), p = i(n, e, "icon"); function m() { c("click"), t.value = !0; } const d = () => e.theme !== "link" ? l(s("t-button"), u({ theme: e.colorTheme, icon: () => p }, e.buttonProps, { onClick: m }), { default: () => n.default ? n.default() : "高级按钮", icon: n.icon ? n.icon : null }) : l(s("t-link"), u({ hover: e.linkHover, onClick: m, prefixIcon: () => p, suffixIcon: () => _, theme: e.colorTheme }, e.linkProps), { default: () => n.default ? n.default() : "高级连接", prefixIcon: n.icon ? n.icon : null, suffixIcon: n.suffixIcon ? n.suffixIcon : null }); function B(o) { t.value = !1, c("close", o); } function h() { t.value = !1, c("cancel"); } function C() { c("confirm"); } const y = () => l(H, null, [l(d, null, null), l(s("t-dialog"), u({ confirmBtn: a, cancelBtn: r, onOpened: () => v(!0), onConfirm: C, onCancel: h, onClose: (o) => B(o), visible: t.value }, e.dialogProps), { default: () => f, header: () => I, confirmBtn: n.confirmBtn ? () => a : null, cancelBtn: n.cancelBtn ? () => r : null })]); function v(o) { o ? c("open") : B(o); } const T = () => l(s("t-popconfirm"), u({ confirmBtn: a, cancelBtn: r, onVisibleChange: (o) => v(o), onConfirm: C, onCancel: h, "onUpdate:visible": t.value }, e.popupProps), { content: () => f, default: () => l(d, null, null), confirmBtn: n.confirmBtn ? () => a : null, cancelBtn: n.cancelBtn ? () => r : null }); return g({ open: () => t.value = !0, close: () => t.value = !1 }), (o, z) => e.action !== "popup" ? (k(), P(y, { key: 0 })) : (k(), P(T, { key: 1 })); } }), M = V(R); export { M as P };