| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436 |
- /**
- * @license
- * Copyright Google LLC All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- (function (global, factory) {
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/cdk/a11y'), require('@angular/cdk/coercion'), require('@angular/core'), require('@angular/material/core'), require('@angular/cdk/bidi'), require('@angular/cdk/keycodes'), require('@angular/cdk/overlay'), require('@angular/cdk/portal'), require('@angular/common'), require('rxjs/operators'), require('@angular/cdk/scrolling'), require('@angular/forms'), require('@angular/material/form-field'), require('rxjs')) :
- typeof define === 'function' && define.amd ? define('@angular/material/autocomplete', ['exports', '@angular/cdk/a11y', '@angular/cdk/coercion', '@angular/core', '@angular/material/core', '@angular/cdk/bidi', '@angular/cdk/keycodes', '@angular/cdk/overlay', '@angular/cdk/portal', '@angular/common', 'rxjs/operators', '@angular/cdk/scrolling', '@angular/forms', '@angular/material/form-field', 'rxjs'], factory) :
- (factory((global.ng = global.ng || {}, global.ng.material = global.ng.material || {}, global.ng.material.autocomplete = {}),global.ng.cdk.a11y,global.ng.cdk.coercion,global.ng.core,global.ng.material.core,global.ng.cdk.bidi,global.ng.cdk.keycodes,global.ng.cdk.overlay,global.ng.cdk.portal,global.ng.common,global.rxjs.operators,global.ng.cdk.scrolling,global.ng.forms,global.ng.material.formField,global.rxjs));
- }(this, (function (exports,a11y,coercion,core,core$1,bidi,keycodes,overlay,portal,common,operators,scrolling,forms,formField,rxjs) { 'use strict';
- /*! *****************************************************************************
- Copyright (c) Microsoft Corporation. All rights reserved.
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
- this file except in compliance with the License. You may obtain a copy of the
- License at http://www.apache.org/licenses/LICENSE-2.0
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
- MERCHANTABLITY OR NON-INFRINGEMENT.
- See the Apache Version 2.0 License for specific language governing permissions
- and limitations under the License.
- ***************************************************************************** */
- /* global Reflect, Promise */
- var extendStatics = function(d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- function __extends(d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- }
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- /**
- * Autocomplete IDs need to be unique across components, so this counter exists outside of
- * the component definition.
- * @type {?}
- */
- var _uniqueAutocompleteIdCounter = 0;
- /**
- * Event object that is emitted when an autocomplete option is selected.
- */
- var /**
- * Event object that is emitted when an autocomplete option is selected.
- */
- MatAutocompleteSelectedEvent = /** @class */ (function () {
- function MatAutocompleteSelectedEvent(source, option) {
- this.source = source;
- this.option = option;
- }
- return MatAutocompleteSelectedEvent;
- }());
- // Boilerplate for applying mixins to MatAutocomplete.
- /**
- * \@docs-private
- */
- var
- // Boilerplate for applying mixins to MatAutocomplete.
- /**
- * \@docs-private
- */
- MatAutocompleteBase = /** @class */ (function () {
- function MatAutocompleteBase() {
- }
- return MatAutocompleteBase;
- }());
- /** @type {?} */
- var _MatAutocompleteMixinBase = core$1.mixinDisableRipple(MatAutocompleteBase);
- /**
- * Injection token to be used to override the default options for `mat-autocomplete`.
- * @type {?}
- */
- var MAT_AUTOCOMPLETE_DEFAULT_OPTIONS = new core.InjectionToken('mat-autocomplete-default-options', {
- providedIn: 'root',
- factory: MAT_AUTOCOMPLETE_DEFAULT_OPTIONS_FACTORY,
- });
- /**
- * \@docs-private
- * @return {?}
- */
- function MAT_AUTOCOMPLETE_DEFAULT_OPTIONS_FACTORY() {
- return { autoActiveFirstOption: false };
- }
- var MatAutocomplete = /** @class */ (function (_super) {
- __extends(MatAutocomplete, _super);
- function MatAutocomplete(_changeDetectorRef, _elementRef, defaults) {
- var _this = _super.call(this) || this;
- _this._changeDetectorRef = _changeDetectorRef;
- _this._elementRef = _elementRef;
- /**
- * Whether the autocomplete panel should be visible, depending on option length.
- */
- _this.showPanel = false;
- _this._isOpen = false;
- /**
- * Function that maps an option's control value to its display value in the trigger.
- */
- _this.displayWith = null;
- /**
- * Event that is emitted whenever an option from the list is selected.
- */
- _this.optionSelected = new core.EventEmitter();
- /**
- * Event that is emitted when the autocomplete panel is opened.
- */
- _this.opened = new core.EventEmitter();
- /**
- * Event that is emitted when the autocomplete panel is closed.
- */
- _this.closed = new core.EventEmitter();
- _this._classList = {};
- /**
- * Unique ID to be used by autocomplete trigger's "aria-owns" property.
- */
- _this.id = "mat-autocomplete-" + _uniqueAutocompleteIdCounter++;
- _this._autoActiveFirstOption = !!defaults.autoActiveFirstOption;
- return _this;
- }
- Object.defineProperty(MatAutocomplete.prototype, "isOpen", {
- /** Whether the autocomplete panel is open. */
- get: /**
- * Whether the autocomplete panel is open.
- * @return {?}
- */
- function () { return this._isOpen && this.showPanel; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MatAutocomplete.prototype, "autoActiveFirstOption", {
- /**
- * Whether the first option should be highlighted when the autocomplete panel is opened.
- * Can be configured globally through the `MAT_AUTOCOMPLETE_DEFAULT_OPTIONS` token.
- */
- get: /**
- * Whether the first option should be highlighted when the autocomplete panel is opened.
- * Can be configured globally through the `MAT_AUTOCOMPLETE_DEFAULT_OPTIONS` token.
- * @return {?}
- */
- function () { return this._autoActiveFirstOption; },
- set: /**
- * @param {?} value
- * @return {?}
- */
- function (value) {
- this._autoActiveFirstOption = coercion.coerceBooleanProperty(value);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MatAutocomplete.prototype, "classList", {
- /**
- * Takes classes set on the host mat-autocomplete element and applies them to the panel
- * inside the overlay container to allow for easy styling.
- */
- set: /**
- * Takes classes set on the host mat-autocomplete element and applies them to the panel
- * inside the overlay container to allow for easy styling.
- * @param {?} value
- * @return {?}
- */
- function (value) {
- if (value && value.length) {
- this._classList = value.split(' ').reduce((/**
- * @param {?} classList
- * @param {?} className
- * @return {?}
- */
- function (classList, className) {
- classList[className.trim()] = true;
- return classList;
- }), (/** @type {?} */ ({})));
- }
- else {
- this._classList = {};
- }
- this._setVisibilityClasses(this._classList);
- this._elementRef.nativeElement.className = '';
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @return {?}
- */
- MatAutocomplete.prototype.ngAfterContentInit = /**
- * @return {?}
- */
- function () {
- this._keyManager = new a11y.ActiveDescendantKeyManager(this.options).withWrap();
- // Set the initial visibility state.
- this._setVisibility();
- };
- /**
- * 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.
- */
- /**
- * 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.
- * @param {?} scrollTop
- * @return {?}
- */
- MatAutocomplete.prototype._setScrollTop = /**
- * 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.
- * @param {?} scrollTop
- * @return {?}
- */
- function (scrollTop) {
- if (this.panel) {
- this.panel.nativeElement.scrollTop = scrollTop;
- }
- };
- /** Returns the panel's scrollTop. */
- /**
- * Returns the panel's scrollTop.
- * @return {?}
- */
- MatAutocomplete.prototype._getScrollTop = /**
- * Returns the panel's scrollTop.
- * @return {?}
- */
- function () {
- return this.panel ? this.panel.nativeElement.scrollTop : 0;
- };
- /** Panel should hide itself when the option list is empty. */
- /**
- * Panel should hide itself when the option list is empty.
- * @return {?}
- */
- MatAutocomplete.prototype._setVisibility = /**
- * Panel should hide itself when the option list is empty.
- * @return {?}
- */
- function () {
- this.showPanel = !!this.options.length;
- this._setVisibilityClasses(this._classList);
- this._changeDetectorRef.markForCheck();
- };
- /** Emits the `select` event. */
- /**
- * Emits the `select` event.
- * @param {?} option
- * @return {?}
- */
- MatAutocomplete.prototype._emitSelectEvent = /**
- * Emits the `select` event.
- * @param {?} option
- * @return {?}
- */
- function (option) {
- /** @type {?} */
- var event = new MatAutocompleteSelectedEvent(this, option);
- this.optionSelected.emit(event);
- };
- /** Sets the autocomplete visibility classes on a classlist based on the panel is visible. */
- /**
- * Sets the autocomplete visibility classes on a classlist based on the panel is visible.
- * @private
- * @param {?} classList
- * @return {?}
- */
- MatAutocomplete.prototype._setVisibilityClasses = /**
- * Sets the autocomplete visibility classes on a classlist based on the panel is visible.
- * @private
- * @param {?} classList
- * @return {?}
- */
- function (classList) {
- classList['mat-autocomplete-visible'] = this.showPanel;
- classList['mat-autocomplete-hidden'] = !this.showPanel;
- };
- MatAutocomplete.decorators = [
- { type: core.Component, args: [{selector: 'mat-autocomplete',
- template: "<ng-template><div class=\"mat-autocomplete-panel\" role=\"listbox\" [id]=\"id\" [ngClass]=\"_classList\" #panel><ng-content></ng-content></div></ng-template>",
- styles: [".mat-autocomplete-panel{min-width:112px;max-width:280px;overflow:auto;-webkit-overflow-scrolling:touch;visibility:hidden;max-width:none;max-height:256px;position:relative;width:100%;border-bottom-left-radius:4px;border-bottom-right-radius:4px}.mat-autocomplete-panel.mat-autocomplete-visible{visibility:visible}.mat-autocomplete-panel.mat-autocomplete-hidden{visibility:hidden}.mat-autocomplete-panel-above .mat-autocomplete-panel{border-radius:0;border-top-left-radius:4px;border-top-right-radius:4px}.mat-autocomplete-panel .mat-divider-horizontal{margin-top:-1px}@media (-ms-high-contrast:active){.mat-autocomplete-panel{outline:solid 1px}}"],
- encapsulation: core.ViewEncapsulation.None,
- changeDetection: core.ChangeDetectionStrategy.OnPush,
- exportAs: 'matAutocomplete',
- inputs: ['disableRipple'],
- host: {
- 'class': 'mat-autocomplete'
- },
- providers: [
- { provide: core$1.MAT_OPTION_PARENT_COMPONENT, useExisting: MatAutocomplete }
- ]
- },] },
- ];
- /** @nocollapse */
- MatAutocomplete.ctorParameters = function () { return [
- { type: core.ChangeDetectorRef },
- { type: core.ElementRef },
- { type: undefined, decorators: [{ type: core.Inject, args: [MAT_AUTOCOMPLETE_DEFAULT_OPTIONS,] }] }
- ]; };
- MatAutocomplete.propDecorators = {
- template: [{ type: core.ViewChild, args: [core.TemplateRef, { static: true },] }],
- panel: [{ type: core.ViewChild, args: ['panel', { static: false },] }],
- options: [{ type: core.ContentChildren, args: [core$1.MatOption, { descendants: true },] }],
- optionGroups: [{ type: core.ContentChildren, args: [core$1.MatOptgroup,] }],
- displayWith: [{ type: core.Input }],
- autoActiveFirstOption: [{ type: core.Input }],
- panelWidth: [{ type: core.Input }],
- optionSelected: [{ type: core.Output }],
- opened: [{ type: core.Output }],
- closed: [{ type: core.Output }],
- classList: [{ type: core.Input, args: ['class',] }]
- };
- return MatAutocomplete;
- }(_MatAutocompleteMixinBase));
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- /**
- * Directive applied to an element to make it usable
- * as a connection point for an autocomplete panel.
- */
- var MatAutocompleteOrigin = /** @class */ (function () {
- function MatAutocompleteOrigin(elementRef) {
- this.elementRef = elementRef;
- }
- MatAutocompleteOrigin.decorators = [
- { type: core.Directive, args: [{
- selector: '[matAutocompleteOrigin]',
- exportAs: 'matAutocompleteOrigin',
- },] },
- ];
- /** @nocollapse */
- MatAutocompleteOrigin.ctorParameters = function () { return [
- { type: core.ElementRef }
- ]; };
- return MatAutocompleteOrigin;
- }());
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- /**
- * The height of each autocomplete option.
- * @type {?}
- */
- var AUTOCOMPLETE_OPTION_HEIGHT = 48;
- /**
- * The total height of the autocomplete panel.
- * @type {?}
- */
- var AUTOCOMPLETE_PANEL_HEIGHT = 256;
- /**
- * Injection token that determines the scroll handling while the autocomplete panel is open.
- * @type {?}
- */
- var MAT_AUTOCOMPLETE_SCROLL_STRATEGY = new core.InjectionToken('mat-autocomplete-scroll-strategy');
- /**
- * \@docs-private
- * @param {?} overlay
- * @return {?}
- */
- function MAT_AUTOCOMPLETE_SCROLL_STRATEGY_FACTORY(overlay$$1) {
- return (/**
- * @return {?}
- */
- function () { return overlay$$1.scrollStrategies.reposition(); });
- }
- /**
- * \@docs-private
- * @type {?}
- */
- var MAT_AUTOCOMPLETE_SCROLL_STRATEGY_FACTORY_PROVIDER = {
- provide: MAT_AUTOCOMPLETE_SCROLL_STRATEGY,
- deps: [overlay.Overlay],
- useFactory: MAT_AUTOCOMPLETE_SCROLL_STRATEGY_FACTORY,
- };
- /**
- * Provider that allows the autocomplete to register as a ControlValueAccessor.
- * \@docs-private
- * @type {?}
- */
- var MAT_AUTOCOMPLETE_VALUE_ACCESSOR = {
- provide: forms.NG_VALUE_ACCESSOR,
- useExisting: core.forwardRef((/**
- * @return {?}
- */
- function () { return MatAutocompleteTrigger; })),
- multi: true
- };
- /**
- * Creates an error to be thrown when attempting to use an autocomplete trigger without a panel.
- * \@docs-private
- * @return {?}
- */
- function getMatAutocompleteMissingPanelError() {
- return Error('Attempting to open an undefined instance of `mat-autocomplete`. ' +
- 'Make sure that the id passed to the `matAutocomplete` is correct and that ' +
- 'you\'re attempting to open it after the ngAfterContentInit hook.');
- }
- var MatAutocompleteTrigger = /** @class */ (function () {
- function MatAutocompleteTrigger(_element, _overlay, _viewContainerRef, _zone, _changeDetectorRef, scrollStrategy, _dir, _formField, _document, _viewportRuler) {
- var _this = this;
- this._element = _element;
- this._overlay = _overlay;
- this._viewContainerRef = _viewContainerRef;
- this._zone = _zone;
- this._changeDetectorRef = _changeDetectorRef;
- this._dir = _dir;
- this._formField = _formField;
- this._document = _document;
- this._viewportRuler = _viewportRuler;
- this._componentDestroyed = false;
- this._autocompleteDisabled = false;
- /**
- * Whether or not the label state is being overridden.
- */
- this._manuallyFloatingLabel = false;
- /**
- * Subscription to viewport size changes.
- */
- this._viewportSubscription = rxjs.Subscription.EMPTY;
- /**
- * 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.
- */
- this._canOpenOnNextFocus = true;
- /**
- * Stream of keyboard events that can close the panel.
- */
- this._closeKeyEventStream = new rxjs.Subject();
- /**
- * Event handler for when the window is blurred. Needs to be an
- * arrow function in order to preserve the context.
- */
- this._windowBlurHandler = (/**
- * @return {?}
- */
- function () {
- // If the user blurred the window while the autocomplete is focused, it means that it'll be
- // refocused when they come back. In this case we want to skip the first focus event, if the
- // pane was closed, in order to avoid reopening it unintentionally.
- _this._canOpenOnNextFocus =
- _this._document.activeElement !== _this._element.nativeElement || _this.panelOpen;
- });
- /**
- * `View -> model callback called when value changes`
- */
- this._onChange = (/**
- * @return {?}
- */
- function () { });
- /**
- * `View -> model callback called when autocomplete has been touched`
- */
- this._onTouched = (/**
- * @return {?}
- */
- function () { });
- /**
- * Position of the autocomplete panel relative to the trigger element. A position of `auto`
- * will render the panel underneath the trigger if there is enough space for it to fit in
- * the viewport, otherwise the panel will be shown above it. If the position is set to
- * `above` or `below`, the panel will always be shown above or below the trigger. no matter
- * whether it fits completely in the viewport.
- */
- this.position = 'auto';
- /**
- * `autocomplete` attribute to be set on the input element.
- * \@docs-private
- */
- this.autocompleteAttribute = 'off';
- this._overlayAttached = false;
- /**
- * Stream of autocomplete option selections.
- */
- this.optionSelections = (/** @type {?} */ (rxjs.defer((/**
- * @return {?}
- */
- function () {
- if (_this.autocomplete && _this.autocomplete.options) {
- return rxjs.merge.apply(void 0, _this.autocomplete.options.map((/**
- * @param {?} option
- * @return {?}
- */
- function (option) { return option.onSelectionChange; })));
- }
- // If there are any subscribers before `ngAfterViewInit`, the `autocomplete` will be undefined.
- // Return a stream that we'll replace with the real one once everything is in place.
- return _this._zone.onStable
- .asObservable()
- .pipe(operators.take(1), operators.switchMap((/**
- * @return {?}
- */
- function () { return _this.optionSelections; })));
- }))));
- if (typeof window !== 'undefined') {
- _zone.runOutsideAngular((/**
- * @return {?}
- */
- function () {
- window.addEventListener('blur', _this._windowBlurHandler);
- }));
- }
- this._scrollStrategy = scrollStrategy;
- }
- Object.defineProperty(MatAutocompleteTrigger.prototype, "autocompleteDisabled", {
- /**
- * 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: /**
- * 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.
- * @return {?}
- */
- function () { return this._autocompleteDisabled; },
- set: /**
- * @param {?} value
- * @return {?}
- */
- function (value) {
- this._autocompleteDisabled = coercion.coerceBooleanProperty(value);
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @param {?} changes
- * @return {?}
- */
- MatAutocompleteTrigger.prototype.ngOnChanges = /**
- * @param {?} changes
- * @return {?}
- */
- function (changes) {
- if (changes['position'] && this._positionStrategy) {
- this._setStrategyPositions(this._positionStrategy);
- if (this.panelOpen) {
- (/** @type {?} */ (this._overlayRef)).updatePosition();
- }
- }
- };
- /**
- * @return {?}
- */
- MatAutocompleteTrigger.prototype.ngOnDestroy = /**
- * @return {?}
- */
- function () {
- if (typeof window !== 'undefined') {
- window.removeEventListener('blur', this._windowBlurHandler);
- }
- this._viewportSubscription.unsubscribe();
- this._componentDestroyed = true;
- this._destroyPanel();
- this._closeKeyEventStream.complete();
- };
- Object.defineProperty(MatAutocompleteTrigger.prototype, "panelOpen", {
- /** Whether or not the autocomplete panel is open. */
- get: /**
- * Whether or not the autocomplete panel is open.
- * @return {?}
- */
- function () {
- return this._overlayAttached && this.autocomplete.showPanel;
- },
- enumerable: true,
- configurable: true
- });
- /** Opens the autocomplete suggestion panel. */
- /**
- * Opens the autocomplete suggestion panel.
- * @return {?}
- */
- MatAutocompleteTrigger.prototype.openPanel = /**
- * Opens the autocomplete suggestion panel.
- * @return {?}
- */
- function () {
- this._attachOverlay();
- this._floatLabel();
- };
- /** Closes the autocomplete suggestion panel. */
- /**
- * Closes the autocomplete suggestion panel.
- * @return {?}
- */
- MatAutocompleteTrigger.prototype.closePanel = /**
- * Closes the autocomplete suggestion panel.
- * @return {?}
- */
- function () {
- this._resetLabel();
- if (!this._overlayAttached) {
- return;
- }
- if (this.panelOpen) {
- // Only emit if the panel was visible.
- this.autocomplete.closed.emit();
- }
- this.autocomplete._isOpen = this._overlayAttached = false;
- if (this._overlayRef && this._overlayRef.hasAttached()) {
- this._overlayRef.detach();
- this._closingActionsSubscription.unsubscribe();
- }
- // Note that in some cases this can end up being called after the component is destroyed.
- // Add a check to ensure that we don't try to run change detection on a destroyed view.
- if (!this._componentDestroyed) {
- // We need to trigger change detection manually, because
- // `fromEvent` doesn't seem to do it at the proper time.
- // This ensures that the label is reset when the
- // user clicks outside.
- this._changeDetectorRef.detectChanges();
- }
- };
- /**
- * Updates the position of the autocomplete suggestion panel to ensure that it fits all options
- * within the viewport.
- */
- /**
- * Updates the position of the autocomplete suggestion panel to ensure that it fits all options
- * within the viewport.
- * @return {?}
- */
- MatAutocompleteTrigger.prototype.updatePosition = /**
- * Updates the position of the autocomplete suggestion panel to ensure that it fits all options
- * within the viewport.
- * @return {?}
- */
- function () {
- if (this._overlayAttached) {
- (/** @type {?} */ (this._overlayRef)).updatePosition();
- }
- };
- Object.defineProperty(MatAutocompleteTrigger.prototype, "panelClosingActions", {
- /**
- * A stream of actions that should close the autocomplete panel, including
- * when an option is selected, on blur, and when TAB is pressed.
- */
- get: /**
- * A stream of actions that should close the autocomplete panel, including
- * when an option is selected, on blur, and when TAB is pressed.
- * @return {?}
- */
- function () {
- var _this = this;
- return rxjs.merge(this.optionSelections, this.autocomplete._keyManager.tabOut.pipe(operators.filter((/**
- * @return {?}
- */
- function () { return _this._overlayAttached; }))), this._closeKeyEventStream, this._getOutsideClickStream(), this._overlayRef ?
- this._overlayRef.detachments().pipe(operators.filter((/**
- * @return {?}
- */
- function () { return _this._overlayAttached; }))) :
- rxjs.of()).pipe(
- // Normalize the output so we return a consistent type.
- operators.map((/**
- * @param {?} event
- * @return {?}
- */
- function (event) { return event instanceof core$1.MatOptionSelectionChange ? event : null; })));
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MatAutocompleteTrigger.prototype, "activeOption", {
- /** The currently active option, coerced to MatOption type. */
- get: /**
- * The currently active option, coerced to MatOption type.
- * @return {?}
- */
- function () {
- if (this.autocomplete && this.autocomplete._keyManager) {
- return this.autocomplete._keyManager.activeItem;
- }
- return null;
- },
- enumerable: true,
- configurable: true
- });
- /** Stream of clicks outside of the autocomplete panel. */
- /**
- * Stream of clicks outside of the autocomplete panel.
- * @private
- * @return {?}
- */
- MatAutocompleteTrigger.prototype._getOutsideClickStream = /**
- * Stream of clicks outside of the autocomplete panel.
- * @private
- * @return {?}
- */
- function () {
- var _this = this;
- return rxjs.merge((/** @type {?} */ (rxjs.fromEvent(this._document, 'click'))), (/** @type {?} */ (rxjs.fromEvent(this._document, 'touchend'))))
- .pipe(operators.filter((/**
- * @param {?} event
- * @return {?}
- */
- function (event) {
- /** @type {?} */
- var clickTarget = (/** @type {?} */ (event.target));
- /** @type {?} */
- var formField$$1 = _this._formField ?
- _this._formField._elementRef.nativeElement : null;
- return _this._overlayAttached &&
- clickTarget !== _this._element.nativeElement &&
- (!formField$$1 || !formField$$1.contains(clickTarget)) &&
- (!!_this._overlayRef && !_this._overlayRef.overlayElement.contains(clickTarget));
- })));
- };
- // Implemented as part of ControlValueAccessor.
- // Implemented as part of ControlValueAccessor.
- /**
- * @param {?} value
- * @return {?}
- */
- MatAutocompleteTrigger.prototype.writeValue =
- // Implemented as part of ControlValueAccessor.
- /**
- * @param {?} value
- * @return {?}
- */
- function (value) {
- var _this = this;
- Promise.resolve(null).then((/**
- * @return {?}
- */
- function () { return _this._setTriggerValue(value); }));
- };
- // Implemented as part of ControlValueAccessor.
- // Implemented as part of ControlValueAccessor.
- /**
- * @param {?} fn
- * @return {?}
- */
- MatAutocompleteTrigger.prototype.registerOnChange =
- // Implemented as part of ControlValueAccessor.
- /**
- * @param {?} fn
- * @return {?}
- */
- function (fn) {
- this._onChange = fn;
- };
- // Implemented as part of ControlValueAccessor.
- // Implemented as part of ControlValueAccessor.
- /**
- * @param {?} fn
- * @return {?}
- */
- MatAutocompleteTrigger.prototype.registerOnTouched =
- // Implemented as part of ControlValueAccessor.
- /**
- * @param {?} fn
- * @return {?}
- */
- function (fn) {
- this._onTouched = fn;
- };
- // Implemented as part of ControlValueAccessor.
- // Implemented as part of ControlValueAccessor.
- /**
- * @param {?} isDisabled
- * @return {?}
- */
- MatAutocompleteTrigger.prototype.setDisabledState =
- // Implemented as part of ControlValueAccessor.
- /**
- * @param {?} isDisabled
- * @return {?}
- */
- function (isDisabled) {
- this._element.nativeElement.disabled = isDisabled;
- };
- /**
- * @param {?} event
- * @return {?}
- */
- MatAutocompleteTrigger.prototype._handleKeydown = /**
- * @param {?} event
- * @return {?}
- */
- function (event) {
- /** @type {?} */
- var keyCode = event.keyCode;
- // Prevent the default action on all escape key presses. This is here primarily to bring IE
- // in line with other browsers. By default, pressing escape on IE will cause it to revert
- // the input value to the one that it had on focus, however it won't dispatch any events
- // which means that the model value will be out of sync with the view.
- if (keyCode === keycodes.ESCAPE) {
- event.preventDefault();
- }
- if (this.activeOption && keyCode === keycodes.ENTER && this.panelOpen) {
- this.activeOption._selectViaInteraction();
- this._resetActiveItem();
- event.preventDefault();
- }
- else if (this.autocomplete) {
- /** @type {?} */
- var prevActiveItem = this.autocomplete._keyManager.activeItem;
- /** @type {?} */
- var isArrowKey = keyCode === keycodes.UP_ARROW || keyCode === keycodes.DOWN_ARROW;
- if (this.panelOpen || keyCode === keycodes.TAB) {
- this.autocomplete._keyManager.onKeydown(event);
- }
- else if (isArrowKey && this._canOpen()) {
- this.openPanel();
- }
- if (isArrowKey || this.autocomplete._keyManager.activeItem !== prevActiveItem) {
- this._scrollToOption();
- }
- }
- };
- /**
- * @param {?} event
- * @return {?}
- */
- MatAutocompleteTrigger.prototype._handleInput = /**
- * @param {?} event
- * @return {?}
- */
- function (event) {
- /** @type {?} */
- var target = (/** @type {?} */ (event.target));
- /** @type {?} */
- var value = target.value;
- // Based on `NumberValueAccessor` from forms.
- if (target.type === 'number') {
- value = value == '' ? null : parseFloat(value);
- }
- // If the input has a placeholder, IE will fire the `input` event on page load,
- // focus and blur, in addition to when the user actually changed the value. To
- // filter out all of the extra events, we save the value on focus and between
- // `input` events, and we check whether it changed.
- // See: https://connect.microsoft.com/IE/feedback/details/885747/
- if (this._previousValue !== value) {
- this._previousValue = value;
- this._onChange(value);
- if (this._canOpen() && this._document.activeElement === event.target) {
- this.openPanel();
- }
- }
- };
- /**
- * @return {?}
- */
- MatAutocompleteTrigger.prototype._handleFocus = /**
- * @return {?}
- */
- function () {
- if (!this._canOpenOnNextFocus) {
- this._canOpenOnNextFocus = true;
- }
- else if (this._canOpen()) {
- this._previousValue = this._element.nativeElement.value;
- this._attachOverlay();
- this._floatLabel(true);
- }
- };
- /**
- * 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.
- * @param shouldAnimate Whether the label should be animated when it is floated.
- */
- /**
- * 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
- * @param {?=} shouldAnimate Whether the label should be animated when it is floated.
- * @return {?}
- */
- MatAutocompleteTrigger.prototype._floatLabel = /**
- * 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
- * @param {?=} shouldAnimate Whether the label should be animated when it is floated.
- * @return {?}
- */
- function (shouldAnimate) {
- if (shouldAnimate === void 0) { shouldAnimate = false; }
- if (this._formField && this._formField.floatLabel === 'auto') {
- if (shouldAnimate) {
- this._formField._animateAndLockLabel();
- }
- else {
- this._formField.floatLabel = 'always';
- }
- this._manuallyFloatingLabel = true;
- }
- };
- /** If the label has been manually elevated, return it to its normal state. */
- /**
- * If the label has been manually elevated, return it to its normal state.
- * @private
- * @return {?}
- */
- MatAutocompleteTrigger.prototype._resetLabel = /**
- * If the label has been manually elevated, return it to its normal state.
- * @private
- * @return {?}
- */
- function () {
- if (this._manuallyFloatingLabel) {
- this._formField.floatLabel = 'auto';
- this._manuallyFloatingLabel = false;
- }
- };
- /**
- * 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.
- */
- /**
- * 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
- * @return {?}
- */
- MatAutocompleteTrigger.prototype._scrollToOption = /**
- * 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
- * @return {?}
- */
- function () {
- /** @type {?} */
- var index = this.autocomplete._keyManager.activeItemIndex || 0;
- /** @type {?} */
- var labelCount = core$1._countGroupLabelsBeforeOption(index, this.autocomplete.options, this.autocomplete.optionGroups);
- /** @type {?} */
- var newScrollPosition = core$1._getOptionScrollPosition(index + labelCount, AUTOCOMPLETE_OPTION_HEIGHT, this.autocomplete._getScrollTop(), AUTOCOMPLETE_PANEL_HEIGHT);
- this.autocomplete._setScrollTop(newScrollPosition);
- };
- /**
- * This method listens to a stream of panel closing actions and resets the
- * stream every time the option list changes.
- */
- /**
- * This method listens to a stream of panel closing actions and resets the
- * stream every time the option list changes.
- * @private
- * @return {?}
- */
- MatAutocompleteTrigger.prototype._subscribeToClosingActions = /**
- * This method listens to a stream of panel closing actions and resets the
- * stream every time the option list changes.
- * @private
- * @return {?}
- */
- function () {
- var _this = this;
- /** @type {?} */
- var firstStable = this._zone.onStable.asObservable().pipe(operators.take(1));
- /** @type {?} */
- var optionChanges = this.autocomplete.options.changes.pipe(operators.tap((/**
- * @return {?}
- */
- function () { return _this._positionStrategy.reapplyLastPosition(); })),
- // Defer emitting to the stream until the next tick, because changing
- // bindings in here will cause "changed after checked" errors.
- operators.delay(0));
- // When the zone is stable initially, and when the option list changes...
- return rxjs.merge(firstStable, optionChanges)
- .pipe(
- // create a new stream of panelClosingActions, replacing any previous streams
- // that were created, and flatten it so our stream only emits closing events...
- operators.switchMap((/**
- * @return {?}
- */
- function () {
- /** @type {?} */
- var wasOpen = _this.panelOpen;
- _this._resetActiveItem();
- _this.autocomplete._setVisibility();
- if (_this.panelOpen) {
- (/** @type {?} */ (_this._overlayRef)).updatePosition();
- // If the `panelOpen` state changed, we need to make sure to emit the `opened`
- // event, because we may not have emitted it when the panel was attached. This
- // can happen if the users opens the panel and there are no options, but the
- // options come in slightly later or as a result of the value changing.
- if (wasOpen !== _this.panelOpen) {
- _this.autocomplete.opened.emit();
- }
- }
- return _this.panelClosingActions;
- })),
- // when the first closing event occurs...
- operators.take(1))
- // set the value, close the panel, and complete.
- .subscribe((/**
- * @param {?} event
- * @return {?}
- */
- function (event) { return _this._setValueAndClose(event); }));
- };
- /** Destroys the autocomplete suggestion panel. */
- /**
- * Destroys the autocomplete suggestion panel.
- * @private
- * @return {?}
- */
- MatAutocompleteTrigger.prototype._destroyPanel = /**
- * Destroys the autocomplete suggestion panel.
- * @private
- * @return {?}
- */
- function () {
- if (this._overlayRef) {
- this.closePanel();
- this._overlayRef.dispose();
- this._overlayRef = null;
- }
- };
- /**
- * @private
- * @param {?} value
- * @return {?}
- */
- MatAutocompleteTrigger.prototype._setTriggerValue = /**
- * @private
- * @param {?} value
- * @return {?}
- */
- function (value) {
- /** @type {?} */
- var toDisplay = this.autocomplete && this.autocomplete.displayWith ?
- this.autocomplete.displayWith(value) :
- value;
- // Simply falling back to an empty string if the display value is falsy does not work properly.
- // The display value can also be the number zero and shouldn't fall back to an empty string.
- /** @type {?} */
- var inputValue = toDisplay != null ? toDisplay : '';
- // If it's used within a `MatFormField`, we should set it through the property so it can go
- // through change detection.
- if (this._formField) {
- this._formField._control.value = inputValue;
- }
- else {
- this._element.nativeElement.value = inputValue;
- }
- this._previousValue = inputValue;
- };
- /**
- * 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.
- */
- /**
- * 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
- * @param {?} event
- * @return {?}
- */
- MatAutocompleteTrigger.prototype._setValueAndClose = /**
- * 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
- * @param {?} event
- * @return {?}
- */
- function (event) {
- if (event && event.source) {
- this._clearPreviousSelectedOption(event.source);
- this._setTriggerValue(event.source.value);
- this._onChange(event.source.value);
- this._element.nativeElement.focus();
- this.autocomplete._emitSelectEvent(event.source);
- }
- this.closePanel();
- };
- /**
- * Clear any previous selected option and emit a selection change event for this option
- */
- /**
- * Clear any previous selected option and emit a selection change event for this option
- * @private
- * @param {?} skip
- * @return {?}
- */
- MatAutocompleteTrigger.prototype._clearPreviousSelectedOption = /**
- * Clear any previous selected option and emit a selection change event for this option
- * @private
- * @param {?} skip
- * @return {?}
- */
- function (skip) {
- this.autocomplete.options.forEach((/**
- * @param {?} option
- * @return {?}
- */
- function (option) {
- if (option != skip && option.selected) {
- option.deselect();
- }
- }));
- };
- /**
- * @private
- * @return {?}
- */
- MatAutocompleteTrigger.prototype._attachOverlay = /**
- * @private
- * @return {?}
- */
- function () {
- var _this = this;
- if (!this.autocomplete) {
- throw getMatAutocompleteMissingPanelError();
- }
- /** @type {?} */
- var overlayRef = this._overlayRef;
- if (!overlayRef) {
- this._portal = new portal.TemplatePortal(this.autocomplete.template, this._viewContainerRef);
- overlayRef = this._overlay.create(this._getOverlayConfig());
- this._overlayRef = overlayRef;
- // Use the `keydownEvents` in order to take advantage of
- // the overlay event targeting provided by the CDK overlay.
- overlayRef.keydownEvents().subscribe((/**
- * @param {?} event
- * @return {?}
- */
- function (event) {
- // Close when pressing ESCAPE or ALT + UP_ARROW, based on the a11y guidelines.
- // See: https://www.w3.org/TR/wai-aria-practices-1.1/#textbox-keyboard-interaction
- if (event.keyCode === keycodes.ESCAPE || (event.keyCode === keycodes.UP_ARROW && event.altKey)) {
- _this._resetActiveItem();
- _this._closeKeyEventStream.next();
- // We need to stop propagation, otherwise the event will eventually
- // reach the input itself and cause the overlay to be reopened.
- event.stopPropagation();
- event.preventDefault();
- }
- }));
- if (this._viewportRuler) {
- this._viewportSubscription = this._viewportRuler.change().subscribe((/**
- * @return {?}
- */
- function () {
- if (_this.panelOpen && overlayRef) {
- overlayRef.updateSize({ width: _this._getPanelWidth() });
- }
- }));
- }
- }
- else {
- // Update the trigger, panel width and direction, in case anything has changed.
- this._positionStrategy.setOrigin(this._getConnectedElement());
- overlayRef.updateSize({ width: this._getPanelWidth() });
- }
- if (overlayRef && !overlayRef.hasAttached()) {
- overlayRef.attach(this._portal);
- this._closingActionsSubscription = this._subscribeToClosingActions();
- }
- /** @type {?} */
- var wasOpen = this.panelOpen;
- this.autocomplete._setVisibility();
- this.autocomplete._isOpen = this._overlayAttached = true;
- // We need to do an extra `panelOpen` check in here, because the
- // autocomplete won't be shown if there are no options.
- if (this.panelOpen && wasOpen !== this.panelOpen) {
- this.autocomplete.opened.emit();
- }
- };
- /**
- * @private
- * @return {?}
- */
- MatAutocompleteTrigger.prototype._getOverlayConfig = /**
- * @private
- * @return {?}
- */
- function () {
- return new overlay.OverlayConfig({
- positionStrategy: this._getOverlayPosition(),
- scrollStrategy: this._scrollStrategy(),
- width: this._getPanelWidth(),
- direction: this._dir
- });
- };
- /**
- * @private
- * @return {?}
- */
- MatAutocompleteTrigger.prototype._getOverlayPosition = /**
- * @private
- * @return {?}
- */
- function () {
- /** @type {?} */
- var strategy = this._overlay.position()
- .flexibleConnectedTo(this._getConnectedElement())
- .withFlexibleDimensions(false)
- .withPush(false);
- this._setStrategyPositions(strategy);
- this._positionStrategy = strategy;
- return strategy;
- };
- /** Sets the positions on a position strategy based on the directive's input state. */
- /**
- * Sets the positions on a position strategy based on the directive's input state.
- * @private
- * @param {?} positionStrategy
- * @return {?}
- */
- MatAutocompleteTrigger.prototype._setStrategyPositions = /**
- * Sets the positions on a position strategy based on the directive's input state.
- * @private
- * @param {?} positionStrategy
- * @return {?}
- */
- function (positionStrategy) {
- /** @type {?} */
- var belowPosition = {
- originX: 'start',
- originY: 'bottom',
- overlayX: 'start',
- overlayY: 'top'
- };
- /** @type {?} */
- var abovePosition = {
- originX: 'start',
- originY: 'top',
- overlayX: 'start',
- overlayY: 'bottom',
- // The overlay edge connected to the trigger should have squared corners, while
- // the opposite end has rounded corners. We apply a CSS class to swap the
- // border-radius based on the overlay position.
- panelClass: 'mat-autocomplete-panel-above'
- };
- /** @type {?} */
- var positions;
- if (this.position === 'above') {
- positions = [abovePosition];
- }
- else if (this.position === 'below') {
- positions = [belowPosition];
- }
- else {
- positions = [belowPosition, abovePosition];
- }
- positionStrategy.withPositions(positions);
- };
- /**
- * @private
- * @return {?}
- */
- MatAutocompleteTrigger.prototype._getConnectedElement = /**
- * @private
- * @return {?}
- */
- function () {
- if (this.connectedTo) {
- return this.connectedTo.elementRef;
- }
- return this._formField ? this._formField.getConnectedOverlayOrigin() : this._element;
- };
- /**
- * @private
- * @return {?}
- */
- MatAutocompleteTrigger.prototype._getPanelWidth = /**
- * @private
- * @return {?}
- */
- function () {
- return this.autocomplete.panelWidth || this._getHostWidth();
- };
- /** Returns the width of the input element, so the panel width can match it. */
- /**
- * Returns the width of the input element, so the panel width can match it.
- * @private
- * @return {?}
- */
- MatAutocompleteTrigger.prototype._getHostWidth = /**
- * Returns the width of the input element, so the panel width can match it.
- * @private
- * @return {?}
- */
- function () {
- return this._getConnectedElement().nativeElement.getBoundingClientRect().width;
- };
- /**
- * Resets the active item to -1 so arrow events will activate the
- * correct options, or to 0 if the consumer opted into it.
- */
- /**
- * Resets the active item to -1 so arrow events will activate the
- * correct options, or to 0 if the consumer opted into it.
- * @private
- * @return {?}
- */
- MatAutocompleteTrigger.prototype._resetActiveItem = /**
- * Resets the active item to -1 so arrow events will activate the
- * correct options, or to 0 if the consumer opted into it.
- * @private
- * @return {?}
- */
- function () {
- this.autocomplete._keyManager.setActiveItem(this.autocomplete.autoActiveFirstOption ? 0 : -1);
- };
- /** Determines whether the panel can be opened. */
- /**
- * Determines whether the panel can be opened.
- * @private
- * @return {?}
- */
- MatAutocompleteTrigger.prototype._canOpen = /**
- * Determines whether the panel can be opened.
- * @private
- * @return {?}
- */
- function () {
- /** @type {?} */
- var element = this._element.nativeElement;
- return !element.readOnly && !element.disabled && !this._autocompleteDisabled;
- };
- MatAutocompleteTrigger.decorators = [
- { type: core.Directive, args: [{
- selector: "input[matAutocomplete], textarea[matAutocomplete]",
- host: {
- '[attr.autocomplete]': 'autocompleteAttribute',
- '[attr.role]': 'autocompleteDisabled ? null : "combobox"',
- '[attr.aria-autocomplete]': 'autocompleteDisabled ? null : "list"',
- '[attr.aria-activedescendant]': '(panelOpen && activeOption) ? activeOption.id : null',
- '[attr.aria-expanded]': 'autocompleteDisabled ? null : panelOpen.toString()',
- '[attr.aria-owns]': '(autocompleteDisabled || !panelOpen) ? null : autocomplete?.id',
- '[attr.aria-haspopup]': '!autocompleteDisabled',
- // Note: we use `focusin`, as opposed to `focus`, in order to open the panel
- // a little earlier. This avoids issues where IE delays the focusing of the input.
- '(focusin)': '_handleFocus()',
- '(blur)': '_onTouched()',
- '(input)': '_handleInput($event)',
- '(keydown)': '_handleKeydown($event)',
- },
- exportAs: 'matAutocompleteTrigger',
- providers: [MAT_AUTOCOMPLETE_VALUE_ACCESSOR]
- },] },
- ];
- /** @nocollapse */
- MatAutocompleteTrigger.ctorParameters = function () { return [
- { type: core.ElementRef },
- { type: overlay.Overlay },
- { type: core.ViewContainerRef },
- { type: core.NgZone },
- { type: core.ChangeDetectorRef },
- { type: undefined, decorators: [{ type: core.Inject, args: [MAT_AUTOCOMPLETE_SCROLL_STRATEGY,] }] },
- { type: bidi.Directionality, decorators: [{ type: core.Optional }] },
- { type: formField.MatFormField, decorators: [{ type: core.Optional }, { type: core.Host }] },
- { type: undefined, decorators: [{ type: core.Optional }, { type: core.Inject, args: [common.DOCUMENT,] }] },
- { type: scrolling.ViewportRuler }
- ]; };
- MatAutocompleteTrigger.propDecorators = {
- autocomplete: [{ type: core.Input, args: ['matAutocomplete',] }],
- position: [{ type: core.Input, args: ['matAutocompletePosition',] }],
- connectedTo: [{ type: core.Input, args: ['matAutocompleteConnectedTo',] }],
- autocompleteAttribute: [{ type: core.Input, args: ['autocomplete',] }],
- autocompleteDisabled: [{ type: core.Input, args: ['matAutocompleteDisabled',] }]
- };
- return MatAutocompleteTrigger;
- }());
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- var MatAutocompleteModule = /** @class */ (function () {
- function MatAutocompleteModule() {
- }
- MatAutocompleteModule.decorators = [
- { type: core.NgModule, args: [{
- imports: [core$1.MatOptionModule, overlay.OverlayModule, core$1.MatCommonModule, common.CommonModule],
- exports: [
- MatAutocomplete,
- core$1.MatOptionModule,
- MatAutocompleteTrigger,
- MatAutocompleteOrigin,
- core$1.MatCommonModule
- ],
- declarations: [MatAutocomplete, MatAutocompleteTrigger, MatAutocompleteOrigin],
- providers: [MAT_AUTOCOMPLETE_SCROLL_STRATEGY_FACTORY_PROVIDER],
- },] },
- ];
- return MatAutocompleteModule;
- }());
- exports.MAT_AUTOCOMPLETE_DEFAULT_OPTIONS_FACTORY = MAT_AUTOCOMPLETE_DEFAULT_OPTIONS_FACTORY;
- exports.MatAutocompleteSelectedEvent = MatAutocompleteSelectedEvent;
- exports.MAT_AUTOCOMPLETE_DEFAULT_OPTIONS = MAT_AUTOCOMPLETE_DEFAULT_OPTIONS;
- exports.MatAutocomplete = MatAutocomplete;
- exports.MatAutocompleteModule = MatAutocompleteModule;
- exports.MAT_AUTOCOMPLETE_SCROLL_STRATEGY_FACTORY = MAT_AUTOCOMPLETE_SCROLL_STRATEGY_FACTORY;
- exports.getMatAutocompleteMissingPanelError = getMatAutocompleteMissingPanelError;
- exports.AUTOCOMPLETE_OPTION_HEIGHT = AUTOCOMPLETE_OPTION_HEIGHT;
- exports.AUTOCOMPLETE_PANEL_HEIGHT = AUTOCOMPLETE_PANEL_HEIGHT;
- exports.MAT_AUTOCOMPLETE_SCROLL_STRATEGY = MAT_AUTOCOMPLETE_SCROLL_STRATEGY;
- exports.MAT_AUTOCOMPLETE_SCROLL_STRATEGY_FACTORY_PROVIDER = MAT_AUTOCOMPLETE_SCROLL_STRATEGY_FACTORY_PROVIDER;
- exports.MAT_AUTOCOMPLETE_VALUE_ACCESSOR = MAT_AUTOCOMPLETE_VALUE_ACCESSOR;
- exports.MatAutocompleteTrigger = MatAutocompleteTrigger;
- exports.MatAutocompleteOrigin = MatAutocompleteOrigin;
- Object.defineProperty(exports, '__esModule', { value: true });
- })));
- //# sourceMappingURL=material-autocomplete.umd.js.map
|