ng-zorro-antd-yj
Version:
An enterprise-class UI components based on Ant Design and Angular
155 lines • 12.4 kB
JavaScript
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
import * as tslib_1 from "tslib";
import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output, ViewEncapsulation } from '@angular/core';
import { slideAlertMotion } from '../core/animation/slide';
import { InputBoolean } from '../core/util/convert';
export 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',
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 }]
};
tslib_1.__decorate([
InputBoolean(),
tslib_1.__metadata("design:type", Object)
], NzAlertComponent.prototype, "nzCloseable", void 0);
tslib_1.__decorate([
InputBoolean(),
tslib_1.__metadata("design:type", Object)
], NzAlertComponent.prototype, "nzShowIcon", void 0);
tslib_1.__decorate([
InputBoolean(),
tslib_1.__metadata("design:type", Object)
], NzAlertComponent.prototype, "nzBanner", void 0);
if (false) {
/** @type {?} */
NzAlertComponent.prototype.destroy;
/** @type {?} */
NzAlertComponent.prototype.iconType;
/** @type {?} */
NzAlertComponent.prototype.iconTheme;
/**
* @type {?}
* @private
*/
NzAlertComponent.prototype.isTypeSet;
/**
* @type {?}
* @private
*/
NzAlertComponent.prototype.isShowIconSet;
/** @type {?} */
NzAlertComponent.prototype.nzCloseText;
/** @type {?} */
NzAlertComponent.prototype.nzIconType;
/** @type {?} */
NzAlertComponent.prototype.nzMessage;
/** @type {?} */
NzAlertComponent.prototype.nzDescription;
/** @type {?} */
NzAlertComponent.prototype.nzType;
/** @type {?} */
NzAlertComponent.prototype.nzCloseable;
/** @type {?} */
NzAlertComponent.prototype.nzShowIcon;
/** @type {?} */
NzAlertComponent.prototype.nzBanner;
/** @type {?} */
NzAlertComponent.prototype.nzOnClose;
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnotYWxlcnQuY29tcG9uZW50LmpzIiwic291cmNlUm9vdCI6Im5nOi8vbmctem9ycm8tYW50ZC15ai8iLCJzb3VyY2VzIjpbImFsZXJ0L256LWFsZXJ0LmNvbXBvbmVudC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUFBLE9BQU8sRUFDTCx1QkFBdUIsRUFDdkIsU0FBUyxFQUNULFlBQVksRUFDWixLQUFLLEVBRUwsTUFBTSxFQUdOLGlCQUFpQixFQUNsQixNQUFNLGVBQWUsQ0FBQztBQUN2QixPQUFPLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUUzRCxPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU0sc0JBQ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