VSlider.4e6efa7b.js 11 KB

1
  1. var Se=Object.defineProperty,ge=Object.defineProperties;var Ve=Object.getOwnPropertyDescriptors;var se=Object.getOwnPropertySymbols;var we=Object.prototype.hasOwnProperty,Ce=Object.prototype.propertyIsEnumerable;var re=(e,t,a)=>t in e?Se(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,S=(e,t)=>{for(var a in t||(t={}))we.call(t,a)&&re(e,a,t[a]);if(se)for(var a of se(t))Ce.call(t,a)&&re(e,a,t[a]);return e},G=(e,t)=>ge(e,Ve(t));import{q as H,aQ as _e,aN as Te,C as s,by as ne,b1 as Z,aV as z,ar as ie,r as J,bz as xe,bf as Fe,as as ce,ap as ve,x as ee,bA as Pe,bj as me,aY as Ee,bp as ze,E as te,at as A,b as n,ab as oe,bg as Me,bB as Re,ac as Le,bC as Ne,a$ as Be,aU as ue,bD as De,bE as $e,y as qe,bF as Ie,bG as de,a0 as Oe,bH as Ae,D as Ke}from"./index.6c36cb53.js";const le=Symbol.for("vuetify:v-slider");function je(e,t,a){const o=a==="vertical",u=t.getBoundingClientRect(),y="touches"in e?e.touches[0]:e;return o?y.clientY-(u.top+u.height/2):y.clientX-(u.left+u.width/2)}function Ue(e,t){return"touches"in e&&e.touches.length?e.touches[0][t]:"changedTouches"in e&&e.changedTouches.length?e.changedTouches[0][t]:e[t]}const Ye=H(G(S(S({disabled:{type:Boolean,default:null},error:Boolean,readonly:{type:Boolean,default:null},max:{type:[Number,String],default:100},min:{type:[Number,String],default:0},step:{type:[Number,String],default:0},thumbColor:String,thumbLabel:{type:[Boolean,String],default:void 0,validator:e=>typeof e=="boolean"||e==="always"},thumbSize:{type:[Number,String],default:20},showTicks:{type:[Boolean,String],default:!1,validator:e=>typeof e=="boolean"||e==="always"},ticks:{type:[Array,Object]},tickSize:{type:[Number,String],default:2},color:String,trackColor:String,trackFillColor:String,trackSize:{type:[Number,String],default:4},direction:{type:String,default:"horizontal",validator:e=>["vertical","horizontal"].includes(e)},reverse:Boolean},_e()),Te({elevation:2})),{ripple:{type:Boolean,default:!0}}),"Slider"),Xe=e=>{const t=s(()=>parseFloat(e.min)),a=s(()=>parseFloat(e.max)),o=s(()=>+e.step>0?parseFloat(e.step):0),u=s(()=>Math.max(ne(o.value),ne(t.value)));function y(p){if(p=parseFloat(p),o.value<=0)return p;const v=ce(p,t.value,a.value),g=t.value%o.value,T=Math.round((v-g)/o.value)*o.value+g;return parseFloat(Math.min(T,a.value).toFixed(u.value))}return{min:t,max:a,step:o,decimals:u,roundValue:y}},Ge=e=>{let{props:t,steps:a,onSliderStart:o,onSliderMove:u,onSliderEnd:y,getActiveThumb:p}=e;const{isRtl:v}=Z(),g=z(t,"reverse"),T=s(()=>t.direction==="vertical"),x=s(()=>T.value!==g.value),{min:f,max:w,step:F,decimals:D,roundValue:M}=a,I=s(()=>parseInt(t.thumbSize,10)),$=s(()=>parseInt(t.tickSize,10)),R=s(()=>parseInt(t.trackSize,10)),P=s(()=>(w.value-f.value)/F.value),O=z(t,"disabled"),E=s(()=>{var l;return t.error||t.disabled?void 0:(l=t.thumbColor)!=null?l:t.color}),i=s(()=>{var l;return t.error||t.disabled?void 0:(l=t.trackColor)!=null?l:t.color}),C=s(()=>{var l;return t.error||t.disabled?void 0:(l=t.trackFillColor)!=null?l:t.color}),m=ie(!1),b=ie(0),_=J(),h=J();function r(l){var ae;const c=t.direction==="vertical",be=c?"top":"left",fe=c?"height":"width",he=c?"clientY":"clientX",{[be]:ke,[fe]:ye}=(ae=_.value)==null?void 0:ae.$el.getBoundingClientRect(),pe=Ue(l,he);let W=Math.min(Math.max((pe-ke-b.value)/ye,0),1)||0;return(c?x.value:x.value!==v.value)&&(W=1-W),M(f.value+W*(w.value-f.value))}const L=l=>{y({value:r(l)}),m.value=!1,b.value=0},q=l=>{h.value=p(l),h.value&&(h.value.focus(),m.value=!0,h.value.contains(l.target)?b.value=je(l,h.value,t.direction):(b.value=0,u({value:r(l)})),o({value:r(l)}))},V={passive:!0,capture:!0};function N(l){u({value:r(l)})}function j(l){l.stopPropagation(),l.preventDefault(),L(l),window.removeEventListener("mousemove",N,V),window.removeEventListener("mouseup",j)}function U(l){var c;L(l),window.removeEventListener("touchmove",N,V),(c=l.target)==null||c.removeEventListener("touchend",U)}function Q(l){var c;q(l),window.addEventListener("touchmove",N,V),(c=l.target)==null||c.addEventListener("touchend",U,{passive:!1})}function k(l){l.preventDefault(),q(l),window.addEventListener("mousemove",N,V),window.addEventListener("mouseup",j,{passive:!1})}const d=l=>{const c=(l-f.value)/(w.value-f.value)*100;return ce(isNaN(c)?0:c,0,100)},B=z(t,"showTicks"),K=s(()=>B.value?t.ticks?Array.isArray(t.ticks)?t.ticks.map(l=>({value:l,position:d(l),label:l.toString()})):Object.keys(t.ticks).map(l=>({value:parseFloat(l),position:d(parseFloat(l)),label:t.ticks[l]})):P.value!==1/0?xe(P.value+1).map(l=>{const c=f.value+l*F.value;return{value:c,position:d(c)}}):[]:[]),Y=s(()=>K.value.some(l=>{let{label:c}=l;return!!c})),X={activeThumbRef:h,color:z(t,"color"),decimals:D,disabled:O,direction:z(t,"direction"),elevation:z(t,"elevation"),hasLabels:Y,isReversed:g,indexFromEnd:x,min:f,max:w,mousePressed:m,numTicks:P,onSliderMousedown:k,onSliderTouchstart:Q,parsedTicks:K,parseMouseMove:r,position:d,readonly:z(t,"readonly"),rounded:z(t,"rounded"),roundValue:M,showTicks:B,startOffset:b,step:F,thumbSize:I,thumbColor:E,thumbLabel:z(t,"thumbLabel"),ticks:z(t,"ticks"),tickSize:$,trackColor:i,trackContainerRef:_,trackFillColor:C,trackSize:R,vertical:T};return Fe(le,X),X},He=H(S({focused:Boolean,max:{type:Number,required:!0},min:{type:Number,required:!0},modelValue:{type:Number,required:!0},position:{type:Number,required:!0},ripple:{type:[Boolean,Object],default:!0}},ve()),"VSliderThumb"),Qe=ee()({name:"VSliderThumb",directives:{Ripple:Pe},props:He(),emits:{"update:modelValue":e=>!0},setup(e,t){let{slots:a,emit:o}=t;const u=me(le),{isRtl:y,rtlClasses:p}=Z();if(!u)throw new Error("[Vuetify] v-slider-thumb must be used inside v-slider or v-range-slider");const{thumbColor:v,step:g,disabled:T,thumbSize:x,thumbLabel:f,direction:w,isReversed:F,vertical:D,readonly:M,elevation:I,mousePressed:$,decimals:R,indexFromEnd:P}=u,O=s(()=>T.value?void 0:I.value),{elevationClasses:E}=Ee(O),{textColorClasses:i,textColorStyles:C}=ze(v),{pageup:m,pagedown:b,end:_,home:h,left:r,right:L,down:q,up:V}=Ne,N=[m,b,_,h,r,L,q,V],j=s(()=>g.value?[1,2,3]:[1,5,10]);function U(k,d){if(!N.includes(k.key))return;k.preventDefault();const B=g.value||.1,K=(e.max-e.min)/B;if([r,L,q,V].includes(k.key)){const X=(D.value?[y.value?r:L,F.value?q:V]:P.value!==y.value?[r,V]:[L,V]).includes(k.key)?1:-1,l=k.shiftKey?2:k.ctrlKey?1:0;d=d+X*B*j.value[l]}else if(k.key===h)d=e.min;else if(k.key===_)d=e.max;else{const Y=k.key===b?1:-1;d=d-Y*B*(K>100?K/10:10)}return Math.max(e.min,Math.min(e.max,d))}function Q(k){const d=U(k,e.modelValue);d!=null&&o("update:modelValue",d)}return te(()=>{const k=A(P.value?100-e.position:e.position,"%");return n("div",{class:["v-slider-thumb",{"v-slider-thumb--focused":e.focused,"v-slider-thumb--pressed":e.focused&&$.value},e.class,p.value],style:[{"--v-slider-thumb-position":k,"--v-slider-thumb-size":A(x.value)},e.style],role:"slider",tabindex:T.value?-1:0,"aria-valuemin":e.min,"aria-valuemax":e.max,"aria-valuenow":e.modelValue,"aria-readonly":!!M.value,"aria-orientation":w.value,onKeydown:M.value?void 0:Q},[n("div",{class:["v-slider-thumb__surface",i.value,E.value],style:S({},C.value)},null),oe(n("div",{class:["v-slider-thumb__ripple",i.value],style:C.value},null),[[Me("ripple"),e.ripple,null,{circle:!0,center:!0}]]),n(Re,{origin:"bottom center"},{default:()=>{var d,B;return[oe(n("div",{class:"v-slider-thumb__label-container"},[n("div",{class:["v-slider-thumb__label"]},[n("div",null,[(B=(d=a["thumb-label"])==null?void 0:d.call(a,{modelValue:e.modelValue}))!=null?B:e.modelValue.toFixed(g.value?R.value:1)])])]),[[Le,f.value&&e.focused||f.value==="always"]])]}})])}),{}}});const We=H(S({start:{type:Number,required:!0},stop:{type:Number,required:!0}},ve()),"VSliderTrack"),Je=ee()({name:"VSliderTrack",props:We(),emits:{},setup(e,t){let{slots:a}=t;const o=me(le);if(!o)throw new Error("[Vuetify] v-slider-track must be inside v-slider or v-range-slider");const{color:u,parsedTicks:y,rounded:p,showTicks:v,tickSize:g,trackColor:T,trackFillColor:x,trackSize:f,vertical:w,min:F,max:D,indexFromEnd:M}=o,{roundedClasses:I}=Be(p),{backgroundColorClasses:$,backgroundColorStyles:R}=ue(x),{backgroundColorClasses:P,backgroundColorStyles:O}=ue(T),E=s(()=>`inset-${w.value?"block":"inline"}-${M.value?"end":"start"}`),i=s(()=>w.value?"height":"width"),C=s(()=>({[E.value]:"0%",[i.value]:"100%"})),m=s(()=>e.stop-e.start),b=s(()=>({[E.value]:A(e.start,"%"),[i.value]:A(m.value,"%")})),_=s(()=>v.value?(w.value?y.value.slice().reverse():y.value).map((r,L)=>{var V,N;const q=r.value!==F.value&&r.value!==D.value?A(r.position,"%"):void 0;return n("div",{key:r.value,class:["v-slider-track__tick",{"v-slider-track__tick--filled":r.position>=e.start&&r.position<=e.stop,"v-slider-track__tick--first":r.value===F.value,"v-slider-track__tick--last":r.value===D.value}],style:{[E.value]:q}},[(r.label||a["tick-label"])&&n("div",{class:"v-slider-track__tick-label"},[(N=(V=a["tick-label"])==null?void 0:V.call(a,{tick:r,index:L}))!=null?N:r.label])])}):[]);return te(()=>n("div",{class:["v-slider-track",I.value,e.class],style:[{"--v-slider-track-size":A(f.value),"--v-slider-tick-size":A(g.value)},e.style]},[n("div",{class:["v-slider-track__background",P.value,{"v-slider-track__background--opacity":!!u.value||!x.value}],style:S(S({},C.value),O.value)},null),n("div",{class:["v-slider-track__fill",$.value],style:S(S({},b.value),R.value)},null),v.value&&n("div",{class:["v-slider-track__ticks",{"v-slider-track__ticks--always-show":v.value==="always"}]},[_.value])])),{}}}),Ze=H(G(S(S(S({},De()),Ye()),$e()),{modelValue:{type:[Number,String],default:0}}),"VSlider"),lt=ee()({name:"VSlider",props:Ze(),emits:{"update:focused":e=>!0,"update:modelValue":e=>!0,start:e=>!0,end:e=>!0},setup(e,t){let{slots:a,emit:o}=t;const u=J(),{rtlClasses:y}=Z(),p=Xe(e),v=qe(e,"modelValue",void 0,i=>p.roundValue(i==null?p.min.value:i)),{min:g,max:T,mousePressed:x,roundValue:f,onSliderMousedown:w,onSliderTouchstart:F,trackContainerRef:D,position:M,hasLabels:I,readonly:$}=Ge({props:e,steps:p,onSliderStart:()=>{o("start",v.value)},onSliderEnd:i=>{let{value:C}=i;const m=f(C);v.value=m,o("end",m)},onSliderMove:i=>{let{value:C}=i;return v.value=f(C)},getActiveThumb:()=>{var i;return(i=u.value)==null?void 0:i.$el}}),{isFocused:R,focus:P,blur:O}=Ie(e),E=s(()=>M(v.value));return te(()=>{const i=de.filterProps(e),C=!!(e.label||a.label||a.prepend);return n(de,Ke({class:["v-slider",{"v-slider--has-labels":!!a["tick-label"]||I.value,"v-slider--focused":R.value,"v-slider--pressed":x.value,"v-slider--disabled":e.disabled},y.value,e.class],style:e.style},i,{focused:R.value}),G(S({},a),{prepend:C?m=>{var b,_,h;return n(Oe,null,[(_=(b=a.label)==null?void 0:b.call(a,m))!=null?_:e.label?n(Ae,{id:m.id.value,class:"v-slider__label",text:e.label},null):void 0,(h=a.prepend)==null?void 0:h.call(a,m)])}:void 0,default:m=>{let{id:b,messagesId:_}=m;return n("div",{class:"v-slider__container",onMousedown:$.value?void 0:w,onTouchstartPassive:$.value?void 0:F},[n("input",{id:b.value,name:e.name||b.value,disabled:!!e.disabled,readonly:!!e.readonly,tabindex:"-1",value:v.value},null),n(Je,{ref:D,start:0,stop:E.value},{"tick-label":a["tick-label"]}),n(Qe,{ref:u,"aria-describedby":_.value,focused:R.value,min:g.value,max:T.value,modelValue:v.value,"onUpdate:modelValue":h=>v.value=h,position:E.value,elevation:e.elevation,onFocus:P,onBlur:O,ripple:e.ripple},{"thumb-label":a["thumb-label"]})])}}))}),{}}});export{lt as V};