Options
All
  • Public
  • Public/Protected
  • All
Menu

UI-Widget that can be attached to an input element. Fetches and displays autocomplete suggestions.

If you want to render your own HTML and just fetch the autocomplete suggestions, use SmartSearch.fetchAutocompleteList instead.

Hierarchy

  • AutocompleteWidget

Index

Constructors

constructor

Methods

getAutocompleteList

  • A function meant to be called at every keystroke that returns a list of suggestions for autocompletion.

    Parameters

    • prefix: string

      All characters typed so far, all strings returned by this function will start with this prefix.

    • Optional options: AutocompleteOptions

    Returns Promise<string[]>

    The highlighted or default autocomplete list for the given prefix, contains at most 5 elements.

highlightPrefix

  • highlightPrefix(item: string, prefix: string): string
  • Highlights the prefix (typed by the user in the input field) using the html strong tag.

    Parameters

    • item: string

      An item from the list of autocomplete suggestions.

    • prefix: string

      The prefix to highlight.

    Returns string

initializeAndAttach

  • initializeAndAttach(inputElement: HTMLInputElement, renderTarget?: HTMLDivElement): void
  • Creates the widget and attaches it to the given HTMLInputElement.

    Parameters

    • inputElement: HTMLInputElement

      The HTML input element to attach the widget to.

    • Optional renderTarget: HTMLDivElement

      The HTML div element to render the widget into

    Returns void

markActiveItem

  • markActiveItem(autocompleteList: HTMLDivElement, cursorIndex: number): HTMLElement
  • Marks the active item with the 'smart-search-autocomplete-active' css class.

    Parameters

    • autocompleteList: HTMLDivElement

      The html element containing all the autocomplete suggestions

    • cursorIndex: number

    Returns HTMLElement

removeHighlights

  • removeHighlights(item: string): string
  • Removes highlights from a highlighted item.

    Parameters

    • item: string

      A string containing a <strong>-tag.

    Returns string

Generated using TypeDoc