@zag-js/range-slider
Advanced tools
Comparing version 0.0.0-dev-20220408111010 to 0.0.0-dev-20220408120729
@@ -1,2 +0,2 @@ | ||
var R=Object.defineProperty,Re=Object.defineProperties,Oe=Object.getOwnPropertyDescriptor,Ve=Object.getOwnPropertyDescriptors,Ne=Object.getOwnPropertyNames,J=Object.getOwnPropertySymbols;var Q=Object.prototype.hasOwnProperty,De=Object.prototype.propertyIsEnumerable;var ee=(e,t,n)=>t in e?R(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,O=(e,t)=>{for(var n in t||(t={}))Q.call(t,n)&&ee(e,n,t[n]);if(J)for(var n of J(t))De.call(t,n)&&ee(e,n,t[n]);return e},V=(e,t)=>Re(e,Ve(t)),Fe=e=>R(e,"__esModule",{value:!0});var _e=(e,t)=>{for(var n in t)R(e,n,{get:t[n],enumerable:!0})},We=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ne(t))!Q.call(e,o)&&(n||o!=="default")&&R(e,o,{get:()=>t[o],enumerable:!(r=Oe(t,o))||r.enumerable});return e};var He=(e=>(t,n)=>e&&e.get(t)||(n=We(Fe({}),t,1),e&&e.set(t,n),n))(typeof WeakMap!="undefined"?new WeakMap:0);var Rt={};_e(Rt,{connect:()=>Se,machine:()=>Me});var te=Math.pow,v=e=>e?"":void 0;function M(e){let t=new Set;function n(r){let o=globalThis.requestAnimationFrame(r);t.add(()=>globalThis.cancelAnimationFrame(o))}return n(()=>n(e)),function(){t.forEach(function(r){r()})}}function ne(e){let t=globalThis.requestAnimationFrame(e);return function(){globalThis.cancelAnimationFrame(t)}}var ze=()=>{},Ue=(...e)=>t=>e.reduce((n,r)=>r(n),t),Vt=(()=>{let e=0;return()=>(e++,e.toString(36))})(),U=e=>je()&&e.test(navigator.platform),je=()=>typeof window!="undefined",$e=()=>U(/^Mac/),Be=()=>U(/^iPhone/),Ye=()=>U(/^iPad/)||$e()&&navigator.maxTouchPoints>1,re=()=>Be()||Ye(),Xe=e=>Array.isArray(e),qe=e=>!(e==null||typeof e!="object"||Xe(e)),Ke=e=>qe(e)&&"button"in e,Ge=e=>e.button===0,E=new Map,h=new Map;function Ze(e,t,n,r){var o;if(!e)return ze;let a=JSON.stringify({type:t,options:r}),s=E.get(e);if(E.has(e))(s==null?void 0:s.has(a))?(o=s==null?void 0:s.get(a))==null||o.add(n):s==null||s.set(a,new Set([n]));else{let u=new Map([[a,new Set([n])]]);E.set(e,u)}function g(u){var p,i;function c(d){var f;let w=E.get(u);(f=w==null?void 0:w.get(a))==null||f.forEach(b=>b(d))}if(!(h==null?void 0:h.has(u))){h.set(u,new Map([[a,c]])),u.addEventListener(t,c,r);return}((p=h==null?void 0:h.get(u))==null?void 0:p.has(a))||((i=h.get(u))==null||i.set(a,c),u.addEventListener(t,c,r))}return g(e),function(){var u,p,i,c;if(!E.has(e))return;let d=E.get(e);if((u=d==null?void 0:d.get(a))==null||u.delete(n),((p=d==null?void 0:d.get(a))==null?void 0:p.size)===0){let f=(i=h.get(e))==null?void 0:i.get(a);e.removeEventListener(t,f,r),d==null||d.delete(a),(c=h.get(e))==null||c.delete(a),(d==null?void 0:d.size)===0&&(E.delete(e),h.delete(e))}}}var j=e=>Object.prototype.toString.call(e).slice(8,-1),Je=e=>j(e)==="Object"&&"current"in e,Qe=e=>j(e)==="Function"?e():e,et=e=>j(e)==="Object"&&!!e.touches,tt={pageX:0,pageY:0,clientX:0,clientY:0};function nt(e,t="page"){let n=et(e)?e.touches[0]||e.changedTouches[0]||tt:e;return{point:{x:n[`${t}X`],y:n[`${t}Y`]}}}function rt(e,t,n,r){let o=Je(e)?e.current:Qe(e);return Ze(o,t,n,r)}function N(e,t,n,r){var o;let a=(o=dt(t))!=null?o:t;return rt(e,a,ot(n,t==="pointerdown"),r)}function ot(e,t=!1){let n=r=>{e(r,nt(r))};return t?it(n):n}function it(e){return t=>{var n;let r=(n=t.view)!=null?n:window,o=t instanceof r.MouseEvent;(!o||o&&t.button===0)&&e(t)}}var at=()=>typeof window!="undefined"&&window.onpointerdown===null,lt=()=>typeof window!="undefined"&&window.ontouchstart===null,ut=()=>typeof window!="undefined"&&window.onmousedown===null,st={pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointercancel:"mousecancel",pointerover:"mouseover",pointerout:"mouseout",pointerenter:"mouseenter",pointerleave:"mouseleave"},ct={pointerdown:"touchstart",pointermove:"touchmove",pointerup:"touchend",pointercancel:"touchcancel"};function dt(e){return at()?e:lt()?ct[e]:ut()?st[e]:e}function oe(e){var t;return(t=e==null?void 0:e.ownerDocument.defaultView)!=null?t:window}function ie(e){var t;return(t=e.nativeEvent)!=null?t:e}function ae(e,t){var n;let{type:r,property:o}=t,a=oe(e)[r==="input"?"HTMLInputElement":"HTMLTextAreaElement"].prototype;return(n=Object.getOwnPropertyDescriptor(a,o))!=null?n:{}}function le(e,t){var n;let r=oe(e);if(!(e instanceof r.HTMLInputElement))return;(n=ae(e,{type:"input",property:"value"}).set)==null||n.call(e,t);let o=new r.Event("input",{bubbles:!0});e.dispatchEvent(o)}function ue(e,t){let{fn:n,property:r,type:o}=t;if(!n||!e)return;let{get:a,set:s}=ae(e,{property:r,type:o}),g=!0;return Object.defineProperty(e,r,{get(){return a==null?void 0:a.call(this)},set(u){return g&&n(u),s==null?void 0:s.call(this,u)}}),function(){g=!1}}var Nt=["input:not([disabled]):not([type=hidden])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","embed","iframe","object","a[href]","area[href]","[tabindex]","audio[controls]","video[controls]","*[tabindex]:not([aria-disabled])","[contenteditable]:not([contenteditable=false])","details > summary:first-of-type"].join(",");function mt(e){return pt(e)?e.form:e.closest("form")}function pt(e){return["textarea","input","select","button"].includes(e.localName)}function se(e,t){if(!e)return;let n=mt(e);return n==null||n.addEventListener("reset",t,{passive:!0}),()=>{n==null||n.removeEventListener("reset",t)}}var ce={ArrowLeft:"ArrowRight",ArrowRight:"ArrowLeft",Home:"End",End:"Home"},ft={Up:"ArrowUp",Down:"ArrowDown",Esc:"Escape"," ":"Space",",":"Comma",Left:"ArrowLeft",Right:"ArrowRight"};function de(e,t={}){var n;let{dir:r="ltr",orientation:o="horizontal"}=t,{key:a}=e;return a=(n=ft[a])!=null?n:a,r==="rtl"&&o==="horizontal"&&a in ce&&(a=ce[a]),a}var gt=new Set(["PageUp","PageDown"]),vt=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]);function me(e){return e.ctrlKey||e.metaKey?.1:gt.has(e.key)||e.shiftKey&&vt.has(e.key)?10:1}function pe(e,t){var n;return Array.from((n=e==null?void 0:e.querySelectorAll(t))!=null?n:[])}var A="default",$="",D=new WeakMap;function ht({target:e,doc:t}={}){let n=t!=null?t:document;return re()?(A==="default"&&($=n.documentElement.style.webkitUserSelect,n.documentElement.style.webkitUserSelect="none"),A="disabled"):e&&(D.set(e,e.style.userSelect),e.style.userSelect="none"),()=>yt({target:e,doc:n})}function yt({target:e,doc:t}={}){let n=t!=null?t:document;if(re()){if(A!=="disabled")return;A="restoring",setTimeout(()=>{M(()=>{A==="restoring"&&(n.documentElement.style.webkitUserSelect==="none"&&(n.documentElement.style.webkitUserSelect=$||""),$="",A="default")})},300)}else if(e&&D.has(e)){let r=D.get(e);e.style.userSelect==="none"&&(e.style.userSelect=r!=null?r:""),e.getAttribute("style")===""&&e.removeAttribute("style"),D.delete(e)}}function fe(e){let{onPointerMove:t,onPointerUp:n,ctx:r}=e,{doc:o=document,threshold:a=5}=r;return Ue(N(o,"pointermove",(s,g)=>{let{point:u}=g;if(!(Math.sqrt(te(u.x,2)+te(u.y,2))<a)){if(Ke(s)&&Ge(s)){n();return}t(g,s)}},!1),N(o,"pointerup",n,!1),N(o,"pointercancel",n,!1),N(o,"contextmenu",n,!1),ht({doc:o}))}var bt=Math.pow;var ge=new Intl.NumberFormat("en-US",{style:"decimal"});function B(e){return parseFloat(ge.format(e))}function xt(e,t){let n=x(e),r=bt(10,t!=null?t:10);return n=Math.round(n*r)/r,t?n.toFixed(t):e.toString()}var Y=(e,t)=>(x(e)-t.min)*100/(t.max-t.min),T=(e,t)=>t.min+(t.max-t.min)*x(e);function I(e,t){return Math.min(Math.max(x(e),t.min),t.max)}function wt(e){var t,n;return(n=(t=ge.formatToParts(e).find(r=>r.type==="fraction"))==null?void 0:t.value.length)!=null?n:0}var ve=(e,t)=>B(x(e)+t),he=(e,t)=>B(x(e)-t),F=(e,t)=>B(x(e)*t);function X(e,t){let n=x(e),r=wt(t),o=Math.round(n/t)*t;return xt(o,r)}function x(e){if(typeof e=="number")return e;let t=parseFloat(e.toString().replace(/[^\w.-]+/g,""));return Number.isNaN(t)?0:t}function _(e){var t;let n=(t=e.spacing)!=null?t:0;return e.value.map((r,o)=>{let a=o===0?e.min:e.value[o-1]+n,s=o===e.value.length-1?e.max:e.value[o+1]-n;return{min:a,max:s,value:r}})}var y=(e,t)=>({x:e,y:t}),W=class{constructor(e){this.v=e}static create(e){return new W(e)}set(e){return new W(Object.assign({},this.v,e))}clone(){return new W(this.v)}get x(){return this.v.x}get y(){return this.v.y}get width(){return this.v.width}get height(){return this.v.height}get minX(){return this.v.x}get midX(){return this.v.x+this.v.width/2}get maxX(){return this.v.x+this.v.width}get minY(){return this.v.y}get midY(){return this.v.y+this.v.height/2}get maxY(){return this.v.y+this.v.height}get center(){return y(this.midX,this.midY)}get centers(){let e=y(this.midX,this.minY),t=y(this.maxX,this.midY),n=y(this.midX,this.maxY),r=y(this.minX,this.midY);return{top:e,right:t,bottom:n,left:r}}get corners(){let e=y(this.minX,this.minY),t=y(this.maxX,this.minY),n=y(this.maxX,this.maxY),r=y(this.minX,this.maxY);return{top:e,right:t,bottom:n,left:r}}get edges(){let e=this.corners,t=[e.top,e.right],n=[e.right,e.bottom],r=[e.left,e.bottom],o=[e.top,e.left];return{top:t,right:n,bottom:r,left:o}}},ye=new WeakMap;function Et(e){var t;if(!e)return{};let n=ye.get(e);return n||(n=((t=e==null?void 0:e.ownerDocument.defaultView)!=null?t:window).getComputedStyle(e),ye.set(e,n)),n}function H(e,t={}){return W.create(Tt(e,t))}function Tt(e,t={}){let{excludeScrollbar:n=!1,excludeBorders:r=!1}=t,{x:o,y:a,width:s,height:g}=e.getBoundingClientRect(),u={x:o,y:a,width:s,height:g},p=Et(e),{borderLeftWidth:i,borderTopWidth:c,borderRightWidth:d,borderBottomWidth:f}=p,w=be(i,d),b=be(c,f);if(r&&(u.width-=w,u.height-=b,u.x+=q(i),u.y+=q(c)),n){let C=e.offsetWidth-e.clientWidth-w,L=e.offsetHeight-e.clientHeight-b;u.width-=C,u.height-=L}return u}var q=e=>parseFloat(e.replace("px","")),be=(...e)=>e.reduce((t,n)=>t+(n?q(n):0),0),_t=(()=>{let e=0;return()=>(e++,e.toString(36))})(),Pt=e=>Array.isArray(e),At=e=>!(e==null||typeof e!="object"||Pt(e)),It=e=>At(e)&&"touches"in e;function kt(e,t={x:0,y:0}){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function xe(...e){return t=>{let n=e.map(o=>kt(o,t)),r=Math.min.apply(Math,n);return e[n.indexOf(r)]}}var St={pageX:0,pageY:0,clientX:0,clientY:0};function we(e,t="page"){let n=It(e)?e.touches[0]||e.changedTouches[0]||St:e;return{x:n[`${t}X`],y:n[`${t}Y`]}}function Ee(e,t){let n=e.x-t.offsetLeft-t.clientLeft+t.scrollLeft,r=e.y-t.offsetTop-t.clientTop+t.scrollTop;return{point:{x:n,y:r},progress:{x:n/t.offsetWidth,y:r/t.offsetHeight}}}function Mt(e){return{button:e,label:e,input:e,output:e,element:e}}var Te=Mt(e=>e);var zt=(()=>{let e=0;return()=>(e++,e.toString(36))})();var K=e=>typeof e=="number"&&!Number.isNaN(e);var Pe=e=>e.button===0;var Ae=e=>e.ctrlKey||e.altKey||e.metaKey||e.shiftKey;var G=require("@zag-js/slider");var m={check(e,t){return t.map((n,r)=>m.convert(e,n,r))},clampPercent(e){return I(e,{min:0,max:1})},getRangeAtIndex(e,t=e.activeIndex){return _(e)[t]},fromPercent(e,t){let n=m.getRangeAtIndex(e),r=n.max/e.max,o=n.min/e.max;t=I(t,{min:o,max:r});let a=T(t,e);return parseFloat(X(a,e.step))},convert(e,t,n){let r=m.getRangeAtIndex(e,n);return I(X(t,e.step),r)},decrement(e,t,n){let r=t!=null?t:e.activeIndex,o=m.getRangeAtIndex(e,r),a=he(o.value,n!=null?n:e.step);return m.convert(e,a,r)},increment(e,t,n){let r=t!=null?t:e.activeIndex,o=m.getRangeAtIndex(e,r),a=ve(o.value,n!=null?n:e.step);return m.convert(e,a,r)}};function Ie(e,t){let{progress:n}=Ee(t,l.getControlEl(e)),r;return e.isHorizontal?r=e.isRtl?1-n.x:n.x:r=1-n.y,m.clampPercent(r)}function Ct(e,t){if(e.activeIndex===-1)return;let n=Ie(e,t);return m.fromPercent(e,n)}function Lt(e){let{orientation:t,value:n,max:r}=e,o=n[0]/r*100,a=100-n[n.length-1]/r*100,s={position:"absolute","--slider-range-start":`${o}%`,"--slider-range-end":`${a}%`};return t==="vertical"?V(O({},s),{bottom:"var(--slider-range-start)",top:"var(--slider-range-end)"}):V(O({},s),{[e.isRtl?"right":"left"]:"var(--slider-range-start)",[e.isRtl?"left":"right"]:"var(--slider-range-end)"})}var l={getDoc:e=>{var t;return(t=e.doc)!=null?t:document},getRootId:e=>`slider-${e.uid}`,getThumbId:(e,t)=>`slider-thumb-${e.uid}-${t}`,getInputId:(e,t)=>`slider-input-${e.uid}-${t}`,getControlId:e=>`slider-${e.uid}-root`,getTrackId:e=>`slider-${e.uid}-track`,getRangeId:e=>`slider-${e.uid}-range`,getLabelId:e=>`slider-${e.uid}-label`,getOutputId:e=>`slider-${e.uid}-output`,getMarkerId:(e,t)=>`slider-marker-${e.uid}-${t}`,getThumbEl:(e,t)=>l.getDoc(e).getElementById(l.getThumbId(e,t)),getInputEl:(e,t)=>l.getDoc(e).getElementById(l.getInputId(e,t)),getControlEl:e=>l.getDoc(e).getElementById(l.getControlId(e)),getElements:e=>pe(l.getControlEl(e),"[role=slider]"),getFirstEl:e=>l.getElements(e)[0],getRangeEl:e=>{var t;return(t=l.getDoc(e))==null?void 0:t.getElementById(l.getRangeId(e))},getValueFromPoint:Ct,dispatchChangeEvent(e){Array.from(e.value).forEach((n,r)=>{let o=l.getInputEl(e,r);!o||le(o,n)})},getControlStyle:G.unstable__dom.getControlStyle,getThumbStyle(e,t){var o,a;let n=e.value[t],r=(a=(o=e.thumbSize)==null?void 0:o[t])!=null?a:{width:0,height:0};return G.unstable__dom.getThumbStyle(V(O({},e),{value:n,thumbSize:r}))},getRangeStyle:Lt,getMarkerStyle(e,t){let n={position:"absolute",pointerEvents:"none"};return e.isHorizontal?(t=e.isRtl?100-t:t,n.left=`${t}%`):n.bottom=`${t}%`,n}};function ke(e,t){let n,o=l.getElements(e).map(d=>H(d)).map(d=>d.center),s=xe(...o)(t.point);if(n=o.indexOf(s),!l.getControlEl(e))return n;let u=Ie(e,t.point),p=T(u,e),i=e.isHorizontal?o.map(d=>d.x):o.map(d=>d.y);return new Set(i).size!==o.length&&p>e.value[n]&&(n=I(n+1,{min:0,max:e.value.length-1})),n}function Se(e,t,n=Te){let r=e.context["aria-label"],o=e.context["aria-labelledby"],a=e.context.value,s=e.matches("focus"),g=e.matches("dragging"),u=e.context.disabled,p=e.context.isInteractive;return{values:e.context.value,isDragging:g,isFocused:s,setValue(i){t({type:"SET_VALUE",value:i})},getThumbValue(i){return a[i]},setThumbValue(i,c){t({type:"SET_VALUE",index:i,value:c})},getThumbPercent(i){return Y(a[i],e.context)},setThumbPercent(i,c){let d=T(c,e.context);t({type:"SET_VALUE",index:i,value:d})},getPercentValue(i){return T(i,e.context)},getThumbMin(i){return m.getRangeAtIndex(e.context,i).min},getThumbMax(i){return m.getRangeAtIndex(e.context,i).max},increment(i){t({type:"INCREMENT",index:i})},decrement(i){t({type:"DECREMENT",index:i})},focus(i=0){!p||t({type:"FOCUS",index:i})},labelProps:n.label({"data-part":"label",id:l.getLabelId(e.context),htmlFor:l.getInputId(e.context,0),onClick(i){var c;!p||(i.preventDefault(),(c=l.getFirstEl(e.context))==null||c.focus())},style:{userSelect:"none"}}),rootProps:n.element({"data-part":"root","data-disabled":v(u),"data-orientation":e.context.orientation,id:l.getRootId(e.context),dir:e.context.dir}),outputProps:n.output({"data-part":"output",id:l.getOutputId(e.context),htmlFor:a.map((i,c)=>l.getInputId(e.context,c)).join(" "),"aria-live":"off"}),trackProps:n.element({"data-part":"track",id:l.getTrackId(e.context),"data-disabled":v(u),"data-orientation":e.context.orientation,"data-focus":v(s),style:{position:"relative"}}),getThumbProps(i){var C,L;let c=a[i],d=_(e.context)[i],f=(L=(C=e.context).getAriaValueText)==null?void 0:L.call(C,c,i),w=Array.isArray(r)?r[i]:r,b=Array.isArray(o)?o[i]:o;return n.element({"data-part":"thumb","data-index":i,id:l.getThumbId(e.context,i),"data-disabled":v(u),"data-orientation":e.context.orientation,"data-focus":v(s&&e.context.activeIndex===i),draggable:!1,"aria-disabled":u||void 0,"aria-label":w,"aria-labelledby":b!=null?b:l.getLabelId(e.context),"aria-orientation":e.context.orientation,"aria-valuemax":d.max,"aria-valuemin":d.min,"aria-valuenow":a[i],"aria-valuetext":f,role:"slider",tabIndex:u?void 0:0,style:l.getThumbStyle(e.context,i),onBlur(){!p||t("BLUR")},onFocus(){!p||t({type:"FOCUS",index:i})},onKeyDown(k){if(!p)return;let P=F(me(k),e.context.step),S=!0,Ce={ArrowUp(){t({type:"ARROW_UP",step:P}),S=e.context.isVertical},ArrowDown(){t({type:"ARROW_DOWN",step:P}),S=e.context.isVertical},ArrowLeft(){t({type:"ARROW_LEFT",step:P}),S=e.context.isHorizontal},ArrowRight(){t({type:"ARROW_RIGHT",step:P}),S=e.context.isHorizontal},PageUp(){t({type:"PAGE_UP",step:P})},PageDown(){t({type:"PAGE_DOWN",step:P})},Home(){t("HOME")},End(){t("END")}},Le=de(k,e.context),Z=Ce[Le];!Z||(Z(k),S&&(k.preventDefault(),k.stopPropagation()))}})},getInputProps(i){return n.input({"data-part":"input",name:`${e.context.name}[${i}]`,type:"text",hidden:!0,defaultValue:e.context.value[i],id:l.getInputId(e.context,i)})},rangeProps:n.element({id:l.getRangeId(e.context),"data-part":"range","data-disabled":v(u),"data-orientation":e.context.orientation,style:l.getRangeStyle(e.context)}),controlProps:n.element({"data-part":"control",id:l.getControlId(e.context),"data-disabled":v(u),"data-orientation":e.context.orientation,"data-focus":v(s),style:l.getControlStyle(e.context),onPointerDown(i){if(!p)return;let c=ie(i);!Pe(c)||Ae(c)||(t({type:"POINTER_DOWN",point:we(c)}),i.preventDefault(),i.stopPropagation())}}),markerGroupProps:n.element({"data-part":"marker-group",role:"presentation","aria-hidden":!0,"data-orientation":e.context.orientation,style:{userSelect:"none",pointerEvents:"none",position:"relative"}}),getMarkerProps({value:i}){let c=Y(i,e.context),d=l.getMarkerStyle(e.context,c),f;return Math.max(...e.context.value)<i?f="over-value":Math.min(...e.context.value)>i?f="under-value":f="at-value",n.element({"data-part":"marker",id:l.getMarkerId(e.context,i),role:"presentation","data-value":i,"aria-hidden":!0,"data-disabled":v(u),"data-state":f,style:d})}}}var z=require("@zag-js/core");var Me=(0,z.createMachine)({id:"range-slider",initial:"unknown",context:{thumbSize:null,uid:"48",threshold:5,activeIndex:-1,min:0,max:100,step:1,value:[0,100],initialValue:[],orientation:"horizontal",dir:"ltr",minStepsBetweenThumbs:0},computed:{isHorizontal:e=>e.orientation==="horizontal",isVertical:e=>e.orientation==="vertical",isRtl:e=>e.orientation==="horizontal"&&e.dir==="rtl",isInteractive:e=>!(e.readonly||e.disabled),spacing:e=>F(e.minStepsBetweenThumbs,e.step),hasMeasuredThumbSize:e=>e.thumbSize!=null},watch:{value:["invokeOnChange","dispatchChangeEvent"]},activities:["trackFormReset","trackScriptedUpdate"],on:{SET_VALUE:{actions:"setValue"},INCREMENT:{actions:"incrementAtIndex"},DECREMENT:{actions:"decrementAtIndex"}},states:{unknown:{on:{SETUP:{target:"idle",actions:["setupDocument","setThumbSize","checkValue"]}}},idle:{on:{POINTER_DOWN:{target:"dragging",actions:["setActiveIndex","invokeOnChangeStart","setPointerValue","focusActiveThumb"]},FOCUS:{target:"focus",actions:"setActiveIndex"}}},focus:{entry:"focusActiveThumb",on:{POINTER_DOWN:{target:"dragging",actions:["setActiveIndex","invokeOnChangeStart","setPointerValue","focusActiveThumb"]},ARROW_LEFT:{guard:"isHorizontal",actions:"decrementAtIndex"},ARROW_RIGHT:{guard:"isHorizontal",actions:"incrementAtIndex"},ARROW_UP:{guard:"isVertical",actions:"incrementAtIndex"},ARROW_DOWN:{guard:"isVertical",actions:"decrementAtIndex"},PAGE_UP:{actions:"incrementAtIndex"},PAGE_DOWN:{actions:"decrementAtIndex"},HOME:{actions:"setActiveThumbToMin"},END:{actions:"setActiveThumbToMax"},BLUR:{target:"idle",actions:"clearActiveIndex"}}},dragging:{entry:"focusActiveThumb",activities:"trackPointerMove",on:{POINTER_UP:{target:"focus",actions:"invokeOnChangeEnd"},POINTER_MOVE:{actions:"setPointerValue"}}}}},{guards:{isHorizontal:e=>e.isHorizontal,isVertical:e=>e.isVertical},activities:{trackScriptedUpdate(e,t,{send:n}){let r=[];return M(()=>{for(let o=0;o<e.value.length;o++){let a=l.getInputEl(e,o);if(!a)return;r.push(ue(a,{type:"input",property:"value",fn(s){n({type:"SET_VALUE",value:parseFloat(s),index:o})}}))}}),()=>r.forEach(o=>o==null?void 0:o())},trackFormReset(e){let t=[];return M(()=>{for(let n=0;n<e.value.length;n++){let r=l.getInputEl(e,n);t.push(se(r,()=>{e.initialValue[n]!=null&&(e.value[n]=e.initialValue[n])}))}}),()=>t.forEach(n=>n==null?void 0:n())},trackPointerMove(e,t,{send:n}){return fe({ctx:e,onPointerMove(r){n({type:"POINTER_MOVE",point:r.point})},onPointerUp(){n("POINTER_UP")}})}},actions:{setupDocument(e,t){t.doc&&(e.doc=(0,z.ref)(t.doc)),e.uid=t.id},invokeOnChangeStart(e){var t;(t=e.onChangeStart)==null||t.call(e,e.value)},invokeOnChangeEnd(e){var t;(t=e.onChangeEnd)==null||t.call(e,e.value)},invokeOnChange(e,t){var n;t.type!=="SETUP"&&((n=e.onChange)==null||n.call(e,e.value))},dispatchChangeEvent(e,t){t.type!=="SETUP"&&l.dispatchChangeEvent(e)},setThumbSize(e){ne(()=>{let t=l.getElements(e);e.thumbSize=t.map(n=>{let{width:r,height:o}=H(n);return{width:r,height:o}})})},setActiveIndex(e,t){var n;e.activeIndex=(n=t.index)!=null?n:ke(e,t)},clearActiveIndex(e){e.activeIndex=-1},setPointerValue(e,t){let n=l.getValueFromPoint(e,t.point);n!=null&&(e.value[e.activeIndex]=m.convert(e,n,e.activeIndex))},focusActiveThumb(e){M(()=>{let t=l.getThumbEl(e,e.activeIndex);t==null||t.focus()})},decrementAtIndex(e,t){e.value[e.activeIndex]=m.decrement(e,t.index,t.step)},incrementAtIndex(e,t){e.value[e.activeIndex]=m.increment(e,t.index,t.step)},setActiveThumbToMin(e){let{min:t}=m.getRangeAtIndex(e);e.value[e.activeIndex]=t},setActiveThumbToMax(e){let{max:t}=m.getRangeAtIndex(e);e.value[e.activeIndex]=t},checkValue(e){let t=m.check(e,e.value);Object.assign(e,{value:t,initialValue:t.slice()})},setValue(e,t){if(K(t.index)&&K(t.value)){e.value[t.index]=m.convert(e,t.value,t.index);return}Array.isArray(t.value)&&(e.value=m.check(e,t.value))}}});module.exports=He(Rt); | ||
var R=Object.defineProperty,Re=Object.defineProperties,Oe=Object.getOwnPropertyDescriptor,Ve=Object.getOwnPropertyDescriptors,Ne=Object.getOwnPropertyNames,J=Object.getOwnPropertySymbols;var Q=Object.prototype.hasOwnProperty,De=Object.prototype.propertyIsEnumerable;var ee=(e,t,n)=>t in e?R(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,O=(e,t)=>{for(var n in t||(t={}))Q.call(t,n)&&ee(e,n,t[n]);if(J)for(var n of J(t))De.call(t,n)&&ee(e,n,t[n]);return e},V=(e,t)=>Re(e,Ve(t)),Fe=e=>R(e,"__esModule",{value:!0});var _e=(e,t)=>{for(var n in t)R(e,n,{get:t[n],enumerable:!0})},We=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ne(t))!Q.call(e,o)&&(n||o!=="default")&&R(e,o,{get:()=>t[o],enumerable:!(r=Oe(t,o))||r.enumerable});return e};var He=(e=>(t,n)=>e&&e.get(t)||(n=We(Fe({}),t,1),e&&e.set(t,n),n))(typeof WeakMap!="undefined"?new WeakMap:0);var Rt={};_e(Rt,{connect:()=>Se,machine:()=>Me});var te=Math.pow,v=e=>e?"":void 0;function M(e){let t=new Set;function n(r){let o=globalThis.requestAnimationFrame(r);t.add(()=>globalThis.cancelAnimationFrame(o))}return n(()=>n(e)),function(){t.forEach(function(r){r()})}}function ne(e){let t=globalThis.requestAnimationFrame(e);return function(){globalThis.cancelAnimationFrame(t)}}var ze=()=>{},Ue=(...e)=>t=>e.reduce((n,r)=>r(n),t),Vt=(()=>{let e=0;return()=>(e++,e.toString(36))})(),U=e=>je()&&e.test(navigator.platform),je=()=>typeof window!="undefined",$e=()=>U(/^Mac/),Be=()=>U(/^iPhone/),Ye=()=>U(/^iPad/)||$e()&&navigator.maxTouchPoints>1,re=()=>Be()||Ye(),Xe=e=>Array.isArray(e),qe=e=>!(e==null||typeof e!="object"||Xe(e)),Ke=e=>qe(e)&&"button"in e,Ge=e=>e.button===0,E=new Map,h=new Map;function Ze(e,t,n,r){var o;if(!e)return ze;let a=JSON.stringify({type:t,options:r}),s=E.get(e);if(E.has(e))(s==null?void 0:s.has(a))?(o=s==null?void 0:s.get(a))==null||o.add(n):s==null||s.set(a,new Set([n]));else{let u=new Map([[a,new Set([n])]]);E.set(e,u)}function g(u){var p,i;function c(d){var f;let w=E.get(u);(f=w==null?void 0:w.get(a))==null||f.forEach(b=>b(d))}if(!(h==null?void 0:h.has(u))){h.set(u,new Map([[a,c]])),u.addEventListener(t,c,r);return}((p=h==null?void 0:h.get(u))==null?void 0:p.has(a))||((i=h.get(u))==null||i.set(a,c),u.addEventListener(t,c,r))}return g(e),function(){var u,p,i,c;if(!E.has(e))return;let d=E.get(e);if((u=d==null?void 0:d.get(a))==null||u.delete(n),((p=d==null?void 0:d.get(a))==null?void 0:p.size)===0){let f=(i=h.get(e))==null?void 0:i.get(a);e.removeEventListener(t,f,r),d==null||d.delete(a),(c=h.get(e))==null||c.delete(a),(d==null?void 0:d.size)===0&&(E.delete(e),h.delete(e))}}}var j=e=>Object.prototype.toString.call(e).slice(8,-1),Je=e=>j(e)==="Object"&&"current"in e,Qe=e=>j(e)==="Function"?e():e,et=e=>j(e)==="Object"&&!!e.touches,tt={pageX:0,pageY:0,clientX:0,clientY:0};function nt(e,t="page"){let n=et(e)?e.touches[0]||e.changedTouches[0]||tt:e;return{point:{x:n[`${t}X`],y:n[`${t}Y`]}}}function rt(e,t,n,r){let o=Je(e)?e.current:Qe(e);return Ze(o,t,n,r)}function N(e,t,n,r){var o;let a=(o=dt(t))!=null?o:t;return rt(e,a,ot(n,t==="pointerdown"),r)}function ot(e,t=!1){let n=r=>{e(r,nt(r))};return t?it(n):n}function it(e){return t=>{var n;let r=(n=t.view)!=null?n:window,o=t instanceof r.MouseEvent;(!o||o&&t.button===0)&&e(t)}}var at=()=>typeof window!="undefined"&&window.onpointerdown===null,lt=()=>typeof window!="undefined"&&window.ontouchstart===null,ut=()=>typeof window!="undefined"&&window.onmousedown===null,st={pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointercancel:"mousecancel",pointerover:"mouseover",pointerout:"mouseout",pointerenter:"mouseenter",pointerleave:"mouseleave"},ct={pointerdown:"touchstart",pointermove:"touchmove",pointerup:"touchend",pointercancel:"touchcancel"};function dt(e){return at()?e:lt()?ct[e]:ut()?st[e]:e}function oe(e){var t;return(t=e==null?void 0:e.ownerDocument.defaultView)!=null?t:window}function ie(e){var t;return(t=e.nativeEvent)!=null?t:e}function ae(e,t){var n;let{type:r,property:o}=t,a=oe(e)[r==="input"?"HTMLInputElement":"HTMLTextAreaElement"].prototype;return(n=Object.getOwnPropertyDescriptor(a,o))!=null?n:{}}function le(e,t){var n;let r=oe(e);if(!(e instanceof r.HTMLInputElement))return;(n=ae(e,{type:"input",property:"value"}).set)==null||n.call(e,t);let o=new r.Event("input",{bubbles:!0});e.dispatchEvent(o)}function ue(e,t){let{fn:n,property:r,type:o}=t;if(!n||!e)return;let{get:a,set:s}=ae(e,{property:r,type:o}),g=!0;return Object.defineProperty(e,r,{get(){return a==null?void 0:a.call(this)},set(u){return g&&n(u),s==null?void 0:s.call(this,u)}}),function(){g=!1}}var Nt=["input:not([disabled]):not([type=hidden])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","embed","iframe","object","a[href]","area[href]","[tabindex]","audio[controls]","video[controls]","*[tabindex]:not([aria-disabled])","[contenteditable]:not([contenteditable=false])","details > summary:first-of-type"].join(",");function mt(e){return pt(e)?e.form:e.closest("form")}function pt(e){return["textarea","input","select","button"].includes(e.localName)}function se(e,t){if(!e)return;let n=mt(e);return n==null||n.addEventListener("reset",t,{passive:!0}),()=>{n==null||n.removeEventListener("reset",t)}}var ce={ArrowLeft:"ArrowRight",ArrowRight:"ArrowLeft",Home:"End",End:"Home"},ft={Up:"ArrowUp",Down:"ArrowDown",Esc:"Escape"," ":"Space",",":"Comma",Left:"ArrowLeft",Right:"ArrowRight"};function de(e,t={}){var n;let{dir:r="ltr",orientation:o="horizontal"}=t,{key:a}=e;return a=(n=ft[a])!=null?n:a,r==="rtl"&&o==="horizontal"&&a in ce&&(a=ce[a]),a}var gt=new Set(["PageUp","PageDown"]),vt=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]);function me(e){return e.ctrlKey||e.metaKey?.1:gt.has(e.key)||e.shiftKey&&vt.has(e.key)?10:1}function pe(e,t){var n;return Array.from((n=e==null?void 0:e.querySelectorAll(t))!=null?n:[])}var A="default",$="",D=new WeakMap;function ht({target:e,doc:t}={}){let n=t!=null?t:document;return re()?(A==="default"&&($=n.documentElement.style.webkitUserSelect,n.documentElement.style.webkitUserSelect="none"),A="disabled"):e&&(D.set(e,e.style.userSelect),e.style.userSelect="none"),()=>yt({target:e,doc:n})}function yt({target:e,doc:t}={}){let n=t!=null?t:document;if(re()){if(A!=="disabled")return;A="restoring",setTimeout(()=>{M(()=>{A==="restoring"&&(n.documentElement.style.webkitUserSelect==="none"&&(n.documentElement.style.webkitUserSelect=$||""),$="",A="default")})},300)}else if(e&&D.has(e)){let r=D.get(e);e.style.userSelect==="none"&&(e.style.userSelect=r!=null?r:""),e.getAttribute("style")===""&&e.removeAttribute("style"),D.delete(e)}}function fe(e){let{onPointerMove:t,onPointerUp:n,ctx:r}=e,{doc:o=document,threshold:a=5}=r;return Ue(N(o,"pointermove",(s,g)=>{let{point:u}=g;if(!(Math.sqrt(te(u.x,2)+te(u.y,2))<a)){if(Ke(s)&&Ge(s)){n();return}t(g,s)}},!1),N(o,"pointerup",n,!1),N(o,"pointercancel",n,!1),N(o,"contextmenu",n,!1),ht({doc:o}))}var bt=Math.pow;var ge=new Intl.NumberFormat("en-US",{style:"decimal"});function B(e){return parseFloat(ge.format(e))}function xt(e,t){let n=x(e),r=bt(10,t!=null?t:10);return n=Math.round(n*r)/r,t?n.toFixed(t):e.toString()}var Y=(e,t)=>(x(e)-t.min)*100/(t.max-t.min),T=(e,t)=>t.min+(t.max-t.min)*x(e);function I(e,t){return Math.min(Math.max(x(e),t.min),t.max)}function wt(e){var t,n;return(n=(t=ge.formatToParts(e).find(r=>r.type==="fraction"))==null?void 0:t.value.length)!=null?n:0}var ve=(e,t)=>B(x(e)+t),he=(e,t)=>B(x(e)-t),F=(e,t)=>B(x(e)*t);function X(e,t){let n=x(e),r=wt(t),o=Math.round(n/t)*t;return xt(o,r)}function x(e){if(typeof e=="number")return e;let t=parseFloat(e.toString().replace(/[^\w.-]+/g,""));return Number.isNaN(t)?0:t}function _(e){var t;let n=(t=e.spacing)!=null?t:0;return e.value.map((r,o)=>{let a=o===0?e.min:e.value[o-1]+n,s=o===e.value.length-1?e.max:e.value[o+1]-n;return{min:a,max:s,value:r}})}var y=(e,t)=>({x:e,y:t}),W=class{constructor(e){this.v=e}static create(e){return new W(e)}set(e){return new W(Object.assign({},this.v,e))}clone(){return new W(this.v)}get x(){return this.v.x}get y(){return this.v.y}get width(){return this.v.width}get height(){return this.v.height}get minX(){return this.v.x}get midX(){return this.v.x+this.v.width/2}get maxX(){return this.v.x+this.v.width}get minY(){return this.v.y}get midY(){return this.v.y+this.v.height/2}get maxY(){return this.v.y+this.v.height}get center(){return y(this.midX,this.midY)}get centers(){let e=y(this.midX,this.minY),t=y(this.maxX,this.midY),n=y(this.midX,this.maxY),r=y(this.minX,this.midY);return{top:e,right:t,bottom:n,left:r}}get corners(){let e=y(this.minX,this.minY),t=y(this.maxX,this.minY),n=y(this.maxX,this.maxY),r=y(this.minX,this.maxY);return{top:e,right:t,bottom:n,left:r}}get edges(){let e=this.corners,t=[e.top,e.right],n=[e.right,e.bottom],r=[e.left,e.bottom],o=[e.top,e.left];return{top:t,right:n,bottom:r,left:o}}},ye=new WeakMap;function Et(e){var t;if(!e)return{};let n=ye.get(e);return n||(n=((t=e==null?void 0:e.ownerDocument.defaultView)!=null?t:window).getComputedStyle(e),ye.set(e,n)),n}function H(e,t={}){return W.create(Tt(e,t))}function Tt(e,t={}){let{excludeScrollbar:n=!1,excludeBorders:r=!1}=t,{x:o,y:a,width:s,height:g}=e.getBoundingClientRect(),u={x:o,y:a,width:s,height:g},p=Et(e),{borderLeftWidth:i,borderTopWidth:c,borderRightWidth:d,borderBottomWidth:f}=p,w=be(i,d),b=be(c,f);if(r&&(u.width-=w,u.height-=b,u.x+=q(i),u.y+=q(c)),n){let C=e.offsetWidth-e.clientWidth-w,L=e.offsetHeight-e.clientHeight-b;u.width-=C,u.height-=L}return u}var q=e=>parseFloat(e.replace("px","")),be=(...e)=>e.reduce((t,n)=>t+(n?q(n):0),0),_t=(()=>{let e=0;return()=>(e++,e.toString(36))})(),Pt=e=>Array.isArray(e),At=e=>!(e==null||typeof e!="object"||Pt(e)),It=e=>At(e)&&"touches"in e;function kt(e,t={x:0,y:0}){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function xe(...e){return t=>{let n=e.map(o=>kt(o,t)),r=Math.min.apply(Math,n);return e[n.indexOf(r)]}}var St={pageX:0,pageY:0,clientX:0,clientY:0};function we(e,t="page"){let n=It(e)?e.touches[0]||e.changedTouches[0]||St:e;return{x:n[`${t}X`],y:n[`${t}Y`]}}function Ee(e,t){let n=e.x-t.offsetLeft-t.clientLeft+t.scrollLeft,r=e.y-t.offsetTop-t.clientTop+t.scrollTop;return{point:{x:n,y:r},progress:{x:n/t.offsetWidth,y:r/t.offsetHeight}}}function Mt(e){return{button:e,label:e,input:e,output:e,element:e}}var Te=Mt(e=>e);var zt=(()=>{let e=0;return()=>(e++,e.toString(36))})();var K=e=>typeof e=="number"&&!Number.isNaN(e);var Pe=e=>e.button===0;var Ae=e=>e.ctrlKey||e.altKey||e.metaKey||e.shiftKey;var G=require("@zag-js/slider");var m={check(e,t){return t.map((n,r)=>m.convert(e,n,r))},clampPercent(e){return I(e,{min:0,max:1})},getRangeAtIndex(e,t=e.activeIndex){return _(e)[t]},fromPercent(e,t){let n=m.getRangeAtIndex(e),r=n.max/e.max,o=n.min/e.max;t=I(t,{min:o,max:r});let a=T(t,e);return parseFloat(X(a,e.step))},convert(e,t,n){let r=m.getRangeAtIndex(e,n);return I(X(t,e.step),r)},decrement(e,t,n){let r=t!=null?t:e.activeIndex,o=m.getRangeAtIndex(e,r),a=he(o.value,n!=null?n:e.step);return m.convert(e,a,r)},increment(e,t,n){let r=t!=null?t:e.activeIndex,o=m.getRangeAtIndex(e,r),a=ve(o.value,n!=null?n:e.step);return m.convert(e,a,r)}};function Ie(e,t){let{progress:n}=Ee(t,l.getControlEl(e)),r;return e.isHorizontal?r=e.isRtl?1-n.x:n.x:r=1-n.y,m.clampPercent(r)}function Ct(e,t){if(e.activeIndex===-1)return;let n=Ie(e,t);return m.fromPercent(e,n)}function Lt(e){let{orientation:t,value:n,max:r}=e,o=n[0]/r*100,a=100-n[n.length-1]/r*100,s={position:"absolute","--slider-range-start":`${o}%`,"--slider-range-end":`${a}%`};return t==="vertical"?V(O({},s),{bottom:"var(--slider-range-start)",top:"var(--slider-range-end)"}):V(O({},s),{[e.isRtl?"right":"left"]:"var(--slider-range-start)",[e.isRtl?"left":"right"]:"var(--slider-range-end)"})}var l={getDoc:e=>{var t;return(t=e.doc)!=null?t:document},getRootId:e=>`slider-${e.uid}`,getThumbId:(e,t)=>`slider-thumb-${e.uid}-${t}`,getInputId:(e,t)=>`slider-input-${e.uid}-${t}`,getControlId:e=>`slider-${e.uid}-root`,getTrackId:e=>`slider-${e.uid}-track`,getRangeId:e=>`slider-${e.uid}-range`,getLabelId:e=>`slider-${e.uid}-label`,getOutputId:e=>`slider-${e.uid}-output`,getMarkerId:(e,t)=>`slider-marker-${e.uid}-${t}`,getThumbEl:(e,t)=>l.getDoc(e).getElementById(l.getThumbId(e,t)),getInputEl:(e,t)=>l.getDoc(e).getElementById(l.getInputId(e,t)),getControlEl:e=>l.getDoc(e).getElementById(l.getControlId(e)),getElements:e=>pe(l.getControlEl(e),"[role=slider]"),getFirstEl:e=>l.getElements(e)[0],getRangeEl:e=>{var t;return(t=l.getDoc(e))==null?void 0:t.getElementById(l.getRangeId(e))},getValueFromPoint:Ct,dispatchChangeEvent(e){Array.from(e.value).forEach((n,r)=>{let o=l.getInputEl(e,r);!o||le(o,n)})},getControlStyle:G.unstable__dom.getControlStyle,getThumbStyle(e,t){var o,a;let n=e.value[t],r=(a=(o=e.thumbSize)==null?void 0:o[t])!=null?a:{width:0,height:0};return G.unstable__dom.getThumbStyle(V(O({},e),{value:n,thumbSize:r}))},getRangeStyle:Lt,getMarkerStyle(e,t){let n={position:"absolute",pointerEvents:"none"};return e.isHorizontal?(t=e.isRtl?100-t:t,n.left=`${t}%`):n.bottom=`${t}%`,n}};function ke(e,t){let n,o=l.getElements(e).map(d=>H(d)).map(d=>d.center),s=xe(...o)(t.point);if(n=o.indexOf(s),!l.getControlEl(e))return n;let u=Ie(e,t.point),p=T(u,e),i=e.isHorizontal?o.map(d=>d.x):o.map(d=>d.y);return new Set(i).size!==o.length&&p>e.value[n]&&(n=I(n+1,{min:0,max:e.value.length-1})),n}function Se(e,t,n=Te){let r=e.context["aria-label"],o=e.context["aria-labelledby"],a=e.context.value,s=e.matches("focus"),g=e.matches("dragging"),u=e.context.disabled,p=e.context.isInteractive;return{values:e.context.value,isDragging:g,isFocused:s,setValue(i){t({type:"SET_VALUE",value:i})},getThumbValue(i){return a[i]},setThumbValue(i,c){t({type:"SET_VALUE",index:i,value:c})},getThumbPercent(i){return Y(a[i],e.context)},setThumbPercent(i,c){let d=T(c,e.context);t({type:"SET_VALUE",index:i,value:d})},getPercentValue(i){return T(i,e.context)},getThumbMin(i){return m.getRangeAtIndex(e.context,i).min},getThumbMax(i){return m.getRangeAtIndex(e.context,i).max},increment(i){t({type:"INCREMENT",index:i})},decrement(i){t({type:"DECREMENT",index:i})},focus(i=0){!p||t({type:"FOCUS",index:i})},labelProps:n.label({"data-part":"label",id:l.getLabelId(e.context),htmlFor:l.getInputId(e.context,0),onClick(i){var c;!p||(i.preventDefault(),(c=l.getFirstEl(e.context))==null||c.focus())},style:{userSelect:"none"}}),rootProps:n.element({"data-part":"root","data-disabled":v(u),"data-orientation":e.context.orientation,id:l.getRootId(e.context),dir:e.context.dir}),outputProps:n.output({"data-part":"output",id:l.getOutputId(e.context),htmlFor:a.map((i,c)=>l.getInputId(e.context,c)).join(" "),"aria-live":"off"}),trackProps:n.element({"data-part":"track",id:l.getTrackId(e.context),"data-disabled":v(u),"data-orientation":e.context.orientation,"data-focus":v(s),style:{position:"relative"}}),getThumbProps(i){var C,L;let c=a[i],d=_(e.context)[i],f=(L=(C=e.context).getAriaValueText)==null?void 0:L.call(C,c,i),w=Array.isArray(r)?r[i]:r,b=Array.isArray(o)?o[i]:o;return n.element({"data-part":"thumb","data-index":i,id:l.getThumbId(e.context,i),"data-disabled":v(u),"data-orientation":e.context.orientation,"data-focus":v(s&&e.context.activeIndex===i),draggable:!1,"aria-disabled":u||void 0,"aria-label":w,"aria-labelledby":b!=null?b:l.getLabelId(e.context),"aria-orientation":e.context.orientation,"aria-valuemax":d.max,"aria-valuemin":d.min,"aria-valuenow":a[i],"aria-valuetext":f,role:"slider",tabIndex:u?void 0:0,style:l.getThumbStyle(e.context,i),onBlur(){!p||t("BLUR")},onFocus(){!p||t({type:"FOCUS",index:i})},onKeyDown(k){if(!p)return;let P=F(me(k),e.context.step),S=!0,Ce={ArrowUp(){t({type:"ARROW_UP",step:P}),S=e.context.isVertical},ArrowDown(){t({type:"ARROW_DOWN",step:P}),S=e.context.isVertical},ArrowLeft(){t({type:"ARROW_LEFT",step:P}),S=e.context.isHorizontal},ArrowRight(){t({type:"ARROW_RIGHT",step:P}),S=e.context.isHorizontal},PageUp(){t({type:"PAGE_UP",step:P})},PageDown(){t({type:"PAGE_DOWN",step:P})},Home(){t("HOME")},End(){t("END")}},Le=de(k,e.context),Z=Ce[Le];!Z||(Z(k),S&&(k.preventDefault(),k.stopPropagation()))}})},getInputProps(i){return n.input({"data-part":"input",name:`${e.context.name}[${i}]`,type:"text",hidden:!0,defaultValue:e.context.value[i],id:l.getInputId(e.context,i)})},rangeProps:n.element({id:l.getRangeId(e.context),"data-part":"range","data-disabled":v(u),"data-orientation":e.context.orientation,style:l.getRangeStyle(e.context)}),controlProps:n.element({"data-part":"control",id:l.getControlId(e.context),"data-disabled":v(u),"data-orientation":e.context.orientation,"data-focus":v(s),style:l.getControlStyle(e.context),onPointerDown(i){if(!p)return;let c=ie(i);!Pe(c)||Ae(c)||(t({type:"POINTER_DOWN",point:we(c)}),i.preventDefault(),i.stopPropagation())}}),markerGroupProps:n.element({"data-part":"marker-group",role:"presentation","aria-hidden":!0,"data-orientation":e.context.orientation,style:{userSelect:"none",pointerEvents:"none",position:"relative"}}),getMarkerProps({value:i}){let c=Y(i,e.context),d=l.getMarkerStyle(e.context,c),f;return Math.max(...e.context.value)<i?f="over-value":Math.min(...e.context.value)>i?f="under-value":f="at-value",n.element({"data-part":"marker",id:l.getMarkerId(e.context,i),role:"presentation","data-value":i,"aria-hidden":!0,"data-disabled":v(u),"data-state":f,style:d})}}}var z=require("@zag-js/core");var Me=(0,z.createMachine)({id:"range-slider",initial:"unknown",context:{thumbSize:null,uid:"48",threshold:5,activeIndex:-1,min:0,max:100,step:1,value:[0,100],initialValue:[],orientation:"horizontal",dir:"ltr",minStepsBetweenThumbs:0},computed:{isHorizontal:e=>e.orientation==="horizontal",isVertical:e=>e.orientation==="vertical",isRtl:e=>e.orientation==="horizontal"&&e.dir==="rtl",isInteractive:e=>!(e.readonly||e.disabled),spacing:e=>F(e.minStepsBetweenThumbs,e.step),hasMeasuredThumbSize:e=>e.thumbSize!=null},watch:{value:["invokeOnChange","dispatchChangeEvent"]},activities:["trackFormReset","trackScriptedUpdate"],on:{SET_VALUE:{actions:"setValue"},INCREMENT:{actions:"incrementAtIndex"},DECREMENT:{actions:"decrementAtIndex"}},states:{unknown:{on:{SETUP:{target:"idle",actions:["setupDocument","setThumbSize","checkValue"]}}},idle:{on:{POINTER_DOWN:{target:"dragging",actions:["setActiveIndex","invokeOnChangeStart","setPointerValue","focusActiveThumb"]},FOCUS:{target:"focus",actions:"setActiveIndex"}}},focus:{entry:"focusActiveThumb",on:{POINTER_DOWN:{target:"dragging",actions:["setActiveIndex","invokeOnChangeStart","setPointerValue","focusActiveThumb"]},ARROW_LEFT:{guard:"isHorizontal",actions:"decrementAtIndex"},ARROW_RIGHT:{guard:"isHorizontal",actions:"incrementAtIndex"},ARROW_UP:{guard:"isVertical",actions:"incrementAtIndex"},ARROW_DOWN:{guard:"isVertical",actions:"decrementAtIndex"},PAGE_UP:{actions:"incrementAtIndex"},PAGE_DOWN:{actions:"decrementAtIndex"},HOME:{actions:"setActiveThumbToMin"},END:{actions:"setActiveThumbToMax"},BLUR:{target:"idle",actions:"clearActiveIndex"}}},dragging:{entry:"focusActiveThumb",activities:"trackPointerMove",on:{POINTER_UP:{target:"focus",actions:"invokeOnChangeEnd"},POINTER_MOVE:{actions:"setPointerValue"}}}}},{guards:{isHorizontal:e=>e.isHorizontal,isVertical:e=>e.isVertical},activities:{trackScriptedUpdate(e,t,{send:n}){let r=[];return M(()=>{for(let o=0;o<e.value.length;o++){let a=l.getInputEl(e,o);if(!a)return;r.push(ue(a,{type:"input",property:"value",fn(s){n({type:"SET_VALUE",value:parseFloat(s),index:o})}}))}}),()=>r.forEach(o=>o==null?void 0:o())},trackFormReset(e){let t=[];return M(()=>{for(let n=0;n<e.value.length;n++){let r=l.getInputEl(e,n);t.push(se(r,()=>{e.initialValue[n]!=null&&(e.value[n]=e.initialValue[n])}))}}),()=>t.forEach(n=>n==null?void 0:n())},trackPointerMove(e,t,{send:n}){return fe({ctx:e,onPointerMove(r){n({type:"POINTER_MOVE",point:r.point})},onPointerUp(){n("POINTER_UP")}})}},actions:{setupDocument(e,t){t.doc&&(e.doc=(0,z.ref)(t.doc)),e.uid=t.id},invokeOnChangeStart(e){var t;(t=e.onChangeStart)==null||t.call(e,{value:e.value})},invokeOnChangeEnd(e){var t;(t=e.onChangeEnd)==null||t.call(e,{value:e.value})},invokeOnChange(e,t){var n;t.type!=="SETUP"&&((n=e.onChange)==null||n.call(e,{value:e.value}))},dispatchChangeEvent(e,t){t.type!=="SETUP"&&l.dispatchChangeEvent(e)},setThumbSize(e){ne(()=>{let t=l.getElements(e);e.thumbSize=t.map(n=>{let{width:r,height:o}=H(n);return{width:r,height:o}})})},setActiveIndex(e,t){var n;e.activeIndex=(n=t.index)!=null?n:ke(e,t)},clearActiveIndex(e){e.activeIndex=-1},setPointerValue(e,t){let n=l.getValueFromPoint(e,t.point);n!=null&&(e.value[e.activeIndex]=m.convert(e,n,e.activeIndex))},focusActiveThumb(e){M(()=>{let t=l.getThumbEl(e,e.activeIndex);t==null||t.focus()})},decrementAtIndex(e,t){e.value[e.activeIndex]=m.decrement(e,t.index,t.step)},incrementAtIndex(e,t){e.value[e.activeIndex]=m.increment(e,t.index,t.step)},setActiveThumbToMin(e){let{min:t}=m.getRangeAtIndex(e);e.value[e.activeIndex]=t},setActiveThumbToMax(e){let{max:t}=m.getRangeAtIndex(e);e.value[e.activeIndex]=t},checkValue(e){let t=m.check(e,e.value);Object.assign(e,{value:t,initialValue:t.slice()})},setValue(e,t){if(K(t.index)&&K(t.value)){e.value[t.index]=m.convert(e,t.value,t.index);return}Array.isArray(t.value)&&(e.value=m.check(e,t.value))}}});module.exports=He(Rt); | ||
//# sourceMappingURL=index.js.map |
@@ -60,11 +60,17 @@ import type { StateMachine as S } from "@zag-js/core"; | ||
*/ | ||
onChange?(value: number[]): void; | ||
onChange?(details: { | ||
value: number[]; | ||
}): void; | ||
/** | ||
* Function invoked when the slider value change is started | ||
*/ | ||
onChangeStart?(value: number[]): void; | ||
onChangeStart?(details: { | ||
value: number[]; | ||
}): void; | ||
/** | ||
* Function invoked when the slider value change is done | ||
*/ | ||
onChangeEnd?(value: number[]): void; | ||
onChangeEnd?(details: { | ||
value: number[]; | ||
}): void; | ||
/** | ||
@@ -71,0 +77,0 @@ * Function that returns a human readable value for the slider thumb |
{ | ||
"name": "@zag-js/range-slider", | ||
"version": "0.0.0-dev-20220408111010", | ||
"version": "0.0.0-dev-20220408120729", | ||
"description": "Core logic for the range-slider widget implemented as a state machine", | ||
@@ -32,10 +32,10 @@ "keywords": [ | ||
"dependencies": { | ||
"@zag-js/core": "^0.0.0-dev-20220408111010", | ||
"@zag-js/dom-utils": "^0.0.0-dev-20220408111010", | ||
"@zag-js/number-utils": "^0.0.0-dev-20220408111010", | ||
"@zag-js/rect-utils": "^0.0.0-dev-20220408111010", | ||
"@zag-js/slider": "^0.0.0-dev-20220408111010", | ||
"@zag-js/types": "^0.0.0-dev-20220408111010", | ||
"@zag-js/utils": "^0.0.0-dev-20220408111010" | ||
"@zag-js/core": "^0.0.0-dev-20220408120729", | ||
"@zag-js/dom-utils": "^0.0.0-dev-20220408120729", | ||
"@zag-js/number-utils": "^0.0.0-dev-20220408120729", | ||
"@zag-js/rect-utils": "^0.0.0-dev-20220408120729", | ||
"@zag-js/slider": "^0.0.0-dev-20220408120729", | ||
"@zag-js/types": "^0.0.0-dev-20220408120729", | ||
"@zag-js/utils": "^0.0.0-dev-20220408120729" | ||
} | ||
} |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
294133
365