Files
2026-08-31 22:21:59 +08:00

4 lines
15 KiB
JavaScript

import{i as e}from"./rolldown-runtime-BgaNhQyE.js";import{An as t,Dr as n,Et as r,St as i,Tt as a,Vn as o,Wt as s,Xn as c,Zt as l,_r as u,fn as d,mn as f,xn as p,xt as m,zn as h}from"./jsx-runtime-CRBytmvs.js";import{t as g}from"./tooltip-SaeG1Uv7.js";import{t as _}from"./CheckCircleFilled-DcF3PzkE.js";import{t as v}from"./CloseCircleFilled-C_pAsEWy.js";import{r as y}from"./PlusOutlined-B8K2rG8r.js";import{h as b}from"./style-BmYds38x.js";var x=e(n()),S={percent:0,prefixCls:`rc-progress`,strokeColor:`#2db7f5`,strokeLinecap:`round`,strokeWidth:1,railColor:`#D9D9D9`,railWidth:1,gapPosition:`bottom`,loading:!1},C=()=>{let e=(0,x.useRef)([]),t=(0,x.useRef)(null);return(0,x.useEffect)(()=>{let n=Date.now(),r=!1;e.current.forEach(e=>{if(!e)return;r=!0;let i=e.style;i.transitionDuration=`.3s, .3s, .3s, .06s`,t.current&&n-t.current<100&&(i.transitionDuration=`0s, 0s`)}),r&&(t.current=Date.now())}),e.current},w=({bg:e,children:t})=>x.createElement(`div`,{style:{width:`100%`,height:`100%`,background:e}},t);function T(e,t){return Object.keys(e).map(n=>{let r=`${Math.floor(parseFloat(n)*t)}%`;return`${e[n]} ${r}`})}var E=x.forwardRef((e,t)=>{let{prefixCls:n,color:r,gradientId:i,radius:a,className:s,style:c,ptg:l,strokeLinecap:u,strokeWidth:d,size:f,gapDegree:p}=e,m=r&&typeof r==`object`,h=m?`#FFF`:void 0,g=f/2,_=x.createElement(`circle`,{className:o(`${n}-circle-path`,s),r:a,cx:g,cy:g,stroke:h,strokeLinecap:u,strokeWidth:d,opacity:l===0?0:1,style:c,ref:t});if(!m)return _;let v=`${i}-conic`,y=p?`${180+p/2}deg`:`0deg`,b=T(r,(360-p)/360),S=T(r,1),C=`conic-gradient(from ${y}, ${b.join(`, `)})`,E=`linear-gradient(to ${p?`bottom`:`top`}, ${S.join(`, `)})`;return x.createElement(x.Fragment,null,x.createElement(`mask`,{id:v},_),x.createElement(`foreignObject`,{x:0,y:0,width:f,height:f,mask:`url(#${v})`},x.createElement(w,{bg:E},x.createElement(w,{bg:C}))))}),D=(e,t,n,r,i,a,o,s,c,l,u=0)=>{let d=n/100*360*((360-a)/360),f=a===0?0:{bottom:0,top:180,left:90,right:-90}[o],p=(100-r)/100*t;return c===`round`&&r!==100&&(p+=l/2,p>=t&&(p=t-.01)),{stroke:typeof s==`string`?s:void 0,strokeDasharray:`${t}px ${e}`,strokeDashoffset:p+u,transform:`rotate(${i+d+f}deg)`,transformOrigin:`50px 50px`,transition:`stroke-dashoffset .3s ease 0s, stroke-dasharray .3s ease 0s, stroke .3s, stroke-width .06s ease .3s, opacity .3s ease 0s`,fillOpacity:0}},O=(({id:e,loading:t})=>{if(!t)return{indeterminateStyleProps:{},indeterminateStyleAnimation:null};let n=`${e}-indeterminate-animate`;return{indeterminateStyleProps:{transform:`rotate(0deg)`,animation:`${n} 1s linear infinite`},indeterminateStyleAnimation:x.createElement(`style`,null,`@keyframes ${n} {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}`)}});function k(){return k=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},k.apply(this,arguments)}function A(e){let t=e??[];return Array.isArray(t)?t:[t]}var j=e=>{let{id:t,prefixCls:n,classNames:r={},styles:i={},steps:a,strokeWidth:s,railWidth:c,gapDegree:l=0,gapPosition:d,railColor:f,strokeLinecap:p,style:m,className:h,strokeColor:g,percent:_,loading:v,...y}={...S,...e},b=u(t),w=`${b}-gradient`,T=50-s/2,j=Math.PI*2*T,M=l>0?90+l/2:-90,N=j*((360-l)/360),{count:P,gap:F}=typeof a==`object`?a:{count:a,gap:2},I=A(_),L=A(g),R=L.find(e=>e&&typeof e==`object`),z=R&&typeof R==`object`?`butt`:p,{indeterminateStyleProps:B,indeterminateStyleAnimation:V}=O({id:b,loading:v}),H=D(j,N,0,100,M,l,d,f,z,s),U=C(),W=()=>{let e=0;return I.map((t,a)=>{let o=L[a]||L[L.length-1],c=D(j,N,e,t,M,l,d,o,z,s);return e+=t,x.createElement(E,{key:a,color:o,ptg:t,radius:T,prefixCls:n,gradientId:w,className:r.track,style:{...c,...B,...i.track},strokeLinecap:z,strokeWidth:s,gapDegree:l,ref:e=>{U[a]=e},size:100})}).reverse()},G=()=>{let e=Math.round(P*(I[0]/100)),t=100/P,a=0;return Array(P).fill(null).map((c,u)=>{let p=u<=e-1?L[0]:f,m=p&&typeof p==`object`?`url(#${w})`:void 0,h=D(j,N,a,t,M,l,d,p,`butt`,s,F);return a+=(N-h.strokeDashoffset+F)*100/N,x.createElement(`circle`,{key:u,className:o(`${n}-circle-path`,r.track),r:T,cx:50,cy:50,stroke:m,strokeWidth:s,opacity:1,style:{...h,...i.track},ref:e=>{U[u]=e}})})};return x.createElement(`svg`,k({className:o(`${n}-circle`,r.root,h),viewBox:`0 0 100 100`,style:{...i.root,...m},id:t,role:`presentation`},y),!P&&x.createElement(`circle`,{className:o(`${n}-circle-rail`,r.rail),r:T,cx:50,cy:50,stroke:f,strokeLinecap:z,strokeWidth:c||s,style:{...H,...i.rail}}),P?G():W(),V)};function M(e){return!e||e<0?0:e>100?100:e}function N({success:e}){let t;return e&&`percent`in e&&(t=e.percent),t}var P=({percent:e,success:t})=>{let n=M(N({success:t}));return[n,M(M(e)-n)]},F=({success:e={},strokeColor:t})=>{let{strokeColor:n}=e;return[n||d.green,t||null]},I=(e,t,n)=>{let r=-1,i=-1;if(t===`step`){let t=n.steps,o=n.strokeWidth;typeof e==`string`||e===void 0?(r=e===`small`?2:14,i=o??8):a(e)?[r,i]=[e,e]:[r=14,i=8]=Array.isArray(e)?e:[e.width,e.height],r*=t}else if(t===`line`){let t=n?.strokeWidth;typeof e==`string`||e===void 0?i=t||(e===`small`?6:8):a(e)?[r,i]=[e,e]:[r=-1,i=8]=Array.isArray(e)?e:[e.width,e.height]}else(t===`circle`||t===`dashboard`)&&(typeof e==`string`||e===void 0?[r,i]=e===`small`?[60,60]:[120,120]:a(e)?[r,i]=[e,e]:Array.isArray(e)&&(r=e[0]??e[1]??120,i=e[0]??e[1]??120));return[r,i]},L=3,R=e=>L/e*100,z=[`root`,`body`,`indicator`],B=e=>{let{prefixCls:t,classNames:n,styles:i,railColor:a,trailColor:s,strokeLinecap:l=`round`,gapPosition:u,gapPlacement:d,gapDegree:f,width:p=120,type:m,children:_,success:v,size:y=p,steps:b}=e,{direction:S}=h(`progress`),C=a??s,[w,T]=I(y,`circle`),{strokeWidth:E}=e;E===void 0&&(E=Math.max(R(w),6));let D={width:w,height:T,fontSize:w*.15+6},O=x.useMemo(()=>{if(f||f===0)return f;if(m===`dashboard`)return 75},[f,m]),k=P(e),A=x.useMemo(()=>{let e=(d??u)||m===`dashboard`&&`bottom`||void 0,t=S===`rtl`;switch(e){case`start`:return t?`right`:`left`;case`end`:return t?`left`:`right`;default:return e}},[S,d,u,m]),M=r(e.strokeColor),N=F({success:v,strokeColor:e.strokeColor}),L=o(`${t}-body`,{[`${t}-circle-gradient`]:M},n.body),B=x.createElement(j,{steps:b,percent:b?k[1]:k,strokeWidth:E,railWidth:E,strokeColor:b?N[1]:N,strokeLinecap:l,railColor:C,prefixCls:t,gapDegree:O,gapPosition:A,classNames:c(n,z),styles:c(i,z)}),V=w<=20,H=x.createElement(`div`,{className:L,style:{...D,...i.body}},B,!V&&_);return V?x.createElement(g,{title:_},H):H},V=`--progress-line-stroke-color`,H=e=>{let n=e?`100%`:`-100%`;return new t(`antProgress${e?`RTL`:`LTR`}Active`,{"0%":{transform:`translateX(${n}) scaleX(0)`,opacity:.1},"20%":{transform:`translateX(${n}) scaleX(0)`,opacity:.5},to:{transform:`translateX(0) scaleX(1)`,opacity:0}})},U=e=>{let{componentCls:t,iconCls:n}=e;return{[t]:{...l(e),display:`inline-flex`,"&-rtl":{direction:`rtl`},[`${t}-indicator`]:{color:e.colorText,lineHeight:1,whiteSpace:`nowrap`,verticalAlign:`middle`,wordBreak:`normal`,[n]:{fontSize:e.fontSize}},[`&${t}-status-exception`]:{[`${t}-indicator`]:{color:e.colorError}},[`&${t}-status-success`]:{[`${t}-indicator`]:{color:e.colorSuccess}}}}},W=e=>{let{componentCls:t}=e;return{[`${t}-line`]:{position:`relative`,width:`100%`,fontSize:e.fontSize,[`${t}-body`]:{display:`inline-flex`,alignItems:`center`,width:`100%`,gap:e.marginXS},[`${t}-rail`]:{flex:`auto`,background:e.remainingColor,borderRadius:e.lineBorderRadius,position:`relative`,width:`100%`,overflow:`hidden`},[`&${t}-status-active`]:{[`${t}-track:after`]:{content:`""`,position:`absolute`,inset:0,backgroundColor:e.colorBgContainer,borderRadius:`inherit`,opacity:0,animationName:H(),animationDuration:e.progressActiveMotionDuration,animationTimingFunction:e.motionEaseOutQuint,animationIterationCount:`infinite`}},[`${t}-track`]:{position:`absolute`,insetInlineStart:0,insetBlock:0,borderRadius:`inherit`,background:e.defaultColor,transition:`all ${e.motionDurationSlow} ${e.motionEaseInOutCirc}`,minWidth:`max-content`,display:`flex`,alignItems:`center`,"&-success":{background:e.colorSuccess}},[`&${t}-status-exception`]:{[`${t}-track`]:{background:e.colorError}},[`&${t}-status-success`]:{[`${t}-track`]:{background:e.colorSuccess}},[`${t}-indicator-outer`]:{[`&${t}-indicator-start`]:{order:-1}},[`${t}-body-layout-bottom`]:{flexDirection:`column`,alignItems:`center`,gap:e.marginXXS},[`${t}-indicator${t}-indicator-inner`]:{color:e.colorWhite,paddingInline:e.paddingXXS,width:`100%`,display:`flex`,justifyContent:`center`,[`&${t}-indicator-end`]:{justifyContent:`end`},[`&${t}-indicator-start`]:{justifyContent:`start`},[`&${t}-indicator-bright`]:{color:`rgba(0, 0, 0, 0.45)`}}}}},G=e=>{let{componentCls:t,iconCls:n}=e;return{[`${t}-circle`]:{[`${t}-circle-rail`]:{stroke:e.remainingColor},[`${t}-body:not(${t}-circle-gradient)`]:{[`${t}-circle-path`]:{stroke:e.defaultColor}},[`${t}-body`]:{position:`relative`,lineHeight:1,backgroundColor:`transparent`},[`${t}-indicator`]:{position:`absolute`,insetBlockStart:`50%`,insetInlineStart:0,width:`100%`,margin:0,padding:0,color:e.circleTextColor,fontSize:e.circleTextFontSize,lineHeight:1,whiteSpace:`normal`,textAlign:`center`,transform:`translateY(-50%)`,[n]:{fontSize:e.circleIconFontSize}},[`&${t}-status-exception`]:{[`${t}-body:not(${t}-circle-gradient)`]:{[`${t}-circle-path`]:{stroke:e.colorError}}},[`&${t}-status-success`]:{[`${t}-body:not(${t}-circle-gradient)`]:{[`${t}-circle-path`]:{stroke:e.colorSuccess}}}},[`${t}-inline-circle`]:{lineHeight:1,[`${t}-inner`]:{verticalAlign:`bottom`}}}},ee=e=>{let{componentCls:t}=e;return{[t]:{[`${t}-steps`]:{display:`inline-block`,"&-body":{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:e.progressStepMarginInlineEnd,[`${t}-indicator`]:{marginInlineStart:e.marginXS}},"&-item":{flexShrink:0,minWidth:e.progressStepMinWidth,backgroundColor:e.remainingColor,transition:`all ${e.motionDurationSlow}`,"&-active":{backgroundColor:e.defaultColor}}}}}},K=e=>{let{componentCls:t,iconCls:n}=e;return{[t]:{[`${t}-small&-line, ${t}-small&-line ${t}-indicator ${n}`]:{fontSize:e.fontSizeSM}}}},te=s(`Progress`,e=>{let t=e.calc(e.marginXXS).div(2).equal(),n=p(e,{progressStepMarginInlineEnd:t,progressStepMinWidth:t,progressActiveMotionDuration:`2.4s`});return[U(n),W(n),G(n),ee(n),K(n)]},e=>({circleTextColor:e.colorText,defaultColor:e.colorInfo,remainingColor:e.colorFillSecondary,lineBorderRadius:100,circleTextFontSize:`1em`,circleIconFontSize:`${e.fontSize/e.fontSizeSM}em`})),ne=e=>{let t=[];return Object.keys(e).forEach(n=>{let r=Number.parseFloat(n.replace(/%/g,``));Number.isNaN(r)||t.push({key:r,value:e[n]})}),t=t.sort((e,t)=>e.key-t.key),t.map(({key:e,value:t})=>`${t} ${e}%`).join(`, `)},re=(e,t)=>{let{from:n=d.blue,to:r=d.blue,direction:i=t===`rtl`?`to left`:`to right`,...a}=e;if(Object.keys(a).length!==0){let e=`linear-gradient(${i}, ${ne(a)})`;return{background:e,[V]:e}}let o=`linear-gradient(${i}, ${n}, ${r})`;return{background:o,[V]:o}},ie=e=>{let{prefixCls:t,classNames:n,styles:r,direction:i,percent:a,size:s,strokeWidth:c,strokeColor:l,strokeLinecap:u=`round`,children:d,railColor:f,trailColor:p,percentPosition:m,success:h}=e,{align:g,type:_}=m,v=f??p,y=u===`square`||u===`butt`?0:void 0,[b,S]=I(s??[-1,c||(s===`small`?6:8)],`line`,{strokeWidth:c}),C={backgroundColor:v||void 0,borderRadius:y,height:S},w=`${t}-track`,T=l&&typeof l!=`string`?re(l,i):{[V]:l,background:l},E={width:`${M(a)}%`,height:S,borderRadius:y,...T},D=N(e),O={width:`${M(D)}%`,height:S,borderRadius:y,backgroundColor:h?.strokeColor};return x.createElement(`div`,{className:o(`${t}-body`,n.body,{[`${t}-body-layout-bottom`]:g===`center`&&_===`outer`}),style:{width:b>0?b:`100%`,...r.body}},x.createElement(`div`,{className:o(`${t}-rail`,n.rail),style:{...C,...r.rail}},x.createElement(`div`,{className:o(w,n.track),style:{...E,...r.track}},_===`inner`&&d),D!==void 0&&x.createElement(`div`,{className:o(w,`${w}-success`,n.track),style:{...O,...r.track}})),_===`outer`&&d)},ae=e=>{let{classNames:t,styles:n,size:r,steps:i,rounding:a=Math.round,percent:s=0,strokeWidth:c=8,strokeColor:l,railColor:u,trailColor:d,prefixCls:f,children:p}=e,m=a(s/100*i),[h,g]=I(r??[r===`small`?2:14,c],`step`,{steps:i,strokeWidth:c}),_=h/i,v=Array.from({length:i}),y=u??d;for(let e=0;e<i;e++){let r=Array.isArray(l)?l[e]:l;v[e]=x.createElement(`div`,{key:e,className:o(`${f}-steps-item`,{[`${f}-steps-item-active`]:e<=m-1},t.track),style:{backgroundColor:e<=m-1?r:y,width:_,height:g,...n.track}})}return x.createElement(`div`,{className:o(`${f}-steps-body`,t.body),style:n.body},v,p)},oe=[`normal`,`exception`,`active`,`success`],se=x.forwardRef((e,t)=>{let{prefixCls:n,className:a,rootClassName:s,classNames:l,styles:u,steps:d,strokeColor:p,percent:g=0,size:S=`medium`,showInfo:C=!0,type:w=`line`,status:T,format:E,style:D,percentPosition:O={},...k}=e,{align:A=`end`,type:j=`outer`}=O,P=Array.isArray(p)?p[0]:p,F=typeof p==`string`||Array.isArray(p)?p:void 0,L=x.useMemo(()=>P?new f(typeof P==`string`?P:Object.values(P)[0]).isLight():!1,[p]),R=x.useMemo(()=>{let t=N(e);return Number.parseInt(t===void 0?(g??0)?.toString():(t??0)?.toString(),10)},[g,e.success]),z=x.useMemo(()=>!oe.includes(T)&&R>=100?`success`:T||`normal`,[T,R]),{getPrefixCls:V,direction:H,className:U,style:W,classNames:G,styles:ee}=h(`progress`),K=V(`progress`,n),[ne,re]=te(K),se={...e,percent:g,type:w,size:S,showInfo:C,percentPosition:O},ce=i(W),le=i(D),[q,J]=m([G,l],[ee,ce,u,le],{props:se}),Y=w===`line`,X=Y&&!d,Z=x.useMemo(()=>{if(!C)return null;let t=N(e),n,r=E||(e=>`${e}%`),i=Y&&L&&j===`inner`;return j===`inner`||E||z!==`exception`&&z!==`success`?n=r(M(g),M(t)):z===`exception`?n=Y?x.createElement(v,null):x.createElement(y,null):z===`success`&&(n=Y?x.createElement(_,null):x.createElement(b,null)),x.createElement(`span`,{className:o(`${K}-indicator`,{[`${K}-indicator-bright`]:i,[`${K}-indicator-${A}`]:X,[`${K}-indicator-${j}`]:X},q.indicator),style:J.indicator,title:typeof n==`string`?n:void 0},n)},[C,g,R,z,w,K,E,Y,L,j,A,X,q.indicator,J.indicator]),Q={...e,classNames:q,styles:J},$;w===`line`?$=d?x.createElement(ae,{...Q,strokeColor:F,prefixCls:K,steps:r(d)?d.count:d},Z):x.createElement(ie,{...Q,strokeColor:P,prefixCls:K,direction:H,percentPosition:{align:A,type:j}},Z):(w===`circle`||w===`dashboard`)&&($=x.createElement(B,{...Q,strokeColor:P,prefixCls:K,progressStatus:z},Z));let ue=o(K,`${K}-status-${z}`,{[`${K}-${w===`dashboard`&&`circle`||w}`]:w!==`line`,[`${K}-inline-circle`]:w===`circle`&&I(S,`circle`)[0]<=20,[`${K}-line`]:X,[`${K}-line-align-${A}`]:X,[`${K}-line-position-${j}`]:X,[`${K}-steps`]:d,[`${K}-show-info`]:C,[`${K}-small`]:S===`small`,[`${K}-rtl`]:H===`rtl`},U,a,s,q.root,ne,re);return x.createElement(`div`,{ref:t,style:J.root,className:ue,role:`progressbar`,"aria-valuenow":R,"aria-valuemin":0,"aria-valuemax":100,...c(k,[`railColor`,`trailColor`,`strokeWidth`,`width`,`gapDegree`,`gapPosition`,`gapPlacement`,`strokeLinecap`,`success`])},$)});export{se as t};