@zag-js/number-input 0.0.0-dev-20220526115355 → 0.0.0-dev-20220603082742

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.js CHANGED
@@ -54,9 +54,14 @@ function raf(fn) {
54
54
  globalThis.cancelAnimationFrame(id);
55
55
  };
56
56
  }
57
+ var runIfFn = (v, ...a) => {
58
+ const res = typeof v === "function" ? v(...a) : v;
59
+ return res != null ? res : void 0;
60
+ };
57
61
  var noop = () => {
58
62
  };
59
63
  var pipe = (...fns) => (v) => fns.reduce((a, b) => b(a), v);
64
+ var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
60
65
  function getListenerElements() {
61
66
  ;
62
67
  globalThis.__listenerElements__ = globalThis.__listenerElements__ || /* @__PURE__ */ new Map();
@@ -67,7 +72,7 @@ function getListenerCache() {
67
72
  globalThis.__listenerCache__ = globalThis.__listenerCache__ || /* @__PURE__ */ new Map();
68
73
  return globalThis.__listenerCache__;
69
74
  }
70
- function globalEventBus(node, type, handler, options) {
75
+ function addGlobalEventListener(node, type, handler, options) {
71
76
  var _a;
72
77
  if (!node)
73
78
  return noop;
@@ -119,17 +124,15 @@ function globalEventBus(node, type, handler, options) {
119
124
  }
120
125
  };
121
126
  }
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;
127
+ var isRef = (v) => hasProp(v, "current");
125
128
  function addDomEvent(target, event, listener, options) {
126
129
  const node = isRef(target) ? target.current : runIfFn(target);
127
- return globalEventBus(node, event, listener, options);
130
+ return addGlobalEventListener(node, event, listener, options);
128
131
  }
129
132
  var MAX_Z_INDEX = 2147483647;
130
- function getNativeEvent(event) {
133
+ function getNativeEvent(e) {
131
134
  var _a;
132
- return (_a = event.nativeEvent) != null ? _a : event;
135
+ return (_a = e.nativeEvent) != null ? _a : e;
133
136
  }
134
137
  function observeAttributes(node, attributes, fn) {
135
138
  if (!node)
@@ -318,11 +321,12 @@ var nf = new Intl.NumberFormat("en-US", { style: "decimal", maximumFractionDigit
318
321
  // ../../utilities/rect/dist/index.mjs
319
322
  var isArray = (v) => Array.isArray(v);
320
323
  var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
321
- var isTouchEvent = (v) => isObject(v) && "touches" in v;
324
+ var hasProp2 = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
325
+ var isTouchEvent = (v) => isObject(v) && hasProp2(v, "touches");
322
326
  var fallback = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 };
323
- function getEventPoint(e, t2 = "page") {
327
+ function getEventPoint(e, t = "page") {
324
328
  const p = isTouchEvent(e) ? e.touches[0] || e.changedTouches[0] || fallback : e;
325
- return { x: p[`${t2}X`], y: p[`${t2}Y`] };
329
+ return { x: p[`${t}X`], y: p[`${t}Y`] };
326
330
  }
327
331
 
328
332
  // ../../types/dist/index.mjs
@@ -339,7 +343,7 @@ var normalizeProp = createNormalizer((v) => v);
339
343
  var pipe2 = (...fns) => (v) => fns.reduce((a, b) => b(a), v);
340
344
  var platform = (v) => isDom() && v.test(navigator.platform);
341
345
  var ua = (v) => isDom() && v.test(navigator.userAgent);
342
- var isDom = () => !!(typeof window !== "undefined");
346
+ var isDom = () => typeof window !== "undefined";
343
347
  var isMac = () => platform(/^Mac/);
344
348
  var isIPhone = () => platform(/^iPhone/);
345
349
  var isIPad = () => platform(/^iPad/) || isMac() && navigator.maxTouchPoints > 1;