Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@radix-ui/react-slider

Package Overview
Dependencies
Maintainers
5
Versions
178
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@radix-ui/react-slider - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

2

dist/index.js

@@ -1,2 +0,2 @@

var e,n,t=require("@radix-ui/react-collection").createCollection,r=require("@radix-ui/react-primitive").Primitive,o=require("@radix-ui/react-utils"),i=o.composeEventHandlers,u=o.createContext,a=o.useComposedRefs,l=o.useControlledState,c=o.useCallbackRef,d=o.useSize,f=require("@radix-ui/utils"),s=f.clamp,v=f.getSelector,m=(e={},n=require("react"),Object.keys(n).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return n[t]}})})),e);function p(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function h(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?p(Object(t),!0).forEach((function(n){S(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):p(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}function S(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function y(){return(y=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}function b(e){return function(e){if(Array.isArray(e))return x(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||E(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(e,n){if(null==e)return{};var t,r,o=function(e,n){if(null==e)return{};var t,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)t=i[r],n.indexOf(t)>=0||(o[t]=e[t]);return o}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)t=i[r],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}function w(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var t=[],r=!0,o=!1,i=void 0;try{for(var u,a=e[Symbol.iterator]();!(r=(u=a.next()).done)&&(t.push(u.value),!n||t.length!==n);r=!0);}catch(e){o=!0,i=e}finally{try{r||null==a.return||a.return()}finally{if(o)throw i}}return t}(e,n)||E(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function E(e,n){if(e){if("string"==typeof e)return x(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?x(e,n):void 0}}function x(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}var M=["PageUp","PageDown"],O=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],T={ltr:["ArrowDown","Home","ArrowLeft","PageUp"],rtl:["ArrowDown","Home","ArrowRight","PageDown"]},D=w(t("Slider"),2),R=D[0],P=D[1],j=R((function(e){return m.createElement(m.Fragment,null,e.children)})),A=w(u("SliderContext","Slider"),2),C=A[0],K=A[1],k=m.forwardRef((function(e,n){var t=e.name,r=e.min,o=void 0===r?0:r,i=e.max,u=void 0===i?100:i,c=e.step,d=void 0===c?1:c,f=e.orientation,v=void 0===f?"horizontal":f,p=e.disabled,h=void 0!==p&&p,S=e.minStepsBetweenThumbs,E=void 0===S?0:S,x=e.defaultValue,T=void 0===x?[o]:x,D=e.value,R=e.onValueChange,P=void 0===R?function(){}:R,A=g(e,["name","min","max","step","orientation","disabled","minStepsBetweenThumbs","defaultValue","value","onValueChange"]),K=Math.max(d,1),k=m.useRef(null),I=a(n,k),H=m.useRef(new Set),z=m.useRef(0),q="horizontal"===v?L:U,F=w(l({prop:D,defaultProp:T,onChange:P}),2),V=F[0],B=void 0===V?[]:V,N=F[1];function $(e,n){var t=Math.round((e-o)/K)*K+o,r=s(t,[o,u]);return new Promise((function(e){N((function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],o=Y(t,r,n);return _(o,E*K)?(z.current=o.indexOf(r),e(z.current),o[n]!==t[n]?o:t):(e(z.current),t)}))}))}function G(e){var n;null===(n=b(H.current)[e])||void 0===n||n.focus()}return m.createElement(C.Provider,{value:m.useMemo((function(){return{min:o,max:u,valueIndexToChangeRef:z,thumbs:H.current,values:B,orientation:v}}),[o,u,B,v])},m.createElement(j,null,m.createElement(q,y({},A,{ref:I,min:o,max:u,"aria-disabled":h,"data-disabled":h,onSlideStart:h?void 0:function(e){$(e,function(e,n){if(1===e.length)return 0;var t=e.map((function(e){return Math.abs(e-n)})),r=Math.min.apply(Math,b(t));return t.indexOf(r)}(B,e)).then((function(e){window.setTimeout((function(){return G(e)}),0)}))},onSlideMove:h?void 0:function(e){$(e,z.current).then(G)},onHomeKeyDown:function(){return!h&&$(o,0)},onEndKeyDown:function(){return!h&&$(u,B.length-1)},onStepKeyDown:function(e){var n=e.event,t=e.direction;if(!h){var r=M.includes(n.key)||n.shiftKey&&O.includes(n.key)?10:1,o=z.current;$(B[o]+K*r*t,o)}}})),t&&B.map((function(e,n){return m.createElement(X,{key:n,name:t+(B.length>1?"[]":""),value:e,hidden:!0})}))))}));exports.Slider=k,k.displayName="Slider";var I=m.createContext({}),L=m.forwardRef((function(e,n){var t=e.min,r=e.max,o=e.dir,i=e.onSlideStart,u=e.onSlideMove,l=e.onStepKeyDown,c=g(e,["min","max","dir","onSlideStart","onSlideMove","onStepKeyDown"]),d=m.useRef(null),f=a(n,d),s=m.useRef(),v=function(e){var n=e.ref,t=e.directionProp,r=w(m.useState("ltr"),2),o=r[0],i=r[1],u=w(m.useState(),2),a=u[0],l=u[1],c=m.useRef(0);return m.useEffect((function(){if(void 0===t){var e=getComputedStyle(n.current);l(e)}}),[t,n]),m.useEffect((function(){function e(){c.current=requestAnimationFrame((function(){var n=null==a?void 0:a.direction;n&&i(n),e()}))}return void 0===t&&e(),function(){return cancelAnimationFrame(c.current)}}),[a,t,i]),t||o}({ref:d,directionProp:o}),p="ltr"===v;function b(e){var n=s.current||d.current.getBoundingClientRect(),o=$([0,n.width],p?[t,r]:[r,t]);return s.current=n,o(e-n.left)}return m.createElement(I.Provider,{value:m.useMemo((function(){return{startEdge:p?"left":"right",endEdge:p?"right":"left",direction:p?1:-1,size:"width"}}),[p])},m.createElement(H,y({},c,{ref:f,style:h(h({},c.style),{},S({},"--radix-slider-thumb-transform","translateX(-50%)")),"data-orientation":"horizontal",onSlideMouseDown:function(e){var n=b(e.clientX);null==i||i(n)},onSlideMouseMove:function(e){var n=b(e.clientX);null==u||u(n)},onSlideMouseUp:function(){return s.current=void 0},onSlideTouchStart:function(e){var n=b(e.targetTouches[0].clientX);null==i||i(n)},onSlideTouchMove:function(e){var n=b(e.targetTouches[0].clientX);null==u||u(n)},onSlideTouchEnd:function(){return s.current=void 0},onStepKeyDown:function(e){function n(n){return e.apply(this,arguments)}return n.toString=function(){return e.toString()},n}((function(e){var n=T[v].includes(e.key);null==l||l({event:e,direction:n?-1:1})}))})))})),U=m.forwardRef((function(e,n){var t=e.min,r=e.max,o=e.onSlideStart,i=e.onSlideMove,u=e.onStepKeyDown,l=g(e,["min","max","onSlideStart","onSlideMove","onStepKeyDown"]),c=m.useRef(null),d=a(n,c),f=m.useRef();function s(e){var n=f.current||c.current.getBoundingClientRect(),o=$([0,n.height],[r,t]);return f.current=n,o(e-n.top)}return m.createElement(I.Provider,{value:m.useMemo((function(){return{startEdge:"bottom",endEdge:"top",size:"height",direction:1}}),[])},m.createElement(H,y({},l,{ref:d,style:h(h({},l.style),{},S({},"--radix-slider-thumb-transform","translateY(50%)")),"data-orientation":"vertical",onSlideMouseDown:function(e){var n=s(e.clientY);null==o||o(n)},onSlideMouseMove:function(e){var n=s(e.clientY);null==i||i(n)},onSlideMouseUp:function(){return f.current=void 0},onSlideTouchStart:function(e){var n=s(e.targetTouches[0].clientY);null==o||o(n)},onSlideTouchMove:function(e){var n=s(e.targetTouches[0].clientY);null==i||i(n)},onSlideTouchEnd:function(){return f.current=void 0},onStepKeyDown:function(e){function n(n){return e.apply(this,arguments)}return n.toString=function(){return e.toString()},n}((function(e){var n=T.ltr.includes(e.key);null==u||u({event:e,direction:n?-1:1})}))})))})),H=m.forwardRef((function(e,n){var t=e.as,o=void 0===t?"span":t,u=e.selector,a=void 0===u?v("Slider"):u,l=e.onSlideMouseDown,d=e.onSlideMouseMove,f=e.onSlideMouseUp,s=e.onSlideTouchStart,p=e.onSlideTouchMove,h=e.onSlideTouchEnd,S=e.onHomeKeyDown,b=e.onEndKeyDown,w=e.onStepKeyDown,E=g(e,["as","selector","onSlideMouseDown","onSlideMouseMove","onSlideMouseUp","onSlideTouchStart","onSlideTouchMove","onSlideTouchEnd","onHomeKeyDown","onEndKeyDown","onStepKeyDown"]),x=c(d),T=c(p),D=c((function(){document.removeEventListener("mousemove",x),document.removeEventListener("mouseup",D),f()})),R=c((function(){document.removeEventListener("touchmove",T),document.removeEventListener("touchend",R),h()}));return m.useEffect((function(){return function(){D(),R()}}),[D,R]),m.createElement(r,y({},E,{as:o,selector:a,ref:n,onMouseDown:i(e.onMouseDown,(function(e){0===e.button&&(B(e.target)||l(e),document.addEventListener("mousemove",x),document.addEventListener("mouseup",D))})),onTouchStart:i(e.onTouchStart,(function(e){B(e.target)?e.target.focus():s(e),document.addEventListener("touchmove",T),document.addEventListener("touchend",R),e.preventDefault()})),onKeyDown:i(e.onKeyDown,(function(e){"Home"===e.key?S(e):"End"===e.key?b(e):M.concat(O).includes(e.key)&&(w(e),e.preventDefault())})),onPointerDown:i(e.onPointerDown,(function(e){e.target.setPointerCapture(e.pointerId)})),onPointerUp:i(e.onPointerUp,(function(e){e.target.releasePointerCapture(e.pointerId)}))}))})),z=m.forwardRef((function(e,n){var t=e.as,o=void 0===t?"span":t,i=e.selector,u=void 0===i?v("SliderTrack"):i,a=g(e,["as","selector"]),l=K("SliderTrack");return m.createElement(r,y({},a,{as:o,selector:u,ref:n,"data-orientation":l.orientation}))}));exports.SliderTrack=z,z.displayName="SliderTrack";var q=m.forwardRef((function(e,n){var t,o=e.as,i=void 0===o?"span":o,u=e.selector,l=void 0===u?v("SliderRange"):u,c=g(e,["as","selector"]),d=K("SliderRange"),f=m.useContext(I),s=m.useRef(null),p=a(n,s),w=d.values.length,E=d.values.map((function(e){return N(e,d.min,d.max)})),x=w>1?Math.min.apply(Math,b(E)):0,M=100-Math.max.apply(Math,b(E));return m.createElement(r,y({},c,{as:i,selector:l,ref:p,style:h(h({},e.style),{},(t={},S(t,f.startEdge,x+"%"),S(t,f.endEdge,M+"%"),t)),"data-orientation":d.orientation}))}));exports.SliderRange=q,q.displayName="SliderRange";var F=m.forwardRef((function(e,n){var t=P(),r=t.ref,o=t.index,i=a(n,r),u=K("SliderThumb").values[o];return void 0!==u?m.createElement(V,y({},e,{ref:i,index:o,value:u})):null}));exports.SliderThumb=F;var V=m.forwardRef((function(e,n){var t,o,u,l,c,f=e.as,s=void 0===f?"span":f,p=e.selector,h=void 0===p?v("SliderThumb"):p,b=e.index,w=e.value,E=g(e,["as","selector","index","value"]),x=K("SliderThumb"),M=m.useContext(I),O=m.useRef(null),T=a(n,O),D=d(O),R=N(w,x.min,x.max),P=function(e,n){return n>2?"Value ".concat(e+1," of ").concat(n):2===n?["Minimum","Maximum"][e]:void 0}(b,x.values.length),j=null==D?void 0:D[M.size],A=j?(t=j,o=R,u=M.direction,c=$([0,50],[0,l=t/2]),(l-c(o)*u)*u):0;return m.useEffect((function(){var e=O.current;if(e)return x.thumbs.add(e),function(){x.thumbs.delete(e)}}),[x.thumbs]),m.createElement("span",{style:S({transform:"var(--radix-slider-thumb-transform)",position:"absolute"},M.startEdge,"calc(".concat(R,"% + ").concat(A,"px)"))},m.createElement(r,y({},E,{as:s,selector:h,ref:T,"aria-label":e["aria-label"]||P,"aria-valuemin":x.min,"aria-valuenow":w,"aria-valuemax":x.max,"aria-orientation":x.orientation,"data-orientation":x.orientation,role:"slider",tabIndex:0,onFocus:i(e.onFocus,(function(){x.valueIndexToChangeRef.current=b}))})))}));F.displayName="SliderThumb";var X=function(e){var n=e.value,t=g(e,["value"]),r=m.useRef(null);return m.useEffect((function(){var e=r.current,t=window.HTMLInputElement.prototype,o=Object.getOwnPropertyDescriptor(t,"value").set;if(o){var i=new Event("input",{bubbles:!0});o.call(e,n),e.dispatchEvent(i)}}),[n]),m.createElement("input",y({hidden:!0},t,{ref:r}))};function Y(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1?arguments[1]:void 0,t=arguments.length>2?arguments[2]:void 0,r=b(e);return r[t]=n,r.sort((function(e,n){return e-n}))}function B(e){var n="data-".concat(v("SliderThumb"));return""===e.getAttribute(n)}function N(e,n,t){return 100/(t-n)*(e-n)}function _(e,n){if(n>0){var t=function(e){return e.slice(0,-1).map((function(n,t){return e[t+1]-n}))}(e);return Math.min.apply(Math,b(t))>=n}return!0}function $(e,n){return function(t){if(e[0]===e[1]||n[0]===n[1])return n[0];var r=(n[1]-n[0])/(e[1]-e[0]);return n[0]+r*(t-e[0])}}var G=k;exports.Root=G;var J=z;exports.Track=J;var Q=q;exports.Range=Q;var W=F;exports.Thumb=W;
var e,n,t=require("@radix-ui/react-collection").createCollection,r=require("@radix-ui/react-primitive").Primitive,o=require("@radix-ui/react-utils"),i=o.composeEventHandlers,u=o.createContext,a=o.useComposedRefs,l=o.useControlledState,c=o.useCallbackRef,d=o.useSize,f=require("@radix-ui/utils"),s=f.clamp,v=f.getSelector,m=(e={},n=require("react"),Object.keys(n).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return n[t]}})})),e);function p(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function h(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?p(Object(t),!0).forEach((function(n){S(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):p(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}function S(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function y(){return(y=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}function b(e){return function(e){if(Array.isArray(e))return x(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||E(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(e,n){if(null==e)return{};var t,r,o=function(e,n){if(null==e)return{};var t,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)t=i[r],n.indexOf(t)>=0||(o[t]=e[t]);return o}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)t=i[r],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}function w(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var t=[],r=!0,o=!1,i=void 0;try{for(var u,a=e[Symbol.iterator]();!(r=(u=a.next()).done)&&(t.push(u.value),!n||t.length!==n);r=!0);}catch(e){o=!0,i=e}finally{try{r||null==a.return||a.return()}finally{if(o)throw i}}return t}(e,n)||E(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function E(e,n){if(e){if("string"==typeof e)return x(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?x(e,n):void 0}}function x(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}var M=["PageUp","PageDown"],O=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],T={ltr:["ArrowDown","Home","ArrowLeft","PageUp"],rtl:["ArrowDown","Home","ArrowRight","PageDown"]},D=w(t("Slider"),2),R=D[0],P=D[1],j=R((function(e){return m.createElement(m.Fragment,null,e.children)})),A=w(u("SliderContext","Slider"),2),C=A[0],K=A[1],k=m.forwardRef((function(e,n){var t=e.name,r=e.min,o=void 0===r?0:r,i=e.max,u=void 0===i?100:i,c=e.step,d=void 0===c?1:c,f=e.orientation,v=void 0===f?"horizontal":f,p=e.disabled,h=void 0!==p&&p,S=e.minStepsBetweenThumbs,E=void 0===S?0:S,x=e.defaultValue,T=void 0===x?[o]:x,D=e.value,R=e.onValueChange,P=void 0===R?function(){}:R,A=g(e,["name","min","max","step","orientation","disabled","minStepsBetweenThumbs","defaultValue","value","onValueChange"]),K=Math.max(d,1),k=m.useRef(null),I=a(n,k),H=m.useRef(new Set),z=m.useRef(0),q="horizontal"===v?L:U,F=w(l({prop:D,defaultProp:T,onChange:P}),2),V=F[0],B=void 0===V?[]:V,N=F[1];function $(e,n){var t=Math.round((e-o)/K)*K+o,r=s(t,[o,u]);return new Promise((function(e){N((function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],o=Y(t,r,n);return _(o,E*K)?(z.current=o.indexOf(r),e(z.current),o[n]!==t[n]?o:t):(e(z.current),t)}))}))}function G(e){var n;null===(n=b(H.current)[e])||void 0===n||n.focus()}return m.createElement(C.Provider,{value:m.useMemo((function(){return{disabled:h,min:o,max:u,valueIndexToChangeRef:z,thumbs:H.current,values:B,orientation:v}}),[h,o,u,B,v])},m.createElement(j,null,m.createElement(q,y({"aria-disabled":h,"data-disabled":h?"":void 0},A,{ref:I,min:o,max:u,onSlideStart:h?void 0:function(e){$(e,function(e,n){if(1===e.length)return 0;var t=e.map((function(e){return Math.abs(e-n)})),r=Math.min.apply(Math,b(t));return t.indexOf(r)}(B,e)).then((function(e){window.setTimeout((function(){return G(e)}),0)}))},onSlideMove:h?void 0:function(e){$(e,z.current).then(G)},onHomeKeyDown:function(){return!h&&$(o,0)},onEndKeyDown:function(){return!h&&$(u,B.length-1)},onStepKeyDown:function(e){var n=e.event,t=e.direction;if(!h){var r=M.includes(n.key)||n.shiftKey&&O.includes(n.key)?10:1,o=z.current;$(B[o]+K*r*t,o)}}})),t&&B.map((function(e,n){return m.createElement(X,{key:n,name:t+(B.length>1?"[]":""),value:e,hidden:!0})}))))}));exports.Slider=k,k.displayName="Slider";var I=m.createContext({}),L=m.forwardRef((function(e,n){var t=e.min,r=e.max,o=e.dir,i=e.onSlideStart,u=e.onSlideMove,l=e.onStepKeyDown,c=g(e,["min","max","dir","onSlideStart","onSlideMove","onStepKeyDown"]),d=m.useRef(null),f=a(n,d),s=m.useRef(),v=function(e){var n=e.ref,t=e.directionProp,r=w(m.useState("ltr"),2),o=r[0],i=r[1],u=w(m.useState(),2),a=u[0],l=u[1],c=m.useRef(0);return m.useEffect((function(){if(void 0===t){var e=getComputedStyle(n.current);l(e)}}),[t,n]),m.useEffect((function(){function e(){c.current=requestAnimationFrame((function(){var n=null==a?void 0:a.direction;n&&i(n),e()}))}return void 0===t&&e(),function(){return cancelAnimationFrame(c.current)}}),[a,t,i]),t||o}({ref:d,directionProp:o}),p="ltr"===v;function b(e){var n=s.current||d.current.getBoundingClientRect(),o=$([0,n.width],p?[t,r]:[r,t]);return s.current=n,o(e-n.left)}return m.createElement(I.Provider,{value:m.useMemo((function(){return{startEdge:p?"left":"right",endEdge:p?"right":"left",direction:p?1:-1,size:"width"}}),[p])},m.createElement(H,y({"data-orientation":"horizontal"},c,{ref:f,style:h(h({},c.style),{},S({},"--radix-slider-thumb-transform","translateX(-50%)")),onSlideMouseDown:function(e){var n=b(e.clientX);null==i||i(n)},onSlideMouseMove:function(e){var n=b(e.clientX);null==u||u(n)},onSlideMouseUp:function(){return s.current=void 0},onSlideTouchStart:function(e){var n=b(e.targetTouches[0].clientX);null==i||i(n)},onSlideTouchMove:function(e){var n=b(e.targetTouches[0].clientX);null==u||u(n)},onSlideTouchEnd:function(){return s.current=void 0},onStepKeyDown:function(e){function n(n){return e.apply(this,arguments)}return n.toString=function(){return e.toString()},n}((function(e){var n=T[v].includes(e.key);null==l||l({event:e,direction:n?-1:1})}))})))})),U=m.forwardRef((function(e,n){var t=e.min,r=e.max,o=e.onSlideStart,i=e.onSlideMove,u=e.onStepKeyDown,l=g(e,["min","max","onSlideStart","onSlideMove","onStepKeyDown"]),c=m.useRef(null),d=a(n,c),f=m.useRef();function s(e){var n=f.current||c.current.getBoundingClientRect(),o=$([0,n.height],[r,t]);return f.current=n,o(e-n.top)}return m.createElement(I.Provider,{value:m.useMemo((function(){return{startEdge:"bottom",endEdge:"top",size:"height",direction:1}}),[])},m.createElement(H,y({"data-orientation":"vertical"},l,{ref:d,style:h(h({},l.style),{},S({},"--radix-slider-thumb-transform","translateY(50%)")),onSlideMouseDown:function(e){var n=s(e.clientY);null==o||o(n)},onSlideMouseMove:function(e){var n=s(e.clientY);null==i||i(n)},onSlideMouseUp:function(){return f.current=void 0},onSlideTouchStart:function(e){var n=s(e.targetTouches[0].clientY);null==o||o(n)},onSlideTouchMove:function(e){var n=s(e.targetTouches[0].clientY);null==i||i(n)},onSlideTouchEnd:function(){return f.current=void 0},onStepKeyDown:function(e){function n(n){return e.apply(this,arguments)}return n.toString=function(){return e.toString()},n}((function(e){var n=T.ltr.includes(e.key);null==u||u({event:e,direction:n?-1:1})}))})))})),H=m.forwardRef((function(e,n){var t=e.as,o=void 0===t?"span":t,u=e.selector,a=void 0===u?v("Slider"):u,l=e.onSlideMouseDown,d=e.onSlideMouseMove,f=e.onSlideMouseUp,s=e.onSlideTouchStart,p=e.onSlideTouchMove,h=e.onSlideTouchEnd,S=e.onHomeKeyDown,b=e.onEndKeyDown,w=e.onStepKeyDown,E=g(e,["as","selector","onSlideMouseDown","onSlideMouseMove","onSlideMouseUp","onSlideTouchStart","onSlideTouchMove","onSlideTouchEnd","onHomeKeyDown","onEndKeyDown","onStepKeyDown"]),x=c(d),T=c(p),D=c((function(){document.removeEventListener("mousemove",x),document.removeEventListener("mouseup",D),f()})),R=c((function(){document.removeEventListener("touchmove",T),document.removeEventListener("touchend",R),h()}));return m.useEffect((function(){return function(){D(),R()}}),[D,R]),m.createElement(r,y({},E,{as:o,selector:a,ref:n,onMouseDown:i(e.onMouseDown,(function(e){0===e.button&&(B(e.target)||l(e),document.addEventListener("mousemove",x),document.addEventListener("mouseup",D))})),onTouchStart:i(e.onTouchStart,(function(e){B(e.target)?e.target.focus():s(e),document.addEventListener("touchmove",T),document.addEventListener("touchend",R),e.preventDefault()})),onKeyDown:i(e.onKeyDown,(function(e){"Home"===e.key?S(e):"End"===e.key?b(e):M.concat(O).includes(e.key)&&(w(e),e.preventDefault())})),onPointerDown:i(e.onPointerDown,(function(e){e.target.setPointerCapture(e.pointerId)})),onPointerUp:i(e.onPointerUp,(function(e){e.target.releasePointerCapture(e.pointerId)}))}))})),z=m.forwardRef((function(e,n){var t=e.as,o=void 0===t?"span":t,i=e.selector,u=void 0===i?v("SliderTrack"):i,a=g(e,["as","selector"]),l=K("SliderTrack");return m.createElement(r,y({"data-disabled":l.disabled?"":void 0,"data-orientation":l.orientation},a,{as:o,selector:u,ref:n}))}));exports.SliderTrack=z,z.displayName="SliderTrack";var q=m.forwardRef((function(e,n){var t,o=e.as,i=void 0===o?"span":o,u=e.selector,l=void 0===u?v("SliderRange"):u,c=g(e,["as","selector"]),d=K("SliderRange"),f=m.useContext(I),s=m.useRef(null),p=a(n,s),w=d.values.length,E=d.values.map((function(e){return N(e,d.min,d.max)})),x=w>1?Math.min.apply(Math,b(E)):0,M=100-Math.max.apply(Math,b(E));return m.createElement(r,y({"data-orientation":d.orientation,"data-disabled":d.disabled?"":void 0},c,{as:i,selector:l,ref:p,style:h(h({},e.style),{},(t={},S(t,f.startEdge,x+"%"),S(t,f.endEdge,M+"%"),t))}))}));exports.SliderRange=q,q.displayName="SliderRange";var F=m.forwardRef((function(e,n){var t=P(),r=t.ref,o=t.index,i=a(n,r),u=K("SliderThumb").values[o];return void 0!==u?m.createElement(V,y({},e,{ref:i,index:o,value:u})):null}));exports.SliderThumb=F;var V=m.forwardRef((function(e,n){var t,o,u,l,c,f=e.as,s=void 0===f?"span":f,p=e.selector,h=void 0===p?v("SliderThumb"):p,b=e.index,w=e.value,E=g(e,["as","selector","index","value"]),x=K("SliderThumb"),M=m.useContext(I),O=m.useRef(null),T=a(n,O),D=d(O),R=N(w,x.min,x.max),P=function(e,n){return n>2?"Value ".concat(e+1," of ").concat(n):2===n?["Minimum","Maximum"][e]:void 0}(b,x.values.length),j=null==D?void 0:D[M.size],A=j?(t=j,o=R,u=M.direction,c=$([0,50],[0,l=t/2]),(l-c(o)*u)*u):0;return m.useEffect((function(){var e=O.current;if(e)return x.thumbs.add(e),function(){x.thumbs.delete(e)}}),[x.thumbs]),m.createElement("span",{style:S({transform:"var(--radix-slider-thumb-transform)",position:"absolute"},M.startEdge,"calc(".concat(R,"% + ").concat(A,"px)"))},m.createElement(r,y({"aria-label":e["aria-label"]||P,"aria-valuemin":x.min,"aria-valuenow":w,"aria-valuemax":x.max,"aria-orientation":x.orientation,"data-orientation":x.orientation,"data-disabled":x.disabled?"":void 0,role:"slider"},E,{as:s,selector:h,ref:T,tabIndex:0,onFocus:i(e.onFocus,(function(){x.valueIndexToChangeRef.current=b}))})))}));F.displayName="SliderThumb";var X=function(e){var n=e.value,t=g(e,["value"]),r=m.useRef(null);return m.useEffect((function(){var e=r.current,t=window.HTMLInputElement.prototype,o=Object.getOwnPropertyDescriptor(t,"value").set;if(o){var i=new Event("input",{bubbles:!0});o.call(e,n),e.dispatchEvent(i)}}),[n]),m.createElement("input",y({hidden:!0},t,{ref:r}))};function Y(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1?arguments[1]:void 0,t=arguments.length>2?arguments[2]:void 0,r=b(e);return r[t]=n,r.sort((function(e,n){return e-n}))}function B(e){var n="data-".concat(v("SliderThumb"));return""===e.getAttribute(n)}function N(e,n,t){return 100/(t-n)*(e-n)}function _(e,n){if(n>0){var t=function(e){return e.slice(0,-1).map((function(n,t){return e[t+1]-n}))}(e);return Math.min.apply(Math,b(t))>=n}return!0}function $(e,n){return function(t){if(e[0]===e[1]||n[0]===n[1])return n[0];var r=(n[1]-n[0])/(e[1]-e[0]);return n[0]+r*(t-e[0])}}var G=k;exports.Root=G;var J=z;exports.Track=J;var Q=q;exports.Range=Q;var W=F;exports.Thumb=W;
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

import{createCollection as e}from"@radix-ui/react-collection";import{Primitive as t}from"@radix-ui/react-primitive";import{composeEventHandlers as n,createContext as o,useComposedRefs as r,useControlledState as i,useCallbackRef as u,useSize as a}from"@radix-ui/react-utils";import{clamp as c,getSelector as l}from"@radix-ui/utils";import*as s from"react";function d(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function m(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?d(Object(n),!0).forEach((function(t){f(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):d(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function f(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function p(){return(p=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e}).apply(this,arguments)}function v(e,t){if(null==e)return{};var n,o,r=function(e,t){if(null==e)return{};var n,o,r={},i=Object.keys(e);for(o=0;o<i.length;o++)n=i[o],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(o=0;o<i.length;o++)n=i[o],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}const S=["PageUp","PageDown"],h=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],w={ltr:["ArrowDown","Home","ArrowLeft","PageUp"],rtl:["ArrowDown","Home","ArrowRight","PageDown"]},[g,y]=e("Slider"),b=g((e=>s.createElement(s.Fragment,null,e.children))),E="Slider",x="span",[M,D]=o("SliderContext",E);export const Slider=s.forwardRef(((e,t)=>{const{name:n,min:o=0,max:u=100,step:a=1,orientation:l="horizontal",disabled:d=!1,minStepsBetweenThumbs:m=0,defaultValue:f=[o],value:w,onValueChange:g=(()=>{})}=e,y=v(e,["name","min","max","step","orientation","disabled","minStepsBetweenThumbs","defaultValue","value","onValueChange"]),E=Math.max(a,1),x=s.useRef(null),D=r(t,x),T=s.useRef(new Set),P=s.useRef(0),j="horizontal"===l?O:R,[K=[],k]=i({prop:w,defaultProp:f,onChange:g});function C(e,t){const n=Math.round((e-o)/E)*E+o,r=c(n,[o,u]);return new Promise((e=>{k(((n=[])=>{const o=function(e=[],t,n){const o=[...e];return o[n]=t,o.sort(((e,t)=>e-t))}(n,r,t);return function(e,t){if(t>0){const n=function(e){return e.slice(0,-1).map(((t,n)=>e[n+1]-t))}(e);return Math.min(...n)>=t}return!0}(o,m*E)?(P.current=o.indexOf(r),e(P.current),o[t]!==n[t]?o:n):(e(P.current),n)}))}))}function A(e){var t;null===(t=[...T.current][e])||void 0===t||t.focus()}return s.createElement(M.Provider,{value:s.useMemo((()=>({min:o,max:u,valueIndexToChangeRef:P,thumbs:T.current,values:K,orientation:l})),[o,u,K,l])},s.createElement(b,null,s.createElement(j,p({},y,{ref:D,min:o,max:u,"aria-disabled":d,"data-disabled":d,onSlideStart:d?void 0:function(e){C(e,function(e,t){if(1===e.length)return 0;const n=e.map((e=>Math.abs(e-t))),o=Math.min(...n);return n.indexOf(o)}(K,e)).then((e=>{window.setTimeout((()=>A(e)),0)}))},onSlideMove:d?void 0:function(e){C(e,P.current).then(A)},onHomeKeyDown:()=>!d&&C(o,0),onEndKeyDown:()=>!d&&C(u,K.length-1),onStepKeyDown:({event:e,direction:t})=>{if(!d){const n=S.includes(e.key)||e.shiftKey&&h.includes(e.key)?10:1,o=P.current;C(K[o]+E*n*t,o)}}})),n&&K.map(((e,t)=>s.createElement(H,{key:t,name:n+(K.length>1?"[]":""),value:e,hidden:!0})))))}));Slider.displayName=E;const T=s.createContext({}),O=s.forwardRef(((e,t)=>{const{min:n,max:o,dir:i,onSlideStart:u,onSlideMove:a,onStepKeyDown:c}=e,l=v(e,["min","max","dir","onSlideStart","onSlideMove","onStepKeyDown"]),d=s.useRef(null),f=r(t,d),S=s.useRef(),h=function({ref:e,directionProp:t}){const[n,o]=s.useState("ltr"),[r,i]=s.useState(),u=s.useRef(0);return s.useEffect((()=>{if(void 0===t){const t=getComputedStyle(e.current);i(t)}}),[t,e]),s.useEffect((()=>{function e(){u.current=requestAnimationFrame((()=>{const t=null==r?void 0:r.direction;t&&o(t),e()}))}return void 0===t&&e(),()=>cancelAnimationFrame(u.current)}),[r,t,o]),t||n}({ref:d,directionProp:i}),g="ltr"===h;function y(e){const t=S.current||d.current.getBoundingClientRect(),r=F([0,t.width],g?[n,o]:[o,n]);return S.current=t,r(e-t.left)}return s.createElement(T.Provider,{value:s.useMemo((()=>({startEdge:g?"left":"right",endEdge:g?"right":"left",direction:g?1:-1,size:"width"})),[g])},s.createElement(P,p({},l,{ref:f,style:m(m({},l.style),{},{"--radix-slider-thumb-transform":"translateX(-50%)"}),"data-orientation":"horizontal",onSlideMouseDown:e=>{const t=y(e.clientX);null==u||u(t)},onSlideMouseMove:e=>{const t=y(e.clientX);null==a||a(t)},onSlideMouseUp:()=>S.current=void 0,onSlideTouchStart:e=>{const t=y(e.targetTouches[0].clientX);null==u||u(t)},onSlideTouchMove:e=>{const t=y(e.targetTouches[0].clientX);null==a||a(t)},onSlideTouchEnd:()=>S.current=void 0,onStepKeyDown:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((e=>{const t=w[h].includes(e.key);null==c||c({event:e,direction:t?-1:1})}))})))})),R=s.forwardRef(((e,t)=>{const{min:n,max:o,onSlideStart:i,onSlideMove:u,onStepKeyDown:a}=e,c=v(e,["min","max","onSlideStart","onSlideMove","onStepKeyDown"]),l=s.useRef(null),d=r(t,l),f=s.useRef();function S(e){const t=f.current||l.current.getBoundingClientRect(),r=F([0,t.height],[o,n]);return f.current=t,r(e-t.top)}return s.createElement(T.Provider,{value:s.useMemo((()=>({startEdge:"bottom",endEdge:"top",size:"height",direction:1})),[])},s.createElement(P,p({},c,{ref:d,style:m(m({},c.style),{},{"--radix-slider-thumb-transform":"translateY(50%)"}),"data-orientation":"vertical",onSlideMouseDown:e=>{const t=S(e.clientY);null==i||i(t)},onSlideMouseMove:e=>{const t=S(e.clientY);null==u||u(t)},onSlideMouseUp:()=>f.current=void 0,onSlideTouchStart:e=>{const t=S(e.targetTouches[0].clientY);null==i||i(t)},onSlideTouchMove:e=>{const t=S(e.targetTouches[0].clientY);null==u||u(t)},onSlideTouchEnd:()=>f.current=void 0,onStepKeyDown:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((e=>{const t=w.ltr.includes(e.key);null==a||a({event:e,direction:t?-1:1})}))})))})),P=s.forwardRef(((e,o)=>{const{as:r=x,selector:i=l(E),onSlideMouseDown:a,onSlideMouseMove:c,onSlideMouseUp:d,onSlideTouchStart:m,onSlideTouchMove:f,onSlideTouchEnd:w,onHomeKeyDown:g,onEndKeyDown:y,onStepKeyDown:b}=e,M=v(e,["as","selector","onSlideMouseDown","onSlideMouseMove","onSlideMouseUp","onSlideTouchStart","onSlideTouchMove","onSlideTouchEnd","onHomeKeyDown","onEndKeyDown","onStepKeyDown"]),D=u(c),T=u(f),O=u((()=>{document.removeEventListener("mousemove",D),document.removeEventListener("mouseup",O),d()})),R=u((()=>{document.removeEventListener("touchmove",T),document.removeEventListener("touchend",R),w()}));return s.useEffect((()=>()=>{O(),R()}),[O,R]),s.createElement(t,p({},M,{as:r,selector:i,ref:o,onMouseDown:n(e.onMouseDown,(e=>{0===e.button&&(I(e.target)||a(e),document.addEventListener("mousemove",D),document.addEventListener("mouseup",O))})),onTouchStart:n(e.onTouchStart,(e=>{I(e.target)?e.target.focus():m(e),document.addEventListener("touchmove",T),document.addEventListener("touchend",R),e.preventDefault()})),onKeyDown:n(e.onKeyDown,(e=>{"Home"===e.key?g(e):"End"===e.key?y(e):S.concat(h).includes(e.key)&&(b(e),e.preventDefault())})),onPointerDown:n(e.onPointerDown,(e=>{e.target.setPointerCapture(e.pointerId)})),onPointerUp:n(e.onPointerUp,(e=>{e.target.releasePointerCapture(e.pointerId)}))}))})),j="SliderTrack",K="span";export const SliderTrack=s.forwardRef(((e,n)=>{const{as:o=K,selector:r=l(j)}=e,i=v(e,["as","selector"]),u=D(j);return s.createElement(t,p({},i,{as:o,selector:r,ref:n,"data-orientation":u.orientation}))}));SliderTrack.displayName=j;const k="SliderRange",C="span";export const SliderRange=s.forwardRef(((e,n)=>{const{as:o=C,selector:i=l(k)}=e,u=v(e,["as","selector"]),a=D(k),c=s.useContext(T),d=s.useRef(null),f=r(n,d),S=a.values.length,h=a.values.map((e=>z(e,a.min,a.max))),w=S>1?Math.min(...h):0,g=100-Math.max(...h);return s.createElement(t,p({},u,{as:o,selector:i,ref:f,style:m(m({},e.style),{},{[c.startEdge]:w+"%",[c.endEdge]:g+"%"}),"data-orientation":a.orientation}))}));SliderRange.displayName=k;const A="SliderThumb",L="span";export const SliderThumb=s.forwardRef(((e,t)=>{const{ref:n,index:o}=y(),i=r(t,n),u=D(A).values[o];return void 0!==u?s.createElement(U,p({},e,{ref:i,index:o,value:u})):null}));const U=s.forwardRef(((e,o)=>{const{as:i=L,selector:u=l(A),index:c,value:d}=e,m=v(e,["as","selector","index","value"]),f=D(A),S=s.useContext(T),h=s.useRef(null),w=r(o,h),g=a(h),y=z(d,f.min,f.max),b=function(e,t){return t>2?"Value ".concat(e+1," of ").concat(t):2===t?["Minimum","Maximum"][e]:void 0}(c,f.values.length),E=null==g?void 0:g[S.size],x=E?function(e,t,n){const o=e/2,r=F([0,50],[0,o]);return(o-r(t)*n)*n}(E,y,S.direction):0;return s.useEffect((()=>{const e=h.current;if(e)return f.thumbs.add(e),()=>{f.thumbs.delete(e)}}),[f.thumbs]),s.createElement("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[S.startEdge]:"calc(".concat(y,"% + ").concat(x,"px)")}},s.createElement(t,p({},m,{as:i,selector:u,ref:w,"aria-label":e["aria-label"]||b,"aria-valuemin":f.min,"aria-valuenow":d,"aria-valuemax":f.max,"aria-orientation":f.orientation,"data-orientation":f.orientation,role:"slider",tabIndex:0,onFocus:n(e.onFocus,(()=>{f.valueIndexToChangeRef.current=c}))})))}));SliderThumb.displayName=A;const H=e=>{const{value:t}=e,n=v(e,["value"]),o=s.useRef(null);return s.useEffect((()=>{const e=o.current,n=window.HTMLInputElement.prototype,{set:r}=Object.getOwnPropertyDescriptor(n,"value");if(r){const n=new Event("input",{bubbles:!0});r.call(e,t),e.dispatchEvent(n)}}),[t]),s.createElement("input",p({hidden:!0},n,{ref:o}))};function I(e){const t="data-".concat(l(A));return""===e.getAttribute(t)}function z(e,t,n){return 100/(n-t)*(e-t)}function F(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const o=(t[1]-t[0])/(e[1]-e[0]);return t[0]+o*(n-e[0])}}export const Root=Slider;export const Track=SliderTrack;export const Range=SliderRange;export const Thumb=SliderThumb;
import{createCollection as e}from"@radix-ui/react-collection";import{Primitive as t}from"@radix-ui/react-primitive";import{composeEventHandlers as n,createContext as o,useComposedRefs as r,useControlledState as i,useCallbackRef as a,useSize as u}from"@radix-ui/react-utils";import{clamp as l,getSelector as c}from"@radix-ui/utils";import*as s from"react";function d(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function m(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?d(Object(n),!0).forEach((function(t){f(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):d(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function f(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function p(){return(p=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e}).apply(this,arguments)}function v(e,t){if(null==e)return{};var n,o,r=function(e,t){if(null==e)return{};var n,o,r={},i=Object.keys(e);for(o=0;o<i.length;o++)n=i[o],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(o=0;o<i.length;o++)n=i[o],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}const S=["PageUp","PageDown"],h=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],w={ltr:["ArrowDown","Home","ArrowLeft","PageUp"],rtl:["ArrowDown","Home","ArrowRight","PageDown"]},[g,b]=e("Slider"),y=g((e=>s.createElement(s.Fragment,null,e.children))),E="Slider",x="span",[M,D]=o("SliderContext",E);export const Slider=s.forwardRef(((e,t)=>{const{name:n,min:o=0,max:a=100,step:u=1,orientation:c="horizontal",disabled:d=!1,minStepsBetweenThumbs:m=0,defaultValue:f=[o],value:w,onValueChange:g=(()=>{})}=e,b=v(e,["name","min","max","step","orientation","disabled","minStepsBetweenThumbs","defaultValue","value","onValueChange"]),E=Math.max(u,1),x=s.useRef(null),D=r(t,x),T=s.useRef(new Set),P=s.useRef(0),j="horizontal"===c?O:R,[K=[],k]=i({prop:w,defaultProp:f,onChange:g});function C(e,t){const n=Math.round((e-o)/E)*E+o,r=l(n,[o,a]);return new Promise((e=>{k(((n=[])=>{const o=function(e=[],t,n){const o=[...e];return o[n]=t,o.sort(((e,t)=>e-t))}(n,r,t);return function(e,t){if(t>0){const n=function(e){return e.slice(0,-1).map(((t,n)=>e[n+1]-t))}(e);return Math.min(...n)>=t}return!0}(o,m*E)?(P.current=o.indexOf(r),e(P.current),o[t]!==n[t]?o:n):(e(P.current),n)}))}))}function A(e){var t;null===(t=[...T.current][e])||void 0===t||t.focus()}return s.createElement(M.Provider,{value:s.useMemo((()=>({disabled:d,min:o,max:a,valueIndexToChangeRef:P,thumbs:T.current,values:K,orientation:c})),[d,o,a,K,c])},s.createElement(y,null,s.createElement(j,p({"aria-disabled":d,"data-disabled":d?"":void 0},b,{ref:D,min:o,max:a,onSlideStart:d?void 0:function(e){C(e,function(e,t){if(1===e.length)return 0;const n=e.map((e=>Math.abs(e-t))),o=Math.min(...n);return n.indexOf(o)}(K,e)).then((e=>{window.setTimeout((()=>A(e)),0)}))},onSlideMove:d?void 0:function(e){C(e,P.current).then(A)},onHomeKeyDown:()=>!d&&C(o,0),onEndKeyDown:()=>!d&&C(a,K.length-1),onStepKeyDown:({event:e,direction:t})=>{if(!d){const n=S.includes(e.key)||e.shiftKey&&h.includes(e.key)?10:1,o=P.current;C(K[o]+E*n*t,o)}}})),n&&K.map(((e,t)=>s.createElement(H,{key:t,name:n+(K.length>1?"[]":""),value:e,hidden:!0})))))}));Slider.displayName=E;const T=s.createContext({}),O=s.forwardRef(((e,t)=>{const{min:n,max:o,dir:i,onSlideStart:a,onSlideMove:u,onStepKeyDown:l}=e,c=v(e,["min","max","dir","onSlideStart","onSlideMove","onStepKeyDown"]),d=s.useRef(null),f=r(t,d),S=s.useRef(),h=function({ref:e,directionProp:t}){const[n,o]=s.useState("ltr"),[r,i]=s.useState(),a=s.useRef(0);return s.useEffect((()=>{if(void 0===t){const t=getComputedStyle(e.current);i(t)}}),[t,e]),s.useEffect((()=>{function e(){a.current=requestAnimationFrame((()=>{const t=null==r?void 0:r.direction;t&&o(t),e()}))}return void 0===t&&e(),()=>cancelAnimationFrame(a.current)}),[r,t,o]),t||n}({ref:d,directionProp:i}),g="ltr"===h;function b(e){const t=S.current||d.current.getBoundingClientRect(),r=F([0,t.width],g?[n,o]:[o,n]);return S.current=t,r(e-t.left)}return s.createElement(T.Provider,{value:s.useMemo((()=>({startEdge:g?"left":"right",endEdge:g?"right":"left",direction:g?1:-1,size:"width"})),[g])},s.createElement(P,p({"data-orientation":"horizontal"},c,{ref:f,style:m(m({},c.style),{},{"--radix-slider-thumb-transform":"translateX(-50%)"}),onSlideMouseDown:e=>{const t=b(e.clientX);null==a||a(t)},onSlideMouseMove:e=>{const t=b(e.clientX);null==u||u(t)},onSlideMouseUp:()=>S.current=void 0,onSlideTouchStart:e=>{const t=b(e.targetTouches[0].clientX);null==a||a(t)},onSlideTouchMove:e=>{const t=b(e.targetTouches[0].clientX);null==u||u(t)},onSlideTouchEnd:()=>S.current=void 0,onStepKeyDown:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((e=>{const t=w[h].includes(e.key);null==l||l({event:e,direction:t?-1:1})}))})))})),R=s.forwardRef(((e,t)=>{const{min:n,max:o,onSlideStart:i,onSlideMove:a,onStepKeyDown:u}=e,l=v(e,["min","max","onSlideStart","onSlideMove","onStepKeyDown"]),c=s.useRef(null),d=r(t,c),f=s.useRef();function S(e){const t=f.current||c.current.getBoundingClientRect(),r=F([0,t.height],[o,n]);return f.current=t,r(e-t.top)}return s.createElement(T.Provider,{value:s.useMemo((()=>({startEdge:"bottom",endEdge:"top",size:"height",direction:1})),[])},s.createElement(P,p({"data-orientation":"vertical"},l,{ref:d,style:m(m({},l.style),{},{"--radix-slider-thumb-transform":"translateY(50%)"}),onSlideMouseDown:e=>{const t=S(e.clientY);null==i||i(t)},onSlideMouseMove:e=>{const t=S(e.clientY);null==a||a(t)},onSlideMouseUp:()=>f.current=void 0,onSlideTouchStart:e=>{const t=S(e.targetTouches[0].clientY);null==i||i(t)},onSlideTouchMove:e=>{const t=S(e.targetTouches[0].clientY);null==a||a(t)},onSlideTouchEnd:()=>f.current=void 0,onStepKeyDown:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((e=>{const t=w.ltr.includes(e.key);null==u||u({event:e,direction:t?-1:1})}))})))})),P=s.forwardRef(((e,o)=>{const{as:r=x,selector:i=c(E),onSlideMouseDown:u,onSlideMouseMove:l,onSlideMouseUp:d,onSlideTouchStart:m,onSlideTouchMove:f,onSlideTouchEnd:w,onHomeKeyDown:g,onEndKeyDown:b,onStepKeyDown:y}=e,M=v(e,["as","selector","onSlideMouseDown","onSlideMouseMove","onSlideMouseUp","onSlideTouchStart","onSlideTouchMove","onSlideTouchEnd","onHomeKeyDown","onEndKeyDown","onStepKeyDown"]),D=a(l),T=a(f),O=a((()=>{document.removeEventListener("mousemove",D),document.removeEventListener("mouseup",O),d()})),R=a((()=>{document.removeEventListener("touchmove",T),document.removeEventListener("touchend",R),w()}));return s.useEffect((()=>()=>{O(),R()}),[O,R]),s.createElement(t,p({},M,{as:r,selector:i,ref:o,onMouseDown:n(e.onMouseDown,(e=>{0===e.button&&(I(e.target)||u(e),document.addEventListener("mousemove",D),document.addEventListener("mouseup",O))})),onTouchStart:n(e.onTouchStart,(e=>{I(e.target)?e.target.focus():m(e),document.addEventListener("touchmove",T),document.addEventListener("touchend",R),e.preventDefault()})),onKeyDown:n(e.onKeyDown,(e=>{"Home"===e.key?g(e):"End"===e.key?b(e):S.concat(h).includes(e.key)&&(y(e),e.preventDefault())})),onPointerDown:n(e.onPointerDown,(e=>{e.target.setPointerCapture(e.pointerId)})),onPointerUp:n(e.onPointerUp,(e=>{e.target.releasePointerCapture(e.pointerId)}))}))})),j="SliderTrack",K="span";export const SliderTrack=s.forwardRef(((e,n)=>{const{as:o=K,selector:r=c(j)}=e,i=v(e,["as","selector"]),a=D(j);return s.createElement(t,p({"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation},i,{as:o,selector:r,ref:n}))}));SliderTrack.displayName=j;const k="SliderRange",C="span";export const SliderRange=s.forwardRef(((e,n)=>{const{as:o=C,selector:i=c(k)}=e,a=v(e,["as","selector"]),u=D(k),l=s.useContext(T),d=s.useRef(null),f=r(n,d),S=u.values.length,h=u.values.map((e=>z(e,u.min,u.max))),w=S>1?Math.min(...h):0,g=100-Math.max(...h);return s.createElement(t,p({"data-orientation":u.orientation,"data-disabled":u.disabled?"":void 0},a,{as:o,selector:i,ref:f,style:m(m({},e.style),{},{[l.startEdge]:w+"%",[l.endEdge]:g+"%"})}))}));SliderRange.displayName=k;const A="SliderThumb",L="span";export const SliderThumb=s.forwardRef(((e,t)=>{const{ref:n,index:o}=b(),i=r(t,n),a=D(A).values[o];return void 0!==a?s.createElement(U,p({},e,{ref:i,index:o,value:a})):null}));const U=s.forwardRef(((e,o)=>{const{as:i=L,selector:a=c(A),index:l,value:d}=e,m=v(e,["as","selector","index","value"]),f=D(A),S=s.useContext(T),h=s.useRef(null),w=r(o,h),g=u(h),b=z(d,f.min,f.max),y=function(e,t){return t>2?"Value ".concat(e+1," of ").concat(t):2===t?["Minimum","Maximum"][e]:void 0}(l,f.values.length),E=null==g?void 0:g[S.size],x=E?function(e,t,n){const o=e/2,r=F([0,50],[0,o]);return(o-r(t)*n)*n}(E,b,S.direction):0;return s.useEffect((()=>{const e=h.current;if(e)return f.thumbs.add(e),()=>{f.thumbs.delete(e)}}),[f.thumbs]),s.createElement("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[S.startEdge]:"calc(".concat(b,"% + ").concat(x,"px)")}},s.createElement(t,p({"aria-label":e["aria-label"]||y,"aria-valuemin":f.min,"aria-valuenow":d,"aria-valuemax":f.max,"aria-orientation":f.orientation,"data-orientation":f.orientation,"data-disabled":f.disabled?"":void 0,role:"slider"},m,{as:i,selector:a,ref:w,tabIndex:0,onFocus:n(e.onFocus,(()=>{f.valueIndexToChangeRef.current=l}))})))}));SliderThumb.displayName=A;const H=e=>{const{value:t}=e,n=v(e,["value"]),o=s.useRef(null);return s.useEffect((()=>{const e=o.current,n=window.HTMLInputElement.prototype,{set:r}=Object.getOwnPropertyDescriptor(n,"value");if(r){const n=new Event("input",{bubbles:!0});r.call(e,t),e.dispatchEvent(n)}}),[t]),s.createElement("input",p({hidden:!0},n,{ref:o}))};function I(e){const t="data-".concat(c(A));return""===e.getAttribute(t)}function z(e,t,n){return 100/(n-t)*(e-t)}function F(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const o=(t[1]-t[0])/(e[1]-e[0]);return t[0]+o*(n-e[0])}}export const Root=Slider;export const Track=SliderTrack;export const Range=SliderRange;export const Thumb=SliderThumb;
//# sourceMappingURL=index.module.js.map
{
"name": "@radix-ui/react-slider",
"version": "0.0.4",
"version": "0.0.5",
"license": "MIT",

@@ -19,6 +19,6 @@ "source": "src/index.ts",

"dependencies": {
"@radix-ui/react-collection": "0.0.4",
"@radix-ui/react-polymorphic": "0.0.4",
"@radix-ui/react-primitive": "0.0.3",
"@radix-ui/react-utils": "0.0.4",
"@radix-ui/react-collection": "0.0.5",
"@radix-ui/react-polymorphic": "0.0.5",
"@radix-ui/react-primitive": "0.0.4",
"@radix-ui/react-utils": "0.0.5",
"@radix-ui/utils": "0.0.3"

@@ -25,0 +25,0 @@ },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc