ng-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
1,448 lines (1,440 loc) • 84.7 kB
JavaScript
import { Component, ViewEncapsulation, ChangeDetectionStrategy, ViewChild, TemplateRef, Input, ContentChildren, Pipe, Injectable, ElementRef, ChangeDetectorRef, Renderer2, EventEmitter, NgZone, ViewChildren, Output, Host, Optional, forwardRef, Directive, NgModule } from '@angular/core';
import { __decorate, __metadata, __read, __spread } from 'tslib';
import { InputBoolean, isNotNil, isNil, zoomMotion, NzNoAnimationDirective, toBoolean, slideMotion, NzAddOnModule, NzOverlayModule, NzNoAnimationModule } from 'ng-zorro-antd/core';
import { Subject, BehaviorSubject, ReplaySubject, combineLatest, merge, fromEvent, EMPTY } from 'rxjs';
import { distinctUntilChanged, map, filter, skip, share, tap, takeUntil, startWith, flatMap } from 'rxjs/operators';
import { UP_ARROW, DOWN_ARROW, ENTER, BACKSPACE, SPACE, TAB } from '@angular/cdk/keycodes';
import { FocusMonitor } from '@angular/cdk/a11y';
import { CdkOverlayOrigin, CdkConnectedOverlay, OverlayModule } from '@angular/cdk/overlay';
import { Platform, PlatformModule } from '@angular/cdk/platform';
import { NG_VALUE_ACCESSOR, FormsModule } from '@angular/forms';
import { CommonModule } from '@angular/common';
import { NzEmptyModule } from 'ng-zorro-antd/empty';
import { NzI18nModule } from 'ng-zorro-antd/i18n';
import { NzIconModule } from 'ng-zorro-antd/icon';
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NzOptionComponent = /** @class */ (function () {
function NzOptionComponent() {
this.changes = new Subject();
this.nzDisabled = false;
this.nzCustomContent = false;
}
/**
* @return {?}
*/
NzOptionComponent.prototype.ngOnChanges = /**
* @return {?}
*/
function () {
this.changes.next();
};
NzOptionComponent.decorators = [
{ type: Component, args: [{
selector: 'nz-option',
exportAs: 'nzOption',
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
template: "<ng-template>\n <ng-content></ng-content>\n</ng-template>"
}] }
];
NzOptionComponent.propDecorators = {
template: [{ type: ViewChild, args: [TemplateRef, { static: false },] }],
nzLabel: [{ type: Input }],
nzValue: [{ type: Input }],
nzDisabled: [{ type: Input }],
nzCustomContent: [{ type: Input }]
};
__decorate([
InputBoolean(),
__metadata("design:type", Object)
], NzOptionComponent.prototype, "nzDisabled", void 0);
__decorate([
InputBoolean(),
__metadata("design:type", Object)
], NzOptionComponent.prototype, "nzCustomContent", void 0);
return NzOptionComponent;
}());
if (false) {
/** @type {?} */
NzOptionComponent.prototype.changes;
/** @type {?} */
NzOptionComponent.prototype.template;
/** @type {?} */
NzOptionComponent.prototype.nzLabel;
/** @type {?} */
NzOptionComponent.prototype.nzValue;
/** @type {?} */
NzOptionComponent.prototype.nzDisabled;
/** @type {?} */
NzOptionComponent.prototype.nzCustomContent;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NzOptionGroupComponent = /** @class */ (function () {
function NzOptionGroupComponent() {
this.isLabelString = false;
}
Object.defineProperty(NzOptionGroupComponent.prototype, "nzLabel", {
get: /**
* @return {?}
*/
function () {
return this.label;
},
set: /**
* @param {?} value
* @return {?}
*/
function (value) {
this.label = value;
this.isLabelString = !(this.nzLabel instanceof TemplateRef);
},
enumerable: true,
configurable: true
});
NzOptionGroupComponent.decorators = [
{ type: Component, args: [{
selector: 'nz-option-group',
exportAs: 'nzOptionGroup',
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
template: "<ng-content></ng-content>"
}] }
];
NzOptionGroupComponent.propDecorators = {
listOfNzOptionComponent: [{ type: ContentChildren, args: [NzOptionComponent,] }],
nzLabel: [{ type: Input }]
};
return NzOptionGroupComponent;
}());
if (false) {
/** @type {?} */
NzOptionGroupComponent.prototype.isLabelString;
/** @type {?} */
NzOptionGroupComponent.prototype.label;
/** @type {?} */
NzOptionGroupComponent.prototype.listOfNzOptionComponent;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NzFilterOptionPipe = /** @class */ (function () {
function NzFilterOptionPipe() {
}
/**
* @param {?} options
* @param {?} searchValue
* @param {?} filterOption
* @param {?} serverSearch
* @return {?}
*/
NzFilterOptionPipe.prototype.transform = /**
* @param {?} options
* @param {?} searchValue
* @param {?} filterOption
* @param {?} serverSearch
* @return {?}
*/
function (options, searchValue, filterOption, serverSearch) {
if (serverSearch || !searchValue) {
return options;
}
else {
return ((/** @type {?} */ (options))).filter((/**
* @param {?} o
* @return {?}
*/
function (o) { return filterOption(searchValue, o); }));
}
};
NzFilterOptionPipe.decorators = [
{ type: Pipe, args: [{ name: 'nzFilterOption' },] }
];
return NzFilterOptionPipe;
}());
var NzFilterGroupOptionPipe = /** @class */ (function () {
function NzFilterGroupOptionPipe() {
}
/**
* @param {?} groups
* @param {?} searchValue
* @param {?} filterOption
* @param {?} serverSearch
* @return {?}
*/
NzFilterGroupOptionPipe.prototype.transform = /**
* @param {?} groups
* @param {?} searchValue
* @param {?} filterOption
* @param {?} serverSearch
* @return {?}
*/
function (groups, searchValue, filterOption, serverSearch) {
if (serverSearch || !searchValue) {
return groups;
}
else {
return ((/** @type {?} */ (groups))).filter((/**
* @param {?} g
* @return {?}
*/
function (g) {
return g.listOfNzOptionComponent.some((/**
* @param {?} o
* @return {?}
*/
function (o) { return filterOption(searchValue, o); }));
}));
}
};
NzFilterGroupOptionPipe.decorators = [
{ type: Pipe, args: [{ name: 'nzFilterGroupOption' },] }
];
return NzFilterGroupOptionPipe;
}());
/**
* @param {?} searchValue
* @param {?} option
* @return {?}
*/
function defaultFilterOption(searchValue, option) {
if (option && option.nzLabel) {
return option.nzLabel.toLowerCase().indexOf(searchValue.toLowerCase()) > -1;
}
else {
return false;
}
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NzSelectService = /** @class */ (function () {
function NzSelectService() {
var _this = this;
// Input params
this.autoClearSearchValue = true;
this.serverSearch = false;
this.filterOption = defaultFilterOption;
this.mode = 'default';
this.maxMultipleCount = Infinity;
this.disabled = false;
// tslint:disable-next-line:no-any
this.compareWith = (/**
* @param {?} o1
* @param {?} o2
* @return {?}
*/
function (o1, o2) { return o1 === o2; });
// selectedValueChanged should emit ngModelChange or not
// tslint:disable-next-line:no-any
this.listOfSelectedValueWithEmit$ = new BehaviorSubject({
value: [],
emit: false
});
// ContentChildren Change
this.mapOfTemplateOption$ = new BehaviorSubject({
listOfNzOptionComponent: [],
listOfNzOptionGroupComponent: []
});
// searchValue Change
this.searchValueRaw$ = new BehaviorSubject('');
this.listOfFilteredOption = [];
this.openRaw$ = new Subject();
this.checkRaw$ = new Subject();
this.open = false;
this.clearInput$ = new Subject();
this.searchValue = '';
this.isShowNotFound = false;
// open
this.open$ = this.openRaw$.pipe(distinctUntilChanged());
this.activatedOption$ = new ReplaySubject(1);
this.listOfSelectedValue$ = this.listOfSelectedValueWithEmit$.pipe(map((/**
* @param {?} data
* @return {?}
*/
function (data) { return data.value; })));
this.modelChange$ = this.listOfSelectedValueWithEmit$.pipe(filter((/**
* @param {?} item
* @return {?}
*/
function (item) { return item.emit; })), map((/**
* @param {?} data
* @return {?}
*/
function (data) {
/** @type {?} */
var selectedList = data.value;
/** @type {?} */
var modelValue = null;
if (_this.isSingleMode) {
if (selectedList.length) {
modelValue = selectedList[0];
}
}
else {
modelValue = selectedList;
}
return modelValue;
})));
this.searchValue$ = this.searchValueRaw$.pipe(distinctUntilChanged(), skip(1), share(), tap((/**
* @param {?} value
* @return {?}
*/
function (value) {
_this.searchValue = value;
if (value) {
_this.updateActivatedOption(_this.listOfFilteredOption[0]);
}
_this.updateListOfFilteredOption();
})));
// tslint:disable-next-line:no-any
this.listOfSelectedValue = [];
// flat ViewChildren
this.listOfTemplateOption = [];
// tag option
this.listOfTagOption = [];
// tag option concat template option
this.listOfTagAndTemplateOption = [];
// ViewChildren
this.listOfNzOptionComponent = [];
this.listOfNzOptionGroupComponent = [];
// display in top control
this.listOfCachedSelectedOption = [];
// selected value or ViewChildren change
this.valueOrOption$ = combineLatest([this.listOfSelectedValue$, this.mapOfTemplateOption$]).pipe(tap((/**
* @param {?} data
* @return {?}
*/
function (data) {
var _a = __read(data, 2), listOfSelectedValue = _a[0], mapOfTemplateOption = _a[1];
_this.listOfSelectedValue = listOfSelectedValue;
_this.listOfNzOptionComponent = mapOfTemplateOption.listOfNzOptionComponent;
_this.listOfNzOptionGroupComponent = mapOfTemplateOption.listOfNzOptionGroupComponent;
_this.listOfTemplateOption = _this.listOfNzOptionComponent.concat(_this.listOfNzOptionGroupComponent.reduce((/**
* @param {?} pre
* @param {?} cur
* @return {?}
*/
function (pre, cur) { return __spread(pre, cur.listOfNzOptionComponent.toArray()); }), (/** @type {?} */ ([]))));
_this.updateListOfTagOption();
_this.updateListOfFilteredOption();
_this.resetActivatedOptionIfNeeded();
_this.updateListOfCachedOption();
})), share());
this.check$ = merge(this.checkRaw$, this.valueOrOption$, this.searchValue$, this.activatedOption$, this.open$, this.modelChange$).pipe(share());
}
/**
* @param {?} option
* @return {?}
*/
NzSelectService.prototype.clickOption = /**
* @param {?} option
* @return {?}
*/
function (option) {
var _this = this;
/** update listOfSelectedOption -> update listOfSelectedValue -> next listOfSelectedValue$ **/
if (!option.nzDisabled) {
this.updateActivatedOption(option);
/** @type {?} */
var listOfSelectedValue = __spread(this.listOfSelectedValue);
if (this.isMultipleOrTags) {
/** @type {?} */
var targetValue = listOfSelectedValue.find((/**
* @param {?} o
* @return {?}
*/
function (o) { return _this.compareWith(o, option.nzValue); }));
if (isNotNil(targetValue)) {
listOfSelectedValue.splice(listOfSelectedValue.indexOf(targetValue), 1);
this.updateListOfSelectedValue(listOfSelectedValue, true);
}
else if (listOfSelectedValue.length < this.maxMultipleCount) {
listOfSelectedValue.push(option.nzValue);
this.updateListOfSelectedValue(listOfSelectedValue, true);
}
}
else if (!this.compareWith(listOfSelectedValue[0], option.nzValue)) {
listOfSelectedValue = [option.nzValue];
this.updateListOfSelectedValue(listOfSelectedValue, true);
}
if (this.isSingleMode) {
this.setOpenState(false);
}
else if (this.autoClearSearchValue) {
this.clearInput();
}
}
};
/**
* @return {?}
*/
NzSelectService.prototype.updateListOfCachedOption = /**
* @return {?}
*/
function () {
var _this = this;
if (this.isSingleMode) {
/** @type {?} */
var selectedOption = this.listOfTemplateOption.find((/**
* @param {?} o
* @return {?}
*/
function (o) {
return _this.compareWith(o.nzValue, _this.listOfSelectedValue[0]);
}));
if (!isNil(selectedOption)) {
this.listOfCachedSelectedOption = [selectedOption];
}
}
else {
/** @type {?} */
var listOfCachedSelectedOption_1 = [];
this.listOfSelectedValue.forEach((/**
* @param {?} v
* @return {?}
*/
function (v) {
/** @type {?} */
var listOfMixedOption = __spread(_this.listOfTagAndTemplateOption, _this.listOfCachedSelectedOption);
/** @type {?} */
var option = listOfMixedOption.find((/**
* @param {?} o
* @return {?}
*/
function (o) { return _this.compareWith(o.nzValue, v); }));
if (option) {
listOfCachedSelectedOption_1.push(option);
}
}));
this.listOfCachedSelectedOption = listOfCachedSelectedOption_1;
}
};
/**
* @return {?}
*/
NzSelectService.prototype.updateListOfTagOption = /**
* @return {?}
*/
function () {
var _this = this;
if (this.isTagsMode) {
/** @type {?} */
var listOfMissValue = this.listOfSelectedValue.filter((/**
* @param {?} value
* @return {?}
*/
function (value) { return !_this.listOfTemplateOption.find((/**
* @param {?} o
* @return {?}
*/
function (o) { return _this.compareWith(o.nzValue, value); })); }));
this.listOfTagOption = listOfMissValue.map((/**
* @param {?} value
* @return {?}
*/
function (value) {
/** @type {?} */
var cachedOption = _this.listOfCachedSelectedOption.find((/**
* @param {?} o
* @return {?}
*/
function (o) { return _this.compareWith(o.nzValue, value); }));
if (cachedOption) {
return cachedOption;
}
else {
/** @type {?} */
var nzOptionComponent = new NzOptionComponent();
nzOptionComponent.nzValue = value;
nzOptionComponent.nzLabel = value;
return nzOptionComponent;
}
}));
this.listOfTagAndTemplateOption = __spread(this.listOfTemplateOption.concat(this.listOfTagOption));
}
else {
this.listOfTagAndTemplateOption = __spread(this.listOfTemplateOption);
}
};
/**
* @return {?}
*/
NzSelectService.prototype.updateAddTagOption = /**
* @return {?}
*/
function () {
var _this = this;
/** @type {?} */
var isMatch = this.listOfTagAndTemplateOption.find((/**
* @param {?} item
* @return {?}
*/
function (item) { return item.nzLabel === _this.searchValue; }));
if (this.isTagsMode && this.searchValue && !isMatch) {
/** @type {?} */
var option = new NzOptionComponent();
option.nzValue = this.searchValue;
option.nzLabel = this.searchValue;
this.addedTagOption = option;
this.updateActivatedOption(option);
}
else {
this.addedTagOption = null;
}
};
/**
* @return {?}
*/
NzSelectService.prototype.updateListOfFilteredOption = /**
* @return {?}
*/
function () {
this.updateAddTagOption();
/** @type {?} */
var listOfFilteredOption = new NzFilterOptionPipe().transform(this.listOfTagAndTemplateOption, this.searchValue, this.filterOption, this.serverSearch);
this.listOfFilteredOption = this.addedTagOption
? __spread([this.addedTagOption], listOfFilteredOption) : __spread(listOfFilteredOption);
this.isShowNotFound = !this.isTagsMode && !this.listOfFilteredOption.length;
};
/**
* @return {?}
*/
NzSelectService.prototype.clearInput = /**
* @return {?}
*/
function () {
this.clearInput$.next();
};
// tslint:disable-next-line:no-any
// tslint:disable-next-line:no-any
/**
* @param {?} value
* @param {?} emit
* @return {?}
*/
NzSelectService.prototype.updateListOfSelectedValue =
// tslint:disable-next-line:no-any
/**
* @param {?} value
* @param {?} emit
* @return {?}
*/
function (value, emit) {
this.listOfSelectedValueWithEmit$.next({ value: value, emit: emit });
};
/**
* @param {?} option
* @return {?}
*/
NzSelectService.prototype.updateActivatedOption = /**
* @param {?} option
* @return {?}
*/
function (option) {
this.activatedOption$.next(option);
this.activatedOption = option;
};
/**
* @param {?} inputValue
* @param {?} tokenSeparators
* @return {?}
*/
NzSelectService.prototype.tokenSeparate = /**
* @param {?} inputValue
* @param {?} tokenSeparators
* @return {?}
*/
function (inputValue, tokenSeparators) {
// auto tokenSeparators
if (inputValue &&
inputValue.length &&
tokenSeparators.length &&
this.isMultipleOrTags &&
this.includesSeparators(inputValue, tokenSeparators)) {
/** @type {?} */
var listOfLabel = this.splitBySeparators(inputValue, tokenSeparators);
this.updateSelectedValueByLabelList(listOfLabel);
this.clearInput();
}
};
/**
* @param {?} str
* @param {?} separators
* @return {?}
*/
NzSelectService.prototype.includesSeparators = /**
* @param {?} str
* @param {?} separators
* @return {?}
*/
function (str, separators) {
// tslint:disable-next-line:prefer-for-of
for (var i = 0; i < separators.length; ++i) {
if (str.lastIndexOf(separators[i]) > 0) {
return true;
}
}
return false;
};
/**
* @param {?} str
* @param {?} separators
* @return {?}
*/
NzSelectService.prototype.splitBySeparators = /**
* @param {?} str
* @param {?} separators
* @return {?}
*/
function (str, separators) {
/** @type {?} */
var reg = new RegExp("[" + separators.join() + "]");
/** @type {?} */
var array = ((/** @type {?} */ (str))).split(reg).filter((/**
* @param {?} token
* @return {?}
*/
function (token) { return token; }));
return Array.from(new Set(array));
};
/**
* @return {?}
*/
NzSelectService.prototype.resetActivatedOptionIfNeeded = /**
* @return {?}
*/
function () {
var _this = this;
/** @type {?} */
var resetActivatedOption = (/**
* @return {?}
*/
function () {
/** @type {?} */
var activatedOption = _this.listOfFilteredOption.find((/**
* @param {?} item
* @return {?}
*/
function (item) {
return _this.compareWith(item.nzValue, _this.listOfSelectedValue[0]);
}));
_this.updateActivatedOption(activatedOption || null);
});
if (this.activatedOption) {
if (!this.listOfFilteredOption.find((/**
* @param {?} item
* @return {?}
*/
function (item) { return _this.compareWith(item.nzValue, (/** @type {?} */ (_this.activatedOption)).nzValue); })) ||
!this.listOfSelectedValue.find((/**
* @param {?} item
* @return {?}
*/
function (item) { return _this.compareWith(item, (/** @type {?} */ (_this.activatedOption)).nzValue); }))) {
resetActivatedOption();
}
}
else {
resetActivatedOption();
}
};
/**
* @param {?} listOfNzOptionComponent
* @param {?} listOfNzOptionGroupComponent
* @return {?}
*/
NzSelectService.prototype.updateTemplateOption = /**
* @param {?} listOfNzOptionComponent
* @param {?} listOfNzOptionGroupComponent
* @return {?}
*/
function (listOfNzOptionComponent, listOfNzOptionGroupComponent) {
this.mapOfTemplateOption$.next({ listOfNzOptionComponent: listOfNzOptionComponent, listOfNzOptionGroupComponent: listOfNzOptionGroupComponent });
};
/**
* @param {?} value
* @return {?}
*/
NzSelectService.prototype.updateSearchValue = /**
* @param {?} value
* @return {?}
*/
function (value) {
this.searchValueRaw$.next(value);
};
/**
* @param {?} listOfLabel
* @return {?}
*/
NzSelectService.prototype.updateSelectedValueByLabelList = /**
* @param {?} listOfLabel
* @return {?}
*/
function (listOfLabel) {
var _this = this;
/** @type {?} */
var listOfSelectedValue = __spread(this.listOfSelectedValue);
/** @type {?} */
var listOfMatchOptionValue = this.listOfTagAndTemplateOption
.filter((/**
* @param {?} item
* @return {?}
*/
function (item) { return listOfLabel.indexOf(item.nzLabel) !== -1; }))
.map((/**
* @param {?} item
* @return {?}
*/
function (item) { return item.nzValue; }))
.filter((/**
* @param {?} item
* @return {?}
*/
function (item) { return !isNotNil(_this.listOfSelectedValue.find((/**
* @param {?} v
* @return {?}
*/
function (v) { return _this.compareWith(v, item); }))); }));
if (this.isMultipleMode) {
this.updateListOfSelectedValue(__spread(listOfSelectedValue, listOfMatchOptionValue), true);
}
else {
/** @type {?} */
var listOfUnMatchOptionValue = listOfLabel.filter((/**
* @param {?} label
* @return {?}
*/
function (label) { return _this.listOfTagAndTemplateOption.map((/**
* @param {?} item
* @return {?}
*/
function (item) { return item.nzLabel; })).indexOf(label) === -1; }));
this.updateListOfSelectedValue(__spread(listOfSelectedValue, listOfMatchOptionValue, listOfUnMatchOptionValue), true);
}
};
/**
* @param {?} e
* @return {?}
*/
NzSelectService.prototype.onKeyDown = /**
* @param {?} e
* @return {?}
*/
function (e) {
var _this = this;
if (this.disabled) {
return;
}
/** @type {?} */
var keyCode = e.keyCode;
/** @type {?} */
var eventTarget = (/** @type {?} */ (e.target));
/** @type {?} */
var listOfFilteredOptionWithoutDisabled = this.listOfFilteredOption.filter((/**
* @param {?} item
* @return {?}
*/
function (item) { return !item.nzDisabled; }));
/** @type {?} */
var activatedIndex = listOfFilteredOptionWithoutDisabled.findIndex((/**
* @param {?} item
* @return {?}
*/
function (item) { return item === _this.activatedOption; }));
switch (keyCode) {
case UP_ARROW:
e.preventDefault();
/** @type {?} */
var preIndex = activatedIndex > 0 ? activatedIndex - 1 : listOfFilteredOptionWithoutDisabled.length - 1;
this.updateActivatedOption(listOfFilteredOptionWithoutDisabled[preIndex]);
break;
case DOWN_ARROW:
e.preventDefault();
/** @type {?} */
var nextIndex = activatedIndex < listOfFilteredOptionWithoutDisabled.length - 1 ? activatedIndex + 1 : 0;
this.updateActivatedOption(listOfFilteredOptionWithoutDisabled[nextIndex]);
if (!this.disabled && !this.open) {
this.setOpenState(true);
}
break;
case ENTER:
e.preventDefault();
if (this.open) {
if (this.activatedOption && !this.activatedOption.nzDisabled) {
this.clickOption(this.activatedOption);
}
}
else {
this.setOpenState(true);
}
break;
case BACKSPACE:
if (this.isMultipleOrTags && !eventTarget.value && this.listOfCachedSelectedOption.length) {
e.preventDefault();
this.removeValueFormSelected(this.listOfCachedSelectedOption[this.listOfCachedSelectedOption.length - 1]);
}
break;
case SPACE:
if (!this.disabled && !this.open) {
this.setOpenState(true);
e.preventDefault();
}
break;
case TAB:
this.setOpenState(false);
break;
}
};
// tslint:disable-next-line:no-any
// tslint:disable-next-line:no-any
/**
* @param {?} option
* @return {?}
*/
NzSelectService.prototype.removeValueFormSelected =
// tslint:disable-next-line:no-any
/**
* @param {?} option
* @return {?}
*/
function (option) {
var _this = this;
if (this.disabled || option.nzDisabled) {
return;
}
/** @type {?} */
var listOfSelectedValue = this.listOfSelectedValue.filter((/**
* @param {?} item
* @return {?}
*/
function (item) { return !_this.compareWith(item, option.nzValue); }));
this.updateListOfSelectedValue(listOfSelectedValue, true);
this.clearInput();
};
/**
* @param {?} value
* @return {?}
*/
NzSelectService.prototype.setOpenState = /**
* @param {?} value
* @return {?}
*/
function (value) {
this.openRaw$.next(value);
this.open = value;
};
/**
* @return {?}
*/
NzSelectService.prototype.check = /**
* @return {?}
*/
function () {
this.checkRaw$.next();
};
Object.defineProperty(NzSelectService.prototype, "isSingleMode", {
get: /**
* @return {?}
*/
function () {
return this.mode === 'default';
},
enumerable: true,
configurable: true
});
Object.defineProperty(NzSelectService.prototype, "isTagsMode", {
get: /**
* @return {?}
*/
function () {
return this.mode === 'tags';
},
enumerable: true,
configurable: true
});
Object.defineProperty(NzSelectService.prototype, "isMultipleMode", {
get: /**
* @return {?}
*/
function () {
return this.mode === 'multiple';
},
enumerable: true,
configurable: true
});
Object.defineProperty(NzSelectService.prototype, "isMultipleOrTags", {
get: /**
* @return {?}
*/
function () {
return this.mode === 'tags' || this.mode === 'multiple';
},
enumerable: true,
configurable: true
});
NzSelectService.decorators = [
{ type: Injectable }
];
return NzSelectService;
}());
if (false) {
/** @type {?} */
NzSelectService.prototype.autoClearSearchValue;
/** @type {?} */
NzSelectService.prototype.serverSearch;
/** @type {?} */
NzSelectService.prototype.filterOption;
/** @type {?} */
NzSelectService.prototype.mode;
/** @type {?} */
NzSelectService.prototype.maxMultipleCount;
/** @type {?} */
NzSelectService.prototype.disabled;
/** @type {?} */
NzSelectService.prototype.compareWith;
/**
* @type {?}
* @private
*/
NzSelectService.prototype.listOfSelectedValueWithEmit$;
/**
* @type {?}
* @private
*/
NzSelectService.prototype.mapOfTemplateOption$;
/**
* @type {?}
* @private
*/
NzSelectService.prototype.searchValueRaw$;
/**
* @type {?}
* @private
*/
NzSelectService.prototype.listOfFilteredOption;
/**
* @type {?}
* @private
*/
NzSelectService.prototype.openRaw$;
/**
* @type {?}
* @private
*/
NzSelectService.prototype.checkRaw$;
/**
* @type {?}
* @private
*/
NzSelectService.prototype.open;
/** @type {?} */
NzSelectService.prototype.clearInput$;
/** @type {?} */
NzSelectService.prototype.searchValue;
/** @type {?} */
NzSelectService.prototype.isShowNotFound;
/** @type {?} */
NzSelectService.prototype.open$;
/** @type {?} */
NzSelectService.prototype.activatedOption;
/** @type {?} */
NzSelectService.prototype.activatedOption$;
/** @type {?} */
NzSelectService.prototype.listOfSelectedValue$;
/** @type {?} */
NzSelectService.prototype.modelChange$;
/** @type {?} */
NzSelectService.prototype.searchValue$;
/** @type {?} */
NzSelectService.prototype.listOfSelectedValue;
/** @type {?} */
NzSelectService.prototype.listOfTemplateOption;
/** @type {?} */
NzSelectService.prototype.listOfTagOption;
/** @type {?} */
NzSelectService.prototype.listOfTagAndTemplateOption;
/** @type {?} */
NzSelectService.prototype.listOfNzOptionComponent;
/** @type {?} */
NzSelectService.prototype.listOfNzOptionGroupComponent;
/** @type {?} */
NzSelectService.prototype.addedTagOption;
/** @type {?} */
NzSelectService.prototype.listOfCachedSelectedOption;
/** @type {?} */
NzSelectService.prototype.valueOrOption$;
/** @type {?} */
NzSelectService.prototype.check$;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NzOptionLiComponent = /** @class */ (function () {
function NzOptionLiComponent(elementRef, nzSelectService, cdr, renderer) {
this.elementRef = elementRef;
this.nzSelectService = nzSelectService;
this.cdr = cdr;
this.el = this.elementRef.nativeElement;
this.selected = false;
this.active = false;
this.destroy$ = new Subject();
renderer.addClass(elementRef.nativeElement, 'ant-select-dropdown-menu-item');
}
/**
* @return {?}
*/
NzOptionLiComponent.prototype.clickOption = /**
* @return {?}
*/
function () {
this.nzSelectService.clickOption(this.nzOption);
};
/**
* @return {?}
*/
NzOptionLiComponent.prototype.ngOnInit = /**
* @return {?}
*/
function () {
var _this = this;
this.nzSelectService.listOfSelectedValue$.pipe(takeUntil(this.destroy$)).subscribe((/**
* @param {?} list
* @return {?}
*/
function (list) {
_this.selected = isNotNil(list.find((/**
* @param {?} v
* @return {?}
*/
function (v) { return _this.nzSelectService.compareWith(v, _this.nzOption.nzValue); })));
_this.cdr.markForCheck();
}));
this.nzSelectService.activatedOption$.pipe(takeUntil(this.destroy$)).subscribe((/**
* @param {?} option
* @return {?}
*/
function (option) {
if (option) {
_this.active = _this.nzSelectService.compareWith(option.nzValue, _this.nzOption.nzValue);
}
else {
_this.active = false;
}
_this.cdr.markForCheck();
}));
};
/**
* @return {?}
*/
NzOptionLiComponent.prototype.ngOnDestroy = /**
* @return {?}
*/
function () {
this.destroy$.next();
this.destroy$.complete();
};
NzOptionLiComponent.decorators = [
{ type: Component, args: [{
selector: '[nz-option-li]',
exportAs: 'nzOptionLi',
template: "<ng-container *ngIf=\"!nzOption.nzCustomContent; else nzOption.template\">\n {{nzOption.nzLabel}}\n</ng-container>\n<ng-container *ngIf=\"nzSelectService.isMultipleOrTags\">\n <i nz-icon nzType=\"check\" class=\"ant-select-selected-icon\" *ngIf=\"!nzMenuItemSelectedIcon; else nzMenuItemSelectedIcon\"></i>\n</ng-container>\n",
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
host: {
'[class.ant-select-dropdown-menu-item-selected]': 'selected && !nzOption.nzDisabled',
'[class.ant-select-dropdown-menu-item-disabled]': 'nzOption.nzDisabled',
'[class.ant-select-dropdown-menu-item-active]': 'active && !nzOption.nzDisabled',
'[attr.unselectable]': '"unselectable"',
'[style.user-select]': '"none"',
'(click)': 'clickOption()',
'(mousedown)': '$event.preventDefault()'
}
}] }
];
/** @nocollapse */
NzOptionLiComponent.ctorParameters = function () { return [
{ type: ElementRef },
{ type: NzSelectService },
{ type: ChangeDetectorRef },
{ type: Renderer2 }
]; };
NzOptionLiComponent.propDecorators = {
nzOption: [{ type: Input }],
nzMenuItemSelectedIcon: [{ type: Input }]
};
return NzOptionLiComponent;
}());
if (false) {
/** @type {?} */
NzOptionLiComponent.prototype.el;
/** @type {?} */
NzOptionLiComponent.prototype.selected;
/** @type {?} */
NzOptionLiComponent.prototype.active;
/** @type {?} */
NzOptionLiComponent.prototype.destroy$;
/** @type {?} */
NzOptionLiComponent.prototype.nzOption;
/** @type {?} */
NzOptionLiComponent.prototype.nzMenuItemSelectedIcon;
/**
* @type {?}
* @private
*/
NzOptionLiComponent.prototype.elementRef;
/** @type {?} */
NzOptionLiComponent.prototype.nzSelectService;
/**
* @type {?}
* @private
*/
NzOptionLiComponent.prototype.cdr;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NzOptionContainerComponent = /** @class */ (function () {
function NzOptionContainerComponent(nzSelectService, cdr, ngZone) {
this.nzSelectService = nzSelectService;
this.cdr = cdr;
this.ngZone = ngZone;
this.destroy$ = new Subject();
this.lastScrollTop = 0;
this.nzScrollToBottom = new EventEmitter();
}
/**
* @param {?} option
* @return {?}
*/
NzOptionContainerComponent.prototype.scrollIntoViewIfNeeded = /**
* @param {?} option
* @return {?}
*/
function (option) {
var _this = this;
// delay after open
setTimeout((/**
* @return {?}
*/
function () {
if (_this.listOfNzOptionLiComponent && _this.listOfNzOptionLiComponent.length && option) {
/** @type {?} */
var targetOption = _this.listOfNzOptionLiComponent.find((/**
* @param {?} o
* @return {?}
*/
function (o) {
return _this.nzSelectService.compareWith(o.nzOption.nzValue, option.nzValue);
}));
/* tslint:disable:no-any */
if (targetOption && targetOption.el && ((/** @type {?} */ (targetOption.el))).scrollIntoViewIfNeeded) {
((/** @type {?} */ (targetOption.el))).scrollIntoViewIfNeeded(false);
}
/* tslint:enable:no-any */
}
}));
};
/**
* @param {?} _index
* @param {?} option
* @return {?}
*/
NzOptionContainerComponent.prototype.trackLabel = /**
* @param {?} _index
* @param {?} option
* @return {?}
*/
function (_index, option) {
return option.nzLabel;
};
// tslint:disable-next-line:no-any
// tslint:disable-next-line:no-any
/**
* @param {?} _index
* @param {?} option
* @return {?}
*/
NzOptionContainerComponent.prototype.trackValue =
// tslint:disable-next-line:no-any
/**
* @param {?} _index
* @param {?} option
* @return {?}
*/
function (_index, option) {
return option.nzValue;
};
/**
* @return {?}
*/
NzOptionContainerComponent.prototype.ngOnInit = /**
* @return {?}
*/
function () {
var _this = this;
this.nzSelectService.activatedOption$.pipe(takeUntil(this.destroy$)).subscribe((/**
* @param {?} option
* @return {?}
*/
function (option) {
_this.scrollIntoViewIfNeeded((/** @type {?} */ (option)));
}));
this.nzSelectService.check$.pipe(takeUntil(this.destroy$)).subscribe((/**
* @return {?}
*/
function () {
_this.cdr.markForCheck();
}));
this.ngZone.runOutsideAngular((/**
* @return {?}
*/
function () {
/** @type {?} */
var ul = _this.dropdownUl.nativeElement;
fromEvent(ul, 'scroll')
.pipe(takeUntil(_this.destroy$))
.subscribe((/**
* @param {?} e
* @return {?}
*/
function (e) {
e.preventDefault();
e.stopPropagation();
if (ul && ul.scrollTop > _this.lastScrollTop && ul.scrollHeight < ul.clientHeight + ul.scrollTop + 10) {
_this.lastScrollTop = ul.scrollTop;
_this.ngZone.run((/**
* @return {?}
*/
function () {
_this.nzScrollToBottom.emit();
}));
}
}));
}));
};
/**
* @return {?}
*/
NzOptionContainerComponent.prototype.ngOnDestroy = /**
* @return {?}
*/
function () {
this.destroy$.next();
this.destroy$.complete();
};
NzOptionContainerComponent.decorators = [
{ type: Component, args: [{
selector: '[nz-option-container]',
exportAs: 'nzOptionContainer',
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
preserveWhitespaces: false,
template: "<ul #dropdownUl\n class=\"ant-select-dropdown-menu ant-select-dropdown-menu-root ant-select-dropdown-menu-vertical\"\n role=\"menu\"\n tabindex=\"0\">\n <li *ngIf=\"nzSelectService.isShowNotFound\"\n nz-select-unselectable\n class=\"ant-select-dropdown-menu-item ant-select-dropdown-menu-item-disabled\">\n <nz-embed-empty [nzComponentName]=\"'select'\" [specificContent]=\"nzNotFoundContent\"></nz-embed-empty>\n </li>\n <li nz-option-li\n *ngIf=\"nzSelectService.addedTagOption\"\n [nzMenuItemSelectedIcon]=\"nzMenuItemSelectedIcon\"\n [nzOption]=\"nzSelectService.addedTagOption\">\n </li>\n <li nz-option-li\n *ngFor=\"let option of nzSelectService.listOfNzOptionComponent | nzFilterOption : nzSelectService.searchValue : nzSelectService.filterOption : nzSelectService.serverSearch; trackBy: trackValue\"\n [nzMenuItemSelectedIcon]=\"nzMenuItemSelectedIcon\"\n [nzOption]=\"option\">\n </li>\n <li class=\"ant-select-dropdown-menu-item-group\"\n *ngFor=\"let group of nzSelectService.listOfNzOptionGroupComponent | nzFilterGroupOption : nzSelectService.searchValue : nzSelectService.filterOption :nzSelectService.serverSearch; trackBy: trackLabel\">\n <div class=\"ant-select-dropdown-menu-item-group-title\"\n [attr.title]=\"group.isLabelString ? group.nzLabel : ''\">\n <ng-container *nzStringTemplateOutlet=\"group.nzLabel\"> {{group.nzLabel}} </ng-container>\n </div>\n <ul class=\"ant-select-dropdown-menu-item-group-list\">\n <li nz-option-li\n *ngFor=\"let option of group.listOfNzOptionComponent | nzFilterOption : nzSelectService.searchValue : nzSelectService.filterOption :nzSelectService.serverSearch; trackBy: trackValue\"\n [nzMenuItemSelectedIcon]=\"nzMenuItemSelectedIcon\"\n [nzOption]=\"option\">\n </li>\n </ul>\n </li>\n <li nz-option-li\n *ngFor=\"let option of nzSelectService.listOfTagOption | nzFilterOption : nzSelectService.searchValue : nzSelectService.filterOption : nzSelectService.serverSearch; trackBy: trackValue \"\n [nzMenuItemSelectedIcon]=\"nzMenuItemSelectedIcon\"\n [nzOption]=\"option\">\n </li>\n</ul>\n"
}] }
];
/** @nocollapse */
NzOptionContainerComponent.ctorParameters = function () { return [
{ type: NzSelectService },
{ type: ChangeDetectorRef },
{ type: NgZone }
]; };
NzOptionContainerComponent.propDecorators = {
listOfNzOptionLiComponent: [{ type: ViewChildren, args: [NzOptionLiComponent,] }],
dropdownUl: [{ type: ViewChild, args: ['dropdownUl', { static: true },] }],
nzNotFoundContent: [{ type: Input }],
nzMenuItemSelectedIcon: [{ type: Input }],
nzScrollToBottom: [{ type: Output }]
};
return NzOptionContainerComponent;
}());
if (false) {
/**
* @type {?}
* @private
*/
NzOptionContainerComponent.prototype.destroy$;
/**
* @type {?}
* @private
*/
NzOptionContainerComponent.prototype.lastScrollTop;
/** @type {?} */
NzOptionContainerComponent.prototype.listOfNzOptionLiComponent;
/** @type {?} */
NzOptionContainerComponent.prototype.dropdownUl;
/** @type {?} */
NzOptionContainerComponent.prototype.nzNotFoundContent;
/** @type {?} */
NzOptionContainerComponent.prototype.nzMenuItemSelectedIcon;
/** @type {?} */
NzOptionContainerComponent.prototype.nzScrollToBottom;
/** @type {?} */
NzOptionContainerComponent.prototype.nzSelectService;
/**
* @type {?}
* @private
*/
NzOptionContainerComponent.prototype.cdr;
/**
* @type {?}
* @private
*/
NzOptionContainerComponent.prototype.ngZone;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NzSelectTopControlComponent = /** @class */ (function () {
function NzSelectTopControlComponent(renderer, nzSelectService, cdr, noAnimation) {
this.renderer = renderer;
this.nzSelectService = nzSelectService;
this.cdr = cdr;
this.noAnimation = noAnimation;
this.isComposing = false;
this.destroy$ = new Subject();
this.nzShowSearch = false;
this.nzOpen = false;
this.nzAllowClear = false;
this.nzShowArrow = true;
this.nzLoading = false;
this.nzTokenSeparators = [];
}
/**
* @param {?} e
* @return {?}
*/
NzSelectTopControlComponent.prototype.onClearSelection = /**
* @param {?} e
* @return {?}
*/
function (e) {
e.stopPropagation();
this.nzSelectService.updateListOfSelectedValue([], true);
};
/**
* @param {?} value
* @return {?}
*/
NzSelectTopControlComponent.prototype.setInputValue = /**
* @param {?} value
* @return {?}
*/
function (value) {
/** fix clear value https://github.com/NG-ZORRO/ng-zorro-antd/issues/3825 **/
if (this.inputElement && !value) {
this.inputElement.nativeElement.value = value;
}
this.inputValue = value;
this.updateWidth();
this.nzSelectService.updateSearchValue(value);
this.nzSelectService.tokenSeparate(this.inputValue, this.nzTokenSeparators);
};
Object.defineProperty(NzSelectTopControlComponent.prototype, "placeHolderDisplay", {
get: /**
* @return {?}
*/
function () {
return this.inputValue || this.isComposing || this.nzSelectService.listOfSelectedValue.length ? 'none' : 'block';
},
enumerable: true,
configurable: true
});
Object.defineProperty(NzSelectTopControlComponent.prototype, "selectedValueStyle", {
get: /**
* @return {?}
*/
function () {
/** @type {?} */
var showSelectedValue = false;
/** @type {?} */
var opacity = 1;
if (!this.nzShowSearch) {
showSelectedValue = true;
}
else {
if (this.nzOpen) {
showSelectedValue = !(this.inputValue || this.isComposing);
if (showSelectedValue) {
opacity = 0.4;
}
}
else {
showSelectedValue = true;
}
}
return {
display: showSelectedValue ? 'block' : 'none',
opacity: "" + opacity
};
},
enumerable: true,
configurable: true
});
// tslint:disable-next-line:no-any
// tslint:disable-next-line:no-any
/**
* @param {?} _index
* @param {?} option
* @return {?}
*/
NzSelectTopControlComponent.prototype.trackValue =
// tslint:disable-next-line:no-any
/**
* @param {?} _index
* @param {?} option
* @return {?}
*/
function (_index, option) {
return option.nzValue;
};
/**
* @return {?}
*/
NzSelectTopControlComponent.prototype.updateWidth = /**
* @return {?}
*/
function () {
if (this.nzSelectService.isMultipleOrTags && this.inputElement) {
if (this.inputValue || this.isComposing) {
this.renderer.setStyle(this.inputElement.nativeElement, 'width', this.inputElement.nativeElement.scrollWidth + "px");
}
else {
this.renderer.removeStyle(this.inputElement.nativeElement, 'width');
}
}
};
/**
* @param {?} option
* @param {?} e
* @return {?}
*/
NzSelectTopControlComponent.prototype.removeSelectedValue = /**
* @param {?} option
* @param {?} e
* @return {?}
*/
function (option, e) {
this.nzSelectService.removeValueFormSelected(option);
e.stopPropagation();
};
/**
* @return {?}
*/
NzSelectTopControlComponent.prototype.ngOnInit = /**
* @return {?}
*/
function () {
var _this = this;
this.nzSelectService.open$.pipe(takeUntil(this.destroy$)).subscribe((/**
* @param {?} open