UNPKG

dm-vue3-ui

Version:

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

2 lines (1 loc) 3.45 kB
"use strict";const e=require("vue"),t=require("../utils"),o=require("../utils/theme"),l=t=>(e.pushScopeId("data-v-f3049a46"),t=t(),e.popScopeId(),t),a={key:0,class:"btn-loading"},n={key:0,class:"m-static-circle"},c=[l((()=>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)))],i={key:1,class:"m-dynamic-circle"},d=[l((()=>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)))],r={key:1,class:"btn-icon"},s={key:2,class:"btn-content"},u="#1677ff",m=((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(l,{emit:m}){const f=l,p=e.ref(!1),v=m,h=t.useSlotsExist(["icon","default"]),y=e.computed((()=>h.icon||f.icon)),k=e.computed((()=>y.value&&!h.default)),b=t.store("platformConfig")||{},g=(null==b?void 0:b.themeColor)||"default";function B(t){f.disabled||f.loading||(p.value?(p.value=!1,e.nextTick((()=>{p.value=!0}))):p.value=!0,v("click",t))}function C(){p.value=!1}return o.themeManager.initializeTheme(),o.themeManager.applyThemeByType(g),e.computed((()=>{switch(f.type){case"primary":default:return u;case"danger":return"#ff4d4f"}})),(t,o)=>(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":k.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:o[0]||(o[0]=e=>B(e)),onKeydown:o[1]||(o[1]=e.withKeys(e.withModifiers((e=>t.keyboard?void B(e):void 0),["prevent"]),["enter"]))},{default:e.withCtx((()=>[t.loading||!y.value?(e.openBlock(),e.createElementBlock("div",a,[t.href||"static"!==t.loadingType?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",n,c)),t.href||"dynamic"!==t.loadingType?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",i,d))])):e.createCommentVNode("",!0),!t.loading&&y.value?(e.openBlock(),e.createElementBlock("span",r,[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(h).default?(e.openBlock(),e.createElementBlock("span",s,[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":p.value}]),onAnimationend:C},null,34))])),_:3},40,["class","href","target"]))}}),[["__scopeId","data-v-f3049a46"]]);module.exports=m;