@zag-js/interact-outside 0.2.1 → 0.2.2

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
@@ -27,11 +27,11 @@ module.exports = __toCommonJS(src_exports);
27
27
  // ../core/src/functions.ts
28
28
  var runIfFn = (v, ...a) => {
29
29
  const res = typeof v === "function" ? v(...a) : v;
30
- return res != null ? res : void 0;
30
+ return res ?? void 0;
31
31
  };
32
32
  var callAll = (...fns) => (...a) => {
33
33
  fns.forEach(function(fn) {
34
- fn == null ? void 0 : fn(...a);
34
+ fn?.(...a);
35
35
  });
36
36
  };
37
37
 
@@ -41,9 +41,8 @@ var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
41
41
  // ../dom/src/platform.ts
42
42
  var isDom = () => typeof window !== "undefined";
43
43
  function getPlatform() {
44
- var _a;
45
44
  const agent = navigator.userAgentData;
46
- return (_a = agent == null ? void 0 : agent.platform) != null ? _a : navigator.platform;
45
+ return agent?.platform ?? navigator.platform;
47
46
  }
48
47
  var pt = (v) => isDom() && v.test(getPlatform());
49
48
  var isTouchDevice = () => isDom() && !!navigator.maxTouchPoints;
@@ -54,23 +53,20 @@ function isDocument(el) {
54
53
  return el.nodeType === Node.DOCUMENT_NODE;
55
54
  }
56
55
  function isWindow(value) {
57
- return (value == null ? void 0 : value.toString()) === "[object Window]";
56
+ return value?.toString() === "[object Window]";
58
57
  }
