Files
2026-07-31 18:51:41 +08:00

1 line
11 KiB
JavaScript

import{i as e}from"./rolldown-runtime-BgaNhQyE.js";import{An as t,Dr as n,Et as r,Ln as i,Mt as a,Ot as o,Pn as s,Tt as c,Vn as l,Wt as u,Zt as d,kt as f,st as p,wt as m,xn as h,xt as g,zn as _}from"./jsx-runtime-ADHq9IcL.js";import{S as v,n as ee}from"./tooltip-CRuv8UNz.js";var y=e(n()),b=e=>{let{prefixCls:t,value:n,current:r,offset:i=0}=e,a;return i&&(a={position:`absolute`,top:`${i}00%`,left:0}),y.createElement(`span`,{style:a,className:l(`${t}-only-unit`,{current:r})},n)};function x(e,t,n){let r=e,i=0;for(;(r+10)%10!==t;)r+=n,i+=n;return i}var S=e=>{let{prefixCls:t,count:n,value:r}=e,i=Number(r),a=Math.abs(n),[o,s]=y.useState(i),[c,l]=y.useState(a),u=()=>{s(i),l(a)};y.useEffect(()=>{let e=setTimeout(u,1e3);return()=>clearTimeout(e)},[i]);let d,f;if(o===i||Number.isNaN(i)||Number.isNaN(o))d=[y.createElement(b,{...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 y.createElement(b,{...e,key:t,value:i,offset:r<0?n-s:n,current:n===s})}),f={transform:`translateY(${-x(o,i,r)}00%)`}}return y.createElement(`span`,{className:`${t}-only`,style:f,onTransitionEnd:u},d)},C=y.forwardRef((e,t)=>{let{prefixCls:n,count:r,className:a,motionClassName:o,style:s,title:c,show:u,component:d=`sup`,children:f,...m}=e,{getPrefixCls:h}=y.useContext(i),g=h(`scroll-number`,n),_={...m,"data-show":u,style:s,className:l(g,a,o),title:c},v=r;if(r&&Number(r)%1==0){let e=String(r).split(``);v=y.createElement(`bdi`,null,e.map((t,n)=>y.createElement(S,{prefixCls:g,count:Number(r),value:t,key:e.length-n})))}return s?.borderColor&&(_.style={...s,boxShadow:`0 0 0 1px ${s.borderColor} inset`}),f?p(f,e=>({className:l(`${g}-custom-component`,e?.className,o)})):y.createElement(d,{..._,ref:t},v)}),w=new t(`antStatusProcessing`,{"0%":{transform:`scale(0.8)`,opacity:.5},"100%":{transform:`scale(2.4)`,opacity:0}}),T=new t(`antZoomBadgeIn`,{"0%":{transform:`scale(0) translate(50%, -50%)`,opacity:0},"100%":{transform:`scale(1) translate(50%, -50%)`}}),E=new t(`antZoomBadgeOut`,{"0%":{transform:`scale(1) translate(50%, -50%)`},"100%":{transform:`scale(0) translate(50%, -50%)`,opacity:0}}),D=new t(`antNoWrapperZoomBadgeIn`,{"0%":{transform:`scale(0)`,opacity:0},"100%":{transform:`scale(1)`}}),O=new t(`antNoWrapperZoomBadgeOut`,{"0%":{transform:`scale(1)`},"100%":{transform:`scale(0)`,opacity:0}}),k=new t(`antBadgeLoadingCircle`,{"0%":{transformOrigin:`50%`},"100%":{transform:`translate(50%, -50%) rotate(360deg)`,transformOrigin:`50%`}}),A=e=>{let{componentCls:t,iconCls:n,antCls:r,badgeShadowSize:i,textFontSize:a,textFontSizeSM:o,statusSize:c,dotSize:l,textFontWeight:u,indicatorHeight:f,indicatorHeightSM:p,marginXS:m,calc:h}=e,g=`${r}-scroll-number`,_=v(e,(e,{darkColor:n})=>({[`&${t} ${t}-color-${e}`]:{background:n,[`&:not(${t}-count)`]:{color:n},"a:hover &":{background:n}}}));return{[t]:{...d(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:u,fontSize:a,lineHeight:s(f),whiteSpace:`nowrap`,textAlign:`center`,background:e.badgeColor,borderRadius:h(f).div(2).equal(),boxShadow:`0 0 0 ${s(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:o,lineHeight:s(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 ${s(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:k,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:w,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:T,animationDuration:e.motionDurationSlow,animationTimingFunction:e.motionEaseOutBack,animationFillMode:`both`},[`${t}-zoom-leave`]:{animationName:E,animationDuration:e.motionDurationSlow,animationTimingFunction:e.motionEaseOutBack,animationFillMode:`both`},[`&${t}-not-a-wrapper`]:{[`${t}-zoom-appear, ${t}-zoom-enter`]:{animationName:D,animationDuration:e.motionDurationSlow,animationTimingFunction:e.motionEaseOutBack},[`${t}-zoom-leave`]:{animationName:O,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`,[`> p${g}-only-unit`]:{height:f,margin:0,WebkitTransformStyle:`preserve-3d`,WebkitBackfaceVisibility:`hidden`}},[`${g}-symbol`]:{verticalAlign:`top`}},"&-rtl":{direction:`rtl`,[`${t}-count, ${t}-dot, ${g}-custom-component`]:{transform:`translate(-50%, -50%)`}}}}},j=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 h(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%)`})},M=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}},te=u(`Badge`,e=>A(j(e)),M),N=y.forwardRef((e,t)=>{let{prefixCls:n,scrollNumberPrefixCls:i,children:s,status:u,text:d,color:h,count:v=null,overflowCount:b=99,dot:x=!1,size:S=`medium`,title:w,offset:T,style:E,className:D,rootClassName:O,classNames:k,styles:A,showZero:j=!1,...M}=e,{getPrefixCls:N,direction:P,className:F,style:I,classNames:L,styles:ne}=_(`badge`),R=N(`badge`,n),[re,ie]=te(R),ae={...e,overflowCount:b,size:S,dot:x,showZero:j},[z,B]=g([L,k],[ne,A],{props:ae}),V=v>b?`${b}+`:v,H=V===`0`||V===0||d===`0`||d===0,U=v===null||H&&!j,W=(m(u)||m(h))&&U,oe=m(u)||!H,G=x&&!H,K=G?``:V,q=(0,y.useMemo)(()=>(!o(K)&&!o(d)||H&&!j)&&!G,[K,H,j,G,d]),J=(0,y.useRef)(v);q||(J.current=v);let Y=J.current,se=(0,y.useRef)(K);q||(se.current=K);let X=se.current,ce=(0,y.useRef)(G);q||(ce.current=G);let Z=(0,y.useMemo)(()=>{if(!T)return{...I,...E};let e=Number.parseInt(T[0],10);return{marginTop:T[1],insetInlineEnd:-e,...I,...E}},[T,E,I]),le=f(Y)||c(Y)?Y:void 0,ue=w===null||w===!1?void 0:w??le,de=!q&&(d===0?j:!!d&&d!==!0),fe=de?y.createElement(`span`,{className:`${R}-status-text`},d):null,pe=r(Y)?p(Y,e=>({style:{...Z,...e.style}})):void 0,Q=ee(h,!1),me=l(z.indicator,{[`${R}-status-dot`]:W,[`${R}-status-${u}`]:!!u,[`${R}-color-${h}`]:Q}),$={};h&&!Q&&($.color=h,$.background=h);let he=l(R,{[`${R}-status`]:W,[`${R}-not-a-wrapper`]:!s,[`${R}-rtl`]:P===`rtl`},D,O,F,z.root,re,ie);if(!s&&W&&(d||oe||!U)){let e=Z.color;return y.createElement(`span`,{ref:t,...M,className:he,style:{...B.root,...Z}},y.createElement(`span`,{className:me,style:{...B.indicator,...$}}),de&&y.createElement(`span`,{style:{color:e},className:`${R}-status-text`},d))}return y.createElement(`span`,{ref:t,...M,className:he,style:B.root},s,y.createElement(a,{visible:!q,motionName:`${R}-zoom`,motionAppear:!1,motionDeadline:1e3},({className:e})=>{let t=N(`scroll-number`,i),n=ce.current,r=l(z.indicator,{[`${R}-dot`]:n,[`${R}-count`]:!n,[`${R}-count-sm`]:S===`small`,[`${R}-multiple-words`]:!n&&X&&X.toString().length>1,[`${R}-status-${u}`]:!!u,[`${R}-color-${h}`]:Q}),a={...B.indicator,...Z};return h&&!Q&&(a||={},a.background=h),y.createElement(C,{prefixCls:t,show:!q,motionClassName:e,className:r,count:X,title:ue,style:a,key:`scrollNumber`},pe)}),fe)}),P=e=>{let{antCls:t,badgeFontHeight:n,marginXS:r,badgeRibbonOffset:i,calc:a}=e,o=`${t}-ribbon`,c=`${t}-ribbon-wrapper`,l=v(e,(e,{darkColor:t})=>({[`&${o}-color-${e}`]:{background:t,color:t}}));return{[c]:{position:`relative`},[o]:{...d(e),position:`absolute`,top:r,padding:`0 ${s(e.paddingXS)}`,color:e.colorPrimary,lineHeight:s(n),whiteSpace:`nowrap`,backgroundColor:e.colorPrimary,borderRadius:e.borderRadiusSM,[`${o}-content`]:{color:e.badgeTextColor},[`${o}-corner`]:{position:`absolute`,top:`100%`,width:i,height:i,color:`currentcolor`,border:`${s(a(i).div(2).equal())} solid`,transform:e.badgeRibbonCornerTransform,transformOrigin:`top`,filter:e.badgeRibbonCornerFilter},...l,[`&${o}-placement-end`]:{insetInlineEnd:a(i).mul(-1).equal(),borderEndEndRadius:0,[`${o}-corner`]:{insetInlineEnd:0,borderInlineEndColor:`transparent`,borderBlockEndColor:`transparent`}},[`&${o}-placement-start`]:{insetInlineStart:a(i).mul(-1).equal(),borderEndStartRadius:0,[`${o}-corner`]:{insetInlineStart:0,borderBlockEndColor:`transparent`,borderInlineStartColor:`transparent`}},"&-rtl":{direction:`rtl`}}}},F=u([`Badge`,`Ribbon`],e=>P(j(e)),M),I=e=>{let{className:t,prefixCls:n,style:r,color:i,children:a,text:o,placement:s=`end`,rootClassName:c,styles:u,classNames:d}=e,{getPrefixCls:f,direction:p,className:m,style:h,classNames:v,styles:b}=_(`ribbon`),x=f(`ribbon`,n),S=`${x}-wrapper`,[C,w]=F(x,S),T={...e,placement:s},[E,D]=g([v,d],[b,u],{props:T}),O=ee(i,!1),k=l(x,`${x}-placement-${s}`,{[`${x}-rtl`]:p===`rtl`,[`${x}-color-${i}`]:O},t,m,E.indicator),A={},j={};return i&&!O&&(A.background=i,j.color=i),y.createElement(`div`,{className:l(S,c,C,w,E.root),style:D.root},a,y.createElement(`div`,{className:l(k,C),style:{...A,...D.indicator,...h,...r}},y.createElement(`span`,{className:l(`${x}-content`,E.content),style:D.content},o),y.createElement(`div`,{className:`${x}-corner`,style:j})))},L=N;L.Ribbon=I;export{L as t};