UNPKG

2.14 kBTypeScriptView Raw
1import * as React from 'react';
2
3export interface ReactFocusLockProps {
4 disabled?: boolean;
5
6 /**
7 * will return focus to the previous position on trap disable.
8 */
9 returnFocus?: boolean;
10
11 /**
12 * @deprecated Use persistentFocus=false instead
13 * enables(or disables) text selection. This also allows not to have ANY focus.
14 */
15 allowTextSelection?: boolean;
16
17 /**
18 * enables of disables "sticky" behavior, when any focusable element shall be focused.
19 * This disallow any text selection on the page.
20 * @default false
21 */
22 persistentFocus?: boolean;
23
24 /**
25 * enables or disables autoFocusing feature.
26 * If enabled - will move focus inside Lock, selecting the first or autoFocusable element
27 * If disable - will blur any focus on Lock activation.
28 * @default true
29 */
30 autoFocus?: boolean;
31
32 /**
33 * disables hidden inputs before and after the lock.
34 */
35 noFocusGuards?: boolean | "tail";
36
37 /**
38 * named focus group for focus scattering aka combined lock targets
39 */
40 group?: string;
41
42 className?: string;
43
44 /**
45 * life-cycle hook, called on lock activation
46 * @param node the observed node
47 */
48 onActivation?(node: HTMLElement): void;
49
50 /**
51 * life-cycle hook, called on deactivation
52 * @param node the observed node
53 */
54 onDeactivation?(node: HTMLElement): void;
55
56 /**
57 * Component to use, defaults to 'div'
58 */
59 as?: React.ReactType,
60 lockProps?: { [key: string]: any },
61
62 /**
63 * Controls focus lock working areas. Lock will silently ignore all the events from `not allowed` areas
64 * @param activeElement
65 * @returns {Boolean} true if focus lock should handle activeElement, false if not
66 */
67 whiteList?: (activeElement: HTMLElement) => boolean;
68
69 /**
70 * Shards forms a scattered lock, same as `group` does, but in more "low" and controlled way
71 */
72 shards?: Array<React.RefObject<any> | HTMLElement>;
73
74 children: React.ReactNode;
75}
76
77export interface AutoFocusProps {
78 children: React.ReactNode;
79 className?: string;
80}
81
82export interface FreeFocusProps {
83 className?: string;
84}
85
86export interface InFocusGuardProps {
87 children: React.ReactNode;
88}
\No newline at end of file