59
58
  function getDocument(el) {
60
- var _a;
61
59
  if (isWindow(el))
62
60
  return el.document;
63
61
  if (isDocument(el))
64
62
  return el;
65
- return (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document;
63
+ return el?.ownerDocument ?? document;
66
64
  }
67
65
  function getWindow(el) {
68
- var _a;
69
- return (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window;
66
+ return el?.ownerDocument.defaultView ?? window;
70
67
  }
71
68
  function getEventTarget(event) {
72
- var _a, _b;
73
- return (_b = (_a = event.composedPath) == null ? void 0 : _a.call(event)[0]) != null ? _b : event.target;
69
+ return event.composedPath?.()[0] ?? event.target;
74
70
  }
75
71
  function contains(parent, child) {
76
72
  if (!parent)
@@ -78,7 +74,7 @@ function contains(parent, child) {
78
74
  return parent === child || isHTMLElement(parent) && isHTMLElement(child) && parent.contains(child);
79
75
  }
80
76
  function isHTMLElement(v) {
81
- return typeof v === "object" && (v == null ? void 0 : v.nodeType) === Node.ELEMENT_NODE && typeof (v == null ? void 0 : v.nodeName) === "string";
77
+ return typeof v === "object" && v?.nodeType === Node.ELEMENT_NODE && typeof v?.nodeName === "string";
82
78
  }
83
79
  function isVisible(el) {
84
80
  if (!isHTMLElement(el))
@@ -113,9 +109,9 @@ function isFocusable(element) {
113
109
  var isRef = (v) => hasProp(v, "current");
114
110
  function addDomEvent(target, eventName, handler, options) {
115
111
  const node = isRef(target) ? target.current : runIfFn(target);
116
- node == null ? void 0 : node.addEventListener(eventName, handler, options);
112
+ node?.addEventListener(eventName, handler, options);
117
113
  return () => {
118
- node == null ? void 0 : node.removeEventListener(eventName, handler, options);
114
+ node?.removeEventListener(eventName, handler, options);
119
115
  };
120
116
  }
121
117
 
@@ -139,7 +135,7 @@ function trackInteractOutside(node, options) {
139
135
  if (contains(node, target)) {
140
136
  return false;
141
137
  }
142
- return !(exclude == null ? void 0 : exclude(target));
138
+ return !exclude?.(target);
143
139
  }
144
140
  let clickHandler;
145
141
  function onPointerDown(event) {
package/dist/index.mjs CHANGED
@@ -1,11 +1,11 @@
1
1
  // ../core/src/functions.ts
2
2
  var runIfFn = (v, ...a) => {
3
3
  const res = typeof v === "function" ? v(...a) : v;
4
- return res != null ? res : void 0;
4
+ return res ?? void 0;
5
5
  };
6
6
  var callAll = (...fns) => (...a) => {
7
7
  fns.forEach(function(fn) {
8
- fn == null ? void 0 : fn(...a);
8
+ fn?.(...a);
9
9
  });
10
10
  };
11
11
 
@@ -15,9 +15,8 @@ var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
15
15
  // ../dom/src/platform.ts
16
16
  var isDom = () => typeof window !== "undefined";
17
17
  function getPlatform() {
18
- var _a;
19
18
  const agent = navigator.userAgentData;
20
- return (_a = agent == null ? void 0 : agent.platform) != null ? _a : navigator.platform;
19
+ return agent?.platform ?? navigator.platform;
21
20
  }
22
21
  var pt = (v) => isDom() && v.test(getPlatform());
23
22
  var isTouchDevice = () => isDom() && !!navigator.maxTouchPoints;
@@ -28,23 +27,20 @@ function isDocument(el) {
28
27
  return el.nodeType === Node.DOCUMENT_NODE;
29
28
  }
30
29
  function isWindow(value) {
31
- return (value == null ? void 0 : value.toString()) === "[object Window]";
30
+ return value?.toString() === "[object Window]";
32
31
  }
33
32
  function getDocument(el) {
34
- var _a;
35
33
  if (isWindow(el))
36
34
  return el.document;
37
35
  if (isDocument(el))
38
36
  return el;
39
- return (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document;
37
+ return el?.ownerDocument ?? document;
40
38
  }
41
39
  function getWindow(el) {
42
- var _a;
43
- return (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window;
40
+ return el?.ownerDocument.defaultView ?? window;
44
41
  }
45
42
  function getEventTarget(event) {
46
- var _a, _b;
47
- return (_b = (_a = event.composedPath) == null ? void 0 : _a.call(event)[0]) != null ? _b : event.target;
43
+ return event.composedPath?.()[0] ?? event.target;
48
44
  }
49
45
  function contains(parent, child) {
50
46
  if (!parent)
@@ -52,7 +48,7 @@ function contains(parent, child) {
52
48
  return parent === child || isHTMLElement(parent) && isHTMLElement(child) && parent.contains(child);
53
49
  }
54
50
  function isHTMLElement(v) {
55
- return typeof v === "object" && (v == null ? void 0 : v.nodeType) === Node.ELEMENT_NODE && typeof (v == null ? void 0 : v.nodeName) === "string";
51
+ return typeof v === "object" && v?.nodeType === Node.ELEMENT_NODE && typeof v?.nodeName === "string";
56
52
  }
57
53
  function isVisible(el) {
58
54
  if (!isHTMLElement(el))
@@ -87,9 +83,9 @@ function isFocusable(element) {
87
83
  var isRef = (v) => hasProp(v, "current");
88
84
  function addDomEvent(target, eventName, handler, options) {
89
85
  const node = isRef(target) ? target.current : runIfFn(target);
90
- node == null ? void 0 : node.addEventListener(eventName, handler, options);
86
+ node?.addEventListener(eventName, handler, options);
91
87
  return () => {
92
- node == null ? void 0 : node.removeEventListener(eventName, handler, options);
88
+ node?.removeEventListener(eventName, handler, options);
93
89
  };
94
90
  }
95
91
 
@@ -113,7 +109,7 @@ function trackInteractOutside(node, options) {
113
109
  if (contains(node, target)) {
114
110
  return false;
115
111
  }
116
- return !(exclude == null ? void 0 : exclude(target));
112
+ return !exclude?.(target);
117
113
  }
118
114
  let clickHandler;
119
115
  function onPointerDown(event) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/interact-outside",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Track interations or focus outside an element",
5
5
  "keywords": [
6
6
  "js",
@@ -17,8 +17,8 @@
17
17
  ],
18
18
  "devDependencies": {
19
19
  "clean-package": "2.2.0",
20
- "@zag-js/dom-utils": "0.2.2",
21
- "@zag-js/utils": "0.3.2"
20
+ "@zag-js/dom-utils": "0.2.4",
21
+ "@zag-js/utils": "0.3.3"
22
22
  },
23
23
  "publishConfig": {
24
24
  "access": "public"