@radix-ui/react-slider 0.1.5-rc.5 → 0.1.5-rc.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"mappings":"A;A;A;AAeA,iBAAiB,KAAK,GAAG,KAAK,CAAC;AAoB/B,OAAA,wFAEE,CAAC;AAeH,4BACE,SAAQ,IAAI,CACV,qBAAqB,GAAG,mBAAmB,EAC3C,MAAM,6BAA6B,GAAG,cAAc,CACrD;IACD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,cAAc,CAAC,kBAAkB,CAAC,CAAC;IACvD,GAAG,CAAC,EAAE,SAAS,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,aAAa,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;CACvC;AAED,OAAA,MAAM,2FA4GL,CAAC;AAoBF,qCAAqC;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,WAAW,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,aAAa,CAAC,KAAK,EAAE,MAAM,aAAa,GAAG,IAAI,CAAC;IAChD,YAAY,CAAC,KAAK,EAAE,MAAM,aAAa,GAAG,IAAI,CAAC;IAC/C,aAAa,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,aAAa,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;CAC9E,CAAC;AACF,gCACE,SAAQ,IAAI,CAAC,eAAe,EAAE,MAAM,sBAAsB,CAAC,EACzD,6BAA6B;CAAG;AAGpC,+BAAgC,SAAQ,sBAAsB;IAC5D,GAAG,CAAC,EAAE,SAAS,CAAC;CACjB;AA8DD,6BAA8B,SAAQ,sBAAsB;CAAG;AA2D/D,yBAAyB,MAAM,wBAAwB,CAAC,OAAO,UAAU,GAAG,CAAC,CAAC;AAC9E,8BAA8B;IAC5B,YAAY,CAAC,KAAK,EAAE,MAAM,YAAY,GAAG,IAAI,CAAC;IAC9C,WAAW,CAAC,KAAK,EAAE,MAAM,YAAY,GAAG,IAAI,CAAC;IAC7C,UAAU,CAAC,KAAK,EAAE,MAAM,YAAY,GAAG,IAAI,CAAC;IAC5C,aAAa,CAAC,KAAK,EAAE,MAAM,aAAa,GAAG,IAAI,CAAC;IAChD,YAAY,CAAC,KAAK,EAAE,MAAM,aAAa,GAAG,IAAI,CAAC;IAC/C,aAAa,CAAC,KAAK,EAAE,MAAM,aAAa,GAAG,IAAI,CAAC;CACjD,CAAC;AACF,yBAA0B,SAAQ,iBAAiB,EAAE,sBAAsB;CAAG;AAuE9E,0BAA0B,MAAM,wBAAwB,CAAC,OAAO,UAAU,IAAI,CAAC,CAAC;AAChF,iCAA2B,SAAQ,kBAAkB;CAAG;AAExD,OAAA,MAAM,qGAaL,CAAC;AAWF,iCAA2B,SAAQ,kBAAkB;CAAG;AAExD,OAAA,MAAM,qGA4BL,CAAC;AAWF,iCAA2B,SAAQ,IAAI,CAAC,oBAAoB,EAAE,OAAO,CAAC;CAAG;AAEzE,OAAA,MAAM,qGAWL,CAAC;AAGF,8BAA+B,SAAQ,kBAAkB;IACvD,KAAK,EAAE,MAAM,CAAC;CACf;AA0MD,OAAA,MAAM,yFAAa,CAAC;AACpB,OAAA,MAAM,+FAAmB,CAAC;AAC1B,OAAA,MAAM,+FAAmB,CAAC;AAC1B,OAAA,MAAM,+FAAmB,CAAC","sources":["./packages/react/slider/src/packages/react/slider/src/Slider.tsx","./packages/react/slider/src/packages/react/slider/src/index.ts"],"sourcesContent":[null,null],"names":[],"version":3,"file":"index.d.ts.map"}
1
+ {"mappings":";;;AAeA,iBAAiB,KAAK,GAAG,KAAK,CAAC;AAoB/B,OAAA,wFAEE,CAAC;AAeH,4BACE,SAAQ,IAAI,CACV,qBAAqB,GAAG,mBAAmB,EAC3C,MAAM,6BAA6B,GAAG,cAAc,CACrD;IACD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,cAAc,CAAC,kBAAkB,CAAC,CAAC;IACvD,GAAG,CAAC,EAAE,SAAS,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,aAAa,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;CACvC;AAED,OAAA,MAAM,2FA4GL,CAAC;AAoBF,qCAAqC;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,WAAW,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,aAAa,CAAC,KAAK,EAAE,MAAM,aAAa,GAAG,IAAI,CAAC;IAChD,YAAY,CAAC,KAAK,EAAE,MAAM,aAAa,GAAG,IAAI,CAAC;IAC/C,aAAa,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,aAAa,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;CAC9E,CAAC;AACF,gCACE,SAAQ,IAAI,CAAC,eAAe,EAAE,MAAM,sBAAsB,CAAC,EACzD,6BAA6B;CAAG;AAGpC,+BAAgC,SAAQ,sBAAsB;IAC5D,GAAG,CAAC,EAAE,SAAS,CAAC;CACjB;AA8DD,6BAA8B,SAAQ,sBAAsB;CAAG;AA2D/D,yBAAyB,MAAM,wBAAwB,CAAC,OAAO,UAAU,GAAG,CAAC,CAAC;AAC9E,8BAA8B;IAC5B,YAAY,CAAC,KAAK,EAAE,MAAM,YAAY,GAAG,IAAI,CAAC;IAC9C,WAAW,CAAC,KAAK,EAAE,MAAM,YAAY,GAAG,IAAI,CAAC;IAC7C,UAAU,CAAC,KAAK,EAAE,MAAM,YAAY,GAAG,IAAI,CAAC;IAC5C,aAAa,CAAC,KAAK,EAAE,MAAM,aAAa,GAAG,IAAI,CAAC;IAChD,YAAY,CAAC,KAAK,EAAE,MAAM,aAAa,GAAG,IAAI,CAAC;IAC/C,aAAa,CAAC,KAAK,EAAE,MAAM,aAAa,GAAG,IAAI,CAAC;CACjD,CAAC;AACF,yBAA0B,SAAQ,iBAAiB,EAAE,sBAAsB;CAAG;AAuE9E,0BAA0B,MAAM,wBAAwB,CAAC,OAAO,UAAU,IAAI,CAAC,CAAC;AAChF,iCAA2B,SAAQ,kBAAkB;CAAG;AAExD,OAAA,MAAM,qGAaL,CAAC;AAWF,iCAA2B,SAAQ,kBAAkB;CAAG;AAExD,OAAA,MAAM,qGA4BL,CAAC;AAWF,iCAA2B,SAAQ,IAAI,CAAC,oBAAoB,EAAE,OAAO,CAAC;CAAG;AAEzE,OAAA,MAAM,qGAWL,CAAC;AAGF,8BAA+B,SAAQ,kBAAkB;IACvD,KAAK,EAAE,MAAM,CAAC;CACf;AA0MD,OAAA,MAAM,yFAAa,CAAC;AACpB,OAAA,MAAM,+FAAmB,CAAC;AAC1B,OAAA,MAAM,+FAAmB,CAAC;AAC1B,OAAA,MAAM,+FAAmB,CAAC","sources":["packages/react/slider/src/packages/react/slider/src/Slider.tsx","packages/react/slider/src/packages/react/slider/src/index.ts","packages/react/slider/src/index.ts"],"sourcesContent":[null,null,"export {\n createSliderScope,\n //\n Slider,\n SliderTrack,\n SliderRange,\n SliderThumb,\n //\n Root,\n Track,\n Range,\n Thumb,\n} from './Slider';\nexport type { SliderProps, SliderTrackProps, SliderRangeProps, SliderThumbProps } from './Slider';\n"],"names":[],"version":3,"file":"index.d.ts.map"}
package/dist/index.js CHANGED
@@ -1,2 +1,587 @@
1
- var e,t,n,r=require("@radix-ui/react-collection").createCollection,o=require("@radix-ui/react-primitive").Primitive,i=require("@radix-ui/react-use-size").useSize,a=require("@radix-ui/react-use-previous").usePrevious,l=require("@radix-ui/react-direction").useDirection,s=require("@radix-ui/react-use-controllable-state").useControllableState,u=require("@radix-ui/react-context").createContextScope,d=require("@radix-ui/react-compose-refs").useComposedRefs,c=require("@radix-ui/primitive").composeEventHandlers,f=require("@radix-ui/number").clamp,p=(e={},t=require("react"),Object.keys(t).forEach((function(n){"default"!==n&&"__esModule"!==n&&Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[n]}})})),e),m=(n=require("@babel/runtime/helpers/extends"))&&n.__esModule?n.default:n;const S=["PageUp","PageDown"],v=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],h={ltr:["ArrowDown","Home","ArrowLeft","PageDown"],rtl:["ArrowDown","Home","ArrowRight","PageDown"]},[w,g,x]=r("Slider"),[b,E]=u("Slider",[x]);exports.createSliderScope=E;const[y,R]=b("Slider"),D=/*#__PURE__*/p.forwardRef(((e,t)=>{const{name:n,min:r=0,max:o=100,step:i=1,orientation:a="horizontal",disabled:l=!1,minStepsBetweenThumbs:u=0,defaultValue:c=[r],value:h,onValueChange:g=(()=>{}),...x}=e,[b,E]=p.useState(null),R=d(t,(e=>E(e))),D=p.useRef(new Set),_=p.useRef(0),M="horizontal"===a,K=!b||Boolean(b.closest("form")),k=M?P:C,[q=[],T]=s({prop:h,defaultProp:c,onChange:e=>{var t;null===(t=[...D.current][_.current])||void 0===t||t.focus(),g(e)}});function I(e,t){const n=function(e){return(String(e).split(".")[1]||"").length}(i),a=function(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}(Math.round((e-r)/i)*i+r,n),l=f(a,[r,o]);T(((e=[])=>{const n=function(e=[],t,n){const r=[...e];return r[n]=t,r.sort(((e,t)=>e-t))}(e,l,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}(n,u*i)?(_.current=n.indexOf(l),String(n)===String(e)?e:n):e}))}/*#__PURE__*/return p.createElement(y,{scope:e.__scopeSlider,disabled:l,min:r,max:o,valueIndexToChangeRef:_,thumbs:D.current,values:q,orientation:a},/*#__PURE__*/p.createElement(w.Provider,{scope:e.__scopeSlider},/*#__PURE__*/p.createElement(w.Slot,{scope:e.__scopeSlider},/*#__PURE__*/p.createElement(k,m({"aria-disabled":l,"data-disabled":l?"":void 0},x,{ref:R,min:r,max:o,onSlideStart:l?void 0:function(e){const t=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)}(q,e);I(e,t)},onSlideMove:l?void 0:function(e){I(e,_.current)},onHomeKeyDown:()=>!l&&I(r,0),onEndKeyDown:()=>!l&&I(o,q.length-1),onStepKeyDown:({event:e,direction:t})=>{if(!l){const n=S.includes(e.key)||e.shiftKey&&v.includes(e.key)?10:1,r=_.current;I(q[r]+i*n*t,r)}}})))),K&&q.map(((e,t)=>/*#__PURE__*/p.createElement(z,{key:t,name:n?n+(q.length>1?"[]":""):void 0,value:e}))))}));exports.Slider=D;const[_,M]=b("Slider",{startEdge:"left",endEdge:"right",size:"width",direction:1}),P=/*#__PURE__*/p.forwardRef(((e,t)=>{const{min:n,max:r,dir:o,onSlideStart:i,onSlideMove:a,onStepKeyDown:s,...u}=e,[c,f]=p.useState(null),S=d(t,(e=>f(e))),v=p.useRef(),w=l(o),g="ltr"===w;function x(e){const t=v.current||c.getBoundingClientRect(),o=H([0,t.width],g?[n,r]:[r,n]);return v.current=t,o(e-t.left)}/*#__PURE__*/return p.createElement(_,{scope:e.__scopeSlider,startEdge:g?"left":"right",endEdge:g?"right":"left",direction:g?1:-1,size:"width"},/*#__PURE__*/p.createElement(K,m({dir:w,"data-orientation":"horizontal"},u,{ref:S,style:{...u.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:e=>{const t=x(e.clientX);null==i||i(t)},onSlideMove:e=>{const t=x(e.clientX);null==a||a(t)},onSlideEnd:()=>v.current=void 0,onStepKeyDown:e=>{const t=h[w].includes(e.key);null==s||s({event:e,direction:t?-1:1})}})))})),C=/*#__PURE__*/p.forwardRef(((e,t)=>{const{min:n,max:r,onSlideStart:o,onSlideMove:i,onStepKeyDown:a,...l}=e,s=p.useRef(null),u=d(t,s),c=p.useRef();function f(e){const t=c.current||s.current.getBoundingClientRect(),o=H([0,t.height],[r,n]);return c.current=t,o(e-t.top)}/*#__PURE__*/return p.createElement(_,{scope:e.__scopeSlider,startEdge:"bottom",endEdge:"top",size:"height",direction:1},/*#__PURE__*/p.createElement(K,m({"data-orientation":"vertical"},l,{ref:u,style:{...l.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:e=>{const t=f(e.clientY);null==o||o(t)},onSlideMove:e=>{const t=f(e.clientY);null==i||i(t)},onSlideEnd:()=>c.current=void 0,onStepKeyDown:e=>{const t=h.ltr.includes(e.key);null==a||a({event:e,direction:t?-1:1})}})))})),K=/*#__PURE__*/p.forwardRef(((e,t)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:i,onSlideEnd:a,onHomeKeyDown:l,onEndKeyDown:s,onStepKeyDown:u,...d}=e,f=R("Slider",n);/*#__PURE__*/return p.createElement(o.span,m({},d,{ref:t,onKeyDown:c(e.onKeyDown,(e=>{"Home"===e.key?(l(e),e.preventDefault()):"End"===e.key?(s(e),e.preventDefault()):S.concat(v).includes(e.key)&&(u(e),e.preventDefault())})),onPointerDown:c(e.onPointerDown,(e=>{const t=e.target;t.setPointerCapture(e.pointerId),e.preventDefault(),f.thumbs.has(t)?t.focus():r(e)})),onPointerMove:c(e.onPointerMove,(e=>{e.target.hasPointerCapture(e.pointerId)&&i(e)})),onPointerUp:c(e.onPointerUp,(e=>{const t=e.target;t.hasPointerCapture(e.pointerId)&&(t.releasePointerCapture(e.pointerId),a(e))}))}))})),k=/*#__PURE__*/p.forwardRef(((e,t)=>{const{__scopeSlider:n,...r}=e,i=R("SliderTrack",n);/*#__PURE__*/return p.createElement(o.span,m({"data-disabled":i.disabled?"":void 0,"data-orientation":i.orientation},r,{ref:t}))}));exports.SliderTrack=k;const q=/*#__PURE__*/p.forwardRef(((e,t)=>{const{__scopeSlider:n,...r}=e,i=R("SliderRange",n),a=M("SliderRange",n),l=p.useRef(null),s=d(t,l),u=i.values.length,c=i.values.map((e=>A(e,i.min,i.max))),f=u>1?Math.min(...c):0,S=100-Math.max(...c);/*#__PURE__*/return p.createElement(o.span,m({"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0},r,{ref:s,style:{...e.style,[a.startEdge]:f+"%",[a.endEdge]:S+"%"}}))}));exports.SliderRange=q;const T=/*#__PURE__*/p.forwardRef(((e,t)=>{const n=g(e.__scopeSlider),[r,o]=p.useState(null),i=d(t,(e=>o(e))),a=p.useMemo((()=>r?n().findIndex((e=>e.ref.current===r)):-1),[n,r]);/*#__PURE__*/return p.createElement(I,m({},e,{ref:i,index:a}))}));exports.SliderThumb=T;const I=/*#__PURE__*/p.forwardRef(((e,t)=>{const{__scopeSlider:n,index:r,...a}=e,l=R("SliderThumb",n),s=M("SliderThumb",n),[u,f]=p.useState(null),S=d(t,(e=>f(e))),v=i(u),h=l.values[r],g=void 0===h?0:A(h,l.min,l.max),x=function(e,t){return t>2?`Value ${e+1} of ${t}`:2===t?["Minimum","Maximum"][e]:void 0}(r,l.values.length),b=null==v?void 0:v[s.size],E=b?function(e,t,n){const r=e/2,o=H([0,50],[0,r]);return(r-o(t)*n)*n}(b,g,s.direction):0;return p.useEffect((()=>{if(u)return l.thumbs.add(u),()=>{l.thumbs.delete(u)}}),[u,l.thumbs]),/*#__PURE__*/p.createElement("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[s.startEdge]:`calc(${g}% + ${E}px)`}},/*#__PURE__*/p.createElement(w.ItemSlot,{scope:e.__scopeSlider},/*#__PURE__*/p.createElement(o.span,m({role:"slider","aria-label":e["aria-label"]||x,"aria-valuemin":l.min,"aria-valuenow":h,"aria-valuemax":l.max,"aria-orientation":l.orientation,"data-orientation":l.orientation,"data-disabled":l.disabled?"":void 0,tabIndex:l.disabled?void 0:0},a,{ref:S,style:void 0===h?{display:"none"}:e.style,onFocus:c(e.onFocus,(()=>{l.valueIndexToChangeRef.current=r}))}))))})),z=e=>{const{value:t,...n}=e,r=p.useRef(null),o=a(t);return p.useEffect((()=>{const e=r.current,n=window.HTMLInputElement.prototype,i=Object.getOwnPropertyDescriptor(n,"value").set;if(o!==t&&i){const n=new Event("input",{bubbles:!0});i.call(e,t),e.dispatchEvent(n)}}),[o,t]),/*#__PURE__*/p.createElement("input",m({style:{display:"none"}},n,{ref:r,defaultValue:t}))};/*#__PURE__*/function A(e,t,n){return 100/(n-t)*(e-t)}function H(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])}}const O=D;exports.Root=O;const B=k;exports.Track=B;const U=q;exports.Range=U;const V=T;exports.Thumb=V;
1
+ var $inrcs$babelruntimehelpersextends = require("@babel/runtime/helpers/extends");
2
+ var $inrcs$react = require("react");
3
+ var $inrcs$radixuinumber = require("@radix-ui/number");
4
+ var $inrcs$radixuiprimitive = require("@radix-ui/primitive");
5
+ var $inrcs$radixuireactcomposerefs = require("@radix-ui/react-compose-refs");
6
+ var $inrcs$radixuireactcontext = require("@radix-ui/react-context");
7
+ var $inrcs$radixuireactusecontrollablestate = require("@radix-ui/react-use-controllable-state");
8
+ var $inrcs$radixuireactdirection = require("@radix-ui/react-direction");
9
+ var $inrcs$radixuireactuseprevious = require("@radix-ui/react-use-previous");
10
+ var $inrcs$radixuireactusesize = require("@radix-ui/react-use-size");
11
+ var $inrcs$radixuireactprimitive = require("@radix-ui/react-primitive");
12
+ var $inrcs$radixuireactcollection = require("@radix-ui/react-collection");
13
+
14
+ function $parcel$export(e, n, v, s) {
15
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
16
+ }
17
+ function $parcel$interopDefault(a) {
18
+ return a && a.__esModule ? a.default : a;
19
+ }
20
+
21
+ $parcel$export(module.exports, "createSliderScope", () => $1791bb30e2e418d5$export$ef72632d7b901f97);
22
+ $parcel$export(module.exports, "Slider", () => $1791bb30e2e418d5$export$472062a354075cee);
23
+ $parcel$export(module.exports, "SliderTrack", () => $1791bb30e2e418d5$export$105594979f116971);
24
+ $parcel$export(module.exports, "SliderRange", () => $1791bb30e2e418d5$export$a5cf38a7a000fe77);
25
+ $parcel$export(module.exports, "SliderThumb", () => $1791bb30e2e418d5$export$2c1b491743890dec);
26
+ $parcel$export(module.exports, "Root", () => $1791bb30e2e418d5$export$be92b6f5f03c0fe9);
27
+ $parcel$export(module.exports, "Track", () => $1791bb30e2e418d5$export$13921ac0cc260818);
28
+ $parcel$export(module.exports, "Range", () => $1791bb30e2e418d5$export$9a58ef0d7ad3278c);
29
+ $parcel$export(module.exports, "Thumb", () => $1791bb30e2e418d5$export$6521433ed15a34db);
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+ const $1791bb30e2e418d5$var$PAGE_KEYS = [
43
+ 'PageUp',
44
+ 'PageDown'
45
+ ];
46
+ const $1791bb30e2e418d5$var$ARROW_KEYS = [
47
+ 'ArrowUp',
48
+ 'ArrowDown',
49
+ 'ArrowLeft',
50
+ 'ArrowRight'
51
+ ];
52
+ const $1791bb30e2e418d5$var$BACK_KEYS = {
53
+ ltr: [
54
+ 'ArrowDown',
55
+ 'Home',
56
+ 'ArrowLeft',
57
+ 'PageDown'
58
+ ],
59
+ rtl: [
60
+ 'ArrowDown',
61
+ 'Home',
62
+ 'ArrowRight',
63
+ 'PageDown'
64
+ ]
65
+ };
66
+ /* -------------------------------------------------------------------------------------------------
67
+ * Slider
68
+ * -----------------------------------------------------------------------------------------------*/ const $1791bb30e2e418d5$var$SLIDER_NAME = 'Slider';
69
+ const [$1791bb30e2e418d5$var$Collection, $1791bb30e2e418d5$var$useCollection, $1791bb30e2e418d5$var$createCollectionScope] = $inrcs$radixuireactcollection.createCollection($1791bb30e2e418d5$var$SLIDER_NAME);
70
+ const [$1791bb30e2e418d5$var$createSliderContext, $1791bb30e2e418d5$export$ef72632d7b901f97] = $inrcs$radixuireactcontext.createContextScope($1791bb30e2e418d5$var$SLIDER_NAME, [
71
+ $1791bb30e2e418d5$var$createCollectionScope
72
+ ]);
73
+ const [$1791bb30e2e418d5$var$SliderProvider, $1791bb30e2e418d5$var$useSliderContext] = $1791bb30e2e418d5$var$createSliderContext($1791bb30e2e418d5$var$SLIDER_NAME);
74
+ const $1791bb30e2e418d5$export$472062a354075cee = /*#__PURE__*/ $inrcs$react.forwardRef((props, forwardedRef)=>{
75
+ const { name: name , min: min = 0 , max: max = 100 , step: step = 1 , orientation: orientation = 'horizontal' , disabled: disabled = false , minStepsBetweenThumbs: minStepsBetweenThumbs = 0 , defaultValue: defaultValue = [
76
+ min
77
+ ] , value: value1 , onValueChange: onValueChange = ()=>{} , ...sliderProps } = props;
78
+ const [slider, setSlider] = $inrcs$react.useState(null);
79
+ const composedRefs = $inrcs$radixuireactcomposerefs.useComposedRefs(forwardedRef, (node)=>setSlider(node)
80
+ );
81
+ const thumbRefs = $inrcs$react.useRef(new Set());
82
+ const valueIndexToChangeRef = $inrcs$react.useRef(0);
83
+ const isHorizontal = orientation === 'horizontal'; // We set this to true by default so that events bubble to forms without JS (SSR)
84
+ const isFormControl = slider ? Boolean(slider.closest('form')) : true;
85
+ const SliderOrientation = isHorizontal ? $1791bb30e2e418d5$var$SliderHorizontal : $1791bb30e2e418d5$var$SliderVertical;
86
+ const [values = [], setValues] = $inrcs$radixuireactusecontrollablestate.useControllableState({
87
+ prop: value1,
88
+ defaultProp: defaultValue,
89
+ onChange: (value)=>{
90
+ var _thumbs$valueIndexToC;
91
+ const thumbs = [
92
+ ...thumbRefs.current
93
+ ];
94
+ (_thumbs$valueIndexToC = thumbs[valueIndexToChangeRef.current]) === null || _thumbs$valueIndexToC === void 0 || _thumbs$valueIndexToC.focus();
95
+ onValueChange(value);
96
+ }
97
+ });
98
+ function handleSlideStart(value) {
99
+ const closestIndex = $1791bb30e2e418d5$var$getClosestValueIndex(values, value);
100
+ updateValues(value, closestIndex);
101
+ }
102
+ function handleSlideMove(value) {
103
+ updateValues(value, valueIndexToChangeRef.current);
104
+ }
105
+ function updateValues(value, atIndex) {
106
+ const decimalCount = $1791bb30e2e418d5$var$getDecimalCount(step);
107
+ const snapToStep = $1791bb30e2e418d5$var$roundValue(Math.round((value - min) / step) * step + min, decimalCount);
108
+ const nextValue = $inrcs$radixuinumber.clamp(snapToStep, [
109
+ min,
110
+ max
111
+ ]);
112
+ setValues((prevValues = [])=>{
113
+ const nextValues = $1791bb30e2e418d5$var$getNextSortedValues(prevValues, nextValue, atIndex);
114
+ if ($1791bb30e2e418d5$var$hasMinStepsBetweenValues(nextValues, minStepsBetweenThumbs * step)) {
115
+ valueIndexToChangeRef.current = nextValues.indexOf(nextValue);
116
+ return String(nextValues) === String(prevValues) ? prevValues : nextValues;
117
+ } else return prevValues;
118
+ });
119
+ }
120
+ return /*#__PURE__*/ $inrcs$react.createElement($1791bb30e2e418d5$var$SliderProvider, {
121
+ scope: props.__scopeSlider,
122
+ disabled: disabled,
123
+ min: min,
124
+ max: max,
125
+ valueIndexToChangeRef: valueIndexToChangeRef,
126
+ thumbs: thumbRefs.current,
127
+ values: values,
128
+ orientation: orientation
129
+ }, /*#__PURE__*/ $inrcs$react.createElement($1791bb30e2e418d5$var$Collection.Provider, {
130
+ scope: props.__scopeSlider
131
+ }, /*#__PURE__*/ $inrcs$react.createElement($1791bb30e2e418d5$var$Collection.Slot, {
132
+ scope: props.__scopeSlider
133
+ }, /*#__PURE__*/ $inrcs$react.createElement(SliderOrientation, ($parcel$interopDefault($inrcs$babelruntimehelpersextends))({
134
+ "aria-disabled": disabled,
135
+ "data-disabled": disabled ? '' : undefined
136
+ }, sliderProps, {
137
+ ref: composedRefs,
138
+ min: min,
139
+ max: max,
140
+ onSlideStart: disabled ? undefined : handleSlideStart,
141
+ onSlideMove: disabled ? undefined : handleSlideMove,
142
+ onHomeKeyDown: ()=>!disabled && updateValues(min, 0)
143
+ ,
144
+ onEndKeyDown: ()=>!disabled && updateValues(max, values.length - 1)
145
+ ,
146
+ onStepKeyDown: ({ event: event , direction: stepDirection })=>{
147
+ if (!disabled) {
148
+ const isPageKey = $1791bb30e2e418d5$var$PAGE_KEYS.includes(event.key);
149
+ const isSkipKey = isPageKey || event.shiftKey && $1791bb30e2e418d5$var$ARROW_KEYS.includes(event.key);
150
+ const multiplier = isSkipKey ? 10 : 1;
151
+ const atIndex = valueIndexToChangeRef.current;
152
+ const value = values[atIndex];
153
+ const stepInDirection = step * multiplier * stepDirection;
154
+ updateValues(value + stepInDirection, atIndex);
155
+ }
156
+ }
157
+ })))), isFormControl && values.map((value, index)=>/*#__PURE__*/ $inrcs$react.createElement($1791bb30e2e418d5$var$BubbleInput, {
158
+ key: index,
159
+ name: name ? name + (values.length > 1 ? '[]' : '') : undefined,
160
+ value: value
161
+ })
162
+ ));
163
+ });
164
+ /*#__PURE__*/ Object.assign($1791bb30e2e418d5$export$472062a354075cee, {
165
+ displayName: $1791bb30e2e418d5$var$SLIDER_NAME
166
+ });
167
+ /* -------------------------------------------------------------------------------------------------
168
+ * SliderHorizontal
169
+ * -----------------------------------------------------------------------------------------------*/ const [$1791bb30e2e418d5$var$SliderOrientationProvider, $1791bb30e2e418d5$var$useSliderOrientationContext] = $1791bb30e2e418d5$var$createSliderContext($1791bb30e2e418d5$var$SLIDER_NAME, {
170
+ startEdge: 'left',
171
+ endEdge: 'right',
172
+ size: 'width',
173
+ direction: 1
174
+ });
175
+ const $1791bb30e2e418d5$var$SliderHorizontal = /*#__PURE__*/ $inrcs$react.forwardRef((props, forwardedRef)=>{
176
+ const { min: min , max: max , dir: dir , onSlideStart: onSlideStart , onSlideMove: onSlideMove , onStepKeyDown: onStepKeyDown , ...sliderProps } = props;
177
+ const [slider, setSlider] = $inrcs$react.useState(null);
178
+ const composedRefs = $inrcs$radixuireactcomposerefs.useComposedRefs(forwardedRef, (node)=>setSlider(node)
179
+ );
180
+ const rectRef = $inrcs$react.useRef();
181
+ const direction = $inrcs$radixuireactdirection.useDirection(dir);
182
+ const isDirectionLTR = direction === 'ltr';
183
+ function getValueFromPointer(pointerPosition) {
184
+ const rect = rectRef.current || slider.getBoundingClientRect();
185
+ const input = [
186
+ 0,
187
+ rect.width
188
+ ];
189
+ const output = isDirectionLTR ? [
190
+ min,
191
+ max
192
+ ] : [
193
+ max,
194
+ min
195
+ ];
196
+ const value = $1791bb30e2e418d5$var$linearScale(input, output);
197
+ rectRef.current = rect;
198
+ return value(pointerPosition - rect.left);
199
+ }
200
+ return /*#__PURE__*/ $inrcs$react.createElement($1791bb30e2e418d5$var$SliderOrientationProvider, {
201
+ scope: props.__scopeSlider,
202
+ startEdge: isDirectionLTR ? 'left' : 'right',
203
+ endEdge: isDirectionLTR ? 'right' : 'left',
204
+ direction: isDirectionLTR ? 1 : -1,
205
+ size: "width"
206
+ }, /*#__PURE__*/ $inrcs$react.createElement($1791bb30e2e418d5$var$SliderImpl, ($parcel$interopDefault($inrcs$babelruntimehelpersextends))({
207
+ dir: direction,
208
+ "data-orientation": "horizontal"
209
+ }, sliderProps, {
210
+ ref: composedRefs,
211
+ style: {
212
+ ...sliderProps.style,
213
+ ['--radix-slider-thumb-transform']: 'translateX(-50%)'
214
+ },
215
+ onSlideStart: (event)=>{
216
+ const value = getValueFromPointer(event.clientX);
217
+ onSlideStart === null || onSlideStart === void 0 || onSlideStart(value);
218
+ },
219
+ onSlideMove: (event)=>{
220
+ const value = getValueFromPointer(event.clientX);
221
+ onSlideMove === null || onSlideMove === void 0 || onSlideMove(value);
222
+ },
223
+ onSlideEnd: ()=>rectRef.current = undefined
224
+ ,
225
+ onStepKeyDown: (event)=>{
226
+ const isBackKey = $1791bb30e2e418d5$var$BACK_KEYS[direction].includes(event.key);
227
+ onStepKeyDown === null || onStepKeyDown === void 0 || onStepKeyDown({
228
+ event: event,
229
+ direction: isBackKey ? -1 : 1
230
+ });
231
+ }
232
+ })));
233
+ });
234
+ /* -------------------------------------------------------------------------------------------------
235
+ * SliderVertical
236
+ * -----------------------------------------------------------------------------------------------*/ const $1791bb30e2e418d5$var$SliderVertical = /*#__PURE__*/ $inrcs$react.forwardRef((props, forwardedRef)=>{
237
+ const { min: min , max: max , onSlideStart: onSlideStart , onSlideMove: onSlideMove , onStepKeyDown: onStepKeyDown , ...sliderProps } = props;
238
+ const sliderRef = $inrcs$react.useRef(null);
239
+ const ref = $inrcs$radixuireactcomposerefs.useComposedRefs(forwardedRef, sliderRef);
240
+ const rectRef = $inrcs$react.useRef();
241
+ function getValueFromPointer(pointerPosition) {
242
+ const rect = rectRef.current || sliderRef.current.getBoundingClientRect();
243
+ const input = [
244
+ 0,
245
+ rect.height
246
+ ];
247
+ const output = [
248
+ max,
249
+ min
250
+ ];
251
+ const value = $1791bb30e2e418d5$var$linearScale(input, output);
252
+ rectRef.current = rect;
253
+ return value(pointerPosition - rect.top);
254
+ }
255
+ return /*#__PURE__*/ $inrcs$react.createElement($1791bb30e2e418d5$var$SliderOrientationProvider, {
256
+ scope: props.__scopeSlider,
257
+ startEdge: "bottom",
258
+ endEdge: "top",
259
+ size: "height",
260
+ direction: 1
261
+ }, /*#__PURE__*/ $inrcs$react.createElement($1791bb30e2e418d5$var$SliderImpl, ($parcel$interopDefault($inrcs$babelruntimehelpersextends))({
262
+ "data-orientation": "vertical"
263
+ }, sliderProps, {
264
+ ref: ref,
265
+ style: {
266
+ ...sliderProps.style,
267
+ ['--radix-slider-thumb-transform']: 'translateY(50%)'
268
+ },
269
+ onSlideStart: (event)=>{
270
+ const value = getValueFromPointer(event.clientY);
271
+ onSlideStart === null || onSlideStart === void 0 || onSlideStart(value);
272
+ },
273
+ onSlideMove: (event)=>{
274
+ const value = getValueFromPointer(event.clientY);
275
+ onSlideMove === null || onSlideMove === void 0 || onSlideMove(value);
276
+ },
277
+ onSlideEnd: ()=>rectRef.current = undefined
278
+ ,
279
+ onStepKeyDown: (event)=>{
280
+ const isBackKey = $1791bb30e2e418d5$var$BACK_KEYS.ltr.includes(event.key);
281
+ onStepKeyDown === null || onStepKeyDown === void 0 || onStepKeyDown({
282
+ event: event,
283
+ direction: isBackKey ? -1 : 1
284
+ });
285
+ }
286
+ })));
287
+ });
288
+ /* -------------------------------------------------------------------------------------------------
289
+ * SliderImpl
290
+ * -----------------------------------------------------------------------------------------------*/ const $1791bb30e2e418d5$var$SliderImpl = /*#__PURE__*/ $inrcs$react.forwardRef((props, forwardedRef)=>{
291
+ const { __scopeSlider: __scopeSlider , onSlideStart: onSlideStart , onSlideMove: onSlideMove , onSlideEnd: onSlideEnd , onHomeKeyDown: onHomeKeyDown , onEndKeyDown: onEndKeyDown , onStepKeyDown: onStepKeyDown , ...sliderProps } = props;
292
+ const context = $1791bb30e2e418d5$var$useSliderContext($1791bb30e2e418d5$var$SLIDER_NAME, __scopeSlider);
293
+ return /*#__PURE__*/ $inrcs$react.createElement($inrcs$radixuireactprimitive.Primitive.span, ($parcel$interopDefault($inrcs$babelruntimehelpersextends))({}, sliderProps, {
294
+ ref: forwardedRef,
295
+ onKeyDown: $inrcs$radixuiprimitive.composeEventHandlers(props.onKeyDown, (event)=>{
296
+ if (event.key === 'Home') {
297
+ onHomeKeyDown(event); // Prevent scrolling to page start
298
+ event.preventDefault();
299
+ } else if (event.key === 'End') {
300
+ onEndKeyDown(event); // Prevent scrolling to page end
301
+ event.preventDefault();
302
+ } else if ($1791bb30e2e418d5$var$PAGE_KEYS.concat($1791bb30e2e418d5$var$ARROW_KEYS).includes(event.key)) {
303
+ onStepKeyDown(event); // Prevent scrolling for directional key presses
304
+ event.preventDefault();
305
+ }
306
+ }),
307
+ onPointerDown: $inrcs$radixuiprimitive.composeEventHandlers(props.onPointerDown, (event)=>{
308
+ const target = event.target;
309
+ target.setPointerCapture(event.pointerId); // Prevent browser focus behaviour because we focus a thumb manually when values change.
310
+ event.preventDefault(); // Touch devices have a delay before focusing so won't focus if touch immediately moves
311
+ // away from target (sliding). We want thumb to focus regardless.
312
+ if (context.thumbs.has(target)) target.focus();
313
+ else onSlideStart(event);
314
+ }),
315
+ onPointerMove: $inrcs$radixuiprimitive.composeEventHandlers(props.onPointerMove, (event)=>{
316
+ const target = event.target;
317
+ if (target.hasPointerCapture(event.pointerId)) onSlideMove(event);
318
+ }),
319
+ onPointerUp: $inrcs$radixuiprimitive.composeEventHandlers(props.onPointerUp, (event)=>{
320
+ const target = event.target;
321
+ if (target.hasPointerCapture(event.pointerId)) {
322
+ target.releasePointerCapture(event.pointerId);
323
+ onSlideEnd(event);
324
+ }
325
+ })
326
+ }));
327
+ });
328
+ /* -------------------------------------------------------------------------------------------------
329
+ * SliderTrack
330
+ * -----------------------------------------------------------------------------------------------*/ const $1791bb30e2e418d5$var$TRACK_NAME = 'SliderTrack';
331
+ const $1791bb30e2e418d5$export$105594979f116971 = /*#__PURE__*/ $inrcs$react.forwardRef((props, forwardedRef)=>{
332
+ const { __scopeSlider: __scopeSlider , ...trackProps } = props;
333
+ const context = $1791bb30e2e418d5$var$useSliderContext($1791bb30e2e418d5$var$TRACK_NAME, __scopeSlider);
334
+ return /*#__PURE__*/ $inrcs$react.createElement($inrcs$radixuireactprimitive.Primitive.span, ($parcel$interopDefault($inrcs$babelruntimehelpersextends))({
335
+ "data-disabled": context.disabled ? '' : undefined,
336
+ "data-orientation": context.orientation
337
+ }, trackProps, {
338
+ ref: forwardedRef
339
+ }));
340
+ });
341
+ /*#__PURE__*/ Object.assign($1791bb30e2e418d5$export$105594979f116971, {
342
+ displayName: $1791bb30e2e418d5$var$TRACK_NAME
343
+ });
344
+ /* -------------------------------------------------------------------------------------------------
345
+ * SliderRange
346
+ * -----------------------------------------------------------------------------------------------*/ const $1791bb30e2e418d5$var$RANGE_NAME = 'SliderRange';
347
+ const $1791bb30e2e418d5$export$a5cf38a7a000fe77 = /*#__PURE__*/ $inrcs$react.forwardRef((props, forwardedRef)=>{
348
+ const { __scopeSlider: __scopeSlider , ...rangeProps } = props;
349
+ const context = $1791bb30e2e418d5$var$useSliderContext($1791bb30e2e418d5$var$RANGE_NAME, __scopeSlider);
350
+ const orientation = $1791bb30e2e418d5$var$useSliderOrientationContext($1791bb30e2e418d5$var$RANGE_NAME, __scopeSlider);
351
+ const ref = $inrcs$react.useRef(null);
352
+ const composedRefs = $inrcs$radixuireactcomposerefs.useComposedRefs(forwardedRef, ref);
353
+ const valuesCount = context.values.length;
354
+ const percentages = context.values.map((value)=>$1791bb30e2e418d5$var$convertValueToPercentage(value, context.min, context.max)
355
+ );
356
+ const offsetStart = valuesCount > 1 ? Math.min(...percentages) : 0;
357
+ const offsetEnd = 100 - Math.max(...percentages);
358
+ return /*#__PURE__*/ $inrcs$react.createElement($inrcs$radixuireactprimitive.Primitive.span, ($parcel$interopDefault($inrcs$babelruntimehelpersextends))({
359
+ "data-orientation": context.orientation,
360
+ "data-disabled": context.disabled ? '' : undefined
361
+ }, rangeProps, {
362
+ ref: composedRefs,
363
+ style: {
364
+ ...props.style,
365
+ [orientation.startEdge]: offsetStart + '%',
366
+ [orientation.endEdge]: offsetEnd + '%'
367
+ }
368
+ }));
369
+ });
370
+ /*#__PURE__*/ Object.assign($1791bb30e2e418d5$export$a5cf38a7a000fe77, {
371
+ displayName: $1791bb30e2e418d5$var$RANGE_NAME
372
+ });
373
+ /* -------------------------------------------------------------------------------------------------
374
+ * SliderThumb
375
+ * -----------------------------------------------------------------------------------------------*/ const $1791bb30e2e418d5$var$THUMB_NAME = 'SliderThumb';
376
+ const $1791bb30e2e418d5$export$2c1b491743890dec = /*#__PURE__*/ $inrcs$react.forwardRef((props, forwardedRef)=>{
377
+ const getItems = $1791bb30e2e418d5$var$useCollection(props.__scopeSlider);
378
+ const [thumb, setThumb] = $inrcs$react.useState(null);
379
+ const composedRefs = $inrcs$radixuireactcomposerefs.useComposedRefs(forwardedRef, (node)=>setThumb(node)
380
+ );
381
+ const index = $inrcs$react.useMemo(()=>thumb ? getItems().findIndex((item)=>item.ref.current === thumb
382
+ ) : -1
383
+ , [
384
+ getItems,
385
+ thumb
386
+ ]);
387
+ return /*#__PURE__*/ $inrcs$react.createElement($1791bb30e2e418d5$var$SliderThumbImpl, ($parcel$interopDefault($inrcs$babelruntimehelpersextends))({}, props, {
388
+ ref: composedRefs,
389
+ index: index
390
+ }));
391
+ });
392
+ const $1791bb30e2e418d5$var$SliderThumbImpl = /*#__PURE__*/ $inrcs$react.forwardRef((props, forwardedRef)=>{
393
+ const { __scopeSlider: __scopeSlider , index: index , ...thumbProps } = props;
394
+ const context = $1791bb30e2e418d5$var$useSliderContext($1791bb30e2e418d5$var$THUMB_NAME, __scopeSlider);
395
+ const orientation = $1791bb30e2e418d5$var$useSliderOrientationContext($1791bb30e2e418d5$var$THUMB_NAME, __scopeSlider);
396
+ const [thumb, setThumb] = $inrcs$react.useState(null);
397
+ const composedRefs = $inrcs$radixuireactcomposerefs.useComposedRefs(forwardedRef, (node)=>setThumb(node)
398
+ );
399
+ const size = $inrcs$radixuireactusesize.useSize(thumb); // We cast because index could be `-1` which would return undefined
400
+ const value = context.values[index];
401
+ const percent = value === undefined ? 0 : $1791bb30e2e418d5$var$convertValueToPercentage(value, context.min, context.max);
402
+ const label = $1791bb30e2e418d5$var$getLabel(index, context.values.length);
403
+ const orientationSize = size === null || size === void 0 ? void 0 : size[orientation.size];
404
+ const thumbInBoundsOffset = orientationSize ? $1791bb30e2e418d5$var$getThumbInBoundsOffset(orientationSize, percent, orientation.direction) : 0;
405
+ $inrcs$react.useEffect(()=>{
406
+ if (thumb) {
407
+ context.thumbs.add(thumb);
408
+ return ()=>{
409
+ context.thumbs.delete(thumb);
410
+ };
411
+ }
412
+ }, [
413
+ thumb,
414
+ context.thumbs
415
+ ]);
416
+ return /*#__PURE__*/ $inrcs$react.createElement("span", {
417
+ style: {
418
+ transform: 'var(--radix-slider-thumb-transform)',
419
+ position: 'absolute',
420
+ [orientation.startEdge]: `calc(${percent}% + ${thumbInBoundsOffset}px)`
421
+ }
422
+ }, /*#__PURE__*/ $inrcs$react.createElement($1791bb30e2e418d5$var$Collection.ItemSlot, {
423
+ scope: props.__scopeSlider
424
+ }, /*#__PURE__*/ $inrcs$react.createElement($inrcs$radixuireactprimitive.Primitive.span, ($parcel$interopDefault($inrcs$babelruntimehelpersextends))({
425
+ role: "slider",
426
+ "aria-label": props['aria-label'] || label,
427
+ "aria-valuemin": context.min,
428
+ "aria-valuenow": value,
429
+ "aria-valuemax": context.max,
430
+ "aria-orientation": context.orientation,
431
+ "data-orientation": context.orientation,
432
+ "data-disabled": context.disabled ? '' : undefined,
433
+ tabIndex: context.disabled ? undefined : 0
434
+ }, thumbProps, {
435
+ ref: composedRefs,
436
+ style: value === undefined ? {
437
+ display: 'none'
438
+ } : props.style,
439
+ onFocus: $inrcs$radixuiprimitive.composeEventHandlers(props.onFocus, ()=>{
440
+ context.valueIndexToChangeRef.current = index;
441
+ })
442
+ }))));
443
+ });
444
+ /*#__PURE__*/ Object.assign($1791bb30e2e418d5$export$2c1b491743890dec, {
445
+ displayName: $1791bb30e2e418d5$var$THUMB_NAME
446
+ });
447
+ /* -----------------------------------------------------------------------------------------------*/ const $1791bb30e2e418d5$var$BubbleInput = (props)=>{
448
+ const { value: value , ...inputProps } = props;
449
+ const ref = $inrcs$react.useRef(null);
450
+ const prevValue = $inrcs$radixuireactuseprevious.usePrevious(value); // Bubble value change to parents (e.g form change event)
451
+ $inrcs$react.useEffect(()=>{
452
+ const input = ref.current;
453
+ const inputProto = window.HTMLInputElement.prototype;
454
+ const descriptor = Object.getOwnPropertyDescriptor(inputProto, 'value');
455
+ const setValue = descriptor.set;
456
+ if (prevValue !== value && setValue) {
457
+ const event = new Event('input', {
458
+ bubbles: true
459
+ });
460
+ setValue.call(input, value);
461
+ input.dispatchEvent(event);
462
+ }
463
+ }, [
464
+ prevValue,
465
+ value
466
+ ]);
467
+ /**
468
+ * We purposefully do not use `type="hidden"` here otherwise forms that
469
+ * wrap it will not be able to access its value via the FormData API.
470
+ *
471
+ * We purposefully do not add the `value` attribute here to allow the value
472
+ * to be set programatically and bubble to any parent form `onChange` event.
473
+ * Adding the `value` will cause React to consider the programatic
474
+ * dispatch a duplicate and it will get swallowed.
475
+ */ return /*#__PURE__*/ $inrcs$react.createElement("input", ($parcel$interopDefault($inrcs$babelruntimehelpersextends))({
476
+ style: {
477
+ display: 'none'
478
+ }
479
+ }, inputProps, {
480
+ ref: ref,
481
+ defaultValue: value
482
+ }));
483
+ };
484
+ function $1791bb30e2e418d5$var$getNextSortedValues(prevValues = [], nextValue, atIndex) {
485
+ const nextValues = [
486
+ ...prevValues
487
+ ];
488
+ nextValues[atIndex] = nextValue;
489
+ return nextValues.sort((a, b)=>a - b
490
+ );
491
+ }
492
+ function $1791bb30e2e418d5$var$convertValueToPercentage(value, min, max) {
493
+ const maxSteps = max - min;
494
+ const percentPerStep = 100 / maxSteps;
495
+ return percentPerStep * (value - min);
496
+ }
497
+ /**
498
+ * Returns a label for each thumb when there are two or more thumbs
499
+ */ function $1791bb30e2e418d5$var$getLabel(index, totalValues) {
500
+ if (totalValues > 2) return `Value ${index + 1} of ${totalValues}`;
501
+ else if (totalValues === 2) return [
502
+ 'Minimum',
503
+ 'Maximum'
504
+ ][index];
505
+ else return undefined;
506
+ }
507
+ /**
508
+ * Given a `values` array and a `nextValue`, determine which value in
509
+ * the array is closest to `nextValue` and return its index.
510
+ *
511
+ * @example
512
+ * // returns 1
513
+ * getClosestValueIndex([10, 30], 25);
514
+ */ function $1791bb30e2e418d5$var$getClosestValueIndex(values, nextValue) {
515
+ if (values.length === 1) return 0;
516
+ const distances = values.map((value)=>Math.abs(value - nextValue)
517
+ );
518
+ const closestDistance = Math.min(...distances);
519
+ return distances.indexOf(closestDistance);
520
+ }
521
+ /**
522
+ * Offsets the thumb centre point while sliding to ensure it remains
523
+ * within the bounds of the slider when reaching the edges
524
+ */ function $1791bb30e2e418d5$var$getThumbInBoundsOffset(width, left, direction) {
525
+ const halfWidth = width / 2;
526
+ const halfPercent = 50;
527
+ const offset = $1791bb30e2e418d5$var$linearScale([
528
+ 0,
529
+ halfPercent
530
+ ], [
531
+ 0,
532
+ halfWidth
533
+ ]);
534
+ return (halfWidth - offset(left) * direction) * direction;
535
+ }
536
+ /**
537
+ * Gets an array of steps between each value.
538
+ *
539
+ * @example
540
+ * // returns [1, 9]
541
+ * getStepsBetweenValues([10, 11, 20]);
542
+ */ function $1791bb30e2e418d5$var$getStepsBetweenValues(values) {
543
+ return values.slice(0, -1).map((value, index)=>values[index + 1] - value
544
+ );
545
+ }
546
+ /**
547
+ * Verifies the minimum steps between all values is greater than or equal
548
+ * to the expected minimum steps.
549
+ *
550
+ * @example
551
+ * // returns false
552
+ * hasMinStepsBetweenValues([1,2,3], 2);
553
+ *
554
+ * @example
555
+ * // returns true
556
+ * hasMinStepsBetweenValues([1,2,3], 1);
557
+ */ function $1791bb30e2e418d5$var$hasMinStepsBetweenValues(values, minStepsBetweenValues) {
558
+ if (minStepsBetweenValues > 0) {
559
+ const stepsBetweenValues = $1791bb30e2e418d5$var$getStepsBetweenValues(values);
560
+ const actualMinStepsBetweenValues = Math.min(...stepsBetweenValues);
561
+ return actualMinStepsBetweenValues >= minStepsBetweenValues;
562
+ }
563
+ return true;
564
+ } // https://github.com/tmcw-up-for-adoption/simple-linear-scale/blob/master/index.js
565
+ function $1791bb30e2e418d5$var$linearScale(input, output) {
566
+ return (value)=>{
567
+ if (input[0] === input[1] || output[0] === output[1]) return output[0];
568
+ const ratio = (output[1] - output[0]) / (input[1] - input[0]);
569
+ return output[0] + ratio * (value - input[0]);
570
+ };
571
+ }
572
+ function $1791bb30e2e418d5$var$getDecimalCount(value) {
573
+ return (String(value).split('.')[1] || '').length;
574
+ }
575
+ function $1791bb30e2e418d5$var$roundValue(value, decimalCount) {
576
+ const rounder = Math.pow(10, decimalCount);
577
+ return Math.round(value * rounder) / rounder;
578
+ }
579
+ const $1791bb30e2e418d5$export$be92b6f5f03c0fe9 = $1791bb30e2e418d5$export$472062a354075cee;
580
+ const $1791bb30e2e418d5$export$13921ac0cc260818 = $1791bb30e2e418d5$export$105594979f116971;
581
+ const $1791bb30e2e418d5$export$9a58ef0d7ad3278c = $1791bb30e2e418d5$export$a5cf38a7a000fe77;
582
+ const $1791bb30e2e418d5$export$6521433ed15a34db = $1791bb30e2e418d5$export$2c1b491743890dec;
583
+
584
+
585
+
586
+
2
587
  //# sourceMappingURL=index.js.map