UNPKG

893 BTypeScriptView Raw
1declare type SetRef = () => Element | null;
2declare type Ref = null | (() => Element | null);
3declare type ElementLocation = {
4 current: SetRef;
5 parent: Ref;
6 left: Ref;
7 right: Ref;
8};
9declare type Location = {
10 stack: ReadonlyArray<ElementLocation>;
11 ownerDocument: Document;
12 element: SetRef;
13};
14export declare const recordElementLocation: (element: Element | null) => Location | null;
15/**
16 * Captures the current focused element to restore focus as close as possible in the future
17 * Handles situations where the focused element is removed from the DOM or no longer focusable
18 * moving focus to the closest focusable element
19 * @param targetElement - element where focus should be restored
20 * @returns a function returning a new element to focus
21 */
22export declare const captureFocusRestore: (targetElement: Element | null) => (() => Element | undefined);
23export {};