import type { Hit } from '@algolia/client-search'; import type { MaybePromise } from '../MaybePromise'; import type { FacetHit, SearchForFacetValuesResponse } from '../preset-algolia/algoliasearch'; import type { RequesterDescription } from '../preset-algolia/createRequester'; import type { SearchResponse } from '../SearchResponse'; import { AutocompleteScopeApi, BaseItem } from './AutocompleteApi'; import { GetSourcesParams } from './AutocompleteOptions'; import { AutocompleteState } from './AutocompleteState'; export interface OnSelectParams extends AutocompleteScopeApi { state: AutocompleteState; event: any; item: TItem; itemInputValue: ReturnType['getItemInputValue']>; itemUrl: ReturnType['getItemUrl']>; source: InternalAutocompleteSource; } export declare type OnActiveParams = OnSelectParams; export declare type OnResolveParams = { source: AutocompleteSource; results: SearchForFacetValuesResponse | SearchResponse | TItem[] | TItem[][]; items: FacetHit[][] | FacetHit[] | Array> | Array | TItem[] | TItem[][]>; state: AutocompleteState; }; declare type DefaultIndicator = { /** * Optional key on a function to indicate it's the default value of this function. */ __default?: boolean; }; export interface AutocompleteSource { /** * Unique identifier for the source. */ sourceId: string; /** * The function called to get the value of an item. * * The value is used to fill the search box. */ getItemInputValue?: DefaultIndicator & (({ item, state, }: { item: TItem; state: AutocompleteState; }) => string); /** * The function called to get the URL of the item. * * The value is used to add [keyboard accessibility](https://www.algolia.com/doc/ui-libraries/autocomplete/core-concepts/keyboard-navigation/) features to let users open items in the current tab, a new tab, or a new window. */ getItemUrl?: DefaultIndicator & (({ item, state, }: { item: TItem; state: AutocompleteState; }) => string | undefined); /** * The function called when the input changes. * * You can use this function to filter the items based on the query. */ getItems(params: GetSourcesParams): MaybePromise>; /** * The function called whenever an item is selected. */ onSelect?: DefaultIndicator & ((params: OnSelectParams) => void); /** * The function called whenever an item is active. * * You can trigger different behaviors if the item is active depending on the triggering event using the `event` parameter. */ onActive?: DefaultIndicator & ((params: OnActiveParams) => void); /** * The function called whenever a source resolves. */ onResolve?: DefaultIndicator & ((params: OnResolveParams) => void); } export declare type InternalAutocompleteSource = { [KParam in keyof AutocompleteSource]-?: AutocompleteSource[KParam]; }; export {};