UNPKG

1.64 kBTypeScriptView Raw
1import * as React from 'react';
2
3export interface TrapFocusProps {
4 /**
5 * If `true`, focus will be locked.
6 */
7 open: boolean;
8 /**
9 * Return the document to consider.
10 * We use it to implement the restore focus between different browser documents.
11 */
12 getDoc: () => Document;
13 /**
14 * Do we still want to enforce the focus?
15 * This prop helps nesting TrapFocus elements.
16 */
17 isEnabled: () => boolean;
18 /**
19 * A single child content element.
20 */
21 children: React.ReactNode;
22 /**
23 * If `true`, the trap focus will not automatically shift focus to itself when it opens, and
24 * replace it to the last focused element when it closes.
25 * This also works correctly with any trap focus children that have the `disableAutoFocus` prop.
26 *
27 * Generally this should never be set to `true` as it makes the trap focus less
28 * accessible to assistive technologies, like screen readers.
29 */
30 disableAutoFocus?: boolean;
31 /**
32 * If `true`, the trap focus will not prevent focus from leaving the trap focus while open.
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 */
37 disableEnforceFocus?: boolean;
38 /**
39 * If `true`, the trap focus will not restore focus to previously focused element once
40 * trap focus is hidden.
41 */
42 disableRestoreFocus?: boolean;
43}
44
45/**
46 * Utility component that locks focus inside the component.
47 * API:
48 *
49 * - [Unstable_TrapFocus API](https://mui.com/api/unstable-trap-focus/)
50 */
51export default function Unstable_TrapFocus(props: TrapFocusProps): JSX.Element;