Interface Typeahead<M extends MenuToggleMenu<M>>

All Known Implementing Classes:
MultiTypeahead, SingleTypeahead

public interface Typeahead<M extends MenuToggleMenu<M>>
  • Method Details

    • allowNewItems

      default M allowNewItems(Function<String, Promise<MenuItem>> createItem)
      Allows the creation of new menu items based on user input. This method enables the typeahead component to dynamically add custom items when the provided input does not match any existing items. A default prompt is used to guide the user with a message like "Create new item ''".
      Parameters:
      createItem - a Function that takes a String input representing the user's data and returns a Promise of a MenuItem, which corresponds to the newly created item.
      Returns:
      an instance of the enclosing type, enabling method chaining for further configuration.
    • allowNewItems

      M allowNewItems(Function<String,String> prompt, Function<String, Promise<MenuItem>> createItem)
      Allows the creation of new menu items based on user input. This method enables a typeahead component to provide functionality for dynamically adding custom items when the user-provided input does not match any existing items.
      Parameters:
      prompt - a Function that takes a String input representing the user's data and returns a String response, typically used to prompt the user or display a message.
      createItem - a Function that takes a String input representing the user's data and returns a Promise of a MenuItem, representing the newly created item.
      Returns:
      an instance of the enclosing type, enabling method chaining for further configuration.
    • onSearch

      M onSearch(SearchFilter searchFilter)
      Configures the search behavior for this typeahead.
      Parameters:
      searchFilter - a SearchFilter that defines the search logic. The first parameter is a MenuItem representing a menu item, and the second parameter is a String representing the search query. The predicate should return true for items matching the search.
      Returns:
      the SingleTypeahead instance for method chaining.
    • onNoResults

      M onNoResults(NoResults noResults)
      Configures the behavior for generating a "no results" menu item when no matching items are found in the menu list for the given input text.
      Parameters:
      noResults - a NoResults implementation responsible for defining how the "no results" menu item is created and displayed when no matches are found.
      Returns:
      the instance of the current type enabling method chaining.