@primer/react
Version:
An implementation of GitHub's Primer Design System using React
31 lines (30 loc) • 1.3 kB
TypeScript
import React from "react";
import { FocusKeys, FocusZoneSettings } from "@primer/behaviors";
//#region src/hooks/useFocusZone.d.ts
interface FocusZoneHookSettings extends Omit<FocusZoneSettings, 'activeDescendantControl'> {
/**
* Optional ref for the container that holds all elements participating in arrow key focus.
* If one is not passed, we will create one for you and return it from the hook.
*/
containerRef?: React.RefObject<HTMLElement | null>;
/**
* If using the "active descendant" focus pattern, pass `true` or a ref to the controlling
* element. If a ref object is not passed, we will create one for you.
*/
activeDescendantFocus?: boolean | React.RefObject<HTMLElement | null>;
/**
* Set to true to disable the focus zone and clean up listeners. Can be re-enabled at
* any time.
*/
disabled?: boolean;
/**
* Set to true to allow focus to move to elements that are dynamically prepended to the container.
*/
focusPrependedElements?: boolean;
}
declare function useFocusZone(settings?: FocusZoneHookSettings, dependencies?: React.DependencyList): {
containerRef: React.RefObject<HTMLElement | null>;
activeDescendantControlRef: React.RefObject<HTMLElement | null>;
};
//#endregion
export { FocusKeys, FocusZoneHookSettings, useFocusZone };