1 line
11 KiB
JavaScript
1 line
11 KiB
JavaScript
import{o as e}from"./request-xrnk7ZJV.js";import{Bn as t,Ct as n,Ft as r,Hn as i,Ln as a,Nn as o,Ot as s,Pr as c,Wn as l,en as u,jt as d,kt as f,nr as p,qt as m,rr as h,st as g,wn as _,wt as v}from"./jsx-runtime-OfKoVykY.js";import{S as y,n as ee}from"./tooltip-DI_m69zk.js";var b=e(c()),x=e=>{let{prefixCls:t,value:n,current:r,offset:i=0}=e,a;return i&&(a={position:`absolute`,top:`${i}00%`,left:0}),b.createElement(`span`,{style:a,className:l(`${t}-only-unit`,{current:r})},n)};function S(e,t,n){let r=e,i=0;for(;(r+10)%10!==t;)r+=n,i+=n;return i}var C=e=>{let{prefixCls:t,count:n,value:r}=e,i=Number(r),a=Math.abs(n),[o,s]=b.useState(i),[c,l]=b.useState(a),u=()=>{s(i),l(a)};b.useEffect(()=>{let e=setTimeout(u,1e3);return()=>clearTimeout(e)},[i]);let d,f;if(o===i||Number.isNaN(i)||Number.isNaN(o))d=[b.createElement(x,{...e,key:i,current:!0})],f={transition:`none`};else{d=[];let t=i+10,n=[];for(let e=i;e<=t;e+=1)n.push(e);let r=c<a?1:-1,s=n.findIndex(e=>e%10===o);d=(r<0?n.slice(0,s+1):n.slice(s)).map((t,n)=>{let i=t%10;return b.createElement(x,{...e,key:t,value:i,offset:r<0?n-s:n,current:n===s})}),f={transform:`translateY(${-S(o,i,r)}00%)`}}return b.createElement(`span`,{className:`${t}-only`,style:f,onTransitionEnd:u},d)},w=b.forwardRef((e,n)=>{let{prefixCls:r,count:i,className:a,motionClassName:o,style:s,title:c,show:u,component:d=`sup`,children:f,...p}=e,{getPrefixCls:m}=b.useContext(t),h=m(`scroll-number`,r),_={...p,"data-show":u,style:s,className:l(h,a,o),title:c},v=i;if(i&&Number(i)%1==0){let e=String(i).split(``);v=b.createElement(`bdi`,null,e.map((t,n)=>b.createElement(C,{prefixCls:h,count:Number(i),value:t,key:e.length-n})))}return s?.borderColor&&(_.style={...s,boxShadow:`0 0 0 1px ${s.borderColor} inset`}),f?g(f,e=>({className:l(`${h}-custom-component`,e?.className,o)})):b.createElement(d,{..._,ref:n},v)}),T=new o(`antStatusProcessing`,{"0%":{transform:`scale(0.8)`,opacity:.5},"100%":{transform:`scale(2.4)`,opacity:0}}),E=new o(`antZoomBadgeIn`,{"0%":{transform:`scale(0) translate(50%, -50%)`,opacity:0},"100%":{transform:`scale(1) translate(50%, -50%)`}}),D=new o(`antZoomBadgeOut`,{"0%":{transform:`scale(1) translate(50%, -50%)`},"100%":{transform:`scale(0) translate(50%, -50%)`,opacity:0}}),O=new o(`antNoWrapperZoomBadgeIn`,{"0%":{transform:`scale(0)`,opacity:0},"100%":{transform:`scale(1)`}}),k=new o(`antNoWrapperZoomBadgeOut`,{"0%":{transform:`scale(1)`},"100%":{transform:`scale(0)`,opacity:0}}),A=new o(`antBadgeLoadingCircle`,{"0%":{transformOrigin:`50%`},"100%":{transform:`translate(50%, -50%) rotate(360deg)`,transformOrigin:`50%`}}),j=e=>{let{componentCls:t,iconCls:n,antCls:r,badgeShadowSize:i,textFontSize:o,textFontSizeSM:s,statusSize:c,dotSize:l,textFontWeight:d,indicatorHeight:f,indicatorHeightSM:p,marginXS:m,calc:h}=e,g=`${r}-scroll-number`,_=y(e,(e,{darkColor:n})=>({[`&${t} ${t}-color-${e}`]:{background:n,[`&:not(${t}-count)`]:{color:n},"a:hover &":{background:n}}}));return{[t]:{...u(e),position:`relative`,display:`inline-block`,width:`fit-content`,lineHeight:1,[`${t}-count`]:{display:`inline-flex`,justifyContent:`center`,zIndex:e.indicatorZIndex,minWidth:f,height:f,color:e.badgeTextColor,fontWeight:d,fontSize:o,lineHeight:a(f),whiteSpace:`nowrap`,textAlign:`center`,background:e.badgeColor,borderRadius:h(f).div(2).equal(),boxShadow:`0 0 0 ${a(i)} ${e.badgeShadowColor}`,transition:`background-color ${e.motionDurationMid}`,a:{color:e.badgeTextColor},"a:hover":{color:e.badgeTextColor},"a:hover &":{background:e.badgeColorHover}},[`${t}-count-sm`]:{minWidth:p,height:p,fontSize:s,lineHeight:a(p),borderRadius:h(p).div(2).equal()},[`${t}-multiple-words`]:{paddingInline:e.paddingInline,bdi:{unicodeBidi:`plaintext`}},[`${t}-dot`]:{zIndex:e.indicatorZIndex,width:l,minWidth:l,height:l,background:e.badgeColor,borderRadius:`100%`,boxShadow:`0 0 0 ${a(i)} ${e.badgeShadowColor}`},[`${t}-count, ${t}-dot, ${g}-custom-component`]:{position:`absolute`,top:0,insetInlineEnd:0,transform:`translate(50%, -50%)`,transformOrigin:`100% 0%`,[`&${n}-spin`]:{animationName:A,animationDuration:`1s`,animationIterationCount:`infinite`,animationTimingFunction:`linear`}},[`&${t}-status`]:{lineHeight:`inherit`,verticalAlign:`baseline`,[`${t}-status-dot`]:{position:`relative`,top:-1,display:`inline-block`,width:c,height:c,verticalAlign:`middle`,borderRadius:`50%`},[`${t}-status-success`]:{backgroundColor:e.colorSuccess},[`${t}-status-processing`]:{overflow:`visible`,color:e.colorInfoTextHover,backgroundColor:e.colorInfo,borderColor:`currentcolor`,"&::after":{position:`absolute`,top:0,insetInlineStart:0,width:`100%`,height:`100%`,borderWidth:i,borderStyle:`solid`,borderColor:`inherit`,borderRadius:`50%`,animationName:T,animationDuration:e.badgeProcessingDuration,animationIterationCount:`infinite`,animationTimingFunction:`ease-in-out`,content:`""`}},[`${t}-status-default`]:{backgroundColor:e.colorTextPlaceholder},[`${t}-status-error`]:{backgroundColor:e.colorError},[`${t}-status-warning`]:{backgroundColor:e.colorWarning},[`${t}-status-text`]:{marginInlineStart:m,color:e.colorText,fontSize:e.fontSize}},..._,[`${t}-zoom-appear, ${t}-zoom-enter`]:{animationName:E,animationDuration:e.motionDurationSlow,animationTimingFunction:e.motionEaseOutBack,animationFillMode:`both`},[`${t}-zoom-leave`]:{animationName:D,animationDuration:e.motionDurationSlow,animationTimingFunction:e.motionEaseOutBack,animationFillMode:`both`},[`&${t}-not-a-wrapper`]:{[`${t}-zoom-appear, ${t}-zoom-enter`]:{animationName:O,animationDuration:e.motionDurationSlow,animationTimingFunction:e.motionEaseOutBack},[`${t}-zoom-leave`]:{animationName:k,animationDuration:e.motionDurationSlow,animationTimingFunction:e.motionEaseOutBack},[`&:not(${t}-status)`]:{verticalAlign:`middle`},[`${g}-custom-component, ${t}-count`]:{transform:`none`},[`${g}-custom-component, ${g}`]:{position:`relative`,top:`auto`,display:`block`,transformOrigin:`50% 50%`}},[g]:{overflow:`hidden`,transition:`all ${e.motionDurationMid} ${e.motionEaseOutBack}`,[`${g}-only`]:{position:`relative`,display:`inline-block`,height:f,transition:`all ${e.motionDurationSlow} ${e.motionEaseOutBack}`,WebkitTransformStyle:`preserve-3d`,WebkitBackfaceVisibility:`hidden`}},"&-rtl":{direction:`rtl`,[`${t}-count, ${t}-dot, ${g}-custom-component`]:{transform:`translate(-50%, -50%)`}}}}},M=e=>{let{fontHeight:t,lineWidth:n,marginXS:r,colorBorderBg:i}=e,a=t,o=n,s=e.colorTextLightSolid,c=e.colorError,l=e.colorErrorHover;return _(e,{badgeFontHeight:a,badgeShadowSize:o,badgeTextColor:s,badgeColor:c,badgeColorHover:l,badgeShadowColor:i,badgeProcessingDuration:`1.2s`,badgeRibbonOffset:r,badgeRibbonCornerTransform:`scaleY(0.75)`,badgeRibbonCornerFilter:`brightness(75%)`})},N=e=>{let{fontSize:t,lineHeight:n,fontSizeSM:r,lineWidth:i,paddingXS:a}=e;return{indicatorZIndex:`auto`,indicatorHeight:Math.round(t*n)-2*i,indicatorHeightSM:t,dotSize:r/2,textFontSize:r,textFontSizeSM:r,textFontWeight:`normal`,statusSize:r/2,paddingInline:a}},P=m(`Badge`,e=>j(M(e)),N),F=b.forwardRef((e,t)=>{let{prefixCls:a,scrollNumberPrefixCls:o,children:c,status:u,text:m,color:_,count:y=null,overflowCount:x=99,dot:S=!1,size:C=`medium`,title:T,offset:E,style:D,className:O,rootClassName:k,classNames:A,styles:j,showZero:M=!1,...N}=e,{getPrefixCls:F,direction:I,className:te,style:L,classNames:R,styles:ne}=i(`badge`),z=F(`badge`,a),[re,ie]=P(z),ae={...e,overflowCount:x,size:C,dot:S,showZero:M},B=y>x?`${x}+`:y,V=B===`0`||B===0||m===`0`||m===0,oe=y===null||V&&!M,H=(p(u)||p(_))&&oe,se=p(u)||!V,U=!(c||!H||!m&&!se),W=(0,b.useMemo)(()=>{if(!E)return;let e=Number.parseFloat(E[0]);return{marginTop:E[1],insetInlineEnd:-e}},[E]),ce=(0,b.useMemo)(()=>({...W,...L,...D}),[W,D,L]),le=U?`root`:`indicator`,ue=v(L,le),de=v(D,le),[G,K]=n([R,A],[ne,ue,j,de],{props:ae}),q=S&&!V,J=q?``:B,Y=(0,b.useMemo)(()=>(!h(J)&&!h(m)||V&&!M)&&!q,[J,V,M,q,m]),fe=(0,b.useRef)(y);Y||(fe.current=y);let X=fe.current,pe=(0,b.useRef)(J);Y||(pe.current=J);let Z=pe.current,me=(0,b.useRef)(q);Y||(me.current=q);let he=d(X)||s(X)?X:void 0,ge=T===null||T===!1?void 0:T??he,_e=!Y&&(m===0?M:m&&m!==!0)?b.createElement(`span`,{style:U?{color:K.root?.color}:void 0,className:`${z}-status-text`},m):null,ve=f(X)?g(X,e=>({style:{...ce,...e.style}})):void 0,Q=ee(_,!1),ye=l(G.indicator,{[`${z}-status-dot`]:H,[`${z}-status-${u}`]:!!u,[`${z}-color-${_}`]:Q}),$={};_&&!Q&&($.color=_,$.background=_);let be=l(z,{[`${z}-status`]:H,[`${z}-not-a-wrapper`]:!c,[`${z}-rtl`]:I===`rtl`},O,k,te,G.root,re,ie);return U?b.createElement(`span`,{ref:t,...N,className:be,style:{...W,...K.root}},b.createElement(`span`,{className:ye,style:{...K.indicator,...$}}),_e):b.createElement(`span`,{ref:t,...N,className:be,style:K.root},c,b.createElement(r,{visible:!Y,motionName:`${z}-zoom`,motionAppear:!1,motionDeadline:1e3},({className:e})=>{let t=F(`scroll-number`,o),n=me.current,r=l(G.indicator,{[`${z}-dot`]:n,[`${z}-count`]:!n,[`${z}-count-sm`]:C===`small`,[`${z}-multiple-words`]:!n&&Z&&Z.toString().length>1,[`${z}-status-${u}`]:!!u,[`${z}-color-${_}`]:Q}),i={...W,...K.indicator};return _&&!Q&&(i.background=_),b.createElement(w,{prefixCls:t,show:!Y,motionClassName:e,className:r,count:Z,title:ge,style:i,key:`scrollNumber`},ve)}),_e)}),I=e=>{let{antCls:t,badgeFontHeight:n,marginXS:r,badgeRibbonOffset:i,calc:o}=e,s=`${t}-ribbon`,c=`${t}-ribbon-wrapper`,l=y(e,(e,{darkColor:t})=>({[`&${s}-color-${e}`]:{background:t,color:t}}));return{[c]:{position:`relative`},[s]:{...u(e),position:`absolute`,top:r,padding:`0 ${a(e.paddingXS)}`,color:e.colorPrimary,lineHeight:a(n),whiteSpace:`nowrap`,backgroundColor:e.colorPrimary,borderRadius:e.borderRadiusSM,[`${s}-content`]:{color:e.badgeTextColor},[`${s}-corner`]:{position:`absolute`,top:`100%`,width:i,height:i,color:`currentcolor`,border:`${a(o(i).div(2).equal())} solid`,transform:e.badgeRibbonCornerTransform,transformOrigin:`top`,filter:e.badgeRibbonCornerFilter},...l,[`&${s}-placement-end`]:{insetInlineEnd:o(i).mul(-1).equal(),borderEndEndRadius:0,[`${s}-corner`]:{insetInlineEnd:0,borderInlineEndColor:`transparent`,borderBlockEndColor:`transparent`}},[`&${s}-placement-start`]:{insetInlineStart:o(i).mul(-1).equal(),borderEndStartRadius:0,[`${s}-corner`]:{insetInlineStart:0,borderBlockEndColor:`transparent`,borderInlineStartColor:`transparent`}},"&-rtl":{direction:`rtl`}}}},te=m([`Badge`,`Ribbon`],e=>I(M(e)),N),L=b.forwardRef((e,t)=>{let{className:r,prefixCls:a,style:o,color:s,children:c,text:u,placement:d=`end`,rootClassName:f,styles:p,classNames:m}=e,{getPrefixCls:h,direction:g,className:_,style:y,classNames:x,styles:S}=i(`ribbon`),C=h(`ribbon`,a),w=`${C}-wrapper`,[T,E]=te(C,w),D={...e,placement:d},O=v(y,`indicator`),k=v(o,`indicator`),[A,j]=n([x,m],[S,O,p,k],{props:D}),M=ee(s,!1),N=l(C,`${C}-placement-${d}`,{[`${C}-rtl`]:g===`rtl`,[`${C}-color-${s}`]:M},r,_,A.indicator),P={},F={};s&&!M&&(P.background=s,F.color=s);let I=b.useRef(null);return b.useImperativeHandle(t,()=>({nativeElement:I.current})),b.createElement(`div`,{ref:I,className:l(w,f,T,E,A.root),style:j.root},c,b.createElement(`div`,{className:l(N,T),style:{...P,...j.indicator}},b.createElement(`span`,{className:l(`${C}-content`,A.content),style:j.content},u),b.createElement(`div`,{className:`${C}-corner`,style:F})))}),R=F;R.Ribbon=L;export{R as t}; |