@zag-js/number-input 0.1.7 → 0.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  export { connect } from "./number-input.connect";
2
2
  export { machine } from "./number-input.machine";
3
3
  export type { UserDefinedContext as Context } from "./number-input.types";
4
- //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __defProp = Object.defineProperty;
2
3
  var __defProps = Object.defineProperties;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -48,99 +49,32 @@ var dataAttr = (guard) => {
48
49
  var ariaAttr = (guard) => {
49
50
  return guard ? "true" : void 0;
50
51
  };
51
- function raf(fn) {
52
- const id = globalThis.requestAnimationFrame(fn);
53
- return function cleanup() {
54
- globalThis.cancelAnimationFrame(id);
55
- };
56
- }
52
+ var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
53
+ var runIfFn = (v, ...a) => {
54
+ const res = typeof v === "function" ? v(...a) : v;
55
+ return res != null ? res : void 0;
56
+ };
57
57
  var noop = () => {
58
58
  };
59
59
  var pipe = (...fns) => (v) => fns.reduce((a, b) => b(a), v);
60
- function getListenerElements() {
61
- ;
62
- globalThis.__listenerElements__ = globalThis.__listenerElements__ || /* @__PURE__ */ new Map();
63
- return globalThis.__listenerElements__;
64
- }
65
- function getListenerCache() {
66
- ;
67
- globalThis.__listenerCache__ = globalThis.__listenerCache__ || /* @__PURE__ */ new Map();
68
- return globalThis.__listenerCache__;
69
- }
70
- function globalEventBus(node, type, handler, options) {
71
- var _a;
72
- if (!node)
73
- return noop;
74
- const hash = JSON.stringify({ type, options });
75
- const listenerElements = getListenerElements();
76
- const listenerCache = getListenerCache();
77
- const group = listenerElements.get(node);
78
- if (!listenerElements.has(node)) {
79
- const group2 = /* @__PURE__ */ new Map([[hash, /* @__PURE__ */ new Set([handler])]]);
80
- listenerElements.set(node, group2);
81
- } else if (group == null ? void 0 : group.has(hash)) {
82
- (_a = group == null ? void 0 : group.get(hash)) == null ? void 0 : _a.add(handler);
83
- } else {
84
- group == null ? void 0 : group.set(hash, /* @__PURE__ */ new Set([handler]));
85
- }
86
- function attach(node2) {
87
- var _a2, _b;
88
- function listener(event) {
89
- var _a3;
90
- const group2 = listenerElements.get(node2);
91
- (_a3 = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _a3.forEach((fn) => fn(event));
92
- }
93
- if (!(listenerCache == null ? void 0 : listenerCache.has(node2))) {
94
- listenerCache.set(node2, /* @__PURE__ */ new Map([[hash, listener]]));
95
- node2.addEventListener(type, listener, options);
96
- return;
97
- }
98
- if (!((_a2 = listenerCache == null ? void 0 : listenerCache.get(node2)) == null ? void 0 : _a2.has(hash))) {
99
- (_b = listenerCache.get(node2)) == null ? void 0 : _b.set(hash, listener);
100
- node2.addEventListener(type, listener, options);
101
- }
102
- }
103
- attach(node);
104
- return function remove() {
105
- var _a2, _b, _c, _d;
106
- if (!listenerElements.has(node))
107
- return;
108
- const group2 = listenerElements.get(node);
109
- (_a2 = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _a2.delete(handler);
110
- if (((_b = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _b.size) === 0) {
111
- const listener = (_c = listenerCache.get(node)) == null ? void 0 : _c.get(hash);
112
- node.removeEventListener(type, listener, options);
113
- group2 == null ? void 0 : group2.delete(hash);
114
- (_d = listenerCache.get(node)) == null ? void 0 : _d.delete(hash);
115
- if ((group2 == null ? void 0 : group2.size) === 0) {
116
- listenerElements.delete(node);
117
- listenerCache.delete(node);
118
- }
119
- }
60
+ var isRef = (v) => hasProp(v, "current");
61
+ function addDomEvent(target, eventName, handler, options) {
62
+ const node = isRef(target) ? target.current : runIfFn(target);
63
+ node == null ? void 0 : node.addEventListener(eventName, handler, options);
64
+ return () => {
65
+ node == null ? void 0 : node.removeEventListener(eventName, handler, options);
120
66
  };
121
67
  }
122
- var t = (v) => Object.prototype.toString.call(v).slice(8, -1);
123
- var isRef = (v) => t(v) === "Object" && "current" in v;
124
- var runIfFn = (fn) => t(fn) === "Function" ? fn() : fn;
125
- function addDomEvent(target, event, listener, options) {
126
- const node = isRef(target) ? target.current : runIfFn(target);
127
- return globalEventBus(node, event, listener, options);
68
+ function raf(fn) {
69
+ const id = globalThis.requestAnimationFrame(fn);
70
+ return function cleanup() {
71
+ globalThis.cancelAnimationFrame(id);
72
+ };
128
73
  }
129
74
  var MAX_Z_INDEX = 2147483647;
130
- function getNativeEvent(event) {
75
+ function getNativeEvent(e) {
131
76
  var _a;
132
- return (_a = event.nativeEvent) != null ? _a : event;
133
- }
134
- var PAGE_KEYS = /* @__PURE__ */ new Set(["PageUp", "PageDown"]);
135
- var ARROW_KEYS = /* @__PURE__ */ new Set(["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"]);
136
- function getEventStep(event) {
137
- if (event.ctrlKey || event.metaKey) {
138
- return 0.1;
139
- } else {
140
- const isPageKey = PAGE_KEYS.has(event.key);
141
- const isSkipKey = isPageKey || event.shiftKey && ARROW_KEYS.has(event.key);
142
- return isSkipKey ? 10 : 1;
143
- }
77
+ return (_a = e.nativeEvent) != null ? _a : e;
144
78
  }
145
79
  function observeAttributes(node, attributes, fn) {
146
80
  if (!node)
@@ -157,29 +91,16 @@ function observeAttributes(node, attributes, fn) {
157
91
  obs.observe(node, { attributes: true, attributeFilter: attrs });
158
92
  return () => obs.disconnect();
159
93
  }
160
- function itemById(v, id) {
161
- return v.find((node) => node.id === id);
162
- }
163
- function indexOfId(v, id) {
164
- const item = itemById(v, id);
165
- return item ? v.indexOf(item) : -1;
166
- }
167
- var getValueText = (item) => {
168
- var _a, _b;
169
- return (_b = (_a = item.dataset.valuetext) != null ? _a : item.textContent) != null ? _b : "";
170
- };
171
- var match = (valueText, query2) => valueText.toLowerCase().startsWith(query2.toLowerCase());
172
- var wrap = (v, idx) => {
173
- return v.map((_, index) => v[(Math.max(idx, 0) + index) % v.length]);
174
- };
175
- function findByText(v, text, currentId) {
176
- const index = currentId ? indexOfId(v, currentId) : -1;
177
- let items = currentId ? wrap(v, index) : v;
178
- const isSingleKey = text.length === 1;
179
- if (isSingleKey) {
180
- items = items.filter((item) => item.id !== currentId);
94
+ var PAGE_KEYS = /* @__PURE__ */ new Set(["PageUp", "PageDown"]);
95
+ var ARROW_KEYS = /* @__PURE__ */ new Set(["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"]);
96
+ function getEventStep(event) {
97
+ if (event.ctrlKey || event.metaKey) {
98
+ return 0.1;
99
+ } else {
100
+ const isPageKey = PAGE_KEYS.has(event.key);
101
+ const isSkipKey = isPageKey || event.shiftKey && ARROW_KEYS.has(event.key);
102
+ return isSkipKey ? 10 : 1;
181
103
  }
182
- return items.find((item) => match(getValueText(item), text));
183
104
  }
184
105
  function addPointerlockChangeListener(doc, fn) {
185
106
  return addDomEvent(doc, "pointerlockchange", fn, false);
@@ -221,38 +142,10 @@ function requestPointerLock(doc, handlers = {}) {
221
142
  exit();
222
143
  };
223
144
  }
224
- function findByTypeahead(_items, options) {
225
- const { state: state2, activeId, key, timeout = 350 } = options;
226
- const search = state2.keysSoFar + key;
227
- const isRepeated = search.length > 1 && Array.from(search).every((char) => char === search[0]);
228
- const query2 = isRepeated ? search[0] : search;
229
- let items = _items.slice();
230
- const next = findByText(items, query2, activeId);
231
- function cleanup() {
232
- clearTimeout(state2.timer);
233
- state2.timer = -1;
234
- }
235
- function update(value) {
236
- state2.keysSoFar = value;
237
- cleanup();
238
- if (value !== "") {
239
- state2.timer = +setTimeout(() => {
240
- update("");
241
- cleanup();
242
- }, timeout);
243
- }
244
- }
245
- update(search);
246
- return next;
247
- }
248
- findByTypeahead.defaultOptions = {
249
- keysSoFar: "",
250
- timer: -1
251
- };
252
145
 
253
146
  // ../../utilities/number/dist/index.mjs
254
147
  var __pow = Math.pow;
255
- function wrap2(num, max) {
148
+ function wrap(num, max) {
256
149
  return (num % max + max) % max;
257
150
  }
258
151
  function roundToDevicePixel(num) {
@@ -318,32 +211,42 @@ var nf = new Intl.NumberFormat("en-US", { style: "decimal", maximumFractionDigit
318
211
  // ../../utilities/rect/dist/index.mjs
319
212
  var isArray = (v) => Array.isArray(v);
320
213
  var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
321
- var isTouchEvent = (v) => isObject(v) && "touches" in v;
214
+ var hasProp2 = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
215
+ var isTouchEvent = (v) => isObject(v) && hasProp2(v, "touches");
322
216
  var fallback = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 };
323
- function getEventPoint(e, t2 = "page") {
217
+ function getEventPoint(e, t = "page") {
324
218
  const p = isTouchEvent(e) ? e.touches[0] || e.changedTouches[0] || fallback : e;
325
- return { x: p[`${t2}X`], y: p[`${t2}Y`] };
219
+ return { x: p[`${t}X`], y: p[`${t}Y`] };
326
220
  }
327
221
 
328
222
  // ../../types/dist/index.mjs
329
223
  function createNormalizer(fn) {
330
- return { button: fn, label: fn, input: fn, output: fn, element: fn };
224
+ return new Proxy({}, {
225
+ get() {
226
+ return fn;
227
+ }
228
+ });
331
229
  }
332
230
  var normalizeProp = createNormalizer((v) => v);
333
231
 
334
232
  // ../../utilities/core/dist/index.mjs
335
- var pipe2 = (...fns) => (v) => fns.reduce((a, b) => b(a), v);
336
- var platform = (v) => isDom() && v.test(navigator.platform);
337
- var ua = (v) => isDom() && v.test(navigator.userAgent);
338
- var isDom = () => !!(typeof window !== "undefined");
339
- var isMac = () => platform(/^Mac/);
340
- var isIPhone = () => platform(/^iPhone/);
341
- var isIPad = () => platform(/^iPad/) || isMac() && navigator.maxTouchPoints > 1;
342
- var isIos = () => isIPhone() || isIPad();
343
- var isSafari = () => ua(/^((?!chrome|android).)*safari/i);
233
+ var isDom = () => typeof window !== "undefined";
234
+ function getPlatform() {
235
+ var _a;
236
+ const agent = navigator.userAgentData;
237
+ return (_a = agent == null ? void 0 : agent.platform) != null ? _a : navigator.platform;
238
+ }
239
+ var pt = (v) => isDom() && v.test(getPlatform());
240
+ var vn = (v) => isDom() && v.test(navigator.vendor);
241
+ var isTouchDevice = () => isDom() && !!navigator.maxTouchPoints;
242
+ var isMac = () => pt(/^Mac/) && !isTouchDevice;
243
+ var isSafari = () => isApple() && vn(/apple/i);
244
+ var isApple = () => pt(/mac|iphone|ipad|ipod/i);
245
+ var isIos = () => isApple() && !isMac();
344
246
  var supportsPointerEvent = () => isDom() && window.onpointerdown === null;
345
247
  var isLeftClick = (v) => v.button === 0;
346
248
  var isModifiedEvent = (v) => v.ctrlKey || v.altKey || v.metaKey;
249
+ var pipe2 = (...fns) => (v) => fns.reduce((a, b) => b(a), v);
347
250
 
348
251
  // src/number-input.dom.ts
349
252
  var dom = {
@@ -404,7 +307,7 @@ var dom = {
404
307
  const win = dom.getWin(ctx);
405
308
  const width = win.innerWidth;
406
309
  const half = roundToDevicePixel(7.5);
407
- point.x = wrap2(point.x + half, width) - half;
310
+ point.x = wrap(point.x + half, width) - half;
408
311
  return { hint, point };
409
312
  },
410
313
  createVirtualCursor(ctx) {
@@ -1052,4 +955,3 @@ function machine(ctx = {}) {
1052
955
  hookSync: true
1053
956
  });
1054
957
  }
1055
- //# sourceMappingURL=index.js.map
package/dist/index.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __defProp = Object.defineProperty;
2
3
  var __defProps = Object.defineProperties;
3
4
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
@@ -25,99 +26,32 @@ var dataAttr = (guard) => {
25
26
  var ariaAttr = (guard) => {
26
27
  return guard ? "true" : void 0;
27
28
  };
28
- function raf(fn) {
29
- const id = globalThis.requestAnimationFrame(fn);
30
- return function cleanup() {
31
- globalThis.cancelAnimationFrame(id);
32
- };
33
- }
29
+ var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
30
+ var runIfFn = (v, ...a) => {
31
+ const res = typeof v === "function" ? v(...a) : v;
32
+ return res != null ? res : void 0;
33
+ };
34
34
  var noop = () => {
35
35
  };
36
36
  var pipe = (...fns) => (v) => fns.reduce((a, b) => b(a), v);
37
- function getListenerElements() {
38
- ;
39
- globalThis.__listenerElements__ = globalThis.__listenerElements__ || /* @__PURE__ */ new Map();
40
- return globalThis.__listenerElements__;
41
- }
42
- function getListenerCache() {
43
- ;
44
- globalThis.__listenerCache__ = globalThis.__listenerCache__ || /* @__PURE__ */ new Map();
45
- return globalThis.__listenerCache__;
46
- }
47
- function globalEventBus(node, type, handler, options) {
48
- var _a;
49
- if (!node)
50
- return noop;
51
- const hash = JSON.stringify({ type, options });
52
- const listenerElements = getListenerElements();
53
- const listenerCache = getListenerCache();
54
- const group = listenerElements.get(node);
55
- if (!listenerElements.has(node)) {
56
- const group2 = /* @__PURE__ */ new Map([[hash, /* @__PURE__ */ new Set([handler])]]);
57
- listenerElements.set(node, group2);
58
- } else if (group == null ? void 0 : group.has(hash)) {
59
- (_a = group == null ? void 0 : group.get(hash)) == null ? void 0 : _a.add(handler);
60
- } else {
61
- group == null ? void 0 : group.set(hash, /* @__PURE__ */ new Set([handler]));
62
- }
63
- function attach(node2) {
64
- var _a2, _b;
65
- function listener(event) {
66
- var _a3;
67
- const group2 = listenerElements.get(node2);
68
- (_a3 = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _a3.forEach((fn) => fn(event));
69
- }
70
- if (!(listenerCache == null ? void 0 : listenerCache.has(node2))) {
71
- listenerCache.set(node2, /* @__PURE__ */ new Map([[hash, listener]]));
72
- node2.addEventListener(type, listener, options);
73
- return;
74
- }
75
- if (!((_a2 = listenerCache == null ? void 0 : listenerCache.get(node2)) == null ? void 0 : _a2.has(hash))) {
76
- (_b = listenerCache.get(node2)) == null ? void 0 : _b.set(hash, listener);
77
- node2.addEventListener(type, listener, options);
78
- }
79
- }
80
- attach(node);
81
- return function remove() {
82
- var _a2, _b, _c, _d;
83
- if (!listenerElements.has(node))
84
- return;
85
- const group2 = listenerElements.get(node);
86
- (_a2 = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _a2.delete(handler);
87
- if (((_b = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _b.size) === 0) {
88
- const listener = (_c = listenerCache.get(node)) == null ? void 0 : _c.get(hash);
89
- node.removeEventListener(type, listener, options);
90
- group2 == null ? void 0 : group2.delete(hash);
91
- (_d = listenerCache.get(node)) == null ? void 0 : _d.delete(hash);
92
- if ((group2 == null ? void 0 : group2.size) === 0) {
93
- listenerElements.delete(node);
94
- listenerCache.delete(node);
95
- }
96
- }
37
+ var isRef = (v) => hasProp(v, "current");
38
+ function addDomEvent(target, eventName, handler, options) {
39
+ const node = isRef(target) ? target.current : runIfFn(target);
40
+ node == null ? void 0 : node.addEventListener(eventName, handler, options);
41
+ return () => {
42
+ node == null ? void 0 : node.removeEventListener(eventName, handler, options);
97
43
  };
98
44
  }
99
- var t = (v) => Object.prototype.toString.call(v).slice(8, -1);
100
- var isRef = (v) => t(v) === "Object" && "current" in v;
101
- var runIfFn = (fn) => t(fn) === "Function" ? fn() : fn;
102
- function addDomEvent(target, event, listener, options) {
103
- const node = isRef(target) ? target.current : runIfFn(target);
104
- return globalEventBus(node, event, listener, options);
45
+ function raf(fn) {
46
+ const id = globalThis.requestAnimationFrame(fn);
47
+ return function cleanup() {
48
+ globalThis.cancelAnimationFrame(id);
49
+ };
105
50
  }
106
51
  var MAX_Z_INDEX = 2147483647;
107
- function getNativeEvent(event) {
52
+ function getNativeEvent(e) {
108
53
  var _a;
109
- return (_a = event.nativeEvent) != null ? _a : event;
110
- }
111
- var PAGE_KEYS = /* @__PURE__ */ new Set(["PageUp", "PageDown"]);
112
- var ARROW_KEYS = /* @__PURE__ */ new Set(["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"]);
113
- function getEventStep(event) {
114
- if (event.ctrlKey || event.metaKey) {
115
- return 0.1;
116
- } else {
117
- const isPageKey = PAGE_KEYS.has(event.key);
118
- const isSkipKey = isPageKey || event.shiftKey && ARROW_KEYS.has(event.key);
119
- return isSkipKey ? 10 : 1;
120
- }
54
+ return (_a = e.nativeEvent) != null ? _a : e;
121
55
  }
122
56
  function observeAttributes(node, attributes, fn) {
123
57
  if (!node)
@@ -134,29 +68,16 @@ function observeAttributes(node, attributes, fn) {
134
68
  obs.observe(node, { attributes: true, attributeFilter: attrs });
135
69
  return () => obs.disconnect();
136
70
  }
137
- function itemById(v, id) {
138
- return v.find((node) => node.id === id);
139
- }
140
- function indexOfId(v, id) {
141
- const item = itemById(v, id);
142
- return item ? v.indexOf(item) : -1;
143
- }
144
- var getValueText = (item) => {
145
- var _a, _b;
146
- return (_b = (_a = item.dataset.valuetext) != null ? _a : item.textContent) != null ? _b : "";
147
- };
148
- var match = (valueText, query2) => valueText.toLowerCase().startsWith(query2.toLowerCase());
149
- var wrap = (v, idx) => {
150
- return v.map((_, index) => v[(Math.max(idx, 0) + index) % v.length]);
151
- };
152
- function findByText(v, text, currentId) {
153
- const index = currentId ? indexOfId(v, currentId) : -1;
154
- let items = currentId ? wrap(v, index) : v;
155
- const isSingleKey = text.length === 1;
156
- if (isSingleKey) {
157
- items = items.filter((item) => item.id !== currentId);
71
+ var PAGE_KEYS = /* @__PURE__ */ new Set(["PageUp", "PageDown"]);
72
+ var ARROW_KEYS = /* @__PURE__ */ new Set(["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"]);
73
+ function getEventStep(event) {
74
+ if (event.ctrlKey || event.metaKey) {
75
+ return 0.1;
76
+ } else {
77
+ const isPageKey = PAGE_KEYS.has(event.key);
78
+ const isSkipKey = isPageKey || event.shiftKey && ARROW_KEYS.has(event.key);
79
+ return isSkipKey ? 10 : 1;
158
80
  }
159
- return items.find((item) => match(getValueText(item), text));
160
81
  }
161
82
  function addPointerlockChangeListener(doc, fn) {
162
83
  return addDomEvent(doc, "pointerlockchange", fn, false);
@@ -198,38 +119,10 @@ function requestPointerLock(doc, handlers = {}) {
198
119
  exit();
199
120
  };
200
121
  }
201
- function findByTypeahead(_items, options) {
202
- const { state: state2, activeId, key, timeout = 350 } = options;
203
- const search = state2.keysSoFar + key;
204
- const isRepeated = search.length > 1 && Array.from(search).every((char) => char === search[0]);
205
- const query2 = isRepeated ? search[0] : search;
206
- let items = _items.slice();
207
- const next = findByText(items, query2, activeId);
208
- function cleanup() {
209
- clearTimeout(state2.timer);
210
- state2.timer = -1;
211
- }
212
- function update(value) {
213
- state2.keysSoFar = value;
214
- cleanup();
215
- if (value !== "") {
216
- state2.timer = +setTimeout(() => {
217
- update("");
218
- cleanup();
219
- }, timeout);
220
- }
221
- }
222
- update(search);
223
- return next;
224
- }
225
- findByTypeahead.defaultOptions = {
226
- keysSoFar: "",
227
- timer: -1
228
- };
229
122
 
230
123
  // ../../utilities/number/dist/index.mjs
231
124
  var __pow = Math.pow;
232
- function wrap2(num, max) {
125
+ function wrap(num, max) {
233
126
  return (num % max + max) % max;
234
127
  }
235
128
  function roundToDevicePixel(num) {
@@ -295,32 +188,42 @@ var nf = new Intl.NumberFormat("en-US", { style: "decimal", maximumFractionDigit
295
188
  // ../../utilities/rect/dist/index.mjs
296
189
  var isArray = (v) => Array.isArray(v);
297
190
  var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
298
- var isTouchEvent = (v) => isObject(v) && "touches" in v;
191
+ var hasProp2 = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
192
+ var isTouchEvent = (v) => isObject(v) && hasProp2(v, "touches");
299
193
  var fallback = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 };
300
- function getEventPoint(e, t2 = "page") {
194
+ function getEventPoint(e, t = "page") {
301
195
  const p = isTouchEvent(e) ? e.touches[0] || e.changedTouches[0] || fallback : e;
302
- return { x: p[`${t2}X`], y: p[`${t2}Y`] };
196
+ return { x: p[`${t}X`], y: p[`${t}Y`] };
303
197
  }
304
198
 
305
199
  // ../../types/dist/index.mjs
306
200
  function createNormalizer(fn) {
307
- return { button: fn, label: fn, input: fn, output: fn, element: fn };
201
+ return new Proxy({}, {
202
+ get() {
203
+ return fn;
204
+ }
205
+ });
308
206
  }
309
207
  var normalizeProp = createNormalizer((v) => v);
310
208
 
311
209
  // ../../utilities/core/dist/index.mjs
312
- var pipe2 = (...fns) => (v) => fns.reduce((a, b) => b(a), v);
313
- var platform = (v) => isDom() && v.test(navigator.platform);
314
- var ua = (v) => isDom() && v.test(navigator.userAgent);
315
- var isDom = () => !!(typeof window !== "undefined");
316
- var isMac = () => platform(/^Mac/);
317
- var isIPhone = () => platform(/^iPhone/);
318
- var isIPad = () => platform(/^iPad/) || isMac() && navigator.maxTouchPoints > 1;
319
- var isIos = () => isIPhone() || isIPad();
320
- var isSafari = () => ua(/^((?!chrome|android).)*safari/i);
210
+ var isDom = () => typeof window !== "undefined";
211
+ function getPlatform() {
212
+ var _a;
213
+ const agent = navigator.userAgentData;
214
+ return (_a = agent == null ? void 0 : agent.platform) != null ? _a : navigator.platform;
215
+ }
216
+ var pt = (v) => isDom() && v.test(getPlatform());
217
+ var vn = (v) => isDom() && v.test(navigator.vendor);
218
+ var isTouchDevice = () => isDom() && !!navigator.maxTouchPoints;
219
+ var isMac = () => pt(/^Mac/) && !isTouchDevice;
220
+ var isSafari = () => isApple() && vn(/apple/i);
221
+ var isApple = () => pt(/mac|iphone|ipad|ipod/i);
222
+ var isIos = () => isApple() && !isMac();
321
223
  var supportsPointerEvent = () => isDom() && window.onpointerdown === null;
322
224
  var isLeftClick = (v) => v.button === 0;
323
225
  var isModifiedEvent = (v) => v.ctrlKey || v.altKey || v.metaKey;
226
+ var pipe2 = (...fns) => (v) => fns.reduce((a, b) => b(a), v);
324
227
 
325
228
  // src/number-input.dom.ts
326
229
  var dom = {
@@ -381,7 +284,7 @@ var dom = {
381
284
  const win = dom.getWin(ctx);
382
285
  const width = win.innerWidth;
383
286
  const half = roundToDevicePixel(7.5);
384
- point.x = wrap2(point.x + half, width) - half;
287
+ point.x = wrap(point.x + half, width) - half;
385
288
  return { hint, point };
386
289
  },
387
290
  createVirtualCursor(ctx) {
@@ -1033,4 +936,3 @@ export {
1033
936
  connect,
1034
937
  machine
1035
938
  };
1036
- //# sourceMappingURL=index.mjs.map
@@ -20,4 +20,3 @@ export declare function connect<T extends PropTypes = ReactPropTypes>(state: Sta
20
20
  incrementButtonProps: T["button"];
21
21
  scrubberProps: T["element"];
22
22
  };
23
- //# sourceMappingURL=number-input.connect.d.ts.map
@@ -24,4 +24,3 @@ export declare const dom: {
24
24
  };
25
25
  createVirtualCursor(ctx: Ctx): void;
26
26
  };
27
- //# sourceMappingURL=number-input.dom.d.ts.map
@@ -1,3 +1,2 @@
1
1
  import type { MachineContext, MachineState, UserDefinedContext } from "./number-input.types";
2
2
  export declare function machine(ctx?: UserDefinedContext): import("@zag-js/core").Machine<MachineContext, MachineState, import("@zag-js/core").StateMachine.AnyEventObject>;
3
- //# sourceMappingURL=number-input.machine.d.ts.map
@@ -196,4 +196,3 @@ export declare type MachineState = {
196
196
  export declare type State = S.State<MachineContext, MachineState>;
197
197
  export declare type Send = S.Send<S.AnyEventObject>;
198
198
  export {};
199
- //# sourceMappingURL=number-input.types.d.ts.map
@@ -11,4 +11,3 @@ export declare const utils: {
11
11
  format: (ctx: Ctx, value: string | number) => string | number;
12
12
  round: (ctx: Ctx) => string;
13
13
  };
14
- //# sourceMappingURL=number-input.utils.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/number-input",
3
- "version": "0.1.7",
3
+ "version": "0.1.10",
4
4
  "description": "Core logic for the number-input widget implemented as a state machine",
5
5
  "keywords": [
6
6
  "js",
@@ -29,12 +29,12 @@
29
29
  "url": "https://github.com/chakra-ui/zag/issues"
30
30
  },
31
31
  "dependencies": {
32
- "@zag-js/core": "0.1.4",
33
- "@zag-js/dom-utils": "0.1.2",
32
+ "@zag-js/core": "0.1.6",
33
+ "@zag-js/dom-utils": "0.1.5",
34
34
  "@zag-js/number-utils": "0.1.2",
35
- "@zag-js/rect-utils": "0.1.1",
36
- "@zag-js/types": "0.1.1",
37
- "@zag-js/utils": "0.1.1"
35
+ "@zag-js/rect-utils": "0.1.2",
36
+ "@zag-js/types": "0.2.0",
37
+ "@zag-js/utils": "0.1.2"
38
38
  },
39
39
  "scripts": {
40
40
  "build:fast": "zag build",
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAChD,YAAY,EAAE,kBAAkB,IAAI,OAAO,EAAE,MAAM,sBAAsB,CAAA"}