1 line
12 KiB
JavaScript
1 line
12 KiB
JavaScript
import{n as e}from"./rolldown-runtime-hePW80VL.js";import{D as t,Ht as n,Ut as r,ct as i,d as a,g as o,gn as s,it as c,k as l,pt as u,tt as d,xn as f}from"./runtime-core.esm-bundler-DkysjgTd.js";import{t as p}from"./runtime-dom.esm-bundler-CirRHyjC.js";import{r as m}from"./en_US-Cv9hrLhb.js";import{F as h,K as g,Tt as _,c as v,l as y,p as b,rt as x,t as S,u as ee}from"./useConfigInject-z_xeO0pP.js";import{t as C}from"./initDefaultProps-D8Mki4gM.js";import{t as w}from"./vue-types-CFReUAWV.js";import{t as T}from"./devWarning-DlchpATv.js";import{t as E}from"./LoadingOutlined-tpSKTswf.js";import{t as D}from"./createContext-LBMERH-r.js";import{r as te}from"./Compact-Icyx2uFm.js";import{t as O}from"./compact-item-BbW5OmKl.js";import{t as ne}from"./wave-BBnUlIB_.js";function k(e){return e===`danger`?{danger:!0}:{type:e}}var A=()=>({prefixCls:String,type:String,htmlType:{type:String,default:`button`},shape:{type:String},size:{type:String},loading:{type:[Boolean,Object],default:()=>!1},disabled:{type:Boolean,default:void 0},ghost:{type:Boolean,default:void 0},block:{type:Boolean,default:void 0},danger:{type:Boolean,default:void 0},icon:w.any,href:String,target:String,title:String,onClick:g(),onMousedown:g()}),j=e=>{e&&(e.style.width=`0px`,e.style.opacity=`0`,e.style.transform=`scale(0)`)},M=e=>{d(()=>{e&&(e.style.width=`${e.scrollWidth}px`,e.style.opacity=`1`,e.style.transform=`scale(1)`)})},N=e=>{e&&e.style&&(e.style.width=null,e.style.opacity=null,e.style.transform=null)},re=l({compatConfig:{MODE:3},name:`LoadingIcon`,props:{prefixCls:String,loading:[Boolean,Object],existIcon:Boolean},setup(e){return()=>{let{existIcon:n,prefixCls:r,loading:i}=e;if(n)return t(`span`,{class:`${r}-loading-icon`},[t(E,null,null)]);let a=!!i;return t(p,{name:`${r}-loading-icon-motion`,onBeforeEnter:j,onEnter:M,onAfterEnter:N,onBeforeLeave:M,onLeave:e=>{setTimeout(()=>{j(e)})},onAfterLeave:N},{default:()=>[a?t(`span`,{class:`${r}-loading-icon`},[t(E,null,null)]):null]})}}}),P=(e,t)=>({[`> span, > ${e}`]:{"&:not(:last-child)":{[`&, & > ${e}`]:{"&:not(:disabled)":{borderInlineEndColor:t}}},"&:not(:first-child)":{[`&, & > ${e}`]:{"&:not(:disabled)":{borderInlineStartColor:t}}}}}),F=e=>{let{componentCls:t,fontSize:n,lineWidth:r,colorPrimaryHover:i,colorErrorHover:a}=e;return{[`${t}-group`]:[{position:`relative`,display:`inline-flex`,[`> span, > ${t}`]:{"&:not(:last-child)":{[`&, & > ${t}`]:{borderStartEndRadius:0,borderEndEndRadius:0}},"&:not(:first-child)":{marginInlineStart:-r,[`&, & > ${t}`]:{borderStartStartRadius:0,borderEndStartRadius:0}}},[t]:{position:`relative`,zIndex:1,"&:hover,\n &:focus,\n &:active":{zIndex:2},"&[disabled]":{zIndex:0}},[`${t}-icon-only`]:{fontSize:n}},P(`${t}-primary`,i),P(`${t}-danger`,a)]}};function I(e,t){return{[`&-item:not(${t}-last-item)`]:{marginBottom:-e.lineWidth},"&-item":{"&:hover,&:focus,&:active":{zIndex:2},"&[disabled]":{zIndex:0}}}}function L(e,t){return{[`&-item:not(${t}-first-item):not(${t}-last-item)`]:{borderRadius:0},[`&-item${t}-first-item:not(${t}-last-item)`]:{[`&, &${e}-sm, &${e}-lg`]:{borderEndEndRadius:0,borderEndStartRadius:0}},[`&-item${t}-last-item:not(${t}-first-item)`]:{[`&, &${e}-sm, &${e}-lg`]:{borderStartStartRadius:0,borderStartEndRadius:0}}}}function R(e){let t=`${e.componentCls}-compact-vertical`;return{[t]:m(m({},I(e,t)),L(e.componentCls,t))}}var z=e=>{let{componentCls:t,iconCls:n}=e;return{[t]:{outline:`none`,position:`relative`,display:`inline-block`,fontWeight:400,whiteSpace:`nowrap`,textAlign:`center`,backgroundImage:`none`,backgroundColor:`transparent`,border:`${e.lineWidth}px ${e.lineType} transparent`,cursor:`pointer`,transition:`all ${e.motionDurationMid} ${e.motionEaseInOut}`,userSelect:`none`,touchAction:`manipulation`,lineHeight:e.lineHeight,color:e.colorText,"> span":{display:`inline-block`},[`> ${n} + span, > span + ${n}`]:{marginInlineStart:e.marginXS},"> a":{color:`currentColor`},"&:not(:disabled)":m({},b(e)),[`&-icon-only${t}-compact-item`]:{flex:`none`},[`&-compact-item${t}-primary`]:{[`&:not([disabled]) + ${t}-compact-item${t}-primary:not([disabled])`]:{position:`relative`,"&:before":{position:`absolute`,top:-e.lineWidth,insetInlineStart:-e.lineWidth,display:`inline-block`,width:e.lineWidth,height:`calc(100% + ${e.lineWidth*2}px)`,backgroundColor:e.colorPrimaryHover,content:`""`}}},"&-compact-vertical-item":{[`&${t}-primary`]:{[`&:not([disabled]) + ${t}-compact-vertical-item${t}-primary:not([disabled])`]:{position:`relative`,"&:before":{position:`absolute`,top:-e.lineWidth,insetInlineStart:-e.lineWidth,display:`inline-block`,width:`calc(100% + ${e.lineWidth*2}px)`,height:e.lineWidth,backgroundColor:e.colorPrimaryHover,content:`""`}}}}}}},B=(e,t)=>({"&:not(:disabled)":{"&:hover":e,"&:active":t}}),V=e=>({minWidth:e.controlHeight,paddingInlineStart:0,paddingInlineEnd:0,borderRadius:`50%`}),H=e=>({borderRadius:e.controlHeight,paddingInlineStart:e.controlHeight/2,paddingInlineEnd:e.controlHeight/2}),U=e=>({cursor:`not-allowed`,borderColor:e.colorBorder,color:e.colorTextDisabled,backgroundColor:e.colorBgContainerDisabled,boxShadow:`none`}),W=(e,t,n,r,i,a,o)=>({[`&${e}-background-ghost`]:m(m({color:t||void 0,backgroundColor:`transparent`,borderColor:n||void 0,boxShadow:`none`},B(m({backgroundColor:`transparent`},a),m({backgroundColor:`transparent`},o))),{"&:disabled":{cursor:`not-allowed`,color:r||void 0,borderColor:i||void 0}})}),G=e=>({"&:disabled":m({},U(e))}),K=e=>m({},G(e)),q=e=>({"&:disabled":{cursor:`not-allowed`,color:e.colorTextDisabled}}),J=e=>m(m(m(m(m({},K(e)),{backgroundColor:e.colorBgContainer,borderColor:e.colorBorder,boxShadow:`0 ${e.controlOutlineWidth}px 0 ${e.controlTmpOutline}`}),B({color:e.colorPrimaryHover,borderColor:e.colorPrimaryHover},{color:e.colorPrimaryActive,borderColor:e.colorPrimaryActive})),W(e.componentCls,e.colorBgContainer,e.colorBgContainer,e.colorTextDisabled,e.colorBorder)),{[`&${e.componentCls}-dangerous`]:m(m(m({color:e.colorError,borderColor:e.colorError},B({color:e.colorErrorHover,borderColor:e.colorErrorBorderHover},{color:e.colorErrorActive,borderColor:e.colorErrorActive})),W(e.componentCls,e.colorError,e.colorError,e.colorTextDisabled,e.colorBorder)),G(e))}),ie=e=>m(m(m(m(m({},K(e)),{color:e.colorTextLightSolid,backgroundColor:e.colorPrimary,boxShadow:`0 ${e.controlOutlineWidth}px 0 ${e.controlOutline}`}),B({color:e.colorTextLightSolid,backgroundColor:e.colorPrimaryHover},{color:e.colorTextLightSolid,backgroundColor:e.colorPrimaryActive})),W(e.componentCls,e.colorPrimary,e.colorPrimary,e.colorTextDisabled,e.colorBorder,{color:e.colorPrimaryHover,borderColor:e.colorPrimaryHover},{color:e.colorPrimaryActive,borderColor:e.colorPrimaryActive})),{[`&${e.componentCls}-dangerous`]:m(m(m({backgroundColor:e.colorError,boxShadow:`0 ${e.controlOutlineWidth}px 0 ${e.colorErrorOutline}`},B({backgroundColor:e.colorErrorHover},{backgroundColor:e.colorErrorActive})),W(e.componentCls,e.colorError,e.colorError,e.colorTextDisabled,e.colorBorder,{color:e.colorErrorHover,borderColor:e.colorErrorHover},{color:e.colorErrorActive,borderColor:e.colorErrorActive})),G(e))}),ae=e=>m(m({},J(e)),{borderStyle:`dashed`}),oe=e=>m(m(m({color:e.colorLink},B({color:e.colorLinkHover},{color:e.colorLinkActive})),q(e)),{[`&${e.componentCls}-dangerous`]:m(m({color:e.colorError},B({color:e.colorErrorHover},{color:e.colorErrorActive})),q(e))}),se=e=>m(m(m({},B({color:e.colorText,backgroundColor:e.colorBgTextHover},{color:e.colorText,backgroundColor:e.colorBgTextActive})),q(e)),{[`&${e.componentCls}-dangerous`]:m(m({color:e.colorError},q(e)),B({color:e.colorErrorHover,backgroundColor:e.colorErrorBg},{color:e.colorErrorHover,backgroundColor:e.colorErrorBg}))}),ce=e=>m(m({},U(e)),{[`&${e.componentCls}:hover`]:m({},U(e))}),le=e=>{let{componentCls:t}=e;return{[`${t}-default`]:J(e),[`${t}-primary`]:ie(e),[`${t}-dashed`]:ae(e),[`${t}-link`]:oe(e),[`${t}-text`]:se(e),[`${t}-disabled`]:ce(e)}},Y=function(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:``,{componentCls:n,iconCls:r,controlHeight:i,fontSize:a,lineHeight:o,lineWidth:s,borderRadius:c,buttonPaddingHorizontal:l}=e,u=Math.max(0,(i-a*o)/2-s),d=l-s,f=`${n}-icon-only`;return[{[`${n}${t}`]:{fontSize:a,height:i,padding:`${u}px ${d}px`,borderRadius:c,[`&${f}`]:{width:i,paddingInlineStart:0,paddingInlineEnd:0,[`&${n}-round`]:{width:`auto`},"> span":{transform:`scale(1.143)`}},[`&${n}-loading`]:{opacity:e.opacityLoading,cursor:`default`},[`${n}-loading-icon`]:{transition:`width ${e.motionDurationSlow} ${e.motionEaseInOut}, opacity ${e.motionDurationSlow} ${e.motionEaseInOut}`},[`&:not(${f}) ${n}-loading-icon > ${r}`]:{marginInlineEnd:e.marginXS}}},{[`${n}${n}-circle${t}`]:V(e)},{[`${n}${n}-round${t}`]:H(e)}]},ue=e=>Y(e),de=e=>Y(y(e,{controlHeight:e.controlHeightSM,padding:e.paddingXS,buttonPaddingHorizontal:8,borderRadius:e.borderRadiusSM}),`${e.componentCls}-sm`),fe=e=>Y(y(e,{controlHeight:e.controlHeightLG,fontSize:e.fontSizeLG,borderRadius:e.borderRadiusLG}),`${e.componentCls}-lg`),pe=e=>{let{componentCls:t}=e;return{[t]:{[`&${t}-block`]:{width:`100%`}}}},me=ee(`Button`,e=>{let{controlTmpOutline:t,paddingContentHorizontal:n}=e,r=y(e,{colorOutlineDefault:t,buttonPaddingHorizontal:n});return[z(r),de(r),ue(r),fe(r),pe(r),le(r),F(r),O(e,{focus:!1}),R(e)]}),he=()=>({prefixCls:String,size:{type:String}}),X=D(),Z=l({compatConfig:{MODE:3},name:`AButtonGroup`,props:he(),setup(e,n){let{slots:r}=n,{prefixCls:i,direction:a}=S(`btn-group`,e),[,,c]=v();X.useProvide(s({size:o(()=>e.size)}));let l=o(()=>{let{size:t}=e,n=``;switch(t){case`large`:n=`lg`;break;case`small`:n=`sm`;break;case`middle`:case void 0:break;default:T(!t,`Button.Group`,"Invalid prop `size`.")}return{[`${i.value}`]:!0,[`${i.value}-${n}`]:n,[`${i.value}-rtl`]:a.value===`rtl`,[c.value]:!0}});return()=>{var e;return t(`div`,{class:l.value},[x((e=r.default)==null?void 0:e.call(r))])}}}),ge=/^[\u4e00-\u9fa5]{2}$/,_e=ge.test.bind(ge);function Q(e){return e===`text`||e===`link`}var $=l({compatConfig:{MODE:3},name:`AButton`,inheritAttrs:!1,__ANT_BUTTON:!0,props:C(A(),{type:`default`}),slots:Object,setup(e,s){let{slots:l,attrs:d,emit:p,expose:g}=s,{prefixCls:v,autoInsertSpaceInButton:y,direction:b,size:ee}=S(`btn`,e),[C,w]=me(v),E=X.useInject(),D=h(),O=o(()=>{var t;return(t=e.disabled)==null?D.value:t}),k=f(null),A=f(void 0),j=!1,M=f(!1),N=f(!1),P=o(()=>y.value!==!1),{compactSize:F,compactItemClassnames:I}=te(v,b),L=o(()=>typeof e.loading==`object`&&e.loading.delay?e.loading.delay||!0:!!e.loading);n(L,e=>{clearTimeout(A.value),typeof L.value==`number`?A.value=setTimeout(()=>{M.value=e},L.value):M.value=e},{immediate:!0});let R=o(()=>{let{type:t,shape:n=`default`,ghost:r,block:i,danger:a}=e,o=v.value,s={large:`lg`,small:`sm`,middle:void 0},c=F.value||(E==null?void 0:E.size)||ee.value,l=c&&s[c]||``;return[I.value,{[w.value]:!0,[`${o}`]:!0,[`${o}-${n}`]:n!=="default"&&n,[`${o}-${t}`]:t,[`${o}-${l}`]:l,[`${o}-loading`]:M.value,[`${o}-background-ghost`]:r&&!Q(t),[`${o}-two-chinese-chars`]:N.value&&P.value,[`${o}-block`]:i,[`${o}-dangerous`]:!!a,[`${o}-rtl`]:b.value===`rtl`}]}),z=()=>{let e=k.value;if(!e||y.value===!1)return;let t=e.textContent;j&&_e(t)?N.value||(N.value=!0):N.value&&(N.value=!1)},B=e=>{if(M.value||O.value){e.preventDefault();return}p(`click`,e)},V=e=>{p(`mousedown`,e)},H=(e,n)=>{let r=n?` `:``;if(e.type===a){let n=e.children.trim();return _e(n)&&(n=n.split(``).join(r)),t(`span`,null,[n])}return e};return r(()=>{T(!(e.ghost&&Q(e.type)),`Button`,"`link` or `text` button can't be a `ghost` button.")}),i(z),u(z),c(()=>{A.value&&clearTimeout(A.value)}),g({focus:()=>{var e;(e=k.value)==null||e.focus()},blur:()=>{var e;(e=k.value)==null||e.blur()}}),()=>{var n,r;let{icon:i=(n=l.icon)==null?void 0:n.call(l)}=e,a=x((r=l.default)==null?void 0:r.call(l));j=a.length===1&&!i&&!Q(e.type);let{type:o,htmlType:s,href:c,title:u,target:f}=e,p=M.value?`loading`:i,h=m(m({},d),{title:u,disabled:O.value,class:[R.value,d.class,{[`${v.value}-icon-only`]:a.length===0&&!!p}],onClick:B,onMousedown:V});O.value||delete h.disabled;let g=i&&!M.value?i:t(re,{existIcon:!!i,prefixCls:v.value,loading:!!M.value},null),y=a.map(e=>H(e,j&&P.value));if(c!==void 0)return C(t(`a`,_(_({},h),{},{href:c,target:f,ref:k}),[g,y]));let b=t(`button`,_(_({},h),{},{ref:k,type:s}),[g,y]);if(!Q(o)){let e=function(){return b}();b=t(ne,{ref:`wave`,disabled:!!M.value},{default:()=>[e]})}return C(b)}}}),ve=e({ButtonGroup:()=>Z,default:()=>ye});$.Group=Z,$.install=function(e){return e.component($.name,$),e.component(Z.name,Z),e};var ye=$;export{k as i,ve as n,A as r,ye as t}; |