index-legacy-f9858fd3.js 3.4 KB

1
  1. System.register(["./index-legacy-e6be1dcb.js"],(function(e,a){"use strict";var t,r,l,n,o,i,u,d,s,c,v,m,g,b,h,y,f,p,V;return{setters:[e=>{t=e.c,r=e.b,l=e.n,n=e.d,o=e.r,i=e.u,u=e.e,d=e.o,s=e.a5,c=e._,v=e.a,m=e.bC,g=e.$,b=e.s,h=e.bP,y=e.p,f=e.aC,p=e.a0,V=e.k}],execute:function(){const[a,x]=t("slider"),C={min:r(0),max:r(100),step:r(1),range:Boolean,reverse:Boolean,disabled:Boolean,readonly:Boolean,vertical:Boolean,barHeight:l,buttonSize:l,activeColor:String,inactiveColor:String,modelValue:{type:[Number,Array],default:0}};var N=n({name:a,props:C,emits:["change","dragEnd","dragStart","update:modelValue"],setup(e,{emit:a,slots:t}){let r,l,n;const V=o(),C=[o(),o()],N=o(),S=i(),w=u((()=>Number(e.max)-Number(e.min))),k=u((()=>{const a=e.vertical?"width":"height";return{background:e.inactiveColor,[a]:d(e.barHeight)}})),A=a=>e.range&&Array.isArray(a),B=()=>{const{modelValue:a,min:t}=e;return A(a)?100*(a[1]-a[0])/w.value+"%":100*(a-Number(t))/w.value+"%"},z=u((()=>{const a={[e.vertical?"height":"width"]:B(),background:e.activeColor};return N.value&&(a.transition="none"),a[e.vertical?e.reverse?"bottom":"top":e.reverse?"right":"left"]=(()=>{const{modelValue:a,min:t}=e;return A(a)?100*(a[0]-Number(t))/w.value+"%":"0%"})(),a})),E=a=>{const t=+e.min,r=+e.max,l=+e.step;a=p(a,t,r);const n=Math.round((a-t)/l)*l;return h(t,n)},P=()=>{const a=e.modelValue;n=A(a)?a.map(E):E(a)},T=(t,r)=>{t=A(t)?(a=>{var t,r;const l=null!=(t=a[0])?t:Number(e.min),n=null!=(r=a[1])?r:Number(e.max);return l>n?[n,l]:[l,n]})(t).map(E):E(t),m(t,e.modelValue)||a("update:modelValue",t),r&&!m(t,n)&&a("change",t)},X=a=>{if(a.stopPropagation(),e.disabled||e.readonly)return;P();const{min:t,reverse:r,vertical:l,modelValue:n}=e,o=g(V),i=l?o.height:o.width,u=Number(t)+(l?r?o.bottom-a.clientY:a.clientY-o.top:r?o.right-a.clientX:a.clientX-o.left)/i*w.value;if(A(n)){const[e,a]=n;T(u<=(e+a)/2?[u,a]:[e,u],!0)}else T(u,!0)},Y=t=>{if(e.disabled||e.readonly)return;"start"===N.value&&a("dragStart",t),y(t,!0),S.move(t),N.value="dragging";const o=g(V);let i=(e.vertical?S.deltaY.value:S.deltaX.value)/(e.vertical?o.height:o.width)*w.value;if(e.reverse&&(i=-i),A(n)){const a=e.reverse?1-r:r;l[a]=n[a]+i}else l=n+i;T(l)},H=t=>{e.disabled||e.readonly||("dragging"===N.value&&(T(l,!0),a("dragEnd",t)),N.value="")},j=a=>x("button-wrapper","number"==typeof a?["left","right"][a]:e.reverse?"left":"right"),I=(a,n)=>{const o="dragging"===N.value;if("number"==typeof n){const e=t[0===n?"left-button":"right-button"];let i;if(o&&Array.isArray(l)&&(i=l[0]>l[1]?1^r:r),e)return e({value:a,dragging:o,dragIndex:i})}return t.button?t.button({value:a,dragging:o}):v("div",{class:x("button"),style:f(e.buttonSize)},null)},M=a=>{const t="number"==typeof a?e.modelValue[a]:e.modelValue;return v("div",{ref:C[null!=a?a:0],role:"slider",class:j(a),tabindex:e.disabled?void 0:0,"aria-valuemin":e.min,"aria-valuenow":t,"aria-valuemax":e.max,"aria-disabled":e.disabled||void 0,"aria-readonly":e.readonly||void 0,"aria-orientation":e.vertical?"vertical":"horizontal",onTouchstartPassive:t=>{"number"==typeof a&&(r=a),(a=>{e.disabled||e.readonly||(S.start(a),l=e.modelValue,P(),N.value="start")})(t)},onTouchend:H,onTouchcancel:H,onClick:b},[I(t,a)])};return T(e.modelValue),s((()=>e.modelValue)),C.forEach((e=>{c("touchmove",Y,{target:e})})),()=>v("div",{ref:V,style:k.value,class:x({vertical:e.vertical,disabled:e.disabled}),onClick:X},[v("div",{class:x("bar"),style:z.value},[e.range?[M(0),M(1)]:M()])])}});e("S",V(N))}}}));