@oslokommune/punkt-react
Version:
React komponentbibliotek til Punkt, et designsystem laget av Oslo Origo
23 lines (22 loc) • 1.23 kB
TypeScript
/**
* Build a list of focusable elements inside a container (same selector used by
* the fileupload preview modals and the global header mega menu). Hidden
* elements are filtered out.
*/
export declare function getFocusableElements(container: HTMLElement | null | undefined): HTMLElement[];
/**
* Like {@link getFocusableElements}, but descends open shadow roots, treats a
* native `<summary>` as focusable, and skips content hidden inside a collapsed
* `<details>`. Returned in flattened tree order. Use this when the container may
* hold web components or `<details>` accordions (e.g. the header mega menu).
*/
export declare function getFocusableElementsDeep(container: HTMLElement | null | undefined): HTMLElement[];
/** Resolve the genuinely focused element, piercing nested open shadow roots. */
export declare function getDeepActiveElement(doc?: Document): HTMLElement | null;
/**
* Keyboard handler that wraps Tab / Shift-Tab focus around the first and last
* focusable elements inside a container. Returns `true` if the event was handled.
*
* Call from a `keydown` listener on the modal root.
*/
export declare function trapTabInside(event: KeyboardEvent, container: HTMLElement | null | undefined): boolean;