2 lines
3.4 KiB
JavaScript
2 lines
3.4 KiB
JavaScript
var D=Object.defineProperty,E=Object.defineProperties;var M=Object.getOwnPropertyDescriptors;var C=Object.getOwnPropertySymbols;var F=Object.prototype.hasOwnProperty,G=Object.prototype.propertyIsEnumerable;var P=(o,t,r)=>t in o?D(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r,f=(o,t)=>{for(var r in t||(t={}))F.call(t,r)&&P(o,r,t[r]);if(C)for(var r of C(t))G.call(t,r)&&P(o,r,t[r]);return o},_=(o,t)=>E(o,M(t));var S=(o,t,r)=>new Promise((n,u)=>{var i=l=>{try{p(r.next(l))}catch(d){u(d)}},m=l=>{try{p(r.throw(l))}catch(d){u(d)}},p=l=>l.done?n(l.value):Promise.resolve(l.value).then(i,m);p((r=r.apply(o,t)).next())});import{aI as T,a5 as H,a6 as L,d as W,r as b,T as y,a8 as q,W as J,c as w,j as v,w as h,k as j,af as K,l as Q,aa as O,s as $,m as R,t as U,_ as X,at as Y,as as A,bj as Z,bf as ee,x as te}from"./index-B-O76M86.js";const se=_(f({},L),{percentage:T(0),hideText:H(!1),color:{type:[String,Array]},duration:T(30),status:String}),ae={name:"wd-progress",options:{virtualHost:!0,addGlobalClass:!0,styleIsolation:"shared"}},re=W(_(f({},ae),{props:se,setup(o){const t=o,r=b(""),n=b(0),u=b(0);let i=null;const m=y(()=>q({background:r.value,width:`${n.value}%`,"transition-duration":`${u.value*t.duration*.001}s`})),p=y(()=>t.status?`is-${t.status}`:""),l=y(()=>{let e="";switch(t.status){case"danger":e="close-outline";break;case"success":e="check-outline";break;case"warning":e="warn-bold";break}return e});J(()=>[t.percentage,t.color,t.duration],()=>{d(t.percentage),k()},{immediate:!0});function d(e){(Number.isNaN(e)||e<0||e>100)&&console.error("The value of percentage must be between 0 and 100")}function B(e,s){return e.some((a,c)=>{if(n.value<a.percentage&&a.percentage<=s)return g(a.percentage,a.color),!0;c===e.length-1&&g(s,a.color)})}function I(e,s){return e.some(a=>{if(s<=a.percentage)return g(s,a.color),!0})}function k(){return S(this,null,function*(){const{percentage:e,color:s}=t;if(!Y(s)||A(s)&&s.length===0){u.value=Math.abs(e-n.value),yield Z(),n.value=e;return}if(n.value===e)return;const a=A(s)?s:[s];x(a);const c=z(a);n.value>e?I(c,e):B(c,e)})}function N(e){return e.every(s=>ee(s)&&Object.prototype.hasOwnProperty.call(s,"color")&&Object.prototype.hasOwnProperty.call(s,"percentage"))}function V(e){return e.every(s=>typeof s=="string")}function x(e){const s=V(e),a=N(e);if(!s&&!a)throw Error("Color must be String or Object with color and percentage");if(a&&e.some(({percentage:c})=>Number.isNaN(c)))throw Error("All the percentage must can be formatted to Number")}function z(e){const s=100/e.length;return N(e)?e.sort((a,c)=>a.percentage-c.percentage):e.map((a,c)=>({color:a,percentage:(c+1)*s}))}function g(e,s){if(i)return;const{duration:a}=t;u.value=Math.abs(e-n.value),setTimeout(()=>{n.value=e,r.value=s,i=setTimeout(()=>{i&&clearTimeout(i),i=null,k()},u.value*a)},50)}return(e,s)=>{const a=Q;return v(),w(a,{class:$(`wd-progress ${e.customClass}`),style:O(e.customStyle)},{default:h(()=>[j(a,{class:"wd-progress__outer"},{default:h(()=>[j(a,{class:$(`wd-progress__inner ${p.value}`),style:O(m.value)},null,8,["class","style"])]),_:1}),e.hideText?e.status?(v(),w(X,{key:1,"custom-class":`wd-progress__label wd-progress__icon ${p.value}`,name:l.value,color:typeof e.color=="string"?e.color:""},null,8,["custom-class","name","color"])):K("",!0):(v(),w(a,{key:0,class:"wd-progress__label"},{default:h(()=>[R(U(e.percentage)+"%",1)]),_:1}))]),_:1},8,["class","style"])}}})),ce=te(re,[["__scopeId","data-v-fc07731c"]]);export{ce as _};
|