badge-CFbskMgu.js 12 KB

1
  1. import{a as e,n as t}from"./react-dom-stZKkA6x.js";import{Dn as n,I as r,Mn as i,Nr as a,Zn as o,bn as s,er as c,un as l,vn as u,xn as d,zn as f}from"./jsx-runtime-C5RSiriy.js";var p=e(t()),m=e(a()),h=new o(`antStatusProcessing`,{"0%":{transform:`scale(0.8)`,opacity:.5},"100%":{transform:`scale(2.4)`,opacity:0}}),g=new o(`antZoomBadgeIn`,{"0%":{transform:`scale(0) translate(50%, -50%)`,opacity:0},"100%":{transform:`scale(1) translate(50%, -50%)`}}),_=new o(`antZoomBadgeOut`,{"0%":{transform:`scale(1) translate(50%, -50%)`},"100%":{transform:`scale(0) translate(50%, -50%)`,opacity:0}}),v=new o(`antNoWrapperZoomBadgeIn`,{"0%":{transform:`scale(0)`,opacity:0},"100%":{transform:`scale(1)`}}),y=new o(`antNoWrapperZoomBadgeOut`,{"0%":{transform:`scale(1)`},"100%":{transform:`scale(0)`,opacity:0}}),b=new o(`antBadgeLoadingCircle`,{"0%":{transformOrigin:`50%`},"100%":{transform:`translate(50%, -50%) rotate(360deg)`,transformOrigin:`50%`}}),x=e=>{let{componentCls:t,iconCls:r,antCls:i,badgeShadowSize:a,textFontSize:o,textFontSizeSM:l,statusSize:u,dotSize:d,textFontWeight:f,indicatorHeight:p,indicatorHeightSM:m,marginXS:x,calc:S}=e,C=`${i}-scroll-number`,w=s(e,(e,{darkColor:n})=>({[`&${t} ${t}-color-${e}`]:{background:n,[`&:not(${t}-count)`]:{color:n},"a:hover &":{background:n}}}));return{[t]:Object.assign(Object.assign(Object.assign(Object.assign({},n(e)),{position:`relative`,display:`inline-block`,width:`fit-content`,lineHeight:1,[`${t}-count`]:{display:`inline-flex`,justifyContent:`center`,zIndex:e.indicatorZIndex,minWidth:p,height:p,color:e.badgeTextColor,fontWeight:f,fontSize:o,lineHeight:c(p),whiteSpace:`nowrap`,textAlign:`center`,background:e.badgeColor,borderRadius:S(p).div(2).equal(),boxShadow:`0 0 0 ${c(a)} ${e.badgeShadowColor}`,transition:`background ${e.motionDurationMid}`,a:{color:e.badgeTextColor},"a:hover":{color:e.badgeTextColor},"a:hover &":{background:e.badgeColorHover}},[`${t}-count-sm`]:{minWidth:m,height:m,fontSize:l,lineHeight:c(m),borderRadius:S(m).div(2).equal()},[`${t}-multiple-words`]:{padding:`0 ${c(e.paddingXS)}`,bdi:{unicodeBidi:`plaintext`}},[`${t}-dot`]:{zIndex:e.indicatorZIndex,width:d,minWidth:d,height:d,background:e.badgeColor,borderRadius:`100%`,boxShadow:`0 0 0 ${c(a)} ${e.badgeShadowColor}`},[`${t}-count, ${t}-dot, ${C}-custom-component`]:{position:`absolute`,top:0,insetInlineEnd:0,transform:`translate(50%, -50%)`,transformOrigin:`100% 0%`,[`&${r}-spin`]:{animationName:b,animationDuration:`1s`,animationIterationCount:`infinite`,animationTimingFunction:`linear`}},[`&${t}-status`]:{lineHeight:`inherit`,verticalAlign:`baseline`,[`${t}-status-dot`]:{position:`relative`,top:-1,display:`inline-block`,width:u,height:u,verticalAlign:`middle`,borderRadius:`50%`},[`${t}-status-success`]:{backgroundColor:e.colorSuccess},[`${t}-status-processing`]:{overflow:`visible`,color:e.colorInfo,backgroundColor:e.colorInfo,borderColor:`currentcolor`,"&::after":{position:`absolute`,top:0,insetInlineStart:0,width:`100%`,height:`100%`,borderWidth:a,borderStyle:`solid`,borderColor:`inherit`,borderRadius:`50%`,animationName:h,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:x,color:e.colorText,fontSize:e.fontSize}}}),w),{[`${t}-zoom-appear, ${t}-zoom-enter`]:{animationName:g,animationDuration:e.motionDurationSlow,animationTimingFunction:e.motionEaseOutBack,animationFillMode:`both`},[`${t}-zoom-leave`]:{animationName:_,animationDuration:e.motionDurationSlow,animationTimingFunction:e.motionEaseOutBack,animationFillMode:`both`},[`&${t}-not-a-wrapper`]:{[`${t}-zoom-appear, ${t}-zoom-enter`]:{animationName:v,animationDuration:e.motionDurationSlow,animationTimingFunction:e.motionEaseOutBack},[`${t}-zoom-leave`]:{animationName:y,animationDuration:e.motionDurationSlow,animationTimingFunction:e.motionEaseOutBack},[`&:not(${t}-status)`]:{verticalAlign:`middle`},[`${C}-custom-component, ${t}-count`]:{transform:`none`},[`${C}-custom-component, ${C}`]:{position:`relative`,top:`auto`,display:`block`,transformOrigin:`50% 50%`}},[C]:{overflow:`hidden`,transition:`all ${e.motionDurationMid} ${e.motionEaseOutBack}`,[`${C}-only`]:{position:`relative`,display:`inline-block`,height:p,transition:`all ${e.motionDurationSlow} ${e.motionEaseOutBack}`,WebkitTransformStyle:`preserve-3d`,WebkitBackfaceVisibility:`hidden`,[`> p${C}-only-unit`]:{height:p,margin:0,WebkitTransformStyle:`preserve-3d`,WebkitBackfaceVisibility:`hidden`}},[`${C}-symbol`]:{verticalAlign:`top`}},"&-rtl":{direction:`rtl`,[`${t}-count, ${t}-dot, ${C}-custom-component`]:{transform:`translate(-50%, -50%)`}}})}},S=e=>{let{fontHeight:t,lineWidth:n,marginXS:r,colorBorderBg:a}=e,o=t,s=n,c=e.colorTextLightSolid,l=e.colorError,u=e.colorErrorHover;return i(e,{badgeFontHeight:o,badgeShadowSize:s,badgeTextColor:c,badgeColor:l,badgeColorHover:u,badgeShadowColor:a,badgeProcessingDuration:`1.2s`,badgeRibbonOffset:r,badgeRibbonCornerTransform:`scaleY(0.75)`,badgeRibbonCornerFilter:`brightness(75%)`})},C=e=>{let{fontSize:t,lineHeight:n,fontSizeSM:r,lineWidth:i}=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}},w=d(`Badge`,e=>x(S(e)),C),T=e=>{let{antCls:t,badgeFontHeight:r,marginXS:i,badgeRibbonOffset:a,calc:o}=e,l=`${t}-ribbon`,u=`${t}-ribbon-wrapper`,d=s(e,(e,{darkColor:t})=>({[`&${l}-color-${e}`]:{background:t,color:t}}));return{[u]:{position:`relative`},[l]:Object.assign(Object.assign(Object.assign(Object.assign({},n(e)),{position:`absolute`,top:i,padding:`0 ${c(e.paddingXS)}`,color:e.colorPrimary,lineHeight:c(r),whiteSpace:`nowrap`,backgroundColor:e.colorPrimary,borderRadius:e.borderRadiusSM,[`${l}-text`]:{color:e.badgeTextColor},[`${l}-corner`]:{position:`absolute`,top:`100%`,width:a,height:a,color:`currentcolor`,border:`${c(o(a).div(2).equal())} solid`,transform:e.badgeRibbonCornerTransform,transformOrigin:`top`,filter:e.badgeRibbonCornerFilter}}),d),{[`&${l}-placement-end`]:{insetInlineEnd:o(a).mul(-1).equal(),borderEndEndRadius:0,[`${l}-corner`]:{insetInlineEnd:0,borderInlineEndColor:`transparent`,borderBlockEndColor:`transparent`}},[`&${l}-placement-start`]:{insetInlineStart:o(a).mul(-1).equal(),borderEndStartRadius:0,[`${l}-corner`]:{insetInlineStart:0,borderBlockEndColor:`transparent`,borderInlineStartColor:`transparent`}},"&-rtl":{direction:`rtl`}})}},E=d([`Badge`,`Ribbon`],e=>T(S(e)),C),D=e=>{let{className:t,prefixCls:n,style:i,color:a,children:o,text:s,placement:c=`end`,rootClassName:l}=e,{getPrefixCls:u,direction:d}=p.useContext(f),h=u(`ribbon`,n),g=`${h}-wrapper`,[_,v,y]=E(h,g),b=r(a,!1),x=(0,m.default)(h,`${h}-placement-${c}`,{[`${h}-rtl`]:d===`rtl`,[`${h}-color-${a}`]:b},t),S={},C={};return a&&!b&&(S.background=a,C.color=a),_(p.createElement(`div`,{className:(0,m.default)(g,l,v,y)},o,p.createElement(`div`,{className:(0,m.default)(x,v),style:Object.assign(Object.assign({},S),i)},p.createElement(`span`,{className:`${h}-text`},s),p.createElement(`div`,{className:`${h}-corner`,style:C}))))},O=e=>{let{prefixCls:t,value:n,current:r,offset:i=0}=e,a;return i&&(a={position:`absolute`,top:`${i}00%`,left:0}),p.createElement(`span`,{style:a,className:(0,m.default)(`${t}-only-unit`,{current:r})},n)};function k(e,t,n){let r=e,i=0;for(;(r+10)%10!==t;)r+=n,i+=n;return i}var A=e=>{let{prefixCls:t,count:n,value:r}=e,i=Number(r),a=Math.abs(n),[o,s]=p.useState(i),[c,l]=p.useState(a),u=()=>{s(i),l(a)};p.useEffect(()=>{let e=setTimeout(u,1e3);return()=>clearTimeout(e)},[i]);let d,f;if(o===i||Number.isNaN(i)||Number.isNaN(o))d=[p.createElement(O,Object.assign({},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 p.createElement(O,Object.assign({},e,{key:t,value:i,offset:r<0?n-s:n,current:n===s}))}),f={transform:`translateY(${-k(o,i,r)}00%)`}}return p.createElement(`span`,{className:`${t}-only`,style:f,onTransitionEnd:u},d)},j=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n},ee=p.forwardRef((e,t)=>{let{prefixCls:n,count:r,className:i,motionClassName:a,style:o,title:s,show:c,component:u=`sup`,children:d}=e,h=j(e,[`prefixCls`,`count`,`className`,`motionClassName`,`style`,`title`,`show`,`component`,`children`]),{getPrefixCls:g}=p.useContext(f),_=g(`scroll-number`,n),v=Object.assign(Object.assign({},h),{"data-show":c,style:o,className:(0,m.default)(_,i,a),title:s}),y=r;if(r&&Number(r)%1==0){let e=String(r).split(``);y=p.createElement(`bdi`,null,e.map((t,n)=>p.createElement(A,{prefixCls:_,count:Number(r),value:t,key:e.length-n})))}return o?.borderColor&&(v.style=Object.assign(Object.assign({},o),{boxShadow:`0 0 0 1px ${o.borderColor} inset`})),d?l(d,e=>({className:(0,m.default)(`${_}-custom-component`,e?.className,a)})):p.createElement(u,Object.assign({},v,{ref:t}),y)}),M=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n},N=p.forwardRef((e,t)=>{let{prefixCls:n,scrollNumberPrefixCls:i,children:a,status:o,text:s,color:c,count:d=null,overflowCount:h=99,dot:g=!1,size:_=`default`,title:v,offset:y,style:b,className:x,rootClassName:S,classNames:C,styles:T,showZero:E=!1}=e,D=M(e,[`prefixCls`,`scrollNumberPrefixCls`,`children`,`status`,`text`,`color`,`count`,`overflowCount`,`dot`,`size`,`title`,`offset`,`style`,`className`,`rootClassName`,`classNames`,`styles`,`showZero`]),{getPrefixCls:O,direction:k,badge:A}=p.useContext(f),j=O(`badge`,n),[N,P,F]=w(j),I=d>h?`${h}+`:d,L=I===`0`||I===0||s===`0`||s===0,R=d===null||L&&!E,z=(o!=null||c!=null)&&R,B=o!=null||!L,V=g&&!L,H=V?``:I,U=(0,p.useMemo)(()=>((H==null||H===``)&&(s==null||s===``)||L&&!E)&&!V,[H,L,E,V,s]),W=(0,p.useRef)(d);U||(W.current=d);let G=W.current,K=(0,p.useRef)(H);U||(K.current=H);let q=K.current,J=(0,p.useRef)(V);U||(J.current=V);let Y=(0,p.useMemo)(()=>{if(!y)return Object.assign(Object.assign({},A?.style),b);let e={marginTop:y[1]};return k===`rtl`?e.left=Number.parseInt(y[0],10):e.right=-Number.parseInt(y[0],10),Object.assign(Object.assign(Object.assign({},e),A?.style),b)},[k,y,b,A?.style]),te=v??(typeof G==`string`||typeof G==`number`?G:void 0),X=!U&&(s===0?E:!!s&&s!==!0),ne=X?p.createElement(`span`,{className:`${j}-status-text`},s):null,re=!G||typeof G!=`object`?void 0:l(G,e=>({style:Object.assign(Object.assign({},Y),e.style)})),Z=r(c,!1),ie=(0,m.default)(C?.indicator,A?.classNames?.indicator,{[`${j}-status-dot`]:z,[`${j}-status-${o}`]:!!o,[`${j}-color-${c}`]:Z}),Q={};c&&!Z&&(Q.color=c,Q.background=c);let $=(0,m.default)(j,{[`${j}-status`]:z,[`${j}-not-a-wrapper`]:!a,[`${j}-rtl`]:k===`rtl`},x,S,A?.className,A?.classNames?.root,C?.root,P,F);if(!a&&z&&(s||B||!R)){let e=Y.color;return N(p.createElement(`span`,Object.assign({},D,{className:$,style:Object.assign(Object.assign(Object.assign({},T?.root),A?.styles?.root),Y)}),p.createElement(`span`,{className:ie,style:Object.assign(Object.assign(Object.assign({},T?.indicator),A?.styles?.indicator),Q)}),X&&p.createElement(`span`,{style:{color:e},className:`${j}-status-text`},s)))}return N(p.createElement(`span`,Object.assign({ref:t},D,{className:$,style:Object.assign(Object.assign({},A?.styles?.root),T?.root)}),a,p.createElement(u,{visible:!U,motionName:`${j}-zoom`,motionAppear:!1,motionDeadline:1e3},({className:e})=>{let t=O(`scroll-number`,i),n=J.current,r=(0,m.default)(C?.indicator,A?.classNames?.indicator,{[`${j}-dot`]:n,[`${j}-count`]:!n,[`${j}-count-sm`]:_===`small`,[`${j}-multiple-words`]:!n&&q&&q.toString().length>1,[`${j}-status-${o}`]:!!o,[`${j}-color-${c}`]:Z}),a=Object.assign(Object.assign(Object.assign({},T?.indicator),A?.styles?.indicator),Y);return c&&!Z&&(a||={},a.background=c),p.createElement(ee,{prefixCls:t,show:!U,motionClassName:e,className:r,count:q,title:te,style:a,key:`scrollNumber`},re)}),ne))});N.Ribbon=D;export{N as t};