UNPKG

potentio

Version:

Unstyled & accessible knob primitive for React and Vue

34 lines (30 loc) 21.4 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("react"),Er=require("@use-gesture/react"),wr=require("merge-props"),g=require("vue");function I(o,t,l){return Math.max(t,Math.min(l,o))}function _r(o){return I(o,0,1)}function Tr(o,t,l){return(o-t)/(l-t)}function Pr(o,t,l){return o*(l-t)+t}function ie({valueRaw:o,valueMin:t,valueMax:l,dragSensitivity:v,deltaX:c,deltaY:p,mapTo01:b,mapFrom01:w}){let a=0;a+=c*v,a+=p*-v;const y=b(o,t,l),h=_r(y+a);return I(w(h,t,l),t,l)}function ue({valueRaw:o,valueMin:t,valueMax:l,step:v,stepLarger:c,keyCode:p}){switch(p){case"ArrowUp":case"ArrowRight":return I(o+v,t,l);case"ArrowDown":case"ArrowLeft":return I(o-v,t,l);case"PageUp":return I(o+c,t,l);case"PageDown":return I(o-c,t,l);case"Home":return t;case"End":return l;default:return null}}function le(o,t){return o?o==="horizontal"?"x":"y":t==="xy"?void 0:t}function se(o,t){if(o)return o;if(t!=="xy")return t==="x"?"horizontal":"vertical"}const T={axis:"y",includeIntoTabOrder:!1,mapTo01:Tr,mapFrom01:Pr};var oe={exports:{}},M={};/** * @license React * react-jsx-runtime.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var Le;function Or(){if(Le)return M;Le=1;var o=B,t=Symbol.for("react.element"),l=Symbol.for("react.fragment"),v=Object.prototype.hasOwnProperty,c=o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,p={key:!0,ref:!0,__self:!0,__source:!0};function b(w,a,y){var h,C={},P=null,j=null;y!==void 0&&(P=""+y),a.key!==void 0&&(P=""+a.key),a.ref!==void 0&&(j=a.ref);for(h in a)v.call(a,h)&&!p.hasOwnProperty(h)&&(C[h]=a[h]);if(w&&w.defaultProps)for(h in a=w.defaultProps,a)C[h]===void 0&&(C[h]=a[h]);return{$$typeof:t,type:w,key:P,ref:j,props:C,_owner:c.current}}return M.Fragment=l,M.jsx=b,M.jsxs=b,M}var N={};/** * @license React * react-jsx-runtime.development.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var Ke;function Cr(){return Ke||(Ke=1,process.env.NODE_ENV!=="production"&&function(){var o=B,t=Symbol.for("react.element"),l=Symbol.for("react.portal"),v=Symbol.for("react.fragment"),c=Symbol.for("react.strict_mode"),p=Symbol.for("react.profiler"),b=Symbol.for("react.provider"),w=Symbol.for("react.context"),a=Symbol.for("react.forward_ref"),y=Symbol.for("react.suspense"),h=Symbol.for("react.suspense_list"),C=Symbol.for("react.memo"),P=Symbol.for("react.lazy"),j=Symbol.for("react.offscreen"),i=Symbol.iterator,_="@@iterator";function K(e){if(e===null||typeof e!="object")return null;var r=i&&e[i]||e[_];return typeof r=="function"?r:null}var S=o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function O(e){{for(var r=arguments.length,n=new Array(r>1?r-1:0),u=1;u<r;u++)n[u-1]=arguments[u];Ye("error",e,n)}}function Ye(e,r,n){{var u=S.ReactDebugCurrentFrame,d=u.getStackAddendum();d!==""&&(r+="%s",n=n.concat([d]));var m=n.map(function(f){return String(f)});m.unshift("Warning: "+r),Function.prototype.apply.call(console[e],console,m)}}var We=!1,Ue=!1,Me=!1,Ne=!1,Be=!1,de;de=Symbol.for("react.module.reference");function He(e){return!!(typeof e=="string"||typeof e=="function"||e===v||e===p||Be||e===c||e===y||e===h||Ne||e===j||We||Ue||Me||typeof e=="object"&&e!==null&&(e.$$typeof===P||e.$$typeof===C||e.$$typeof===b||e.$$typeof===w||e.$$typeof===a||e.$$typeof===de||e.getModuleId!==void 0))}function qe(e,r,n){var u=e.displayName;if(u)return u;var d=r.displayName||r.name||"";return d!==""?n+"("+d+")":n}function ve(e){return e.displayName||"Context"}function F(e){if(e==null)return null;if(typeof e.tag=="number"&&O("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case v:return"Fragment";case l:return"Portal";case p:return"Profiler";case c:return"StrictMode";case y:return"Suspense";case h:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case w:var r=e;return ve(r)+".Consumer";case b:var n=e;return ve(n._context)+".Provider";case a:return qe(e,e.render,"ForwardRef");case C:var u=e.displayName||null;return u!==null?u:F(e.type)||"Memo";case P:{var d=e,m=d._payload,f=d._init;try{return F(f(m))}catch{return null}}}return null}var A=Object.assign,Y=0,pe,be,me,ye,ge,he,Re;function Ee(){}Ee.__reactDisabledLog=!0;function Xe(){{if(Y===0){pe=console.log,be=console.info,me=console.warn,ye=console.error,ge=console.group,he=console.groupCollapsed,Re=console.groupEnd;var e={configurable:!0,enumerable:!0,value:Ee,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}Y++}}function Je(){{if(Y--,Y===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:A({},e,{value:pe}),info:A({},e,{value:be}),warn:A({},e,{value:me}),error:A({},e,{value:ye}),group:A({},e,{value:ge}),groupCollapsed:A({},e,{value:he}),groupEnd:A({},e,{value:Re})})}Y<0&&O("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var z=S.ReactCurrentDispatcher,G;function H(e,r,n){{if(G===void 0)try{throw Error()}catch(d){var u=d.stack.trim().match(/\n( *(at )?)/);G=u&&u[1]||""}return` `+G+e}}var Z=!1,q;{var ze=typeof WeakMap=="function"?WeakMap:Map;q=new ze}function we(e,r){if(!e||Z)return"";{var n=q.get(e);if(n!==void 0)return n}var u;Z=!0;var d=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var m;m=z.current,z.current=null,Xe();try{if(r){var f=function(){throw Error()};if(Object.defineProperty(f.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(f,[])}catch(D){u=D}Reflect.construct(e,[],f)}else{try{f.call()}catch(D){u=D}e.call(f.prototype)}}else{try{throw Error()}catch(D){u=D}e()}}catch(D){if(D&&u&&typeof D.stack=="string"){for(var s=D.stack.split(` `),x=u.stack.split(` `),R=s.length-1,E=x.length-1;R>=1&&E>=0&&s[R]!==x[E];)E--;for(;R>=1&&E>=0;R--,E--)if(s[R]!==x[E]){if(R!==1||E!==1)do if(R--,E--,E<0||s[R]!==x[E]){var k=` `+s[R].replace(" at new "," at ");return e.displayName&&k.includes("<anonymous>")&&(k=k.replace("<anonymous>",e.displayName)),typeof e=="function"&&q.set(e,k),k}while(R>=1&&E>=0);break}}}finally{Z=!1,z.current=m,Je(),Error.prepareStackTrace=d}var $=e?e.displayName||e.name:"",L=$?H($):"";return typeof e=="function"&&q.set(e,L),L}function Ge(e,r,n){return we(e,!1)}function Ze(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function X(e,r,n){if(e==null)return"";if(typeof e=="function")return we(e,Ze(e));if(typeof e=="string")return H(e);switch(e){case y:return H("Suspense");case h:return H("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case a:return Ge(e.render);case C:return X(e.type,r,n);case P:{var u=e,d=u._payload,m=u._init;try{return X(m(d),r,n)}catch{}}}return""}var W=Object.prototype.hasOwnProperty,_e={},Te=S.ReactDebugCurrentFrame;function J(e){if(e){var r=e._owner,n=X(e.type,e._source,r?r.type:null);Te.setExtraStackFrame(n)}else Te.setExtraStackFrame(null)}function Qe(e,r,n,u,d){{var m=Function.call.bind(W);for(var f in e)if(m(e,f)){var s=void 0;try{if(typeof e[f]!="function"){var x=Error((u||"React class")+": "+n+" type `"+f+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[f]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw x.name="Invariant Violation",x}s=e[f](r,f,u,n,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(R){s=R}s&&!(s instanceof Error)&&(J(d),O("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",u||"React class",n,f,typeof s),J(null)),s instanceof Error&&!(s.message in _e)&&(_e[s.message]=!0,J(d),O("Failed %s type: %s",n,s.message),J(null))}}}var er=Array.isArray;function Q(e){return er(e)}function rr(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,n=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return n}}function tr(e){try{return Pe(e),!1}catch{return!0}}function Pe(e){return""+e}function Oe(e){if(tr(e))return O("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",rr(e)),Pe(e)}var U=S.ReactCurrentOwner,nr={key:!0,ref:!0,__self:!0,__source:!0},Ce,Se,ee;ee={};function ar(e){if(W.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function or(e){if(W.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function ir(e,r){if(typeof e.ref=="string"&&U.current&&r&&U.current.stateNode!==r){var n=F(U.current.type);ee[n]||(O('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',F(U.current.type),e.ref),ee[n]=!0)}}function ur(e,r){{var n=function(){Ce||(Ce=!0,O("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};n.isReactWarning=!0,Object.defineProperty(e,"key",{get:n,configurable:!0})}}function lr(e,r){{var n=function(){Se||(Se=!0,O("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};n.isReactWarning=!0,Object.defineProperty(e,"ref",{get:n,configurable:!0})}}var sr=function(e,r,n,u,d,m,f){var s={$$typeof:t,type:e,key:r,ref:n,props:f,_owner:m};return s._store={},Object.defineProperty(s._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(s,"_self",{configurable:!1,enumerable:!1,writable:!1,value:u}),Object.defineProperty(s,"_source",{configurable:!1,enumerable:!1,writable:!1,value:d}),Object.freeze&&(Object.freeze(s.props),Object.freeze(s)),s};function cr(e,r,n,u,d){{var m,f={},s=null,x=null;n!==void 0&&(Oe(n),s=""+n),or(r)&&(Oe(r.key),s=""+r.key),ar(r)&&(x=r.ref,ir(r,d));for(m in r)W.call(r,m)&&!nr.hasOwnProperty(m)&&(f[m]=r[m]);if(e&&e.defaultProps){var R=e.defaultProps;for(m in R)f[m]===void 0&&(f[m]=R[m])}if(s||x){var E=typeof e=="function"?e.displayName||e.name||"Unknown":e;s&&ur(f,E),x&&lr(f,E)}return sr(e,s,x,d,u,U.current,f)}}var re=S.ReactCurrentOwner,xe=S.ReactDebugCurrentFrame;function V(e){if(e){var r=e._owner,n=X(e.type,e._source,r?r.type:null);xe.setExtraStackFrame(n)}else xe.setExtraStackFrame(null)}var te;te=!1;function ne(e){return typeof e=="object"&&e!==null&&e.$$typeof===t}function De(){{if(re.current){var e=F(re.current.type);if(e)return` Check the render method of \``+e+"`."}return""}}function fr(e){{if(e!==void 0){var r=e.fileName.replace(/^.*[\\\/]/,""),n=e.lineNumber;return` Check your code at `+r+":"+n+"."}return""}}var ke={};function dr(e){{var r=De();if(!r){var n=typeof e=="string"?e:e.displayName||e.name;n&&(r=` Check the top-level render call using <`+n+">.")}return r}}function je(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var n=dr(r);if(ke[n])return;ke[n]=!0;var u="";e&&e._owner&&e._owner!==re.current&&(u=" It was passed a child from "+F(e._owner.type)+"."),V(e),O('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',n,u),V(null)}}function Fe(e,r){{if(typeof e!="object")return;if(Q(e))for(var n=0;n<e.length;n++){var u=e[n];ne(u)&&je(u,r)}else if(ne(e))e._store&&(e._store.validated=!0);else if(e){var d=K(e);if(typeof d=="function"&&d!==e.entries)for(var m=d.call(e),f;!(f=m.next()).done;)ne(f.value)&&je(f.value,r)}}}function vr(e){{var r=e.type;if(r==null||typeof r=="string")return;var n;if(typeof r=="function")n=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===a||r.$$typeof===C))n=r.propTypes;else return;if(n){var u=F(r);Qe(n,e.props,"prop",u,e)}else if(r.PropTypes!==void 0&&!te){te=!0;var d=F(r);O("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",d||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&O("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function pr(e){{for(var r=Object.keys(e.props),n=0;n<r.length;n++){var u=r[n];if(u!=="children"&&u!=="key"){V(e),O("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",u),V(null);break}}e.ref!==null&&(V(e),O("Invalid attribute `ref` supplied to `React.Fragment`."),V(null))}}var Ie={};function Ae(e,r,n,u,d,m){{var f=He(e);if(!f){var s="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(s+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var x=fr(d);x?s+=x:s+=De();var R;e===null?R="null":Q(e)?R="array":e!==void 0&&e.$$typeof===t?(R="<"+(F(e.type)||"Unknown")+" />",s=" Did you accidentally export a JSX literal instead of a component?"):R=typeof e,O("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",R,s)}var E=cr(e,r,n,d,m);if(E==null)return E;if(f){var k=r.children;if(k!==void 0)if(u)if(Q(k)){for(var $=0;$<k.length;$++)Fe(k[$],e);Object.freeze&&Object.freeze(k)}else O("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Fe(k,e)}if(W.call(r,"key")){var L=F(e),D=Object.keys(r).filter(function(Rr){return Rr!=="key"}),ae=D.length>0?"{key: someKey, "+D.join(": ..., ")+": ...}":"{key: someKey}";if(!Ie[L+ae]){var hr=D.length>0?"{"+D.join(": ..., ")+": ...}":"{}";O(`A props object containing a "key" prop is being spread into JSX: let props = %s; <%s {...props} /> React keys must be passed directly to JSX without using spread: let props = %s; <%s key={someKey} {...props} />`,ae,L,hr,L),Ie[L+ae]=!0}}return e===v?pr(E):vr(E),E}}function br(e,r,n){return Ae(e,r,n,!0)}function mr(e,r,n){return Ae(e,r,n,!1)}var yr=mr,gr=br;N.Fragment=v,N.jsx=yr,N.jsxs=gr}()),N}process.env.NODE_ENV==="production"?oe.exports=Or():oe.exports=Cr();var ce=oe.exports;const fe=B.forwardRef(({valueRaw:o,valueMin:t,valueMax:l,dragSensitivity:v,valueRawRoundFn:c,valueRawDisplayFn:p,onValueRawChange:b,orientation:w,axis:a=T.axis,includeIntoTabOrder:y=T.includeIntoTabOrder,mapTo01:h=T.mapTo01,mapFrom01:C=T.mapFrom01,disabled:P=!1,...j},i)=>{const _=c(o),K=Er.useDrag(({delta:S})=>{if(P)return;const O=ie({valueRaw:o,valueMin:t,valueMax:l,dragSensitivity:v,deltaX:S[0],deltaY:S[1],mapTo01:h,mapFrom01:C});b(O)},{enabled:!P,pointer:{keys:!1},axis:le(w,a)});return ce.jsx("div",{ref:i,role:"slider","aria-valuenow":_,"aria-valuemin":t,"aria-valuemax":l,"aria-orientation":se(w,a),"aria-valuetext":p(o),"aria-disabled":P?"true":void 0,"data-disabled":P?"":void 0,tabIndex:y?0:-1,...wr(K(),{style:{touchAction:"none",userSelect:"none",WebkitUserSelect:"none"},onPointerDown(S){P||S.currentTarget.focus()}},j)})});fe.displayName="KnobHeadless";fe.defaultProps={axis:T.axis,includeIntoTabOrder:T.includeIntoTabOrder,mapTo01:T.mapTo01,mapFrom01:T.mapFrom01};const Ve=B.forwardRef((o,t)=>ce.jsx("label",{ref:t,...o}));Ve.displayName="KnobHeadlessLabel";const $e=B.forwardRef((o,t)=>ce.jsx("output",{ref:t,...o}));$e.displayName="KnobHeadlessOutput";const Sr=({valueRaw:o,valueMin:t,valueMax:l,step:v,stepLarger:c,onValueRawChange:p,noDefaultPrevention:b=!1})=>({onKeyDown:a=>{const y=ue({valueRaw:o,valueMin:t,valueMax:l,step:v,stepLarger:c,keyCode:a.code});y!==null&&(p(y,a),xr({event:a,noDefaultPrevention:b}))}}),xr=({event:o,noDefaultPrevention:t})=>{t||o.preventDefault()};function Dr(o,t,l={}){let v=0,c=0,p=!1,b=null;const w=i=>{if(b!==null)return;p=!0,b=i.pointerId,v=i.clientX,c=i.clientY,i.currentTarget.setPointerCapture(i.pointerId)},a=i=>{if(!p||i.pointerId!==b)return;const _=i.clientX-v,K=i.clientY-c;let S;l.axis==="x"?S=[_,0]:l.axis==="y"?S=[0,K]:S=[_,K],t({delta:S}),v=i.clientX,c=i.clientY},y=i=>{if(i.pointerId!==b)return;p=!1,b=null;const _=i.currentTarget;_.hasPointerCapture(i.pointerId)&&_.releasePointerCapture(i.pointerId)},h=i=>{if(i.pointerId===b){p=!1,b=null;const _=i.currentTarget;_.hasPointerCapture(i.pointerId)&&_.releasePointerCapture(i.pointerId)}},C=i=>{if(i.pointerId===b&&p){p=!1,b=null;const _=g.unref(o);_&&_.hasPointerCapture(i.pointerId)&&_.releasePointerCapture(i.pointerId)}},P=i=>{p&&i.pointerId===b&&a(i)},j=()=>{const i=g.unref(o);i&&(i.removeEventListener("pointerdown",w),i.removeEventListener("pointermove",a),i.removeEventListener("pointerup",y),i.removeEventListener("pointercancel",h),window.removeEventListener("pointerup",C),window.removeEventListener("pointermove",P),p=!1,b=null)};g.watch(o,(i,_)=>{_&&j(),i&&(i.addEventListener("pointerdown",w),i.addEventListener("pointermove",a),i.addEventListener("pointerup",y),i.addEventListener("pointercancel",h),window.addEventListener("pointerup",C),window.addEventListener("pointermove",P))},{immediate:!0}),g.onUnmounted(j)}function kr(o,t){const l=c=>{c.preventDefault(),t({deltaY:c.deltaY,deltaX:c.deltaX,event:c})},v=()=>{const c=g.unref(o);c&&c.removeEventListener("wheel",l)};g.watch(o,(c,p)=>{p&&v(),c&&c.addEventListener("wheel",l,{passive:!1})},{immediate:!0}),g.onUnmounted(v)}const jr=["aria-valuenow","aria-valuemin","aria-valuemax","aria-orientation","aria-valuetext","aria-label","aria-labelledby","aria-disabled","data-disabled","tabindex"],Fr=g.defineComponent({__name:"KnobHeadless",props:{wheelSensitivity:{default:.01},valueRaw:{},valueMin:{},valueMax:{},dragSensitivity:{},valueRawRoundFn:{},valueRawDisplayFn:{},onValueRawChange:{},orientation:{},axis:{default:T.axis},includeIntoTabOrder:{type:Boolean,default:T.includeIntoTabOrder},mapTo01:{type:Function,default:T.mapTo01},mapFrom01:{type:Function,default:T.mapFrom01},disabled:{type:Boolean},"aria-label":{},"aria-labelledby":{}},setup(o){const t=o,l=g.ref(),v=g.computed(()=>t.valueRawRoundFn(t.valueRaw)),c=g.computed(()=>le(t.orientation,t.axis||T.axis)),p=g.computed(()=>se(t.orientation,t.axis||T.axis));Dr(l,({delta:a})=>{if(t.disabled)return;const y=ie({valueRaw:t.valueRaw,valueMin:t.valueMin,valueMax:t.valueMax,dragSensitivity:t.dragSensitivity,deltaX:a[0],deltaY:a[1],mapTo01:t.mapTo01||T.mapTo01,mapFrom01:t.mapFrom01||T.mapFrom01});t.onValueRawChange(y)},{axis:c.value}),kr(l,({deltaY:a,deltaX:y})=>{if(t.disabled)return;let h=0;c.value==="x"?h=-y:c.value==="y"?h=-a:h=Math.abs(a)>Math.abs(y)?-a:-y;const C=h*t.wheelSensitivity,P=(t.mapTo01||T.mapTo01)(t.valueRaw,t.valueMin,t.valueMax),j=I(P+C,0,1),i=I((t.mapFrom01||T.mapFrom01)(j,t.valueMin,t.valueMax),t.valueMin,t.valueMax);t.onValueRawChange(i)});const b=a=>{t.disabled||a.currentTarget.focus()},w=a=>{a.preventDefault()};return(a,y)=>(g.openBlock(),g.createElementBlock("div",g.mergeProps({ref_key:"knobRef",ref:l,role:"slider","aria-valuenow":v.value,"aria-valuemin":a.valueMin,"aria-valuemax":a.valueMax,"aria-orientation":p.value,"aria-valuetext":a.valueRawDisplayFn(a.valueRaw),"aria-label":a.ariaLabel,"aria-labelledby":a.ariaLabelledby,"aria-disabled":a.disabled?"true":void 0,"data-disabled":a.disabled?"":void 0,tabindex:a.includeIntoTabOrder?0:-1,style:{touchAction:"none",userSelect:"none",WebkitUserSelect:"none"},onPointerdown:b,onKeydown:w},a.$attrs),[g.renderSlot(a.$slots,"default")],16,jr))}}),Ir=["id"],Ar=g.defineComponent({__name:"KnobHeadlessLabel",props:{id:{}},setup(o){return(t,l)=>(g.openBlock(),g.createElementBlock("label",g.mergeProps({id:t.id},t.$attrs),[g.renderSlot(t.$slots,"default")],16,Ir))}}),Lr=["for"],Kr=g.defineComponent({__name:"KnobHeadlessOutput",props:{htmlFor:{}},setup(o){return(t,l)=>(g.openBlock(),g.createElementBlock("output",g.mergeProps({for:t.htmlFor},t.$attrs),[g.renderSlot(t.$slots,"default")],16,Lr))}});function Vr({valueRaw:o,valueMin:t,valueMax:l,step:v,stepLarger:c,onValueRawChange:p,noDefaultPrevention:b=!1}){return{onKeyDown:a=>{const y=ue({valueRaw:o,valueMin:t,valueMax:l,step:v,stepLarger:c,keyCode:a.code});y!==null&&(p(y,a),b||a.preventDefault())}}}exports.KNOB_DEFAULTS=T;exports.ReactKnobHeadless=fe;exports.ReactKnobHeadlessLabel=Ve;exports.ReactKnobHeadlessOutput=$e;exports.VueKnobHeadless=Fr;exports.VueKnobHeadlessLabel=Ar;exports.VueKnobHeadlessOutput=Kr;exports.calculateDragValue=ie;exports.calculateKeyboardValue=ue;exports.getAriaOrientation=se;exports.getDragAxis=le;exports.useReactKnobKeyboardControls=Sr;exports.useVueKnobKeyboardControls=Vr; //# sourceMappingURL=potentio.cjs.js.map