ng-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
237 lines (231 loc) • 7.78 kB
JavaScript
import { __decorate, __metadata } from 'tslib';
import { EventEmitter, Component, ChangeDetectionStrategy, ViewEncapsulation, Renderer2, ElementRef, Input, Output, NgModule } from '@angular/core';
import { fadeMotion } from 'ng-zorro-antd/core/animation';
import { warnDeprecation } from 'ng-zorro-antd/core/logger';
import { InputBoolean } from 'ng-zorro-antd/core/util';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { NzIconModule } from 'ng-zorro-antd/icon';
/**
* @fileoverview added by tsickle
* Generated from: tag.component.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NzTagComponent = /** @class */ (function () {
function NzTagComponent(renderer, elementRef) {
this.renderer = renderer;
this.elementRef = elementRef;
this.presetColor = false;
this.cacheClassName = null;
this.nzMode = 'default';
this.nzChecked = false;
this.nzNoAnimation = false;
this.nzAfterClose = new EventEmitter();
this.nzOnClose = new EventEmitter();
this.nzCheckedChange = new EventEmitter();
}
/**
* @private
* @param {?=} color
* @return {?}
*/
NzTagComponent.prototype.isPresetColor = /**
* @private
* @param {?=} color
* @return {?}
*/
function (color) {
if (!color) {
return false;
}
return (/^(pink|red|yellow|orange|cyan|green|blue|purple|geekblue|magenta|volcano|gold|lime)(-inverse)?$/.test(color) ||
/^(success|processing|error|default|warning)$/.test(color));
};
/**
* @private
* @return {?}
*/
NzTagComponent.prototype.updateClassMap = /**
* @private
* @return {?}
*/
function () {
this.presetColor = this.isPresetColor(this.nzColor);
if (this.cacheClassName) {
this.renderer.removeClass(this.elementRef.nativeElement, this.cacheClassName);
}
if (this.presetColor) {
this.cacheClassName = "ant-tag-" + this.nzColor;
this.renderer.addClass(this.elementRef.nativeElement, this.cacheClassName);
}
};
/**
* @return {?}
*/
NzTagComponent.prototype.updateCheckedStatus = /**
* @return {?}
*/
function () {
if (this.nzMode === 'checkable') {
this.nzChecked = !this.nzChecked;
this.nzCheckedChange.emit(this.nzChecked);
this.updateClassMap();
}
};
/**
* @param {?} e
* @return {?}
*/
NzTagComponent.prototype.closeTag = /**
* @param {?} e
* @return {?}
*/
function (e) {
this.nzOnClose.emit(e);
if (!e.defaultPrevented) {
this.renderer.removeChild(this.renderer.parentNode(this.elementRef.nativeElement), this.elementRef.nativeElement);
}
};
/**
* @param {?} e
* @return {?}
*/
NzTagComponent.prototype.afterAnimation = /**
* @param {?} e
* @return {?}
*/
function (e) {
if (e.toState === 'void') {
this.nzAfterClose.emit();
if (this.nzAfterClose.observers.length) {
warnDeprecation("'(nzAfterClose)' Output is going to be removed in 9.0.0. Please use '(nzOnClose)' instead.");
}
}
};
/**
* @return {?}
*/
NzTagComponent.prototype.ngOnInit = /**
* @return {?}
*/
function () {
this.updateClassMap();
};
/**
* @return {?}
*/
NzTagComponent.prototype.ngOnChanges = /**
* @return {?}
*/
function () {
this.updateClassMap();
};
NzTagComponent.decorators = [
{ type: Component, args: [{
selector: 'nz-tag',
exportAs: 'nzTag',
preserveWhitespaces: false,
animations: [fadeMotion],
template: "\n <ng-content></ng-content>\n <i nz-icon nzType=\"close\" *ngIf=\"nzMode === 'closeable'\" tabindex=\"-1\" (click)=\"closeTag($event)\"></i>\n ",
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
host: {
'[@fadeMotion]': '',
'[@.disabled]': 'nzNoAnimation',
'[style.background-color]': 'presetColor ? null : nzColor',
'[class.ant-tag]': "true",
'[class.ant-tag-has-color]': "nzColor && !presetColor",
'[class.ant-tag-checkable]': "nzMode === 'checkable'",
'[class.ant-tag-checkable-checked]': "nzChecked",
'(click)': 'updateCheckedStatus()',
'(@fadeMotion.done)': 'afterAnimation($event)'
}
}] }
];
/** @nocollapse */
NzTagComponent.ctorParameters = function () { return [
{ type: Renderer2 },
{ type: ElementRef }
]; };
NzTagComponent.propDecorators = {
nzMode: [{ type: Input }],
nzColor: [{ type: Input }],
nzChecked: [{ type: Input }],
nzNoAnimation: [{ type: Input }],
nzAfterClose: [{ type: Output }],
nzOnClose: [{ type: Output }],
nzCheckedChange: [{ type: Output }]
};
__decorate([
InputBoolean(),
__metadata("design:type", Object)
], NzTagComponent.prototype, "nzChecked", void 0);
__decorate([
InputBoolean(),
__metadata("design:type", Object)
], NzTagComponent.prototype, "nzNoAnimation", void 0);
return NzTagComponent;
}());
if (false) {
/** @type {?} */
NzTagComponent.ngAcceptInputType_nzChecked;
/** @type {?} */
NzTagComponent.ngAcceptInputType_nzNoAnimation;
/** @type {?} */
NzTagComponent.prototype.presetColor;
/** @type {?} */
NzTagComponent.prototype.cacheClassName;
/** @type {?} */
NzTagComponent.prototype.nzMode;
/** @type {?} */
NzTagComponent.prototype.nzColor;
/** @type {?} */
NzTagComponent.prototype.nzChecked;
/** @type {?} */
NzTagComponent.prototype.nzNoAnimation;
/** @type {?} */
NzTagComponent.prototype.nzAfterClose;
/** @type {?} */
NzTagComponent.prototype.nzOnClose;
/** @type {?} */
NzTagComponent.prototype.nzCheckedChange;
/**
* @type {?}
* @private
*/
NzTagComponent.prototype.renderer;
/**
* @type {?}
* @private
*/
NzTagComponent.prototype.elementRef;
}
/**
* @fileoverview added by tsickle
* Generated from: tag.module.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NzTagModule = /** @class */ (function () {
function NzTagModule() {
}
NzTagModule.decorators = [
{ type: NgModule, args: [{
imports: [CommonModule, FormsModule, NzIconModule],
declarations: [NzTagComponent],
exports: [NzTagComponent]
},] }
];
return NzTagModule;
}());
/**
* @fileoverview added by tsickle
* Generated from: public-api.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @fileoverview added by tsickle
* Generated from: ng-zorro-antd-tag.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
export { NzTagComponent, NzTagModule };
//# sourceMappingURL=ng-zorro-antd-tag.js.map