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-20220413091534 to 0.0.0-dev-20220413174154

dist/index.d.ts.map

1

dist/index.d.ts
export { connect } from "./number-input.connect";
export { machine } from "./number-input.machine";
export type { MachineContext, MachineState } from "./number-input.types";
//# sourceMappingURL=index.d.ts.map

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

var nt=Object.defineProperty;var ee=Object.getOwnPropertyDescriptor;var ne=Object.getOwnPropertyNames;var re=Object.prototype.hasOwnProperty;var ie=(t,e)=>{for(var n in e)nt(t,n,{get:e[n],enumerable:!0})},oe=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ne(e))!re.call(t,o)&&o!==n&&nt(t,o,{get:()=>e[o],enumerable:!(i=ee(e,o))||i.enumerable});return t};var se=t=>oe(nt({},"__esModule",{value:!0}),t);var Ke={};ie(Ke,{connect:()=>kt,machine:()=>Qt});module.exports=se(Ke);var I=t=>t?"":void 0;function V(t){let e=new Set;function n(i){let o=globalThis.requestAnimationFrame(i);e.add(()=>globalThis.cancelAnimationFrame(o))}return n(()=>n(t)),function(){e.forEach(function(i){i()})}}var pt=()=>{};var $e=(()=>{let t=0;return()=>(t++,t.toString(36))})();var R=new Map,T=new Map;function ae(t,e,n,i){var o;if(!t)return pt;let l=JSON.stringify({type:e,options:i}),p=R.get(t);if(R.has(t))p!=null&&p.has(l)?(o=p?.get(l))==null||o.add(n):p?.set(l,new Set([n]));else{let y=new Map([[l,new Set([n])]]);R.set(t,y)}function g(y){var m,w;function E(c){var d;let r=R.get(y);(d=r?.get(l))==null||d.forEach(s=>s(c))}if(!(T!=null&&T.has(y))){T.set(y,new Map([[l,E]])),y.addEventListener(e,E,i);return}(m=T?.get(y))!=null&&m.has(l)||((w=T.get(y))==null||w.set(l,E),y.addEventListener(e,E,i))}return g(t),function(){var y,m,w,E;if(!R.has(t))return;let c=R.get(t);if((y=c?.get(l))==null||y.delete(n),((m=c?.get(l))==null?void 0:m.size)===0){let d=(w=T.get(t))==null?void 0:w.get(l);t.removeEventListener(e,d,i),c?.delete(l),(E=T.get(t))==null||E.delete(l),c?.size===0&&(R.delete(t),T.delete(t))}}}var mt=t=>Object.prototype.toString.call(t).slice(8,-1),le=t=>mt(t)==="Object"&&"current"in t,ue=t=>mt(t)==="Function"?t():t;function Y(t,e,n,i){let o=le(t)?t.current:ue(t);return ae(o,e,n,i)}function K(t){var e;return(e=t.nativeEvent)!=null?e:t}var vt=2147483647;var qe=["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 ce=new Set(["PageUp","PageDown"]),de=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]);function gt(t){return t.ctrlKey||t.metaKey?.1:ce.has(t.key)||t.shiftKey&&de.has(t.key)?10:1}function yt(t,e,n){if(!t)return pt;let i=Array.isArray(e)?e:[e],o=t.ownerDocument.defaultView||window,l=new o.MutationObserver(p=>{for(let g of p)g.type==="attributes"&&g.attributeName&&i.includes(g.attributeName)&&n(g)});return l.observe(t,{attributes:!0,attributeFilter:i}),()=>l.disconnect()}function he(t,e){return t.addEventListener("webkitpointerlockchange",e,!1),t.addEventListener("mozpointerlockchange",e,!1),t.addEventListener("pointerlockchange",e,!1),function(){t.removeEventListener("mozpointerlockchange",e,!1),t.removeEventListener("pointerlockchange",e,!1)}}function fe(t,e){return t.addEventListener("webkitpointerlockerror",e,!1),t.addEventListener("mozpointerlockerror",e,!1),t.addEventListener("pointerlockerror",e,!1),function(){t.removeEventListener("webkitpointerlockerror",e,!1),t.removeEventListener("mozpointerlockerror",e,!1),t.removeEventListener("pointerlockerror",e,!1)}}function pe(t){return t.requestPointerLock||t.mozRequestPointerLock||t.webkitRequestPointerLock}function me(t){return t.exitPointerLock||t.mozExitPointerLock||t.webkitExitPointerLock}function bt(t,e={}){let{onPointerLock:n,onPointerUnlock:i}=e,o=t.body;function l(){return"pointerLockElement"in t||"mozPointerLockElement"in t||"webkitPointerLockElement"in t}function p(){return!!t.pointerLockElement}function g(){p()?n?.():i?.()}function y(r){p()&&i?.(),console.error("PointerLock error occured:",r),m()}function m(){t.exitPointerLock=me(t),t.exitPointerLock()}let w=new Set;function E(){w.add(he(t,g)),w.add(fe(t,y))}function c(){!l()||(w.forEach(r=>r()),w.clear(),m())}function d(){!l()||!p()||(o.requestPointerLock=pe(o),o.requestPointerLock(),E())}return d(),c}var wt=new Intl.NumberFormat("en-US",{style:"decimal"});function rt(t){return parseFloat(wt.format(t))}function xt(t,e){return(t%e+e)%e}function ve(t,e){let n=P(t),i=10**(e??10);return n=Math.round(n*i)/i,e?n.toFixed(e):t.toString()}function O(t){if(typeof window>"u")return Math.round(t);let e=window.devicePixelRatio;return Math.floor(t*e+.5)/e}function X(t,e){return Math.min(Math.max(P(t),e.min),e.max)}function Et(t){var e,n;return(n=(e=wt.formatToParts(t).find(i=>i.type==="fraction"))==null?void 0:e.value.length)!=null?n:0}var St=(t,e)=>rt(P(t)+e),Ct=(t,e)=>rt(P(t)-e),At=(t,e)=>rt(P(t)*e);function P(t){if(typeof t=="number")return t;let e=parseFloat(t.toString().replace(/[^\w.-]+/g,""));return Number.isNaN(e)?0:e}function ge(t){var e;let n=Et(t.step),i=P(t.value),o=Number.isNaN(i)?n:Math.max(Et(i),n);return Math.max(o,(e=t.precision)!=null?e:0)}function _(t,e){return ve(t,ge({...e,value:t}))}function Pt(t,e){return P(t)>=e.max}function Mt(t,e){return P(t)<=e.min}function Lt(t,e){let n=P(t);return n>=e.min&&n<=e.max}var Je=(()=>{let t=0;return()=>(t++,t.toString(36))})(),ye=t=>Array.isArray(t),be=t=>!(t==null||typeof t!="object"||ye(t)),Ee=t=>be(t)&&"touches"in t;var we={pageX:0,pageY:0,clientX:0,clientY:0};function Tt(t,e="page"){let n=Ee(t)?t.touches[0]||t.changedTouches[0]||we:t;return{x:n[`${e}X`],y:n[`${e}Y`]}}function xe(t){return{button:t,label:t,input:t,output:t,element:t}}var It=xe(t=>t);var v={getDoc:t=>{var e;return(e=t.doc)!=null?e:document},getWin:t=>{var e;return(e=v.getDoc(t).defaultView)!=null?e:window},getInputId:t=>{var e,n;return(n=(e=t.ids)==null?void 0:e.input)!=null?n:`number-input-${t.uid}-input`},getIncButtonId:t=>{var e,n;return(n=(e=t.ids)==null?void 0:e.incBtn)!=null?n:`number-input-${t.uid}-inc-btn`},getDecButtonId:t=>{var e,n;return(n=(e=t.ids)==null?void 0:e.decBtn)!=null?n:`number-input-${t.uid}-dec-btn`},getScrubberId:t=>{var e,n;return(n=(e=t.ids)==null?void 0:e.scrubber)!=null?n:`number-input-${t.uid}-scrubber`},getCursorId:t=>`number-input-${t.uid}-cursor`,getLabelId:t=>{var e,n;return(n=(e=t.ids)==null?void 0:e.label)!=null?n:`number-input-${t.uid}-label`},getRootId:t=>{var e,n;return(n=(e=t.ids)==null?void 0:e.root)!=null?n:`number-input-${t.uid}-root`},getInputEl:t=>v.getDoc(t).getElementById(v.getInputId(t)),getIncButtonEl:t=>v.getDoc(t).getElementById(v.getIncButtonId(t)),getDecButtonEl:t=>v.getDoc(t).getElementById(v.getDecButtonId(t)),getScrubberEl:t=>v.getDoc(t).getElementById(v.getScrubberId(t)),getCursorEl:t=>v.getDoc(t).getElementById(v.getCursorId(t)),getMousementValue(t,e){let n=O(e.movementX),i=O(e.movementY),o=n>0?"increment":n<0?"decrement":null;t.isRtl&&o==="increment"&&(o="decrement"),t.isRtl&&o==="decrement"&&(o="increment");let l={x:t.scrubberCursorPoint.x+n,y:t.scrubberCursorPoint.y+i},g=v.getWin(t).innerWidth,y=O(7.5);return l.x=xt(l.x+y,g)-y,{hint:o,point:l}},createVirtualCursor(t){let e=v.getDoc(t),n=e.createElement("div");n.className="scrubber--cursor",n.id=v.getCursorId(t),Object.assign(n.style,{width:"15px",height:"15px",position:"fixed",pointerEvents:"none",left:"0px",top:"0px",zIndex:vt,transform:t.scrubberCursorPoint?`translate3d(${t.scrubberCursorPoint.x}px, ${t.scrubberCursorPoint.y}px, 0px)`:void 0,willChange:"transform"}),n.innerHTML=`
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __pow = Math.pow;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/index.ts
var src_exports = {};
__export(src_exports, {
connect: () => connect,
machine: () => machine
});
module.exports = __toCommonJS(src_exports);
// ../../utilities/dom/src/attrs.ts
var dataAttr = (guard) => {
return guard ? "" : void 0;
};
// ../../utilities/dom/src/next-tick.ts
function nextTick(fn) {
const set = /* @__PURE__ */ new Set();
function raf(fn2) {
const id = globalThis.requestAnimationFrame(fn2);
set.add(() => globalThis.cancelAnimationFrame(id));
}
raf(() => raf(fn));
return function cleanup() {
set.forEach(function(fn2) {
fn2();
});
};
}
// ../../utilities/core/src/array.ts
function clear(v) {
while (v.length > 0)
v.pop();
return v;
}
// ../../utilities/core/src/functions.ts
var runIfFn = (v, ...a) => {
const res = typeof v === "function" ? v(...a) : v;
return res != null ? res : void 0;
};
var cast = (v) => v;
var noop = () => {
};
var pipe = (...fns) => (v) => fns.reduce((a, b) => b(a), v);
var uuid = /* @__PURE__ */ (() => {
let id = 0;
return () => {
id++;
return id.toString(36);
};
})();
// ../../utilities/core/src/guard.ts
var ua = (v) => isDom() && v.test(navigator.userAgent);
var isDom = () => !!(typeof window !== "undefined");
var isSafari = () => ua(/^((?!chrome|android).)*safari/i);
var isArray = (v) => Array.isArray(v);
var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
var isNumber = (v) => typeof v === "number" && !Number.isNaN(v);
var isString = (v) => typeof v === "string";
var isFunction = (v) => typeof v === "function";
var supportsPointerEvent = () => isDom() && window.onpointerdown === null;
var isTouchEvent = (v) => isObject(v) && "touches" in v;
// ../../utilities/core/src/warning.ts
function warn(...a) {
const m = a.length === 1 ? a[0] : a[1];
const c = a.length === 2 ? a[0] : true;
if (c && void 0 !== "production") {
console.warn(m);
}
}
function invariant(...a) {
const m = a.length === 1 ? a[0] : a[1];
const c = a.length === 2 ? a[0] : true;
if (c && void 0 !== "production") {
throw new Error(m);
}
}
// ../../utilities/dom/src/event-bus.ts
var listenerElements = /* @__PURE__ */ new Map();
var listenerCache = /* @__PURE__ */ new Map();
function globalEventBus(node, type, handler, options) {
var _a;
if (!node)
return noop;
const hash = JSON.stringify({ type, options });
const group = listenerElements.get(node);
if (!listenerElements.has(node)) {
const group2 = /* @__PURE__ */ new Map([[hash, /* @__PURE__ */ new Set([handler])]]);
listenerElements.set(node, group2);
} else if (group == null ? void 0 : group.has(hash)) {
(_a = group == null ? void 0 : group.get(hash)) == null ? void 0 : _a.add(handler);
} else {
group == null ? void 0 : group.set(hash, /* @__PURE__ */ new Set([handler]));
}
function attach(node2) {
var _a2, _b;
function listener(event) {
var _a3;
const group2 = listenerElements.get(node2);
(_a3 = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _a3.forEach((fn) => fn(event));
}
if (!(listenerCache == null ? void 0 : listenerCache.has(node2))) {
listenerCache.set(node2, /* @__PURE__ */ new Map([[hash, listener]]));
node2.addEventListener(type, listener, options);
return;
}
if (!((_a2 = listenerCache == null ? void 0 : listenerCache.get(node2)) == null ? void 0 : _a2.has(hash))) {
(_b = listenerCache.get(node2)) == null ? void 0 : _b.set(hash, listener);
node2.addEventListener(type, listener, options);
}
}
attach(node);
return function remove() {
var _a2, _b, _c, _d;
if (!listenerElements.has(node))
return;
const group2 = listenerElements.get(node);
(_a2 = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _a2.delete(handler);
if (((_b = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _b.size) === 0) {
const listener = (_c = listenerCache.get(node)) == null ? void 0 : _c.get(hash);
node.removeEventListener(type, listener, options);
group2 == null ? void 0 : group2.delete(hash);
(_d = listenerCache.get(node)) == null ? void 0 : _d.delete(hash);
if ((group2 == null ? void 0 : group2.size) === 0) {
listenerElements.delete(node);
listenerCache.delete(node);
}
}
};
}
// ../../utilities/dom/src/listener.ts
var t = (v) => Object.prototype.toString.call(v).slice(8, -1);
var isRef = (v) => t(v) === "Object" && "current" in v;
var runIfFn2 = (fn) => t(fn) === "Function" ? fn() : fn;
function addDomEvent(target, event, listener, options) {
const node = isRef(target) ? target.current : runIfFn2(target);
return globalEventBus(node, event, listener, options);
}
// ../../utilities/dom/src/query.ts
function getNativeEvent(event) {
var _a;
return (_a = event.nativeEvent) != null ? _a : event;
}
// ../../utilities/dom/src/constants.ts
var MAX_Z_INDEX = 2147483647;
// ../../utilities/dom/src/keyboard-event.ts
var PAGE_KEYS = /* @__PURE__ */ new Set(["PageUp", "PageDown"]);
var ARROW_KEYS = /* @__PURE__ */ new Set(["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"]);
function getEventStep(event) {
if (event.ctrlKey || event.metaKey) {
return 0.1;
} else {
const isPageKey = PAGE_KEYS.has(event.key);
const isSkipKey = isPageKey || event.shiftKey && ARROW_KEYS.has(event.key);
return isSkipKey ? 10 : 1;
}
}
// ../../utilities/dom/src/mutation-observer.ts
function observeAttributes(node, attributes, fn) {
if (!node)
return noop;
const attrs = Array.isArray(attributes) ? attributes : [attributes];
const win = node.ownerDocument.defaultView || window;
const obs = new win.MutationObserver((changes) => {
for (const change of changes) {
if (change.type === "attributes" && change.attributeName && attrs.includes(change.attributeName)) {
fn(change);
}
}
});
obs.observe(node, { attributes: true, attributeFilter: attrs });
return () => obs.disconnect();
}
// ../../utilities/dom/src/pointerlock.ts
function addPointerlockChangeListener(doc, fn) {
return addDomEvent(doc, "pointerlockchange", fn, false);
}
function addPointerlockErrorListener(doc, fn) {
doc.addEventListener("pointerlockerror", fn, false);
return function cleanup() {
doc.removeEventListener("pointerlockerror", fn, false);
};
}
function requestPointerLock(doc, handlers = {}) {
const { onPointerLock, onPointerUnlock } = handlers;
const body = doc.body;
const supported = "pointerLockElement" in doc || "mozPointerLockElement" in doc;
const locked = !!doc.pointerLockElement;
function onPointerChange() {
if (locked)
onPointerLock == null ? void 0 : onPointerLock();
else
onPointerUnlock == null ? void 0 : onPointerUnlock();
}
function onPointerError(event) {
if (locked)
onPointerUnlock == null ? void 0 : onPointerUnlock();
console.error("PointerLock error occured:", event);
exit();
}
function exit() {
doc.exitPointerLock();
}
if (!supported)
return;
body.requestPointerLock();
const cleanup = pipe(addPointerlockChangeListener(doc, onPointerChange), addPointerlockErrorListener(doc, onPointerError));
return function dispose() {
if (!supported)
return;
cleanup();
exit();
};
}
// ../../utilities/number/src/number-format.ts
var nf = new Intl.NumberFormat("en-US", { style: "decimal" });
function formatter(n) {
return parseFloat(nf.format(n));
}
// ../../utilities/number/src/number.ts
function wrap(num, max) {
return (num % max + max) % max;
}
function round(v, t2) {
let num = valueOf(v);
const p = __pow(10, t2 != null ? t2 : 10);
num = Math.round(num * p) / p;
return t2 ? num.toFixed(t2) : v.toString();
}
function roundToPx(num) {
if (typeof window === "undefined")
return Math.round(num);
const dp = window.devicePixelRatio;
return Math.floor(num * dp + 0.5) / dp;
}
function clamp(v, o) {
return Math.min(Math.max(valueOf(v), o.min), o.max);
}
function countDecimals(v) {
var _a, _b;
return (_b = (_a = nf.formatToParts(v).find((p) => p.type === "fraction")) == null ? void 0 : _a.value.length) != null ? _b : 0;
}
var increment = (v, s) => formatter(valueOf(v) + s);
var decrement = (v, s) => formatter(valueOf(v) - s);
var multiply = (v, s) => formatter(valueOf(v) * s);
function valueOf(v) {
if (typeof v === "number")
return v;
const num = parseFloat(v.toString().replace(/[^\w.-]+/g, ""));
return !Number.isNaN(num) ? num : 0;
}
function getMaxPrecision(o) {
var _a;
const stepPrecision = countDecimals(o.step);
const val = valueOf(o.value);
const valuePrecision = Number.isNaN(val) ? stepPrecision : Math.max(countDecimals(val), stepPrecision);
return Math.max(valuePrecision, (_a = o.precision) != null ? _a : 0);
}
function roundToPrecision(v, o) {
return round(v, getMaxPrecision(__spreadProps(__spreadValues({}, o), { value: v })));
}
function isAtMax(v, o) {
const val = valueOf(v);
return val >= o.max;
}
function isAtMin(v, o) {
const val = valueOf(v);
return val <= o.min;
}
function isWithinRange(v, o) {
const val = valueOf(v);
return val >= o.min && val <= o.max;
}
// ../../utilities/rect/src/point.ts
var fallback = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 };
function getEventPoint(e, t2 = "page") {
const p = isTouchEvent(e) ? e.touches[0] || e.changedTouches[0] || fallback : e;
return { x: p[`${t2}X`], y: p[`${t2}Y`] };
}
// ../../types/src/prop-types.ts
function createNormalizer(fn) {
return { button: fn, label: fn, input: fn, output: fn, element: fn };
}
var normalizeProp = createNormalizer((v) => v);
// src/number-input.dom.ts
var dom = {
getDoc: (ctx) => {
var _a;
return (_a = ctx.doc) != null ? _a : document;
},
getWin: (ctx) => {
var _a;
return (_a = dom.getDoc(ctx).defaultView) != null ? _a : window;
},
getInputId: (ctx) => {
var _a, _b;
return (_b = (_a = ctx.ids) == null ? void 0 : _a.input) != null ? _b : `number-input-${ctx.uid}-input`;
},
getIncButtonId: (ctx) => {
var _a, _b;
return (_b = (_a = ctx.ids) == null ? void 0 : _a.incBtn) != null ? _b : `number-input-${ctx.uid}-inc-btn`;
},
getDecButtonId: (ctx) => {
var _a, _b;
return (_b = (_a = ctx.ids) == null ? void 0 : _a.decBtn) != null ? _b : `number-input-${ctx.uid}-dec-btn`;
},
getScrubberId: (ctx) => {
var _a, _b;
return (_b = (_a = ctx.ids) == null ? void 0 : _a.scrubber) != null ? _b : `number-input-${ctx.uid}-scrubber`;
},
getCursorId: (ctx) => `number-input-${ctx.uid}-cursor`,
getLabelId: (ctx) => {
var _a, _b;
return (_b = (_a = ctx.ids) == null ? void 0 : _a.label) != null ? _b : `number-input-${ctx.uid}-label`;
},
getRootId: (ctx) => {
var _a, _b;
return (_b = (_a = ctx.ids) == null ? void 0 : _a.root) != null ? _b : `number-input-${ctx.uid}-root`;
},
getInputEl: (ctx) => dom.getDoc(ctx).getElementById(dom.getInputId(ctx)),
getIncButtonEl: (ctx) => dom.getDoc(ctx).getElementById(dom.getIncButtonId(ctx)),
getDecButtonEl: (ctx) => dom.getDoc(ctx).getElementById(dom.getDecButtonId(ctx)),
getScrubberEl: (ctx) => dom.getDoc(ctx).getElementById(dom.getScrubberId(ctx)),
getCursorEl: (ctx) => dom.getDoc(ctx).getElementById(dom.getCursorId(ctx)),
getMousementValue(ctx, event) {
const x = roundToPx(event.movementX);
const y = roundToPx(event.movementY);
let hint = x > 0 ? "increment" : x < 0 ? "decrement" : null;
if (ctx.isRtl && hint === "increment")
hint = "decrement";
if (ctx.isRtl && hint === "decrement")
hint = "increment";
const point = {
x: ctx.scrubberCursorPoint.x + x,
y: ctx.scrubberCursorPoint.y + y
};
const win = dom.getWin(ctx);
const width = win.innerWidth;
const half = roundToPx(7.5);
point.x = wrap(point.x + half, width) - half;
return { hint, point };
},
createVirtualCursor(ctx) {
const doc = dom.getDoc(ctx);
const el = doc.createElement("div");
el.className = "scrubber--cursor";
el.id = dom.getCursorId(ctx);
Object.assign(el.style, {
width: "15px",
height: "15px",
position: "fixed",
pointerEvents: "none",
left: "0px",
top: "0px",
zIndex: MAX_Z_INDEX,
transform: ctx.scrubberCursorPoint ? `translate3d(${ctx.scrubberCursorPoint.x}px, ${ctx.scrubberCursorPoint.y}px, 0px)` : void 0,
willChange: "transform"
});
el.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);">

@@ -7,3 +415,1334 @@ <g transform="translate(2 3)">

</g>
</svg>`,e.body.appendChild(n)}};var x={isValidNumericEvent:(t,e)=>{var o,l;if(e.key==null)return!0;let n=e.ctrlKey||e.altKey||e.metaKey,i=e.key.length===1;return n||!i?!0:(l=(o=t.validateCharacter)==null?void 0:o.call(t,e.key))!=null?l:x.isFloatingPoint(e.key)},isFloatingPoint:t=>/^[Ee0-9+\-.]$/.test(t),sanitize:(t,e)=>{var n;return e.split("").filter((n=t.validateCharacter)!=null?n:x.isFloatingPoint).join("")},increment:(t,e)=>{let n=St(t.value,e!=null?e:t.step);return n=X(n,t),_(n,t)},decrement:(t,e)=>{let n=Ct(t.value,e!=null?e:t.step);return n=X(n,t),_(n,t)},clamp:t=>{let e=X(t.value,t);return _(e,t)},parse:(t,e)=>{var n,i;return(i=(n=t.parse)==null?void 0:n.call(t,e))!=null?i:e},format:(t,e)=>{var i,o;let n=e.toString();return(o=(i=t.format)==null?void 0:i.call(t,n))!=null?o:n},round:t=>_(t.value,t)};function kt(t,e,n=It){let i=t.hasTag("focus"),o=t.context.isOutOfRange||!!t.context.invalid,l=!!t.context.disabled,p=l||!t.context.canIncrement,g=l||!t.context.canDecrement,y=t.context.messages;return{isFocused:i,isInvalid:o,value:t.context.formattedValue,valueAsNumber:t.context.valueAsNumber,setValue(m){e({type:"SET_VALUE",value:m.toString()})},clearValue(){e({type:"SET_VALUE",value:""})},increment(){e("INCREMENT")},decrement(){e("DECREMENT")},setToMax(){e({type:"SET_VALUE",value:t.context.max})},setToMin(){e({type:"SET_VALUE",value:t.context.min})},focus(){V(()=>{var m;(m=v.getInputEl(t.context))==null||m.focus()})},rootProps:n.element({id:v.getRootId(t.context),"data-part":"root","data-disabled":I(l)}),labelProps:n.label({"data-part":"label","data-disabled":I(l),"data-invalid":I(o),id:v.getLabelId(t.context),htmlFor:v.getInputId(t.context)}),inputProps:n.input({"data-part":"input",name:t.context.name,id:v.getInputId(t.context),role:"spinbutton",value:t.context.formattedValue,pattern:t.context.pattern,inputMode:t.context.inputMode,"aria-invalid":o||void 0,"data-invalid":I(o),disabled:l,"data-disabled":I(l),readOnly:!!t.context.readonly,autoComplete:"off",autoCorrect:"off",spellCheck:"false",type:"text","aria-roledescription":"number field","aria-valuemin":t.context.min,"aria-valuemax":t.context.max,"aria-valuenow":isNaN(t.context.valueAsNumber)?void 0:t.context.valueAsNumber,"aria-valuetext":t.context.valueText,onFocus(){e("FOCUS")},onBlur(){e("BLUR")},onChange(m){K(m).isComposing||e({type:"CHANGE",target:m.currentTarget,hint:"set"})},onKeyDown(m){if(K(m).isComposing)return;x.isValidNumericEvent(t.context,m)||m.preventDefault();let E=At(gt(m),t.context.step),d={ArrowUp(){e({type:"ARROW_UP",step:E})},ArrowDown(){e({type:"ARROW_DOWN",step:E})},Home(){e("HOME")},End(){e("END")}}[m.key];d&&(d(m),m.preventDefault())}}),decrementButtonProps:n.button({"data-part":"spin-button",id:v.getDecButtonId(t.context),disabled:g,"data-disabled":I(g),"aria-label":y.decrementLabel,type:"button",tabIndex:-1,"aria-controls":v.getInputId(t.context),onPointerDown(m){g||(e({type:"PRESS_DOWN",hint:"decrement"}),m.preventDefault())},onPointerUp(){e({type:"PRESS_UP",hint:"decrement"})},onPointerLeave(){g||e({type:"PRESS_UP",hint:"decrement"})}}),incrementButtonProps:n.button({"data-part":"spin-button",id:v.getIncButtonId(t.context),disabled:p,"data-disabled":I(p),"aria-label":y.incrementLabel,type:"button",tabIndex:-1,"aria-controls":v.getInputId(t.context),onPointerDown(m){m.preventDefault(),!p&&e({type:"PRESS_DOWN",hint:"increment"})},onPointerUp(){e({type:"PRESS_UP",hint:"increment"})},onPointerLeave(){e({type:"PRESS_UP",hint:"increment"})}}),scrubberProps:n.element({"data-disabled":I(l),"data-part":"scrubber",id:v.getScrubberId(t.context),role:"presentation",onMouseDown(m){if(l)return;let w=K(m);m.preventDefault();let E=Tt(w);E.x=E.x-O(7.5),E.y=E.y-O(7.5),e({type:"PRESS_DOWN_SCRUBBER",point:E})},style:{cursor:l?void 0:"ew-resize"}})}}var Q={},gn=Symbol(),yn=Symbol(),Se=Symbol(),Rt=Object.getPrototypeOf,at=new WeakMap,Ce=t=>t&&(at.has(t)?at.get(t):Rt(t)===Object.prototype||Rt(t)===Array.prototype),Ae=t=>Ce(t)&&t[Se]||null,Ot=(t,e=!0)=>{at.set(t,e)},Ft=Symbol(),M=Symbol(),G=Symbol(),Pe=Symbol(),j=Symbol(),Nt=Symbol(),ut=new WeakSet;function Z(t){return ut.add(t),t}var J=t=>typeof t=="object"&&t!==null,Me=t=>J(t)&&!ut.has(t)&&(Array.isArray(t)||!(Symbol.iterator in t))&&!(t instanceof WeakMap)&&!(t instanceof WeakSet)&&!(t instanceof Error)&&!(t instanceof Number)&&!(t instanceof Date)&&!(t instanceof String)&&!(t instanceof RegExp)&&!(t instanceof ArrayBuffer),Dt=new WeakMap,Wt=1,Bt=new WeakMap;function ct(t={}){if(!J(t))throw new Error("object required");let e=Dt.get(t);if(e)return e;let n=Wt,i=new Set,o=(c,d=++Wt)=>{n!==d&&(n=d,i.forEach(r=>r(c,d)))},l=new Map,p=c=>{let d=l.get(c);return d||(d=(r,s)=>{let a=[...r];a[1]=[c,...a[1]],o(a,s)},l.set(c,d)),d},g=c=>{let d=l.get(c);return l.delete(c),d},y=(c,d)=>{let r=Bt.get(d);if(r?.[0]===n)return r[1];let s=Array.isArray(c)?[]:Object.create(Object.getPrototypeOf(c));return Ot(s,!0),Bt.set(d,[n,s]),Reflect.ownKeys(c).forEach(a=>{let u=Reflect.get(c,a,d);if(ut.has(u))Ot(u,!1),s[a]=u;else if(u instanceof Promise)if(j in u)s[a]=u[j];else{let f=u[Nt]||u;Object.defineProperty(s,a,{get(){if(j in u)return u[j];throw f}})}else u?.[M]?s[a]=u[G]:s[a]=u}),Object.freeze(s),s},m=Array.isArray(t)?[]:Object.create(Object.getPrototypeOf(t)),w={get(c,d,r){return d===Ft?n:d===M?i:d===G?y(c,r):d===Pe?w:Reflect.get(c,d,r)},deleteProperty(c,d){let r=Reflect.get(c,d),s=r?.[M];s&&s.delete(g(d));let a=Reflect.deleteProperty(c,d);return a&&o(["delete",[d],r]),a},is:Object.is,canProxy:Me,set(c,d,r,s){var a;let u=Reflect.get(c,d,s);if(this.is(u,r))return!0;let f=u?.[M];f&&f.delete(g(d)),J(r)&&(r=Ae(r)||r);let h;return(a=Object.getOwnPropertyDescriptor(c,d))!=null&&a.set?h=r:r instanceof Promise?h=r.then(b=>(h[j]=b,o(["resolve",[d],b]),b)).catch(b=>{h[Nt]=b,o(["reject",[d],b])}):r?.[M]?(h=r,h[M].add(p(d))):this.canProxy(r)?(h=ct(r),h[M].add(p(d))):h=r,Reflect.set(c,d,h,s),o(["set",[d],r,u]),!0}},E=new Proxy(m,w);return Dt.set(t,E),Reflect.ownKeys(t).forEach(c=>{let d=Object.getOwnPropertyDescriptor(t,c);d.get||d.set?Object.defineProperty(m,c,d):E[c]=t[c]}),E}function Ht(t){return J(t)?t[Ft]:void 0}function dt(t,e,n){(Q.env&&Q.env.MODE)!=="production"&&!t?.[M]&&console.warn("Please use proxy object");let i,o=[],l=p=>{if(o.push(p),n){e(o.splice(0));return}i||(i=Promise.resolve().then(()=>{i=void 0,e(o.splice(0))}))};return t[M].add(l),()=>{t[M].delete(l)}}function Le(t){return(Q.env&&Q.env.MODE)!=="production"&&!t?.[G]&&console.warn("Please use proxy object"),t[G]}function Te(t){for(;t.length>0;)t.pop();return t}var Vt=(t,...e)=>(typeof t=="function"?t(...e):t)??void 0,L=t=>t,_t=()=>{};var Ie=(()=>{let t=0;return()=>(t++,t.toString(36))})(),D=t=>Array.isArray(t),U=t=>!(t==null||typeof t!="object"||D(t)),ke=t=>typeof t=="number"&&!Number.isNaN(t),S=t=>typeof t=="string",W=t=>typeof t=="function";function it(...t){let e=t.length===1?t[0]:t[1],n=t.length===2?t[0]:!0}function ot(...t){let e=t.length===1?t[0]:t[1],n=t.length===2?t[0]:!0}function Ut(t){return{predicate:e=>(n,i)=>{var o;return(o=t.find(l=>{var p;return l.guard=l.guard||(()=>!0),S(l.guard)?!!((p=e[l.guard])!=null&&p.call(e,n,i)):zt(l.guard)?l.guard.predicate(e??{})(n,i):l.guard(n,i)}))==null?void 0:o.actions}}}function zt(t){return U(t)&&t.predicate!=null}function st(t,e){return(n,i)=>zt(t)?t.predicate(e??{})(n,i):t}function Re(...t){return{predicate:e=>(n,i)=>t.map(o=>{var l;return S(o)?!!((l=e[o])!=null&&l.call(e,n,i)):W(o)?o(n,i):o.predicate(e)(n,i)}).some(Boolean)}}function Oe(...t){return{predicate:e=>(n,i)=>t.map(o=>{var l;return S(o)?!!((l=e[o])!=null&&l.call(e,n,i)):W(o)?o(n,i):o.predicate(e)(n,i)}).every(Boolean)}}function Ne(t){return{predicate:e=>(n,i)=>{var o;return S(t)?!((o=e[t])!=null&&o.call(e,n,i)):W(t)?!t(n,i):!t.predicate(e)(n,i)}}}var Yt={or:Re,and:Oe,not:Ne};function De(t){return U(t)&&t.predicate!=null}var We=()=>!0;function Kt(t,e){return t=t??We,(n,i)=>{if(S(t)){let o=e?.[t];return W(o)?o(n,i):o}return De(t)?t.predicate(e??{})(n,i):t?.(n,i)}}function F(t){var e,n,i;if(Array.isArray(t)){for(n=Array(e=t.length);e--;)n[e]=(i=t[e])&&typeof i=="object"?F(i):i;return n}if(Object.prototype.toString.call(t)==="[object Object]"){n={};for(e in t)e==="__proto__"?Object.defineProperty(n,e,{value:F(t[e]),configurable:!0,enumerable:!0,writable:!0}):n[e]=(i=t[e])&&typeof i=="object"?F(i):i;return n}return t}function jt(t,e,n,i){return dt(t,o=>{o.some(l=>l[1][0]===e)&&n(t[e])},i)}var bn=Symbol(),N=new WeakMap,z=new WeakMap,Xt=(t,e)=>{let n=N.get(t);n&&(n[0].forEach(i=>{let{d:o}=i;t!==o&&Xt(o)}),++n[2],e&&n[3].add(e))},Be=(t,e)=>{let n=N.get(t);return n?.[2]?(n[3].add(e),!0):!1},lt=t=>{let e=N.get(t);e&&(--e[2],e[2]||(e[3].forEach(n=>n()),e[3].clear()),e[0].forEach(n=>{let{d:i}=n;t!==i&&lt(i)}))},He=t=>{let{s:e,d:n}=t,i=z.get(n);i||(i=[new Set],z.set(t.d,i)),i[0].add(t);let o=N.get(e);if(!o){let l=new Set,p=dt(e,g=>{l.forEach(y=>{let{d:m,c:w,n:E,i:c}=y;e===m&&g.every(d=>d[1].length===1&&c.includes(d[1][0]))||y.p||(Xt(e,w),E?lt(e):y.p=Promise.resolve().then(()=>{delete y.p,lt(e)}))})},!0);o=[l,p,0,new Set],N.set(e,o)}o[0].add(t)},$t=t=>{let{s:e,d:n}=t,i=z.get(n);i?.[0].delete(t),i?.[0].size===0&&z.delete(n);let o=N.get(e);if(o){let[l,p]=o;l.delete(t),l.size||(p(),N.delete(e))}},Ve=t=>{let e=z.get(t);return e?Array.from(e[0]):[]};function _e(t,e){let n=e?.proxy||ct({}),i=!!e?.sync,o=Object.keys(t);return o.forEach(l=>{if(Object.getOwnPropertyDescriptor(n,l))throw new Error("object property already defined");let p=t[l],g=null,y=()=>{if(g&&(Array.from(g).map(([c])=>Be(c,y)).some(c=>c)||Array.from(g).every(([c,d])=>Ht(c)===d.v)))return;let m=new Map,w=p(c=>(m.set(c,{v:Ht(c)}),c)),E=()=>{m.forEach((c,d)=>{var r;let s=(r=g?.get(d))==null?void 0:r.s;if(s)c.s=s;else{let a={s:d,d:n,k:l,c:y,n:i,i:o};He(a),c.s=a}}),g?.forEach((c,d)=>{!m.has(d)&&c.s&&$t(c.s)}),g=m};w instanceof Promise?w.finally(E):E(),n[l]=w};y()}),n}function je(t,e){let n=e?.delete?new Set:null;Ve(t).forEach(i=>{let{k:o}=i;(!e?.keys||e.keys.includes(o))&&($t(i),n&&n.add(o))}),n&&n.forEach(i=>{delete t[i]})}function Fe(t){var e;let n=ct({value:"",previousValue:"",event:L({}),context:(e=t.context)!=null?e:L({}),done:!1,tags:[],hasTag(i){return this.tags.includes(i)},matches(...i){return i.includes(this.value)},can(i){return L(this).nextEvents.includes(i)},get nextEvents(){var i,o,l,p;let g=(l=(o=(i=t.states)==null?void 0:i[this.value])==null?void 0:o.on)!=null?l:{},y=(p=t?.on)!=null?p:{};return Object.keys({...g,...y})},get changed(){return this.event.value==="machine.init"||!this.previousValue?!1:this.value!==this.previousValue}});return L(n)}function $(t,e){return(n,i)=>{if(ke(t))return t;if(W(t))return t(n,i);if(S(t)){let o=Number.parseFloat(t);if(!Number.isNaN(o))return o;if(e){let l=e?.[t];if(l==null){let p=`[machine] Cannot determine delay for ${t}. It doesn't exist in options.delays`;throw new Error(p)}return W(l)?l(n,i):l}}}}function A(t){return S(t)?{type:t}:t}function k(t){return t?D(t)?t:[t]:[]}function qt(t){return S(t)?{target:t}:t}function Ue(t,e){return(n,i)=>k(t).map(qt).find(o=>{var l;let p=Kt(o.guard,e)(n,i);return(l=p??o.target)!=null?l:o.actions})}function ze(t,e){let n=S(t)?qt(t):t,i=o=>(o.actions&&!o.target&&e&&(o.target=e),o);if(D(n))return n.map(i);if(U(n))return i(L(n))}var q=class{constructor(t,e){this.config=t,this.status="Not Started",this.type="machine",this.activityEvents=new Map,this.delayedEvents=new Map,this.stateListeners=new Set,this.eventListeners=new Set,this.doneListeners=new Set,this.contextWatchers=new Set,this.removeStateListener=_t,this.removeEventListener=_t,this.children=new Map,this.start=r=>{if(this.status==="Running")return this;this.status="Running";let s=A("machine.init");if(r){let f=U(r)?r:{context:this.config.context,value:r};this.setState(f.value),this.setContext(f.context)}let a={target:r?void 0:this.config.initial},u=this.getNextStateInfo(a,s);return u.target=L(u.target||a.target),this.initialState=u,this.performStateChangeEffects(u.target,u,s),this.removeStateListener=dt(this.state,()=>{this.stateListeners.forEach(f=>{f(this.stateSnapshot)})},this.sync),this.removeEventListener=jt(this.state,"event",f=>{this.config.onEvent&&this.executeActions(this.config.onEvent,f);for(let h of this.eventListeners)h(f)}),this.setupContextWatchers(),this.executeActivities(A("machine.start"),k(this.config.activities),"machine.start"),this.executeActions(this.config.entry,A("machine.start")),this},this.setupContextWatchers=()=>{var r;for(let[s,a]of Object.entries((r=this.config.watch)!=null?r:{}))this.contextWatchers.add(jt(this.state.context,s,()=>{this.executeActions(a,this.state.event)}))},this.setupComputed=()=>{var r;let s=L((r=this.config.computed)!=null?r:{}),a=Object.fromEntries(Object.entries(s).map(([u,f])=>[u,h=>f(h(this.state.context))]));_e(a,{proxy:this.state.context})},this.detachComputed=()=>{je(this.state.context,{delete:!0})},this.stop=()=>{if(this.status!=="Stopped")return this.setState(null),this.setEvent("machine.stop"),this.config.context&&this.setContext(this.config.context),this.stopStateListeners(),this.stopChildren(),this.stopActivities(),this.stopDelayedEvents(),this.stopContextWatchers(),this.stopEventListeners(),this.detachComputed(),this.status="Stopped",this.executeActions(this.config.exit,A("machine.stop")),this},this.stopEventListeners=()=>{this.eventListeners.clear(),this.removeEventListener()},this.stopStateListeners=()=>{this.removeStateListener(),this.stateListeners.clear()},this.stopContextWatchers=()=>{this.contextWatchers.forEach(r=>r()),this.contextWatchers.clear()},this.stopDelayedEvents=()=>{this.delayedEvents.forEach(r=>{r.forEach(s=>s())}),this.delayedEvents.clear()},this.stopActivities=r=>{var s,a;r?((s=this.activityEvents.get(r))==null||s.forEach(u=>u()),(a=this.activityEvents.get(r))==null||a.clear(),this.activityEvents.delete(r)):(this.activityEvents.forEach(u=>{u.forEach(f=>f()),u.clear()}),this.activityEvents.clear())},this.sendChild=(r,s)=>{let a=A(r),u=Vt(s,this.contextSnapshot),f=this.children.get(u);f||ot(`[machine/send-child] Cannot send '${a.type}' event to unknown child`),f.send(a)},this.stopChild=r=>{this.children.has(r)||ot("[machine/stop-child] Cannot stop unknown child"),this.children.get(r).stop(),this.children.delete(r)},this.removeChild=r=>{this.children.delete(r)},this.stopChildren=()=>{this.children.forEach(r=>r.stop()),this.children.clear()},this.setParent=r=>{this.parent=r},this.spawn=(r,s)=>{let a=Vt(r);return s&&(a.id=s),a.type="machine.actor",a.setParent(this),this.children.set(a.id,L(a)),a.onDone(()=>{this.removeChild(a.id)}).start(),L(Z(a))},this.addActivityCleanup=(r,s)=>{var a;!r||(this.activityEvents.has(r)?(a=this.activityEvents.get(r))==null||a.add(s):this.activityEvents.set(r,new Set([s])))},this.setState=r=>{this.state.previousValue=this.state.value,this.state.value=r;let s=this.getStateNode(r);r==null?Te(this.state.tags):this.state.tags=k(s?.tags)},this.setContext=r=>{for(let s in r)this.state.context[s]=r[s]},this.withContext=r=>{this.detachComputed();let s={...this.config.context,...r};return new q({...this.config,context:s},this.options)},this.withOptions=r=>(this.detachComputed(),new q(this.config,{...this.options,...r})),this.setActions=r=>{this.actionMap={...this.actionMap,...r}},this.clone=()=>(this.detachComputed(),new q(this.config,this.options)),this.getStateNode=r=>{var s;if(r)return(s=this.config.states)==null?void 0:s[r]},this.getNextStateInfo=(r,s)=>{var a;let u=this.determineTransition(r,s),f=(a=u?.target)!=null?a:this.state.value,h=this.getStateNode(f);return{transition:u,stateNode:h,target:f}},this.getActionFromDelayedTransition=r=>{let s=A("machine.after"),a=$(r.delay,this.delayMap)(this.contextSnapshot,s),u;return{entry:()=>{u=globalThis.setTimeout(()=>{let f=this.state.value,h=this.getNextStateInfo(r,s);this.performStateChangeEffects(f,h,s)},a)},exit:()=>{globalThis.clearTimeout(u)}}},this.getDelayedEventActions=r=>{let s=this.getStateNode(r),a=A("machine.after");if(!s||!s.after)return;let u=[],f=[];if(D(s.after)){let h=this.determineTransition(s.after,a);if(!h)return;let b=this.getActionFromDelayedTransition(h);u.push(b.entry),f.push(b.exit)}else if(U(s.after))for(let h in s.after){let b=s.after[h],C={};if(D(b)){let H=this.determineTransition(b,a);H&&(C=H)}else S(b)?C={target:b,delay:h}:C={...b,delay:h};let B=this.getActionFromDelayedTransition(C);u.push(B.entry),f.push(B.exit)}return{entries:u,exits:f}},this.executeActions=(r,s)=>{var a;let u=st(r,this.guardMap)(this.contextSnapshot,s);for(let f of k(u)){let h=S(f)?(a=this.actionMap)==null?void 0:a[f]:f;it(S(f)&&!h,`[machine/exec-action] No implementation found for action: \`${f}\``),h?.(this.state.context,s,this.meta)}},this.executeActivities=(r,s,a)=>{var u;for(let f of s){let h=S(f)?(u=this.activityMap)==null?void 0:u[f]:f;if(!h){it(`[machine/exec-activity] No implementation found for activity: \`${f}\``);continue}let b=h(this.state.context,r,this.meta);b&&this.addActivityCleanup(a??this.state.value,b)}},this.createEveryActivities=(r,s)=>{if(!r)return;let a=A("machine.every");if(D(r)){let u=k(r).find(h=>{let b=$(h.delay,this.delayMap);h.delay=b(this.contextSnapshot,a);let C=Kt(h.guard,this.guardMap)(this.contextSnapshot,a);return C??h.delay});if(!u)return;let f=$(u.delay,this.delayMap)(this.contextSnapshot,a);s(()=>{let h=globalThis.setInterval(()=>{this.executeActions(u.actions,a)},f);return()=>{globalThis.clearInterval(h)}})}else for(let u in r){let f=r?.[u],h=$(u,this.delayMap)(this.contextSnapshot,a);s(()=>{let b=globalThis.setInterval(()=>{this.executeActions(f,a)},h);return()=>{globalThis.clearInterval(b)}})}},this.setEvent=r=>{this.state.event=Z(A(r))},this.performExitEffects=(r,s)=>{let a=this.state.value,u=r?this.getStateNode(r):void 0;this.stopActivities(a);let f=st(u?.exit,this.guardMap)(this.contextSnapshot,s),h=k(f),b=this.delayedEvents.get(a);b&&h.push(...b),this.executeActions(h,s),this.eventListeners.clear()},this.performEntryEffects=(r,s)=>{let a=this.getStateNode(r),u=k(a?.activities);this.createEveryActivities(a?.every,C=>{u.unshift(C)}),u.length>0&&this.executeActivities(s,u);let f=st(a?.entry,this.guardMap)(this.contextSnapshot,s),h=k(f),b=this.getDelayedEventActions(r);a?.after&&b&&(this.delayedEvents.set(r,b?.exits),h.push(...b.entries)),this.executeActions(h,s),a?.type==="final"&&(this.state.done=!0,this.doneListeners.forEach(C=>{C(this.stateSnapshot)}),this.stop())},this.performTransitionEffects=(r,s)=>{let a=this.determineTransition(r,s);this.executeActions(a?.actions,s)},this.performStateChangeEffects=(r,s,a)=>{var u,f;this.setEvent(a),s.target=(f=(u=s.target)!=null?u:this.state.value)!=null?f:void 0;let h=s.target&&s.target!==this.state.value;h&&this.performExitEffects(r,a),this.performTransitionEffects(s?.transition,a),this.setState(s.target),h&&this.performEntryEffects(s.target,a)},this.determineTransition=(r,s)=>{let a=Ue(r,this.guardMap);return a?.(this.contextSnapshot,s)},this.sendParent=r=>{var s;this.parent||ot("[machine/send-parent] Cannot send event to an unknown parent");let a=A(r);(s=this.parent)==null||s.send(a)},this.send=r=>{let s=A(r);this.transition(this.state.value,s)},this.transition=(r,s)=>{var a,u,f;let h=S(r)?this.getStateNode(r):r?.stateNode,b=A(s);if(!h&&!this.config.on){let te=this.status==="Stopped"?"[machine/transition] Cannot transition a stopped machine":"[machine/transition] State does not have a definition";it(te);return}let C=(f=(a=h?.on)==null?void 0:a[b.type])!=null?f:(u=this.config.on)==null?void 0:u[b.type],B=ze(C,this.state.value);if(!B)return;let H=this.getNextStateInfo(B,b);return this.performStateChangeEffects(this.state.value,H,b),H.stateNode},this.subscribe=r=>(this.stateListeners.add(r),this.status==="Running"&&r(this.stateSnapshot),()=>{this.stateListeners.delete(r)}),this.onDone=r=>(this.doneListeners.add(r),this),this.onTransition=r=>(this.stateListeners.add(r),this.status==="Running"&&r(this.stateSnapshot),this),this.onEvent=r=>(r(this.state.event),this.eventListeners.add(r),this);var n,i,o,l,p,g,y,m,w,E,c;this.options=F(e),this.id=(n=t.id)!=null?n:`machine-${Ie()}`,this.guardMap=(o=(i=this.options)==null?void 0:i.guards)!=null?o:{},this.actionMap=(p=(l=this.options)==null?void 0:l.actions)!=null?p:{},this.delayMap=(y=(g=this.options)==null?void 0:g.delays)!=null?y:{},this.activityMap=(w=(m=this.options)==null?void 0:m.activities)!=null?w:{},this.sync=(c=(E=this.options)==null?void 0:E.sync)!=null?c:!1,this.state=Fe(F(t)),this.setupComputed();let d=A("machine.created");this.executeActions(t?.created,d)}get stateSnapshot(){return L(Le(this.state))}get contextSnapshot(){return this.stateSnapshot.context}get self(){let t=this;return{id:this.id,send:this.send.bind(this),sendParent:this.sendParent.bind(this),sendChild:this.sendChild.bind(this),stop:this.stop.bind(this),stopChild:this.stopChild.bind(this),spawn:this.spawn.bind(this),get state(){return t.stateSnapshot}}}get meta(){return{state:this.stateSnapshot,guards:this.guardMap,send:this.send.bind(this),listen:this.onEvent.bind(this),self:this.self,getState:()=>this.stateSnapshot}}},Gt=(t,e)=>new q(t,e);var Zt=(...t)=>e=>t.reduce((n,i)=>i(n),e);var xn=(()=>{let t=0;return()=>(t++,t.toString(36))})();var Ye=t=>Jt()&&t.test(navigator.userAgent);var Jt=()=>typeof window<"u";var tt=()=>Ye(/^((?!chrome|android).)*safari/i);var et=()=>Jt()&&window.onpointerdown===null;var{not:ht,and:ft}=Yt,Qt=Gt({id:"number-input",initial:"unknown",context:{uid:"",dir:"ltr",focusInputOnChange:!0,clampValueOnBlur:!0,allowOverflow:!1,inputMode:"decimal",pattern:"[0-9]*(.[0-9]+)?",hint:null,value:"",step:1,min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,precision:0,inputSelection:null,scrubberCursorPoint:null,invalid:!1,messages:{incrementLabel:"increment value",decrementLabel:"decrease value"}},computed:{isRtl:t=>t.dir==="rtl",valueAsNumber:t=>P(t.value),isAtMin:t=>Mt(t.value,t),isAtMax:t=>Pt(t.value,t),isOutOfRange:t=>!Lt(t.value,t),canIncrement:t=>t.allowOverflow||!t.isAtMax,canDecrement:t=>t.allowOverflow||!t.isAtMin,valueText:t=>{var e,n;return(n=(e=t.messages).valueText)==null?void 0:n.call(e,t.value)},formattedValue:t=>{var e,n;return(n=(e=t.format)==null?void 0:e.call(t,t.value).toString())!=null?n:t.value}},watch:{value:["invokeOnChange"],isOutOfRange:["invokeOnInvalid"]},entry:["syncInputValue"],on:{SET_VALUE:{actions:["setValue","setHintToSet"]},INCREMENT:{actions:["increment"]},DECREMENT:{actions:["decrement"]}},states:{unknown:{on:{SETUP:{target:"idle",actions:"setupDocument"}}},idle:{on:{PRESS_DOWN:{target:"before:spin",actions:["focusInput","setHint"]},PRESS_DOWN_SCRUBBER:{target:"scrubbing",actions:["focusInput","setHint","setCursorPoint"]},FOCUS:"focused"}},focused:{tags:["focus"],activities:"attachWheelListener",on:{PRESS_DOWN:{target:"before:spin",actions:["focusInput","setHint"]},PRESS_DOWN_SCRUBBER:{target:"scrubbing",actions:["focusInput","setHint","setCursorPoint"]},ARROW_UP:{actions:"increment"},ARROW_DOWN:{actions:"decrement"},HOME:{actions:"setToMin"},END:{actions:"setToMax"},CHANGE:{actions:["setValue","setSelectionRange","setHint"]},BLUR:[{guard:"isInvalidExponential",target:"idle",actions:["clearValue","clearHint"]},{guard:ft("clampOnBlur",ht("isInRange")),target:"idle",actions:["clampValue","clearHint"]},{actions:["roundValue"]}]}},"before:spin":{tags:["focus"],entry:Ut([{guard:"isIncrementHint",actions:"increment"},{guard:"isDecrementHint",actions:"decrement"}]),after:{CHANGE_DELAY:{target:"spinning",guard:"isInRange"}},on:{PRESS_UP:{target:"focused",actions:["clearHint","restoreSelection"]}}},spinning:{tags:["focus"],activities:"trackButtonDisabled",every:[{delay:"CHANGE_INTERVAL",guard:ft(ht("isAtMin"),"isIncrementHint"),actions:"increment"},{delay:"CHANGE_INTERVAL",guard:ft(ht("isAtMax"),"isDecrementHint"),actions:"decrement"}],on:{PRESS_UP:{target:"focused",actions:["clearHint","restoreSelection"]}}},scrubbing:{tags:["focus"],entry:["addCustomCursor","disableTextSelection"],exit:["removeCustomCursor","restoreTextSelection"],activities:["activatePointerLock","trackMousemove"],on:{POINTER_UP_SCRUBBER:{target:"focused",actions:["clearCursorPoint"]},POINTER_MOVE_SCRUBBER:[{guard:"isIncrementHint",actions:["increment","setCursorPoint","updateCursor"]},{guard:"isDecrementHint",actions:["decrement","setCursorPoint","updateCursor"]}]}}}},{delays:{CHANGE_INTERVAL:50,CHANGE_DELAY:300},guards:{clampOnBlur:t=>!!t.clampValueOnBlur,isAtMin:t=>t.isAtMin,isAtMax:t=>t.isAtMax,isInRange:t=>!t.isOutOfRange,isDecrementHint:(t,e)=>{var n;return((n=e.hint)!=null?n:t.hint)==="decrement"},isIncrementHint:(t,e)=>{var n;return((n=e.hint)!=null?n:t.hint)==="increment"},isInvalidExponential:t=>t.value.toString().startsWith("e")},activities:{trackButtonDisabled(t,e,{send:n}){let i=null;return t.hint==="increment"&&(i=v.getIncButtonEl(t)),t.hint==="decrement"&&(i=v.getDecButtonEl(t)),yt(i,"disabled",function(){n("PRESS_UP")})},attachWheelListener(t){let e=[];return e.push(V(()=>{let n=v.getInputEl(t);if(!n)return;function i(o){let l=v.getDoc(t).activeElement===n;if(!t.allowMouseWheel||!l)return;o.preventDefault();let p=Math.sign(o.deltaY)*-1;p===1?t.value=x.increment(t):p===-1&&(t.value=x.decrement(t))}e.push(Y(n,"wheel",i,{passive:!1}))})),()=>e.forEach(n=>n())},activatePointerLock(t){if(!(tt()||!et()))return bt(v.getDoc(t))},trackMousemove(t,e,{send:n}){let i=v.getDoc(t);function o(p){if(!t.scrubberCursorPoint)return;let g=v.getMousementValue(t,p);!g.hint||n({type:"POINTER_MOVE_SCRUBBER",hint:g.hint,point:g.point})}function l(){n("POINTER_UP_SCRUBBER")}return Zt(Y(i,"mousemove",o,!1),Y(i,"mouseup",l,!1))}},actions:{setupDocument:(t,e)=>{e.doc&&(t.doc=Z(e.doc)),t.uid=e.id},focusInput(t){if(!t.focusInputOnChange)return;let e=v.getInputEl(t);V(()=>e==null?void 0:e.focus())},increment(t,e){t.value=x.increment(t,e.step)},decrement(t,e){t.value=x.decrement(t,e.step)},clampValue(t){t.value=x.clamp(t)},roundValue(t){t.value=x.round(t)},setValue(t,e){var i,o;let n=(o=(i=e.target)==null?void 0:i.value)!=null?o:e.value;t.value=x.sanitize(t,x.parse(t,n))},clearValue(t){t.value=""},setToMax(t){t.value=t.max.toString()},setToMin(t){t.value=t.min.toString()},setHint(t,e){t.hint=e.hint},clearHint(t){t.hint=null},setHintToSet(t){t.hint="set"},setSelectionRange(t,e){t.inputSelection={start:e.target.selectionStart,end:e.target.selectionEnd}},restoreSelection(t){var n,i,o;let e=v.getInputEl(t);!e||!t.inputSelection||(e.selectionStart=(i=t.inputSelection.start)!=null?i:(n=e.value)==null?void 0:n.length,e.selectionEnd=(o=t.inputSelection.end)!=null?o:e.selectionStart)},invokeOnChange(t){var e;(e=t.onChange)==null||e.call(t,{value:t.value,valueAsNumber:t.valueAsNumber})},invokeOnInvalid(t){var n;if(!t.isOutOfRange)return;let e=t.valueAsNumber>t.max?"rangeOverflow":"rangeUnderflow";(n=t.onInvalid)==null||n.call(t,{reason:e,value:t.formattedValue,valueAsNumber:t.valueAsNumber})},syncInputValue(t){let e=v.getInputEl(t);if(!e||e.value==t.value)return;let n=x.parse(t,e.value);t.value=x.sanitize(t,n)},setCursorPoint(t,e){t.scrubberCursorPoint=e.point},clearCursorPoint(t){t.scrubberCursorPoint=null},updateCursor(t){let e=v.getCursorEl(t);!e||!t.scrubberCursorPoint||(e.style.transform=`translate3d(${t.scrubberCursorPoint.x}px, ${t.scrubberCursorPoint.y}px, 0px)`)},addCustomCursor(t){tt()||!et()||v.createVirtualCursor(t)},removeCustomCursor(t){if(tt()||!et())return;let n=v.getDoc(t).getElementById(v.getCursorId(t));n==null||n.remove()},disableTextSelection(t){let e=v.getDoc(t);e.body.style.pointerEvents="none",e.documentElement.style.userSelect="none",e.documentElement.style.cursor="ew-resize"},restoreTextSelection(t){let e=v.getDoc(t);e.body.style.pointerEvents="",e.documentElement.style.userSelect="",e.documentElement.style.cursor=""}}});
</svg>`;
doc.body.appendChild(el);
}
};
// src/number-input.utils.ts
var utils = {
isValidNumericEvent: (ctx, event) => {
var _a, _b;
if (event.key == null)
return true;
const isModifierKey = event.ctrlKey || event.altKey || event.metaKey;
const isSingleCharacterKey = event.key.length === 1;
if (isModifierKey || !isSingleCharacterKey)
return true;
return (_b = (_a = ctx.validateCharacter) == null ? void 0 : _a.call(ctx, event.key)) != null ? _b : utils.isFloatingPoint(event.key);
},
isFloatingPoint: (v) => /^[Ee0-9+\-.]$/.test(v),
sanitize: (ctx, value) => {
var _a;
return value.split("").filter((_a = ctx.validateCharacter) != null ? _a : utils.isFloatingPoint).join("");
},
increment: (ctx, step) => {
let value = increment(ctx.value, step != null ? step : ctx.step);
value = clamp(value, ctx);
return roundToPrecision(value, ctx);
},
decrement: (ctx, step) => {
let value = decrement(ctx.value, step != null ? step : ctx.step);
value = clamp(value, ctx);
return roundToPrecision(value, ctx);
},
clamp: (ctx) => {
let value = clamp(ctx.value, ctx);
return roundToPrecision(value, ctx);
},
parse: (ctx, value) => {
var _a, _b;
return (_b = (_a = ctx.parse) == null ? void 0 : _a.call(ctx, value)) != null ? _b : value;
},
format: (ctx, value) => {
var _a, _b;
const _val = value.toString();
return (_b = (_a = ctx.format) == null ? void 0 : _a.call(ctx, _val)) != null ? _b : _val;
},
round: (ctx) => {
return roundToPrecision(ctx.value, ctx);
}
};
// src/number-input.connect.ts
function connect(state, send, normalize = normalizeProp) {
const isFocused = state.hasTag("focus");
const isInvalid = state.context.isOutOfRange || !!state.context.invalid;
const isDisabled = !!state.context.disabled;
const isIncrementDisabled = isDisabled || !state.context.canIncrement;
const isDecrementDisabled = isDisabled || !state.context.canDecrement;
const messages = state.context.messages;
return {
isFocused,
isInvalid,
value: state.context.formattedValue,
valueAsNumber: state.context.valueAsNumber,
setValue(value) {
send({ type: "SET_VALUE", value: value.toString() });
},
clearValue() {
send({ type: "SET_VALUE", value: "" });
},
increment() {
send("INCREMENT");
},
decrement() {
send("DECREMENT");
},
setToMax() {
send({ type: "SET_VALUE", value: state.context.max });
},
setToMin() {
send({ type: "SET_VALUE", value: state.context.min });
},
focus() {
nextTick(() => {
var _a;
(_a = dom.getInputEl(state.context)) == null ? void 0 : _a.focus();
});
},
rootProps: normalize.element({
id: dom.getRootId(state.context),
"data-part": "root",
"data-disabled": dataAttr(isDisabled)
}),
labelProps: normalize.label({
"data-part": "label",
"data-disabled": dataAttr(isDisabled),
"data-invalid": dataAttr(isInvalid),
id: dom.getLabelId(state.context),
htmlFor: dom.getInputId(state.context)
}),
inputProps: normalize.input({
"data-part": "input",
name: state.context.name,
id: dom.getInputId(state.context),
role: "spinbutton",
value: state.context.formattedValue,
pattern: state.context.pattern,
inputMode: state.context.inputMode,
"aria-invalid": isInvalid || void 0,
"data-invalid": dataAttr(isInvalid),
disabled: isDisabled,
"data-disabled": dataAttr(isDisabled),
readOnly: !!state.context.readonly,
autoComplete: "off",
autoCorrect: "off",
spellCheck: "false",
type: "text",
"aria-roledescription": "number field",
"aria-valuemin": state.context.min,
"aria-valuemax": state.context.max,
"aria-valuenow": isNaN(state.context.valueAsNumber) ? void 0 : state.context.valueAsNumber,
"aria-valuetext": state.context.valueText,
onFocus() {
send("FOCUS");
},
onBlur() {
send("BLUR");
},
onChange(event) {
const evt = getNativeEvent(event);
if (evt.isComposing)
return;
send({ type: "CHANGE", target: event.currentTarget, hint: "set" });
},
onKeyDown(event) {
const evt = getNativeEvent(event);
if (evt.isComposing)
return;
if (!utils.isValidNumericEvent(state.context, event)) {
event.preventDefault();
}
const step = multiply(getEventStep(event), state.context.step);
const keyMap = {
ArrowUp() {
send({ type: "ARROW_UP", step });
},
ArrowDown() {
send({ type: "ARROW_DOWN", step });
},
Home() {
send("HOME");
},
End() {
send("END");
}
};
const exec = keyMap[event.key];
if (exec) {
exec(event);
event.preventDefault();
}
}
}),
decrementButtonProps: normalize.button({
"data-part": "spin-button",
id: dom.getDecButtonId(state.context),
disabled: isDecrementDisabled,
"data-disabled": dataAttr(isDecrementDisabled),
"aria-label": messages.decrementLabel,
type: "button",
tabIndex: -1,
"aria-controls": dom.getInputId(state.context),
onPointerDown(event) {
if (isDecrementDisabled)
return;
send({ type: "PRESS_DOWN", hint: "decrement" });
event.preventDefault();
},
onPointerUp() {
send({ type: "PRESS_UP", hint: "decrement" });
},
onPointerLeave() {
if (isDecrementDisabled)
return;
send({ type: "PRESS_UP", hint: "decrement" });
}
}),
incrementButtonProps: normalize.button({
"data-part": "spin-button",
id: dom.getIncButtonId(state.context),
disabled: isIncrementDisabled,
"data-disabled": dataAttr(isIncrementDisabled),
"aria-label": messages.incrementLabel,
type: "button",
tabIndex: -1,
"aria-controls": dom.getInputId(state.context),
onPointerDown(event) {
event.preventDefault();
if (isIncrementDisabled)
return;
send({ type: "PRESS_DOWN", hint: "increment" });
},
onPointerUp() {
send({ type: "PRESS_UP", hint: "increment" });
},
onPointerLeave() {
send({ type: "PRESS_UP", hint: "increment" });
}
}),
scrubberProps: normalize.element({
"data-disabled": dataAttr(isDisabled),
"data-part": "scrubber",
id: dom.getScrubberId(state.context),
role: "presentation",
onMouseDown(event) {
if (isDisabled)
return;
const evt = getNativeEvent(event);
event.preventDefault();
const point = getEventPoint(evt);
point.x = point.x - roundToPx(7.5);
point.y = point.y - roundToPx(7.5);
send({ type: "PRESS_DOWN_SCRUBBER", point });
},
style: {
cursor: isDisabled ? void 0 : "ew-resize"
}
})
};
}
// ../../../node_modules/@zag-js/core/src/index.ts
var import_vanilla3 = require("valtio/vanilla");
// ../../core/src/action-utils.ts
function choose(actions) {
return {
predicate: (guardMap) => (ctx, event) => {
var _a;
return (_a = actions.find((def) => {
var _a2;
def.guard = def.guard || (() => true);
if (isString(def.guard)) {
return !!((_a2 = guardMap[def.guard]) == null ? void 0 : _a2.call(guardMap, ctx, event));
}
if (isGuardHelper(def.guard)) {
return def.guard.predicate(guardMap != null ? guardMap : {})(ctx, event);
}
return def.guard(ctx, event);
})) == null ? void 0 : _a.actions;
}
};
}
function isGuardHelper(value) {
return isObject(value) && value.predicate != null;
}
function determineActionsFn(values, guardMap) {
return (context, event) => {
if (isGuardHelper(values))
return values.predicate(guardMap != null ? guardMap : {})(context, event);
return values;
};
}
// ../../core/src/guard-utils.ts
function or(...conditions) {
return {
predicate: (guards2) => (ctx, event) => conditions.map((condition) => {
var _a;
if (isString(condition)) {
return !!((_a = guards2[condition]) == null ? void 0 : _a.call(guards2, ctx, event));
}
if (isFunction(condition)) {
return condition(ctx, event);
}
return condition.predicate(guards2)(ctx, event);
}).some(Boolean)
};
}
function and(...conditions) {
return {
predicate: (guards2) => (ctx, event) => conditions.map((condition) => {
var _a;
if (isString(condition)) {
return !!((_a = guards2[condition]) == null ? void 0 : _a.call(guards2, ctx, event));
}
if (isFunction(condition)) {
return condition(ctx, event);
}
return condition.predicate(guards2)(ctx, event);
}).every(Boolean)
};
}
function not(condition) {
return {
predicate: (guardMap) => (ctx, event) => {
var _a;
if (isString(condition)) {
return !((_a = guardMap[condition]) == null ? void 0 : _a.call(guardMap, ctx, event));
}
if (isFunction(condition)) {
return !condition(ctx, event);
}
return !condition.predicate(guardMap)(ctx, event);
}
};
}
var guards = { or, and, not };
function isGuardHelper2(value) {
return isObject(value) && value.predicate != null;
}
var TruthyGuard = () => true;
function determineGuardFn(guard, guardMap) {
guard = guard != null ? guard : TruthyGuard;
return (context, event) => {
if (isString(guard)) {
const value = guardMap == null ? void 0 : guardMap[guard];
return isFunction(value) ? value(context, event) : value;
}
if (isGuardHelper2(guard)) {
return guard.predicate(guardMap != null ? guardMap : {})(context, event);
}
return guard == null ? void 0 : guard(context, event);
};
}
// ../../../node_modules/klona/json/index.mjs
function klona(val) {
var k, out, tmp;
if (Array.isArray(val)) {
out = Array(k = val.length);
while (k--)
out[k] = (tmp = val[k]) && typeof tmp === "object" ? klona(tmp) : tmp;
return out;
}
if (Object.prototype.toString.call(val) === "[object Object]") {
out = {};
for (k in val) {
if (k === "__proto__") {
Object.defineProperty(out, k, {
value: klona(val[k]),
configurable: true,
enumerable: true,
writable: true
});
} else {
out[k] = (tmp = val[k]) && typeof tmp === "object" ? klona(tmp) : tmp;
}
}
return out;
}
return val;
}
// ../../core/src/machine.ts
var import_utils13 = require("valtio/utils");
var import_vanilla2 = require("valtio/vanilla");
// ../../core/src/create-proxy.ts
var import_vanilla = require("valtio/vanilla");
function createProxy(config) {
var _a;
const state = (0, import_vanilla.proxy)({
value: "",
previousValue: "",
event: cast({}),
context: (_a = config.context) != null ? _a : cast({}),
done: false,
tags: [],
hasTag(tag) {
return this.tags.includes(tag);
},
matches(...value) {
return value.includes(this.value);
},
can(event) {
return cast(this).nextEvents.includes(event);
},
get nextEvents() {
var _a2, _b, _c, _d;
const stateEvents = (_c = (_b = (_a2 = config.states) == null ? void 0 : _a2[this.value]) == null ? void 0 : _b["on"]) != null ? _c : {};
const globalEvents = (_d = config == null ? void 0 : config.on) != null ? _d : {};
return Object.keys(__spreadValues(__spreadValues({}, stateEvents), globalEvents));
},
get changed() {
if (this.event.value === "machine.init" /* Init */ || !this.previousValue)
return false;
return this.value !== this.previousValue;
}
});
return cast(state);
}
// ../../core/src/delay-utils.ts
function determineDelayFn(delay, delaysMap) {
return (context, event) => {
if (isNumber(delay))
return delay;
if (isFunction(delay)) {
return delay(context, event);
}
if (isString(delay)) {
const value = Number.parseFloat(delay);
if (!Number.isNaN(value)) {
return value;
}
if (delaysMap) {
const valueOrFn = delaysMap == null ? void 0 : delaysMap[delay];
if (valueOrFn == null) {
const msg = `[machine] Cannot determine delay for ${delay}. It doesn't exist in options.delays`;
throw new Error(msg);
}
return isFunction(valueOrFn) ? valueOrFn(context, event) : valueOrFn;
}
}
};
}
// ../../core/src/utils.ts
function toEvent(event) {
const obj = isString(event) ? { type: event } : event;
return obj;
}
function toArray(value) {
if (!value)
return [];
return isArray(value) ? value : [value];
}
// ../../core/src/transition-utils.ts
function toTarget(target) {
return isString(target) ? { target } : target;
}
function determineTransitionFn(transitions, guardMap) {
return (context, event) => {
return toArray(transitions).map(toTarget).find((transition) => {
var _a;
const determineGuard = determineGuardFn(transition.guard, guardMap);
const guard = determineGuard(context, event);
return (_a = guard != null ? guard : transition.target) != null ? _a : transition.actions;
});
};
}
function toTransition(transition, current) {
const _transition = isString(transition) ? toTarget(transition) : transition;
const fn = (t2) => {
const isTargetless = t2.actions && !t2.target;
if (isTargetless && current)
t2.target = current;
return t2;
};
if (isArray(_transition)) {
return _transition.map(fn);
}
if (isObject(_transition)) {
return fn(cast(_transition));
}
}
// ../../core/src/machine.ts
var Machine = class {
constructor(config, options) {
this.config = config;
this.status = "Not Started" /* NotStarted */;
this.type = "machine" /* Machine */;
this.activityEvents = /* @__PURE__ */ new Map();
this.delayedEvents = /* @__PURE__ */ new Map();
this.stateListeners = /* @__PURE__ */ new Set();
this.eventListeners = /* @__PURE__ */ new Set();
this.doneListeners = /* @__PURE__ */ new Set();
this.contextWatchers = /* @__PURE__ */ new Set();
this.removeStateListener = noop;
this.removeEventListener = noop;
this.children = /* @__PURE__ */ new Map();
this.start = (init) => {
if (this.status === "Running" /* Running */) {
return this;
}
this.status = "Running" /* Running */;
const event = toEvent("machine.init" /* Init */);
if (init) {
const resolved = isObject(init) ? init : { context: this.config.context, value: init };
this.setState(resolved.value);
this.setContext(resolved.context);
}
const transition = {
target: !!init ? void 0 : this.config.initial
};
const info = this.getNextStateInfo(transition, event);
info.target = cast(info.target || transition.target);
this.initialState = info;
this.performStateChangeEffects(info.target, info, event);
this.removeStateListener = (0, import_vanilla2.subscribe)(this.state, () => {
this.stateListeners.forEach((listener) => {
listener(this.stateSnapshot);
});
}, this.sync);
this.removeEventListener = (0, import_utils13.subscribeKey)(this.state, "event", (value) => {
if (this.config.onEvent) {
this.executeActions(this.config.onEvent, value);
}
for (const listener of this.eventListeners) {
listener(value);
}
});
this.setupContextWatchers();
this.executeActivities(toEvent("machine.start" /* Start */), toArray(this.config.activities), "machine.start" /* Start */);
this.executeActions(this.config.entry, toEvent("machine.start" /* Start */));
return this;
};
this.setupContextWatchers = () => {
var _a;
for (const [key, fn] of Object.entries((_a = this.config.watch) != null ? _a : {})) {
this.contextWatchers.add((0, import_utils13.subscribeKey)(this.state.context, key, () => {
this.executeActions(fn, this.state.event);
}));
}
};
this.setupComputed = () => {
var _a;
const computed = cast((_a = this.config.computed) != null ? _a : {});
const deriveFns = Object.fromEntries(Object.entries(computed).map(([key, fn]) => [key, (get) => fn(get(this.state.context))]));
(0, import_utils13.derive)(deriveFns, { proxy: this.state.context });
};
this.detachComputed = () => {
(0, import_utils13.underive)(this.state.context, { delete: true });
};
this.stop = () => {
if (this.status === "Stopped" /* Stopped */)
return;
this.setState(null);
this.setEvent("machine.stop" /* Stop */);
if (this.config.context) {
this.setContext(this.config.context);
}
this.stopStateListeners();
this.stopChildren();
this.stopActivities();
this.stopDelayedEvents();
this.stopContextWatchers();
this.stopEventListeners();
this.detachComputed();
this.status = "Stopped" /* Stopped */;
this.executeActions(this.config.exit, toEvent("machine.stop" /* Stop */));
return this;
};
this.stopEventListeners = () => {
this.eventListeners.clear();
this.removeEventListener();
};
this.stopStateListeners = () => {
this.removeStateListener();
this.stateListeners.clear();
};
this.stopContextWatchers = () => {
this.contextWatchers.forEach((fn) => fn());
this.contextWatchers.clear();
};
this.stopDelayedEvents = () => {
this.delayedEvents.forEach((state) => {
state.forEach((stop) => stop());
});
this.delayedEvents.clear();
};
this.stopActivities = (state) => {
var _a, _b;
if (state) {
(_a = this.activityEvents.get(state)) == null ? void 0 : _a.forEach((stop) => stop());
(_b = this.activityEvents.get(state)) == null ? void 0 : _b.clear();
this.activityEvents.delete(state);
} else {
this.activityEvents.forEach((state2) => {
state2.forEach((stop) => stop());
state2.clear();
});
this.activityEvents.clear();
}
};
this.sendChild = (evt, to) => {
const event = toEvent(evt);
const id = runIfFn(to, this.contextSnapshot);
const child = this.children.get(id);
if (!child) {
invariant(`[machine/send-child] Cannot send '${event.type}' event to unknown child`);
}
child.send(event);
};
this.stopChild = (id) => {
if (!this.children.has(id)) {
invariant("[machine/stop-child] Cannot stop unknown child");
}
this.children.get(id).stop();
this.children.delete(id);
};
this.removeChild = (id) => {
this.children.delete(id);
};
this.stopChildren = () => {
this.children.forEach((child) => child.stop());
this.children.clear();
};
this.setParent = (parent) => {
this.parent = parent;
};
this.spawn = (src, id) => {
const actor = runIfFn(src);
if (id)
actor.id = id;
actor.type = "machine.actor" /* Actor */;
actor.setParent(this);
this.children.set(actor.id, cast(actor));
actor.onDone(() => {
this.removeChild(actor.id);
}).start();
return cast((0, import_vanilla2.ref)(actor));
};
this.addActivityCleanup = (state, cleanup) => {
var _a;
if (!state)
return;
if (!this.activityEvents.has(state)) {
this.activityEvents.set(state, /* @__PURE__ */ new Set([cleanup]));
} else {
(_a = this.activityEvents.get(state)) == null ? void 0 : _a.add(cleanup);
}
};
this.setState = (target) => {
this.state.previousValue = this.state.value;
this.state.value = target;
const stateNode = this.getStateNode(target);
if (target == null) {
clear(this.state.tags);
} else {
this.state.tags = toArray(stateNode == null ? void 0 : stateNode.tags);
}
};
this.setContext = (context) => {
for (const key in context) {
this.state.context[key] = context[key];
}
};
this.withContext = (context) => {
this.detachComputed();
const newContext = __spreadValues(__spreadValues({}, this.config.context), context);
return new Machine(__spreadProps(__spreadValues({}, this.config), { context: newContext }), this.options);
};
this.withOptions = (options) => {
this.detachComputed();
return new Machine(this.config, __spreadValues(__spreadValues({}, this.options), options));
};
this.setActions = (actions) => {
this.actionMap = __spreadValues(__spreadValues({}, this.actionMap), actions);
};
this.clone = () => {
this.detachComputed();
return new Machine(this.config, this.options);
};
this.getStateNode = (state) => {
var _a;
if (!state)
return;
return (_a = this.config.states) == null ? void 0 : _a[state];
};
this.getNextStateInfo = (transitions, event) => {
var _a;
const transition = this.determineTransition(transitions, event);
const target = (_a = transition == null ? void 0 : transition.target) != null ? _a : this.state.value;
const stateNode = this.getStateNode(target);
return {
transition,
stateNode,
target
};
};
this.getActionFromDelayedTransition = (transition) => {
const event = toEvent("machine.after" /* After */);
const determineDelay = determineDelayFn(transition.delay, this.delayMap);
const delay = determineDelay(this.contextSnapshot, event);
let id;
return {
entry: () => {
id = globalThis.setTimeout(() => {
const current = this.state.value;
const next = this.getNextStateInfo(transition, event);
this.performStateChangeEffects(current, next, event);
}, delay);
},
exit: () => {
globalThis.clearTimeout(id);
}
};
};
this.getDelayedEventActions = (state) => {
const stateNode = this.getStateNode(state);
const event = toEvent("machine.after" /* After */);
if (!stateNode || !stateNode.after)
return;
const entries = [];
const exits = [];
if (isArray(stateNode.after)) {
const transition = this.determineTransition(stateNode.after, event);
if (!transition)
return;
const actions = this.getActionFromDelayedTransition(transition);
entries.push(actions.entry);
exits.push(actions.exit);
} else if (isObject(stateNode.after)) {
for (const delay in stateNode.after) {
const transition = stateNode.after[delay];
let resolvedTransition = {};
if (isArray(transition)) {
const picked = this.determineTransition(transition, event);
if (picked)
resolvedTransition = picked;
} else if (isString(transition)) {
resolvedTransition = { target: transition, delay };
} else {
resolvedTransition = __spreadProps(__spreadValues({}, transition), { delay });
}
const actions = this.getActionFromDelayedTransition(resolvedTransition);
entries.push(actions.entry);
exits.push(actions.exit);
}
}
return { entries, exits };
};
this.executeActions = (actions, event) => {
var _a;
const _actions = determineActionsFn(actions, this.guardMap)(this.contextSnapshot, event);
for (const action of toArray(_actions)) {
const fn = isString(action) ? (_a = this.actionMap) == null ? void 0 : _a[action] : action;
warn(isString(action) && !fn, `[machine/exec-action] No implementation found for action: \`${action}\``);
fn == null ? void 0 : fn(this.state.context, event, this.meta);
}
};
this.executeActivities = (event, activities, state) => {
var _a;
for (const activity of activities) {
const fn = isString(activity) ? (_a = this.activityMap) == null ? void 0 : _a[activity] : activity;
if (!fn) {
warn(`[machine/exec-activity] No implementation found for activity: \`${activity}\``);
continue;
}
const cleanup = fn(this.state.context, event, this.meta);
if (cleanup) {
this.addActivityCleanup(state != null ? state : this.state.value, cleanup);
}
}
};
this.createEveryActivities = (every, callbackfn) => {
if (!every)
return;
const event = toEvent("machine.every" /* Every */);
if (isArray(every)) {
const picked = toArray(every).find((t2) => {
const determineDelay2 = determineDelayFn(t2.delay, this.delayMap);
t2.delay = determineDelay2(this.contextSnapshot, event);
const determineGuard = determineGuardFn(t2.guard, this.guardMap);
const guard = determineGuard(this.contextSnapshot, event);
return guard != null ? guard : t2.delay;
});
if (!picked)
return;
const determineDelay = determineDelayFn(picked.delay, this.delayMap);
const delay = determineDelay(this.contextSnapshot, event);
const activity = () => {
const id = globalThis.setInterval(() => {
this.executeActions(picked.actions, event);
}, delay);
return () => {
globalThis.clearInterval(id);
};
};
callbackfn(activity);
} else {
for (const interval in every) {
const actions = every == null ? void 0 : every[interval];
const determineDelay = determineDelayFn(interval, this.delayMap);
const delay = determineDelay(this.contextSnapshot, event);
const activity = () => {
const id = globalThis.setInterval(() => {
this.executeActions(actions, event);
}, delay);
return () => {
globalThis.clearInterval(id);
};
};
callbackfn(activity);
}
}
};
this.setEvent = (event) => {
this.state.event = (0, import_vanilla2.ref)(toEvent(event));
};
this.performExitEffects = (current, event) => {
const currentState = this.state.value;
const stateNode = current ? this.getStateNode(current) : void 0;
this.stopActivities(currentState);
const _exit = determineActionsFn(stateNode == null ? void 0 : stateNode.exit, this.guardMap)(this.contextSnapshot, event);
const exitActions = toArray(_exit);
const afterExitActions = this.delayedEvents.get(currentState);
if (afterExitActions) {
exitActions.push(...afterExitActions);
}
this.executeActions(exitActions, event);
this.eventListeners.clear();
};
this.performEntryEffects = (next, event) => {
const stateNode = this.getStateNode(next);
const activities = toArray(stateNode == null ? void 0 : stateNode.activities);
this.createEveryActivities(stateNode == null ? void 0 : stateNode.every, (activity) => {
activities.unshift(activity);
});
if (activities.length > 0) {
this.executeActivities(event, activities);
}
const _entry = determineActionsFn(stateNode == null ? void 0 : stateNode.entry, this.guardMap)(this.contextSnapshot, event);
const entryActions = toArray(_entry);
const afterActions = this.getDelayedEventActions(next);
if ((stateNode == null ? void 0 : stateNode.after) && afterActions) {
this.delayedEvents.set(next, afterActions == null ? void 0 : afterActions.exits);
entryActions.push(...afterActions.entries);
}
this.executeActions(entryActions, event);
if ((stateNode == null ? void 0 : stateNode.type) === "final") {
this.state.done = true;
this.doneListeners.forEach((listener) => {
listener(this.stateSnapshot);
});
this.stop();
}
};
this.performTransitionEffects = (transition, event) => {
const t2 = this.determineTransition(transition, event);
this.executeActions(t2 == null ? void 0 : t2.actions, event);
};
this.performStateChangeEffects = (current, next, event) => {
var _a, _b;
this.setEvent(event);
next.target = (_b = (_a = next.target) != null ? _a : this.state.value) != null ? _b : void 0;
const ok = next.target && next.target !== this.state.value;
if (ok) {
this.performExitEffects(current, event);
}
this.performTransitionEffects(next == null ? void 0 : next.transition, event);
this.setState(next.target);
if (ok) {
this.performEntryEffects(next.target, event);
}
};
this.determineTransition = (transition, event) => {
const fn = determineTransitionFn(transition, this.guardMap);
return fn == null ? void 0 : fn(this.contextSnapshot, event);
};
this.sendParent = (evt) => {
var _a;
if (!this.parent) {
invariant("[machine/send-parent] Cannot send event to an unknown parent");
}
const event = toEvent(evt);
(_a = this.parent) == null ? void 0 : _a.send(event);
};
this.send = (evt) => {
const event = toEvent(evt);
this.transition(this.state.value, event);
};
this.transition = (state, evt) => {
var _a, _b, _c;
const stateNode = isString(state) ? this.getStateNode(state) : state == null ? void 0 : state.stateNode;
const event = toEvent(evt);
if (!stateNode && !this.config.on) {
const msg = this.status === "Stopped" /* Stopped */ ? "[machine/transition] Cannot transition a stopped machine" : "[machine/transition] State does not have a definition";
warn(msg);
return;
}
const transitionConfig = (_c = (_a = stateNode == null ? void 0 : stateNode.on) == null ? void 0 : _a[event.type]) != null ? _c : (_b = this.config.on) == null ? void 0 : _b[event.type];
const transition = toTransition(transitionConfig, this.state.value);
if (!transition)
return;
const info = this.getNextStateInfo(transition, event);
this.performStateChangeEffects(this.state.value, info, event);
return info.stateNode;
};
this.subscribe = (listener) => {
this.stateListeners.add(listener);
if (this.status === "Running" /* Running */) {
listener(this.stateSnapshot);
}
return () => {
this.stateListeners.delete(listener);
};
};
this.onDone = (listener) => {
this.doneListeners.add(listener);
return this;
};
this.onTransition = (listener) => {
this.stateListeners.add(listener);
if (this.status === "Running" /* Running */) {
listener(this.stateSnapshot);
}
return this;
};
this.onEvent = (listener) => {
listener(this.state.event);
this.eventListeners.add(listener);
return this;
};
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
this.options = klona(options);
this.id = (_a = config.id) != null ? _a : `machine-${uuid()}`;
this.guardMap = (_c = (_b = this.options) == null ? void 0 : _b.guards) != null ? _c : {};
this.actionMap = (_e = (_d = this.options) == null ? void 0 : _d.actions) != null ? _e : {};
this.delayMap = (_g = (_f = this.options) == null ? void 0 : _f.delays) != null ? _g : {};
this.activityMap = (_i = (_h = this.options) == null ? void 0 : _h.activities) != null ? _i : {};
this.sync = (_k = (_j = this.options) == null ? void 0 : _j.sync) != null ? _k : false;
this.state = createProxy(klona(config));
this.setupComputed();
const event = toEvent("machine.created" /* Created */);
this.executeActions(config == null ? void 0 : config.created, event);
}
get stateSnapshot() {
return cast((0, import_vanilla2.snapshot)(this.state));
}
get contextSnapshot() {
return this.stateSnapshot.context;
}
get self() {
const _self = this;
return {
id: this.id,
send: this.send.bind(this),
sendParent: this.sendParent.bind(this),
sendChild: this.sendChild.bind(this),
stop: this.stop.bind(this),
stopChild: this.stopChild.bind(this),
spawn: this.spawn.bind(this),
get state() {
return _self.stateSnapshot;
}
};
}
get meta() {
return {
state: this.stateSnapshot,
guards: this.guardMap,
send: this.send.bind(this),
listen: this.onEvent.bind(this),
self: this.self,
getState: () => this.stateSnapshot
};
}
};
var createMachine = (config, options) => new Machine(config, options);
// src/number-input.machine.ts
var { not: not2, and: and2 } = guards;
var machine = createMachine({
id: "number-input",
initial: "unknown",
context: {
uid: "",
dir: "ltr",
focusInputOnChange: true,
clampValueOnBlur: true,
allowOverflow: false,
inputMode: "decimal",
pattern: "[0-9]*(.[0-9]+)?",
hint: null,
value: "",
step: 1,
min: Number.MIN_SAFE_INTEGER,
max: Number.MAX_SAFE_INTEGER,
precision: 0,
inputSelection: null,
scrubberCursorPoint: null,
invalid: false,
messages: {
incrementLabel: "increment value",
decrementLabel: "decrease value"
}
},
computed: {
isRtl: (ctx) => ctx.dir === "rtl",
valueAsNumber: (ctx) => valueOf(ctx.value),
isAtMin: (ctx) => isAtMin(ctx.value, ctx),
isAtMax: (ctx) => isAtMax(ctx.value, ctx),
isOutOfRange: (ctx) => !isWithinRange(ctx.value, ctx),
canIncrement: (ctx) => ctx.allowOverflow || !ctx.isAtMax,
canDecrement: (ctx) => ctx.allowOverflow || !ctx.isAtMin,
valueText: (ctx) => {
var _a, _b;
return (_b = (_a = ctx.messages).valueText) == null ? void 0 : _b.call(_a, ctx.value);
},
formattedValue: (ctx) => {
var _a, _b;
return (_b = (_a = ctx.format) == null ? void 0 : _a.call(ctx, ctx.value).toString()) != null ? _b : ctx.value;
}
},
watch: {
value: ["invokeOnChange"],
isOutOfRange: ["invokeOnInvalid"]
},
entry: ["syncInputValue"],
on: {
SET_VALUE: {
actions: ["setValue", "setHintToSet"]
},
INCREMENT: { actions: ["increment"] },
DECREMENT: { actions: ["decrement"] }
},
states: {
unknown: {
on: {
SETUP: {
target: "idle",
actions: "setupDocument"
}
}
},
idle: {
on: {
PRESS_DOWN: {
target: "before:spin",
actions: ["focusInput", "setHint"]
},
PRESS_DOWN_SCRUBBER: {
target: "scrubbing",
actions: ["focusInput", "setHint", "setCursorPoint"]
},
FOCUS: "focused"
}
},
focused: {
tags: ["focus"],
activities: "attachWheelListener",
on: {
PRESS_DOWN: {
target: "before:spin",
actions: ["focusInput", "setHint"]
},
PRESS_DOWN_SCRUBBER: {
target: "scrubbing",
actions: ["focusInput", "setHint", "setCursorPoint"]
},
ARROW_UP: {
actions: "increment"
},
ARROW_DOWN: {
actions: "decrement"
},
HOME: {
actions: "setToMin"
},
END: {
actions: "setToMax"
},
CHANGE: {
actions: ["setValue", "setSelectionRange", "setHint"]
},
BLUR: [
{
guard: "isInvalidExponential",
target: "idle",
actions: ["clearValue", "clearHint"]
},
{
guard: and2("clampOnBlur", not2("isInRange")),
target: "idle",
actions: ["clampValue", "clearHint"]
},
{
actions: ["roundValue"]
}
]
}
},
"before:spin": {
tags: ["focus"],
entry: choose([
{ guard: "isIncrementHint", actions: "increment" },
{ guard: "isDecrementHint", actions: "decrement" }
]),
after: {
CHANGE_DELAY: {
target: "spinning",
guard: "isInRange"
}
},
on: {
PRESS_UP: {
target: "focused",
actions: ["clearHint", "restoreSelection"]
}
}
},
spinning: {
tags: ["focus"],
activities: "trackButtonDisabled",
every: [
{
delay: "CHANGE_INTERVAL",
guard: and2(not2("isAtMin"), "isIncrementHint"),
actions: "increment"
},
{
delay: "CHANGE_INTERVAL",
guard: and2(not2("isAtMax"), "isDecrementHint"),
actions: "decrement"
}
],
on: {
PRESS_UP: {
target: "focused",
actions: ["clearHint", "restoreSelection"]
}
}
},
scrubbing: {
tags: ["focus"],
entry: ["addCustomCursor", "disableTextSelection"],
exit: ["removeCustomCursor", "restoreTextSelection"],
activities: ["activatePointerLock", "trackMousemove"],
on: {
POINTER_UP_SCRUBBER: {
target: "focused",
actions: ["clearCursorPoint"]
},
POINTER_MOVE_SCRUBBER: [
{
guard: "isIncrementHint",
actions: ["increment", "setCursorPoint", "updateCursor"]
},
{
guard: "isDecrementHint",
actions: ["decrement", "setCursorPoint", "updateCursor"]
}
]
}
}
}
}, {
delays: {
CHANGE_INTERVAL: 50,
CHANGE_DELAY: 300
},
guards: {
clampOnBlur: (ctx) => !!ctx.clampValueOnBlur,
isAtMin: (ctx) => ctx.isAtMin,
isAtMax: (ctx) => ctx.isAtMax,
isInRange: (ctx) => !ctx.isOutOfRange,
isDecrementHint: (ctx, evt) => {
var _a;
return ((_a = evt.hint) != null ? _a : ctx.hint) === "decrement";
},
isIncrementHint: (ctx, evt) => {
var _a;
return ((_a = evt.hint) != null ? _a : ctx.hint) === "increment";
},
isInvalidExponential: (ctx) => ctx.value.toString().startsWith("e")
},
activities: {
trackButtonDisabled(ctx, _evt, { send }) {
let btnEl = null;
if (ctx.hint === "increment") {
btnEl = dom.getIncButtonEl(ctx);
}
if (ctx.hint === "decrement") {
btnEl = dom.getDecButtonEl(ctx);
}
return observeAttributes(btnEl, "disabled", function onDisable() {
send("PRESS_UP");
});
},
attachWheelListener(ctx) {
const cleanups = [];
cleanups.push(nextTick(() => {
const input = dom.getInputEl(ctx);
if (!input)
return;
function onWheel(event) {
const isInputFocused = dom.getDoc(ctx).activeElement === input;
if (!ctx.allowMouseWheel || !isInputFocused)
return;
event.preventDefault();
const dir = Math.sign(event.deltaY) * -1;
if (dir === 1)
ctx.value = utils.increment(ctx);
else if (dir === -1)
ctx.value = utils.decrement(ctx);
}
cleanups.push(addDomEvent(input, "wheel", onWheel, { passive: false }));
}));
return () => cleanups.forEach((c) => c());
},
activatePointerLock(ctx) {
if (isSafari() || !supportsPointerEvent())
return;
return requestPointerLock(dom.getDoc(ctx));
},
trackMousemove(ctx, _evt, { send }) {
const doc = dom.getDoc(ctx);
function onMousemove(event) {
if (!ctx.scrubberCursorPoint)
return;
const value = dom.getMousementValue(ctx, event);
if (!value.hint)
return;
send({ type: "POINTER_MOVE_SCRUBBER", hint: value.hint, point: value.point });
}
function onMouseup() {
send("POINTER_UP_SCRUBBER");
}
return pipe(addDomEvent(doc, "mousemove", onMousemove, false), addDomEvent(doc, "mouseup", onMouseup, false));
}
},
actions: {
setupDocument: (ctx, evt) => {
if (evt.doc)
ctx.doc = (0, import_vanilla3.ref)(evt.doc);
ctx.uid = evt.id;
},
focusInput(ctx) {
if (!ctx.focusInputOnChange)
return;
const input = dom.getInputEl(ctx);
nextTick(() => input == null ? void 0 : input.focus());
},
increment(ctx, evt) {
ctx.value = utils.increment(ctx, evt.step);
},
decrement(ctx, evt) {
ctx.value = utils.decrement(ctx, evt.step);
},
clampValue(ctx) {
ctx.value = utils.clamp(ctx);
},
roundValue(ctx) {
ctx.value = utils.round(ctx);
},
setValue(ctx, evt) {
var _a, _b;
const value = (_b = (_a = evt.target) == null ? void 0 : _a.value) != null ? _b : evt.value;
ctx.value = utils.sanitize(ctx, utils.parse(ctx, value));
},
clearValue(ctx) {
ctx.value = "";
},
setToMax(ctx) {
ctx.value = ctx.max.toString();
},
setToMin(ctx) {
ctx.value = ctx.min.toString();
},
setHint(ctx, evt) {
ctx.hint = evt.hint;
},
clearHint(ctx) {
ctx.hint = null;
},
setHintToSet(ctx) {
ctx.hint = "set";
},
setSelectionRange(ctx, evt) {
ctx.inputSelection = {
start: evt.target.selectionStart,
end: evt.target.selectionEnd
};
},
restoreSelection(ctx) {
var _a, _b, _c;
const input = dom.getInputEl(ctx);
if (!input || !ctx.inputSelection)
return;
input.selectionStart = (_b = ctx.inputSelection.start) != null ? _b : (_a = input.value) == null ? void 0 : _a.length;
input.selectionEnd = (_c = ctx.inputSelection.end) != null ? _c : input.selectionStart;
},
invokeOnChange(ctx) {
var _a;
(_a = ctx.onChange) == null ? void 0 : _a.call(ctx, { value: ctx.value, valueAsNumber: ctx.valueAsNumber });
},
invokeOnInvalid(ctx) {
var _a;
if (!ctx.isOutOfRange)
return;
const reason = ctx.valueAsNumber > ctx.max ? "rangeOverflow" : "rangeUnderflow";
(_a = ctx.onInvalid) == null ? void 0 : _a.call(ctx, { reason, value: ctx.formattedValue, valueAsNumber: ctx.valueAsNumber });
},
syncInputValue(ctx) {
const input = dom.getInputEl(ctx);
if (!input || input.value == ctx.value)
return;
const value = utils.parse(ctx, input.value);
ctx.value = utils.sanitize(ctx, value);
},
setCursorPoint(ctx, evt) {
ctx.scrubberCursorPoint = evt.point;
},
clearCursorPoint(ctx) {
ctx.scrubberCursorPoint = null;
},
updateCursor(ctx) {
const cursor = dom.getCursorEl(ctx);
if (!cursor || !ctx.scrubberCursorPoint)
return;
cursor.style.transform = `translate3d(${ctx.scrubberCursorPoint.x}px, ${ctx.scrubberCursorPoint.y}px, 0px)`;
},
addCustomCursor(ctx) {
if (isSafari() || !supportsPointerEvent())
return;
dom.createVirtualCursor(ctx);
},
removeCustomCursor(ctx) {
if (isSafari() || !supportsPointerEvent())
return;
const doc = dom.getDoc(ctx);
const el = doc.getElementById(dom.getCursorId(ctx));
el == null ? void 0 : el.remove();
},
disableTextSelection(ctx) {
const doc = dom.getDoc(ctx);
doc.body.style.pointerEvents = "none";
doc.documentElement.style.userSelect = "none";
doc.documentElement.style.cursor = "ew-resize";
},
restoreTextSelection(ctx) {
const doc = dom.getDoc(ctx);
doc.body.style.pointerEvents = "";
doc.documentElement.style.userSelect = "";
doc.documentElement.style.cursor = "";
}
}
});
//# sourceMappingURL=index.js.map

