UNPKG

@leonchabbey/norigin-spatial-navigation

Version:
68 lines (67 loc) 2.31 kB
export declare const ROOT_FOCUS_KEY = "SN:ROOT"; interface FocusableComponentLayout { left: number; top: number; width: number; height: number; x: number; y: number; } export interface FocusableEventLayout extends FocusableComponentLayout, Pick<FocusableComponent, 'node'> { } interface FocusableComponent { focusKey: string; node: HTMLElement | null; parentFocusKey: string; onEnterPress: (details: KeyPressDetails) => void; onEnterRelease: () => void; onArrowPress: (direction: string, details: KeyPressDetails) => boolean; onFocus: (layout: FocusableEventLayout, details: FocusDetails) => void; onBlur: (layout: FocusableEventLayout, details: FocusDetails) => void; onUpdateFocus: (focused: boolean) => void; onUpdateHasFocusedChild: (hasFocusedChild: boolean) => void; saveLastFocusedChild: boolean; trackChildren: boolean; preferredChildFocusKey?: string; focusable: boolean; isFocusBoundary: boolean; autoRestoreFocus: boolean; lastFocusedChildKey?: string; layout: FocusableComponentLayout; layoutUpdated?: boolean; } export declare type PressedKeys = { [index: string]: number; }; /** * Extra details about pressed keys passed on the key events */ export interface KeyPressDetails { pressedKeys: PressedKeys; } /** * Extra details passed from outside to be bounced back on other callbacks */ export interface FocusDetails { event?: Event; nativeEvent?: Event; [key: string]: any; } export declare type BackwardsCompatibleKeyMap = { [index: string]: number | number[]; }; export declare type KeyMap = { [index: string]: number[]; }; export declare const init: ({ debug, visualDebug, nativeMode, throttle: throttleParam, throttleKeypresses, useGetBoundingClientRect }?: { debug?: boolean | undefined; visualDebug?: boolean | undefined; nativeMode?: boolean | undefined; throttle?: number | undefined; throttleKeypresses?: boolean | undefined; useGetBoundingClientRect?: boolean | undefined; }) => void, setThrottle: ({ throttle: throttleParam, throttleKeypresses }?: { throttle?: number | undefined; throttleKeypresses?: boolean | undefined; }) => void, destroy: () => void, setKeyMap: (keyMap: BackwardsCompatibleKeyMap) => void; export {};