ng-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
1,112 lines (1,081 loc) • 116 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs'), require('@angular/cdk/scrolling'), require('ng-zorro-antd/core/util'), require('rxjs/operators'), require('@angular/cdk/a11y'), require('@angular/cdk/keycodes'), require('@angular/cdk/overlay'), require('@angular/cdk/platform'), require('@angular/forms'), require('ng-zorro-antd/core/animation'), require('ng-zorro-antd/core/config'), require('ng-zorro-antd/core/no-animation'), require('@angular/common'), require('ng-zorro-antd/core/outlet'), require('ng-zorro-antd/core/overlay'), require('ng-zorro-antd/core/transition-patch'), require('ng-zorro-antd/empty'), require('ng-zorro-antd/i18n'), require('ng-zorro-antd/icon')) :
typeof define === 'function' && define.amd ? define('ng-zorro-antd/select', ['exports', '@angular/core', 'rxjs', '@angular/cdk/scrolling', 'ng-zorro-antd/core/util', 'rxjs/operators', '@angular/cdk/a11y', '@angular/cdk/keycodes', '@angular/cdk/overlay', '@angular/cdk/platform', '@angular/forms', 'ng-zorro-antd/core/animation', 'ng-zorro-antd/core/config', 'ng-zorro-antd/core/no-animation', '@angular/common', 'ng-zorro-antd/core/outlet', 'ng-zorro-antd/core/overlay', 'ng-zorro-antd/core/transition-patch', 'ng-zorro-antd/empty', 'ng-zorro-antd/i18n', 'ng-zorro-antd/icon'], factory) :
(global = global || self, factory((global['ng-zorro-antd'] = global['ng-zorro-antd'] || {}, global['ng-zorro-antd'].select = {}), global.ng.core, global.rxjs, global.ng.cdk.scrolling, global['ng-zorro-antd'].core.util, global.rxjs.operators, global.ng.cdk.a11y, global.ng.cdk.keycodes, global.ng.cdk.overlay, global.ng.cdk.platform, global.ng.forms, global['ng-zorro-antd'].core.animation, global['ng-zorro-antd'].core.config, global['ng-zorro-antd'].core['no-animation'], global.ng.common, global['ng-zorro-antd'].core.outlet, global['ng-zorro-antd'].core.overlay, global['ng-zorro-antd'].core['transition-patch'], global['ng-zorro-antd'].empty, global['ng-zorro-antd'].i18n, global['ng-zorro-antd'].icon));
}(this, (function (exports, core, rxjs, scrolling, util, operators, a11y, keycodes, overlay, platform, forms, animation, config, noAnimation, common, outlet, overlay$1, transitionPatch, empty, i18n, icon) { '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 __());
}
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
function __rest(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
}
function __decorate(decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
}
function __param(paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
}
function __metadata(metadataKey, metadataValue) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
}
function __awaiter(thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
function __generator(thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
}
function __exportStar(m, exports) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
function __values(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
}
function __read(o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
}
function __spread() {
for (var ar = [], i = 0; i < arguments.length; i++)
ar = ar.concat(__read(arguments[i]));
return ar;
}
function __spreadArrays() {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};
function __await(v) {
return this instanceof __await ? (this.v = v, this) : new __await(v);
}
function __asyncGenerator(thisArg, _arguments, generator) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var g = generator.apply(thisArg, _arguments || []), i, q = [];
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
function fulfill(value) { resume("next", value); }
function reject(value) { resume("throw", value); }
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
}
function __asyncDelegator(o) {
var i, p;
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
}
function __asyncValues(o) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var m = o[Symbol.asyncIterator], i;
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
}
function __makeTemplateObject(cooked, raw) {
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
return cooked;
};
function __importStar(mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result.default = mod;
return result;
}
function __importDefault(mod) {
return (mod && mod.__esModule) ? mod : { default: mod };
}
function __classPrivateFieldGet(receiver, privateMap) {
if (!privateMap.has(receiver)) {
throw new TypeError("attempted to get private field on non-instance");
}
return privateMap.get(receiver);
}
function __classPrivateFieldSet(receiver, privateMap, value) {
if (!privateMap.has(receiver)) {
throw new TypeError("attempted to set private field on non-instance");
}
privateMap.set(receiver, value);
return value;
}
/**
* @fileoverview added by tsickle
* Generated from: option-group.component.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NzOptionGroupComponent = /** @class */ (function () {
function NzOptionGroupComponent() {
this.nzLabel = null;
this.changes = new rxjs.Subject();
}
/**
* @return {?}
*/
NzOptionGroupComponent.prototype.ngOnChanges = /**
* @return {?}
*/
function () {
this.changes.next();
};
NzOptionGroupComponent.decorators = [
{ type: core.Component, args: [{
selector: 'nz-option-group',
exportAs: 'nzOptionGroup',
encapsulation: core.ViewEncapsulation.None,
changeDetection: core.ChangeDetectionStrategy.OnPush,
template: "\n <ng-content></ng-content>\n "
}] }
];
NzOptionGroupComponent.propDecorators = {
nzLabel: [{ type: core.Input }]
};
return NzOptionGroupComponent;
}());
if (false) {
/** @type {?} */
NzOptionGroupComponent.prototype.nzLabel;
/** @type {?} */
NzOptionGroupComponent.prototype.changes;
}
/**
* @fileoverview added by tsickle
* Generated from: option-container.component.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NzOptionContainerComponent = /** @class */ (function () {
function NzOptionContainerComponent() {
this.notFoundContent = undefined;
this.menuItemSelectedIcon = null;
this.dropdownRender = null;
this.activatedValue = null;
this.listOfSelectedValue = [];
this.mode = 'default';
this.matchWidth = true;
this.itemSize = 32;
this.maxItemLength = 8;
this.listOfContainerItem = [];
this.itemClick = new core.EventEmitter();
this.scrollToBottom = new core.EventEmitter();
this.scrolledIndex = 0;
}
/**
* @param {?} value
* @return {?}
*/
NzOptionContainerComponent.prototype.onItemClick = /**
* @param {?} value
* @return {?}
*/
function (value) {
this.itemClick.emit(value);
};
/**
* @param {?} value
* @return {?}
*/
NzOptionContainerComponent.prototype.onItemHover = /**
* @param {?} value
* @return {?}
*/
function (value) {
// TODO: keydown.enter won't activate this value
this.activatedValue = value;
};
/**
* @param {?} _index
* @param {?} option
* @return {?}
*/
NzOptionContainerComponent.prototype.trackValue = /**
* @param {?} _index
* @param {?} option
* @return {?}
*/
function (_index, option) {
return option.key;
};
/**
* @param {?} index
* @return {?}
*/
NzOptionContainerComponent.prototype.onScrolledIndexChange = /**
* @param {?} index
* @return {?}
*/
function (index) {
this.scrolledIndex = index;
if (index === this.listOfContainerItem.length - this.maxItemLength) {
this.scrollToBottom.emit();
}
};
/**
* @return {?}
*/
NzOptionContainerComponent.prototype.scrollToActivatedValue = /**
* @return {?}
*/
function () {
var _this = this;
/** @type {?} */
var index = this.listOfContainerItem.findIndex((/**
* @param {?} item
* @return {?}
*/
function (item) { return _this.compareWith(item.key, _this.activatedValue); }));
if (index < this.scrolledIndex || index >= this.scrolledIndex + this.maxItemLength) {
this.cdkVirtualScrollViewport.scrollToIndex(index || 0);
}
};
/**
* @param {?} changes
* @return {?}
*/
NzOptionContainerComponent.prototype.ngOnChanges = /**
* @param {?} changes
* @return {?}
*/
function (changes) {
var listOfContainerItem = changes.listOfContainerItem, activatedValue = changes.activatedValue;
if (listOfContainerItem || activatedValue) {
this.scrollToActivatedValue();
}
};
/**
* @return {?}
*/
NzOptionContainerComponent.prototype.ngAfterViewInit = /**
* @return {?}
*/
function () {
var _this = this;
setTimeout((/**
* @return {?}
*/
function () { return _this.scrollToActivatedValue(); }));
};
NzOptionContainerComponent.decorators = [
{ type: core.Component, args: [{
selector: 'nz-option-container',
exportAs: 'nzOptionContainer',
changeDetection: core.ChangeDetectionStrategy.OnPush,
encapsulation: core.ViewEncapsulation.None,
preserveWhitespaces: false,
template: "\n <div>\n <div *ngIf=\"listOfContainerItem.length === 0\" class=\"ant-select-item-empty\">\n <nz-embed-empty nzComponentName=\"select\" [specificContent]=\"notFoundContent\"></nz-embed-empty>\n </div>\n <cdk-virtual-scroll-viewport\n [class.full-width]=\"!matchWidth\"\n [itemSize]=\"itemSize\"\n [maxBufferPx]=\"itemSize * maxItemLength\"\n [minBufferPx]=\"itemSize * maxItemLength\"\n (scrolledIndexChange)=\"onScrolledIndexChange($event)\"\n [style.height.px]=\"listOfContainerItem.length * itemSize\"\n [style.max-height.px]=\"itemSize * maxItemLength\"\n >\n <ng-container *cdkVirtualFor=\"let item of listOfContainerItem; trackBy: trackValue\">\n <ng-container [ngSwitch]=\"item.type\">\n <nz-option-item-group *ngSwitchCase=\"'group'\" [nzLabel]=\"item.groupLabel\"></nz-option-item-group>\n <nz-option-item\n *ngSwitchCase=\"'item'\"\n [icon]=\"menuItemSelectedIcon\"\n [customContent]=\"item.nzCustomContent\"\n [template]=\"item.template\"\n [grouped]=\"!!item.groupLabel\"\n [disabled]=\"item.nzDisabled\"\n [showState]=\"mode === 'tags' || mode === 'multiple'\"\n [label]=\"item.nzLabel\"\n [compareWith]=\"compareWith\"\n [activatedValue]=\"activatedValue\"\n [listOfSelectedValue]=\"listOfSelectedValue\"\n [value]=\"item.nzValue\"\n (itemHover)=\"onItemHover($event)\"\n (itemClick)=\"onItemClick($event)\"\n ></nz-option-item>\n </ng-container>\n </ng-container>\n </cdk-virtual-scroll-viewport>\n <ng-template [ngTemplateOutlet]=\"dropdownRender\"></ng-template>\n </div>\n ",
host: {
'[class.ant-select-dropdown]': 'true'
}
}] }
];
NzOptionContainerComponent.propDecorators = {
notFoundContent: [{ type: core.Input }],
menuItemSelectedIcon: [{ type: core.Input }],
dropdownRender: [{ type: core.Input }],
activatedValue: [{ type: core.Input }],
listOfSelectedValue: [{ type: core.Input }],
compareWith: [{ type: core.Input }],
mode: [{ type: core.Input }],
matchWidth: [{ type: core.Input }],
itemSize: [{ type: core.Input }],
maxItemLength: [{ type: core.Input }],
listOfContainerItem: [{ type: core.Input }],
itemClick: [{ type: core.Output }],
scrollToBottom: [{ type: core.Output }],
cdkVirtualScrollViewport: [{ type: core.ViewChild, args: [scrolling.CdkVirtualScrollViewport, { static: true },] }]
};
return NzOptionContainerComponent;
}());
if (false) {
/** @type {?} */
NzOptionContainerComponent.prototype.notFoundContent;
/** @type {?} */
NzOptionContainerComponent.prototype.menuItemSelectedIcon;
/** @type {?} */
NzOptionContainerComponent.prototype.dropdownRender;
/** @type {?} */
NzOptionContainerComponent.prototype.activatedValue;
/** @type {?} */
NzOptionContainerComponent.prototype.listOfSelectedValue;
/** @type {?} */
NzOptionContainerComponent.prototype.compareWith;
/** @type {?} */
NzOptionContainerComponent.prototype.mode;
/** @type {?} */
NzOptionContainerComponent.prototype.matchWidth;
/** @type {?} */
NzOptionContainerComponent.prototype.itemSize;
/** @type {?} */
NzOptionContainerComponent.prototype.maxItemLength;
/** @type {?} */
NzOptionContainerComponent.prototype.listOfContainerItem;
/** @type {?} */
NzOptionContainerComponent.prototype.itemClick;
/** @type {?} */
NzOptionContainerComponent.prototype.scrollToBottom;
/** @type {?} */
NzOptionContainerComponent.prototype.cdkVirtualScrollViewport;
/**
* @type {?}
* @private
*/
NzOptionContainerComponent.prototype.scrolledIndex;
}
/**
* @fileoverview added by tsickle
* Generated from: option.component.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NzOptionComponent = /** @class */ (function () {
function NzOptionComponent(nzOptionGroupComponent) {
this.nzOptionGroupComponent = nzOptionGroupComponent;
this.destroy$ = new rxjs.Subject();
this.changes = new rxjs.Subject();
this.groupLabel = null;
this.nzLabel = null;
this.nzValue = null;
this.nzDisabled = false;
this.nzHide = false;
this.nzCustomContent = false;
}
/**
* @return {?}
*/
NzOptionComponent.prototype.ngOnInit = /**
* @return {?}
*/
function () {
var _this = this;
if (this.nzOptionGroupComponent) {
this.nzOptionGroupComponent.changes.pipe(operators.startWith(true), operators.takeUntil(this.destroy$)).subscribe((/**
* @return {?}
*/
function () {
_this.groupLabel = _this.nzOptionGroupComponent.nzLabel;
}));
}
};
/**
* @return {?}
*/
NzOptionComponent.prototype.ngOnChanges = /**
* @return {?}
*/
function () {
this.changes.next();
};
/**
* @return {?}
*/
NzOptionComponent.prototype.ngOnDestroy = /**
* @return {?}
*/
function () {
this.destroy$.next();
this.destroy$.complete();
};
NzOptionComponent.decorators = [
{ type: core.Component, args: [{
selector: 'nz-option',
exportAs: 'nzOption',
encapsulation: core.ViewEncapsulation.None,
changeDetection: core.ChangeDetectionStrategy.OnPush,
template: "\n <ng-template>\n <ng-content></ng-content>\n </ng-template>\n "
}] }
];
/** @nocollapse */
NzOptionComponent.ctorParameters = function () { return [
{ type: NzOptionGroupComponent, decorators: [{ type: core.Optional }] }
]; };
NzOptionComponent.propDecorators = {
template: [{ type: core.ViewChild, args: [core.TemplateRef, { static: true },] }],
nzLabel: [{ type: core.Input }],
nzValue: [{ type: core.Input }],
nzDisabled: [{ type: core.Input }],
nzHide: [{ type: core.Input }],
nzCustomContent: [{ type: core.Input }]
};
__decorate([
util.InputBoolean(),
__metadata("design:type", Object)
], NzOptionComponent.prototype, "nzDisabled", void 0);
__decorate([
util.InputBoolean(),
__metadata("design:type", Object)
], NzOptionComponent.prototype, "nzHide", void 0);
__decorate([
util.InputBoolean(),
__metadata("design:type", Object)
], NzOptionComponent.prototype, "nzCustomContent", void 0);
return NzOptionComponent;
}());
if (false) {
/** @type {?} */
NzOptionComponent.ngAcceptInputType_nzDisabled;
/** @type {?} */
NzOptionComponent.ngAcceptInputType_nzHide;
/** @type {?} */
NzOptionComponent.ngAcceptInputType_nzCustomContent;
/**
* @type {?}
* @private
*/
NzOptionComponent.prototype.destroy$;
/** @type {?} */
NzOptionComponent.prototype.changes;
/** @type {?} */
NzOptionComponent.prototype.groupLabel;
/** @type {?} */
NzOptionComponent.prototype.template;
/** @type {?} */
NzOptionComponent.prototype.nzLabel;
/** @type {?} */
NzOptionComponent.prototype.nzValue;
/** @type {?} */
NzOptionComponent.prototype.nzDisabled;
/** @type {?} */
NzOptionComponent.prototype.nzHide;
/** @type {?} */
NzOptionComponent.prototype.nzCustomContent;
/**
* @type {?}
* @private
*/
NzOptionComponent.prototype.nzOptionGroupComponent;
}
/**
* @fileoverview added by tsickle
* Generated from: select-search.component.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NzSelectSearchComponent = /** @class */ (function () {
function NzSelectSearchComponent(elementRef, renderer, focusMonitor) {
this.elementRef = elementRef;
this.renderer = renderer;
this.focusMonitor = focusMonitor;
this.disabled = false;
this.mirrorSync = false;
this.showInput = true;
this.focusTrigger = false;
this.value = '';
this.autofocus = false;
this.valueChange = new core.EventEmitter();
this.isComposingChange = new core.EventEmitter();
}
/**
* @param {?} isComposing
* @return {?}
*/
NzSelectSearchComponent.prototype.setCompositionState = /**
* @param {?} isComposing
* @return {?}
*/
function (isComposing) {
this.isComposingChange.next(isComposing);
};
/**
* @param {?} value
* @return {?}
*/
NzSelectSearchComponent.prototype.onValueChange = /**
* @param {?} value
* @return {?}
*/
function (value) {
/** @type {?} */
var inputDOM = this.inputElement.nativeElement;
inputDOM.value = value;
this.value = value;
this.valueChange.next(value);
if (this.mirrorSync) {
this.syncMirrorWidth();
}
};
/**
* @return {?}
*/
NzSelectSearchComponent.prototype.clearInputValue = /**
* @return {?}
*/
function () {
this.onValueChange('');
};
/**
* @return {?}
*/
NzSelectSearchComponent.prototype.syncMirrorWidth = /**
* @return {?}
*/
function () {
/** @type {?} */
var mirrorDOM = this.mirrorElement.nativeElement;
/** @type {?} */
var hostDOM = this.elementRef.nativeElement;
/** @type {?} */
var inputDOM = this.inputElement.nativeElement;
this.renderer.removeStyle(hostDOM, 'width');
mirrorDOM.innerHTML = inputDOM.value + " ";
this.renderer.setStyle(hostDOM, 'width', mirrorDOM.scrollWidth + "px");
};
/**
* @return {?}
*/
NzSelectSearchComponent.prototype.focus = /**
* @return {?}
*/
function () {
this.focusMonitor.focusVia(this.inputElement, 'keyboard');
};
/**
* @return {?}
*/
NzSelectSearchComponent.prototype.blur = /**
* @return {?}
*/
function () {
this.inputElement.nativeElement.blur();
};
/**
* @param {?} changes
* @return {?}
*/
NzSelectSearchComponent.prototype.ngOnChanges = /**
* @param {?} changes
* @return {?}
*/
function (changes) {
/** @type {?} */
var inputDOM = this.inputElement.nativeElement;
var focusTrigger = changes.focusTrigger, showInput = changes.showInput;
if (focusTrigger && focusTrigger.currentValue === true && focusTrigger.previousValue === false) {
inputDOM.focus();
}
if (showInput) {
if (this.showInput) {
this.renderer.removeAttribute(inputDOM, 'readonly');
}
else {
this.renderer.setAttribute(inputDOM, 'readonly', 'readonly');
}
}
};
/**
* @return {?}
*/
NzSelectSearchComponent.prototype.ngAfterViewInit = /**
* @return {?}
*/
function () {
if (this.mirrorSync) {
this.syncMirrorWidth();
}
if (this.autofocus) {
this.focus();
}
};
NzSelectSearchComponent.decorators = [
{ type: core.Component, args: [{
selector: 'nz-select-search',
encapsulation: core.ViewEncapsulation.None,
changeDetection: core.ChangeDetectionStrategy.OnPush,
template: "\n <input\n #inputElement\n autocomplete=\"off\"\n class=\"ant-select-selection-search-input\"\n [ngModel]=\"value\"\n [attr.autofocus]=\"autofocus ? 'autofocus' : null\"\n [disabled]=\"disabled\"\n [style.opacity]=\"showInput ? null : 0\"\n (ngModelChange)=\"onValueChange($event)\"\n (compositionstart)=\"setCompositionState(true)\"\n (compositionend)=\"setCompositionState(false)\"\n />\n <span #mirrorElement *ngIf=\"mirrorSync\" class=\"ant-select-selection-search-mirror\"></span>\n ",
host: {
'[class.ant-select-selection-search]': 'true'
}
}] }
];
/** @nocollapse */
NzSelectSearchComponent.ctorParameters = function () { return [
{ type: core.ElementRef },
{ type: core.Renderer2 },
{ type: a11y.FocusMonitor }
]; };
NzSelectSearchComponent.propDecorators = {
disabled: [{ type: core.Input }],
mirrorSync: [{ type: core.Input }],
showInput: [{ type: core.Input }],
focusTrigger: [{ type: core.Input }],
value: [{ type: core.Input }],
autofocus: [{ type: core.Input }],
valueChange: [{ type: core.Output }],
isComposingChange: [{ type: core.Output }],
inputElement: [{ type: core.ViewChild, args: ['inputElement', { static: true },] }],
mirrorElement: [{ type: core.ViewChild, args: ['mirrorElement', { static: false },] }]
};
return NzSelectSearchComponent;
}());
if (false) {
/** @type {?} */
NzSelectSearchComponent.prototype.disabled;
/** @type {?} */
NzSelectSearchComponent.prototype.mirrorSync;
/** @type {?} */
NzSelectSearchComponent.prototype.showInput;
/** @type {?} */
NzSelectSearchComponent.prototype.focusTrigger;
/** @type {?} */
NzSelectSearchComponent.prototype.value;
/** @type {?} */
NzSelectSearchComponent.prototype.autofocus;
/** @type {?} */
NzSelectSearchComponent.prototype.valueChange;
/** @type {?} */
NzSelectSearchComponent.prototype.isComposingChange;
/** @type {?} */
NzSelectSearchComponent.prototype.inputElement;
/** @type {?} */
NzSelectSearchComponent.prototype.mirrorElement;
/**
* @type {?}
* @private
*/
NzSelectSearchComponent.prototype.elementRef;
/**
* @type {?}
* @private
*/
NzSelectSearchComponent.prototype.renderer;
/**
* @type {?}
* @private
*/
NzSelectSearchComponent.prototype.focusMonitor;
}
/**
* @fileoverview added by tsickle
* Generated from: select-top-control.component.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NzSelectTopControlComponent = /** @class */ (function () {
function NzSelectTopControlComponent(noAnimation) {
this.noAnimation = noAnimation;
this.showSearch = false;
this.placeHolder = null;
this.open = false;
this.maxTagCount = Infinity;
this.autofocus = false;
this.disabled = false;
this.mode = 'default';
this.customTemplate = null;
this.maxTagPlaceholder = null;
this.removeIcon = null;
this.listOfTopItem = [];
this.tokenSeparators = [];
this.tokenize = new core.EventEmitter();
this.inputValueChange = new core.EventEmitter();
this.animationEnd = new core.EventEmitter();
this.deleteItem = new core.EventEmitter();
this.openChange = new core.EventEmitter();
this.listOfSlicedItem = [];
this.isShowPlaceholder = true;
this.isShowSingleLabel = false;
this.isComposing = false;
this.inputValue = null;
}
/**
* @return {?}
*/
NzSelectTopControlComponent.prototype.onHostClick = /**
* @return {?}
*/
function () {
if (!this.disabled) {
this.openChange.next(!this.open);
}
};
/**
* @param {?} e
* @return {?}
*/
NzSelectTopControlComponent.prototype.onHostKeydown = /**
* @param {?} e
* @return {?}
*/
function (e) {
/** @type {?} */
var inputValue = ((/** @type {?} */ (e.target))).value;
if (e.keyCode === keycodes.BACKSPACE && this.mode !== 'default' && !inputValue && this.listOfTopItem.length > 0) {
e.preventDefault();
this.onDeleteItem(this.listOfTopItem[this.listOfTopItem.length - 1]);
}
};
/**
* @return {?}
*/
NzSelectTopControlComponent.prototype.updateTemplateVariable = /**
* @return {?}
*/
function () {
/** @type {?} */
var isSelectedValueEmpty = this.listOfTopItem.length === 0;
this.isShowPlaceholder = isSelectedValueEmpty && !this.isComposing && !this.inputValue;
this.isShowSingleLabel = !isSelectedValueEmpty && !this.isComposing && !this.inputValue;
};
/**
* @param {?} isComposing
* @return {?}
*/
NzSelectTopControlComponent.prototype.isComposingChange = /**
* @param {?} isComposing
* @return {?}
*/
function (isComposing) {
this.isComposing = isComposing;
this.updateTemplateVariable();
};
/**
* @param {?} value
* @return {?}
*/
NzSelectTopControlComponent.prototype.onInputValueChange = /**
* @param {?} value
* @return {?}
*/
function (value) {
if (value !== this.inputValue) {
this.inputValue = value;
this.updateTemplateVariable();
this.inputValueChange.emit(value);
this.tokenSeparate(value, this.tokenSeparators);
}
};
/**
* @param {?} inputValue
* @param {?} tokenSeparators
* @return {?}
*/
NzSelectTopControlComponent.prototype.tokenSeparate = /**
* @param {?} inputValue
* @param {?} tokenSeparators
* @return {?}
*/
function (inputValue, tokenSeparators) {
/** @type {?} */
var 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;
});
/** @type {?} */
var 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 __spread(new Set(array));
});
if (inputValue &&
inputValue.length &&
tokenSeparators.length &&
this.mode !== 'default' &&
includesSeparators(inputValue, tokenSeparators)) {
/** @type {?} */
var listOfLabel = splitBySeparators(inputValue, tokenSeparators);
this.tokenize.next(listOfLabel);
}
};
/**
* @return {?}
*/
NzSelectTopControlComponent.prototype.clearInputValue = /**
* @return {?}
*/
function () {
if (this.nzSelectSearchComponent) {
this.nzSelectSearchComponent.clearInputValue();
}
};
/**
* @return {?}
*/
NzSelectTopControlComponent.prototype.focus = /**
* @return {?}
*/
function () {
if (this.nzSelectSearchComponent) {
this.nzSelectSearchComponent.focus();
}
};
/**
* @return {?}
*/
NzSelectTopControlComponent.prototype.blur = /**
* @return {?}
*/
function () {
if (this.nzSelectSearchComponent) {
this.nzSelectSearchComponent.blur();
}
};
/**
* @param {?} _index
* @param {?} option
* @return {?}
*/
NzSelectTopControlComponent.prototype.trackValue = /**
* @param {?} _index
* @param {?} option
* @return {?}
*/
function (_index, option) {
return option.nzValue;
};
/**
* @param {?} item
* @return {?}
*/
NzSelectTopControlComponent.prototype.onDeleteItem = /**
* @param {?} item
* @return {?}
*/
function (item) {
if (!this.disabled && !item.nzDisabled) {
this.deleteItem.next(item);
}
};
/**
* @return {?}
*/
NzSelectTopControlComponent.prototype.onAnimationEnd = /**
* @return {?}
*/
function () {
this.animationEnd.next();
};
/**
* @param {?} changes
* @return {?}
*/
NzSelectTopControlComponent.prototype.ngOnChanges = /**
* @param {?} changes
* @return {?}
*/
function (changes) {
var _this = this;
var listOfTopItem = changes.listOfTopItem, maxTagCount = changes.maxTagCount, customTemplate = changes.customTemplate, maxTagPlaceholder = changes.maxTagPlaceholder;
if (listOfTopItem) {
this.updateTemplateVariable();
}
if (listOfTopItem || maxTagCount || customTemplate || maxTagPlaceholder) {
/** @type {?} */
var listOfSlicedItem = this.listOfTopItem.slice(0, this.maxTagCount).map((/**
* @param {?} o
* @return {?}
*/
function (o) {
return {
nzLabel: o.nzLabel,
nzValue: o.nzValue,
nzDisabled: o.nzDisabled,
contentTemplateOutlet: _this.customTemplate,
contentTemplateOutletContext: o
};
}));
if (this.listOfTopItem.length > this.maxTagCount) {
/** @type {?} */
var exceededLabel = "+ " + (this.listOfTopItem.length - this.maxTagCount) + " ...";
/** @type {?} */
var listOfSelectedValue = this.listOfTopItem.map((/**
* @param {?} item
* @return {?}
*/
function (item) { return item.nzValue; }));
/** @type {?} */
var exceededItem = {
nzLabel: exceededLabel,
nzValue: '$$__nz_exceeded_item',
nzDisabled: true,
contentTemplateOutlet: this.maxTagPlaceholder,
contentTemplateOutletContext: listOfSelectedValue.slice(this.maxTagCount)
};
listOfSlicedItem.push(exceededItem);
}
this.listOfSlicedItem = listOfSlicedItem;
}
};
NzSelectTopControlComponent.decorators = [
{ type: core.Component, args: [{
selector: 'nz-select-top-control',
exportAs: 'nzSelectTopControl',
preserveWhitespaces: false,
animations: [animation.zoomMotion],
changeDetection: core.ChangeDetectionStrategy.OnPush,
encapsulation: core.ViewEncapsulation.None,
template: "\n <!--single mode-->\n <ng-container [ngSwitch]=\"mode\">\n <ng-container *ngSwitchCase=\"'default'\">\n <nz-select-item\n *ngIf=\"isShowSingleLabel\"\n [deletable]=\"false\"\n [disabled]=\"false\"\n [removeIcon]=\"removeIcon\"\n [label]=\"listOfTopItem[0].nzLabel\"\n [contentTemplateOutlet]=\"customTemplate\"\n [contentTemplateOutletContext]=\"listOfTopItem[0]\"\n ></nz-select-item>\n <nz-select-search\n [disabled]=\"disabled\"\n [value]=\"inputValue\"\n [showInput]=\"open && showSearch\"\n [mirrorSync]=\"false\"\n [autofocus]=\"autofocus\"\n [focusTrigger]=\"open\"\n (isComposingChange)=\"isComposingChange($event)\"\n (valueChange)=\"onInputValueChange($event)\"\n ></nz-select-search>\n </ng-container>\n <ng-container *ngSwitchDefault>\n <!--multiple or tags mode-->\n <nz-select-item\n *ngFor=\"let item of listOfSlicedItem; trackBy: trackValue\"\n [@zoomMotion]\n [@.disabled]=\"noAnimation?.nzNoAnimation\"\n [nzNoAnimation]=\"noAnimation?.nzNoAnimation\"\n [removeIcon]=\"removeIcon\"\n [label]=\"item.nzLabel\"\n [disabled]=\"item.nzDisabled || disabled\"\n [contentTemplateOutlet]=\"item.contentTemplateOutlet\"\n [deletable]=\"true\"\n [contentTemplateOutletContext]=\"item.contentTemplateOutletContext\"\n (@zoomMotion.done)=\"onAnimationEnd()\"\n (delete)=\"onDeleteItem(item.contentTemplateOutletContext)\"\n >\n </nz-select-item>\n <nz-select-search\n [disabled]=\"disabled\"\n [value]=\"inputValue\"\n [autofocus]=\"autofocus\"\n [showInput]=\"true\"\n [mirrorSync]=\"true\"\n [focusTrigger]=\"open\"\n (isComposingChange)=\"isComposingChange($event)\"\n (valueChange)=\"onInputValueChange($event)\"\n ></nz-select-search>\n </ng-container>\n </ng-container>\n <nz-select-placeholder *ngIf=\"isShowPlaceholder\" [placeholder]=\"placeHolder\"></nz-select-placeholder>\n ",
host: {
'[class.ant-select-selector]': 'true',
'(click)': 'onHostClick()',
'(keydown)': 'onHostKeydown($event)'
}
}] }
];
/** @nocollapse */
NzSelectTopControlComponent.ctorParameters = function () { return [
{ type: noAnimation.NzNoAnimationDirective, decorators: [{ type: core.Host }, { type: core.Optional }] }
]; };
NzSelectTopControlComponent.propDecorators = {
showSearch: [{ type: core.Input }],
placeHolder: [{ type: core.Input }],
open: [{ type: core.Input }],
maxTagCount: [{ type: core.Input }],
autofocus: [{ type: core.Input }],
disabled: [{ type: core.Input }],
mode: [{ type: core.Input }],
customTemplate: [{ type: core.Input }],
maxTagPlaceholder: [{ type: core.Input }],
removeIcon: [{ type: core.Input }],
listOfTopItem: [{ type: core.Input }],
tokenSeparators: [{ type: core.Input }],
tokenize: [{ type: core.Output }],
inputValueChange: [{ type: core.Output }],
animationEnd: [{ type: core.Output }],
deleteItem: [{ type: core.Output }],
openChange: [{ type: core.Output }],
nzSelectSearchComponent: [{ type: core.ViewChild, args: [NzSelectSearchComponent,] }]
};
return NzSelectTopControlComponent;
}());
if (false) {
/** @type {?} */
NzSelectTopControlComponent.prototype.showSearch;
/** @type {?} */
NzSelectTopControlComponent.prototype.placeHolder;
/** @type {?} */
NzSelectTopControlComponent.prototype.open;
/** @type {?} */
NzSelectTopControlComponent.prototype.maxTagCount;
/** @type {?} */
NzSelectTopControlComponent.prototype.autofocus;
/** @type {?} */
NzSelectTopControlComponent.prototype.disabled;
/** @type {?} */
NzSelectTopControlComponent.prototype.mode;
/** @type {?} */
NzSelectTopControlComponent.prototype.customTemplate;
/** @type {?} */
NzSelectTopControlComponent.prototype.maxTagPlaceholder;
/** @type {?} */
NzSelectTopControlComponent.prototype.removeIcon;
/** @type {?} */
NzSelectTopControlComponent.prototype.listOfTopItem;
/** @type {?} */
NzSelectTopControlComponent.prototype.tokenSeparators;
/** @type {?} */
NzSelectTopControlComponent.prototype.tokenize;
/** @type {?} */
NzSelectTopControlComponent.prototype.inputValueChange;
/** @type {?} */
NzSelectTopControlComponent.prototype.animationEnd;
/** @type {?} */
NzSelectTopControlComponent.prototype.deleteItem;
/** @type {?} */
NzSelectTopCon