UNPKG

mealcomes

Version:

MealComes 用于学习前端的组件库

171 lines (170 loc) 3.95 kB
import { c as C, w as P } from "./utils-aznwSRCL.mjs"; import { defineComponent as S, ref as k, createElementBlock as i, openBlock as n, normalizeClass as T, unref as o, createBlock as t, createCommentVNode as r, Fragment as g, renderSlot as l, withCtx as d, resolveDynamicComponent as u, nextTick as E } from "vue"; import { L as v } from "./internal-icon-BfdBrYGj.mjs"; import { M as f } from "./icon-B8YaO9re.mjs"; import { _ as z } from "./_util-DbCYqsOr.mjs"; const I = { /** * 按钮大小 */ size: { type: String }, /** * 按钮类型 */ type: { type: String, validator: (s) => [ "primary", "success", "warning", "danger", "info", "default", "" ].includes(s) }, /** * 圆角按钮 */ round: { type: Boolean, default: !1 }, /** * 是否加载中 */ loading: { type: Boolean, default: !1 }, /** * 是否禁用 */ disabled: { type: Boolean, default: !1 }, /** * 原始类型 */ nativeType: { type: String, default: "button" }, /** * 图标位置 */ iconPlacement: { type: String, default: "left" }, /** * 圆形按钮 */ circle: { type: Boolean, default: !1 }, /** * 朴素按钮 */ plain: { type: Boolean, default: !1 } }, D = { /** * 点击事件 */ click: (s) => s instanceof MouseEvent, /** * 鼠标按下事件 */ mousedown: (s) => s instanceof MouseEvent }, L = ["type", "disabled"], N = { key: 2 }, R = /* @__PURE__ */ S({ name: "mc-button", inheritAttrs: !1, __name: "button", props: I, emits: D, setup(s, { emit: b }) { const a = C("button"), $ = s, p = b, c = k(!1), y = k(); let m; function w() { m && clearTimeout(m); } function h() { w(), c.value = !0, E(() => { var e; (e = y.value) == null || e.wave(); }), m = setTimeout(() => { c.value = !1; }, 1e3); } function B(e) { $.loading || (h(), p("click", e)); } function M(e) { p("mousedown", e); } return (e, A) => (n(), i("button", { class: T([ o(a).b(), o(a).m(e.type), o(a).m(e.size), o(a).is("loading", e.loading), o(a).is("disabled", e.disabled), o(a).is("round", e.round), o(a).is("circle", e.circle), o(a).is("plain", e.plain) ]), type: e.nativeType, disabled: e.disabled || e.loading, onClick: B, onMousedown: M }, [ e.loading && e.iconPlacement === "left" ? (n(), i(g, { key: 0 }, [ e.$slots.loading ? l(e.$slots, "loading", { key: 0 }) : (n(), t(o(f), { key: 1 }, { default: d(() => [ (n(), t(u(o(v)))) ]), _: 1 })) ], 64)) : e.$slots.icon && e.iconPlacement === "left" ? (n(), t(o(f), { key: 1 }, { default: d(() => [ e.$slots.icon ? (n(), t(u(e.$slots.icon), { key: 0 })) : l(e.$slots, "icon", { key: 1 }) ]), _: 3 })) : r("", !0), e.$slots.default ? (n(), i("span", N, [ l(e.$slots, "default") ])) : r("", !0), e.loading && e.iconPlacement === "right" ? (n(), i(g, { key: 3 }, [ e.$slots.loading ? l(e.$slots, "loading", { key: 0 }) : (n(), t(o(f), { key: 1 }, { default: d(() => [ (n(), t(u(o(v)))) ]), _: 1 })) ], 64)) : e.$slots.icon && e.iconPlacement === "right" ? (n(), t(o(f), { key: 4 }, { default: d(() => [ e.$slots.icon ? (n(), t(u(e.$slots.icon), { key: 0 })) : l(e.$slots, "icon", { key: 1 }) ]), _: 3 })) : r("", !0), c.value ? (n(), t(z, { key: 5, ref_key: "waveRef", ref: y }, null, 512)) : r("", !0) ], 42, L)); } }), G = P(R); export { G as M, D as a, I as b }; //# sourceMappingURL=button-DLbtVcMl.mjs.map