@zag-js/interact-outside 0.2.4 → 0.2.6

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
@@ -70,6 +70,14 @@ function getWindowFrames(win) {
70
70
  // src/index.ts
71
71
  var POINTER_OUTSIDE_EVENT = "pointerdown.outside";
72
72
  var FOCUS_OUTSIDE_EVENT = "focus.outside";
73
+ function isComposedPathFocusable(event) {
74
+ const composedPath = event.composedPath() ?? [event.target];
75
+ for (const node of composedPath) {
76
+ if ((0, import_dom_query.isHTMLElement)(node) && (0, import_tabbable.isFocusable)(node))
77
+ return true;
78
+ }
79
+ return false;
80
+ }
73
81
  function trackInteractOutside(node, options) {
74
82
  const { exclude, onFocusOutside, onPointerDownOutside, onInteractOutside } = options;
75
83
  if (!node)
@@ -102,7 +110,7 @@ function trackInteractOutside(node, options) {
102
110
  detail: {
103
111
  originalEvent: event,
104
112
  contextmenu: (0, import_dom_event.isContextMenuEvent)(event),
105
- focusable: (0, import_tabbable.isFocusable)((0, import_dom_query.getEventTarget)(event))
113
+ focusable: isComposedPathFocusable(event)
106
114
  }
107
115
  });
108
116
  }
package/dist/index.mjs CHANGED
@@ -9,6 +9,14 @@ import { isFocusable } from "@zag-js/tabbable";
9
9
  import { callAll } from "@zag-js/utils";
10
10
  var POINTER_OUTSIDE_EVENT = "pointerdown.outside";
11
11
  var FOCUS_OUTSIDE_EVENT = "focus.outside";
12
+ function isComposedPathFocusable(event) {
13
+ const composedPath = event.composedPath() ?? [event.target];
14
+ for (const node of composedPath) {
15
+ if (isHTMLElement(node) && isFocusable(node))
16
+ return true;
17
+ }
18
+ return false;
19
+ }
12
20
  function trackInteractOutside(node, options) {
13
21
  const { exclude, onFocusOutside, onPointerDownOutside, onInteractOutside } = options;
14
22
  if (!node)
@@ -41,7 +49,7 @@ function trackInteractOutside(node, options) {
41
49
  detail: {
42
50
  originalEvent: event,
43
51
  contextmenu: isContextMenuEvent(event),
44
- focusable: isFocusable(getEventTarget(event))
52
+ focusable: isComposedPathFocusable(event)
45
53
  }
46
54
  });
47
55
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/interact-outside",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "description": "Track interations or focus outside an element",
5
5
  "keywords": [
6
6
  "js",
@@ -18,8 +18,8 @@
18
18
  "dependencies": {
19
19
  "@zag-js/dom-query": "0.1.4",
20
20
  "@zag-js/dom-event": "0.0.1",
21
- "@zag-js/tabbable": "0.0.1",
22
- "@zag-js/utils": "0.3.3"
21
+ "@zag-js/tabbable": "0.1.1",
22
+ "@zag-js/utils": "0.3.4"
23
23
  },
24
24
  "devDependencies": {
25
25
  "clean-package": "2.2.0"