import { Overlay, ScrollStrategy } from '@angular/cdk/overlay'; import { ChangeDetectorRef, ElementRef, InjectionToken, NgZone, OnDestroy, ViewContainerRef } from '@angular/core'; import { ViewportRuler } from '@angular/cdk/scrolling'; import { ControlValueAccessor } from '@angular/forms'; import { OuiOption, OuiOptionSelectionChange } from '../core'; import { Observable } from 'rxjs'; import { OuiAutocomplete } from './autocomplete'; import { OuiAutocompleteOrigin } from './autocomplete-origin'; import { OuiFormField } from '../form-field/form-field'; import * as i0 from "@angular/core"; /** * The following style constants are necessary to save here in order * to properly calculate the scrollTop of the panel. Because we are not * actually focusing the active item, scroll must be handled manually. */ /** The height of each autocomplete option. */ export declare const AUTOCOMPLETE_OPTION_HEIGHT = 48; /** The total height of the autocomplete panel. */ export declare const AUTOCOMPLETE_PANEL_HEIGHT = 256; /** Injection token that determines the scroll handling while the autocomplete panel is open. */ export declare const OUI_AUTOCOMPLETE_SCROLL_STRATEGY: InjectionToken<() => ScrollStrategy>; /** @docs-private */ export declare function OUI_AUTOCOMPLETE_SCROLL_STRATEGY_FACTORY(overlay: Overlay): () => ScrollStrategy; /** @docs-private */ export declare const OUI_AUTOCOMPLETE_SCROLL_STRATEGY_FACTORY_PROVIDER: { provide: InjectionToken<() => ScrollStrategy>; deps: (typeof Overlay)[]; useFactory: typeof OUI_AUTOCOMPLETE_SCROLL_STRATEGY_FACTORY; }; /** * Provider that allows the autocomplete to register as a ControlValueAccessor. * * @docs-private */ export declare const OUI_AUTOCOMPLETE_VALUE_ACCESSOR: any; /** * Creates an error to be thrown when attempting to use an autocomplete trigger without a panel. * * @docs-private */ export declare function getOuiAutocompleteMissingPanelError(): Error; export declare class OuiAutocompleteTrigger implements ControlValueAccessor, OnDestroy { private _element; private _overlay; private _viewContainerRef; private _zone; private _changeDetectorRef; private _formField; private _document; private _viewportRuler?; private _overlayRef; private _portal; private _componentDestroyed; private _autocompleteDisabled; private _scrollStrategy; /** Old value of the native input. Used to work around issues with the `input` event on IE. */ private _previousValue; /** Strategy that is used to position the panel. */ private _positionStrategy; /** The subscription for closing actions (some are bound to document). */ private _closingActionsSubscription; /** Subscription to viewport size changes. */ private _viewportSubscription; /** * Whether the autocomplete can open the next time it is focused. Used to prevent a focused, * closed autocomplete from being reopened if the user switches to another browser tab and then * comes back. */ private _canOpenOnNextFocus; /** Stream of keyboard events that can close the panel. */ private readonly _closeKeyEventStream; private _overlayAttached; /** Stream of autocomplete option selections. */ readonly optionSelections: Observable; /** The autocomplete panel to be attached to this trigger. */ autocomplete: OuiAutocomplete; /** * Reference relative to which to position the autocomplete panel. * Defaults to the autocomplete trigger element. */ connectedTo: OuiAutocompleteOrigin; /** * `autocomplete` attribute to be set on the input element. * * @docs-private */ autocompleteAttribute: string; /** * Event handler for when the window is blurred. Needs to be an * arrow function in order to preserve the context. */ private _windowBlurHandler; /** `View -> model callback called when value changes` */ _onChange: (value: any) => void; /** `View -> model callback called when autocomplete has been touched` */ _onTouched: () => void; /** * Whether the autocomplete is disabled. When disabled, the element will * act as a regular input and the user won't be able to open the panel. */ get autocompleteDisabled(): boolean; set autocompleteDisabled(value: boolean); constructor(_element: ElementRef, _overlay: Overlay, _viewContainerRef: ViewContainerRef, _zone: NgZone, _changeDetectorRef: ChangeDetectorRef, scrollStrategy: any, _formField: OuiFormField, _document: Document, _viewportRuler?: ViewportRuler); ngOnDestroy(): void; /** Whether or not the autocomplete panel is open. */ get panelOpen(): boolean; /** Opens the autocomplete suggestion panel. */ openPanel(): void; /** Closes the autocomplete suggestion panel. */ closePanel(): void; /** * Updates the position of the autocomplete suggestion panel to ensure that it fits all options * within the viewport. */ updatePosition(): void; /** * A stream of actions that should close the autocomplete panel, including * when an option is selected, on blur, and when TAB is pressed. */ get panelClosingActions(): Observable; /** The currently active option, coerced to OuiOption type. */ get activeOption(): OuiOption | null; /** Stream of clicks outside of the autocomplete panel. */ private _getOutsideClickStream; writeValue(value: any): void; registerOnChange(fn: (value: any) => {}): void; registerOnTouched(fn: () => {}): void; setDisabledState(isDisabled: boolean): void; _handleKeydown(event: KeyboardEvent): void; _handleInput(event: KeyboardEvent): void; _handleFocus(): void; /** * Given that we are not actually focusing active options, we must manually adjust scroll * to reveal options below the fold. First, we find the offset of the option from the top * of the panel. If that offset is below the fold, the new scrollTop will be the offset - * the panel height + the option height, so the active option will be just visible at the * bottom of the panel. If that offset is above the top of the visible panel, the new scrollTop * will become the offset. If that offset is visible within the panel already, the scrollTop is * not adjusted. */ private _scrollToOption; /** * This method listens to a stream of panel closing actions and resets the * stream every time the option list changes. */ private _subscribeToClosingActions; /** Destroys the autocomplete suggestion panel. */ private _destroyPanel; private _setTriggerValue; /** * This method closes the panel, and if a value is specified, also sets the associated * control to that value. It will also mark the control as dirty if this interaction * stemmed from the user. */ private _setValueAndClose; /** * Clear any previous selected option and emit a selection change event for this option */ private _clearPreviousSelectedOption; private _attachOverlay; private _getOverlayConfig; private _getOverlayPosition; private _getConnectedElement; private _getPanelWidth; /** Returns the width of the input element, so the panel width can match it. */ private _getHostWidth; /** * Resets the active item to -1 so arrow events will activate the * correct options, or to 0 if the consumer opted into it. */ private _resetActiveItem; /** Determines whether the panel can be opened. */ private _canOpen; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } //# sourceMappingURL=autocomplete-trigger.d.ts.map