reablocks
Version:
Component library for React
20 lines (19 loc) • 743 B
TypeScript
import { ReactNode, RefObject } from 'react';
export declare const DATA_ATTRIBUTE_INDEX = "keyboard_index";
export interface FocusableElement {
/** Ref pointing to the focusable DOM element. */
ref: RefObject<HTMLElement>;
/** Handler invoked when the element is clicked. */
onClick: (() => void) | undefined;
}
export interface HotkeyIem {
/** Keyboard shortcut associated with the item. */
hotkey: string;
/** Index of the item in the flattened tree. */
index: number;
}
export declare const useFlattenedTree: (children: ReactNode, selectedIndex: number, onSelectedIndexChange: (index: number) => void) => {
flattenedTree: ReactNode[];
hotkeys: HotkeyIem[];
itemsRef: RefObject<HTMLElement[]>;
};