UNPKG

ng-zorro-antd

Version:

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

162 lines (156 loc) 6.7 kB
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 */ var NzAlertComponent = /** @class */ (function () { function NzAlertComponent() { 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 {?} */ NzAlertComponent.prototype.closeAlert = /** * @return {?} */ function () { this.destroy = true; }; /** * @return {?} */ NzAlertComponent.prototype.onFadeAnimationDone = /** * @return {?} */ function () { if (this.destroy) { this.nzOnClose.emit(true); } }; /** * @return {?} */ NzAlertComponent.prototype.updateIconClassMap = /** * @return {?} */ function () { 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 {?} */ NzAlertComponent.prototype.ngOnChanges = /** * @param {?} changes * @return {?} */ function (changes) { var nzShowIcon = changes.nzShowIcon, nzDescription = changes.nzDescription, nzType = changes.nzType, nzBanner = changes.nzBanner; 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: ["\n nz-alert {\n display: block;\n }\n "] }] } ]; 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); return NzAlertComponent; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ var NzAlertModule = /** @class */ (function () { function NzAlertModule() { } NzAlertModule.decorators = [ { type: NgModule, args: [{ declarations: [NzAlertComponent], exports: [NzAlertComponent], imports: [CommonModule, NzIconModule, NzAddOnModule] },] } ]; return NzAlertModule; }()); /** * @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