@zag-js/interact-outside
Advanced tools
Comparing version 0.0.0-dev-20221229205502 to 0.0.0-dev-20230201181615
@@ -30,7 +30,7 @@ "use strict"; | ||
const res = typeof v === "function" ? v(...a) : v; | ||
return res != null ? res : void 0; | ||
return res ?? void 0; | ||
}; | ||
var callAll = (...fns) => (...a) => { | ||
fns.forEach(function(fn) { | ||
fn == null ? void 0 : fn(...a); | ||
fn?.(...a); | ||
}); | ||
@@ -45,5 +45,4 @@ }; | ||
function getPlatform() { | ||
var _a; | ||
const agent = navigator.userAgentData; | ||
return (_a = agent == null ? void 0 : agent.platform) != null ? _a : navigator.platform; | ||
return agent?.platform ?? navigator.platform; | ||
} | ||
@@ -59,6 +58,5 @@ var pt = (v) => isDom() && v.test(getPlatform()); | ||
function isWindow(value) { | ||
return (value == null ? void 0 : value.toString()) === "[object Window]"; | ||
return value?.toString() === "[object Window]"; | ||
} | ||
function getDocument(el) { | ||
var _a; | ||
if (isWindow(el)) | ||
@@ -68,11 +66,9 @@ return el.document; | ||
return el; | ||
return (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document; | ||
return el?.ownerDocument ?? document; | ||
} | ||
function getWindow(el) { | ||
var _a; | ||
return (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window; | ||
return el?.ownerDocument.defaultView ?? window; | ||
} | ||
function getEventTarget(event) { | ||
var _a, _b; | ||
return (_b = (_a = event.composedPath) == null ? void 0 : _a.call(event)[0]) != null ? _b : event.target; | ||
return event.composedPath?.()[0] ?? event.target; | ||
} | ||
@@ -85,3 +81,3 @@ function contains(parent, child) { | ||
function isHTMLElement(v) { | ||
return typeof v === "object" && (v == null ? void 0 : v.nodeType) === Node.ELEMENT_NODE && typeof (v == null ? void 0 : v.nodeName) === "string"; | ||
return typeof v === "object" && v?.nodeType === Node.ELEMENT_NODE && typeof v?.nodeName === "string"; | ||
} | ||
@@ -121,5 +117,5 @@ function isVisible(el) { | ||
const node = isRef(target) ? target.current : runIfFn(target); | ||
node == null ? void 0 : node.addEventListener(eventName, handler, options); | ||
node?.addEventListener(eventName, handler, options); | ||
return () => { | ||
node == null ? void 0 : node.removeEventListener(eventName, handler, options); | ||
node?.removeEventListener(eventName, handler, options); | ||
}; | ||
@@ -148,3 +144,3 @@ } | ||
} | ||
return !(exclude == null ? void 0 : exclude(target)); | ||
return !exclude?.(target); | ||
} | ||
@@ -151,0 +147,0 @@ let clickHandler; |
{ | ||
"name": "@zag-js/interact-outside", | ||
"version": "0.0.0-dev-20221229205502", | ||
"version": "0.0.0-dev-20230201181615", | ||
"description": "Track interations or focus outside an element", | ||
@@ -20,4 +20,4 @@ "keywords": [ | ||
"clean-package": "2.2.0", | ||
"@zag-js/dom-utils": "0.0.0-dev-20221229205502", | ||
"@zag-js/utils": "0.0.0-dev-20221229205502" | ||
"@zag-js/dom-utils": "0.0.0-dev-20230201181615", | ||
"@zag-js/utils": "0.0.0-dev-20230201181615" | ||
}, | ||
@@ -24,0 +24,0 @@ "publishConfig": { |
Sorry, the diff of this file is not supported yet
15539
373