VSlider-Bmvc6aBM.js 10 KB

1
  1. import{c9 as Y,de as fe,df as he,aR as a,dg as te,cx as J,cS as P,bG as le,ag as H,dh as ke,cA as ye,cX as re,ct as ie,cc as Q,bA as Se,cD as oe,di as pe,cL as ge,cg as Z,cI as I,an as r,aA as ae,bx as we,dj as Ve,aB as Ce,dk as _e,dl as xe,cR as se,dm as Te,dn as Fe,cd as Pe,dp as Re,dq as ne,aX as Le,dr as Me,bn as ze}from"./index-D68iA7pN.js";const ee=Symbol.for("vuetify:v-slider");function Ee(e,t,n){const i=n==="vertical",o=t.getBoundingClientRect(),f="touches"in e?e.touches[0]:e;return i?f.clientY-(o.top+o.height/2):f.clientX-(o.left+o.width/2)}function Ne(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 Be=Y({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,...fe(),...he({elevation:2}),ripple:{type:Boolean,default:!0}},"Slider"),De=e=>{const t=a(()=>parseFloat(e.min)),n=a(()=>parseFloat(e.max)),i=a(()=>+e.step>0?parseFloat(e.step):0),o=a(()=>Math.max(te(i.value),te(t.value)));function f(h){if(h=parseFloat(h),i.value<=0)return h;const u=re(h,t.value,n.value),k=t.value%i.value,V=Math.round((u-k)/i.value)*i.value+k;return parseFloat(Math.min(V,n.value).toFixed(o.value))}return{min:t,max:n,step:i,decimals:o,roundValue:f}},Ae=e=>{let{props:t,steps:n,onSliderStart:i,onSliderMove:o,onSliderEnd:f,getActiveThumb:h}=e;const{isRtl:u}=J(),k=P(t,"reverse"),V=a(()=>t.direction==="vertical"),C=a(()=>V.value!==k.value),{min:v,max:S,step:_,decimals:E,roundValue:R}=n,D=a(()=>parseInt(t.thumbSize,10)),N=a(()=>parseInt(t.tickSize,10)),L=a(()=>parseInt(t.trackSize,10)),x=a(()=>(S.value-v.value)/_.value),A=P(t,"disabled"),T=a(()=>t.error||t.disabled?void 0:t.thumbColor??t.color),d=a(()=>t.error||t.disabled?void 0:t.trackColor??t.color),p=a(()=>t.error||t.disabled?void 0:t.trackFillColor??t.color),c=le(!1),y=le(0),M=H(),g=H();function s(l){const w=t.direction==="vertical",ue=w?"top":"left",de=w?"height":"width",ce=w?"clientY":"clientX",{[ue]:ve,[de]:me}=M.value?.$el.getBoundingClientRect(),be=Ne(l,ce);let W=Math.min(Math.max((be-ve-y.value)/me,0),1)||0;return(w?C.value:C.value!==u.value)&&(W=1-W),R(v.value+W*(S.value-v.value))}const z=l=>{f({value:s(l)}),c.value=!1,y.value=0},B=l=>{g.value=h(l),g.value&&(g.value.focus(),c.value=!0,g.value.contains(l.target)?y.value=Ee(l,g.value,t.direction):(y.value=0,o({value:s(l)})),i({value:s(l)}))},F={passive:!0,capture:!0};function q(l){o({value:s(l)})}function j(l){l.stopPropagation(),l.preventDefault(),z(l),window.removeEventListener("mousemove",q,F),window.removeEventListener("mouseup",j)}function X(l){z(l),window.removeEventListener("touchmove",q,F),l.target?.removeEventListener("touchend",X)}function G(l){B(l),window.addEventListener("touchmove",q,F),l.target?.addEventListener("touchend",X,{passive:!1})}function m(l){l.preventDefault(),B(l),window.addEventListener("mousemove",q,F),window.addEventListener("mouseup",j,{passive:!1})}const b=l=>{const w=(l-v.value)/(S.value-v.value)*100;return re(isNaN(w)?0:w,0,100)},O=P(t,"showTicks"),K=a(()=>O.value?t.ticks?Array.isArray(t.ticks)?t.ticks.map(l=>({value:l,position:b(l),label:l.toString()})):Object.keys(t.ticks).map(l=>({value:parseFloat(l),position:b(parseFloat(l)),label:t.ticks[l]})):x.value!==1/0?ke(x.value+1).map(l=>{const w=v.value+l*_.value;return{value:w,position:b(w)}}):[]:[]),$=a(()=>K.value.some(l=>{let{label:w}=l;return!!w})),U={activeThumbRef:g,color:P(t,"color"),decimals:E,disabled:A,direction:P(t,"direction"),elevation:P(t,"elevation"),hasLabels:$,isReversed:k,indexFromEnd:C,min:v,max:S,mousePressed:c,numTicks:x,onSliderMousedown:m,onSliderTouchstart:G,parsedTicks:K,parseMouseMove:s,position:b,readonly:P(t,"readonly"),rounded:P(t,"rounded"),roundValue:R,showTicks:O,startOffset:y,step:_,thumbSize:D,thumbColor:T,thumbLabel:P(t,"thumbLabel"),ticks:P(t,"ticks"),tickSize:N,trackColor:d,trackContainerRef:M,trackFillColor:p,trackSize:L,vertical:V};return ye(ee,U),U},Ie=Y({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},name:String,...ie()},"VSliderThumb"),qe=Q()({name:"VSliderThumb",directives:{Ripple:Se},props:Ie(),emits:{"update:modelValue":e=>!0},setup(e,t){let{slots:n,emit:i}=t;const o=oe(ee),{isRtl:f,rtlClasses:h}=J();if(!o)throw new Error("[Vuetify] v-slider-thumb must be used inside v-slider or v-range-slider");const{thumbColor:u,step:k,disabled:V,thumbSize:C,thumbLabel:v,direction:S,isReversed:_,vertical:E,readonly:R,elevation:D,mousePressed:N,decimals:L,indexFromEnd:x}=o,A=a(()=>V.value?void 0:D.value),{elevationClasses:T}=pe(A),{textColorClasses:d,textColorStyles:p}=ge(u),{pageup:c,pagedown:y,end:M,home:g,left:s,right:z,down:B,up:F}=_e,q=[c,y,M,g,s,z,B,F],j=a(()=>k.value?[1,2,3]:[1,5,10]);function X(m,b){if(!q.includes(m.key))return;m.preventDefault();const O=k.value||.1,K=(e.max-e.min)/O;if([s,z,B,F].includes(m.key)){const U=(E.value?[f.value?s:z,_.value?B:F]:x.value!==f.value?[s,F]:[z,F]).includes(m.key)?1:-1,l=m.shiftKey?2:m.ctrlKey?1:0;b=b+U*O*j.value[l]}else if(m.key===g)b=e.min;else if(m.key===M)b=e.max;else{const $=m.key===y?1:-1;b=b-$*O*(K>100?K/10:10)}return Math.max(e.min,Math.min(e.max,b))}function G(m){const b=X(m,e.modelValue);b!=null&&i("update:modelValue",b)}return Z(()=>{const m=I(x.value?100-e.position:e.position,"%");return r("div",{class:["v-slider-thumb",{"v-slider-thumb--focused":e.focused,"v-slider-thumb--pressed":e.focused&&N.value},e.class,h.value],style:[{"--v-slider-thumb-position":m,"--v-slider-thumb-size":I(C.value)},e.style],role:"slider",tabindex:V.value?-1:0,"aria-label":e.name,"aria-valuemin":e.min,"aria-valuemax":e.max,"aria-valuenow":e.modelValue,"aria-readonly":!!R.value,"aria-orientation":S.value,onKeydown:R.value?void 0:G},[r("div",{class:["v-slider-thumb__surface",d.value,T.value],style:{...p.value}},null),ae(r("div",{class:["v-slider-thumb__ripple",d.value],style:p.value},null),[[we("ripple"),e.ripple,null,{circle:!0,center:!0}]]),r(Ve,{origin:"bottom center"},{default:()=>[ae(r("div",{class:"v-slider-thumb__label-container"},[r("div",{class:["v-slider-thumb__label"]},[r("div",null,[n["thumb-label"]?.({modelValue:e.modelValue})??e.modelValue.toFixed(k.value?L.value:1)])])]),[[Ce,v.value&&e.focused||v.value==="always"]])]})])}),{}}}),Oe=Y({start:{type:Number,required:!0},stop:{type:Number,required:!0},...ie()},"VSliderTrack"),Ke=Q()({name:"VSliderTrack",props:Oe(),emits:{},setup(e,t){let{slots:n}=t;const i=oe(ee);if(!i)throw new Error("[Vuetify] v-slider-track must be inside v-slider or v-range-slider");const{color:o,parsedTicks:f,rounded:h,showTicks:u,tickSize:k,trackColor:V,trackFillColor:C,trackSize:v,vertical:S,min:_,max:E,indexFromEnd:R}=i,{roundedClasses:D}=xe(h),{backgroundColorClasses:N,backgroundColorStyles:L}=se(C),{backgroundColorClasses:x,backgroundColorStyles:A}=se(V),T=a(()=>`inset-${S.value?"block":"inline"}-${R.value?"end":"start"}`),d=a(()=>S.value?"height":"width"),p=a(()=>({[T.value]:"0%",[d.value]:"100%"})),c=a(()=>e.stop-e.start),y=a(()=>({[T.value]:I(e.start,"%"),[d.value]:I(c.value,"%")})),M=a(()=>u.value?(S.value?f.value.slice().reverse():f.value).map((s,z)=>{const B=s.value!==_.value&&s.value!==E.value?I(s.position,"%"):void 0;return r("div",{key:s.value,class:["v-slider-track__tick",{"v-slider-track__tick--filled":s.position>=e.start&&s.position<=e.stop,"v-slider-track__tick--first":s.value===_.value,"v-slider-track__tick--last":s.value===E.value}],style:{[T.value]:B}},[(s.label||n["tick-label"])&&r("div",{class:"v-slider-track__tick-label"},[n["tick-label"]?.({tick:s,index:z})??s.label])])}):[]);return Z(()=>r("div",{class:["v-slider-track",D.value,e.class],style:[{"--v-slider-track-size":I(v.value),"--v-slider-tick-size":I(k.value)},e.style]},[r("div",{class:["v-slider-track__background",x.value,{"v-slider-track__background--opacity":!!o.value||!C.value}],style:{...p.value,...A.value}},null),r("div",{class:["v-slider-track__fill",N.value],style:{...y.value,...L.value}},null),u.value&&r("div",{class:["v-slider-track__ticks",{"v-slider-track__ticks--always-show":u.value==="always"}]},[M.value])])),{}}}),je=Y({...Te(),...Be(),...Fe(),modelValue:{type:[Number,String],default:0}},"VSlider"),$e=Q()({name:"VSlider",props:je(),emits:{"update:focused":e=>!0,"update:modelValue":e=>!0,start:e=>!0,end:e=>!0},setup(e,t){let{slots:n,emit:i}=t;const o=H(),{rtlClasses:f}=J(),h=De(e),u=Pe(e,"modelValue",void 0,d=>h.roundValue(d??h.min.value)),{min:k,max:V,mousePressed:C,roundValue:v,onSliderMousedown:S,onSliderTouchstart:_,trackContainerRef:E,position:R,hasLabels:D,readonly:N}=Ae({props:e,steps:h,onSliderStart:()=>{i("start",u.value)},onSliderEnd:d=>{let{value:p}=d;const c=v(p);u.value=c,i("end",c)},onSliderMove:d=>{let{value:p}=d;return u.value=v(p)},getActiveThumb:()=>o.value?.$el}),{isFocused:L,focus:x,blur:A}=Re(e),T=a(()=>R(u.value));return Z(()=>{const d=ne.filterProps(e),p=!!(e.label||n.label||n.prepend);return r(ne,ze({class:["v-slider",{"v-slider--has-labels":!!n["tick-label"]||D.value,"v-slider--focused":L.value,"v-slider--pressed":C.value,"v-slider--disabled":e.disabled},f.value,e.class],style:e.style},d,{focused:L.value}),{...n,prepend:p?c=>r(Le,null,[n.label?.(c)??(e.label?r(Me,{id:c.id.value,class:"v-slider__label",text:e.label},null):void 0),n.prepend?.(c)]):void 0,default:c=>{let{id:y,messagesId:M}=c;return r("div",{class:"v-slider__container",onMousedown:N.value?void 0:S,onTouchstartPassive:N.value?void 0:_},[r("input",{id:y.value,name:e.name||y.value,disabled:!!e.disabled,readonly:!!e.readonly,tabindex:"-1",value:u.value},null),r(Ke,{ref:E,start:0,stop:T.value},{"tick-label":n["tick-label"]}),r(qe,{ref:o,"aria-describedby":M.value,focused:L.value,min:k.value,max:V.value,modelValue:u.value,"onUpdate:modelValue":g=>u.value=g,position:T.value,elevation:e.elevation,onFocus:x,onBlur:A,ripple:e.ripple,name:e.name},{"thumb-label":n["thumb-label"]})])}})}),{}}});export{$e as V,Ae as a,Ke as b,qe as c,Ee as g,Be as m,De as u};