@zag-js/focus-visible 0.71.0 → 0.73.0

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
@@ -12,12 +12,10 @@ function isValidKey(e) {
12
12
  }
13
13
  var nonTextInputTypes = /* @__PURE__ */ new Set(["checkbox", "radio", "range", "color", "file", "image", "button", "submit", "reset"]);
14
14
  function isKeyboardFocusEvent(isTextInput, modality, e) {
15
- const IHTMLInputElement = typeof window !== "undefined" ? domQuery.getWindow(e?.target).HTMLInputElement : HTMLInputElement;
16
- const IHTMLTextAreaElement = typeof window !== "undefined" ? domQuery.getWindow(e?.target).HTMLTextAreaElement : HTMLTextAreaElement;
17
- const IHTMLElement = typeof window !== "undefined" ? domQuery.getWindow(e?.target).HTMLElement : HTMLElement;
18
- const IKeyboardEvent = typeof window !== "undefined" ? domQuery.getWindow(e?.target).KeyboardEvent : KeyboardEvent;
19
- isTextInput = isTextInput || e?.target instanceof IHTMLInputElement && !nonTextInputTypes.has(e?.target?.type) || e?.target instanceof IHTMLTextAreaElement || e?.target instanceof IHTMLElement && e?.target.isContentEditable;
20
- return !(isTextInput && modality === "keyboard" && e instanceof IKeyboardEvent && !Reflect.has(FOCUS_VISIBLE_INPUT_KEYS, e.key));
15
+ const target = e ? domQuery.getEventTarget(e) : null;
16
+ const win = domQuery.getWindow(target);
17
+ isTextInput = isTextInput || target instanceof win.HTMLInputElement && !nonTextInputTypes.has(target?.type) || target instanceof win.HTMLTextAreaElement || target instanceof win.HTMLElement && target.isContentEditable;
18
+ return !(isTextInput && modality === "keyboard" && e instanceof win.KeyboardEvent && !Reflect.has(FOCUS_VISIBLE_INPUT_KEYS, e.key));
21
19
  }
22
20
  var currentModality = null;
23
21
  var changeHandlers = /* @__PURE__ */ new Set();
@@ -54,7 +52,8 @@ function handleClickEvent(e) {
54
52
  }
55
53
  }
56
54
  function handleFocusEvent(e) {
57
- if (e.target === domQuery.getWindow(e.target) || e.target === domQuery.getDocument(e.target)) {
55
+ const target = domQuery.getEventTarget(e);
56
+ if (target === domQuery.getWindow(target) || target === domQuery.getDocument(target)) {
58
57
  return;
59
58
  }
60
59
  if (!hasEventBeforeFocus && !hasBlurredWindowRecently) {
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { getWindow, getDocument, isMac } from '@zag-js/dom-query';
1
+ import { getWindow, getDocument, getEventTarget, isMac } from '@zag-js/dom-query';
2
2
 
3
3
  // src/index.ts
4
4
  function isVirtualClick(event) {
@@ -10,12 +10,10 @@ function isValidKey(e) {
10
10
  }
11
11
  var nonTextInputTypes = /* @__PURE__ */ new Set(["checkbox", "radio", "range", "color", "file", "image", "button", "submit", "reset"]);
12
12
  function isKeyboardFocusEvent(isTextInput, modality, e) {
13
- const IHTMLInputElement = typeof window !== "undefined" ? getWindow(e?.target).HTMLInputElement : HTMLInputElement;
14
- const IHTMLTextAreaElement = typeof window !== "undefined" ? getWindow(e?.target).HTMLTextAreaElement : HTMLTextAreaElement;
15
- const IHTMLElement = typeof window !== "undefined" ? getWindow(e?.target).HTMLElement : HTMLElement;
16
- const IKeyboardEvent = typeof window !== "undefined" ? getWindow(e?.target).KeyboardEvent : KeyboardEvent;
17
- isTextInput = isTextInput || e?.target instanceof IHTMLInputElement && !nonTextInputTypes.has(e?.target?.type) || e?.target instanceof IHTMLTextAreaElement || e?.target instanceof IHTMLElement && e?.target.isContentEditable;
18
- return !(isTextInput && modality === "keyboard" && e instanceof IKeyboardEvent && !Reflect.has(FOCUS_VISIBLE_INPUT_KEYS, e.key));
13
+ const target = e ? getEventTarget(e) : null;
14
+ const win = getWindow(target);
15
+ isTextInput = isTextInput || target instanceof win.HTMLInputElement && !nonTextInputTypes.has(target?.type) || target instanceof win.HTMLTextAreaElement || target instanceof win.HTMLElement && target.isContentEditable;
16
+ return !(isTextInput && modality === "keyboard" && e instanceof win.KeyboardEvent && !Reflect.has(FOCUS_VISIBLE_INPUT_KEYS, e.key));
19
17
  }
20
18
  var currentModality = null;
21
19
  var changeHandlers = /* @__PURE__ */ new Set();
@@ -52,7 +50,8 @@ function handleClickEvent(e) {
52
50
  }
53
51
  }
54
52
  function handleFocusEvent(e) {
55
- if (e.target === getWindow(e.target) || e.target === getDocument(e.target)) {
53
+ const target = getEventTarget(e);
54
+ if (target === getWindow(target) || target === getDocument(target)) {
56
55
  return;
57
56
  }
58
57
  if (!hasEventBeforeFocus && !hasBlurredWindowRecently) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/focus-visible",
3
- "version": "0.71.0",
3
+ "version": "0.73.0",
4
4
  "description": "Focus visible polyfill utility based on WICG",
5
5
  "keywords": [
6
6
  "js",
@@ -25,7 +25,7 @@
25
25
  "clean-package": "../../../clean-package.config.json",
26
26
  "main": "dist/index.js",
27
27
  "dependencies": {
28
- "@zag-js/dom-query": "0.71.0"
28
+ "@zag-js/dom-query": "0.73.0"
29
29
  },
30
30
  "devDependencies": {
31
31
  "clean-package": "2.2.0"