range-slider-input
Advanced tools
Comparing version 2.4.2 to 2.4.3
@@ -1,1 +0,1 @@ | ||
!function(e,a){"object"==typeof exports&&"object"==typeof module?module.exports=a():"function"==typeof define&&define.amd?define([],a):"object"==typeof exports?exports.rangeSlider=a():e.rangeSlider=a()}(this,(()=>{return e={138:e=>{e.exports=(e,a={})=>{const i=e=>!isNaN(e)&&+e+""==e+"",t=(e=0,a=0)=>({min:e,max:a}),n=e=>{[C,M].forEach(e)},m=(e,a,i)=>{if(e)return a;i()},s=(e,a,i="")=>{e.setAttribute(a,i)},l=(e,a)=>{e.removeAttribute(a)},r=(e,a,i,t=!0)=>{e.addEventListener(a,i,t?{passive:!1,capture:!0}:{})},d=(e,a,i,t=!0)=>{e.removeEventListener(a,i,t?{passive:!1,capture:!0}:{})},o=(e,i)=>{a[e]={}.hasOwnProperty.call(a,e)?a[e]:i},u=(e,i)=>a.orientation===B?e:i,b=e=>1===e?J.max:J.min,x=()=>{let e=!1;i(a.min)&&i(a.max)||(e=!0),a.min=e?1:+a.min,a.max=e?1:+a.max},h=()=>{a.thumbsDisabled instanceof Array?(1===a.thumbsDisabled.length&&a.thumbsDisabled.push(!1),1!==a.thumbsDisabled.length&&2!==a.thumbsDisabled.length&&(a.thumbsDisabled=[!1,!1])):a.thumbsDisabled=[a.thumbsDisabled,a.thumbsDisabled],a.thumbsDisabled[0]=!!a.thumbsDisabled[0],a.thumbsDisabled[1]=!!a.thumbsDisabled[1]},p=(e,i=!1,n=!0,m=!0)=>{const r=t(se[J.min].value,se[J.max].value);e=e||r,se[J.min].value=e.min,se[J.max].value=te||i?e.max:e.min+ae,g(),Y.min>Y.max&&(J.min=+!J.min,J.max=+!J.max,l(le[J.min],O),l(le[J.max],G),s(le[J.min],G),s(le[J.max],O),te&&(te=te===C?M:C),g()),Z=i?Y:e;let d=!1;(r.min!==se[J.min].value||i)&&(d=!0),(r.max!==se[J.max].value||i)&&(d=!0),d&&(n&&a.onInput&&a.onInput([Y.min,Y.max],m),E(),c(),D(),y())},g=()=>{n((e=>{Y[e]=+se[J[e]].value}))},c=()=>{n((e=>{le[J[e]].style[u("top","left")]=`calc(${(Y[e]-a.min)/ee*100}% + ${(.5-(Y[e]-a.min)/ee)*u(Q,K)[e]}px)`}))},D=()=>{const i=(.5-(Y.min-a.min)/ee)*u(Q,K).min/e[`client${u("Height","Width")}`],t=(.5-(Y.max-a.min)/ee)*u(Q,K).max/e[`client${u("Height","Width")}`];me.style[u("top","left")]=100*((Y.min-a.min)/ee+i)+"%",me.style[u("height","width")]=100*((Y.max-a.min)/ee-(Y.min-a.min)/ee-i+t)+"%"},v=()=>{n(((e,i)=>{U[e]=a.thumbsDisabled[i]?Y[e]:a[e]}))},f=()=>{n(((e,i)=>{a.disabled||a.thumbsDisabled[i]?l(le[b(i)],F):s(le[b(i)],F,0)}))},y=()=>{n((e=>{s(le[J[e]],"aria-valuemin",a.min),s(le[J[e]],"aria-valuemax",a.max),s(le[J[e]],"aria-valuenow",Y[e]),s(le[J[e]],"aria-valuetext",Y[e])}))},w=()=>{a.disabled?s(e,X):l(e,X)},S=()=>{a.thumbsDisabled.forEach(((e,a)=>{const i=b(a);e?(s(le[i],X),s(le[i],"aria-disabled",!0)):(l(le[i],X),s(le[i],"aria-disabled",!1))}))},$=(e,i=!1)=>{a[e]=i,x(),n((e=>{se[0][e]=a[e],se[1][e]=a[e]})),ee=a.max-a.min,p("",!0,!0,!1),v()},_=()=>{a.orientation===B?s(e,V):l(e,V),me.style[u("left","top")]="",me.style[u("width","height")]="",le[0].style[u("left","top")]="",le[1].style[u("left","top")]=""},E=()=>{n((e=>{K[e]=z(W(le[J[e]]).width),Q[e]=z(W(le[J[e]]).height)}))},T=(i,t)=>{const n=(t[`offset${u("Top","Left")}`]+(i[`client${u("Y","X")}`]-t.getBoundingClientRect()[u("top","left")])-(te?(.5-(Y[te]-a.min)/ee)*u(Q,K)[te]:0))/e[`client${u("Height","Width")}`]*ee+a.min;return n<a.min?a.min:n>a.max?a.max:n},L=(e,a)=>!e.target.classList.contains(a),R=(e,a)=>{E(),s(a,P),ne=T(e,a),ie=!0},A=(e,i,t)=>{a.disabled||a.thumbsDisabled[b(i)]||(R(e,t),te=J.min===i?C:M,a.onThumbDragStart&&a.onThumbDragStart())},H=e=>{if(ie){const i=T(e,me),n=i-ne;let m=Y.min,s=Y.max;const l=te?U.min:a.min,r=te?U.max:a.max;te&&te!==C||(m=te?i:Z.min+n),te&&te!==M||(s=te?i:Z.max+n),m>=l&&m<=r&&s>=l&&s<=r?(p({min:m,max:s}),ne=i):(m>r&&te&&(p(t(r,r)),ne=i),s<l&&te&&(p(t(l,l)),ne=i),m<l&&(p(t(l,te?Y.max:Y.max-Y.min+l)),ne=i),s>r&&(p(t(te?Y.min:Y.min-Y.max+r,r)),ne=i)),te||v()}},I=()=>{ie&&(l(le[0],P),l(le[1],P),l(me,P),ie=!1,te?a.onThumbDragEnd&&a.onThumbDragEnd():a.onRangeDragEnd&&a.onRangeDragEnd())},N=()=>{E(),c(),D()},j=()=>{const e=z(se[0].step);return se[0].step===k?k:0===e||isNaN(e)?1:e},q=Math.abs,z=parseFloat,W=window.getComputedStyle,C="min",M="max",k="any",B="vertical",F="tabindex",G="data-lower",O="data-upper",P="data-active",V="data-vertical",X="data-disabled",Y=t(),J=t(0,1),K=t(),Q=t(),U=t();let Z=t(),ee=0,ae=0,ie=!1,te=!1,ne=0;o("rangeSlideDisabled",!1),o("thumbsDisabled",[!1,!1]),o("orientation","horizontal"),o("disabled",!1),o("onThumbDragStart",!1),o("onRangeDragStart",!1),o("onThumbDragEnd",!1),o("onRangeDragEnd",!1),o("onInput",!1),o("value",[25,75]),o("step",1),o("min",0),o("max",100),x(),h(),e.innerHTML=`<input type="range" min="${a.min}" max="${a.max}" step="${a.step}" value="${a.value[0]}" disabled><input type="range" min="${a.min}" max="${a.max}" step="${a.step}" value="${a.value[1]}" disabled><div role="slider" class="range-slider__thumb" ${G}></div><div role="slider" class="range-slider__thumb" ${O}></div><div class="range-slider__range"></div>`,e.classList.add("range-slider");const me=e.querySelector(".range-slider__range"),se=e.querySelectorAll("input"),le=e.querySelectorAll(".range-slider__thumb");return ee=a.max-a.min,p("",!0,!1),v(),w(),S(),f(),_(),r(e,"pointerdown",(e=>{(e=>{let i=!1;if(!a.disabled&&(L(e,"range-slider__thumb")&&L(e,"range-slider__range")||a.rangeSlideDisabled&&L(e,"range-slider__thumb"))&&(i=!0),i&&a.thumbsDisabled[0]&&a.thumbsDisabled[1]&&(i=!1),i){const i=T(e,me),n=q(Y.min-i),m=q(Y.max-i);if(a.thumbsDisabled[0])i>=Y.min&&(p(t(Y.min,i),!0),A(e,J.max,le[J.max]));else if(a.thumbsDisabled[1])i<=Y.max&&(p(t(i,Y.max),!0),A(e,J.min,le[J.min]));else{let a=J.max;n===m?p(t(Y.min,i),!0):(p(t(n<m?i:Y.min,m<n?i:Y.max),!0),a=n<m?J.min:J.max),A(e,a,le[a])}}})(e)})),Array.from(le).forEach(((e,i)=>{r(e,"pointerdown",(a=>{A(a,i,e)})),r(e,"keydown",(e=>{e.which>=37&&e.which<=40&&(e.preventDefault(),((e,i)=>{const t=(37===i||40===i?-1:1)*u(-1,1);if(!a.disabled&&!a.thumbsDisabled[b(e)]){let a=j();a=a===k?1:a;let i=Y.min+a*(J.min===e?t:0),n=Y.max+a*(J.max===e?t:0);i>U.max&&(i=U.max),n<U.min&&(n=U.min),p({min:i,max:n},!0)}})(i,e.which))}))})),r(me,"pointerdown",(e=>{(e=>{a.disabled||a.rangeSlideDisabled||(R(e,me),ae=Y.max-Y.min,te=!1,a.onRangeDragStart&&a.onRangeDragStart())})(e)})),r(document,"pointermove",H),r(document,"pointerup",I),r(window,"resize",N),{min:(e=!1)=>m(!e&&0!==e,a.min,(()=>{$(C,e)})),max:(e=!1)=>m(!e&&0!==e,a.max,(()=>{$(M,e)})),step:(e=!1)=>m(!e,j(),(()=>{se[0].step=e,se[1].step=e,p("",!0,!0,!1)})),value:(e=!1)=>m(!e,[Y.min,Y.max],(()=>{p(t(e[0],e[1]),!0,!0,!1),v()})),orientation:(e=!1)=>m(!e,a.orientation,(()=>{a.orientation=e,_(),p("",!0,!0,!1)})),disabled:(e=!0)=>{a.disabled=!!e,w()},thumbsDisabled:(e=[!0,!0])=>{a.thumbsDisabled=e,h(),v(),f(),S()},rangeSlideDisabled:(e=!0)=>{a.rangeSlideDisabled=!!e},currentValueIndex:()=>te?te===C?0:1:-1,removeGlobalEventListeners:()=>{d(document,"pointermove",H),d(document,"pointerup",I),d(window,"resize",N)}}}}},a={},function i(t){var n=a[t];if(void 0!==n)return n.exports;var m=a[t]={exports:{}};return e[t](m,m.exports,i),m.exports}(138);var e,a})); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.rangeSlider=t():e.rangeSlider=t()}(this,(()=>{return e={138:e=>{e.exports=(e,t={})=>{const a=e=>!isNaN(e)&&+e+""==e+"",i=(e=0,t=0)=>({min:e,max:t}),n=e=>{[k,F].forEach(e)},m=(e,t,a)=>{if(e)return t;a()},s=(e,t,a="")=>{e.setAttribute(t,a)},l=(e,t)=>{e.removeAttribute(t)},r=(e,t,a,i=!0)=>{e.addEventListener(t,a,i?{passive:!1,capture:!0}:{})},d=(e,t,a,i=!0)=>{e.removeEventListener(t,a,i?{passive:!1,capture:!0}:{})},o=(e,a)=>{t[e]={}.hasOwnProperty.call(t,e)?t[e]:a},u=(e,a)=>t.orientation===H?e:a,b=e=>1===e?Q.max:Q.min,x=()=>{let e=!1;a(t.min)&&a(t.max)||(e=!0),t.min=e?1:+t.min,t.max=e?1:+t.max},h=()=>{t.thumbsDisabled instanceof Array?(1===t.thumbsDisabled.length&&t.thumbsDisabled.push(!1),1!==t.thumbsDisabled.length&&2!==t.thumbsDisabled.length&&(t.thumbsDisabled=[!1,!1])):t.thumbsDisabled=[t.thumbsDisabled,t.thumbsDisabled],t.thumbsDisabled[0]=!!t.thumbsDisabled[0],t.thumbsDisabled[1]=!!t.thumbsDisabled[1]},p=(e,a=!1,n=!0,m=!0)=>{const r=i(le[Q.min].value,le[Q.max].value);e=e||r,le[Q.min].value=e.min,le[Q.max].value=ne||a?e.max:e.min+ae,g(),K.min>K.max&&(Q.min=+!Q.min,Q.max=+!Q.max,l(re[Q.min],V),l(re[Q.max],P),s(re[Q.min],P),s(re[Q.max],V),ne&&(ne=ne===k?F:k),g()),ee=a?K:e;let d=!1;(r.min!==le[Q.min].value||a)&&(d=!0),(r.max!==le[Q.max].value||a)&&(d=!0),d&&(n&&t.onInput&&t.onInput([K.min,K.max],m),E(),c(),D(),y())},g=()=>{n((e=>{K[e]=+le[Q[e]].value}))},c=()=>{n((e=>{re[Q[e]].style[u("top","left")]=`calc(${(K[e]-t.min)/te*100}% + ${(.5-(K[e]-t.min)/te)*u(W,U)[e]}px)`}))},D=()=>{const a=e.getBoundingClientRect(),i=(.5-(K.min-t.min)/te)*u(W,U).min/u(a.bottom-a.top,a.right-a.left),n=(.5-(K.max-t.min)/te)*u(W,U).max/u(a.bottom-a.top,a.right-a.left);se.style[u("top","left")]=100*((K.min-t.min)/te+i)+"%",se.style[u("height","width")]=100*((K.max-t.min)/te-(K.min-t.min)/te-i+n)+"%"},v=()=>{n(((e,a)=>{Z[e]=t.thumbsDisabled[a]?K[e]:t[e]}))},f=()=>{n(((e,a)=>{t.disabled||t.thumbsDisabled[a]?l(re[b(a)],O):s(re[b(a)],O,0)}))},y=()=>{n((e=>{s(re[Q[e]],"aria-valuemin",t.min),s(re[Q[e]],"aria-valuemax",t.max),s(re[Q[e]],"aria-valuenow",K[e]),s(re[Q[e]],"aria-valuetext",K[e])}))},w=()=>{t.disabled?s(e,J):l(e,J)},S=()=>{t.thumbsDisabled.forEach(((e,t)=>{const a=b(t);e?(s(re[a],J),s(re[a],"aria-disabled",!0)):(l(re[a],J),s(re[a],"aria-disabled",!1))}))},_=(e,a=!1)=>{t[e]=a,x(),n((e=>{le[0][e]=t[e],le[1][e]=t[e]})),te=t.max-t.min,p("",!0,!0,!1),v()},$=()=>{t.orientation===H?s(e,Y):l(e,Y),se.style[u("left","top")]="",se.style[u("width","height")]="",re[0].style[u("left","top")]="",re[1].style[u("left","top")]=""},E=()=>{n((e=>{U[e]=z(M(re[Q[e]]).width),W[e]=z(M(re[Q[e]]).height)}))},R=(a,i)=>{const n=e.getBoundingClientRect(),m=i.getBoundingClientRect(),s=(u(m.top-n.top,m.left-n.left)+(a[`client${u("Y","X")}`]-i.getBoundingClientRect()[u("top","left")])-(ne?(.5-(K[ne]-t.min)/te)*u(W,U)[ne]:0))/u(n.bottom-n.top,n.right-n.left)*te+t.min;return s<t.min?t.min:s>t.max?t.max:s},T=(e,t)=>!e.target.classList.contains(t),A=(e,a=!0)=>{let n=!1;if(!t.disabled&&(T(e,"range-slider__thumb")&&T(e,"range-slider__range")||t.rangeSlideDisabled&&T(e,"range-slider__thumb"))&&(n=!0),n&&t.thumbsDisabled[0]&&t.thumbsDisabled[1]&&(n=!1),n){const n=R(e,se),m=q(K.min-n),s=q(K.max-n);if(t.thumbsDisabled[0])n>=K.min&&(p(i(K.min,n),!0,!a),C(e,Q.max,re[Q.max],!a));else if(t.thumbsDisabled[1])n<=K.max&&(p(i(n,K.max),!0,!a),C(e,Q.min,re[Q.min],!a));else{let t=Q.max;m===s?p(i(K.min,n),!0,!a):(p(i(m<s?n:K.min,s<m?n:K.max),!0,!a),t=m<s?Q.min:Q.max),C(e,t,re[t],!a)}a&&A(e,!1)}},L=(e,t)=>{E(),s(t,X),me=R(e,t),ie=!0},C=(e,a,i,n=!0)=>{t.disabled||t.thumbsDisabled[b(a)]||(L(e,i),ne=Q.min===a?k:F,n&&t.onThumbDragStart&&t.onThumbDragStart())},B=e=>{if(ie){const a=R(e,se),n=a-me;let m=K.min,s=K.max;const l=ne?Z.min:t.min,r=ne?Z.max:t.max;ne&&ne!==k||(m=ne?a:ee.min+n),ne&&ne!==F||(s=ne?a:ee.max+n),m>=l&&m<=r&&s>=l&&s<=r?(p({min:m,max:s}),me=a):(m>r&&ne&&(p(i(r,r)),me=a),s<l&&ne&&(p(i(l,l)),me=a),m<l&&(p(i(l,ne?K.max:K.max-K.min+l)),me=a),s>r&&(p(i(ne?K.min:K.min-K.max+r,r)),me=a)),ne||v()}},I=()=>{ie&&(l(re[0],X),l(re[1],X),l(se,X),ie=!1,ne?t.onThumbDragEnd&&t.onThumbDragEnd():t.onRangeDragEnd&&t.onRangeDragEnd())},N=()=>{E(),c(),D()},j=()=>{const e=z(le[0].step);return le[0].step===G?G:0===e||isNaN(e)?1:e},q=Math.abs,z=parseFloat,M=window.getComputedStyle,k="min",F="max",G="any",H="vertical",O="tabindex",P="data-lower",V="data-upper",X="data-active",Y="data-vertical",J="data-disabled",K=i(),Q=i(0,1),U=i(),W=i(),Z=i();let ee=i(),te=0,ae=0,ie=!1,ne=!1,me=0;o("rangeSlideDisabled",!1),o("thumbsDisabled",[!1,!1]),o("orientation","horizontal"),o("disabled",!1),o("onThumbDragStart",!1),o("onRangeDragStart",!1),o("onThumbDragEnd",!1),o("onRangeDragEnd",!1),o("onInput",!1),o("value",[25,75]),o("step",1),o("min",0),o("max",100),x(),h(),e.innerHTML=`<input type="range" min="${t.min}" max="${t.max}" step="${t.step}" value="${t.value[0]}" disabled><input type="range" min="${t.min}" max="${t.max}" step="${t.step}" value="${t.value[1]}" disabled><div role="slider" class="range-slider__thumb" ${P}></div><div role="slider" class="range-slider__thumb" ${V}></div><div class="range-slider__range"></div>`,e.classList.add("range-slider");const se=e.querySelector(".range-slider__range"),le=e.querySelectorAll("input"),re=e.querySelectorAll(".range-slider__thumb");return te=t.max-t.min,p("",!0,!1),v(),w(),S(),f(),$(),r(e,"pointerdown",(e=>{A(e)})),Array.from(re).forEach(((e,a)=>{r(e,"pointerdown",(t=>{C(t,a,e)})),r(e,"keydown",(e=>{e.which>=37&&e.which<=40&&(e.preventDefault(),((e,a)=>{const i=(37===a||40===a?-1:1)*u(-1,1);if(!t.disabled&&!t.thumbsDisabled[b(e)]){let t=j();t=t===G?1:t;let a=K.min+t*(Q.min===e?i:0),n=K.max+t*(Q.max===e?i:0);a>Z.max&&(a=Z.max),n<Z.min&&(n=Z.min),p({min:a,max:n},!0)}})(a,e.which))}))})),r(se,"pointerdown",(e=>{(e=>{t.disabled||t.rangeSlideDisabled||(L(e,se),ae=K.max-K.min,ne=!1,t.onRangeDragStart&&t.onRangeDragStart())})(e)})),r(document,"pointermove",B),r(document,"pointerup",I),r(window,"resize",N),{min:(e=!1)=>m(!e&&0!==e,t.min,(()=>{_(k,e)})),max:(e=!1)=>m(!e&&0!==e,t.max,(()=>{_(F,e)})),step:(e=!1)=>m(!e,j(),(()=>{le[0].step=e,le[1].step=e,p("",!0,!0,!1)})),value:(e=!1)=>m(!e,[K.min,K.max],(()=>{p(i(e[0],e[1]),!0,!0,!1),v()})),orientation:(e=!1)=>m(!e,t.orientation,(()=>{t.orientation=e,$(),p("",!0,!0,!1)})),disabled:(e=!0)=>{t.disabled=!!e,w()},thumbsDisabled:(e=[!0,!0])=>{t.thumbsDisabled=e,h(),v(),f(),S()},rangeSlideDisabled:(e=!0)=>{t.rangeSlideDisabled=!!e},currentValueIndex:()=>ne?ne===k?0:1:-1,removeGlobalEventListeners:()=>{d(document,"pointermove",B),d(document,"pointerup",I),d(window,"resize",N)}}}}},t={},function a(i){var n=t[i];if(void 0!==n)return n.exports;var m=t[i]={exports:{}};return e[i](m,m.exports,a),m.exports}(138);var e,t})); |
@@ -1,1 +0,1 @@ | ||
!function(e,a){"object"==typeof exports&&"object"==typeof module?module.exports=a():"function"==typeof define&&define.amd?define([],a):"object"==typeof exports?exports.rangeSlider=a():e.rangeSlider=a()}(this,(()=>{return e={265:function(e){e.exports=(e,a={})=>{const t=e=>!isNaN(e)&&+e+""==e+"",i=(e=0,a=0)=>({min:e,max:a}),n=e=>{[N,W].forEach(e)},r=(e,a,t)=>{if(e)return a;t()},s=(e,a,t="")=>{e.setAttribute(a,t)},l=(e,a)=>{e.removeAttribute(a)},d=(e,a,t,i=!0)=>{e.addEventListener(a,t,i?{passive:!1,capture:!0}:{})},m=(e,a,t,i=!0)=>{e.removeEventListener(a,t,i?{passive:!1,capture:!0}:{})},o=(e,t)=>{a[e]={}.hasOwnProperty.call(a,e)?a[e]:t},u=(e,t)=>a.orientation===M?e:t,b=e=>1===e?J.max:J.min,h=()=>{let e=!1;t(a.min)&&t(a.max)||(e=!0),a.min=e?1:+a.min,a.max=e?1:+a.max},p=()=>{a.thumbsDisabled instanceof Array?(1===a.thumbsDisabled.length&&a.thumbsDisabled.push(!1),1!==a.thumbsDisabled.length&&2!==a.thumbsDisabled.length&&(a.thumbsDisabled=[!1,!1])):a.thumbsDisabled=[a.thumbsDisabled,a.thumbsDisabled],a.thumbsDisabled[0]=!!a.thumbsDisabled[0],a.thumbsDisabled[1]=!!a.thumbsDisabled[1]},g=(e,t=!1,n=!0,r=!0)=>{const d=i(se[J.min].value,se[J.max].value);e=e||d,se[J.min].value=e.min,se[J.max].value=ie||t?e.max:e.min+ae,c(),Y.min>Y.max&&(J.min=+!J.min,J.max=+!J.max,l(le[J.min],O),l(le[J.max],G),s(le[J.min],G),s(le[J.max],O),ie&&(ie=ie===N?W:N),c()),Z=t?Y:e;let m=!1;(d.min!==se[J.min].value||t)&&(m=!0),(d.max!==se[J.max].value||t)&&(m=!0),m&&(n&&a.onInput&&a.onInput([Y.min,Y.max],r),E(),x(),v(),w())},c=()=>{n((e=>{Y[e]=+se[J[e]].value}))},x=()=>{n((e=>{le[J[e]].style[u("top","left")]=`calc(${(Y[e]-a.min)/ee*100}% + ${(.5-(Y[e]-a.min)/ee)*u(Q,K)[e]}px)`}))},v=()=>{const t=(.5-(Y.min-a.min)/ee)*u(Q,K).min/e[`client${u("Height","Width")}`],i=(.5-(Y.max-a.min)/ee)*u(Q,K).max/e[`client${u("Height","Width")}`];re.style[u("top","left")]=100*((Y.min-a.min)/ee+t)+"%",re.style[u("height","width")]=100*((Y.max-a.min)/ee-(Y.min-a.min)/ee-t+i)+"%"},f=()=>{n(((e,t)=>{U[e]=a.thumbsDisabled[t]?Y[e]:a[e]}))},D=()=>{n(((e,t)=>{a.disabled||a.thumbsDisabled[t]?l(le[b(t)],F):s(le[b(t)],F,0)}))},w=()=>{n((e=>{s(le[J[e]],"aria-valuemin",a.min),s(le[J[e]],"aria-valuemax",a.max),s(le[J[e]],"aria-valuenow",Y[e]),s(le[J[e]],"aria-valuetext",Y[e])}))},y=()=>{a.disabled?s(e,X):l(e,X)},_=()=>{a.thumbsDisabled.forEach(((e,a)=>{const t=b(a);e?(s(le[t],X),s(le[t],"aria-disabled",!0)):(l(le[t],X),s(le[t],"aria-disabled",!1))}))},S=(e,t=!1)=>{a[e]=t,h(),n((e=>{se[0][e]=a[e],se[1][e]=a[e]})),ee=a.max-a.min,g("",!0,!0,!1),f()},$=()=>{a.orientation===M?s(e,V):l(e,V),re.style[u("left","top")]="",re.style[u("width","height")]="",le[0].style[u("left","top")]="",le[1].style[u("left","top")]=""},E=()=>{n((e=>{K[e]=C(H(le[J[e]]).width),Q[e]=C(H(le[J[e]]).height)}))},k=(t,i)=>{const n=(i[`offset${u("Top","Left")}`]+(t[`client${u("Y","X")}`]-i.getBoundingClientRect()[u("top","left")])-(ie?(.5-(Y[ie]-a.min)/ee)*u(Q,K)[ie]:0))/e[`client${u("Height","Width")}`]*ee+a.min;return n<a.min?a.min:n>a.max?a.max:n},z=(e,a)=>!e.target.classList.contains(a),T=(e,a)=>{E(),s(a,P),ne=k(e,a),te=!0},L=(e,t,i)=>{a.disabled||a.thumbsDisabled[b(t)]||(T(e,i),ie=J.min===t?N:W,a.onThumbDragStart&&a.onThumbDragStart())},R=e=>{if(te){const t=k(e,re),n=t-ne;let r=Y.min,s=Y.max;const l=ie?U.min:a.min,d=ie?U.max:a.max;ie&&ie!==N||(r=ie?t:Z.min+n),ie&&ie!==W||(s=ie?t:Z.max+n),r>=l&&r<=d&&s>=l&&s<=d?(g({min:r,max:s}),ne=t):(r>d&&ie&&(g(i(d,d)),ne=t),s<l&&ie&&(g(i(l,l)),ne=t),r<l&&(g(i(l,ie?Y.max:Y.max-Y.min+l)),ne=t),s>d&&(g(i(ie?Y.min:Y.min-Y.max+d,d)),ne=t)),ie||f()}},A=()=>{te&&(l(le[0],P),l(le[1],P),l(re,P),te=!1,ie?a.onThumbDragEnd&&a.onThumbDragEnd():a.onRangeDragEnd&&a.onRangeDragEnd())},I=()=>{E(),x(),v()},j=()=>{const e=C(se[0].step);return se[0].step===B?B:0===e||isNaN(e)?1:e},q=Math.abs,C=parseFloat,H=window.getComputedStyle,N="min",W="max",B="any",M="vertical",F="tabindex",G="data-lower",O="data-upper",P="data-active",V="data-vertical",X="data-disabled",Y=i(),J=i(0,1),K=i(),Q=i(),U=i();let Z=i(),ee=0,ae=0,te=!1,ie=!1,ne=0;if(!this.cssInjected){const e=document.createElement("style");e.textContent=".range-slider{touch-action:none;-webkit-tap-highlight-color:transparent;-webkit-user-select:none;user-select:none;cursor:pointer;display:block;position:relative;width:100%;height:8px;background:#ddd;border-radius:4px}.range-slider[data-vertical]{height:100%;width:8px}.range-slider[data-disabled]{opacity:.5;cursor:not-allowed}.range-slider .range-slider__thumb{position:absolute;z-index:3;top:50%;width:24px;height:24px;transform:translate(-50%,-50%);border-radius:50%;background:#2196f3}.range-slider .range-slider__thumb:focus-visible{outline:0;box-shadow:0 0 0 6px rgba(33,150,243,.5)}.range-slider[data-vertical] .range-slider__thumb{left:50%}.range-slider .range-slider__thumb[data-disabled]{z-index:2}.range-slider .range-slider__range{position:absolute;z-index:1;transform:translate(0,-50%);top:50%;width:100%;height:100%;background:#51adf6}.range-slider[data-vertical] .range-slider__range{left:50%;transform:translate(-50%,0)}.range-slider input[type=range]{-webkit-appearance:none;pointer-events:none;position:absolute;z-index:2;top:0;left:0;width:0;height:0;background-color:transparent}.range-slider input[type=range]::-webkit-slider-thumb{-webkit-appearance:none;appearance:none}.range-slider input[type=range]::-moz-range-thumb{width:0;height:0;border:0}.range-slider input[type=range]:focus{outline:0}";const a=document.head,t=document.querySelector("head>style,head>link");t?a.insertBefore(e,t):a.appendChild(e),this.cssInjected=!0}o("rangeSlideDisabled",!1),o("thumbsDisabled",[!1,!1]),o("orientation","horizontal"),o("disabled",!1),o("onThumbDragStart",!1),o("onRangeDragStart",!1),o("onThumbDragEnd",!1),o("onRangeDragEnd",!1),o("onInput",!1),o("value",[25,75]),o("step",1),o("min",0),o("max",100),h(),p(),e.innerHTML=`<input type="range" min="${a.min}" max="${a.max}" step="${a.step}" value="${a.value[0]}" disabled><input type="range" min="${a.min}" max="${a.max}" step="${a.step}" value="${a.value[1]}" disabled><div role="slider" class="range-slider__thumb" ${G}></div><div role="slider" class="range-slider__thumb" ${O}></div><div class="range-slider__range"></div>`,e.classList.add("range-slider");const re=e.querySelector(".range-slider__range"),se=e.querySelectorAll("input"),le=e.querySelectorAll(".range-slider__thumb");return ee=a.max-a.min,g("",!0,!1),f(),y(),_(),D(),$(),d(e,"pointerdown",(e=>{(e=>{let t=!1;if(!a.disabled&&(z(e,"range-slider__thumb")&&z(e,"range-slider__range")||a.rangeSlideDisabled&&z(e,"range-slider__thumb"))&&(t=!0),t&&a.thumbsDisabled[0]&&a.thumbsDisabled[1]&&(t=!1),t){const t=k(e,re),n=q(Y.min-t),r=q(Y.max-t);if(a.thumbsDisabled[0])t>=Y.min&&(g(i(Y.min,t),!0),L(e,J.max,le[J.max]));else if(a.thumbsDisabled[1])t<=Y.max&&(g(i(t,Y.max),!0),L(e,J.min,le[J.min]));else{let a=J.max;n===r?g(i(Y.min,t),!0):(g(i(n<r?t:Y.min,r<n?t:Y.max),!0),a=n<r?J.min:J.max),L(e,a,le[a])}}})(e)})),Array.from(le).forEach(((e,t)=>{d(e,"pointerdown",(a=>{L(a,t,e)})),d(e,"keydown",(e=>{e.which>=37&&e.which<=40&&(e.preventDefault(),((e,t)=>{const i=(37===t||40===t?-1:1)*u(-1,1);if(!a.disabled&&!a.thumbsDisabled[b(e)]){let a=j();a=a===B?1:a;let t=Y.min+a*(J.min===e?i:0),n=Y.max+a*(J.max===e?i:0);t>U.max&&(t=U.max),n<U.min&&(n=U.min),g({min:t,max:n},!0)}})(t,e.which))}))})),d(re,"pointerdown",(e=>{(e=>{a.disabled||a.rangeSlideDisabled||(T(e,re),ae=Y.max-Y.min,ie=!1,a.onRangeDragStart&&a.onRangeDragStart())})(e)})),d(document,"pointermove",R),d(document,"pointerup",A),d(window,"resize",I),{min:(e=!1)=>r(!e&&0!==e,a.min,(()=>{S(N,e)})),max:(e=!1)=>r(!e&&0!==e,a.max,(()=>{S(W,e)})),step:(e=!1)=>r(!e,j(),(()=>{se[0].step=e,se[1].step=e,g("",!0,!0,!1)})),value:(e=!1)=>r(!e,[Y.min,Y.max],(()=>{g(i(e[0],e[1]),!0,!0,!1),f()})),orientation:(e=!1)=>r(!e,a.orientation,(()=>{a.orientation=e,$(),g("",!0,!0,!1)})),disabled:(e=!0)=>{a.disabled=!!e,y()},thumbsDisabled:(e=[!0,!0])=>{a.thumbsDisabled=e,p(),f(),D(),_()},rangeSlideDisabled:(e=!0)=>{a.rangeSlideDisabled=!!e},currentValueIndex:()=>ie?ie===N?0:1:-1,removeGlobalEventListeners:()=>{m(document,"pointermove",R),m(document,"pointerup",A),m(window,"resize",I)}}}}},a={},function t(i){var n=a[i];if(void 0!==n)return n.exports;var r=a[i]={exports:{}};return e[i].call(r.exports,r,r.exports,t),r.exports}(265);var e,a})); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.rangeSlider=t():e.rangeSlider=t()}(this,(()=>{return e={265:function(e){e.exports=(e,t={})=>{const a=e=>!isNaN(e)&&+e+""==e+"",n=(e=0,t=0)=>({min:e,max:t}),i=e=>{[M,F].forEach(e)},r=(e,t,a)=>{if(e)return t;a()},s=(e,t,a="")=>{e.setAttribute(t,a)},l=(e,t)=>{e.removeAttribute(t)},m=(e,t,a,n=!0)=>{e.addEventListener(t,a,n?{passive:!1,capture:!0}:{})},d=(e,t,a,n=!0)=>{e.removeEventListener(t,a,n?{passive:!1,capture:!0}:{})},o=(e,a)=>{t[e]={}.hasOwnProperty.call(t,e)?t[e]:a},u=(e,a)=>t.orientation===H?e:a,b=e=>1===e?Q.max:Q.min,h=()=>{let e=!1;a(t.min)&&a(t.max)||(e=!0),t.min=e?1:+t.min,t.max=e?1:+t.max},p=()=>{t.thumbsDisabled instanceof Array?(1===t.thumbsDisabled.length&&t.thumbsDisabled.push(!1),1!==t.thumbsDisabled.length&&2!==t.thumbsDisabled.length&&(t.thumbsDisabled=[!1,!1])):t.thumbsDisabled=[t.thumbsDisabled,t.thumbsDisabled],t.thumbsDisabled[0]=!!t.thumbsDisabled[0],t.thumbsDisabled[1]=!!t.thumbsDisabled[1]},g=(e,a=!1,i=!0,r=!0)=>{const m=n(le[Q.min].value,le[Q.max].value);e=e||m,le[Q.min].value=e.min,le[Q.max].value=ie||a?e.max:e.min+ae,c(),K.min>K.max&&(Q.min=+!Q.min,Q.max=+!Q.max,l(me[Q.min],V),l(me[Q.max],P),s(me[Q.min],P),s(me[Q.max],V),ie&&(ie=ie===M?F:M),c()),ee=a?K:e;let d=!1;(m.min!==le[Q.min].value||a)&&(d=!0),(m.max!==le[Q.max].value||a)&&(d=!0),d&&(i&&t.onInput&&t.onInput([K.min,K.max],r),$(),x(),f(),w())},c=()=>{i((e=>{K[e]=+le[Q[e]].value}))},x=()=>{i((e=>{me[Q[e]].style[u("top","left")]=`calc(${(K[e]-t.min)/te*100}% + ${(.5-(K[e]-t.min)/te)*u(W,U)[e]}px)`}))},f=()=>{const a=e.getBoundingClientRect(),n=(.5-(K.min-t.min)/te)*u(W,U).min/u(a.bottom-a.top,a.right-a.left),i=(.5-(K.max-t.min)/te)*u(W,U).max/u(a.bottom-a.top,a.right-a.left);se.style[u("top","left")]=100*((K.min-t.min)/te+n)+"%",se.style[u("height","width")]=100*((K.max-t.min)/te-(K.min-t.min)/te-n+i)+"%"},v=()=>{i(((e,a)=>{Z[e]=t.thumbsDisabled[a]?K[e]:t[e]}))},D=()=>{i(((e,a)=>{t.disabled||t.thumbsDisabled[a]?l(me[b(a)],O):s(me[b(a)],O,0)}))},w=()=>{i((e=>{s(me[Q[e]],"aria-valuemin",t.min),s(me[Q[e]],"aria-valuemax",t.max),s(me[Q[e]],"aria-valuenow",K[e]),s(me[Q[e]],"aria-valuetext",K[e])}))},y=()=>{t.disabled?s(e,J):l(e,J)},_=()=>{t.thumbsDisabled.forEach(((e,t)=>{const a=b(t);e?(s(me[a],J),s(me[a],"aria-disabled",!0)):(l(me[a],J),s(me[a],"aria-disabled",!1))}))},S=(e,a=!1)=>{t[e]=a,h(),i((e=>{le[0][e]=t[e],le[1][e]=t[e]})),te=t.max-t.min,g("",!0,!0,!1),v()},E=()=>{t.orientation===H?s(e,Y):l(e,Y),se.style[u("left","top")]="",se.style[u("width","height")]="",me[0].style[u("left","top")]="",me[1].style[u("left","top")]=""},$=()=>{i((e=>{U[e]=q(N(me[Q[e]]).width),W[e]=q(N(me[Q[e]]).height)}))},k=(a,n)=>{const i=e.getBoundingClientRect(),r=n.getBoundingClientRect(),s=(u(r.top-i.top,r.left-i.left)+(a[`client${u("Y","X")}`]-n.getBoundingClientRect()[u("top","left")])-(ie?(.5-(K[ie]-t.min)/te)*u(W,U)[ie]:0))/u(i.bottom-i.top,i.right-i.left)*te+t.min;return s<t.min?t.min:s>t.max?t.max:s},R=(e,t)=>!e.target.classList.contains(t),z=(e,a=!0)=>{let i=!1;if(!t.disabled&&(R(e,"range-slider__thumb")&&R(e,"range-slider__range")||t.rangeSlideDisabled&&R(e,"range-slider__thumb"))&&(i=!0),i&&t.thumbsDisabled[0]&&t.thumbsDisabled[1]&&(i=!1),i){const i=k(e,se),r=B(K.min-i),s=B(K.max-i);if(t.thumbsDisabled[0])i>=K.min&&(g(n(K.min,i),!0,!a),T(e,Q.max,me[Q.max],!a));else if(t.thumbsDisabled[1])i<=K.max&&(g(n(i,K.max),!0,!a),T(e,Q.min,me[Q.min],!a));else{let t=Q.max;r===s?g(n(K.min,i),!0,!a):(g(n(r<s?i:K.min,s<r?i:K.max),!0,!a),t=r<s?Q.min:Q.max),T(e,t,me[t],!a)}a&&z(e,!1)}},C=(e,t)=>{$(),s(t,X),re=k(e,t),ne=!0},T=(e,a,n,i=!0)=>{t.disabled||t.thumbsDisabled[b(a)]||(C(e,n),ie=Q.min===a?M:F,i&&t.onThumbDragStart&&t.onThumbDragStart())},A=e=>{if(ne){const a=k(e,se),i=a-re;let r=K.min,s=K.max;const l=ie?Z.min:t.min,m=ie?Z.max:t.max;ie&&ie!==M||(r=ie?a:ee.min+i),ie&&ie!==F||(s=ie?a:ee.max+i),r>=l&&r<=m&&s>=l&&s<=m?(g({min:r,max:s}),re=a):(r>m&&ie&&(g(n(m,m)),re=a),s<l&&ie&&(g(n(l,l)),re=a),r<l&&(g(n(l,ie?K.max:K.max-K.min+l)),re=a),s>m&&(g(n(ie?K.min:K.min-K.max+m,m)),re=a)),ie||v()}},I=()=>{ne&&(l(me[0],X),l(me[1],X),l(se,X),ne=!1,ie?t.onThumbDragEnd&&t.onThumbDragEnd():t.onRangeDragEnd&&t.onRangeDragEnd())},L=()=>{$(),x(),f()},j=()=>{const e=q(le[0].step);return le[0].step===G?G:0===e||isNaN(e)?1:e},B=Math.abs,q=parseFloat,N=window.getComputedStyle,M="min",F="max",G="any",H="vertical",O="tabindex",P="data-lower",V="data-upper",X="data-active",Y="data-vertical",J="data-disabled",K=n(),Q=n(0,1),U=n(),W=n(),Z=n();let ee=n(),te=0,ae=0,ne=!1,ie=!1,re=0;if(!this.cssInjected){const e=document.createElement("style");e.textContent=".range-slider{touch-action:none;-webkit-tap-highlight-color:transparent;-webkit-user-select:none;user-select:none;cursor:pointer;display:block;position:relative;width:100%;height:8px;background:#ddd;border-radius:4px}.range-slider[data-vertical]{height:100%;width:8px}.range-slider[data-disabled]{opacity:.5;cursor:not-allowed}.range-slider .range-slider__thumb{position:absolute;z-index:3;top:50%;width:24px;height:24px;transform:translate(-50%,-50%);border-radius:50%;background:#2196f3}.range-slider .range-slider__thumb:focus-visible{outline:0;box-shadow:0 0 0 6px rgba(33,150,243,.5)}.range-slider[data-vertical] .range-slider__thumb{left:50%}.range-slider .range-slider__thumb[data-disabled]{z-index:2}.range-slider .range-slider__range{position:absolute;z-index:1;transform:translate(0,-50%);top:50%;width:100%;height:100%;background:#51adf6}.range-slider[data-vertical] .range-slider__range{left:50%;transform:translate(-50%,0)}.range-slider input[type=range]{-webkit-appearance:none;pointer-events:none;position:absolute;z-index:2;top:0;left:0;width:0;height:0;background-color:transparent}.range-slider input[type=range]::-webkit-slider-thumb{-webkit-appearance:none;appearance:none}.range-slider input[type=range]::-moz-range-thumb{width:0;height:0;border:0}.range-slider input[type=range]:focus{outline:0}";const t=document.head,a=document.querySelector("head>style,head>link");a?t.insertBefore(e,a):t.appendChild(e),this.cssInjected=!0}o("rangeSlideDisabled",!1),o("thumbsDisabled",[!1,!1]),o("orientation","horizontal"),o("disabled",!1),o("onThumbDragStart",!1),o("onRangeDragStart",!1),o("onThumbDragEnd",!1),o("onRangeDragEnd",!1),o("onInput",!1),o("value",[25,75]),o("step",1),o("min",0),o("max",100),h(),p(),e.innerHTML=`<input type="range" min="${t.min}" max="${t.max}" step="${t.step}" value="${t.value[0]}" disabled><input type="range" min="${t.min}" max="${t.max}" step="${t.step}" value="${t.value[1]}" disabled><div role="slider" class="range-slider__thumb" ${P}></div><div role="slider" class="range-slider__thumb" ${V}></div><div class="range-slider__range"></div>`,e.classList.add("range-slider");const se=e.querySelector(".range-slider__range"),le=e.querySelectorAll("input"),me=e.querySelectorAll(".range-slider__thumb");return te=t.max-t.min,g("",!0,!1),v(),y(),_(),D(),E(),m(e,"pointerdown",(e=>{z(e)})),Array.from(me).forEach(((e,a)=>{m(e,"pointerdown",(t=>{T(t,a,e)})),m(e,"keydown",(e=>{e.which>=37&&e.which<=40&&(e.preventDefault(),((e,a)=>{const n=(37===a||40===a?-1:1)*u(-1,1);if(!t.disabled&&!t.thumbsDisabled[b(e)]){let t=j();t=t===G?1:t;let a=K.min+t*(Q.min===e?n:0),i=K.max+t*(Q.max===e?n:0);a>Z.max&&(a=Z.max),i<Z.min&&(i=Z.min),g({min:a,max:i},!0)}})(a,e.which))}))})),m(se,"pointerdown",(e=>{(e=>{t.disabled||t.rangeSlideDisabled||(C(e,se),ae=K.max-K.min,ie=!1,t.onRangeDragStart&&t.onRangeDragStart())})(e)})),m(document,"pointermove",A),m(document,"pointerup",I),m(window,"resize",L),{min:(e=!1)=>r(!e&&0!==e,t.min,(()=>{S(M,e)})),max:(e=!1)=>r(!e&&0!==e,t.max,(()=>{S(F,e)})),step:(e=!1)=>r(!e,j(),(()=>{le[0].step=e,le[1].step=e,g("",!0,!0,!1)})),value:(e=!1)=>r(!e,[K.min,K.max],(()=>{g(n(e[0],e[1]),!0,!0,!1),v()})),orientation:(e=!1)=>r(!e,t.orientation,(()=>{t.orientation=e,E(),g("",!0,!0,!1)})),disabled:(e=!0)=>{t.disabled=!!e,y()},thumbsDisabled:(e=[!0,!0])=>{t.thumbsDisabled=e,p(),v(),D(),_()},rangeSlideDisabled:(e=!0)=>{t.rangeSlideDisabled=!!e},currentValueIndex:()=>ie?ie===M?0:1:-1,removeGlobalEventListeners:()=>{d(document,"pointermove",A),d(document,"pointerup",I),d(window,"resize",L)}}}}},t={},function a(n){var i=t[n];if(void 0!==i)return i.exports;var r=t[n]={exports:{}};return e[n].call(r.exports,r,r.exports,a),r.exports}(265);var e,t})); |
{ | ||
"name": "range-slider-input", | ||
"version": "2.4.2", | ||
"version": "2.4.3", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "description": "A lightweight (~2kB) library to create range sliders that can capture a value or a range of values with one or two drag handles", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32903