Autocomplete

Autocomplete input and dropdown selection with filtering options.

Installation

The Autocomplete component is built with the Popover and the Command components.

npx nx g @spartan-ng/cli:ui autocomplete

Usage

import { HlmAutocomplete } from '@spartan-ng/helm/autocomplete';
<hlm-autocomplete [options]="options" />

Brain API

BrnAutocompleteEmpty

Selector: [brnAutocompleteEmpty]

BrnAutocompleteGroup

Selector: [brnAutocompleteGroup]

Inputs

PropTypeDefaultDescription
id string `brn-autocomplete-group-${++BrnAutocompleteGroup._id}` The id of the autocomplete list

BrnAutocompleteItem

Selector: button[brnAutocompleteItem]

Inputs

PropTypeDefaultDescription
id unknown `brn-autocomplete-item-${++BrnAutocompleteItem._id}` A unique id for the item
value* (required) T - The value this item represents.
disabled boolean false Whether the item is disabled.

Outputs

PropTypeDefaultDescription
selected void - Emits when the item is selected.

BrnAutocompleteList

Selector: [brnAutocompleteList]

Inputs

PropTypeDefaultDescription
id string `brn-autocomplete-list-${++BrnAutocompleteList._id}` The id of the command list

BrnAutocompleteSearchInput

Selector: input[brnAutocompleteSearchInput]

Inputs

PropTypeDefaultDescription
value string - The initial value of the search input

BrnAutocomplete

Selector: [brnAutocomplete]

Inputs

PropTypeDefaultDescription
id string `brn-autocomplete-${++BrnAutocomplete._id}` The id of the autocomplete

Outputs

PropTypeDefaultDescription
valueChange T - when the selection has changed

Helm API

HlmAutocompleteEmpty

Selector: [hlmAutocompleteEmpty]

Inputs

PropTypeDefaultDescription
class ClassValue --

HlmAutocompleteGroup

Selector: hlm-autocomplete-group

Inputs

PropTypeDefaultDescription
class string - The user defined class

HlmAutocompleteItem

Selector: button[hlm-autocomplete-item]

Inputs

PropTypeDefaultDescription
class string - The user defined class

HlmAutocompleteList

Selector: hlm-autocomplete-list

Inputs

PropTypeDefaultDescription
class string - The user defined class

HlmAutocompleteSearchInput

Selector: input[hlm-autocomplete-search-input]

Inputs

PropTypeDefaultDescription
class ClassValue - The user defined class

HlmAutocompleteSearch

Selector: hlm-autocomplete-search

Inputs

PropTypeDefaultDescription
class ClassValue - The user defined class

HlmAutocompleteTrigger

Selector: [hlmAutocompleteTrigger]

Inputs

PropTypeDefaultDescription
disabledTrigger boolean false Whether the trigger is disabled.

HlmAutocomplete

Selector: hlm-autocomplete

Inputs

PropTypeDefaultDescription
class ClassValue - The user defined class
autocompleteListClass ClassValue - Custom class for the autocomplete list.
autocompleteEmptyClass ClassValue - Custom class for the empty and loading state container.
filteredOptions T[] [] The list of filtered options to display in the autocomplete.
value T - The selected value.
search string - The search query.
transformValueToSearch (value: T) => string this._config.transformValueToSearch Function to transform an option value to a search string. Defaults to identity function for strings.
optionTemplate TemplateRef<HlmAutocompleteOption<T>> - Optional template for rendering each option.
loading boolean false Whether the autocomplete is in a loading state.
searchPlaceholderText unknown Select an option Placeholder text for the input field.
loadingText unknown Loading options... Text to display when loading options.
emptyText unknown No options found Text to display when no options are found.
ariaLabelToggleButton string Toggle options Aria label for the toggle button.
inputId string `hlm-autocomplete-input-${++HlmAutocomplete._id}` The id of the input field.
disabled boolean false Whether the autocomplete is disabled.

Outputs

PropTypeDefaultDescription
valueChange T | null - Emitted when the selected value changes.
searchChange string - Emitted when the search query changes.

Examples

Objects

Asynchronous

Form

Command Collapsible