@@ -22,1 +22,2 @@ import { PropTypes, ReactPropTypes } from "@zag-js/types";

};
//# sourceMappingURL=number-input.connect.d.ts.map

@@ -26,1 +26,2 @@ import { MachineContext as Ctx } from "./number-input.types";

};
//# sourceMappingURL=number-input.dom.d.ts.map
import type { MachineContext, MachineState } from "./number-input.types";
export declare const machine: import("@zag-js/core").Machine<MachineContext, MachineState, import("@zag-js/core").StateMachine.AnyEventObject>;
//# sourceMappingURL=number-input.machine.d.ts.map

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

export {};
//# sourceMappingURL=number-input.types.d.ts.map

@@ -14,1 +14,2 @@ import type { KeyboardEvent } from "react";

};
//# sourceMappingURL=number-input.utils.d.ts.map

27

package.json
{
"name": "@zag-js/number-input",
"version": "0.0.0-dev-20220413091534",
"version": "0.0.0-dev-20220413174154",
"description": "Core logic for the number-input widget implemented as a state machine",

@@ -23,3 +23,3 @@ "keywords": [

"files": [
"dist"
"dist/**/*"
],

@@ -33,9 +33,18 @@ "publishConfig": {

"dependencies": {
"@zag-js/core": "^0.0.0-dev-20220413091534",
"@zag-js/dom-utils": "^0.0.0-dev-20220413091534",
"@zag-js/number-utils": "^0.0.0-dev-20220413091534",
"@zag-js/rect-utils": "^0.0.0-dev-20220413091534",
"@zag-js/types": "^0.0.0-dev-20220413091534",
"@zag-js/utils": "^0.0.0-dev-20220413091534"
"@zag-js/core": "^0.0.0-dev-20220413174154",
"@zag-js/dom-utils": "^0.0.0-dev-20220413174154",
"@zag-js/number-utils": "^0.0.0-dev-20220413174154",
"@zag-js/rect-utils": "^0.0.0-dev-20220413174154",
"@zag-js/types": "^0.0.0-dev-20220413174154",
"@zag-js/utils": "^0.0.0-dev-20220413174154"
},
"scripts": {
"build:fast": "zag build",
"start": "zag build --watch",
"build": "zag build --prod",
"test": "jest --config ../../../jest.config.js --rootDir . --passWithNoTests",
"lint": "eslint src --ext .ts,.tsx",
"test:ci": "yarn test --ci --runInBand",
"test:watch": "yarn test --watch --updateSnapshot"
}
}
}

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