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.2 to 0.0.3

49

dist/index.d.ts
import * as React from "react";
import { Primitive } from "@radix-ui/react-primitive";
import * as Polymorphic from "@radix-ui/react-polymorphic";
import { Merge } from "@radix-ui/utils";
type Direction = 'ltr' | 'rtl';
type SliderOwnProps = {
declare const SLIDER_DEFAULT_TAG = "span";
type SliderOwnProps = Merge<Polymorphic.OwnProps<typeof Primitive>, {
name?: string;

@@ -15,23 +19,30 @@ disabled?: boolean;

onValueChange?(value: number[]): void;
};
export const Slider: import("@radix-ui/react-polymorphic").ForwardRefExoticComponentWithAs<"span", SliderOwnProps>;
export const SliderTrack: import("@radix-ui/react-polymorphic").ForwardRefExoticComponentWithAs<"span", {}>;
type SliderRangeOwnProps = {
children: never;
};
export const SliderRange: import("@radix-ui/react-polymorphic").ForwardRefExoticComponentWithAs<"span", SliderRangeOwnProps>;
type SliderThumbOwnProps = {
value: never;
index: never;
};
export const SliderThumb: import("@radix-ui/react-polymorphic").ForwardRefExoticComponentWithAs<"span", import("@radix-ui/react-polymorphic").MergeProps<SliderThumbImplOwnProps, SliderThumbOwnProps>>;
type SliderThumbImplOwnProps = {
}>;
type SliderPrimitive = Polymorphic.ForwardRefComponent<typeof SLIDER_DEFAULT_TAG, SliderOwnProps>;
export const Slider: SliderPrimitive;
declare const TRACK_DEFAULT_TAG = "span";
type SliderTrackOwnProps = Polymorphic.OwnProps<typeof Primitive>;
type SliderTrackPrimitive = Polymorphic.ForwardRefComponent<typeof TRACK_DEFAULT_TAG, SliderTrackOwnProps>;
export const SliderTrack: SliderTrackPrimitive;
declare const RANGE_DEFAULT_TAG = "span";
type SliderRangeOwnProps = Merge<Polymorphic.OwnProps<typeof Primitive>, {
children?: never;
}>;
type SliderRangePrimitive = Polymorphic.ForwardRefComponent<typeof RANGE_DEFAULT_TAG, SliderRangeOwnProps>;
export const SliderRange: SliderRangePrimitive;
declare const THUMB_DEFAULT_TAG = "span";
type SliderThumbOwnProps = Omit<Polymorphic.OwnProps<typeof SliderThumbImpl>, 'value' | 'index'>;
type SliderThumbPrimitive = Polymorphic.ForwardRefComponent<Polymorphic.IntrinsicElement<typeof SliderThumbImpl>, SliderThumbOwnProps>;
export const SliderThumb: SliderThumbPrimitive;
type SliderThumbImplOwnProps = Merge<Polymorphic.OwnProps<typeof Primitive>, {
value: number;
index: number;
};
export const Root: import("@radix-ui/react-polymorphic").ForwardRefExoticComponentWithAs<"span", SliderOwnProps>;
export const Track: import("@radix-ui/react-polymorphic").ForwardRefExoticComponentWithAs<"span", {}>;
export const Range: import("@radix-ui/react-polymorphic").ForwardRefExoticComponentWithAs<"span", SliderRangeOwnProps>;
export const Thumb: import("@radix-ui/react-polymorphic").ForwardRefExoticComponentWithAs<"span", import("@radix-ui/react-polymorphic").MergeProps<SliderThumbImplOwnProps, SliderThumbOwnProps>>;
}>;
type SliderThumbImplPrimitive = Polymorphic.ForwardRefComponent<typeof THUMB_DEFAULT_TAG, SliderThumbImplOwnProps>;
declare const SliderThumbImpl: SliderThumbImplPrimitive;
export const Root: SliderPrimitive;
export const Track: SliderTrackPrimitive;
export const Range: SliderRangePrimitive;
export const Thumb: SliderThumbPrimitive;
//# sourceMappingURL=index.d.ts.map

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

@@ -15,13 +15,11 @@ "source": "src/index.ts",

"scripts": {
"build": "parcel build src/index.ts --no-cache",
"clean": "rm -rf dist",
"version": "yarn version",
"prepublish": "yarn clean && yarn build"
"prepublish": "yarn clean"
},
"dependencies": {
"@radix-ui/react-collection": "0.0.2",
"@radix-ui/react-polymorphic": "0.0.2",
"@radix-ui/react-primitive": "0.0.1",
"@radix-ui/react-utils": "0.0.2",
"@radix-ui/utils": "0.0.2"
"@radix-ui/react-collection": "0.0.3",
"@radix-ui/react-polymorphic": "0.0.3",
"@radix-ui/react-primitive": "0.0.2",
"@radix-ui/react-utils": "0.0.3",
"@radix-ui/utils": "0.0.3"
},

@@ -28,0 +26,0 @@ "peerDependencies": {

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