5 lines
15 KiB
JavaScript
5 lines
15 KiB
JavaScript
import{r as s,L as v,R as de,bN as ue,dp as ee,J as ae,bx as te,ar as me,z as ge,G as pe,H as fe,bi as ye,aE as he,K as $e,a6 as Ce,ac as Se,a7 as be,b8 as ke}from"./index-B-sDl1ER.js";const xe={percent:0,prefixCls:"rc-progress",strokeColor:"#2db7f5",strokeLinecap:"round",strokeWidth:1,railColor:"#D9D9D9",railWidth:1,gapPosition:"bottom",loading:!1},Pe=()=>{const e=s.useRef([]),t=s.useRef(null);return s.useEffect(()=>{const r=Date.now();let o=!1;e.current.forEach(n=>{if(!n)return;o=!0;const a=n.style;a.transitionDuration=".3s, .3s, .3s, .06s",t.current&&r-t.current<100&&(a.transitionDuration="0s, 0s")}),o&&(t.current=Date.now())}),e.current},se=({bg:e,children:t})=>s.createElement("div",{style:{width:"100%",height:"100%",background:e}},t);function ne(e,t){return Object.keys(e).map(r=>{const o=parseFloat(r),n=`${Math.floor(o*t)}%`;return`${e[r]} ${n}`})}const Ee=s.forwardRef((e,t)=>{const{prefixCls:r,color:o,gradientId:n,radius:a,className:d,style:u,ptg:i,strokeLinecap:m,strokeWidth:$,size:g,gapDegree:l}=e,h=o&&typeof o=="object",k=h?"#FFF":void 0,E=g/2,b=s.createElement("circle",{className:v(`${r}-circle-path`,d),r:a,cx:E,cy:E,stroke:k,strokeLinecap:m,strokeWidth:$,opacity:i===0?0:1,style:u,ref:t});if(!h)return b;const w=`${n}-conic`,p=l?`${180+l/2}deg`:"0deg",C=ne(o,(360-l)/360),y=ne(o,1),f=`conic-gradient(from ${p}, ${C.join(", ")})`,x=`linear-gradient(to ${l?"bottom":"top"}, ${y.join(", ")})`;return s.createElement(s.Fragment,null,s.createElement("mask",{id:w},b),s.createElement("foreignObject",{x:0,y:0,width:g,height:g,mask:`url(#${w})`},s.createElement(se,{bg:x},s.createElement(se,{bg:f}))))}),V=100,z=(e,t,r,o,n,a,d,u,i,m,$=0)=>{const g=r/100*360*((360-a)/360),l=a===0?0:{bottom:0,top:180,left:90,right:-90}[d];let h=(100-o)/100*t;i==="round"&&o!==100&&(h+=m/2,h>=t&&(h=t-.01));const k=V/2;return{stroke:typeof u=="string"?u:void 0,strokeDasharray:`${t}px ${e}`,strokeDashoffset:h+$,transform:`rotate(${n+g+l}deg)`,transformOrigin:`${k}px ${k}px`,transition:"stroke-dashoffset .3s ease 0s, stroke-dasharray .3s ease 0s, stroke .3s, stroke-width .06s ease .3s, opacity .3s ease 0s",fillOpacity:0}},Ne=(({id:e,loading:t})=>{if(!t)return{indeterminateStyleProps:{},indeterminateStyleAnimation:null};const r=`${e}-indeterminate-animate`;return{indeterminateStyleProps:{transform:"rotate(0deg)",animation:`${r} 1s linear infinite`},indeterminateStyleAnimation:de.createElement("style",null,`@keyframes ${r} {
|
|
0% { transform: rotate(0deg); }
|
|
100% { transform: rotate(360deg); }
|
|
}`)}});function re(){return re=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e},re.apply(this,arguments)}function ie(e){const t=e??[];return Array.isArray(t)?t:[t]}const ve=e=>{const{id:t,prefixCls:r,classNames:o={},styles:n={},steps:a,strokeWidth:d,railWidth:u,gapDegree:i=0,gapPosition:m,railColor:$,strokeLinecap:g,style:l,className:h,strokeColor:k,percent:E,loading:b,...w}={...xe,...e},p=V/2,C=ue(t),y=`${C}-gradient`,f=p-d/2,x=Math.PI*2*f,P=i>0?90+i/2:-90,S=x*((360-i)/360),{count:A,gap:D}=typeof a=="object"?a:{count:a,gap:2},W=ie(E),L=ie(k),T=L.find(N=>N&&typeof N=="object"),c=T&&typeof T=="object"?"butt":g,{indeterminateStyleProps:_,indeterminateStyleAnimation:Y}=Ne({id:C,loading:b}),Z=z(x,S,0,100,P,i,m,$,c,d),O=Pe(),H=()=>{let N=0;return W.map((M,R)=>{const X=L[R]||L[L.length-1],B=z(x,S,N,M,P,i,m,X,c,d);return N+=M,s.createElement(Ee,{key:R,color:X,ptg:M,radius:f,prefixCls:r,gradientId:y,className:o.track,style:{...B,..._,...n.track},strokeLinecap:c,strokeWidth:d,gapDegree:i,ref:I=>{O[R]=I},size:V})}).reverse()},F=()=>{const N=Math.round(A*(W[0]/100)),M=100/A;let R=0;return new Array(A).fill(null).map((X,B)=>{const I=B<=N-1?L[0]:$,j=I&&typeof I=="object"?`url(#${y})`:void 0,q=z(x,S,R,M,P,i,m,I,"butt",d,D);return R+=(S-q.strokeDashoffset+D)*100/S,s.createElement("circle",{key:B,className:v(`${r}-circle-path`,o.track),r:f,cx:p,cy:p,stroke:j,strokeWidth:d,opacity:1,style:{...q,...n.track},ref:U=>{O[B]=U}})})};return s.createElement("svg",re({className:v(`${r}-circle`,o.root,h),viewBox:`0 0 ${V} ${V}`,style:{...n.root,...l},id:t,role:"presentation"},w),!A&&s.createElement("circle",{className:v(`${r}-circle-rail`,o.rail),r:f,cx:p,cy:p,stroke:$,strokeLinecap:c,strokeWidth:u||d,style:{...Z,...n.rail}}),A?F():H(),Y)};function G(e){return!e||e<0?0:e>100?100:e}function J({success:e}){let t;return e&&"percent"in e&&(t=e.percent),t}const we=({percent:e,success:t})=>{const r=G(J({success:t}));return[r,G(G(e)-r)]},Ie=({success:e={},strokeColor:t})=>{const{strokeColor:r}=e;return[r||ee.green,t||null]},Q=(e,t,r)=>{let o=-1,n=-1;if(t==="step"){const a=r.steps,d=r.strokeWidth;typeof e=="string"||typeof e>"u"?(o=e==="small"?2:14,n=d??8):typeof e=="number"?[o,n]=[e,e]:[o=14,n=8]=Array.isArray(e)?e:[e.width,e.height],o*=a}else if(t==="line"){const a=r?.strokeWidth;typeof e=="string"||typeof e>"u"?n=a||(e==="small"?6:8):typeof e=="number"?[o,n]=[e,e]:[o=-1,n=8]=Array.isArray(e)?e:[e.width,e.height]}else(t==="circle"||t==="dashboard")&&(typeof e=="string"||typeof e>"u"?[o,n]=e==="small"?[60,60]:[120,120]:typeof e=="number"?[o,n]=[e,e]:Array.isArray(e)&&(o=e[0]??e[1]??120,n=e[0]??e[1]??120));return[o,n]},Ae=3,De=e=>Ae/e*100,ce=["root","body","indicator"],Re=e=>{const{prefixCls:t,classNames:r,styles:o,railColor:n,trailColor:a,strokeLinecap:d="round",gapPosition:u,gapPlacement:i,gapDegree:m,width:$=120,type:g,children:l,success:h,size:k=$,steps:E}=e,{direction:b}=ae("progress"),w=n??a,[p,C]=Q(k,"circle");let{strokeWidth:y}=e;y===void 0&&(y=Math.max(De(p),6));const f={width:p,height:C,fontSize:p*.15+6},x=s.useMemo(()=>{if(m||m===0)return m;if(g==="dashboard")return 75},[m,g]),P=we(e),S=s.useMemo(()=>{const c=(i??u)||g==="dashboard"&&"bottom"||void 0,_=b==="rtl";switch(c){case"start":return _?"right":"left";case"end":return _?"left":"right";default:return c}},[b,i,u,g]),A=Object.prototype.toString.call(e.strokeColor)==="[object Object]",D=Ie({success:h,strokeColor:e.strokeColor}),W=v(`${t}-body`,{[`${t}-circle-gradient`]:A},r.body),L=s.createElement(ve,{steps:E,percent:E?P[1]:P,strokeWidth:y,railWidth:y,strokeColor:E?D[1]:D,strokeLinecap:d,railColor:w,prefixCls:t,gapDegree:x,gapPosition:S,classNames:te(r,ce),styles:te(o,ce)}),T=p<=20,K=s.createElement("div",{className:W,style:{...f,...o.body}},L,!T&&l);return T?s.createElement(me,{title:l},K):K},oe="--progress-line-stroke-color",Le=e=>{const t="-100%";return new ye("antProgressLTRActive",{"0%":{transform:`translateX(${t}) scaleX(0)`,opacity:.1},"20%":{transform:`translateX(${t}) scaleX(0)`,opacity:.5},to:{transform:"translateX(0) scaleX(1)",opacity:0}})},Me=e=>{const{componentCls:t,iconCls:r}=e;return{[t]:{...fe(e),display:"inline-flex","&-rtl":{direction:"rtl"},[`${t}-indicator`]:{color:e.colorText,lineHeight:1,whiteSpace:"nowrap",verticalAlign:"middle",wordBreak:"normal",[r]:{fontSize:e.fontSize}},[`&${t}-status-exception`]:{[`${t}-indicator`]:{color:e.colorError}},[`&${t}-status-success`]:{[`${t}-indicator`]:{color:e.colorSuccess}}}}},We=e=>{const{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:Le(),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)"}}}}},je=e=>{const{componentCls:t,iconCls:r}=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%)",[r]:{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"}}}},Te=e=>{const{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}}}}}},Oe=e=>{const{componentCls:t,iconCls:r}=e;return{[t]:{[`${t}-small&-line, ${t}-small&-line ${t}-indicator ${r}`]:{fontSize:e.fontSizeSM}}}},Fe=e=>({circleTextColor:e.colorText,defaultColor:e.colorInfo,remainingColor:e.colorFillSecondary,lineBorderRadius:100,circleTextFontSize:"1em",circleIconFontSize:`${e.fontSize/e.fontSizeSM}em`}),Xe=ge("Progress",e=>{const t=e.calc(e.marginXXS).div(2).equal(),r=pe(e,{progressStepMarginInlineEnd:t,progressStepMinWidth:t,progressActiveMotionDuration:"2.4s"});return[Me(r),We(r),je(r),Te(r),Oe(r)]},Fe),Be=e=>{let t=[];return Object.keys(e).forEach(r=>{const o=Number.parseFloat(r.replace(/%/g,""));Number.isNaN(o)||t.push({key:o,value:e[r]})}),t=t.sort((r,o)=>r.key-o.key),t.map(({key:r,value:o})=>`${o} ${r}%`).join(", ")},Ge=(e,t)=>{const{from:r=ee.blue,to:o=ee.blue,direction:n=t==="rtl"?"to left":"to right",...a}=e;if(Object.keys(a).length!==0){const u=Be(a),i=`linear-gradient(${n}, ${u})`;return{background:i,[oe]:i}}const d=`linear-gradient(${n}, ${r}, ${o})`;return{background:d,[oe]:d}},_e=e=>{const{prefixCls:t,classNames:r,styles:o,direction:n,percent:a,size:d,strokeWidth:u,strokeColor:i,strokeLinecap:m="round",children:$,railColor:g,trailColor:l,percentPosition:h,success:k}=e,{align:E,type:b}=h,w=g??l,p=m==="square"||m==="butt"?0:void 0,C=d??[-1,u||(d==="small"?6:8)],[y,f]=Q(C,"line",{strokeWidth:u}),x={backgroundColor:w||void 0,borderRadius:p,height:f},P=`${t}-track`,S=i&&typeof i!="string"?Ge(i,n):{[oe]:i,background:i},A={width:`${G(a)}%`,height:f,borderRadius:p,...S},D=J(e),W={width:`${G(D)}%`,height:f,borderRadius:p,backgroundColor:k?.strokeColor};return s.createElement("div",{className:v(`${t}-body`,r.body,{[`${t}-body-layout-bottom`]:E==="center"&&b==="outer"}),style:{width:y>0?y:"100%",...o.body}},s.createElement("div",{className:v(`${t}-rail`,r.rail),style:{...x,...o.rail}},s.createElement("div",{className:v(P,r.track),style:{...A,...o.track}},b==="inner"&&$),D!==void 0&&s.createElement("div",{className:v(P,`${P}-success`,r.track),style:{...W,...o.track}})),b==="outer"&&$)},He=e=>{const{classNames:t,styles:r,size:o,steps:n,rounding:a=Math.round,percent:d=0,strokeWidth:u=8,strokeColor:i,railColor:m,trailColor:$,prefixCls:g,children:l}=e,h=a(n*(d/100)),E=o??[o==="small"?2:14,u],[b,w]=Q(E,"step",{steps:n,strokeWidth:u}),p=b/n,C=Array.from({length:n}),y=m??$;for(let f=0;f<n;f++){const x=Array.isArray(i)?i[f]:i;C[f]=s.createElement("div",{key:f,className:v(`${g}-steps-item`,{[`${g}-steps-item-active`]:f<=h-1},t.track),style:{backgroundColor:f<=h-1?x:y,width:p,height:w,...r.track}})}return s.createElement("div",{className:v(`${g}-steps-body`,t.body),style:r.body},C,l)},Ke=["normal","exception","active","success"],qe=s.forwardRef((e,t)=>{const{prefixCls:r,className:o,rootClassName:n,classNames:a,styles:d,steps:u,strokeColor:i,percent:m=0,size:$="medium",showInfo:g=!0,type:l="line",status:h,format:k,style:E,percentPosition:b={},...w}=e,{align:p="end",type:C="outer"}=b,y=Array.isArray(i)?i[0]:i,f=typeof i=="string"||Array.isArray(i)?i:void 0,x=s.useMemo(()=>{if(y){const I=typeof y=="string"?y:Object.values(y)[0];return new he(I).isLight()}return!1},[i]),P=s.useMemo(()=>{const I=J(e);return Number.parseInt(I!==void 0?(I??0)?.toString():(m??0)?.toString(),10)},[m,e.success]),S=s.useMemo(()=>!Ke.includes(h)&&P>=100?"success":h||"normal",[h,P]),{getPrefixCls:A,direction:D,className:W,style:L,classNames:T,styles:K}=ae("progress"),c=A("progress",r),[_,Y]=Xe(c),Z={...e,percent:m,type:l,size:$,showInfo:g,percentPosition:b},[O,H]=$e([T,a],[K,d],{props:Z}),F=l==="line",N=F&&!u,M=s.useMemo(()=>{if(!g)return null;const I=J(e);let j;const q=k||(le=>`${le}%`),U=F&&x&&C==="inner";return C==="inner"||k||S!=="exception"&&S!=="success"?j=q(G(m),G(I)):S==="exception"?j=F?s.createElement(Ce,null):s.createElement(Se,null):S==="success"&&(j=F?s.createElement(be,null):s.createElement(ke,null)),s.createElement("span",{className:v(`${c}-indicator`,{[`${c}-indicator-bright`]:U,[`${c}-indicator-${p}`]:N,[`${c}-indicator-${C}`]:N},O.indicator),style:H.indicator,title:typeof j=="string"?j:void 0},j)},[g,m,P,S,l,c,k,F,x,C,p,N,O.indicator,H.indicator]),R={...e,classNames:O,styles:H};let X;l==="line"?X=u?s.createElement(He,{...R,strokeColor:f,prefixCls:c,steps:typeof u=="object"?u.count:u},M):s.createElement(_e,{...R,strokeColor:y,prefixCls:c,direction:D,percentPosition:{align:p,type:C}},M):(l==="circle"||l==="dashboard")&&(X=s.createElement(Re,{...R,strokeColor:y,prefixCls:c,progressStatus:S},M));const B=v(c,`${c}-status-${S}`,{[`${c}-${l==="dashboard"&&"circle"||l}`]:l!=="line",[`${c}-inline-circle`]:l==="circle"&&Q($,"circle")[0]<=20,[`${c}-line`]:N,[`${c}-line-align-${p}`]:N,[`${c}-line-position-${C}`]:N,[`${c}-steps`]:u,[`${c}-show-info`]:g,[`${c}-small`]:$==="small",[`${c}-rtl`]:D==="rtl"},W,o,n,O.root,_,Y);return s.createElement("div",{ref:t,style:{...L,...H.root,...E},className:B,role:"progressbar","aria-valuenow":P,"aria-valuemin":0,"aria-valuemax":100,...te(w,["railColor","trailColor","strokeWidth","width","gapDegree","gapPosition","gapPlacement","strokeLinecap","success"])},X)});export{qe as P};
|