@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.js CHANGED
@@ -62,19 +62,33 @@ function raf(fn) {
62
62
  globalThis.cancelAnimationFrame(id);
63
63
  };
64
64
  }
65
- var noop = () => {
66
- };
67
- var pipe = (...fns) => (v) => fns.reduce((a, b) => b(a), v);
68
- var platform = (v) => isDom() && v.test(navigator.platform);
69
- var isDom = () => !!(typeof window !== "undefined");
70
- var isMac = () => platform(/^Mac/);
71
- var isIPhone = () => platform(/^iPhone/);
72
- var isIPad = () => platform(/^iPad/) || isMac() && navigator.maxTouchPoints > 1;
73
- var isIos = () => isIPhone() || isIPad();
65
+ var isDom = () => typeof window !== "undefined";
74
66
  var isArray = (v) => Array.isArray(v);
75
67
  var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
76
- var isMouseEvent = (v) => isObject(v) && "button" in v;
68
+ var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
69
+ function getPlatform() {
70
+ var _a;
71
+ const agent = navigator.userAgentData;
72
+ return (_a = agent == null ? void 0 : agent.platform) != null ? _a : navigator.platform;
73
+ }
74
+ var pt = (v) => isDom() && v.test(getPlatform());
75
+ var isTouchDevice = isDom() && !!navigator.maxTouchPoints;
76
+ var isMac = () => pt(/^Mac/) && !isTouchDevice;
77
+ var isApple = () => pt(/mac|iphone|ipad|ipod/i);
78
+ var isIos = () => isApple() && !isMac();
79
+ var supportsPointerEvent = () => isDom() && window.onpointerdown === null;
80
+ var supportsTouchEvent = () => isDom() && window.ontouchstart === null;
81
+ var supportsMouseEvent = () => isDom() && window.onmousedown === null;
82
+ var isMouseEvent = (v) => isObject(v) && hasProp(v, "button");
83
+ var isTouchEvent = (v) => isObject(v) && hasProp(v, "touches");
77
84
  var isLeftClick = (v) => v.button === 0;
85
+ var runIfFn = (v, ...a) => {
86
+ const res = typeof v === "function" ? v(...a) : v;
87
+ return res != null ? res : void 0;
88
+ };
89
+ var noop = () => {
90
+ };
91
+ var pipe = (...fns) => (v) => fns.reduce((a, b) => b(a), v);
78
92
  function getListenerElements() {
79
93
  ;
80
94
  globalThis.__listenerElements__ = globalThis.__listenerElements__ || /* @__PURE__ */ new Map();
@@ -85,7 +99,7 @@ function getListenerCache() {
85
99
  globalThis.__listenerCache__ = globalThis.__listenerCache__ || /* @__PURE__ */ new Map();
86
100
  return globalThis.__listenerCache__;
87
101
  }
88
- function globalEventBus(node, type, handler, options) {
102
+ function addGlobalEventListener(node, type, handler, options) {
89
103
  var _a;
90
104
  if (!node)
91
105
  return noop;
@@ -137,10 +151,7 @@ function globalEventBus(node, type, handler, options) {
137
151
  }
138
152
  };
139
153
  }
140
- var t = (v) => Object.prototype.toString.call(v).slice(8, -1);
141
- var isRef = (v) => t(v) === "Object" && "current" in v;
142
- var runIfFn = (fn) => t(fn) === "Function" ? fn() : fn;
143
- var isTouchEvent = (v) => t(v) === "Object" && !!v.touches;
154
+ var isRef = (v) => hasProp(v, "current");
144
155
  var fallback = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 };
145
156
  function extractInfo(event, type = "page") {
146
157
  const point = isTouchEvent(event) ? event.touches[0] || event.changedTouches[0] || fallback : event;
@@ -153,7 +164,7 @@ function extractInfo(event, type = "page") {
153
164
  }
154
165
  function addDomEvent(target, event, listener, options) {
155
166
  const node = isRef(target) ? target.current : runIfFn(target);
156
- return globalEventBus(node, event, listener, options);
167
+ return addGlobalEventListener(node, event, listener, options);
157
168
  }
158
169
  function addPointerEvent(target, event, listener, options) {
159
170
  var _a;
@@ -176,9 +187,6 @@ function filterPrimaryPointer(fn) {
176
187
  fn(event);
177
188
  };
178
189
  }
179
- var supportsPointerEvent = () => typeof window !== "undefined" && window.onpointerdown === null;
180
- var supportsTouchEvent = () => typeof window !== "undefined" && window.ontouchstart === null;
181
- var supportsMouseEvent = () => typeof window !== "undefined" && window.onmousedown === null;
182
190
  var mouseEventNames = {
183
191
  pointerdown: "mousedown",
184
192
  pointermove: "mousemove",
@@ -585,11 +593,11 @@ var import_core = require("@zag-js/core");
585
593
 
586
594
  // ../../utilities/number/dist/index.mjs
587
595
  var __pow2 = Math.pow;
588
- function round(v, t2) {
596
+ function round(v, t) {
589
597
  let num = valueOf(v);
590
- const p = __pow2(10, t2 != null ? t2 : 10);
598
+ const p = __pow2(10, t != null ? t : 10);
591
599
  num = Math.round(num * p) / p;
592
- return t2 ? num.toFixed(t2) : v.toString();
600
+ return t ? num.toFixed(t) : v.toString();
593
601
  }
594
602
  function clamp(v, o) {
595
603
  return Math.min(Math.max(valueOf(v), o.min), o.max);
@@ -632,6 +640,8 @@ function decimalOperation(a, op, b) {
632
640
  var nf = new Intl.NumberFormat("en-US", { style: "decimal", maximumFractionDigits: 20 });
633
641
 
634
642
  // ../../utilities/rect/dist/index.mjs
643
+ var isDom2 = () => typeof window !== "undefined";
644
+ var isTouchDevice2 = isDom2() && !!navigator.maxTouchPoints;
635
645
  function relativeToNode(p, el) {
636
646
  const dx = p.x - el.offsetLeft - el.clientLeft + el.scrollLeft;
637
647
  const dy = p.y - el.offsetTop - el.clientTop + el.scrollTop;