import * as i3 from '@angular/cdk/a11y'; import { ActiveDescendantKeyManager } from '@angular/cdk/a11y'; import * as i0 from '@angular/core'; import { ElementRef, EventEmitter, ChangeDetectorRef, AfterViewInit, OnDestroy, TemplateRef, QueryList, OnChanges, OnInit, ViewContainerRef, NgZone, InjectionToken } from '@angular/core'; import { NxFormfieldComponent } from '@aposin/ng-aquila/formfield'; import { Observable } from 'rxjs'; import { BooleanInput, NumberInput } from '@angular/cdk/coercion'; import * as i1 from '@angular/common'; import * as i2 from '@angular/cdk/overlay'; import { Overlay, ScrollStrategy, ViewportRuler } from '@angular/cdk/overlay'; import { Directionality } from '@angular/cdk/bidi'; import { AutofillMonitor } from '@angular/cdk/text-field'; import { ControlValueAccessor } from '@angular/forms'; import { NxWordComponent } from '@aposin/ng-aquila/natural-language-form'; /** Option selected event */ declare class NxAutocompleteOptionSelected { /** The option that is selected or deselected. */ readonly source: NxAutocompleteOptionComponent; /** Whether the input was triggered by the user. */ readonly isUserInput: boolean; constructor( /** The option that is selected or deselected. */ source: NxAutocompleteOptionComponent, /** Whether the input was triggered by the user. */ isUserInput?: boolean); } declare class NxAutocompleteOptionComponent { /** @docs-private */ readonly elementRef: ElementRef; private readonly _cdr; /** Id of the autocomplete option. By default it is set to an incremented value. */ get id(): string; private readonly _id; /** Whether or not the option is currently selected. */ get selected(): boolean; private _selected; /** * Whether or not the option is currently active and ready to be selected. * An active option displays styles as if it is focused, but the * focus is actually retained somewhere else. This comes in handy * for components like autocomplete where focus must remain on the input. */ get active(): boolean; private _active; /** Whether the option is disabled. */ set disabled(value: BooleanInput); get disabled(): boolean; private _disabled; /** The value of the autocomplete option. */ value: any; /** Event emitted when the option is selected or deselected. */ readonly onSelectionChange: EventEmitter; constructor( /** @docs-private */ elementRef: ElementRef, _cdr: ChangeDetectorRef); /** Ensures the option is selected when activated from the keyboard. */ _handleKeydown(event: KeyboardEvent): void; /** * Selects the option while indicating the selection came from the user. * * Used to determine if the select's view -> model callback should be invoked. */ _selectViaInteraction(): void; /** Returns the correct tabindex for the option depending on disabled state. */ _getTabIndex(): string; /** Emits the selection change event. */ private _emitSelectionChangeEvent; /** @docs-private */ get viewValue(): string; /** * This method sets display styles on the option to make it appear * active. This is used by the ActiveDescendantKeyManager so key * events will display the proper options as active on arrow key events. * @docs-private */ setActiveStyles(): void; /** * This method removes display styles on the option that made it appear * active. This is used by the ActiveDescendantKeyManager so key * events will display the proper options as active on arrow key events. * @docs-private */ setInactiveStyles(): void; /** * Gets the label to be used when determining whether the option should be focused. * @docs-private */ getLabel(): string; /** Selects the option. */ select(): void; /** Deselects the option. */ deselect(): void; /** * Sets focus onto this option. * @docs-private */ focus(): void; _onMouseDown(event: Event): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } /** Event object that is emitted when an autocomplete option is selected. */ declare class NxAutocompleteSelectedEvent { /** Reference to the autocomplete panel that emitted the event. */ readonly source: NxAutocompleteComponent; /** Option that was selected. */ readonly option: NxAutocompleteOptionComponent; constructor( /** Reference to the autocomplete panel that emitted the event. */ source: NxAutocompleteComponent, /** Option that was selected. */ option: NxAutocompleteOptionComponent); } declare class NxAutocompleteComponent implements AfterViewInit, OnDestroy { private readonly _cdr; private readonly _elementRef; private readonly formFieldComponent; /** Manages active item in option list based on key events. */ _keyManager: ActiveDescendantKeyManager; /** Whether the autocomplete panel should be visible, depending on option length. */ showPanel: boolean; /** Whether the autocomplete panel is open. */ get isOpen(): boolean; _isOpen: boolean; /** @docs-private */ template: TemplateRef; /** * Element for the panel containing the autocomplete options. * @docs-private */ panel: ElementRef; /** Items observable. If given, autocomplete takes care of the options and ng-content is discarderd */ set items(val: string[] | Observable); get items(): string[]; private _items; private _itemsSubscription?; /** * Is items observable set. * @docs-private */ get hasItems(): boolean; private _hasItems; /** Event that is emitted whenever an option from the list is selected. */ readonly optionSelected: EventEmitter; /** Event that is emitted when the autocomplete panel is opened. */ readonly opened: EventEmitter; /** Event that is emitted when the autocomplete panel is closed. */ readonly closed: EventEmitter; /** Autocomplete options in view - ie from items */ private _vOptions; /** Autocomplete options in content - ie user provided */ private _cOptions; /** Autocomplete options */ get options(): QueryList; /** * Takes classes set on the host nx-autocomplete element and applies them to the panel * inside the overlay container to allow for easy styling. */ set classList(value: string); _classList: { [key: string]: boolean; }; /** Unique ID to be used by autocomplete trigger's "aria-owns" property. */ id: string; private readonly _destroyed; /** * Value to string converter function. * As an autocomplete option can hold any value, a converter might be needed * to get a string representation of the value, which can be stored in the input. * * Default: `value => value ? value.toString() : null`. */ valueFormatter: (value: any) => string; constructor(_cdr: ChangeDetectorRef, _elementRef: ElementRef, formFieldComponent: NxFormfieldComponent | null); ngAfterViewInit(): void; ngOnDestroy(): void; /** * Sets the panel scrollTop. This allows us to manually scroll to display options * above or below the fold, as they are not actually being focused when active. */ _setScrollTop(scrollTop: number): void; /** Returns the panel's scrollTop. */ _getScrollTop(): number; /** Panel should hide itself when the option list is empty. */ _setVisibility(): void; /** Emits the `select` event. */ _emitSelectEvent(option: NxAutocompleteOptionComponent): void; get _isInOutlineField(): boolean; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } /** * Provider that allows the autocomplete to register as a ControlValueAccessor. * @docs-private */ declare const NX_AUTOCOMPLETE_VALUE_ACCESSOR: any; /** Injection token that determines the scroll handling while an autocomplete is open. */ declare const NX_AUTOCOMPLETE_SCROLL_STRATEGY: InjectionToken<() => ScrollStrategy>; /** * @docs-private * @deprecated No longer used. * @deletion-target 18.0.0 */ declare function NX_AUTOCOMPLETE_SCROLL_STRATEGY_PROVIDER_FACTORY(overlay: Overlay): () => ScrollStrategy; /** * @docs-private * @deprecated No longer used. * @deletion-target 18.0.0 */ declare const NX_AUTOCOMPLETE_SCROLL_STRATEGY_PROVIDER: { provide: InjectionToken<() => ScrollStrategy>; useFactory: typeof NX_AUTOCOMPLETE_SCROLL_STRATEGY_PROVIDER_FACTORY; deps: (typeof Overlay)[]; }; /** * Creates an error to be thrown when attempting to use an autocomplete trigger without a panel. */ declare function getNxAutocompleteMissingPanelError(): Error; declare class NxAutocompleteTriggerDirective implements ControlValueAccessor, OnDestroy, OnChanges, AfterViewInit, OnInit { private readonly _element; private readonly _overlay; private readonly _viewContainerRef; private readonly _zone; private readonly _cdr; private readonly _dir; private readonly _autofillMonitor; private readonly _nxFormField; private readonly _nxWordField; private readonly _document; private readonly _defaultScrollStrategyFactory; private readonly _viewportRuler?; private _overlayRef; private _portal; private _componentDestroyed; private _isAutofill; /** 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; /** Whether or not the label state is being overridden. */ private _manuallyFloatingLabel; /** The subscription for closing actions (some are bound to document). */ private _closingActionsSubscription; /** Subscription to viewport size changes. */ private _viewportSubscription; /** Subscription to control value changes */ private _controlValueChangesSubscription; /** Subscription to items observable */ private _itemsSubscription; /** * 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; private _injector; /** Stream of keyboard events that can close the panel. */ private readonly _closeKeyEventStream; /** Value changes */ private readonly _valueChanges; private _initialized; /** Strategy factory that will be used to handle scrolling while the autocomplete panel is open. */ private readonly _scrollStrategyFactory; /** The autocomplete panel to be attached to this trigger. */ autocomplete: NxAutocompleteComponent; /** The items callback. Called with input value, must return Observable of Array of strings */ set itemsCb(val: (val: string) => Observable); get itemsCb(): (val: string) => Observable; private _itemsCb; /** Debounce in ms before items callback is triggered. Defaults to 400 */ set debounce(val: NumberInput); private _debounce; /** Whether autocomplete functionality is disabled. */ set autocompleteDisabled(val: boolean); get autocompleteDisabled(): boolean; private _autocompleteDisabled; panelGrow: boolean; panelMaxWidth: string | number; /** Whether or not the autocomplete panel is open. */ get panelOpen(): boolean; private _overlayAttached; /** Stream of autocomplete option selections. */ readonly optionSelections: Observable; /** The currently active option, coerced to NxAutocompleteOptionComponent type. */ get activeOption(): NxAutocompleteOptionComponent | null; /** Stream of clicks outside of the autocomplete panel. */ private get _outsideClickStream(); private readonly _destroyed; /** * 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; private get _formField(); constructor(_element: ElementRef, _overlay: Overlay, _viewContainerRef: ViewContainerRef, _zone: NgZone, _cdr: ChangeDetectorRef, _dir: Directionality, _autofillMonitor: AutofillMonitor, _nxFormField: NxFormfieldComponent | null, _nxWordField: NxWordComponent | null, _document: Document | null, _defaultScrollStrategyFactory: () => ScrollStrategy, _viewportRuler?: ViewportRuler | undefined); ngOnInit(): void; ngOnDestroy(): void; ngOnChanges(): void; ngAfterViewInit(): void; /** * Binds or rebinds the autocomplete items. Prerequisites: * - items callback has to be defined * - autocomplete panel has to be bound */ private _bindAutocompleteItems; /** Opens the autocomplete suggestion panel. */ openPanel(): void; /** Closes the autocomplete suggestion panel. */ closePanel(): 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; writeValue(value: any): void; registerOnChange(fn: (value: any) => void): void; registerOnTouched(fn: () => void): void; setDisabledState(isDisabled: boolean): void; _handleKeydown(event: KeyboardEvent): void; _handleInput(event: KeyboardEvent): void; _handleFocus(): void; /** * In "auto" mode, the label will animate down as soon as focus is lost. * This causes the value to jump when selecting an option with the mouse. * This method manually floats the label until the panel can be closed. */ private _floatLabel; /** If the label has been manually elevated, return it to its normal state. */ private _resetLabel; /** * 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; /** Returns the width of the input element, so the panel min-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 _isFieldEnabled; private _flipDirection; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } declare class NxAutocompleteModule { static ɵfac: i0.ɵɵFactoryDeclaration; static ɵmod: i0.ɵɵNgModuleDeclaration; static ɵinj: i0.ɵɵInjectorDeclaration; } export { NX_AUTOCOMPLETE_SCROLL_STRATEGY, NX_AUTOCOMPLETE_SCROLL_STRATEGY_PROVIDER, NX_AUTOCOMPLETE_SCROLL_STRATEGY_PROVIDER_FACTORY, NX_AUTOCOMPLETE_VALUE_ACCESSOR, NxAutocompleteComponent, NxAutocompleteModule, NxAutocompleteOptionComponent, NxAutocompleteOptionSelected, NxAutocompleteSelectedEvent, NxAutocompleteTriggerDirective, getNxAutocompleteMissingPanelError };