UNPKG

@gits-id/button

Version:

GITS Button Component

122 lines (121 loc) 3.96 kB
import { defineComponent as B, computed as r, resolveComponent as x, openBlock as s, createBlock as f, resolveDynamicComponent as h, unref as t, mergeProps as I, withCtx as k, renderSlot as a, normalizeClass as u, createCommentVNode as d, createElementBlock as b } from "vue"; import g from "@gits-id/icon"; const T = B({ __name: "VBtn", props: { color: { default: "default" }, size: { default: "md" }, to: null, href: null, text: { type: Boolean }, outlined: { type: Boolean }, rounded: { type: Boolean }, disabled: { type: Boolean }, noRing: { type: Boolean }, tile: { type: Boolean }, block: { type: Boolean }, shadow: { type: Boolean }, icon: { type: Boolean }, loading: { type: Boolean }, loadingText: { default: "Loading..." }, newTab: { type: Boolean }, type: { default: "button" }, ring: { type: Boolean }, solid: { type: Boolean }, fab: { type: Boolean }, loadingIcon: { default: "gg:spinner" }, prefix: { type: Boolean }, prefixIcon: { default: "" }, prefixIconSize: { default: "sm" }, prefixIconClass: { default: "" }, suffix: { type: Boolean }, suffixIcon: { default: "" }, suffixIconSize: { default: "sm" }, suffixIconClass: { default: "" }, loadingClass: { default: "animate-spin" }, flush: { type: Boolean } }, setup(n) { const e = n, l = r(() => e.to ? x("router-link") : e.href ? "a" : "button"), i = r(() => `focus:ring focus:ring-offset-2 focus:outline-none ${{ default: "", primary: "focus:ring-primary-500", secondary: "focus:ring-secondary-500", info: "focus:ring-info-500", warning: "focus:ring-warning-500", success: "focus:ring-success-500", error: "focus:ring-error-500", dark: "focus:ring-gray-500" }[e.color]}`), c = r(() => [ "btn", `btn-${e.color}`, `btn--${e.size}`, { [i.value]: !e.noRing, "btn--rounded": e.rounded, "btn--outlined": e.outlined, "btn--fab": e.fab, "btn--tile": e.tile, "btn--block": e.block, "btn--loading": e.loading, "btn--text": e.text, "btn--flush": e.flush, shadow: e.shadow } ]), m = r(() => { let o = { type: e.type, "aria-label": "Button" }; return e.disabled && (o["aria-disabled"] = !0, o.disabled = !0), e.to && (o.to = e.to), e.href && (o.href = e.href), e.newTab && (o.rel = "noopener", o.target = "_blank"), o; }); return (o, p) => (s(), f(h(t(l)), I({ class: t(c) }, { ...t(m), ...o.$attrs }), { default: k(() => [ a(o.$slots, "prefix", {}, () => [ n.prefixIcon || n.loading ? (s(), f(t(g), { key: 0, name: n.loading ? n.loadingIcon : n.prefixIcon, class: u([ "btn-icon", n.prefixIconClass, n.loading ? n.loadingClass : void 0 ]), size: n.prefixIconSize }, null, 8, ["name", "class", "size"])) : d("", !0) ]), a(o.$slots, "default"), a(o.$slots, "suffix", {}, () => [ n.suffixIcon ? (s(), f(t(g), { key: 0, name: n.suffixIcon, size: n.suffixIconSize, class: u(["btn-icon", n.suffixIconClass]) }, null, 8, ["name", "size", "class"])) : d("", !0) ]) ]), _: 3 }, 16, ["class"])); } }), y = (n, e) => { const l = n.__vccOpts || n; for (const [i, c] of e) l[i] = c; return l; }, C = {}, $ = { class: "v-btn-group" }; function v(n, e) { return s(), b("div", $, [ a(n.$slots, "default") ]); } const R = /* @__PURE__ */ y(C, [["render", v]]), z = {}, w = { class: "v-btn-toolbar" }; function V(n, e) { return s(), b("div", w, [ a(n.$slots, "default") ]); } const D = /* @__PURE__ */ y(z, [["render", V]]); export { T as VBtn, R as VBtnGroup, D as VBtnToolbar, T as default };