1 line
4.1 KiB
JavaScript
1 line
4.1 KiB
JavaScript
import{i as e}from"./rolldown-runtime-BgaNhQyE.js";import{Ct as t,Dr as n,St as r,Tt as i,Vn as a,Wt as o,Yn as s,Zt as c,st as l,wr as u,xn as d,xt as f,zn as p}from"./jsx-runtime-CRBytmvs.js";import{n as m}from"./PlusOutlined-B8K2rG8r.js";var h=e(n()),g=e=>{let{value:n,formatter:r,precision:a,decimalSeparator:o,groupSeparator:s=``,prefixCls:c,className:l,style:u}=e,d;if(t(r))d=r(n);else{let e=String(n),t=e.match(/^(-?)(\d*)(\.(\d+))?$/);if(!t||e===`-`)d=e;else{let e=t[1],n=t[2]||`0`,r=t[4]||``;n=n.replace(/\B(?=(\d{3})+(?!\d))/g,s),i(a)&&(r=r.padEnd(a,`0`).slice(0,a>0?a:0)),r&&=`${o}${r}`,d=[h.createElement(`span`,{key:`int`,className:`${c}-content-value-int`},e,n),r&&h.createElement(`span`,{key:`decimal`,className:`${c}-content-value-decimal`},r)]}}return h.createElement(`span`,{className:l,style:u},d)},_=e=>{let{componentCls:t,marginXXS:n,padding:r,colorTextDescription:i,titleFontSize:a,colorTextHeading:o,contentFontSize:s,fontFamily:l}=e;return{[t]:{...c(e),[`${t}-header`]:{paddingBottom:n,[`${t}-title`]:{color:i,fontSize:a}},[`${t}-skeleton`]:{paddingTop:r},[`${t}-content`]:{color:o,fontSize:s,fontFamily:l,[`${t}-content-value`]:{display:`inline-block`,direction:`ltr`},[`${t}-content-prefix, ${t}-content-suffix`]:{display:`inline-block`},[`${t}-content-prefix`]:{marginInlineEnd:n},[`${t}-content-suffix`]:{marginInlineStart:n}}}}},v=o(`Statistic`,e=>_(d(e,{})),e=>{let{fontSizeHeading3:t,fontSize:n}=e;return{titleFontSize:n,contentFontSize:t}}),y=h.forwardRef((e,n)=>{let{prefixCls:i,className:o,rootClassName:c,style:l,valueStyle:u,value:d=0,title:_,valueRender:y,prefix:b,suffix:x,loading:S=!1,formatter:C,precision:w,decimalSeparator:T=`.`,groupSeparator:E=`,`,onMouseEnter:D,onMouseLeave:O,styles:k,classNames:A,...ee}=e,{getPrefixCls:j,direction:M,className:N,style:P,classNames:F,styles:I}=p(`statistic`),L=j(`statistic`,i),[R,z]=v(L),B={...e,decimalSeparator:T,groupSeparator:E,loading:S,value:d},V=r(P),H=r(l),[U,W]=f([F,A],[I,V,k,H],{props:B}),G=a(L,{[`${L}-rtl`]:M===`rtl`},N,o,c,U.root,R,z),K=a(`${L}-header`,U.header),q=a(`${L}-title`,U.title),J=a(`${L}-content`,U.content),Y=a(`${L}-content-value`,U.value),X=a(`${L}-content-prefix`,U.prefix),Z=a(`${L}-content-suffix`,U.suffix),Q=h.createElement(g,{decimalSeparator:T,groupSeparator:E,prefixCls:L,formatter:C,precision:w,value:d,className:Y,style:W.value}),$=h.useRef(null);h.useImperativeHandle(n,()=>({nativeElement:$.current}));let te=s(ee,{aria:!0,data:!0});return h.createElement(`div`,{...te,className:G,style:W.root,ref:$,onMouseEnter:D,onMouseLeave:O},_&&h.createElement(`div`,{className:K,style:W.header},h.createElement(`div`,{className:q,style:W.title},_)),h.createElement(m,{paragraph:!1,loading:S,className:`${L}-skeleton`,active:!0},h.createElement(`div`,{className:J,style:{...u,...W.content}},b&&h.createElement(`span`,{className:X,style:W.prefix},b),t(y)?y(Q):Q,x&&h.createElement(`span`,{className:Z,style:W.suffix},x))))}),b=[[`Y`,1e3*60*60*24*365],[`M`,1e3*60*60*24*30],[`D`,1e3*60*60*24],[`H`,1e3*60*60],[`m`,1e3*60],[`s`,1e3],[`S`,1]];function x(e,t){let n=e,r=/\[[^\]]*]/g,i=(t.match(r)||[]).map(e=>e.slice(1,-1)),a=t.replace(r,`[]`),o=b.reduce((e,[t,r])=>{if(e.includes(t)){let i=Math.floor(n/r);return n-=i*r,e.replace(RegExp(`${t}+`,`g`),e=>{let t=e.length;return i.toString().padStart(t,`0`)})}return e},a),s=0;return o.replace(r,()=>{let e=i[s];return s+=1,e})}function S(e,t,n){let{format:r=``}=t,i=new Date(e).getTime(),a=Date.now();return x(Math.max(n?i-a:a-i,0),r)}var C=1e3/60;function w(e){return new Date(e).getTime()}var T=e=>{let{value:t,format:n=`HH:mm:ss`,onChange:r,onFinish:i,type:a,...o}=e,s=a===`countdown`,[c,d]=h.useState(null),f=u(()=>{let e=Date.now(),n=w(t);d({});let a=s?n-e:e-n;return r?.(a),s&&n<e?(i?.(),!1):!0});h.useEffect(()=>{let e,t=()=>{f()||window.clearInterval(e)},n=()=>{e=window.setInterval(t,C)},r=()=>{window.clearInterval(e)};return n(),()=>{r()}},[t,s]),h.useEffect(()=>{d({})},[]);let p=(e,t)=>c?S(e,{...t,format:n},s):`-`,m=e=>l(e,{title:void 0});return h.createElement(y,{...o,value:t,valueRender:m,formatter:p})},E=h.memo(e=>h.createElement(T,{...e,type:`countdown`}));y.Timer=T,y.Countdown=E;var D=y;export{D as t}; |