import { AfterViewInit, ChangeDetectorRef, ElementRef, EventEmitter, OnDestroy, OnInit, QueryList } from '@angular/core'; import { FormControl, NgControl } from '@angular/forms'; import { MatAutocompleteSelectedEvent } from '@angular/material/autocomplete'; import { TsDocumentService } from '@terminus/ngx-tools/browser'; import { TsChipCollectionComponent, TsChipComponent } from '@terminus/ui/chip'; import { TsFormFieldControl } from '@terminus/ui/form-field'; import { TsOptgroupComponent, TsOptionComponent } from '@terminus/ui/option'; import { TsStyleThemeTypes } from '@terminus/ui/utilities'; import { BehaviorSubject, Subject } from 'rxjs'; import { TsAutocompletePanelComponent, TsAutocompletePanelSelectedEvent } from './autocomplete-panel/autocomplete-panel.component'; import { TsAutocompleteTriggerDirective } from './autocomplete-panel/autocomplete-trigger.directive'; export declare class TsAutocompleteSelectedEvent extends MatAutocompleteSelectedEvent { } /** * The event object that is emitted when the select value has changed */ export declare class TsAutocompleteChange { source: TsAutocompleteComponent; value: T; constructor(source: TsAutocompleteComponent, value: T); } export declare type TsAutocompleteFormatter = (v: unknown) => string; export declare type TsAutocompleteComparator = (a: unknown, b: unknown) => boolean; /** * The autocomplete UI Component * * @deprecated Please use `TsSelectionListComponent` * * @example * * * https://getterminus.github.io/ui-demos-release/components/autocomplete */ export declare class TsAutocompleteComponent implements OnInit, AfterViewInit, OnDestroy, TsFormFieldControl { private changeDetectorRef; private documentService; elementRef: ElementRef; ngControl: NgControl; /** * Give the component an explicit name * * @internal */ readonly componentName = "TsAutocompleteComponent"; /** * Define the FormControl * * @internal */ autocompleteFormControl: FormControl; /** * Store a reference to the document object * * @internal */ private document; /** * Subject used to alert the parent {@link TsFormFieldComponent} when the label gap should be recalculated * * Implemented as part of TsFormFieldControl. * * @internal */ readonly labelChanges: Subject; /** * Manages keyboard events for options in the panel. * * @internal */ private keyManager; /** * The IDs of child options to be passed to the aria-owns attribute. * * @internal */ optionIds: string; /** * Whether or not the overlay panel is open */ panelOpen: boolean; /** * Since the {@link TsFormFieldComponent} is inside this template, we cannot use a provider to pass this component instance to the form * field. Instead, we pass it manually through the template with this reference. * * @internal */ selfReference: this; readonly stateChanges: Subject; /** * Define the default component ID * * @internal */ readonly uid: string; /** * Management of the query string * * @internal */ querySubject: BehaviorSubject; /** * Store the search query * * @internal */ searchQuery: string; /** * Access the trigger */ autocompletePanel: TsAutocompletePanelComponent; /** * Access the trigger */ autocompleteTrigger: TsAutocompleteTriggerDirective; /** * Access the chip list */ chipCollection: TsChipCollectionComponent | undefined; /** * Access the actual HTML element */ inputElement: ElementRef; /** * Access a list of all the defined select options */ options: QueryList; /** * Access all of the defined groups of options */ optionGroups: QueryList; /** * Whether the select has a value */ get empty(): boolean; /** * Whether the input has focus */ get focused(): boolean; /** * Determine if the label should float */ get shouldLabelFloat(): boolean; /** * Define if multiple selections are allowed */ allowMultiple: boolean; /** * Define if should allow duplicate selections */ allowDuplicateSelections: boolean; /** * Define if the panel should reopen after a selection is made * * NOTE: Though it is technically 're-opening', it happens fast enough so that it doesn't appear to close at all. */ reopenAfterSelection: boolean; /** * Define a debounce delay for the query stream * * @param value */ set debounceDelay(value: number); get debounceDelay(): number; private _debounceDelay; /** * Define if the required marker should be hidden */ hideRequiredMarker: boolean; /** * Define a hint for the input * * @param value */ set hint(value: string | undefined); get hint(): string | undefined; private _hint; /** * Define an ID for the component * * @param value */ set id(value: string); get id(): string; protected _id: string; /** * Define if the control should be disabled */ isDisabled: boolean; /** * Define if the control is required * * @param value */ set isRequired(value: boolean); get isRequired(): boolean; private _isRequired; /** * Define a minimum character count for queries * * @param value */ set minimumCharacters(value: number); get minimumCharacters(): number; private _minimumCharacters; /** * Define if the input should currently be showing a progress spinner */ showProgress: boolean; /** * Define the component theme */ theme: TsStyleThemeTypes; /** * Define if validation messages should be shown immediately or on blur */ validateOnChange: boolean; /** * Value of the select control * * @param newValue */ set value(newValue: string | undefined); get value(): string | undefined; private _value; /** * Define the placeholder/label */ label: string | undefined; /** * Define the name attribute value */ name: string | undefined; /** * Define the formatter for the selected items. * * @param v */ displayFormatter: TsAutocompleteFormatter; /** * Define the comparator for the values of the options * * @param a * @param b */ valueComparator: TsAutocompleteComparator; /** * Event for when the panel is closed */ readonly closed: EventEmitter; /** * Event for when a duplicate selection is made */ readonly duplicateSelection: EventEmitter>; /** * Event for when the panel is opened */ readonly opened: EventEmitter; /** * Emit the selected chip */ readonly optionSelected: EventEmitter>; /** * Event for when an option is removed */ readonly optionDeselected: EventEmitter>; /** * Emit the current selection */ readonly selection: EventEmitter; /** * Emit the query string */ readonly query: EventEmitter; /** * Event for when the query has changed */ readonly queryChange: EventEmitter; /** * Event for when the selections change */ readonly selectionChange: EventEmitter>; /** * Event that emits whenever the raw value of the select changes. This is here primarily * to facilitate the two-way binding for the `value` input. * * Needed for {@link TsFormFieldComponent}. */ readonly valueChange: EventEmitter; constructor(changeDetectorRef: ChangeDetectorRef, documentService: TsDocumentService, elementRef: ElementRef, ngControl: NgControl); /** * Seed initial control values */ ngOnInit(): void; /** * Subscribe to the querySubject and pass values to the query emitter * * NOTE: When an option is selected, the full selected value is piped through this stream * somehow. Have not figured out why. Best guess is it's something due to the `matAutocomplete` * directive. For now, we are filtering out anything that is not a string. */ ngAfterViewInit(): void; /** * Needed for untilComponentDestroyed */ ngOnDestroy(): void; /** * Stub in onChange * * @internal * * Needed for ControlValueAccessor (View -> model callback called when value changes) */ onChange: (value: string) => void; /** * Stub in onTouched * * @internal * * Needed for ControlValueAccessor (View -> model callback called when select has been touched) */ onTouched: () => void; /** * Close the overlay panel */ close(): void; /** * Set up a key manager to listen to keyboard events on the overlay panel */ private initKeyManager; /** * Focus the text input * * @internal */ focus(): void; /** * Open the overlay panel */ open(): void; /** * Emit a change event to set the model value * */ private propagateChanges; /** * Call FormControl updateValueAndValidity function to ensure value and valid status get updated. */ private updateValueAndValidity; /** * Sets the select's value. Part of the ControlValueAccessor interface required to integrate with Angular's core forms API. * * NOTE: Currently we are not using this, but it still must be present since this component is acting as a CVA. * * @internal * * @param value - New value to be written to the model */ writeValue(value: string): void; /** * Save a callback function to be invoked when the select's value changes from user input. * Part of the ControlValueAccessor interface required to integrate with Angular's core forms API. * * @internal * * @param fn - Callback to be triggered when the value changes */ registerOnChange(fn: (value: string) => void): void; /** * Save a callback function to be invoked when the select is blurred by the user. * Part of the ControlValueAccessor interface required to integrate with Angular's core forms API. * * @internal * * @param fn - Callback to be triggered when the component has been touched */ registerOnTouched(fn: () => {}): void; /** * Disables the select. * Part of the ControlValueAccessor interface required to integrate with Angular's core forms API. * * @param isDisabled - If the component is disabled */ setDisabledState(isDisabled: boolean): void; /** * Ensure the correct element gets focus when the primary container is clicked. * * @internal * * Implemented as part of TsFormFieldControl. */ onContainerClick(): void; /** * Close the dropdown and reset the query when the user leaves the input * * @param event - The keyboard or mouse event */ handleInputBlur(event: KeyboardEvent | MouseEvent): void; /** * Reset input */ private resetAutocompleteQuery; /** * Select an item * * @param selection - The item to select */ autocompleteSelectItem(selection: TsAutocompletePanelSelectedEvent): void; /** * Chip component emit a focusInput event, autocomplete puts focus on input field. */ focusInput(): void; /** * Deselect an item * * @param option - The value of the item to remove */ autocompleteDeselectItem(option: TsChipComponent): void; /** * Function for tracking for-loops changes * * @internal * * @param index - The item index * @returns The unique ID */ trackByFn(index: any): number; }