@zag-js/focus-visible 0.2.0 → 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.d.ts +2 -2
- package/dist/index.js +6 -1
- package/dist/index.mjs +6 -1
- package/package.json +18 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
type Modality = "keyboard" | "pointer" | "virtual";
|
|
2
|
+
type FocusVisibleCallback = (isFocusVisible: boolean) => void;
|
|
3
3
|
declare function trackFocusVisible(fn: FocusVisibleCallback): () => void;
|
|
4
4
|
declare function trackInteractionModality(fn: (value: Modality | null) => void): () => void;
|
|
5
5
|
declare function setInteractionModality(value: Modality): void;
|
package/dist/index.js
CHANGED
|
@@ -50,7 +50,12 @@ function onPointerEvent(event) {
|
|
|
50
50
|
if (event.type === "mousedown" || event.type === "pointerdown") {
|
|
51
51
|
hasEventBeforeFocus = true;
|
|
52
52
|
const target = event.composedPath ? event.composedPath()[0] : event.target;
|
|
53
|
-
|
|
53
|
+
let matches = false;
|
|
54
|
+
try {
|
|
55
|
+
matches = target.matches(":focus-visible");
|
|
56
|
+
} catch {
|
|
57
|
+
}
|
|
58
|
+
if (matches)
|
|
54
59
|
return;
|
|
55
60
|
trigger("pointer", event);
|
|
56
61
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -23,7 +23,12 @@ function onPointerEvent(event) {
|
|
|
23
23
|
if (event.type === "mousedown" || event.type === "pointerdown") {
|
|
24
24
|
hasEventBeforeFocus = true;
|
|
25
25
|
const target = event.composedPath ? event.composedPath()[0] : event.target;
|
|
26
|
-
|
|
26
|
+
let matches = false;
|
|
27
|
+
try {
|
|
28
|
+
matches = target.matches(":focus-visible");
|
|
29
|
+
} catch {
|
|
30
|
+
}
|
|
31
|
+
if (matches)
|
|
27
32
|
return;
|
|
28
33
|
trigger("pointer", event);
|
|
29
34
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/focus-visible",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Focus visible polyfill utility based on WICG",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"module": "dist/index.mjs",
|
|
7
|
-
"types": "dist/index.d.ts",
|
|
8
5
|
"keywords": [
|
|
9
6
|
"js",
|
|
10
7
|
"utils",
|
|
@@ -25,10 +22,25 @@
|
|
|
25
22
|
"bugs": {
|
|
26
23
|
"url": "https://github.com/chakra-ui/zag/issues"
|
|
27
24
|
},
|
|
25
|
+
"clean-package": "../../../clean-package.config.json",
|
|
26
|
+
"main": "dist/index.js",
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"clean-package": "2.2.0"
|
|
29
|
+
},
|
|
30
|
+
"module": "dist/index.mjs",
|
|
31
|
+
"types": "dist/index.d.ts",
|
|
32
|
+
"exports": {
|
|
33
|
+
".": {
|
|
34
|
+
"types": "./dist/index.d.ts",
|
|
35
|
+
"import": "./dist/index.mjs",
|
|
36
|
+
"require": "./dist/index.js"
|
|
37
|
+
},
|
|
38
|
+
"./package.json": "./package.json"
|
|
39
|
+
},
|
|
28
40
|
"scripts": {
|
|
29
|
-
"build-fast": "tsup src
|
|
41
|
+
"build-fast": "tsup src",
|
|
30
42
|
"start": "pnpm build --watch",
|
|
31
|
-
"build": "tsup src
|
|
43
|
+
"build": "tsup src --dts",
|
|
32
44
|
"test": "jest --config ../../../jest.config.js --rootDir tests",
|
|
33
45
|
"lint": "eslint src --ext .ts,.tsx",
|
|
34
46
|
"test-ci": "pnpm test --ci --runInBand -u",
|