@zag-js/number-input 0.1.8 → 0.1.9

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.mjs CHANGED
@@ -31,6 +31,13 @@ function raf(fn) {
31
31
  globalThis.cancelAnimationFrame(id);
32
32
  };
33
33
  }
34
+ var isDom = () => typeof window !== "undefined";
35
+ var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
36
+ var isTouchDevice = isDom() && !!navigator.maxTouchPoints;
37
+ var runIfFn = (v, ...a) => {
38
+ const res = typeof v === "function" ? v(...a) : v;
39
+ return res != null ? res : void 0;
40
+ };
34
41
  var noop = () => {
35
42
  };
36
43
  var pipe = (...fns) => (v) => fns.reduce((a, b) => b(a), v);
@@ -44,7 +51,7 @@ function getListenerCache() {
44
51
  globalThis.__listenerCache__ = globalThis.__listenerCache__ || /* @__PURE__ */ new Map();
45
52
  return globalThis.__listenerCache__;
46
53
  }
47
- function globalEventBus(node, type, handler, options) {
54
+ function addGlobalEventListener(node, type, handler, options) {
48
55
  var _a;
49
56
  if (!node)
50
57
  return noop;
@@ -96,17 +103,15 @@ function globalEventBus(node, type, handler, options) {
96
103
  }
97
104
  };
98
105
  }
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;
106
+ var isRef = (v) => hasProp(v, "current");
102
107
  function addDomEvent(target, event, listener, options) {
103
108
  const node = isRef(target) ? target.current : runIfFn(target);
104
- return globalEventBus(node, event, listener, options);
109
+ return addGlobalEventListener(node, event, listener, options);
105
110
  }
106
111
  var MAX_Z_INDEX = 2147483647;
107
- function getNativeEvent(event) {
112
+ function getNativeEvent(e) {
108
113
  var _a;
109
- return (_a = event.nativeEvent) != null ? _a : event;
114
+ return (_a = e.nativeEvent) != null ? _a : e;
110
115
  }
111
116
  function observeAttributes(node, attributes, fn) {
112
117
  if (!node)
@@ -293,13 +298,16 @@ function decimalOperation(a, op, b) {
293
298
  var nf = new Intl.NumberFormat("en-US", { style: "decimal", maximumFractionDigits: 20 });
294
299
 
295
300
  // ../../utilities/rect/dist/index.mjs
301
+ var isDom2 = () => typeof window !== "undefined";
296
302
  var isArray = (v) => Array.isArray(v);
297
303
  var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
298
- var isTouchEvent = (v) => isObject(v) && "touches" in v;
304
+ var hasProp2 = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
305
+ var isTouchDevice2 = isDom2() && !!navigator.maxTouchPoints;
306
+ var isTouchEvent = (v) => isObject(v) && hasProp2(v, "touches");
299
307
  var fallback = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 };
300
- function getEventPoint(e, t2 = "page") {
308
+ function getEventPoint(e, t = "page") {
301
309
  const p = isTouchEvent(e) ? e.touches[0] || e.changedTouches[0] || fallback : e;
302
- return { x: p[`${t2}X`], y: p[`${t2}Y`] };
310
+ return { x: p[`${t}X`], y: p[`${t}Y`] };
303
311
  }
304
312
 
305
313
  // ../../types/dist/index.mjs
@@ -313,18 +321,23 @@ function createNormalizer(fn) {
313
321
  var normalizeProp = createNormalizer((v) => v);
314
322
 
315
323
  // ../../utilities/core/dist/index.mjs
316
- var pipe2 = (...fns) => (v) => fns.reduce((a, b) => b(a), v);
317
- var platform = (v) => isDom() && v.test(navigator.platform);
318
- var ua = (v) => isDom() && v.test(navigator.userAgent);
319
- var isDom = () => !!(typeof window !== "undefined");
320
- var isMac = () => platform(/^Mac/);
321
- var isIPhone = () => platform(/^iPhone/);
322
- var isIPad = () => platform(/^iPad/) || isMac() && navigator.maxTouchPoints > 1;
323
- var isIos = () => isIPhone() || isIPad();
324
- var isSafari = () => ua(/^((?!chrome|android).)*safari/i);
325
- var supportsPointerEvent = () => isDom() && window.onpointerdown === null;
324
+ var isDom3 = () => typeof window !== "undefined";
325
+ function getPlatform() {
326
+ var _a;
327
+ const agent = navigator.userAgentData;
328
+ return (_a = agent == null ? void 0 : agent.platform) != null ? _a : navigator.platform;
329
+ }
330
+ var pt = (v) => isDom3() && v.test(getPlatform());
331
+ var vn = (v) => isDom3() && v.test(navigator.vendor);
332
+ var isTouchDevice3 = isDom3() && !!navigator.maxTouchPoints;
333
+ var isMac = () => pt(/^Mac/) && !isTouchDevice3;
334
+ var isSafari = () => isApple() && vn(/apple/i);
335
+ var isApple = () => pt(/mac|iphone|ipad|ipod/i);
336
+ var isIos = () => isApple() && !isMac();
337
+ var supportsPointerEvent = () => isDom3() && window.onpointerdown === null;
326
338
  var isLeftClick = (v) => v.button === 0;
327
339
  var isModifiedEvent = (v) => v.ctrlKey || v.altKey || v.metaKey;
340
+ var pipe2 = (...fns) => (v) => fns.reduce((a, b) => b(a), v);
328
341
 
329
342
  // src/number-input.dom.ts
330
343
  var dom = {