1 | /**
|
---|
2 | * @license
|
---|
3 | * Copyright Google LLC All Rights Reserved.
|
---|
4 | *
|
---|
5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
6 | * found in the LICENSE file at https://angular.io/license
|
---|
7 | */
|
---|
8 | import { Directionality } from '@angular/cdk/bidi';
|
---|
9 | import { BooleanInput } from '@angular/cdk/coercion';
|
---|
10 | import { Overlay, ScrollStrategy } from '@angular/cdk/overlay';
|
---|
11 | import { ViewportRuler } from '@angular/cdk/scrolling';
|
---|
12 | import { AfterViewInit, ChangeDetectorRef, ElementRef, InjectionToken, NgZone, OnDestroy, ViewContainerRef, OnChanges, SimpleChanges } from '@angular/core';
|
---|
13 | import { ControlValueAccessor } from '@angular/forms';
|
---|
14 | import { MatOption, MatOptionSelectionChange } from '@angular/material/core';
|
---|
15 | import { MatFormField } from '@angular/material/form-field';
|
---|
16 | import { Observable } from 'rxjs';
|
---|
17 | import { _MatAutocompleteBase, MatAutocompleteDefaultOptions } from './autocomplete';
|
---|
18 | import { _MatAutocompleteOriginBase } from './autocomplete-origin';
|
---|
19 | /** Injection token that determines the scroll handling while the autocomplete panel is open. */
|
---|
20 | import * as ɵngcc0 from '@angular/core';
|
---|
21 | export declare const MAT_AUTOCOMPLETE_SCROLL_STRATEGY: InjectionToken<() => ScrollStrategy>;
|
---|
22 | /** @docs-private */
|
---|
23 | export declare function MAT_AUTOCOMPLETE_SCROLL_STRATEGY_FACTORY(overlay: Overlay): () => ScrollStrategy;
|
---|
24 | /** @docs-private */
|
---|
25 | export declare const MAT_AUTOCOMPLETE_SCROLL_STRATEGY_FACTORY_PROVIDER: {
|
---|
26 | provide: InjectionToken<() => ScrollStrategy>;
|
---|
27 | deps: (typeof Overlay)[];
|
---|
28 | useFactory: typeof MAT_AUTOCOMPLETE_SCROLL_STRATEGY_FACTORY;
|
---|
29 | };
|
---|
30 | /**
|
---|
31 | * Provider that allows the autocomplete to register as a ControlValueAccessor.
|
---|
32 | * @docs-private
|
---|
33 | */
|
---|
34 | export declare const MAT_AUTOCOMPLETE_VALUE_ACCESSOR: any;
|
---|
35 | /**
|
---|
36 | * Creates an error to be thrown when attempting to use an autocomplete trigger without a panel.
|
---|
37 | * @docs-private
|
---|
38 | */
|
---|
39 | export declare function getMatAutocompleteMissingPanelError(): Error;
|
---|
40 | /** Base class with all of the `MatAutocompleteTrigger` functionality. */
|
---|
41 | export declare abstract class _MatAutocompleteTriggerBase implements ControlValueAccessor, AfterViewInit, OnChanges, OnDestroy {
|
---|
42 | private _element;
|
---|
43 | private _overlay;
|
---|
44 | private _viewContainerRef;
|
---|
45 | private _zone;
|
---|
46 | private _changeDetectorRef;
|
---|
47 | private _dir;
|
---|
48 | private _formField;
|
---|
49 | private _document;
|
---|
50 | private _viewportRuler;
|
---|
51 | private _defaults?;
|
---|
52 | private _overlayRef;
|
---|
53 | private _portal;
|
---|
54 | private _componentDestroyed;
|
---|
55 | private _autocompleteDisabled;
|
---|
56 | private _scrollStrategy;
|
---|
57 | /** Old value of the native input. Used to work around issues with the `input` event on IE. */
|
---|
58 | private _previousValue;
|
---|
59 | /** Strategy that is used to position the panel. */
|
---|
60 | private _positionStrategy;
|
---|
61 | /** Whether or not the label state is being overridden. */
|
---|
62 | private _manuallyFloatingLabel;
|
---|
63 | /** The subscription for closing actions (some are bound to document). */
|
---|
64 | private _closingActionsSubscription;
|
---|
65 | /** Subscription to viewport size changes. */
|
---|
66 | private _viewportSubscription;
|
---|
67 | /**
|
---|
68 | * Whether the autocomplete can open the next time it is focused. Used to prevent a focused,
|
---|
69 | * closed autocomplete from being reopened if the user switches to another browser tab and then
|
---|
70 | * comes back.
|
---|
71 | */
|
---|
72 | private _canOpenOnNextFocus;
|
---|
73 | /** Stream of keyboard events that can close the panel. */
|
---|
74 | private readonly _closeKeyEventStream;
|
---|
75 | /**
|
---|
76 | * Event handler for when the window is blurred. Needs to be an
|
---|
77 | * arrow function in order to preserve the context.
|
---|
78 | */
|
---|
79 | private _windowBlurHandler;
|
---|
80 | /** `View -> model callback called when value changes` */
|
---|
81 | _onChange: (value: any) => void;
|
---|
82 | /** `View -> model callback called when autocomplete has been touched` */
|
---|
83 | _onTouched: () => void;
|
---|
84 | /** The autocomplete panel to be attached to this trigger. */
|
---|
85 | autocomplete: _MatAutocompleteBase;
|
---|
86 | /**
|
---|
87 | * Position of the autocomplete panel relative to the trigger element. A position of `auto`
|
---|
88 | * will render the panel underneath the trigger if there is enough space for it to fit in
|
---|
89 | * the viewport, otherwise the panel will be shown above it. If the position is set to
|
---|
90 | * `above` or `below`, the panel will always be shown above or below the trigger. no matter
|
---|
91 | * whether it fits completely in the viewport.
|
---|
92 | */
|
---|
93 | position: 'auto' | 'above' | 'below';
|
---|
94 | /**
|
---|
95 | * Reference relative to which to position the autocomplete panel.
|
---|
96 | * Defaults to the autocomplete trigger element.
|
---|
97 | */
|
---|
98 | connectedTo: _MatAutocompleteOriginBase;
|
---|
99 | /**
|
---|
100 | * `autocomplete` attribute to be set on the input element.
|
---|
101 | * @docs-private
|
---|
102 | */
|
---|
103 | autocompleteAttribute: string;
|
---|
104 | /**
|
---|
105 | * Whether the autocomplete is disabled. When disabled, the element will
|
---|
106 | * act as a regular input and the user won't be able to open the panel.
|
---|
107 | */
|
---|
108 | get autocompleteDisabled(): boolean;
|
---|
109 | set autocompleteDisabled(value: boolean);
|
---|
110 | constructor(_element: ElementRef<HTMLInputElement>, _overlay: Overlay, _viewContainerRef: ViewContainerRef, _zone: NgZone, _changeDetectorRef: ChangeDetectorRef, scrollStrategy: any, _dir: Directionality, _formField: MatFormField, _document: any, _viewportRuler: ViewportRuler, _defaults?: MatAutocompleteDefaultOptions | undefined);
|
---|
111 | /** Class to apply to the panel when it's above the input. */
|
---|
112 | protected abstract _aboveClass: string;
|
---|
113 | ngAfterViewInit(): void;
|
---|
114 | ngOnChanges(changes: SimpleChanges): void;
|
---|
115 | ngOnDestroy(): void;
|
---|
116 | /** Whether or not the autocomplete panel is open. */
|
---|
117 | get panelOpen(): boolean;
|
---|
118 | private _overlayAttached;
|
---|
119 | /** Opens the autocomplete suggestion panel. */
|
---|
120 | openPanel(): void;
|
---|
121 | /** Closes the autocomplete suggestion panel. */
|
---|
122 | closePanel(): void;
|
---|
123 | /**
|
---|
124 | * Updates the position of the autocomplete suggestion panel to ensure that it fits all options
|
---|
125 | * within the viewport.
|
---|
126 | */
|
---|
127 | updatePosition(): void;
|
---|
128 | /**
|
---|
129 | * A stream of actions that should close the autocomplete panel, including
|
---|
130 | * when an option is selected, on blur, and when TAB is pressed.
|
---|
131 | */
|
---|
132 | get panelClosingActions(): Observable<MatOptionSelectionChange | null>;
|
---|
133 | /** Stream of autocomplete option selections. */
|
---|
134 | readonly optionSelections: Observable<MatOptionSelectionChange>;
|
---|
135 | /** The currently active option, coerced to MatOption type. */
|
---|
136 | get activeOption(): MatOption | null;
|
---|
137 | /** Stream of clicks outside of the autocomplete panel. */
|
---|
138 | private _getOutsideClickStream;
|
---|
139 | writeValue(value: any): void;
|
---|
140 | registerOnChange(fn: (value: any) => {}): void;
|
---|
141 | registerOnTouched(fn: () => {}): void;
|
---|
142 | setDisabledState(isDisabled: boolean): void;
|
---|
143 | _handleKeydown(event: KeyboardEvent): void;
|
---|
144 | _handleInput(event: KeyboardEvent): void;
|
---|
145 | _handleFocus(): void;
|
---|
146 | /**
|
---|
147 | * In "auto" mode, the label will animate down as soon as focus is lost.
|
---|
148 | * This causes the value to jump when selecting an option with the mouse.
|
---|
149 | * This method manually floats the label until the panel can be closed.
|
---|
150 | * @param shouldAnimate Whether the label should be animated when it is floated.
|
---|
151 | */
|
---|
152 | private _floatLabel;
|
---|
153 | /** If the label has been manually elevated, return it to its normal state. */
|
---|
154 | private _resetLabel;
|
---|
155 | /**
|
---|
156 | * This method listens to a stream of panel closing actions and resets the
|
---|
157 | * stream every time the option list changes.
|
---|
158 | */
|
---|
159 | private _subscribeToClosingActions;
|
---|
160 | /** Destroys the autocomplete suggestion panel. */
|
---|
161 | private _destroyPanel;
|
---|
162 | private _setTriggerValue;
|
---|
163 | /**
|
---|
164 | * This method closes the panel, and if a value is specified, also sets the associated
|
---|
165 | * control to that value. It will also mark the control as dirty if this interaction
|
---|
166 | * stemmed from the user.
|
---|
167 | */
|
---|
168 | private _setValueAndClose;
|
---|
169 | /**
|
---|
170 | * Clear any previous selected option and emit a selection change event for this option
|
---|
171 | */
|
---|
172 | private _clearPreviousSelectedOption;
|
---|
173 | private _attachOverlay;
|
---|
174 | private _getOverlayConfig;
|
---|
175 | private _getOverlayPosition;
|
---|
176 | /** Sets the positions on a position strategy based on the directive's input state. */
|
---|
177 | private _setStrategyPositions;
|
---|
178 | private _getConnectedElement;
|
---|
179 | private _getPanelWidth;
|
---|
180 | /** Returns the width of the input element, so the panel width can match it. */
|
---|
181 | private _getHostWidth;
|
---|
182 | /**
|
---|
183 | * Resets the active item to -1 so arrow events will activate the
|
---|
184 | * correct options, or to 0 if the consumer opted into it.
|
---|
185 | */
|
---|
186 | private _resetActiveItem;
|
---|
187 | /** Determines whether the panel can be opened. */
|
---|
188 | private _canOpen;
|
---|
189 | /** Use defaultView of injected document if available or fallback to global window reference */
|
---|
190 | private _getWindow;
|
---|
191 | /** Scrolls to a particular option in the list. */
|
---|
192 | private _scrollToOption;
|
---|
193 | static ngAcceptInputType_autocompleteDisabled: BooleanInput;
|
---|
194 | static ɵfac: ɵngcc0.ɵɵFactoryDeclaration<_MatAutocompleteTriggerBase, [null, null, null, null, null, null, { optional: true; }, { optional: true; host: true; }, { optional: true; }, null, { optional: true; }]>;
|
---|
195 | static ɵdir: ɵngcc0.ɵɵDirectiveDeclaration<_MatAutocompleteTriggerBase, never, never, { "position": "matAutocompletePosition"; "autocompleteAttribute": "autocomplete"; "autocompleteDisabled": "matAutocompleteDisabled"; "autocomplete": "matAutocomplete"; "connectedTo": "matAutocompleteConnectedTo"; }, {}, never>;
|
---|
196 | }
|
---|
197 | export declare class MatAutocompleteTrigger extends _MatAutocompleteTriggerBase {
|
---|
198 | protected _aboveClass: string;
|
---|
199 | static ɵfac: ɵngcc0.ɵɵFactoryDeclaration<MatAutocompleteTrigger, never>;
|
---|
200 | static ɵdir: ɵngcc0.ɵɵDirectiveDeclaration<MatAutocompleteTrigger, "input[matAutocomplete], textarea[matAutocomplete]", ["matAutocompleteTrigger"], {}, {}, never>;
|
---|
201 | }
|
---|
202 |
|
---|
203 | //# sourceMappingURL=autocomplete-trigger.d.ts.map |
---|