2 lines
4.8 KiB
JavaScript
2 lines
4.8 KiB
JavaScript
import{s as g,O as A,bq as q,r as K,a$ as U,cf as j,p as H,bH as L,L as z,bP as M,q as N,a as _,o as m,e as h,F as O,x as S,c as B,w as V,A as w,y as C,u as e,E as I,k as E,z as Q,B as G,v as R,D as J,b0 as T,C as W,Q as X}from"./entry.539d3b49.js";import{u as Y,T as Z}from"./index.e7365e3c.js";import{b as oo,a as eo,u as F}from"./use-form-item.aa386fad.js";const P=Symbol("buttonGroupContextKey"),to=(t,r)=>{Y({from:"type.text",replacement:"link",version:"3.0.0",scope:"props",ref:"https://element-plus.org/en-US/component/button.html#button-attributes"},g(()=>t.type==="text"));const n=A(P,void 0),a=q("button"),{form:l}=oo(),o=eo(g(()=>n==null?void 0:n.size)),c=F(),f=K(),d=U(),u=g(()=>t.type||(n==null?void 0:n.type)||""),k=g(()=>{var i,b,v;return(v=(b=t.autoInsertSpace)!=null?b:(i=a.value)==null?void 0:i.autoInsertSpace)!=null?v:!1}),y=g(()=>{var i;const b=(i=d.default)==null?void 0:i.call(d);if(k.value&&(b==null?void 0:b.length)===1){const v=b[0];if((v==null?void 0:v.type)===j){const D=v.children;return/^\p{Unified_Ideograph}{2}$/u.test(D.trim())}}return!1});return{_disabled:c,_size:o,_type:u,_ref:f,shouldAddSpace:y,handleClick:i=>{t.nativeType==="reset"&&(l==null||l.resetFields()),r("click",i)}}},so=["default","primary","success","warning","info","danger","text",""],no=["button","submit","reset"],$=H({size:L,disabled:Boolean,type:{type:String,values:so,default:""},icon:{type:z},nativeType:{type:String,values:no,default:"button"},loading:Boolean,loadingIcon:{type:z,default:()=>M},plain:Boolean,text:Boolean,link:Boolean,bg:Boolean,autofocus:Boolean,round:Boolean,circle:Boolean,color:String,dark:Boolean,autoInsertSpace:{type:Boolean,default:void 0}}),ao={click:t=>t instanceof MouseEvent};function p(t,r=20){return t.mix("#141414",r).toString()}function lo(t){const r=F(),n=N("button");return g(()=>{let a={};const l=t.color;if(l){const o=new Z(l),c=t.dark?o.tint(20).toString():p(o,20);if(t.plain)a=n.cssVarBlock({"bg-color":t.dark?p(o,90):o.tint(90).toString(),"text-color":l,"border-color":t.dark?p(o,50):o.tint(50).toString(),"hover-text-color":`var(${n.cssVarName("color-white")})`,"hover-bg-color":l,"hover-border-color":l,"active-bg-color":c,"active-text-color":`var(${n.cssVarName("color-white")})`,"active-border-color":c}),r.value&&(a[n.cssVarBlockName("disabled-bg-color")]=t.dark?p(o,90):o.tint(90).toString(),a[n.cssVarBlockName("disabled-text-color")]=t.dark?p(o,50):o.tint(50).toString(),a[n.cssVarBlockName("disabled-border-color")]=t.dark?p(o,80):o.tint(80).toString());else{const f=t.dark?p(o,30):o.tint(30).toString(),d=o.isDark()?`var(${n.cssVarName("color-white")})`:`var(${n.cssVarName("color-black")})`;if(a=n.cssVarBlock({"bg-color":l,"text-color":d,"border-color":l,"hover-bg-color":f,"hover-text-color":d,"hover-border-color":f,"active-bg-color":c,"active-border-color":c}),r.value){const u=t.dark?p(o,50):o.tint(50).toString();a[n.cssVarBlockName("disabled-bg-color")]=u,a[n.cssVarBlockName("disabled-text-color")]=t.dark?"rgba(255, 255, 255, 0.5)":`var(${n.cssVarName("color-white")})`,a[n.cssVarBlockName("disabled-border-color")]=u}}}return a})}const ro=["aria-disabled","disabled","autofocus","type"],io=_({name:"ElButton"}),co=_({...io,props:$,emits:ao,setup(t,{expose:r,emit:n}){const a=t,l=lo(a),o=N("button"),{_ref:c,_size:f,_type:d,_disabled:u,shouldAddSpace:k,handleClick:y}=to(a,n);return r({ref:c,size:f,type:d,disabled:u,shouldAddSpace:k}),(s,i)=>(m(),h("button",{ref_key:"_ref",ref:c,class:C([e(o).b(),e(o).m(e(d)),e(o).m(e(f)),e(o).is("disabled",e(u)),e(o).is("loading",s.loading),e(o).is("plain",s.plain),e(o).is("round",s.round),e(o).is("circle",s.circle),e(o).is("text",s.text),e(o).is("link",s.link),e(o).is("has-bg",s.bg)]),"aria-disabled":e(u)||s.loading,disabled:e(u)||s.loading,autofocus:s.autofocus,type:s.nativeType,style:Q(e(l)),onClick:i[0]||(i[0]=(...b)=>e(y)&&e(y)(...b))},[s.loading?(m(),h(O,{key:0},[s.$slots.loading?S(s.$slots,"loading",{key:0}):(m(),B(e(I),{key:1,class:C(e(o).is("loading"))},{default:V(()=>[(m(),B(w(s.loadingIcon)))]),_:1},8,["class"]))],64)):s.icon||s.$slots.icon?(m(),B(e(I),{key:1},{default:V(()=>[s.icon?(m(),B(w(s.icon),{key:0})):S(s.$slots,"icon",{key:1})]),_:3})):E("v-if",!0),s.$slots.default?(m(),h("span",{key:2,class:C({[e(o).em("text","expand")]:e(k)})},[S(s.$slots,"default")],2)):E("v-if",!0)],14,ro))}});var uo=G(co,[["__file","/home/runner/work/element-plus/element-plus/packages/components/button/src/button.vue"]]);const bo={size:$.size,type:$.type},po=_({name:"ElButtonGroup"}),mo=_({...po,props:bo,setup(t){const r=t;R(P,J({size:T(r,"size"),type:T(r,"type")}));const n=N("button");return(a,l)=>(m(),h("div",{class:C(`${e(n).b("group")}`)},[S(a.$slots,"default")],2))}});var x=G(mo,[["__file","/home/runner/work/element-plus/element-plus/packages/components/button/src/button-group.vue"]]);const ko=W(uo,{ButtonGroup:x});X(x);export{ko as E};
|