UNPKG

ng-zorro-antd

Version:

An enterprise-class UI components based on Ant Design and Angular

1,083 lines (1,074 loc) 34 kB
import { OverlayConfig, ConnectionPositionPair, Overlay, OverlayModule } from '@angular/cdk/overlay'; import { DOCUMENT, CommonModule } from '@angular/common'; import { Component, ChangeDetectionStrategy, ViewEncapsulation, Input, EventEmitter, ChangeDetectorRef, ElementRef, Output, NgZone, Host, Optional, ContentChildren, ViewChildren, ViewChild, TemplateRef, forwardRef, Directive, ViewContainerRef, Inject, NgModule } from '@angular/core'; import { NG_VALUE_ACCESSOR, FormsModule } from '@angular/forms'; import { scrollIntoView, InputBoolean, slideMotion, NzNoAnimationDirective, NzAddOnModule, NzNoAnimationModule } from 'ng-zorro-antd/core'; import { __decorate, __metadata } from 'tslib'; import { UP_ARROW, DOWN_ARROW, ESCAPE, TAB, ENTER } from '@angular/cdk/keycodes'; import { TemplatePortal } from '@angular/cdk/portal'; import { Subscription, defer, merge, fromEvent } from 'rxjs'; import { take, switchMap, filter, delay, map, distinct } from 'rxjs/operators'; /** * @fileoverview added by tsickle * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ class NzAutocompleteOptgroupComponent { constructor() { } } NzAutocompleteOptgroupComponent.decorators = [ { type: Component, args: [{ selector: 'nz-auto-optgroup', exportAs: 'nzAutoOptgroup', preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, template: "<div class=\"ant-select-dropdown-menu-item-group-title\">\n <ng-container *nzStringTemplateOutlet=\"nzLabel\">{{nzLabel}}</ng-container>\n</div>\n<ul class=\"ant-select-dropdown-menu-item-group-list\">\n <ng-content select=\"nz-auto-option\"></ng-content>\n</ul>\n", host: { role: 'group', class: 'ant-select-dropdown-menu-item-group' } }] } ]; /** @nocollapse */ NzAutocompleteOptgroupComponent.ctorParameters = () => []; NzAutocompleteOptgroupComponent.propDecorators = { nzLabel: [{ type: Input }] }; if (false) { /** @type {?} */ NzAutocompleteOptgroupComponent.prototype.nzLabel; } /** * @fileoverview added by tsickle * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ class NzOptionSelectionChange { /** * @param {?} source * @param {?=} isUserInput */ constructor(source, isUserInput = false) { this.source = source; this.isUserInput = isUserInput; } } if (false) { /** @type {?} */ NzOptionSelectionChange.prototype.source; /** @type {?} */ NzOptionSelectionChange.prototype.isUserInput; } class NzAutocompleteOptionComponent { /** * @param {?} changeDetectorRef * @param {?} element */ constructor(changeDetectorRef, element) { this.changeDetectorRef = changeDetectorRef; this.element = element; this.nzDisabled = false; this.selectionChange = new EventEmitter(); this.active = false; this.selected = false; } /** * @return {?} */ select() { this.selected = true; this.changeDetectorRef.markForCheck(); this.emitSelectionChangeEvent(); } /** * @return {?} */ deselect() { this.selected = false; this.changeDetectorRef.markForCheck(); this.emitSelectionChangeEvent(); } /** * Git display label * @return {?} */ getLabel() { return this.nzLabel || this.nzValue.toString(); } /** * Set active (only styles) * @return {?} */ setActiveStyles() { if (!this.active) { this.active = true; this.changeDetectorRef.markForCheck(); } } /** * Unset active (only styles) * @return {?} */ setInactiveStyles() { if (this.active) { this.active = false; this.changeDetectorRef.markForCheck(); } } /** * @return {?} */ scrollIntoViewIfNeeded() { scrollIntoView(this.element.nativeElement); } /** * @return {?} */ selectViaInteraction() { if (!this.nzDisabled) { this.selected = !this.selected; if (this.selected) { this.setActiveStyles(); } else { this.setInactiveStyles(); } this.emitSelectionChangeEvent(true); this.changeDetectorRef.markForCheck(); } } /** * @private * @param {?=} isUserInput * @return {?} */ emitSelectionChangeEvent(isUserInput = false) { this.selectionChange.emit(new NzOptionSelectionChange(this, isUserInput)); } } NzAutocompleteOptionComponent.decorators = [ { type: Component, args: [{ selector: 'nz-auto-option', exportAs: 'nzAutoOption', preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, template: "<ng-content></ng-content>", host: { role: 'menuitem', class: 'ant-select-dropdown-menu-item', '[class.ant-select-dropdown-menu-item-selected]': 'selected', '[class.ant-select-dropdown-menu-item-active]': 'active', '[class.ant-select-dropdown-menu-item-disabled]': 'nzDisabled', '[attr.aria-selected]': 'selected.toString()', '[attr.aria-disabled]': 'nzDisabled.toString()', '(click)': 'selectViaInteraction()', '(mousedown)': '$event.preventDefault()' } }] } ]; /** @nocollapse */ NzAutocompleteOptionComponent.ctorParameters = () => [ { type: ChangeDetectorRef }, { type: ElementRef } ]; NzAutocompleteOptionComponent.propDecorators = { nzValue: [{ type: Input }], nzLabel: [{ type: Input }], nzDisabled: [{ type: Input }], selectionChange: [{ type: Output }] }; __decorate([ InputBoolean(), __metadata("design:type", Object) ], NzAutocompleteOptionComponent.prototype, "nzDisabled", void 0); if (false) { /** @type {?} */ NzAutocompleteOptionComponent.prototype.nzValue; /** @type {?} */ NzAutocompleteOptionComponent.prototype.nzLabel; /** @type {?} */ NzAutocompleteOptionComponent.prototype.nzDisabled; /** @type {?} */ NzAutocompleteOptionComponent.prototype.selectionChange; /** @type {?} */ NzAutocompleteOptionComponent.prototype.active; /** @type {?} */ NzAutocompleteOptionComponent.prototype.selected; /** * @type {?} * @private */ NzAutocompleteOptionComponent.prototype.changeDetectorRef; /** * @type {?} * @private */ NzAutocompleteOptionComponent.prototype.element; } /** * @fileoverview added by tsickle * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @record */ function AutocompleteDataSourceItem() { } if (false) { /** @type {?} */ AutocompleteDataSourceItem.prototype.value; /** @type {?} */ AutocompleteDataSourceItem.prototype.label; } class NzAutocompleteComponent { /** * @param {?} changeDetectorRef * @param {?} ngZone * @param {?=} noAnimation */ constructor(changeDetectorRef, ngZone, noAnimation) { this.changeDetectorRef = changeDetectorRef; this.ngZone = ngZone; this.noAnimation = noAnimation; this.nzOverlayClassName = ''; this.nzOverlayStyle = {}; this.nzDefaultActiveFirstOption = true; this.nzBackfill = false; this.selectionChange = new EventEmitter(); this.showPanel = false; this.isOpen = false; this.dropDownPosition = 'bottom'; this.activeItemIndex = -1; this.selectionChangeSubscription = Subscription.EMPTY; this.dataSourceChangeSubscription = Subscription.EMPTY; /** * Options changes listener */ this.optionSelectionChanges = defer((/** * @return {?} */ () => { if (this.options) { return merge(...this.options.map((/** * @param {?} option * @return {?} */ option => option.selectionChange))); } return this.ngZone.onStable.asObservable().pipe(take(1), switchMap((/** * @return {?} */ () => this.optionSelectionChanges))); })); } /** * Options accessor, its source may be content or dataSource * @return {?} */ get options() { // first dataSource if (this.nzDataSource) { return this.fromDataSourceOptions; } else { return this.fromContentOptions; } } /** * @return {?} */ ngAfterViewInit() { this.optionsInit(); } /** * @return {?} */ ngOnDestroy() { this.dataSourceChangeSubscription.unsubscribe(); this.selectionChangeSubscription.unsubscribe(); } /** * @return {?} */ setVisibility() { this.showPanel = !!this.options.length; this.changeDetectorRef.markForCheck(); } /** * @param {?} index * @return {?} */ setActiveItem(index) { /** @type {?} */ const activeItem = this.options.toArray()[index]; if (activeItem && !activeItem.active) { this.activeItem = activeItem; this.activeItemIndex = index; this.clearSelectedOptions(this.activeItem); this.activeItem.setActiveStyles(); this.changeDetectorRef.markForCheck(); } } /** * @return {?} */ setNextItemActive() { /** @type {?} */ const nextIndex = this.activeItemIndex + 1 <= this.options.length - 1 ? this.activeItemIndex + 1 : 0; this.setActiveItem(nextIndex); } /** * @return {?} */ setPreviousItemActive() { /** @type {?} */ const previousIndex = this.activeItemIndex - 1 < 0 ? this.options.length - 1 : this.activeItemIndex - 1; this.setActiveItem(previousIndex); } /** * @param {?=} option * @return {?} */ getOptionIndex(option) { return (/** @type {?} */ (this.options.reduce((/** * @param {?} result * @param {?} current * @param {?} index * @return {?} */ (result, current, index) => { return result === -1 ? (option === current ? index : -1) : result; }), -1))); } /** * @private * @return {?} */ optionsInit() { this.setVisibility(); this.subscribeOptionChanges(); /** @type {?} */ const changes = this.nzDataSource ? this.fromDataSourceOptions.changes : this.fromContentOptions.changes; // async this.dataSourceChangeSubscription = changes.subscribe((/** * @param {?} e * @return {?} */ e => { if (!e.dirty && this.isOpen) { setTimeout((/** * @return {?} */ () => this.setVisibility())); } this.subscribeOptionChanges(); })); } /** * Clear the status of options * @private * @param {?=} skip * @param {?=} deselect * @return {?} */ clearSelectedOptions(skip, deselect = false) { this.options.forEach((/** * @param {?} option * @return {?} */ option => { if (option !== skip) { if (deselect) { option.deselect(); } option.setInactiveStyles(); } })); } /** * @private * @return {?} */ subscribeOptionChanges() { this.selectionChangeSubscription.unsubscribe(); this.selectionChangeSubscription = this.optionSelectionChanges .pipe(filter((/** * @param {?} event * @return {?} */ (event) => event.isUserInput))) .subscribe((/** * @param {?} event * @return {?} */ (event) => { event.source.select(); event.source.setActiveStyles(); this.activeItem = event.source; this.activeItemIndex = this.getOptionIndex(this.activeItem); this.clearSelectedOptions(event.source, true); this.selectionChange.emit(event.source); })); } } NzAutocompleteComponent.decorators = [ { type: Component, args: [{ selector: 'nz-autocomplete', exportAs: 'nzAutocomplete', preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, template: "<ng-template>\n <div class=\"ant-select-dropdown ant-select-dropdown--single ant-select-dropdown-placement-bottomLeft\"\n #panel\n [@.disabled]=\"noAnimation?.nzNoAnimation\"\n [nzNoAnimation]=\"noAnimation?.nzNoAnimation\"\n [@slideMotion]=\"dropDownPosition\"\n [class.ant-select-dropdown-hidden]=\"!showPanel\" [ngClass]=\"nzOverlayClassName\" [ngStyle]=\"nzOverlayStyle\">\n <div style=\"overflow: auto;\">\n <ul class=\"ant-select-dropdown-menu ant-select-dropdown-menu-root ant-select-dropdown-menu-vertical\"\n role=\"menu\"\n aria-activedescendant>\n <ng-template *ngTemplateOutlet=\"nzDataSource ? optionsTemplate : contentTemplate\"></ng-template>\n </ul>\n </div>\n </div>\n <ng-template #contentTemplate>\n <ng-content></ng-content>\n </ng-template>\n <ng-template #optionsTemplate>\n <nz-auto-option *ngFor=\"let option of nzDataSource\" [nzValue]=\"option\">{{option}}</nz-auto-option>\n </ng-template>\n</ng-template>", animations: [slideMotion], styles: [` .ant-select-dropdown { top: 100%; left: 0; position: relative; width: 100%; margin-top: 4px; margin-bottom: 4px; } `] }] } ]; /** @nocollapse */ NzAutocompleteComponent.ctorParameters = () => [ { type: ChangeDetectorRef }, { type: NgZone }, { type: NzNoAnimationDirective, decorators: [{ type: Host }, { type: Optional }] } ]; NzAutocompleteComponent.propDecorators = { nzWidth: [{ type: Input }], nzOverlayClassName: [{ type: Input }], nzOverlayStyle: [{ type: Input }], nzDefaultActiveFirstOption: [{ type: Input }], nzBackfill: [{ type: Input }], nzDataSource: [{ type: Input }], selectionChange: [{ type: Output }], fromContentOptions: [{ type: ContentChildren, args: [NzAutocompleteOptionComponent, { descendants: true },] }], fromDataSourceOptions: [{ type: ViewChildren, args: [NzAutocompleteOptionComponent,] }], template: [{ type: ViewChild, args: [TemplateRef, { static: false },] }], panel: [{ type: ViewChild, args: ['panel', { static: false },] }], content: [{ type: ViewChild, args: ['content', { static: false },] }] }; __decorate([ InputBoolean(), __metadata("design:type", Object) ], NzAutocompleteComponent.prototype, "nzDefaultActiveFirstOption", void 0); __decorate([ InputBoolean(), __metadata("design:type", Object) ], NzAutocompleteComponent.prototype, "nzBackfill", void 0); if (false) { /** @type {?} */ NzAutocompleteComponent.prototype.nzWidth; /** @type {?} */ NzAutocompleteComponent.prototype.nzOverlayClassName; /** @type {?} */ NzAutocompleteComponent.prototype.nzOverlayStyle; /** @type {?} */ NzAutocompleteComponent.prototype.nzDefaultActiveFirstOption; /** @type {?} */ NzAutocompleteComponent.prototype.nzBackfill; /** @type {?} */ NzAutocompleteComponent.prototype.nzDataSource; /** @type {?} */ NzAutocompleteComponent.prototype.selectionChange; /** @type {?} */ NzAutocompleteComponent.prototype.showPanel; /** @type {?} */ NzAutocompleteComponent.prototype.isOpen; /** @type {?} */ NzAutocompleteComponent.prototype.activeItem; /** @type {?} */ NzAutocompleteComponent.prototype.dropDownPosition; /** * Provided by content * @type {?} */ NzAutocompleteComponent.prototype.fromContentOptions; /** * Provided by dataSource * @type {?} */ NzAutocompleteComponent.prototype.fromDataSourceOptions; /** * cdk-overlay * @type {?} */ NzAutocompleteComponent.prototype.template; /** @type {?} */ NzAutocompleteComponent.prototype.panel; /** @type {?} */ NzAutocompleteComponent.prototype.content; /** * @type {?} * @private */ NzAutocompleteComponent.prototype.activeItemIndex; /** * @type {?} * @private */ NzAutocompleteComponent.prototype.selectionChangeSubscription; /** * @type {?} * @private */ NzAutocompleteComponent.prototype.dataSourceChangeSubscription; /** * Options changes listener * @type {?} */ NzAutocompleteComponent.prototype.optionSelectionChanges; /** * @type {?} * @private */ NzAutocompleteComponent.prototype.changeDetectorRef; /** * @type {?} * @private */ NzAutocompleteComponent.prototype.ngZone; /** @type {?} */ NzAutocompleteComponent.prototype.noAnimation; } /** * @fileoverview added by tsickle * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** @type {?} */ const NZ_AUTOCOMPLETE_VALUE_ACCESSOR = { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef((/** * @return {?} */ () => NzAutocompleteTriggerDirective)), multi: true }; /** * @return {?} */ function getNzAutocompleteMissingPanelError() { return Error('Attempting to open an undefined instance of `nz-autocomplete`. ' + 'Make sure that the id passed to the `nzAutocomplete` is correct and that ' + "you're attempting to open it after the ngAfterContentInit hook."); } class NzAutocompleteTriggerDirective { /** * @param {?} elementRef * @param {?} _overlay * @param {?} viewContainerRef * @param {?} document */ constructor(elementRef, _overlay, viewContainerRef, document) { this.elementRef = elementRef; this._overlay = _overlay; this.viewContainerRef = viewContainerRef; this.document = document; // tslint:disable-next-line:no-any this._onChange = (/** * @return {?} */ () => { }); this._onTouched = (/** * @return {?} */ () => { }); this.panelOpen = false; } /** * Current active option * @return {?} */ get activeOption() { if (this.nzAutocomplete && this.nzAutocomplete.options.length) { return this.nzAutocomplete.activeItem; } } /** * @return {?} */ ngOnDestroy() { this.destroyPanel(); } // tslint:disable-next-line:no-any /** * @param {?} value * @return {?} */ writeValue(value) { this.setTriggerValue(value); } /** * @param {?} fn * @return {?} */ registerOnChange(fn) { this._onChange = fn; } /** * @param {?} fn * @return {?} */ registerOnTouched(fn) { this._onTouched = fn; } /** * @param {?} isDisabled * @return {?} */ setDisabledState(isDisabled) { /** @type {?} */ const element = this.elementRef.nativeElement; element.disabled = isDisabled; this.closePanel(); } /** * @return {?} */ openPanel() { this.previousValue = this.elementRef.nativeElement.value; this.attachOverlay(); } /** * @return {?} */ closePanel() { if (this.panelOpen) { this.nzAutocomplete.isOpen = this.panelOpen = false; if (this.overlayRef && this.overlayRef.hasAttached()) { this.selectionChangeSubscription.unsubscribe(); this.overlayBackdropClickSubscription.unsubscribe(); this.overlayPositionChangeSubscription.unsubscribe(); this.optionsChangeSubscription.unsubscribe(); this.overlayRef.detach(); this.overlayRef = null; this.portal = null; } } } /** * @param {?} event * @return {?} */ handleKeydown(event) { /** @type {?} */ const keyCode = event.keyCode; /** @type {?} */ const isArrowKey = keyCode === UP_ARROW || keyCode === DOWN_ARROW; if (keyCode === ESCAPE) { event.preventDefault(); } if (this.panelOpen && (keyCode === ESCAPE || keyCode === TAB)) { // Reset value when tab / ESC close if (this.activeOption && this.activeOption.getLabel() !== this.previousValue) { this.setTriggerValue(this.previousValue); } this.closePanel(); } else if (this.panelOpen && keyCode === ENTER) { if (this.nzAutocomplete.showPanel && this.activeOption) { event.preventDefault(); this.activeOption.selectViaInteraction(); } } else if (this.panelOpen && isArrowKey && this.nzAutocomplete.showPanel) { event.stopPropagation(); event.preventDefault(); if (keyCode === UP_ARROW) { this.nzAutocomplete.setPreviousItemActive(); } else { this.nzAutocomplete.setNextItemActive(); } if (this.activeOption) { this.activeOption.scrollIntoViewIfNeeded(); } this.doBackfill(); } } /** * @param {?} event * @return {?} */ handleInput(event) { /** @type {?} */ const target = (/** @type {?} */ (event.target)); /** @type {?} */ const document = (/** @type {?} */ (this.document)); /** @type {?} */ let value = target.value; if (target.type === 'number') { value = value === '' ? null : parseFloat(value); } if (this.previousValue !== value) { this.previousValue = value; this._onChange(value); if (this.canOpen() && document.activeElement === event.target) { this.openPanel(); } } } /** * @return {?} */ handleFocus() { if (this.canOpen()) { this.openPanel(); } } /** * @return {?} */ handleBlur() { this.closePanel(); this._onTouched(); } /** * Subscription data source changes event * @private * @return {?} */ subscribeOptionsChange() { return this.nzAutocomplete.options.changes.pipe(delay(0)).subscribe((/** * @return {?} */ () => { this.resetActiveItem(); })); } /** * Subscription option changes event and set the value * @private * @return {?} */ subscribeSelectionChange() { return this.nzAutocomplete.selectionChange.subscribe((/** * @param {?} option * @return {?} */ (option) => { this.setValueAndClose(option); })); } /** * Subscription external click and close panel * @private * @return {?} */ subscribeOverlayBackdropClick() { return merge(fromEvent(this.document, 'click'), fromEvent(this.document, 'touchend')).subscribe((/** * @param {?} event * @return {?} */ (event) => { /** @type {?} */ const clickTarget = (/** @type {?} */ (event.target)); // Make sure is not self if (clickTarget !== this.elementRef.nativeElement && !(/** @type {?} */ (this.overlayRef)).overlayElement.contains(clickTarget) && this.panelOpen) { this.closePanel(); } })); } /** * Subscription overlay position changes and reset dropdown position * @private * @return {?} */ subscribeOverlayPositionChange() { return this.positionStrategy.positionChanges .pipe(map((/** * @param {?} position * @return {?} */ (position) => position.connectionPair.originY)), distinct()) .subscribe((/** * @param {?} position * @return {?} */ (position) => { this.nzAutocomplete.dropDownPosition = position; })); } /** * @private * @return {?} */ attachOverlay() { if (!this.nzAutocomplete) { throw getNzAutocompleteMissingPanelError(); } if (!this.portal) { this.portal = new TemplatePortal(this.nzAutocomplete.template, this.viewContainerRef); } if (!this.overlayRef) { this.overlayRef = this._overlay.create(this.getOverlayConfig()); } if (this.overlayRef && !this.overlayRef.hasAttached()) { this.overlayRef.attach(this.portal); this.overlayPositionChangeSubscription = this.subscribeOverlayPositionChange(); this.selectionChangeSubscription = this.subscribeSelectionChange(); this.overlayBackdropClickSubscription = this.subscribeOverlayBackdropClick(); this.optionsChangeSubscription = this.subscribeOptionsChange(); } this.nzAutocomplete.isOpen = this.panelOpen = true; this.nzAutocomplete.setVisibility(); this.overlayRef.updateSize({ width: this.nzAutocomplete.nzWidth || this.getHostWidth() }); setTimeout((/** * @return {?} */ () => { if (this.overlayRef) { this.overlayRef.updatePosition(); } }), 150); this.resetActiveItem(); if (this.activeOption) { this.activeOption.scrollIntoViewIfNeeded(); } } /** * @private * @return {?} */ destroyPanel() { if (this.overlayRef) { this.closePanel(); } } /** * @private * @return {?} */ getOverlayConfig() { return new OverlayConfig({ positionStrategy: this.getOverlayPosition(), scrollStrategy: this._overlay.scrollStrategies.reposition(), // default host element width width: this.nzAutocomplete.nzWidth || this.getHostWidth() }); } /** * @private * @return {?} */ getConnectedElement() { return this.elementRef; } /** * @private * @return {?} */ getHostWidth() { return this.getConnectedElement().nativeElement.getBoundingClientRect().width; } /** * @private * @return {?} */ getOverlayPosition() { /** @type {?} */ const positions = [ new ConnectionPositionPair({ originX: 'start', originY: 'bottom' }, { overlayX: 'start', overlayY: 'top' }), new ConnectionPositionPair({ originX: 'start', originY: 'top' }, { overlayX: 'start', overlayY: 'bottom' }) ]; this.positionStrategy = this._overlay .position() .flexibleConnectedTo(this.getConnectedElement()) .withPositions(positions) .withFlexibleDimensions(false) .withPush(false); return this.positionStrategy; } /** * @private * @return {?} */ resetActiveItem() { /** @type {?} */ const index = this.nzAutocomplete.getOptionIndex(this.nzAutocomplete.activeItem); if (this.nzAutocomplete.activeItem && index !== -1) { this.nzAutocomplete.setActiveItem(index); } else { this.nzAutocomplete.setActiveItem(this.nzAutocomplete.nzDefaultActiveFirstOption ? 0 : -1); } } /** * @private * @param {?} option * @return {?} */ setValueAndClose(option) { /** @type {?} */ const value = option.nzValue; this.setTriggerValue(option.getLabel()); this._onChange(value); this.elementRef.nativeElement.focus(); this.closePanel(); } /** * @private * @param {?} value * @return {?} */ setTriggerValue(value) { this.elementRef.nativeElement.value = value || ''; if (!this.nzAutocomplete.nzBackfill) { this.previousValue = value; } } /** * @private * @return {?} */ doBackfill() { if (this.nzAutocomplete.nzBackfill && this.nzAutocomplete.activeItem) { this.setTriggerValue(this.nzAutocomplete.activeItem.getLabel()); } } /** * @private * @return {?} */ canOpen() { /** @type {?} */ const element = this.elementRef.nativeElement; return !element.readOnly && !element.disabled; } } NzAutocompleteTriggerDirective.decorators = [ { type: Directive, args: [{ selector: `input[nzAutocomplete], textarea[nzAutocomplete]`, exportAs: 'nzAutocompleteTrigger', providers: [NZ_AUTOCOMPLETE_VALUE_ACCESSOR], host: { autocomplete: 'off', 'aria-autocomplete': 'list', '(focusin)': 'handleFocus()', '(blur)': 'handleBlur()', '(input)': 'handleInput($event)', '(keydown)': 'handleKeydown($event)' } },] } ]; /** @nocollapse */ NzAutocompleteTriggerDirective.ctorParameters = () => [ { type: ElementRef }, { type: Overlay }, { type: ViewContainerRef }, { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [DOCUMENT,] }] } ]; NzAutocompleteTriggerDirective.propDecorators = { nzAutocomplete: [{ type: Input }] }; if (false) { /** * Bind nzAutocomplete component * @type {?} */ NzAutocompleteTriggerDirective.prototype.nzAutocomplete; /** @type {?} */ NzAutocompleteTriggerDirective.prototype._onChange; /** @type {?} */ NzAutocompleteTriggerDirective.prototype._onTouched; /** @type {?} */ NzAutocompleteTriggerDirective.prototype.panelOpen; /** * @type {?} * @private */ NzAutocompleteTriggerDirective.prototype.overlayRef; /** * @type {?} * @private */ NzAutocompleteTriggerDirective.prototype.portal; /** * @type {?} * @private */ NzAutocompleteTriggerDirective.prototype.positionStrategy; /** * @type {?} * @private */ NzAutocompleteTriggerDirective.prototype.previousValue; /** * @type {?} * @private */ NzAutocompleteTriggerDirective.prototype.selectionChangeSubscription; /** * @type {?} * @private */ NzAutocompleteTriggerDirective.prototype.optionsChangeSubscription; /** * @type {?} * @private */ NzAutocompleteTriggerDirective.prototype.overlayBackdropClickSubscription; /** * @type {?} * @private */ NzAutocompleteTriggerDirective.prototype.overlayPositionChangeSubscription; /** * @type {?} * @private */ NzAutocompleteTriggerDirective.prototype.elementRef; /** * @type {?} * @private */ NzAutocompleteTriggerDirective.prototype._overlay; /** * @type {?} * @private */ NzAutocompleteTriggerDirective.prototype.viewContainerRef; /** * @type {?} * @private */ NzAutocompleteTriggerDirective.prototype.document; } /** * @fileoverview added by tsickle * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ class NzAutocompleteModule { } NzAutocompleteModule.decorators = [ { type: NgModule, args: [{ declarations: [ NzAutocompleteComponent, NzAutocompleteOptionComponent, NzAutocompleteTriggerDirective, NzAutocompleteOptgroupComponent ], exports: [ NzAutocompleteComponent, NzAutocompleteOptionComponent, NzAutocompleteTriggerDirective, NzAutocompleteOptgroupComponent ], imports: [CommonModule, OverlayModule, FormsModule, NzAddOnModule, NzNoAnimationModule] },] } ]; /** * @fileoverview added by tsickle * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @fileoverview added by tsickle * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ export { NZ_AUTOCOMPLETE_VALUE_ACCESSOR, NzAutocompleteComponent, NzAutocompleteModule, NzAutocompleteOptgroupComponent, NzAutocompleteOptionComponent, NzAutocompleteTriggerDirective, NzOptionSelectionChange, getNzAutocompleteMissingPanelError }; //# sourceMappingURL=ng-zorro-antd-auto-complete.js.map