///
import { WithEventHandlers, WithKeyboardFocusCallback } from "../types.d";
import defaultFindMatchIndex from "../utils/findMatchIndex";
export interface SearchEffectOptions extends WithEventHandlers, Required {
/**
* An optional function to get the string values for all the focusable elements
* in the keydown container element. If this is omitted, it will just return the
* `element.textContent` for each item while removing any font icons from the element
* since the font icons interfere with the search.
*/
getValues?: (focusableElements: HTMLElement[]) => string[];
/**
* An optional reset time in milliseconds to apply for the search. When this is
* omitted, it will default to 500ms.
*/
searchResetTime?: number;
/**
* An optional function that is used to find the next match index. By default, this
* will do a case-insensitive starts-with search.
*/
findMatchIndex?: typeof defaultFindMatchIndex;
/**
* Boolean if the current item can be a valid search result. This is helpful if you'd
* like to show that the same item keeps gaining foucs during a search. This is enabled
* by default if omitted.
*/
isSelfMatchable?: boolean;
}
/**
* A hook used to create a `onKeyDown` event handler that will allow text matching/searching
* within. This can be used with any of the other hooks/effects/event listeners provided from
* this package or your own functionality to make extremely complex widgets.
*
* That said, this is normally used for the "menu" or "tree" roles.
*
* @param options All the options to create the search event handler.
* @return a keydown event handler that should be provided to a React element
*/
export default function useSearchEventHandler({ handlers, onKeyboardFocus, searchResetTime, getValues, findMatchIndex, isSelfMatchable, }: SearchEffectOptions): {
handlers: H & {
onKeyDown: (event: import("react").KeyboardEvent) => void;
onClick?: ((event: import("react").MouseEvent) => void) | undefined;
};
};