@nosto/autocomplete

    Interface AutocompleteConfig<State>

    interface AutocompleteConfig<State> {
        dropdownSelector: Selector | ((input: HTMLInputElement) => Selector);
        fetch: SearchQuery | ((input: string) => PromiseLike<State>);
        googleAnalytics?: boolean | GoogleAnalyticsConfig;
        historyEnabled?: boolean;
        historySize?: number;
        hitDecorators?: HitDecorator[];
        inputSelector: Selector;
        minQueryLength?: number;
        nostoAnalytics?: boolean;
        render: (container: HTMLElement, state: State) => void | PromiseLike<void>;
        submit?: (
            query: string,
            config: AutocompleteConfig<State>,
            options?: SearchAutocompleteOptions,
        ) => void;
    }

    Type Parameters

    • State
    Index

    Properties

    dropdownSelector: Selector | ((input: HTMLInputElement) => Selector)

    The dropdown element to attach the autocomplete to

    fetch: SearchQuery | ((input: string) => PromiseLike<State>)

    The function to use to fetch the search state

    googleAnalytics?: boolean | GoogleAnalyticsConfig

    Google Analytics configuration. Set to false to disable.

    historyEnabled?: boolean

    Enable history

    historySize?: number

    Max number of history items to show

    hitDecorators?: HitDecorator[]

    Decorate each search hit before rendering

    import { priceDecorator } from "@nosto/autocomplete"

    autocomplete({
    hitDecorators: [
    priceDecorator({ defaultCurrency: "USD" })
    ]
    })
    inputSelector: Selector

    The input element to attach the autocomplete to

    minQueryLength?: number

    Minimum length of the query before searching

    nostoAnalytics?: boolean

    Enable Nosto Analytics

    render: (container: HTMLElement, state: State) => void | PromiseLike<void>

    The function to use to render the dropdown

    submit?: (
        query: string,
        config: AutocompleteConfig<State>,
        options?: SearchAutocompleteOptions,
    ) => void

    The function to use to submit the search

    MMNEPVFCICPMFPCPTTAAATR