@destyler/focus-visible 0.2.10 → 0.2.12
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.mts +12 -12
- package/dist/index.mjs +2 -4
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
//#region src/focus-visible.d.ts
|
|
2
|
-
type Modality = 'keyboard' | 'pointer' | 'virtual';
|
|
2
|
+
export type Modality = 'keyboard' | 'pointer' | 'virtual';
|
|
3
3
|
type RootNode = Document | ShadowRoot | Node;
|
|
4
4
|
interface GlobalListenerData {
|
|
5
5
|
focus: VoidFunction;
|
|
6
6
|
}
|
|
7
|
-
declare const listenerMap: Map<Window, GlobalListenerData>;
|
|
8
|
-
declare function getInteractionModality(): Modality | null;
|
|
9
|
-
declare function setInteractionModality(modality: Modality): void;
|
|
10
|
-
interface InteractionModalityChangeDetails {
|
|
7
|
+
export declare const listenerMap: Map<Window, GlobalListenerData>;
|
|
8
|
+
export declare function getInteractionModality(): Modality | null;
|
|
9
|
+
export declare function setInteractionModality(modality: Modality): void;
|
|
10
|
+
export interface InteractionModalityChangeDetails {
|
|
11
11
|
/** The modality of the interaction that caused the focus to be visible. */
|
|
12
12
|
modality: Modality | null;
|
|
13
13
|
}
|
|
14
|
-
interface InteractionModalityProps {
|
|
14
|
+
export interface InteractionModalityProps {
|
|
15
15
|
/** The root element to track focus visibility for. */
|
|
16
16
|
root?: RootNode | undefined;
|
|
17
17
|
/** Callback to be called when the interaction modality changes. */
|
|
18
18
|
onChange: (details: InteractionModalityChangeDetails) => void;
|
|
19
19
|
}
|
|
20
|
-
declare function trackInteractionModality(props: InteractionModalityProps): VoidFunction;
|
|
21
|
-
declare function isFocusVisible(): boolean;
|
|
22
|
-
interface FocusVisibleChangeDetails {
|
|
20
|
+
export declare function trackInteractionModality(props: InteractionModalityProps): VoidFunction;
|
|
21
|
+
export declare function isFocusVisible(): boolean;
|
|
22
|
+
export interface FocusVisibleChangeDetails {
|
|
23
23
|
/** Whether keyboard focus is visible globally. */
|
|
24
24
|
isFocusVisible: boolean;
|
|
25
25
|
/** The modality of the interaction that caused the focus to be visible. */
|
|
26
26
|
modality: Modality | null;
|
|
27
27
|
}
|
|
28
|
-
interface FocusVisibleProps {
|
|
28
|
+
export interface FocusVisibleProps {
|
|
29
29
|
/** The root element to track focus visibility for. */
|
|
30
30
|
root?: RootNode | undefined;
|
|
31
31
|
/** Whether the element is a text input. */
|
|
@@ -35,6 +35,6 @@ interface FocusVisibleProps {
|
|
|
35
35
|
/** Callback to be called when the focus visibility changes. */
|
|
36
36
|
onChange?: ((details: FocusVisibleChangeDetails) => void) | undefined;
|
|
37
37
|
}
|
|
38
|
-
declare function trackFocusVisible(props?: FocusVisibleProps): VoidFunction;
|
|
38
|
+
export declare function trackFocusVisible(props?: FocusVisibleProps): VoidFunction;
|
|
39
39
|
//#endregion
|
|
40
|
-
export {
|
|
40
|
+
export {};
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { getDocument, getEventTarget, getWindow, isMac } from "@destyler/dom";
|
|
2
|
-
|
|
3
2
|
//#region src/focus-visible.ts
|
|
4
3
|
/**
|
|
5
4
|
* Credit: Huge props to the team at Adobe for inspiring this implementation.
|
|
@@ -16,7 +15,7 @@ function isVirtualClick(event) {
|
|
|
16
15
|
function isValidKey(e) {
|
|
17
16
|
return !(e.metaKey || !isMac() && e.altKey || e.ctrlKey || e.key === "Control" || e.key === "Shift" || e.key === "Meta");
|
|
18
17
|
}
|
|
19
|
-
const nonTextInputTypes = new Set([
|
|
18
|
+
const nonTextInputTypes = /* @__PURE__ */ new Set([
|
|
20
19
|
"checkbox",
|
|
21
20
|
"radio",
|
|
22
21
|
"range",
|
|
@@ -169,6 +168,5 @@ function trackFocusVisible(props = {}) {
|
|
|
169
168
|
changeHandlers.delete(handler);
|
|
170
169
|
};
|
|
171
170
|
}
|
|
172
|
-
|
|
173
171
|
//#endregion
|
|
174
|
-
export { getInteractionModality, isFocusVisible, listenerMap, setInteractionModality, trackFocusVisible, trackInteractionModality };
|
|
172
|
+
export { getInteractionModality, isFocusVisible, listenerMap, setInteractionModality, trackFocusVisible, trackInteractionModality };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@destyler/focus-visible",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.12",
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "Elone Hoo <elonehoo@gmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"dist"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@destyler/dom": "0.2.
|
|
25
|
+
"@destyler/dom": "0.2.12"
|
|
26
26
|
},
|
|
27
27
|
"publishConfig": {
|
|
28
28
|
"access": "public"
|