Files
2026-07-13 15:23:29 +08:00

1 line
11 KiB
JavaScript

import{$t as e,Bt as t,Or as n,Sn as r,Sr as i,St as a,Tr as o,_n as s,an as c,cn as l,dn as u,hn as d,mn as f,nn as p,pn as m,sn as h,st as g}from"./jsx-runtime-NwRKtVrk.js";import{i as _,x as v}from"./statusUtils-G17j4Ng-.js";var y=n(o()),b=e=>{let{prefixCls:t,value:n,current:r,offset:a=0}=e,o;return a&&(o={position:`absolute`,top:`${a}00%`,left:0}),y.createElement(`span`,{style:o,className:i(`${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:l,component:u=`sup`,children:d,...f}=e,{getPrefixCls:p}=y.useContext(h),m=p(`scroll-number`,n),_={...f,"data-show":l,style:s,className:i(m,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:m,count:Number(r),value:t,key:e.length-n})))}return s?.borderColor&&(_.style={...s,boxShadow:`0 0 0 1px ${s.borderColor} inset`}),d?g(d,e=>({className:i(`${m}-custom-component`,e?.className,o)})):y.createElement(u,{..._,ref:t},v)}),w=new p(`antStatusProcessing`,{"0%":{transform:`scale(0.8)`,opacity:.5},"100%":{transform:`scale(2.4)`,opacity:0}}),T=new p(`antZoomBadgeIn`,{"0%":{transform:`scale(0) translate(50%, -50%)`,opacity:0},"100%":{transform:`scale(1) translate(50%, -50%)`}}),E=new p(`antZoomBadgeOut`,{"0%":{transform:`scale(1) translate(50%, -50%)`},"100%":{transform:`scale(0) translate(50%, -50%)`,opacity:0}}),D=new p(`antNoWrapperZoomBadgeIn`,{"0%":{transform:`scale(0)`,opacity:0},"100%":{transform:`scale(1)`}}),O=new p(`antNoWrapperZoomBadgeOut`,{"0%":{transform:`scale(1)`},"100%":{transform:`scale(0)`,opacity:0}}),k=new p(`antBadgeLoadingCircle`,{"0%":{transformOrigin:`50%`},"100%":{transform:`translate(50%, -50%) rotate(360deg)`,transformOrigin:`50%`}}),A=t=>{let{componentCls:n,iconCls:r,antCls:i,badgeShadowSize:a,textFontSize:o,textFontSizeSM:s,statusSize:l,dotSize:u,textFontWeight:d,indicatorHeight:f,indicatorHeightSM:p,marginXS:m,calc:h}=t,g=`${i}-scroll-number`,_=v(t,(e,{darkColor:t})=>({[`&${n} ${n}-color-${e}`]:{background:t,[`&:not(${n}-count)`]:{color:t},"a:hover &":{background:t}}}));return{[n]:{...e(t),position:`relative`,display:`inline-block`,width:`fit-content`,lineHeight:1,[`${n}-count`]:{display:`inline-flex`,justifyContent:`center`,zIndex:t.indicatorZIndex,minWidth:f,height:f,color:t.badgeTextColor,fontWeight:d,fontSize:o,lineHeight:c(f),whiteSpace:`nowrap`,textAlign:`center`,background:t.badgeColor,borderRadius:h(f).div(2).equal(),boxShadow:`0 0 0 ${c(a)} ${t.badgeShadowColor}`,transition:`background-color ${t.motionDurationMid}`,a:{color:t.badgeTextColor},"a:hover":{color:t.badgeTextColor},"a:hover &":{background:t.badgeColorHover}},[`${n}-count-sm`]:{minWidth:p,height:p,fontSize:s,lineHeight:c(p),borderRadius:h(p).div(2).equal()},[`${n}-multiple-words`]:{paddingInline:t.paddingInline,bdi:{unicodeBidi:`plaintext`}},[`${n}-dot`]:{zIndex:t.indicatorZIndex,width:u,minWidth:u,height:u,background:t.badgeColor,borderRadius:`100%`,boxShadow:`0 0 0 ${c(a)} ${t.badgeShadowColor}`},[`${n}-count, ${n}-dot, ${g}-custom-component`]:{position:`absolute`,top:0,insetInlineEnd:0,transform:`translate(50%, -50%)`,transformOrigin:`100% 0%`,[`&${r}-spin`]:{animationName:k,animationDuration:`1s`,animationIterationCount:`infinite`,animationTimingFunction:`linear`}},[`&${n}-status`]:{lineHeight:`inherit`,verticalAlign:`baseline`,[`${n}-status-dot`]:{position:`relative`,top:-1,display:`inline-block`,width:l,height:l,verticalAlign:`middle`,borderRadius:`50%`},[`${n}-status-success`]:{backgroundColor:t.colorSuccess},[`${n}-status-processing`]:{overflow:`visible`,color:t.colorInfo,backgroundColor:t.colorInfo,borderColor:`currentcolor`,"&::after":{position:`absolute`,top:0,insetInlineStart:0,width:`100%`,height:`100%`,borderWidth:a,borderStyle:`solid`,borderColor:`inherit`,borderRadius:`50%`,animationName:w,animationDuration:t.badgeProcessingDuration,animationIterationCount:`infinite`,animationTimingFunction:`ease-in-out`,content:`""`}},[`${n}-status-default`]:{backgroundColor:t.colorTextPlaceholder},[`${n}-status-error`]:{backgroundColor:t.colorError},[`${n}-status-warning`]:{backgroundColor:t.colorWarning},[`${n}-status-text`]:{marginInlineStart:m,color:t.colorText,fontSize:t.fontSize}},..._,[`${n}-zoom-appear, ${n}-zoom-enter`]:{animationName:T,animationDuration:t.motionDurationSlow,animationTimingFunction:t.motionEaseOutBack,animationFillMode:`both`},[`${n}-zoom-leave`]:{animationName:E,animationDuration:t.motionDurationSlow,animationTimingFunction:t.motionEaseOutBack,animationFillMode:`both`},[`&${n}-not-a-wrapper`]:{[`${n}-zoom-appear, ${n}-zoom-enter`]:{animationName:D,animationDuration:t.motionDurationSlow,animationTimingFunction:t.motionEaseOutBack},[`${n}-zoom-leave`]:{animationName:O,animationDuration:t.motionDurationSlow,animationTimingFunction:t.motionEaseOutBack},[`&:not(${n}-status)`]:{verticalAlign:`middle`},[`${g}-custom-component, ${n}-count`]:{transform:`none`},[`${g}-custom-component, ${g}`]:{position:`relative`,top:`auto`,display:`block`,transformOrigin:`50% 50%`}},[g]:{overflow:`hidden`,transition:`all ${t.motionDurationMid} ${t.motionEaseOutBack}`,[`${g}-only`]:{position:`relative`,display:`inline-block`,height:f,transition:`all ${t.motionDurationSlow} ${t.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`,[`${n}-count, ${n}-dot, ${g}-custom-component`]:{transform:`translate(-50%, -50%)`}}}}},j=e=>{let{fontHeight:n,lineWidth:r,marginXS:i,colorBorderBg:a}=e,o=n,s=r,c=e.colorTextLightSolid,l=e.colorError,u=e.colorErrorHover;return t(e,{badgeFontHeight:o,badgeShadowSize:s,badgeTextColor:c,badgeColor:l,badgeColorHover:u,badgeShadowColor:a,badgeProcessingDuration:`1.2s`,badgeRibbonOffset:i,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}},ee=a(`Badge`,e=>A(j(e)),M),N=y.forwardRef((e,t)=>{let{prefixCls:n,scrollNumberPrefixCls:a,children:o,status:c,text:p,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:te}=l(`badge`),R=N(`badge`,n),[ne,re]=ee(R),ie={...e,overflowCount:b,size:S,dot:x,showZero:j},[z,B]=u([L,k],[te,A],{props:ie}),V=v>b?`${b}+`:v,H=V===`0`||V===0||p===`0`||p===0,ae=v===null||H&&!j,U=(m(c)||m(h))&&ae,oe=m(c)||!H,W=x&&!H,G=W?``:V,K=(0,y.useMemo)(()=>(!s(G)&&!s(p)||H&&!j)&&!W,[G,H,j,W,p]),q=(0,y.useRef)(v);K||(q.current=v);let J=q.current,Y=(0,y.useRef)(G);K||(Y.current=G);let X=Y.current,se=(0,y.useRef)(W);K||(se.current=W);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]),ce=w??(typeof J==`string`||f(J)?J:void 0),le=!K&&(p===0?j:!!p&&p!==!0),ue=le?y.createElement(`span`,{className:`${R}-status-text`},p):null,de=d(J)?g(J,e=>({style:{...Z,...e.style}})):void 0,Q=_(h,!1),fe=i(z.indicator,{[`${R}-status-dot`]:U,[`${R}-status-${c}`]:!!c,[`${R}-color-${h}`]:Q}),$={};h&&!Q&&($.color=h,$.background=h);let pe=i(R,{[`${R}-status`]:U,[`${R}-not-a-wrapper`]:!o,[`${R}-rtl`]:P===`rtl`},D,O,F,z.root,ne,re);if(!o&&U&&(p||oe||!ae)){let e=Z.color;return y.createElement(`span`,{ref:t,...M,className:pe,style:{...B.root,...Z}},y.createElement(`span`,{className:fe,style:{...B.indicator,...$}}),le&&y.createElement(`span`,{style:{color:e},className:`${R}-status-text`},p))}return y.createElement(`span`,{ref:t,...M,className:pe,style:B.root},o,y.createElement(r,{visible:!K,motionName:`${R}-zoom`,motionAppear:!1,motionDeadline:1e3},({className:e})=>{let t=N(`scroll-number`,a),n=se.current,r=i(z.indicator,{[`${R}-dot`]:n,[`${R}-count`]:!n,[`${R}-count-sm`]:S===`small`,[`${R}-multiple-words`]:!n&&X&&X.toString().length>1,[`${R}-status-${c}`]:!!c,[`${R}-color-${h}`]:Q}),o={...B.indicator,...Z};return h&&!Q&&(o||={},o.background=h),y.createElement(C,{prefixCls:t,show:!K,motionClassName:e,className:r,count:X,title:ce,style:o,key:`scrollNumber`},de)}),ue)}),P=t=>{let{antCls:n,badgeFontHeight:r,marginXS:i,badgeRibbonOffset:a,calc:o}=t,s=`${n}-ribbon`,l=`${n}-ribbon-wrapper`,u=v(t,(e,{darkColor:t})=>({[`&${s}-color-${e}`]:{background:t,color:t}}));return{[l]:{position:`relative`},[s]:{...e(t),position:`absolute`,top:i,padding:`0 ${c(t.paddingXS)}`,color:t.colorPrimary,lineHeight:c(r),whiteSpace:`nowrap`,backgroundColor:t.colorPrimary,borderRadius:t.borderRadiusSM,[`${s}-content`]:{color:t.badgeTextColor},[`${s}-corner`]:{position:`absolute`,top:`100%`,width:a,height:a,color:`currentcolor`,border:`${c(o(a).div(2).equal())} solid`,transform:t.badgeRibbonCornerTransform,transformOrigin:`top`,filter:t.badgeRibbonCornerFilter},...u,[`&${s}-placement-end`]:{insetInlineEnd:o(a).mul(-1).equal(),borderEndEndRadius:0,[`${s}-corner`]:{insetInlineEnd:0,borderInlineEndColor:`transparent`,borderBlockEndColor:`transparent`}},[`&${s}-placement-start`]:{insetInlineStart:o(a).mul(-1).equal(),borderEndStartRadius:0,[`${s}-corner`]:{insetInlineStart:0,borderBlockEndColor:`transparent`,borderInlineStartColor:`transparent`}},"&-rtl":{direction:`rtl`}}}},F=a([`Badge`,`Ribbon`],e=>P(j(e)),M),I=e=>{let{className:t,prefixCls:n,style:r,color:a,children:o,text:s,placement:c=`end`,rootClassName:d,styles:f,classNames:p}=e,{getPrefixCls:m,direction:h,className:g,style:v,classNames:b,styles:x}=l(`ribbon`),S=m(`ribbon`,n),C=`${S}-wrapper`,[w,T]=F(S,C),E={...e,placement:c},[D,O]=u([b,p],[x,f],{props:E}),k=_(a,!1),A=i(S,`${S}-placement-${c}`,{[`${S}-rtl`]:h===`rtl`,[`${S}-color-${a}`]:k},t,g,D.indicator),j={},M={};return a&&!k&&(j.background=a,M.color=a),y.createElement(`div`,{className:i(C,d,w,T,D.root),style:O.root},o,y.createElement(`div`,{className:i(A,w),style:{...j,...O.indicator,...v,...r}},y.createElement(`span`,{className:i(`${S}-content`,D.content),style:O.content},s),y.createElement(`div`,{className:`${S}-corner`,style:M})))},L=N;L.Ribbon=I;export{L as t};