index-legacy-141c80f8.js 3.4 KB

1
  1. System.register(["./index-legacy-a314c7dd.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.a4,c=e._,v=e.a,m=e.bG,g=e.$,b=e.s,h=e.bo,y=e.p,f=e.aU,p=e.a0,V=e.k}],execute:function(){const[a,x]=t("slider"),N={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 S=n({name:a,props:N,emits:["change","dragEnd","dragStart","update:modelValue"],setup(e,{emit:a,slots:t}){let r,l,n;const V=o(),N=[o(),o()],S=o(),w=i(),C=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])/C.value+"%":100*(a-Number(t))/C.value+"%"},z=u((()=>{const a={[e.vertical?"height":"width"]:B(),background:e.activeColor};return S.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))/C.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)},T=()=>{const a=e.modelValue;n=A(a)?a.map(E):E(a)},X=(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)},Y=a=>{if(a.stopPropagation(),e.disabled||e.readonly)return;T();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*C.value;if(A(n)){const[e,a]=n;X(u<=(e+a)/2?[u,a]:[e,u],!0)}else X(u,!0)},H=t=>{if(e.disabled||e.readonly)return;"start"===S.value&&a("dragStart",t),y(t,!0),w.move(t),S.value="dragging";const o=g(V);let i=(e.vertical?w.deltaY.value:w.deltaX.value)/(e.vertical?o.height:o.width)*C.value;if(e.reverse&&(i=-i),A(n)){const a=e.reverse?1-r:r;l[a]=n[a]+i}else l=n+i;X(l)},P=t=>{e.disabled||e.readonly||("dragging"===S.value&&(X(l,!0),a("dragEnd",t)),S.value="")},j=a=>x("button-wrapper","number"==typeof a?["left","right"][a]:e.reverse?"left":"right"),G=(a,n)=>{const o="dragging"===S.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)},I=a=>{const t="number"==typeof a?e.modelValue[a]:e.modelValue;return v("div",{ref:N[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||(w.start(a),l=e.modelValue,T(),S.value="start")})(t)},onTouchend:P,onTouchcancel:P,onClick:b},[G(t,a)])};return X(e.modelValue),s((()=>e.modelValue)),N.forEach((e=>{c("touchmove",H,{target:e})})),()=>v("div",{ref:V,style:k.value,class:x({vertical:e.vertical,disabled:e.disabled}),onClick:Y},[v("div",{class:x("bar"),style:z.value},[e.range?[I(0),I(1)]:I()])])}});e("S",V(S))}}}));