You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

6 lines
4.3 KiB

import{e as A,f as m,k as V,l as G,c2 as O,ar as q,bb as H,as as R,at as U,G as j,w as J}from"./index.1762932289438.js";import{k as T,c as o,f as K,a as B,l as c,o as l,D as C,E as i,u as t,q as k,M as f,m as D,L as I,G as N,H as Q,I as X}from"./vue.1762932289438.js";const Y=A({type:{type:String,default:"line",values:["line","circle","dashboard"]},percentage:{type:Number,default:0,validator:u=>u>=0&&u<=100},status:{type:String,default:"",values:["","success","exception","warning"]},indeterminate:Boolean,duration:{type:Number,default:3},strokeWidth:{type:Number,default:6},strokeLinecap:{type:m(String),default:"round"},textInside:Boolean,width:{type:Number,default:126},showText:{type:Boolean,default:!0},color:{type:m([String,Array,Function]),default:""},striped:Boolean,stripedFlow:Boolean,format:{type:m(Function),default:u=>`${u}%`}}),Z=T({name:"ElProgress"}),_=T({...Z,props:Y,setup(u){const s=u,b={success:"#13ce66",exception:"#ff4949",warning:"#e6a23c",default:"#20a0ff"},r=G("progress"),F=o(()=>{const e={width:`${s.percentage}%`,animationDuration:`${s.duration}s`},a=P(s.percentage);return a.includes("gradient")?e.background=a:e.backgroundColor=a,e}),y=o(()=>(s.strokeWidth/s.width*100).toFixed(1)),v=o(()=>["circle","dashboard"].includes(s.type)?Number.parseInt(`${50-Number.parseFloat(y.value)/2}`,10):0),w=o(()=>{const e=v.value,a=s.type==="dashboard";return`
M 50 50
m 0 ${a?"":"-"}${e}
a ${e} ${e} 0 1 1 0 ${a?"-":""}${e*2}
a ${e} ${e} 0 1 1 0 ${a?"":"-"}${e*2}
`}),h=o(()=>2*Math.PI*v.value),g=o(()=>s.type==="dashboard"?.75:1),$=o(()=>`${-1*h.value*(1-g.value)/2}px`),E=o(()=>({strokeDasharray:`${h.value*g.value}px, ${h.value}px`,strokeDashoffset:$.value})),x=o(()=>({strokeDasharray:`${h.value*g.value*(s.percentage/100)}px, ${h.value}px`,strokeDashoffset:$.value,transition:"stroke-dasharray 0.6s ease 0s, stroke 0.6s ease, opacity ease 0.6s"})),L=o(()=>{let e;return s.color?e=P(s.percentage):e=b[s.status]||b.default,e}),W=o(()=>s.status==="warning"?O:s.type==="line"?s.status==="success"?q:H:s.status==="success"?R:U),z=o(()=>s.type==="line"?12+s.strokeWidth*.4:s.width*.111111+2),S=o(()=>s.format(s.percentage));function M(e){const a=100/e.length;return e.map((n,p)=>B(n)?{color:n,percentage:(p+1)*a}:n).sort((n,p)=>n.percentage-p.percentage)}const P=e=>{var a;const{color:d}=s;if(K(d))return d(e);if(B(d))return d;{const n=M(d);for(const p of n)if(p.percentage>e)return p.color;return(a=n[n.length-1])==null?void 0:a.color}};return(e,a)=>(l(),c("div",{class:i([t(r).b(),t(r).m(e.type),t(r).is(e.status),{[t(r).m("without-text")]:!e.showText,[t(r).m("text-inside")]:e.textInside}]),role:"progressbar","aria-valuenow":e.percentage,"aria-valuemin":"0","aria-valuemax":"100"},[e.type==="line"?(l(),c("div",{key:0,class:i(t(r).b("bar"))},[k("div",{class:i(t(r).be("bar","outer")),style:f({height:`${e.strokeWidth}px`})},[k("div",{class:i([t(r).be("bar","inner"),{[t(r).bem("bar","inner","indeterminate")]:e.indeterminate},{[t(r).bem("bar","inner","striped")]:e.striped},{[t(r).bem("bar","inner","striped-flow")]:e.stripedFlow}]),style:f(t(F))},[(e.showText||e.$slots.default)&&e.textInside?(l(),c("div",{key:0,class:i(t(r).be("bar","innerText"))},[D(e.$slots,"default",{percentage:e.percentage},()=>[k("span",null,I(t(S)),1)])],2)):C("v-if",!0)],6)],6)],2)):(l(),c("div",{key:1,class:i(t(r).b("circle")),style:f({height:`${e.width}px`,width:`${e.width}px`})},[(l(),c("svg",{viewBox:"0 0 100 100"},[k("path",{class:i(t(r).be("circle","track")),d:t(w),stroke:`var(${t(r).cssVarName("fill-color-light")}, #e5e9f2)`,"stroke-linecap":e.strokeLinecap,"stroke-width":t(y),fill:"none",style:f(t(E))},null,14,["d","stroke","stroke-linecap","stroke-width"]),k("path",{class:i(t(r).be("circle","path")),d:t(w),stroke:t(L),fill:"none",opacity:e.percentage?1:0,"stroke-linecap":e.strokeLinecap,"stroke-width":t(y),style:f(t(x))},null,14,["d","stroke","opacity","stroke-linecap","stroke-width"])]))],6)),(e.showText||e.$slots.default)&&!e.textInside?(l(),c("div",{key:2,class:i(t(r).e("text")),style:f({fontSize:`${t(z)}px`})},[D(e.$slots,"default",{percentage:e.percentage},()=>[e.status?(l(),N(t(j),{key:1},{default:Q(()=>[(l(),N(X(t(W))))]),_:1})):(l(),c("span",{key:0},I(t(S)),1))])],6)):C("v-if",!0)],10,["aria-valuenow"]))}});var ee=V(_,[["__file","progress.vue"]]);const re=J(ee);export{re as E};