@zag-js/focus-visible 0.1.1 → 0.1.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 +3 -1
- package/dist/index.js +10 -1
- package/dist/index.mjs +10 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
declare type Modality = "keyboard" | "pointer" | "virtual";
|
|
2
2
|
declare type FocusVisibleCallback = (isFocusVisible: boolean) => void;
|
|
3
3
|
export declare function trackFocusVisible(fn: FocusVisibleCallback): () => void;
|
|
4
|
-
export declare function trackInteractionModality(fn: (
|
|
4
|
+
export declare function trackInteractionModality(fn: (value: Modality | null) => void): () => void;
|
|
5
|
+
export declare function setInteractionModality(value: Modality): void;
|
|
6
|
+
export declare function getInteractionModality(): Modality;
|
|
5
7
|
export {};
|
package/dist/index.js
CHANGED
|
@@ -20,6 +20,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var src_exports = {};
|
|
22
22
|
__export(src_exports, {
|
|
23
|
+
getInteractionModality: () => getInteractionModality,
|
|
24
|
+
setInteractionModality: () => setInteractionModality,
|
|
23
25
|
trackFocusVisible: () => trackFocusVisible,
|
|
24
26
|
trackInteractionModality: () => trackInteractionModality
|
|
25
27
|
});
|
|
@@ -80,7 +82,7 @@ function onWindowBlur() {
|
|
|
80
82
|
hasBlurredWindowRecently = true;
|
|
81
83
|
}
|
|
82
84
|
function isFocusVisible() {
|
|
83
|
-
return modality
|
|
85
|
+
return modality !== "pointer";
|
|
84
86
|
}
|
|
85
87
|
function setupGlobalFocusEvents() {
|
|
86
88
|
if (typeof window === "undefined" || hasSetup) {
|
|
@@ -125,3 +127,10 @@ function trackInteractionModality(fn) {
|
|
|
125
127
|
handlers.delete(handler);
|
|
126
128
|
};
|
|
127
129
|
}
|
|
130
|
+
function setInteractionModality(value) {
|
|
131
|
+
modality = value;
|
|
132
|
+
trigger(value, null);
|
|
133
|
+
}
|
|
134
|
+
function getInteractionModality() {
|
|
135
|
+
return modality;
|
|
136
|
+
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
1
|
// src/index.ts
|
|
4
2
|
var hasSetup = false;
|
|
5
3
|
var modality = null;
|
|
@@ -57,7 +55,7 @@ function onWindowBlur() {
|
|
|
57
55
|
hasBlurredWindowRecently = true;
|
|
58
56
|
}
|
|
59
57
|
function isFocusVisible() {
|
|
60
|
-
return modality
|
|
58
|
+
return modality !== "pointer";
|
|
61
59
|
}
|
|
62
60
|
function setupGlobalFocusEvents() {
|
|
63
61
|
if (typeof window === "undefined" || hasSetup) {
|
|
@@ -102,7 +100,16 @@ function trackInteractionModality(fn) {
|
|
|
102
100
|
handlers.delete(handler);
|
|
103
101
|
};
|
|
104
102
|
}
|
|
103
|
+
function setInteractionModality(value) {
|
|
104
|
+
modality = value;
|
|
105
|
+
trigger(value, null);
|
|
106
|
+
}
|
|
107
|
+
function getInteractionModality() {
|
|
108
|
+
return modality;
|
|
109
|
+
}
|
|
105
110
|
export {
|
|
111
|
+
getInteractionModality,
|
|
112
|
+
setInteractionModality,
|
|
106
113
|
trackFocusVisible,
|
|
107
114
|
trackInteractionModality
|
|
108
115
|
};
|