@navikt/ds-react
Version:
React components from the Norwegian Labour and Welfare Administration.
45 lines (44 loc) • 1.7 kB
TypeScript
import React from "react";
/**
* TODO:
* - owner(container) for corrent document
*/
interface FocusBoundaryProps extends React.HTMLAttributes<HTMLDivElement> {
/**
* FocusBoundary expects a single child element since its a slotted component.
*/
children: React.ReactElement;
/**
* When `true`, tabbing from last item will focus first tabbable
* and shift+tab from first item will focus last tabbable element.
* This does not "trap" focus inside the boundary, it only loops it when
* tabbing. If focus is moved outside the boundary programmatically or by
* pointer, it will not be moved back.
*
* - Links (`<a>` elements), are not considered tabbable for the purpose of looping.
* - Hidden inputs (i.e. `<input type="hidden">`) are not considered tabbable.
* - Elements that are `display: none` or `visibility: hidden` are not considered tabbable.
* - Elements with `tabIndex < 0` are not considered tabbable.
* @defaultValue false
*/
loop?: boolean;
/**
* When `true`, focus cannot escape the focus boundary via keyboard,
* pointer, or a programmatic focus.
* @defaultValue false
*/
trapped?: boolean;
/**
* Event handler called when auto-focusing on mount.
* Can be prevented.
*/
onMountAutoFocus?: (event: Event) => void;
/**
* Event handler called when auto-focusing on unmount.
* Can be prevented.
*/
onUnmountAutoFocus?: (event: Event) => void;
}
declare const FocusBoundary: React.ForwardRefExoticComponent<FocusBoundaryProps & React.RefAttributes<HTMLDivElement>>;
export { FocusBoundary };
export type { FocusBoundaryProps };