UNPKG

2.16 kBTypeScriptView Raw
1/* eslint-disable @typescript-eslint/naming-convention */
2import * as React from 'react';
3
4export interface TrapFocusProps {
5 /**
6 * If `true`, focus is locked.
7 */
8 open: boolean;
9 /**
10 * Returns an array of ordered tabbable nodes (i.e. in tab order) within the root.
11 * For instance, you can provide the "tabbable" npm dependency.
12 * @param {HTMLElement} root
13 */
14 getTabbable?: (root: HTMLElement) => string[];
15 /**
16 * This prop extends the `open` prop.
17 * It allows to toggle the open state without having to wait for a rerender when changing the `open` prop.
18 * This prop should be memoized.
19 * It can be used to support multiple trap focus mounted at the same time.
20 * @default function defaultIsEnabled() {
21 * return true;
22 * }
23 */
24 isEnabled?: () => boolean;
25 /**
26 * A single child content element.
27 */
28 children: React.ReactElement<any, any>;
29 /**
30 * If `true`, the trap focus will not automatically shift focus to itself when it opens, and
31 * replace it to the last focused element when it closes.
32 * This also works correctly with any trap focus children that have the `disableAutoFocus` prop.
33 *
34 * Generally this should never be set to `true` as it makes the trap focus less
35 * accessible to assistive technologies, like screen readers.
36 * @default false
37 */
38 disableAutoFocus?: boolean;
39 /**
40 * If `true`, the trap focus will not prevent focus from leaving the trap focus while open.
41 *
42 * Generally this should never be set to `true` as it makes the trap focus less
43 * accessible to assistive technologies, like screen readers.
44 * @default false
45 */
46 disableEnforceFocus?: boolean;
47 /**
48 * If `true`, the trap focus will not restore focus to previously focused element once
49 * trap focus is hidden.
50 * @default false
51 */
52 disableRestoreFocus?: boolean;
53}
54
55/**
56 * Utility component that locks focus inside the component.
57 *
58 * Demos:
59 *
60 * - [Trap Focus](https://mui.com/components/trap-focus/)
61 *
62 * API:
63 *
64 * - [Unstable_TrapFocus API](https://mui.com/api/unstable-trap-focus/)
65 */
66export default function Unstable_TrapFocus(props: TrapFocusProps): JSX.Element;