ng-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
149 lines (143 loc) • 5.97 kB
JavaScript
import { __decorate, __metadata } from 'tslib';
import { CommonModule } from '@angular/common';
import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output, ViewEncapsulation, NgModule } from '@angular/core';
import { slideAlertMotion, InputBoolean, NzAddOnModule } from 'ng-zorro-antd/core';
import { NzIconModule } from 'ng-zorro-antd/icon';
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
class NzAlertComponent {
constructor() {
this.destroy = false;
this.iconType = 'info-circle';
this.iconTheme = 'fill';
this.isTypeSet = false;
this.isShowIconSet = false;
this.nzType = 'info';
this.nzCloseable = false;
this.nzShowIcon = false;
this.nzBanner = false;
this.nzOnClose = new EventEmitter();
}
/**
* @return {?}
*/
closeAlert() {
this.destroy = true;
}
/**
* @return {?}
*/
onFadeAnimationDone() {
if (this.destroy) {
this.nzOnClose.emit(true);
}
}
/**
* @return {?}
*/
updateIconClassMap() {
switch (this.nzType) {
case 'error':
this.iconType = 'close-circle';
break;
case 'success':
this.iconType = 'check-circle';
break;
case 'info':
this.iconType = 'info-circle';
break;
case 'warning':
this.iconType = 'exclamation-circle';
break;
}
this.iconTheme = this.nzDescription ? 'outline' : 'fill';
}
/**
* @param {?} changes
* @return {?}
*/
ngOnChanges(changes) {
const { nzShowIcon, nzDescription, nzType, nzBanner } = changes;
if (nzShowIcon) {
this.isShowIconSet = true;
}
if (nzDescription || nzType) {
this.updateIconClassMap();
}
if (nzType) {
this.isTypeSet = true;
}
if (nzBanner) {
if (!this.isTypeSet) {
this.nzType = 'warning';
}
if (!this.isShowIconSet) {
this.nzShowIcon = true;
}
}
}
}
NzAlertComponent.decorators = [
{ type: Component, args: [{
selector: 'nz-alert',
exportAs: 'nzAlert',
animations: [slideAlertMotion],
template: "<div *ngIf=\"!destroy\"\n class=\"ant-alert\"\n [class.ant-alert-success]=\"nzType === 'success'\"\n [class.ant-alert-info]=\"nzType === 'info'\"\n [class.ant-alert-warning]=\"nzType === 'warning'\"\n [class.ant-alert-error]=\"nzType === 'error'\"\n [class.ant-alert-no-icon]=\"!nzShowIcon\"\n [class.ant-alert-banner]=\"nzBanner\"\n [class.ant-alert-closable]=\"nzCloseable\"\n [class.ant-alert-with-description]=\"!!nzDescription\"\n [@slideAlertMotion]\n (@slideAlertMotion.done)=\"onFadeAnimationDone()\">\n <ng-container *ngIf=\"nzShowIcon\">\n <i class=\"ant-alert-icon\" [ngClass]=\"nzIconType\" *ngIf=\"nzIconType; else iconTemplate\"></i>\n <ng-template #iconTemplate>\n <i nz-icon class=\"ant-alert-icon\" [type]=\"iconType\" [theme]=\"iconTheme\"></i>\n </ng-template>\n </ng-container>\n <span class=\"ant-alert-message\" *ngIf=\"nzMessage\">\n <ng-container *nzStringTemplateOutlet=\"nzMessage\">{{ nzMessage }}</ng-container>\n </span>\n <span class=\"ant-alert-description\" *ngIf=\"nzDescription\">\n <ng-container *nzStringTemplateOutlet=\"nzDescription\">{{ nzDescription }}</ng-container>\n </span>\n <a *ngIf=\"nzCloseable || nzCloseText\"\n class=\"ant-alert-close-icon\"\n (click)=\"closeAlert()\">\n <ng-template #closeDefaultTemplate>\n <i nz-icon type=\"close\" class=\"anticon-close\"></i>\n </ng-template>\n <ng-container *ngIf=\"nzCloseText; else closeDefaultTemplate\">\n <ng-container *nzStringTemplateOutlet=\"nzCloseText\">{{ nzCloseText }}</ng-container>\n </ng-container>\n </a>\n</div>",
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
preserveWhitespaces: false,
styles: [`
nz-alert {
display: block;
}
`]
}] }
];
NzAlertComponent.propDecorators = {
nzCloseText: [{ type: Input }],
nzIconType: [{ type: Input }],
nzMessage: [{ type: Input }],
nzDescription: [{ type: Input }],
nzType: [{ type: Input }],
nzCloseable: [{ type: Input }],
nzShowIcon: [{ type: Input }],
nzBanner: [{ type: Input }],
nzOnClose: [{ type: Output }]
};
__decorate([
InputBoolean(),
__metadata("design:type", Object)
], NzAlertComponent.prototype, "nzCloseable", void 0);
__decorate([
InputBoolean(),
__metadata("design:type", Object)
], NzAlertComponent.prototype, "nzShowIcon", void 0);
__decorate([
InputBoolean(),
__metadata("design:type", Object)
], NzAlertComponent.prototype, "nzBanner", void 0);
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
class NzAlertModule {
}
NzAlertModule.decorators = [
{ type: NgModule, args: [{
declarations: [NzAlertComponent],
exports: [NzAlertComponent],
imports: [CommonModule, NzIconModule, NzAddOnModule]
},] }
];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
export { NzAlertComponent, NzAlertModule };
//# sourceMappingURL=ng-zorro-antd-alert.js.map