Class BaseSearchInput<T extends BaseSearchInput<T>>

All Implemented Interfaces:
Attachable, ElementAttributeMethods<HTMLElement, T>, ElementClassListMethods<HTMLElement, T>, ElementConsumerMethods<HTMLElement, T>, ElementContainerMethods<HTMLElement, T>, ElementEventMethods<HTMLElement, T>, ElementIdMethods<HTMLElement, T>, ElementQueryMethods<HTMLElement>, HTMLElementAttributeMethods<HTMLElement, T>, HTMLElementDataMethods<HTMLElement, T>, HTMLElementStyleMethods<HTMLElement, T>, HTMLElementVisibilityMethods<HTMLElement, T>, IsElement<HTMLElement>, TypedBuilder<HTMLElement, T>, Component, ComponentIcon<HTMLElement, T>, Expandable<HTMLElement, T>, HasValue<String>, Validatable<HTMLElement, T>, OuiaSupport<HTMLElement, T>, Modifiers.Disabled<HTMLElement, T>, Modifiers.Plain<HTMLElement, T>
Direct Known Subclasses:
BaseFilterInput, SearchInput

public abstract class BaseSearchInput<T extends BaseSearchInput<T>> extends BaseTextInputGroup<T> implements Attachable, Expandable<HTMLElement, T>
Base class for search input components within a TextInputGroup.

Provides core search input functionality including a clear button, customizable utility visibility, and optional typeahead support via an attached Menu. When a menu is added, the search input acts as an autocomplete: typing filters menu items, and selecting an item populates the input field.

  • Method Details

    • attach

      public void attach(MutationRecord mutationRecord)
      Specified by:
      attach in interface Attachable
    • detach

      public void detach(MutationRecord mutationRecord)
      Specified by:
      detach in interface Attachable
    • addMenu

      public T addMenu(Menu menu)
      Adds a menu to the search input, enabling typeahead functionality. A menu can only be added once and cannot be added to an already attached search input. Additionally, this ensures the proper setup for handling input and clear actions.
      Parameters:
      menu - the Menu instance to be added to the search input
      Returns:
      the instance of the current class for method chaining
    • add

      public T add(Menu menu)
      Adds a menu to the search input, enabling typeahead functionality. A menu can only be added once and cannot be added to an already attached search input. Additionally, this ensures the proper setup for handling input and clear actions.
      Parameters:
      menu - the Menu instance to be added to the search input
      Returns:
      the instance of the current class for method chaining
    • noDefaultOnClear

      public T noDefaultOnClear()
      Removes the default behavior when the component is cleared. By default, the clear button clears the input field (w/o firing a change event).
    • showUtilitiesIf

      public T showUtilitiesIf(BiFunction<T,String,Boolean> visibility)
      Sets the visibility condition for the utility button. By default, the button is visible when the input field is not empty. The provided BiFunction determines whether the utility should be visible based on the current SearchInput instance and a String value.
      Parameters:
      visibility - a BiFunction that takes the SearchInput instance and a String value as arguments and returns a Boolean indicating whether the utility should be visible.
    • stayOpen

      public T stayOpen(StayOpenPredicate stayOpen)
      Specifies a condition that determines whether the menu should remain open when a menu item is clicked.
      Parameters:
      stayOpen - a Predicate that evaluates an Event to determine if the menu remains open.
      Returns:
      the current instance with the condition applied, enabling method chaining.
    • onClear

      public T onClear(ComponentHandler<T> onClear)
      Adds a handler to be executed when the clear action is pressed.
      Parameters:
      onClear - a ComponentHandler that defines the behavior to execute on a clear action.
    • onLoaded

      public T onLoaded(ComponentHandler<T> loadedHandler)
      Adds a handler called when the menu has finished loading its items. This is relevant for menus with asynchronous item loading. By default, a loaded handler that triggers a search with the current value is already registered.
      Parameters:
      loadedHandler - a ComponentHandler to execute after the menu items have loaded.
    • onSearch

      public T onSearch(SearchFilter searchFilter)
      Sets the search filter used to match menu items against the input value. Defaults to SearchFilter.contains().
      Parameters:
      searchFilter - a SearchFilter that determines how menu items are matched during typeahead.
    • onToggle

      public T onToggle(ToggleHandler<T> toggleHandler)
      Adds a handler called when the typeahead menu is expanded or collapsed.
      Parameters:
      toggleHandler - a ToggleHandler that receives the toggle event and the current expanded state.
    • collapse

      public void collapse(boolean fireEvent)
      Specified by:
      collapse in interface Expandable<HTMLElement, T extends BaseSearchInput<T>>
    • expand

      public void expand(boolean fireEvent)
      Specified by:
      expand in interface Expandable<HTMLElement, T extends BaseSearchInput<T>>
    • typeahead

      public boolean typeahead()
      Checks whether typeahead functionality is active for this input. Typeahead is enabled when a menu has been added to the input.
      Returns:
      true if typeahead is enabled; false otherwise.
    • value

      public T value(String value)
      Description copied from class: BaseTextInputGroup
      Overrides:
      value in class BaseTextInputGroup<T extends BaseSearchInput<T>>
    • value

      public T value(String value, boolean fireEvent)
      Overrides:
      value in class BaseTextInputGroup<T extends BaseSearchInput<T>>