UNPKG

@loke/ui

Version:
52 lines (51 loc) • 2.13 kB
import { Primitive } from "@loke/ui/primitive"; import { type ComponentPropsWithoutRef, type ReactNode } from "react"; type PrimitiveDivProps = ComponentPropsWithoutRef<typeof Primitive.div>; interface FocusScopeProps extends PrimitiveDivProps { /** Nodes outside the DOM subtree that remain within a trapped scope. */ branches?: HTMLElement[]; /** * When `true`, tabbing from last item will focus first tabbable * and shift+tab from first item will focus last tababble. * @defaultValue false */ loop?: 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; /** * When `true`, focus cannot escape the focus scope via keyboard, * pointer, or a programmatic focus. * @defaultValue false */ trapped?: boolean; } declare const FocusScope: import("react").ForwardRefExoticComponent<FocusScopeProps & import("react").RefAttributes<HTMLDivElement>> & { displayName: string; }; interface FocusScopeBranchRegistry { add: (node: HTMLElement) => void; remove: (node: HTMLElement) => void; } interface FocusScopeBranchProviderProps { children?: ReactNode; registry: FocusScopeBranchRegistry | null | undefined; } declare const FocusScopeBranchProvider: ({ registry, children, }: FocusScopeBranchProviderProps) => import("react").JSX.Element; declare const useFocusScopeBranchRegistry: () => { readonly nodes: HTMLElement[]; readonly registry: FocusScopeBranchRegistry; }; declare const useFocusScopeBranch: (node: HTMLElement | null) => void; declare const Root: import("react").ForwardRefExoticComponent<FocusScopeProps & import("react").RefAttributes<HTMLDivElement>> & { displayName: string; }; export type { FocusScopeBranchProviderProps, FocusScopeBranchRegistry, FocusScopeProps, }; export { FocusScope, FocusScopeBranchProvider, Root, useFocusScopeBranch, useFocusScopeBranchRegistry, };