@zag-js/focus-visible 0.0.0-dev-20230623144255 → 0.0.0-dev-20230623145152

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
@@ -2,6 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
+ const domQuery = require('@zag-js/dom-query');
6
+
5
7
  let hasSetup = false;
6
8
  let modality = null;
7
9
  let hasEventBeforeFocus = false;
@@ -66,7 +68,7 @@ function isFocusVisible() {
66
68
  return modality !== "pointer";
67
69
  }
68
70
  function setupGlobalFocusEvents() {
69
- if (typeof window === "undefined" || hasSetup) {
71
+ if (!domQuery.isDom() || hasSetup) {
70
72
  return;
71
73
  }
72
74
  const { focus } = HTMLElement.prototype;
package/dist/index.mjs CHANGED
@@ -1,3 +1,5 @@
1
+ import { isDom } from '@zag-js/dom-query';
2
+
1
3
  let hasSetup = false;
2
4
  let modality = null;
3
5
  let hasEventBeforeFocus = false;
@@ -62,7 +64,7 @@ function isFocusVisible() {
62
64
  return modality !== "pointer";
63
65
  }
64
66
  function setupGlobalFocusEvents() {
65
- if (typeof window === "undefined" || hasSetup) {
67
+ if (!isDom() || hasSetup) {
66
68
  return;
67
69
  }
68
70
  const { focus } = HTMLElement.prototype;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/focus-visible",
3
- "version": "0.0.0-dev-20230623144255",
3
+ "version": "0.0.0-dev-20230623145152",
4
4
  "description": "Focus visible polyfill utility based on WICG",
5
5
  "keywords": [
6
6
  "js",
@@ -25,6 +25,9 @@
25
25
  },
26
26
  "clean-package": "../../../clean-package.config.json",
27
27
  "main": "dist/index.js",
28
+ "dependencies": {
29
+ "@zag-js/dom-query": "0.0.0-dev-20230623145152"
30
+ },
28
31
  "devDependencies": {
29
32
  "clean-package": "2.2.0"
30
33
  },
package/src/index.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { isDom } from "@zag-js/dom-query"
2
+
1
3
  type Modality = "keyboard" | "pointer" | "virtual"
2
4
  type HandlerEvent = PointerEvent | MouseEvent | KeyboardEvent | FocusEvent
3
5
  type Handler = (modality: Modality, e: HandlerEvent | null) => void
@@ -96,7 +98,7 @@ function isFocusVisible() {
96
98
  }
97
99
 
98
100
  function setupGlobalFocusEvents() {
99
- if (typeof window === "undefined" || hasSetup) {
101
+ if (!isDom() || hasSetup) {
100
102
  return
101
103
  }
102
104