UNPKG

dm-vue3-ui

Version:

This Components Library will help get you started developing in Vue 3.

2 lines (1 loc) 3.13 kB
"use strict";const e=require("vue"),t=require("../utils"),o={key:0,class:"btn-loading"},l={key:0,class:"m-static-circle"},a={key:1,class:"m-dynamic-circle"},n={key:1,class:"btn-icon"},c={key:2,class:"btn-content"},d=((e,t)=>{const o=e.__vccOpts||e;for(const[l,a]of t)o[l]=a;return o})(e.defineComponent({name:"dm-button",__name:"index",props:{type:{default:"default"},shape:{default:"default"},icon:{default:void 0},size:{default:"middle"},ghost:{type:Boolean,default:!1},customClass:{default:void 0},href:{default:void 0},target:{default:"_self"},keyboard:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},loadingType:{default:"dynamic"},block:{type:Boolean,default:!1}},emits:["click"],setup(d,{emit:i}){const s=d,r=e.ref(!1),u=i,m=t.useSlotsExist(["icon","default"]),f=e.computed((()=>m.icon||s.icon)),p=e.computed((()=>f.value&&!m.default));function k(t){r.value?(r.value=!1,e.nextTick((()=>{r.value=!0}))):r.value=!0,u("click",t)}function v(){r.value=!1}return(t,d)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.href?"a":"div"),{tabindex:"0",class:e.normalizeClass(["dm-button",[`btn-${t.type} btn-${t.size}`,{[`loading-${t.size}`]:!t.href&&t.loading,"btn-icon-only":p.value,"btn-circle":"circle"===t.shape,"btn-round":"round"===t.shape,"btn-loading-blur":!t.href&&t.loading,"btn-ghost":t.ghost,"btn-block":t.block,"btn-disabled":t.disabled},t.customClass]]),href:t.href,target:t.target,onClick:d[0]||(d[0]=e=>t.disabled||t.loading?()=>!1:k(e)),onKeydown:d[1]||(d[1]=e.withKeys(e.withModifiers((e=>!t.keyboard||t.disabled||t.loading?()=>!1:void k(e)),["prevent"]),["enter"]))},{default:e.withCtx((()=>[t.loading||!f.value?(e.openBlock(),e.createElementBlock("div",o,[t.href||"static"!==t.loadingType?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",l,d[2]||(d[2]=[e.createElementVNode("svg",{class:"circle",width:"1em",height:"1em",fill:"currentColor",viewBox:"0 0 100 100"},[e.createElementVNode("path",{d:"M 50,50 m 0,-45 a 45,45 0 1 1 0,90 a 45,45 0 1 1 0,-90","stroke-linecap":"round",class:"path","fill-opacity":"0"})],-1)]))),t.href||"dynamic"!==t.loadingType?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",a,d[3]||(d[3]=[e.createElementVNode("svg",{class:"circle",viewBox:"0 0 50 50",width:"1em",height:"1em",fill:"currentColor"},[e.createElementVNode("circle",{class:"path",cx:"25",cy:"25",r:"20",fill:"none"})],-1)])))])):e.createCommentVNode("",!0),!t.loading&&f.value?(e.openBlock(),e.createElementBlock("span",n,[e.renderSlot(t.$slots,"icon",{},(()=>[t.icon?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.icon),{key:0})):e.createCommentVNode("",!0)]),!0)])):e.createCommentVNode("",!0),e.unref(m).default?(e.openBlock(),e.createElementBlock("span",c,[e.renderSlot(t.$slots,"default",{},void 0,!0)])):e.createCommentVNode("",!0),t.disabled?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",{key:3,class:e.normalizeClass(["button-wave",{"wave-active":r.value}]),onAnimationend:v},null,34))])),_:3},40,["class","href","target"]))}}),[["__scopeId","data-v-bdc2e67b"]]);module.exports=d;