@zag-js/splitter 0.1.6 → 0.1.7

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
@@ -39,19 +39,33 @@ function raf(fn) {
39
39
  globalThis.cancelAnimationFrame(id);
40
40
  };
41
41
  }
42
- var noop = () => {
43
- };
44
- var pipe = (...fns) => (v) => fns.reduce((a, b) => b(a), v);
45
- var platform = (v) => isDom() && v.test(navigator.platform);
46
- var isDom = () => !!(typeof window !== "undefined");
47
- var isMac = () => platform(/^Mac/);
48
- var isIPhone = () => platform(/^iPhone/);
49
- var isIPad = () => platform(/^iPad/) || isMac() && navigator.maxTouchPoints > 1;
50
- var isIos = () => isIPhone() || isIPad();
42
+ var isDom = () => typeof window !== "undefined";
51
43
  var isArray = (v) => Array.isArray(v);
52
44
  var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
53
- var isMouseEvent = (v) => isObject(v) && "button" in v;
45
+ var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
46
+ function getPlatform() {
47
+ var _a;
48
+ const agent = navigator.userAgentData;
49
+ return (_a = agent == null ? void 0 : agent.platform) != null ? _a : navigator.platform;
50
+ }
51
+ var pt = (v) => isDom() && v.test(getPlatform());
52
+ var isTouchDevice = isDom() && !!navigator.maxTouchPoints;
53
+ var isMac = () => pt(/^Mac/) && !isTouchDevice;
54
+ var isApple = () => pt(/mac|iphone|ipad|ipod/i);
55
+ var isIos = () => isApple() && !isMac();
56
+ var supportsPointerEvent = () => isDom() && window.onpointerdown === null;
57
+ var supportsTouchEvent = () => isDom() && window.ontouchstart === null;
58
+ var supportsMouseEvent = () => isDom() && window.onmousedown === null;
59
+ var isMouseEvent = (v) => isObject(v) && hasProp(v, "button");
60
+ var isTouchEvent = (v) => isObject(v) && hasProp(v, "touches");
54
61
  var isLeftClick = (v) => v.button === 0;
62
+ var runIfFn = (v, ...a) => {
63
+ const res = typeof v === "function" ? v(...a) : v;
64
+ return res != null ? res : void 0;
65
+ };
66
+ var noop = () => {
67
+ };
68
+ var pipe = (...fns) => (v) => fns.reduce((a, b) => b(a), v);
55
69
  function getListenerElements() {
56
70
  ;
57
71
  globalThis.__listenerElements__ = globalThis.__listenerElements__ || /* @__PURE__ */ new Map();
@@ -62,7 +76,7 @@ function getListenerCache() {
62
76
  globalThis.__listenerCache__ = globalThis.__listenerCache__ || /* @__PURE__ */ new Map();
63
77
  return globalThis.__listenerCache__;
64
78
  }
65
- function globalEventBus(node, type, handler, options) {
79
+ function addGlobalEventListener(node, type, handler, options) {
66
80
  var _a;
67
81
  if (!node)
68
82
  return noop;
@@ -114,10 +128,7 @@ function globalEventBus(node, type, handler, options) {
114
128
  }
115
129
  };
116
130
  }
117
- var t = (v) => Object.prototype.toString.call(v).slice(8, -1);
118
- var isRef = (v) => t(v) === "Object" && "current" in v;
119
- var runIfFn = (fn) => t(fn) === "Function" ? fn() : fn;
120
- var isTouchEvent = (v) => t(v) === "Object" && !!v.touches;
131
+ var isRef = (v) => hasProp(v, "current");
121
132
  var fallback = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 };
122
133
  function extractInfo(event, type = "page") {
123
134
  const point = isTouchEvent(event) ? event.touches[0] || event.changedTouches[0] || fallback : event;
@@ -130,7 +141,7 @@ function extractInfo(event, type = "page") {
130
141
  }
131
142
  function addDomEvent(target, event, listener, options) {
132
143
  const node = isRef(target) ? target.current : runIfFn(target);
133
- return globalEventBus(node, event, listener, options);
144
+ return addGlobalEventListener(node, event, listener, options);
134
145
  }
135
146
  function addPointerEvent(target, event, listener, options) {
136
147
  var _a;
@@ -153,9 +164,6 @@ function filterPrimaryPointer(fn) {
153
164
  fn(event);
154
165
  };
155
166
  }
156
- var supportsPointerEvent = () => typeof window !== "undefined" && window.onpointerdown === null;
157
- var supportsTouchEvent = () => typeof window !== "undefined" && window.ontouchstart === null;
158
- var supportsMouseEvent = () => typeof window !== "undefined" && window.onmousedown === null;
159
167
  var mouseEventNames = {
160
168
  pointerdown: "mousedown",
161
169
  pointermove: "mousemove",
@@ -562,11 +570,11 @@ import { createMachine, guards, ref } from "@zag-js/core";
562
570
 
563
571
  // ../../utilities/number/dist/index.mjs
564
572
  var __pow2 = Math.pow;
565
- function round(v, t2) {
573
+ function round(v, t) {
566
574
  let num = valueOf(v);
567
- const p = __pow2(10, t2 != null ? t2 : 10);
575
+ const p = __pow2(10, t != null ? t : 10);
568
576
  num = Math.round(num * p) / p;
569
- return t2 ? num.toFixed(t2) : v.toString();
577
+ return t ? num.toFixed(t) : v.toString();
570
578
  }
571
579
  function clamp(v, o) {
572
580
  return Math.min(Math.max(valueOf(v), o.min), o.max);
@@ -609,6 +617,8 @@ function decimalOperation(a, op, b) {
609
617
  var nf = new Intl.NumberFormat("en-US", { style: "decimal", maximumFractionDigits: 20 });
610
618
 
611
619
  // ../../utilities/rect/dist/index.mjs
620
+ var isDom2 = () => typeof window !== "undefined";
621
+ var isTouchDevice2 = isDom2() && !!navigator.maxTouchPoints;
612
622
  function relativeToNode(p, el) {
613
623
  const dx = p.x - el.offsetLeft - el.clientLeft + el.scrollLeft;
614
624
  const dy = p.y - el.offsetTop - el.clientTop + el.scrollTop;