mirror of
https://github.com/Safe3/openresty-manager.git
synced 2025-10-04 22:01:52 +08:00
3 lines
15 KiB
JavaScript
3 lines
15 KiB
JavaScript
import{A as w,x as X,o as H,z as A,q as z,s as K,ay as V,aB as W,d as I,j as x,n as u,c as g,O as B,_ as $,r as F,aC as Y,l as E,a7 as q,h as Q,m as U,k as J,av as Z,u as ee,ac as te,aD as re,ab as oe,B as se}from"./index-sY8U2mN5.js";import{C as ne}from"./index-ByZ25-ct.js";import{u as le}from"./useRefs-BdmXd5te.js";const ie=["normal","exception","active","success"],_=()=>({prefixCls:String,type:w(),percent:Number,format:K(),status:w(),showInfo:z(),strokeWidth:Number,strokeLinecap:w(),strokeColor:A(),trailColor:String,width:Number,success:H(),gapDegree:Number,gapPosition:w(),size:X([String,Number,Array]),steps:Number,successPercent:Number,title:String,progressStatus:w()});function P(e){return!e||e<0?0:e>100?100:e}function D(e){let{success:t,successPercent:o}=e,r=o;return t&&"progress"in t&&(V(!1,"Progress","`success.progress` is deprecated. Please use `success.percent` instead."),r=t.progress),t&&"percent"in t&&(r=t.percent),r}function ae(e){let{percent:t,success:o,successPercent:r}=e;const s=P(D({success:o,successPercent:r}));return[s,P(P(t)-s)]}function ce(e){let{success:t={},strokeColor:o}=e;const{strokeColor:r}=t;return[r||W.green,o||null]}const j=(e,t,o)=>{var r,s,f,l;let n=-1,i=-1;if(t==="step"){const h=o.steps,d=o.strokeWidth;typeof e=="string"||typeof e>"u"?(n=e==="small"?2:14,i=d??8):typeof e=="number"?[n,i]=[e,e]:[n=14,i=8]=e,n*=h}else if(t==="line"){const h=o==null?void 0:o.strokeWidth;typeof e=="string"||typeof e>"u"?i=h||(e==="small"?6:8):typeof e=="number"?[n,i]=[e,e]:[n=-1,i=8]=e}else(t==="circle"||t==="dashboard")&&(typeof e=="string"||typeof e>"u"?[n,i]=e==="small"?[60,60]:[120,120]:typeof e=="number"?[n,i]=[e,e]:(n=(s=(r=e[0])!==null&&r!==void 0?r:e[1])!==null&&s!==void 0?s:120,i=(l=(f=e[0])!==null&&f!==void 0?f:e[1])!==null&&l!==void 0?l:120));return{width:n,height:i}};var ue=function(e,t){var o={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(o[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(e);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(o[r[s]]=e[r[s]]);return o};const de=()=>x(x({},_()),{strokeColor:A(),direction:w()}),ge=e=>{let t=[];return Object.keys(e).forEach(o=>{const r=parseFloat(o.replace(/%/g,""));isNaN(r)||t.push({key:r,value:e[o]})}),t=t.sort((o,r)=>o.key-r.key),t.map(o=>{let{key:r,value:s}=o;return`${s} ${r}%`}).join(", ")},pe=(e,t)=>{const{from:o=W.blue,to:r=W.blue,direction:s=t==="rtl"?"to left":"to right"}=e,f=ue(e,["from","to","direction"]);if(Object.keys(f).length!==0){const l=ge(f);return{backgroundImage:`linear-gradient(${s}, ${l})`}}return{backgroundImage:`linear-gradient(${s}, ${o}, ${r})`}},fe=I({compatConfig:{MODE:3},name:"ProgressLine",inheritAttrs:!1,props:de(),setup(e,t){let{slots:o,attrs:r}=t;const s=u(()=>{const{strokeColor:a,direction:p}=e;return a&&typeof a!="string"?pe(a,p):{backgroundColor:a}}),f=u(()=>e.strokeLinecap==="square"||e.strokeLinecap==="butt"?0:void 0),l=u(()=>e.trailColor?{backgroundColor:e.trailColor}:void 0),n=u(()=>{var a;return(a=e.size)!==null&&a!==void 0?a:[-1,e.strokeWidth||(e.size==="small"?6:8)]}),i=u(()=>j(n.value,"line",{strokeWidth:e.strokeWidth})),h=u(()=>{const{percent:a}=e;return x({width:`${P(a)}%`,height:`${i.value.height}px`,borderRadius:f.value},s.value)}),d=u(()=>D(e)),y=u(()=>{const{success:a}=e;return{width:`${P(d.value)}%`,height:`${i.value.height}px`,borderRadius:f.value,backgroundColor:a==null?void 0:a.strokeColor}}),v={width:i.value.width<0?"100%":i.value.width,height:`${i.value.height}px`};return()=>{var a;return g(B,null,[g("div",$($({},r),{},{class:[`${e.prefixCls}-outer`,r.class],style:[r.style,v]}),[g("div",{class:`${e.prefixCls}-inner`,style:l.value},[g("div",{class:`${e.prefixCls}-bg`,style:h.value},null),d.value!==void 0?g("div",{class:`${e.prefixCls}-success-bg`,style:y.value},null):null])]),(a=o.default)===null||a===void 0?void 0:a.call(o)])}}}),ve={percent:0,prefixCls:"vc-progress",strokeColor:"#2db7f5",strokeLinecap:"round",strokeWidth:1,trailColor:"#D9D9D9",trailWidth:1},he=e=>{const t=F(null);return Y(()=>{const o=Date.now();let r=!1;e.value.forEach(s=>{const f=(s==null?void 0:s.$el)||s;if(!f)return;r=!0;const l=f.style;l.transitionDuration=".3s, .3s, .3s, .06s",t.value&&o-t.value<100&&(l.transitionDuration="0s, 0s")}),r&&(t.value=Date.now())}),e},me={gapDegree:Number,gapPosition:{type:String},percent:{type:[Array,Number]},prefixCls:String,strokeColor:{type:[Object,String,Array]},strokeLinecap:{type:String},strokeWidth:Number,trailColor:String,trailWidth:Number,transition:String};var Ce=function(e,t){var o={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(o[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(e);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(o[r[s]]=e[r[s]]);return o};let N=0;function R(e){return+e.replace("%","")}function M(e){return Array.isArray(e)?e:[e]}function T(e,t,o,r){let s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0,f=arguments.length>5?arguments[5]:void 0;const l=50-r/2;let n=0,i=-l,h=0,d=-2*l;switch(f){case"left":n=-l,i=0,h=2*l,d=0;break;case"right":n=l,i=0,h=-2*l,d=0;break;case"bottom":i=l,d=2*l;break}const y=`M 50,50 m ${n},${i}
|
|
a ${l},${l} 0 1 1 ${h},${-d}
|
|
a ${l},${l} 0 1 1 ${-h},${d}`,v=Math.PI*2*l,a={stroke:o,strokeDasharray:`${t/100*(v-s)}px ${v}px`,strokeDashoffset:`-${s/2+e/100*(v-s)}px`,transition:"stroke-dashoffset .3s ease 0s, stroke-dasharray .3s ease 0s, stroke .3s, stroke-width .06s ease .3s, opacity .3s ease 0s"};return{pathString:y,pathStyle:a}}const ye=I({compatConfig:{MODE:3},name:"VCCircle",props:E(me,ve),setup(e){N+=1;const t=F(N),o=u(()=>M(e.percent)),r=u(()=>M(e.strokeColor)),[s,f]=le();he(f);const l=()=>{const{prefixCls:n,strokeWidth:i,strokeLinecap:h,gapDegree:d,gapPosition:y}=e;let v=0;return o.value.map((a,p)=>{const c=r.value[p]||r.value[r.value.length-1],b=Object.prototype.toString.call(c)==="[object Object]"?`url(#${n}-gradient-${t.value})`:"",{pathString:C,pathStyle:S}=T(v,a,c,i,d,y);v+=a;const k={key:p,d:C,stroke:b,"stroke-linecap":h,"stroke-width":i,opacity:a===0?0:1,"fill-opacity":"0",class:`${n}-circle-path`,style:S};return g("path",$({ref:s(p)},k),null)})};return()=>{const{prefixCls:n,strokeWidth:i,trailWidth:h,gapDegree:d,gapPosition:y,trailColor:v,strokeLinecap:a,strokeColor:p}=e,c=Ce(e,["prefixCls","strokeWidth","trailWidth","gapDegree","gapPosition","trailColor","strokeLinecap","strokeColor"]),{pathString:b,pathStyle:C}=T(0,100,v,i,d,y);delete c.percent;const S=r.value.find(m=>Object.prototype.toString.call(m)==="[object Object]"),k={d:b,stroke:v,"stroke-linecap":a,"stroke-width":h||i,"fill-opacity":"0",class:`${n}-circle-trail`,style:C};return g("svg",$({class:`${n}-circle`,viewBox:"0 0 100 100"},c),[S&&g("defs",null,[g("linearGradient",{id:`${n}-gradient-${t.value}`,x1:"100%",y1:"0%",x2:"0%",y2:"0%"},[Object.keys(S).sort((m,O)=>R(m)-R(O)).map((m,O)=>g("stop",{key:O,offset:m,"stop-color":S[m]},null))])]),g("path",k,null),l().reverse()])}}}),be=()=>x(x({},_()),{strokeColor:A()}),$e=3,Se=e=>$e/e*100,ke=I({compatConfig:{MODE:3},name:"ProgressCircle",inheritAttrs:!1,props:E(be(),{trailColor:null}),setup(e,t){let{slots:o,attrs:r}=t;const s=u(()=>{var c;return(c=e.width)!==null&&c!==void 0?c:120}),f=u(()=>{var c;return(c=e.size)!==null&&c!==void 0?c:[s.value,s.value]}),l=u(()=>j(f.value,"circle")),n=u(()=>{if(e.gapDegree||e.gapDegree===0)return e.gapDegree;if(e.type==="dashboard")return 75}),i=u(()=>({width:`${l.value.width}px`,height:`${l.value.height}px`,fontSize:`${l.value.width*.15+6}px`})),h=u(()=>{var c;return(c=e.strokeWidth)!==null&&c!==void 0?c:Math.max(Se(l.value.width),6)}),d=u(()=>e.gapPosition||e.type==="dashboard"&&"bottom"||void 0),y=u(()=>ae(e)),v=u(()=>Object.prototype.toString.call(e.strokeColor)==="[object Object]"),a=u(()=>ce({success:e.success,strokeColor:e.strokeColor})),p=u(()=>({[`${e.prefixCls}-inner`]:!0,[`${e.prefixCls}-circle-gradient`]:v.value}));return()=>{var c;const b=g(ye,{percent:y.value,strokeWidth:h.value,trailWidth:h.value,strokeColor:a.value,strokeLinecap:e.strokeLinecap,trailColor:e.trailColor,prefixCls:e.prefixCls,gapDegree:n.value,gapPosition:d.value},null);return g("div",$($({},r),{},{class:[p.value,r.class],style:[r.style,i.value]}),[l.value.width<=20?g(q,null,{default:()=>[g("span",null,[b])],title:o.default}):g(B,null,[b,(c=o.default)===null||c===void 0?void 0:c.call(o)])])}}}),xe=()=>x(x({},_()),{steps:Number,strokeColor:X(),trailColor:String}),Pe=I({compatConfig:{MODE:3},name:"Steps",props:xe(),setup(e,t){let{slots:o}=t;const r=u(()=>Math.round(e.steps*((e.percent||0)/100))),s=u(()=>{var n;return(n=e.size)!==null&&n!==void 0?n:[e.size==="small"?2:14,e.strokeWidth||8]}),f=u(()=>j(s.value,"step",{steps:e.steps,strokeWidth:e.strokeWidth||8})),l=u(()=>{const{steps:n,strokeColor:i,trailColor:h,prefixCls:d}=e,y=[];for(let v=0;v<n;v+=1){const a=Array.isArray(i)?i[v]:i,p={[`${d}-steps-item`]:!0,[`${d}-steps-item-active`]:v<=r.value-1};y.push(g("div",{key:v,class:p,style:{backgroundColor:v<=r.value-1?a:h,width:`${f.value.width/n}px`,height:`${f.value.height}px`}},null))}return y});return()=>{var n;return g("div",{class:`${e.prefixCls}-steps-outer`},[l.value,(n=o.default)===null||n===void 0?void 0:n.call(o)])}}}),we=new Z("antProgressActive",{"0%":{transform:"translateX(-100%) scaleX(0)",opacity:.1},"20%":{transform:"translateX(-100%) scaleX(0)",opacity:.5},to:{transform:"translateX(0) scaleX(1)",opacity:0}}),Oe=e=>{const{componentCls:t,iconCls:o}=e;return{[t]:x(x({},J(e)),{display:"inline-block","&-rtl":{direction:"rtl"},"&-line":{position:"relative",width:"100%",fontSize:e.fontSize,marginInlineEnd:e.marginXS,marginBottom:e.marginXS},[`${t}-outer`]:{display:"inline-block",width:"100%"},[`&${t}-show-info`]:{[`${t}-outer`]:{marginInlineEnd:`calc(-2em - ${e.marginXS}px)`,paddingInlineEnd:`calc(2em + ${e.paddingXS}px)`}},[`${t}-inner`]:{position:"relative",display:"inline-block",width:"100%",overflow:"hidden",verticalAlign:"middle",backgroundColor:e.progressRemainingColor,borderRadius:e.progressLineRadius},[`${t}-inner:not(${t}-circle-gradient)`]:{[`${t}-circle-path`]:{stroke:e.colorInfo}},[`${t}-success-bg, ${t}-bg`]:{position:"relative",backgroundColor:e.colorInfo,borderRadius:e.progressLineRadius,transition:`all ${e.motionDurationSlow} ${e.motionEaseInOutCirc}`},[`${t}-success-bg`]:{position:"absolute",insetBlockStart:0,insetInlineStart:0,backgroundColor:e.colorSuccess},[`${t}-text`]:{display:"inline-block",width:"2em",marginInlineStart:e.marginXS,color:e.progressInfoTextColor,lineHeight:1,whiteSpace:"nowrap",textAlign:"start",verticalAlign:"middle",wordBreak:"normal",[o]:{fontSize:e.fontSize}},[`&${t}-status-active`]:{[`${t}-bg::before`]:{position:"absolute",inset:0,backgroundColor:e.colorBgContainer,borderRadius:e.progressLineRadius,opacity:0,animationName:we,animationDuration:e.progressActiveMotionDuration,animationTimingFunction:e.motionEaseOutQuint,animationIterationCount:"infinite",content:'""'}},[`&${t}-status-exception`]:{[`${t}-bg`]:{backgroundColor:e.colorError},[`${t}-text`]:{color:e.colorError}},[`&${t}-status-exception ${t}-inner:not(${t}-circle-gradient)`]:{[`${t}-circle-path`]:{stroke:e.colorError}},[`&${t}-status-success`]:{[`${t}-bg`]:{backgroundColor:e.colorSuccess},[`${t}-text`]:{color:e.colorSuccess}},[`&${t}-status-success ${t}-inner:not(${t}-circle-gradient)`]:{[`${t}-circle-path`]:{stroke:e.colorSuccess}}})}},Ie=e=>{const{componentCls:t,iconCls:o}=e;return{[t]:{[`${t}-circle-trail`]:{stroke:e.progressRemainingColor},[`&${t}-circle ${t}-inner`]:{position:"relative",lineHeight:1,backgroundColor:"transparent"},[`&${t}-circle ${t}-text`]:{position:"absolute",insetBlockStart:"50%",insetInlineStart:0,width:"100%",margin:0,padding:0,color:e.colorText,lineHeight:1,whiteSpace:"normal",textAlign:"center",transform:"translateY(-50%)",[o]:{fontSize:`${e.fontSize/e.fontSizeSM}em`}},[`${t}-circle&-status-exception`]:{[`${t}-text`]:{color:e.colorError}},[`${t}-circle&-status-success`]:{[`${t}-text`]:{color:e.colorSuccess}}},[`${t}-inline-circle`]:{lineHeight:1,[`${t}-inner`]:{verticalAlign:"bottom"}}}},De=e=>{const{componentCls:t}=e;return{[t]:{[`${t}-steps`]:{display:"inline-block","&-outer":{display:"flex",flexDirection:"row",alignItems:"center"},"&-item":{flexShrink:0,minWidth:e.progressStepMinWidth,marginInlineEnd:e.progressStepMarginInlineEnd,backgroundColor:e.progressRemainingColor,transition:`all ${e.motionDurationSlow}`,"&-active":{backgroundColor:e.colorInfo}}}}}},_e=e=>{const{componentCls:t,iconCls:o}=e;return{[t]:{[`${t}-small&-line, ${t}-small&-line ${t}-text ${o}`]:{fontSize:e.fontSizeSM}}}},je=Q("Progress",e=>{const t=e.marginXXS/2,o=U(e,{progressLineRadius:100,progressInfoTextColor:e.colorText,progressDefaultColor:e.colorInfo,progressRemainingColor:e.colorFillSecondary,progressStepMarginInlineEnd:t,progressStepMinWidth:t,progressActiveMotionDuration:"2.4s"});return[Oe(o),Ie(o),De(o),_e(o)]});var We=function(e,t){var o={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(o[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(e);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(o[r[s]]=e[r[s]]);return o};const Ae=I({compatConfig:{MODE:3},name:"AProgress",inheritAttrs:!1,props:E(_(),{type:"line",percent:0,showInfo:!0,trailColor:null,size:"default",strokeLinecap:"round"}),slots:Object,setup(e,t){let{slots:o,attrs:r}=t;const{prefixCls:s,direction:f}=ee("progress",e),[l,n]=je(s),i=u(()=>Array.isArray(e.strokeColor)?e.strokeColor[0]:e.strokeColor),h=u(()=>{const{percent:p=0}=e,c=D(e);return parseInt(c!==void 0?c.toString():p.toString(),10)}),d=u(()=>{const{status:p}=e;return!ie.includes(p)&&h.value>=100?"success":p||"normal"}),y=u(()=>{const{type:p,showInfo:c,size:b}=e,C=s.value;return{[C]:!0,[`${C}-inline-circle`]:p==="circle"&&j(b,"circle").width<=20,[`${C}-${p==="dashboard"&&"circle"||p}`]:!0,[`${C}-status-${d.value}`]:!0,[`${C}-show-info`]:c,[`${C}-${b}`]:b,[`${C}-rtl`]:f.value==="rtl",[n.value]:!0}}),v=u(()=>typeof e.strokeColor=="string"||Array.isArray(e.strokeColor)?e.strokeColor:void 0),a=()=>{const{showInfo:p,format:c,type:b,percent:C,title:S}=e,k=D(e);if(!p)return null;let m;const O=c||(o==null?void 0:o.format)||(G=>`${G}%`),L=b==="line";return c||o!=null&&o.format||d.value!=="exception"&&d.value!=="success"?m=O(P(C),P(k)):d.value==="exception"?m=L?g(te,null,null):g(re,null,null):d.value==="success"&&(m=L?g(oe,null,null):g(ne,null,null)),g("span",{class:`${s.value}-text`,title:S===void 0&&typeof m=="string"?m:void 0},[m])};return()=>{const{type:p,steps:c,title:b}=e,{class:C}=r,S=We(r,["class"]),k=a();let m;return p==="line"?m=c?g(Pe,$($({},e),{},{strokeColor:v.value,prefixCls:s.value,steps:c}),{default:()=>[k]}):g(fe,$($({},e),{},{strokeColor:i.value,prefixCls:s.value,direction:f.value}),{default:()=>[k]}):(p==="circle"||p==="dashboard")&&(m=g(ke,$($({},e),{},{prefixCls:s.value,strokeColor:i.value,progressStatus:d.value}),{default:()=>[k]})),l(g("div",$($({role:"progressbar"},S),{},{class:[y.value,C],title:b}),[m]))}}}),Re=se(Ae);export{Re as _};
|