UNPKG

ng-zorro-antd-yj

Version:

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

220 lines 14.7 kB
/** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, ViewEncapsulation } from '@angular/core'; import { moveUpMotion } from '../core/animation/move'; import { NzMessageContainerComponent } from './nz-message-container.component'; var NzMessageComponent = /** @class */ (function () { function NzMessageComponent(_messageContainer, cdr) { this._messageContainer = _messageContainer; this.cdr = cdr; // Whether to set a timeout to destroy itself. this._eraseTimer = null; } /** * @return {?} */ NzMessageComponent.prototype.ngOnInit = /** * @return {?} */ function () { // `NzMessageContainer` does its job so all properties cannot be undefined. this._options = (/** @type {?} */ (this.nzMessage.options)); if (this._options.nzAnimate) { this.nzMessage.state = 'enter'; } this._autoErase = this._options.nzDuration > 0; if (this._autoErase) { this._initErase(); this._startEraseTimeout(); } }; /** * @return {?} */ NzMessageComponent.prototype.ngOnDestroy = /** * @return {?} */ function () { if (this._autoErase) { this._clearEraseTimeout(); } }; /** * @return {?} */ NzMessageComponent.prototype.onEnter = /** * @return {?} */ function () { if (this._autoErase && this._options.nzPauseOnHover) { this._clearEraseTimeout(); this._updateTTL(); } }; /** * @return {?} */ NzMessageComponent.prototype.onLeave = /** * @return {?} */ function () { if (this._autoErase && this._options.nzPauseOnHover) { this._startEraseTimeout(); } }; // Remove self // Remove self /** * @protected * @param {?=} userAction * @return {?} */ NzMessageComponent.prototype._destroy = // Remove self /** * @protected * @param {?=} userAction * @return {?} */ function (userAction) { var _this = this; if (userAction === void 0) { userAction = false; } if (this._options.nzAnimate) { this.nzMessage.state = 'leave'; this.cdr.detectChanges(); setTimeout((/** * @return {?} */ function () { return _this._messageContainer.removeMessage(_this.nzMessage.messageId, userAction); }), 200); } else { this._messageContainer.removeMessage(this.nzMessage.messageId, userAction); } }; /** * @private * @return {?} */ NzMessageComponent.prototype._initErase = /** * @private * @return {?} */ function () { this._eraseTTL = this._options.nzDuration; this._eraseTimingStart = Date.now(); }; /** * @private * @return {?} */ NzMessageComponent.prototype._updateTTL = /** * @private * @return {?} */ function () { if (this._autoErase) { this._eraseTTL -= Date.now() - this._eraseTimingStart; } }; /** * @private * @return {?} */ NzMessageComponent.prototype._startEraseTimeout = /** * @private * @return {?} */ function () { var _this = this; if (this._eraseTTL > 0) { this._clearEraseTimeout(); this._eraseTimer = setTimeout((/** * @return {?} */ function () { return _this._destroy(); }), this._eraseTTL); this._eraseTimingStart = Date.now(); } else { this._destroy(); } }; /** * @private * @return {?} */ NzMessageComponent.prototype._clearEraseTimeout = /** * @private * @return {?} */ function () { if (this._eraseTimer !== null) { clearTimeout(this._eraseTimer); this._eraseTimer = null; } }; NzMessageComponent.decorators = [ { type: Component, args: [{ changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, selector: 'nz-message', preserveWhitespaces: false, animations: [moveUpMotion], template: "<div class=\"ant-message-notice\"\n [@moveUpMotion]=\"nzMessage.state\"\n (mouseenter)=\"onEnter()\"\n (mouseleave)=\"onLeave()\">\n <div class=\"ant-message-notice-content\">\n <div class=\"ant-message-custom-content\" [ngClass]=\"'ant-message-' + nzMessage.type\">\n <ng-container [ngSwitch]=\"nzMessage.type\">\n <i *ngSwitchCase=\"'success'\" nz-icon type=\"check-circle\"></i>\n <i *ngSwitchCase=\"'info'\" nz-icon type=\"info-circle\"></i>\n <i *ngSwitchCase=\"'warning'\" nz-icon type=\"exclamation-circle\"></i>\n <i *ngSwitchCase=\"'error'\" nz-icon type=\"close-circle\"></i>\n <i *ngSwitchCase=\"'loading'\" nz-icon type=\"loading\"></i>\n </ng-container>\n <ng-container *nzStringTemplateOutlet=\"nzMessage.content\">\n <span [innerHTML]=\"nzMessage.content\"></span>\n </ng-container>\n </div>\n </div>\n</div>\n" }] } ]; /** @nocollapse */ NzMessageComponent.ctorParameters = function () { return [ { type: NzMessageContainerComponent }, { type: ChangeDetectorRef } ]; }; NzMessageComponent.propDecorators = { nzMessage: [{ type: Input }], nzIndex: [{ type: Input }] }; return NzMessageComponent; }()); export { NzMessageComponent }; if (false) { /** @type {?} */ NzMessageComponent.prototype.nzMessage; /** @type {?} */ NzMessageComponent.prototype.nzIndex; /** * @type {?} * @protected */ NzMessageComponent.prototype._options; /** * @type {?} * @private */ NzMessageComponent.prototype._autoErase; /** * @type {?} * @private */ NzMessageComponent.prototype._eraseTimer; /** * @type {?} * @private */ NzMessageComponent.prototype._eraseTimingStart; /** * @type {?} * @private */ NzMessageComponent.prototype._eraseTTL; /** * @type {?} * @private */ NzMessageComponent.prototype._messageContainer; /** * @type {?} * @protected */ NzMessageComponent.prototype.cdr; } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnotbWVzc2FnZS5jb21wb25lbnQuanMiLCJzb3VyY2VSb290Ijoibmc6Ly9uZy16b3Jyby1hbnRkLXlqLyIsInNvdXJjZXMiOlsibWVzc2FnZS9uei1tZXNzYWdlLmNvbXBvbmVudC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7O0FBQUEsT0FBTyxFQUNMLHVCQUF1QixFQUN2QixpQkFBaUIsRUFDakIsU0FBUyxFQUNULEtBQUssRUFHTCxpQkFBaUIsRUFDbEIsTUFBTSxlQUFlLENBQUM7QUFDdkIsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBQ3RELE9BQU8sRUFBRSwyQkFBMkIsRUFBRSxNQUFNLGtDQUFrQyxDQUFDO0FBRy9FO0lBbUJFLDRCQUFvQixpQkFBOEMsRUFBWSxHQUFzQjtRQUFoRixzQkFBaUIsR0FBakIsaUJBQWlCLENBQTZCO1FBQVksUUFBRyxHQUFILEdBQUcsQ0FBbUI7O1FBSjVGLGdCQUFXLEdBQWtCLElBQUksQ0FBQztJQUk2RCxDQUFDOzs7O0lBRXhHLHFDQUFROzs7SUFBUjtRQUNFLDJFQU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