UNPKG

ng-zorro-antd

Version:

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

23 lines (21 loc) 10.3 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("ng-zorro-antd/core"),require("@angular/cdk/overlay"),require("@angular/core"),require("rxjs"),require("@angular/common"),require("ng-zorro-antd/icon")):"function"==typeof define&&define.amd?define("ng-zorro-antd/message",["exports","ng-zorro-antd/core","@angular/cdk/overlay","@angular/core","rxjs","@angular/common","ng-zorro-antd/icon"],t):t(((e=e||self)["ng-zorro-antd"]=e["ng-zorro-antd"]||{},e["ng-zorro-antd"].message={}),e["ng-zorro-antd"].core,e.ng.cdk.overlay,e.ng.core,e.rxjs,e.ng.common,e["ng-zorro-antd"].icon)}(this,(function(e,t,n,o,s,i,r){"use strict"; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */var a=function(e,t){return(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};var c=function(){return(c=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var s in t=arguments[n])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e}).apply(this,arguments)};var g=0,p=function(){function e(e,t,n,o,s,i,r){void 0===r&&(r=""),this.nzSingletonService=e,this.overlay=t,this.containerClass=n,this.injector=o,this.cfr=s,this.appRef=i,this.name=r,this._container=this.withContainer(),this.nzSingletonService.registerSingletonWithKey(this.name,this._container)}return e.prototype.remove=function(e){e?this._container.removeMessage(e):this._container.removeMessageAll()},e.prototype.createMessage=function(e,t){var n=c({},e,{createdAt:new Date,messageId:this._generateMessageId(),options:t});return this._container.createMessage(n),n},e.prototype.config=function(e){t.warnDeprecation("'config' of 'NzMessageService' and 'NzNotificationService' is deprecated and will be removed in 9.0.0. Please use 'set' of 'NzConfigService' instead."),this._container.setConfig(e)},e.prototype._generateMessageId=function(){return this.name+"-"+g++},e.prototype.withContainer=function(){var e=this.nzSingletonService.getSingletonWithKey(this.name);if(e)return e;var t=this.cfr.resolveComponentFactory(this.containerClass).create(this.injector);t.changeDetectorRef.detectChanges(),this.appRef.attachView(t.hostView);var n=this.overlay.create().overlayElement;return n.style.zIndex="1010",n.appendChild(t.hostView.rootNodes[0]),t.instance},e}();var u=new o.InjectionToken("NZ_MESSAGE_DEFAULT_CONFIG"),h=new o.InjectionToken("NZ_MESSAGE_CONFIG"),f={provide:u,useValue:{nzAnimate:!0,nzDuration:3e3,nzMaxStack:7,nzPauseOnHover:!0,nzTop:24}},l=function(){function e(e,n,o,s){this.cdr=e,this.nzConfigService=n,this.messages=[],s&&t.warnDeprecation("Injection token 'NZ_MESSAGE_CONFIG' is deprecated and will be removed in 9.0.0. Please use 'NzConfigService' instead."),this.setConfig(c({},o,s))}return e.prototype.ngOnInit=function(){this.subscribeConfigChange()},e.prototype.setConfig=function(e){this.config=this.mergeMessageConfig(e),this.top=t.toCssPixel(this.config.nzTop),this.cdr.markForCheck()},e.prototype.createMessage=function(e){this.messages.length>=this.config.nzMaxStack&&this.messages.splice(0,1),e.options=this._mergeMessageOptions(e.options),e.onClose=new s.Subject,this.messages.push(e),this.cdr.detectChanges()},e.prototype.removeMessage=function(e,t){var n=this;void 0===t&&(t=!1),this.messages.some((function(o,s){return o.messageId===e&&(n.messages.splice(s,1),n.cdr.detectChanges(),o.onClose.next(t),o.onClose.complete(),!0)}))},e.prototype.removeMessageAll=function(){this.messages=[],this.cdr.detectChanges()},e.prototype.subscribeConfigChange=function(){var e=this;this.nzConfigService.getConfigChangeEventForComponent("message").subscribe((function(){return e.setConfig()}))},e.prototype.mergeMessageConfig=function(e){return c({},this.config,e,this.nzConfigService.getConfigForComponent("message"))},e.prototype._mergeMessageOptions=function(e){var t={nzDuration:this.config.nzDuration,nzAnimate:this.config.nzAnimate,nzPauseOnHover:this.config.nzPauseOnHover};return c({},t,e)},e.decorators=[{type:o.Component,args:[{changeDetection:o.ChangeDetectionStrategy.OnPush,encapsulation:o.ViewEncapsulation.None,selector:"nz-message-container",exportAs:"nzMessageContainer",preserveWhitespaces:!1,template:'<div class="ant-message" [style.top]="top">\n <nz-message *ngFor="let message of messages; let i = index" [nzMessage]="message" [nzIndex]="i"></nz-message>\n</div>'}]}],e.ctorParameters=function(){return[{type:o.ChangeDetectorRef},{type:t.NzConfigService},{type:void 0,decorators:[{type:o.Optional},{type:o.Inject,args:[u]}]},{type:void 0,decorators:[{type:o.Optional},{type:o.Inject,args:[h]}]}]},e}();var m=function(){function e(){}return e.decorators=[{type:o.NgModule}],e}(),d=function(e){function s(t,n,o,s,i){return e.call(this,t,n,l,o,s,i,"message")||this}return function(e,t){function n(){this.constructor=e}a(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}(s,e),s.prototype.success=function(e,t){return this.createMessage({type:"success",content:e},t)},s.prototype.error=function(e,t){return this.createMessage({type:"error",content:e},t)},s.prototype.info=function(e,t){return this.createMessage({type:"info",content:e},t)},s.prototype.warning=function(e,t){return this.createMessage({type:"warning",content:e},t)},s.prototype.loading=function(e,t){return this.createMessage({type:"loading",content:e},t)},s.prototype.create=function(e,t,n){return this.createMessage({type:e,content:t},n)},s.decorators=[{type:o.Injectable,args:[{providedIn:m}]}],s.ctorParameters=function(){return[{type:t.NzSingletonService},{type:n.Overlay},{type:o.Injector},{type:o.ComponentFactoryResolver},{type:o.ApplicationRef}]},s.ngInjectableDef=o.ɵɵdefineInjectable({factory:function(){return new s(o.ɵɵinject(t.NzSingletonService),o.ɵɵinject(n.Overlay),o.ɵɵinject(o.INJECTOR),o.ɵɵinject(o.ComponentFactoryResolver),o.ɵɵinject(o.ApplicationRef))},token:s,providedIn:m}),s}(p),y=function(){function e(e,t){this._messageContainer=e,this.cdr=t,this._eraseTimer=null}return e.prototype.ngOnInit=function(){this._options=this.nzMessage.options,this._options.nzAnimate&&(this.nzMessage.state="enter"),this._autoErase=this._options.nzDuration>0,this._autoErase&&(this._initErase(),this._startEraseTimeout())},e.prototype.ngOnDestroy=function(){this._autoErase&&this._clearEraseTimeout()},e.prototype.onEnter=function(){this._autoErase&&this._options.nzPauseOnHover&&(this._clearEraseTimeout(),this._updateTTL())},e.prototype.onLeave=function(){this._autoErase&&this._options.nzPauseOnHover&&this._startEraseTimeout()},e.prototype._destroy=function(e){var t=this;void 0===e&&(e=!1),this._options.nzAnimate?(this.nzMessage.state="leave",this.cdr.detectChanges(),setTimeout((function(){return t._messageContainer.removeMessage(t.nzMessage.messageId,e)}),200)):this._messageContainer.removeMessage(this.nzMessage.messageId,e)},e.prototype._initErase=function(){this._eraseTTL=this._options.nzDuration,this._eraseTimingStart=Date.now()},e.prototype._updateTTL=function(){this._autoErase&&(this._eraseTTL-=Date.now()-this._eraseTimingStart)},e.prototype._startEraseTimeout=function(){var e=this;this._eraseTTL>0?(this._clearEraseTimeout(),this._eraseTimer=setTimeout((function(){return e._destroy()}),this._eraseTTL),this._eraseTimingStart=Date.now()):this._destroy()},e.prototype._clearEraseTimeout=function(){null!==this._eraseTimer&&(clearTimeout(this._eraseTimer),this._eraseTimer=null)},e.decorators=[{type:o.Component,args:[{changeDetection:o.ChangeDetectionStrategy.OnPush,encapsulation:o.ViewEncapsulation.None,selector:"nz-message",exportAs:"nzMessage",preserveWhitespaces:!1,animations:[t.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 nzType="check-circle"></i>\n <i *ngSwitchCase="\'info\'" nz-icon nzType="info-circle"></i>\n <i *ngSwitchCase="\'warning\'" nz-icon nzType="exclamation-circle"></i>\n <i *ngSwitchCase="\'error\'" nz-icon nzType="close-circle"></i>\n <i *ngSwitchCase="\'loading\'" nz-icon nzType="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'}]}],e.ctorParameters=function(){return[{type:l},{type:o.ChangeDetectorRef}]},e.propDecorators={nzMessage:[{type:o.Input}],nzIndex:[{type:o.Input}]},e}();var v=function(){function e(){}return e.decorators=[{type:o.NgModule,args:[{imports:[i.CommonModule,n.OverlayModule,r.NzIconModule,t.NzAddOnModule,m],declarations:[l,y],providers:[f],entryComponents:[l]}]}],e}(); /** * @license * Copyright Alibaba.com All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE */e.NZ_MESSAGE_CONFIG=h,e.NZ_MESSAGE_DEFAULT_CONFIG=u,e.NZ_MESSAGE_DEFAULT_CONFIG_PROVIDER=f,e.NzMessageBaseService=p,e.NzMessageComponent=y,e.NzMessageContainerComponent=l,e.NzMessageModule=v,e.NzMessageService=d,e.NzMessageServiceModule=m,Object.defineProperty(e,"__esModule",{value:!0})})); //# sourceMappingURL=ng-zorro-antd-message.umd.min.js.map