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