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

@zag-js/number-input

Package Overview
Dependencies
Maintainers
1
Versions
1034
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zag-js/number-input - npm Package Compare versions

Comparing version 0.0.0-dev-20220410020729 to 0.0.0-dev-20220412122925

2

dist/index.js

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

var T=Object.defineProperty;var oe=Object.getOwnPropertyDescriptor;var ie=Object.getOwnPropertyNames;var ae=Object.prototype.hasOwnProperty;var le=e=>T(e,"__esModule",{value:!0});var ue=(e,t)=>{for(var n in t)T(e,n,{get:t[n],enumerable:!0})},se=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ie(t))!ae.call(e,o)&&(n||o!=="default")&&T(e,o,{get:()=>t[o],enumerable:!(r=oe(t,o))||r.enumerable});return e};var ce=(e=>(t,n)=>e&&e.get(t)||(n=se(le({}),t,1),e&&e.set(t,n),n))(typeof WeakMap!="undefined"?new WeakMap:0);var Be={};ue(Be,{connect:()=>Q,machine:()=>ne});var h=e=>e?"":void 0;function P(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()})}}var O=()=>{};var He=(()=>{let e=0;return()=>(e++,e.toString(36))})();var E=new Map,b=new Map;function de(e,t,n,r){var o;if(!e)return O;let a=JSON.stringify({type:t,options:r}),u=E.get(e);if(E.has(e))(u==null?void 0:u.has(a))?(o=u==null?void 0:u.get(a))==null||o.add(n):u==null||u.set(a,new Set([n]));else{let s=new Map([[a,new Set([n])]]);E.set(e,s)}function c(s){var l,m;function d(f){var g;let x=E.get(s);(g=x==null?void 0:x.get(a))==null||g.forEach(re=>re(f))}if(!(b==null?void 0:b.has(s))){b.set(s,new Map([[a,d]])),s.addEventListener(t,d,r);return}((l=b==null?void 0:b.get(s))==null?void 0:l.has(a))||((m=b.get(s))==null||m.set(a,d),s.addEventListener(t,d,r))}return c(e),function(){var s,l,m,d;if(!E.has(e))return;let f=E.get(e);if((s=f==null?void 0:f.get(a))==null||s.delete(n),((l=f==null?void 0:f.get(a))==null?void 0:l.size)===0){let g=(m=b.get(e))==null?void 0:m.get(a);e.removeEventListener(t,g,r),f==null||f.delete(a),(d=b.get(e))==null||d.delete(a),(f==null?void 0:f.size)===0&&(E.delete(e),b.delete(e))}}}var N=e=>Object.prototype.toString.call(e).slice(8,-1),pe=e=>N(e)==="Object"&&"current"in e,me=e=>N(e)==="Function"?e():e;function C(e,t,n,r){let o=pe(e)?e.current:me(e);return de(o,t,n,r)}function L(e){var t;return(t=e.nativeEvent)!=null?t:e}var B=2147483647;var Ve=["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(",");var fe=new Set(["PageUp","PageDown"]),ve=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]);function _(e){return e.ctrlKey||e.metaKey?.1:fe.has(e.key)||e.shiftKey&&ve.has(e.key)?10:1}function H(e,t,n){if(!e)return O;let r=Array.isArray(t)?t:[t],o=e.ownerDocument.defaultView||window,a=new o.MutationObserver(u=>{for(let c of u)c.type==="attributes"&&c.attributeName&&r.includes(c.attributeName)&&n(c)});return a.observe(e,{attributes:!0,attributeFilter:r}),()=>a.disconnect()}function ge(e,t){return e.addEventListener("webkitpointerlockchange",t,!1),e.addEventListener("mozpointerlockchange",t,!1),e.addEventListener("pointerlockchange",t,!1),function(){e.removeEventListener("mozpointerlockchange",t,!1),e.removeEventListener("pointerlockchange",t,!1)}}function he(e,t){return e.addEventListener("webkitpointerlockerror",t,!1),e.addEventListener("mozpointerlockerror",t,!1),e.addEventListener("pointerlockerror",t,!1),function(){e.removeEventListener("webkitpointerlockerror",t,!1),e.removeEventListener("mozpointerlockerror",t,!1),e.removeEventListener("pointerlockerror",t,!1)}}function be(e){return e.requestPointerLock||e.mozRequestPointerLock||e.webkitRequestPointerLock}function ye(e){return e.exitPointerLock||e.mozExitPointerLock||e.webkitExitPointerLock}function V(e,t={}){let{onPointerLock:n,onPointerUnlock:r}=t,o=e.body;function a(){return"pointerLockElement"in e||"mozPointerLockElement"in e||"webkitPointerLockElement"in e}function u(){return!!e.pointerLockElement}function c(){u()?n==null||n():r==null||r()}function s(x){u()&&(r==null||r()),console.error("PointerLock error occured:",x),l()}function l(){e.exitPointerLock=ye(e),e.exitPointerLock()}let m=new Set;function d(){m.add(ge(e,c)),m.add(he(e,s))}function f(){!a()||(m.forEach(x=>x()),m.clear(),l())}function g(){!a()||(o.requestPointerLock=be(o),o.requestPointerLock(),d())}return g(),f}var Ee=Object.defineProperty,we=Object.defineProperties,xe=Object.getOwnPropertyDescriptors,W=Object.getOwnPropertySymbols,Pe=Object.prototype.hasOwnProperty,Se=Object.prototype.propertyIsEnumerable,Ce=Math.pow,U=(e,t,n)=>t in e?Ee(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Le=(e,t)=>{for(var n in t||(t={}))Pe.call(t,n)&&U(e,n,t[n]);if(W)for(var n of W(t))Se.call(t,n)&&U(e,n,t[n]);return e},Me=(e,t)=>we(e,xe(t)),F=new Intl.NumberFormat("en-US",{style:"decimal"});function k(e){return parseFloat(F.format(e))}function j(e,t){return(e%t+t)%t}function Ie(e,t){let n=v(e),r=Ce(10,t!=null?t:10);return n=Math.round(n*r)/r,t?n.toFixed(t):e.toString()}function w(e){if(typeof window=="undefined")return Math.round(e);let t=window.devicePixelRatio;return Math.floor(e*t+.5)/t}function M(e,t){return Math.min(Math.max(v(e),t.min),t.max)}function Y(e){var t,n;return(n=(t=F.formatToParts(e).find(r=>r.type==="fraction"))==null?void 0:t.value.length)!=null?n:0}var X=(e,t)=>k(v(e)+t),z=(e,t)=>k(v(e)-t),K=(e,t)=>k(v(e)*t);function v(e){if(typeof e=="number")return e;let t=parseFloat(e.toString().replace(/[^\w.-]+/g,""));return Number.isNaN(t)?0:t}function Ae(e){var t;let n=Y(e.step),r=v(e.value),o=Number.isNaN(r)?n:Math.max(Y(r),n);return Math.max(o,(t=e.precision)!=null?t:0)}function S(e,t){return Ie(e,Ae(Me(Le({},t),{value:e})))}function q(e,t){return v(e)>=t.max}function $(e,t){return v(e)<=t.min}function G(e,t){let n=v(e);return n>=t.min&&n<=t.max}var Fe=(()=>{let e=0;return()=>(e++,e.toString(36))})(),Te=e=>Array.isArray(e),ke=e=>!(e==null||typeof e!="object"||Te(e)),Re=e=>ke(e)&&"touches"in e;var De={pageX:0,pageY:0,clientX:0,clientY:0};function Z(e,t="page"){let n=Re(e)?e.touches[0]||e.changedTouches[0]||De:e;return{x:n[`${t}X`],y:n[`${t}Y`]}}function Oe(e){return{button:e,label:e,input:e,output:e,element:e}}var J=Oe(e=>e);var i={getDoc:e=>{var t;return(t=e.doc)!=null?t:document},getWin:e=>{var t;return(t=i.getDoc(e).defaultView)!=null?t:window},getInputId:e=>`number-input-${e.uid}-input`,getIncButtonId:e=>`number-input-${e.uid}-inc-btn`,getDecButtonId:e=>`number-input-${e.uid}-dec-btn`,getScrubberId:e=>`number-input-${e.uid}-scrubber`,getCursorId:e=>`number-input-${e.uid}-cursor`,getLabelId:e=>`number-input-${e.uid}-label`,getRootId:e=>`number-input-${e.uid}-root`,getInputEl:e=>i.getDoc(e).getElementById(i.getInputId(e)),getIncButtonEl:e=>i.getDoc(e).getElementById(i.getIncButtonId(e)),getDecButtonEl:e=>i.getDoc(e).getElementById(i.getDecButtonId(e)),getScrubberEl:e=>i.getDoc(e).getElementById(i.getScrubberId(e)),getCursorEl:e=>i.getDoc(e).getElementById(i.getCursorId(e)),getMousementValue(e,t){let n=w(t.movementX),r=w(t.movementY),o=n>0?"increment":n<0?"decrement":null;e.isRtl&&o==="increment"&&(o="decrement"),e.isRtl&&o==="decrement"&&(o="increment");let a={x:e.scrubberCursorPoint.x+n,y:e.scrubberCursorPoint.y+r},c=i.getWin(e).innerWidth,s=w(7.5);return a.x=j(a.x+s,c)-s,{hint:o,point:a}},createVirtualCursor(e){let t=i.getDoc(e),n=t.createElement("div");n.className="scrubber--cursor",n.id=i.getCursorId(e),Object.assign(n.style,{width:"15px",height:"15px",position:"fixed",pointerEvents:"none",left:"0px",top:"0px",zIndex:B,transform:e.scrubberCursorPoint?`translate3d(${e.scrubberCursorPoint.x}px, ${e.scrubberCursorPoint.y}px, 0px)`:void 0,willChange:"transform"}),n.innerHTML=`
var T=Object.defineProperty;var oe=Object.getOwnPropertyDescriptor;var ie=Object.getOwnPropertyNames;var ae=Object.prototype.hasOwnProperty;var le=e=>T(e,"__esModule",{value:!0});var ue=(e,t)=>{for(var n in t)T(e,n,{get:t[n],enumerable:!0})},se=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ie(t))!ae.call(e,o)&&(n||o!=="default")&&T(e,o,{get:()=>t[o],enumerable:!(r=oe(t,o))||r.enumerable});return e};var ce=(e=>(t,n)=>e&&e.get(t)||(n=se(le({}),t,1),e&&e.set(t,n),n))(typeof WeakMap!="undefined"?new WeakMap:0);var Be={};ue(Be,{connect:()=>Q,machine:()=>ne});var h=e=>e?"":void 0;function P(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()})}}var O=()=>{};var He=(()=>{let e=0;return()=>(e++,e.toString(36))})();var E=new Map,b=new Map;function de(e,t,n,r){var o;if(!e)return O;let a=JSON.stringify({type:t,options:r}),u=E.get(e);if(E.has(e))(u==null?void 0:u.has(a))?(o=u==null?void 0:u.get(a))==null||o.add(n):u==null||u.set(a,new Set([n]));else{let s=new Map([[a,new Set([n])]]);E.set(e,s)}function c(s){var l,m;function d(f){var g;let x=E.get(s);(g=x==null?void 0:x.get(a))==null||g.forEach(re=>re(f))}if(!(b==null?void 0:b.has(s))){b.set(s,new Map([[a,d]])),s.addEventListener(t,d,r);return}((l=b==null?void 0:b.get(s))==null?void 0:l.has(a))||((m=b.get(s))==null||m.set(a,d),s.addEventListener(t,d,r))}return c(e),function(){var s,l,m,d;if(!E.has(e))return;let f=E.get(e);if((s=f==null?void 0:f.get(a))==null||s.delete(n),((l=f==null?void 0:f.get(a))==null?void 0:l.size)===0){let g=(m=b.get(e))==null?void 0:m.get(a);e.removeEventListener(t,g,r),f==null||f.delete(a),(d=b.get(e))==null||d.delete(a),(f==null?void 0:f.size)===0&&(E.delete(e),b.delete(e))}}}var N=e=>Object.prototype.toString.call(e).slice(8,-1),pe=e=>N(e)==="Object"&&"current"in e,me=e=>N(e)==="Function"?e():e;function C(e,t,n,r){let o=pe(e)?e.current:me(e);return de(o,t,n,r)}function L(e){var t;return(t=e.nativeEvent)!=null?t:e}var B=2147483647;var Ve=["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(",");var fe=new Set(["PageUp","PageDown"]),ve=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]);function _(e){return e.ctrlKey||e.metaKey?.1:fe.has(e.key)||e.shiftKey&&ve.has(e.key)?10:1}function H(e,t,n){if(!e)return O;let r=Array.isArray(t)?t:[t],o=e.ownerDocument.defaultView||window,a=new o.MutationObserver(u=>{for(let c of u)c.type==="attributes"&&c.attributeName&&r.includes(c.attributeName)&&n(c)});return a.observe(e,{attributes:!0,attributeFilter:r}),()=>a.disconnect()}function ge(e,t){return e.addEventListener("webkitpointerlockchange",t,!1),e.addEventListener("mozpointerlockchange",t,!1),e.addEventListener("pointerlockchange",t,!1),function(){e.removeEventListener("mozpointerlockchange",t,!1),e.removeEventListener("pointerlockchange",t,!1)}}function he(e,t){return e.addEventListener("webkitpointerlockerror",t,!1),e.addEventListener("mozpointerlockerror",t,!1),e.addEventListener("pointerlockerror",t,!1),function(){e.removeEventListener("webkitpointerlockerror",t,!1),e.removeEventListener("mozpointerlockerror",t,!1),e.removeEventListener("pointerlockerror",t,!1)}}function be(e){return e.requestPointerLock||e.mozRequestPointerLock||e.webkitRequestPointerLock}function ye(e){return e.exitPointerLock||e.mozExitPointerLock||e.webkitExitPointerLock}function V(e,t={}){let{onPointerLock:n,onPointerUnlock:r}=t,o=e.body;function a(){return"pointerLockElement"in e||"mozPointerLockElement"in e||"webkitPointerLockElement"in e}function u(){return!!e.pointerLockElement}function c(){u()?n==null||n():r==null||r()}function s(x){u()&&(r==null||r()),console.error("PointerLock error occured:",x),l()}function l(){e.exitPointerLock=ye(e),e.exitPointerLock()}let m=new Set;function d(){m.add(ge(e,c)),m.add(he(e,s))}function f(){!a()||(m.forEach(x=>x()),m.clear(),l())}function g(){!a()||(o.requestPointerLock=be(o),o.requestPointerLock(),d())}return g(),f}var Ee=Object.defineProperty,we=Object.defineProperties,xe=Object.getOwnPropertyDescriptors,W=Object.getOwnPropertySymbols,Pe=Object.prototype.hasOwnProperty,Se=Object.prototype.propertyIsEnumerable,Ce=Math.pow,U=(e,t,n)=>t in e?Ee(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Le=(e,t)=>{for(var n in t||(t={}))Pe.call(t,n)&&U(e,n,t[n]);if(W)for(var n of W(t))Se.call(t,n)&&U(e,n,t[n]);return e},Me=(e,t)=>we(e,xe(t)),F=new Intl.NumberFormat("en-US",{style:"decimal"});function k(e){return parseFloat(F.format(e))}function j(e,t){return(e%t+t)%t}function Ie(e,t){let n=v(e),r=Ce(10,t!=null?t:10);return n=Math.round(n*r)/r,t?n.toFixed(t):e.toString()}function w(e){if(typeof window=="undefined")return Math.round(e);let t=window.devicePixelRatio;return Math.floor(e*t+.5)/t}function M(e,t){return Math.min(Math.max(v(e),t.min),t.max)}function Y(e){var t,n;return(n=(t=F.formatToParts(e).find(r=>r.type==="fraction"))==null?void 0:t.value.length)!=null?n:0}var X=(e,t)=>k(v(e)+t),z=(e,t)=>k(v(e)-t),K=(e,t)=>k(v(e)*t);function v(e){if(typeof e=="number")return e;let t=parseFloat(e.toString().replace(/[^\w.-]+/g,""));return Number.isNaN(t)?0:t}function Ae(e){var t;let n=Y(e.step),r=v(e.value),o=Number.isNaN(r)?n:Math.max(Y(r),n);return Math.max(o,(t=e.precision)!=null?t:0)}function S(e,t){return Ie(e,Ae(Me(Le({},t),{value:e})))}function q(e,t){return v(e)>=t.max}function $(e,t){return v(e)<=t.min}function G(e,t){let n=v(e);return n>=t.min&&n<=t.max}var Fe=(()=>{let e=0;return()=>(e++,e.toString(36))})(),Te=e=>Array.isArray(e),ke=e=>!(e==null||typeof e!="object"||Te(e)),Re=e=>ke(e)&&"touches"in e;var De={pageX:0,pageY:0,clientX:0,clientY:0};function Z(e,t="page"){let n=Re(e)?e.touches[0]||e.changedTouches[0]||De:e;return{x:n[`${t}X`],y:n[`${t}Y`]}}function Oe(e){return{button:e,label:e,input:e,output:e,element:e}}var J=Oe(e=>e);var i={getDoc:e=>{var t;return(t=e.doc)!=null?t:document},getWin:e=>{var t;return(t=i.getDoc(e).defaultView)!=null?t:window},getInputId:e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.input)!=null?n:`number-input-${e.uid}-input`},getIncButtonId:e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.incBtn)!=null?n:`number-input-${e.uid}-inc-btn`},getDecButtonId:e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.decBtn)!=null?n:`number-input-${e.uid}-dec-btn`},getScrubberId:e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.scrubber)!=null?n:`number-input-${e.uid}-scrubber`},getCursorId:e=>`number-input-${e.uid}-cursor`,getLabelId:e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.label)!=null?n:`number-input-${e.uid}-label`},getRootId:e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.root)!=null?n:`number-input-${e.uid}-root`},getInputEl:e=>i.getDoc(e).getElementById(i.getInputId(e)),getIncButtonEl:e=>i.getDoc(e).getElementById(i.getIncButtonId(e)),getDecButtonEl:e=>i.getDoc(e).getElementById(i.getDecButtonId(e)),getScrubberEl:e=>i.getDoc(e).getElementById(i.getScrubberId(e)),getCursorEl:e=>i.getDoc(e).getElementById(i.getCursorId(e)),getMousementValue(e,t){let n=w(t.movementX),r=w(t.movementY),o=n>0?"increment":n<0?"decrement":null;e.isRtl&&o==="increment"&&(o="decrement"),e.isRtl&&o==="decrement"&&(o="increment");let a={x:e.scrubberCursorPoint.x+n,y:e.scrubberCursorPoint.y+r},c=i.getWin(e).innerWidth,s=w(7.5);return a.x=j(a.x+s,c)-s,{hint:o,point:a}},createVirtualCursor(e){let t=i.getDoc(e),n=t.createElement("div");n.className="scrubber--cursor",n.id=i.getCursorId(e),Object.assign(n.style,{width:"15px",height:"15px",position:"fixed",pointerEvents:"none",left:"0px",top:"0px",zIndex:B,transform:e.scrubberCursorPoint?`translate3d(${e.scrubberCursorPoint.x}px, ${e.scrubberCursorPoint.y}px, 0px)`:void 0,willChange:"transform"}),n.innerHTML=`
<svg width="46" height="15" style="left: -15.5px; position: absolute; top: 0; filter: drop-shadow(rgba(0, 0, 0, 0.4) 0px 1px 1.1px);">

@@ -3,0 +3,0 @@ <g transform="translate(2 3)">

@@ -6,2 +6,10 @@ import { StateMachine as S } from "@zag-js/core";

declare type InputSelection = Record<"start" | "end", number | null>;
declare type IdMap = Partial<{
root: string;
label: string;
input: string;
incBtn: string;
decBtn: string;
scrubber: string;
}>;
declare type IntlMessages = {

@@ -24,2 +32,6 @@ /**

/**
* The ids of the elements in the number input. Useful for composition.
*/
ids?: IdMap;
/**
* The name attribute of the number input. Useful for form submission.

@@ -26,0 +38,0 @@ */

{
"name": "@zag-js/number-input",
"version": "0.0.0-dev-20220410020729",
"version": "0.0.0-dev-20220412122925",
"description": "Core logic for the number-input widget implemented as a state machine",

@@ -32,9 +32,9 @@ "keywords": [

"dependencies": {
"@zag-js/core": "^0.0.0-dev-20220410020729",
"@zag-js/dom-utils": "^0.0.0-dev-20220410020729",
"@zag-js/number-utils": "^0.0.0-dev-20220410020729",
"@zag-js/rect-utils": "^0.0.0-dev-20220410020729",
"@zag-js/types": "^0.0.0-dev-20220410020729",
"@zag-js/utils": "^0.0.0-dev-20220410020729"
"@zag-js/core": "^0.0.0-dev-20220412122925",
"@zag-js/dom-utils": "^0.0.0-dev-20220412122925",
"@zag-js/number-utils": "^0.0.0-dev-20220412122925",
"@zag-js/rect-utils": "^0.0.0-dev-20220412122925",
"@zag-js/types": "^0.0.0-dev-20220412122925",
"@zag-js/utils": "^0.0.0-dev-20220412122925"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc