carbon-react
Version:
A library of reusable React components for easily building user interfaces.
21 lines (20 loc) • 1.19 kB
TypeScript
import React, { RefObject } from "react";
export declare const TAB_GUARD_TOP = "tab-guard-top";
export declare const TAB_GUARD_BOTTOM = "tab-guard-bottom";
export interface FocusTrapProps {
children: React.ReactNode;
autoFocus?: boolean;
/** provide a custom first element to focus */
focusFirstElement?: RefObject<HTMLElement> | HTMLElement | null;
/** a custom callback that will override the default focus trap behaviour */
bespokeTrap?: (ev: KeyboardEvent, firstElement?: HTMLElement, lastElement?: HTMLElement) => void;
/** optional selector to identify the focusable elements, if not provided a default selector is used */
focusableSelectors?: string;
/** a ref to the container wrapping the focusable elements */
wrapperRef: RefObject<HTMLElement>;
isOpen?: boolean;
/** an optional array of refs to containers whose content should also be reachable from the FocusTrap */
additionalWrapperRefs?: RefObject<HTMLElement>[];
}
declare const FocusTrap: ({ children, autoFocus, focusableSelectors, focusFirstElement, bespokeTrap, wrapperRef, isOpen, additionalWrapperRefs, }: FocusTrapProps) => React.JSX.Element;
export default FocusTrap;