ng-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
16 lines (14 loc) • 12.7 kB
JavaScript
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("ng-zorro-antd/core/animation"),require("ng-zorro-antd/message"),require("@angular/cdk/overlay"),require("@angular/common"),require("ng-zorro-antd/core/outlet"),require("ng-zorro-antd/icon"),require("ng-zorro-antd/core/config"),require("ng-zorro-antd/core/logger"),require("ng-zorro-antd/core/util"),require("rxjs"),require("rxjs/operators"),require("ng-zorro-antd/core/services")):"function"==typeof define&&define.amd?define("ng-zorro-antd/notification",["exports","@angular/core","ng-zorro-antd/core/animation","ng-zorro-antd/message","@angular/cdk/overlay","@angular/common","ng-zorro-antd/core/outlet","ng-zorro-antd/icon","ng-zorro-antd/core/config","ng-zorro-antd/core/logger","ng-zorro-antd/core/util","rxjs","rxjs/operators","ng-zorro-antd/core/services"],t):t(((n=n||self)["ng-zorro-antd"]=n["ng-zorro-antd"]||{},n["ng-zorro-antd"].notification={}),n.ng.core,n["ng-zorro-antd"].core.animation,n["ng-zorro-antd"].message,n.ng.cdk.overlay,n.ng.common,n["ng-zorro-antd"].core.outlet,n["ng-zorro-antd"].icon,n["ng-zorro-antd"].core.config,n["ng-zorro-antd"].core.logger,n["ng-zorro-antd"].core.util,n.rxjs,n.rxjs.operators,n["ng-zorro-antd"].core.services)}(this,(function(n,t,e,o,i,r,c,a,s,p,l,f,u,g){"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 d=function(n,t){return(d=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var e in t)t.hasOwnProperty(e)&&(n[e]=t[e])})(n,t)};function m(n,t){function e(){this.constructor=n}d(n,t),n.prototype=null===t?Object.create(t):(e.prototype=t.prototype,new e)}var y=function(){return(y=Object.assign||function(n){for(var t,e=1,o=arguments.length;e<o;e++)for(var i in t=arguments[e])Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i]);return n}).apply(this,arguments)};function z(n,t){var e="function"==typeof Symbol&&n[Symbol.iterator];if(!e)return n;var o,i,r=e.call(n),c=[];try{for(;(void 0===t||t-- >0)&&!(o=r.next()).done;)c.push(o.value)}catch(n){i={error:n}}finally{try{o&&!o.done&&(e=r.return)&&e.call(r)}finally{if(i)throw i.error}}return c}var h=function(n){function o(e){var o=n.call(this,e)||this;return o.destroyed=new t.EventEmitter,o}return m(o,n),o.prototype.ngOnDestroy=function(){n.prototype.ngOnDestroy.call(this),this.instance.onClick.complete()},o.prototype.onClick=function(n){this.instance.onClick.next(n)},o.prototype.close=function(){this.destroy(!0)},Object.defineProperty(o.prototype,"state",{get:function(){return"enter"===this.instance.state?"topLeft"===this.placement||"bottomLeft"===this.placement?"enterLeft":"enterRight":this.instance.state},enumerable:!0,configurable:!0}),o.decorators=[{type:t.Component,args:[{encapsulation:t.ViewEncapsulation.None,selector:"nz-notification",exportAs:"nzNotification",preserveWhitespaces:!1,animations:[e.notificationMotion],template:'\n <div\n class="ant-notification-notice ant-notification-notice-closable"\n [ngStyle]="instance.options?.nzStyle"\n [ngClass]="instance.options?.nzClass"\n [@notificationMotion]="state"\n (click)="onClick($event)"\n (mouseenter)="onEnter()"\n (mouseleave)="onLeave()"\n >\n <div *ngIf="!instance.template" class="ant-notification-notice-content">\n <div class="ant-notification-notice-content" [ngClass]="{ \'ant-notification-notice-with-icon\': instance.type !== \'blank\' }">\n <div [class.ant-notification-notice-with-icon]="instance.type !== \'blank\'">\n <ng-container [ngSwitch]="instance.type">\n <i\n *ngSwitchCase="\'success\'"\n nz-icon\n nzType="check-circle"\n class="ant-notification-notice-icon ant-notification-notice-icon-success"\n ></i>\n <i\n *ngSwitchCase="\'info\'"\n nz-icon\n nzType="info-circle"\n class="ant-notification-notice-icon ant-notification-notice-icon-info"\n ></i>\n <i\n *ngSwitchCase="\'warning\'"\n nz-icon\n nzType="exclamation-circle"\n class="ant-notification-notice-icon ant-notification-notice-icon-warning"\n ></i>\n <i\n *ngSwitchCase="\'error\'"\n nz-icon\n nzType="close-circle"\n class="ant-notification-notice-icon ant-notification-notice-icon-error"\n ></i>\n </ng-container>\n <div class="ant-notification-notice-message" [innerHTML]="instance.title"></div>\n <div class="ant-notification-notice-description" [innerHTML]="instance.content"></div>\n </div>\n </div>\n </div>\n <ng-template\n [ngIf]="instance.template"\n [ngTemplateOutlet]="instance.template"\n [ngTemplateOutletContext]="{ $implicit: this, data: instance.options?.nzData }"\n >\n </ng-template>\n <a tabindex="0" class="ant-notification-notice-close" (click)="close()">\n <span class="ant-notification-notice-close-x">\n <ng-container *ngIf="instance.options?.nzCloseIcon; else iconTpl">\n <ng-container *nzStringTemplateOutlet="instance.options?.nzCloseIcon">\n <i nz-icon [nzType]="instance.options?.nzCloseIcon"></i>\n </ng-container>\n </ng-container>\n <ng-template #iconTpl>\n <i nz-icon nzType="close" class="ant-notification-close-icon"></i>\n </ng-template>\n </span>\n </a>\n </div>\n '}]}],o.ctorParameters=function(){return[{type:t.ChangeDetectorRef}]},o.propDecorators={instance:[{type:t.Input}],placement:[{type:t.Input}],index:[{type:t.Input}],destroyed:[{type:t.Output}]},o}(o.NzMNComponent);var v={nzTop:"24px",nzBottom:"24px",nzPlacement:"topRight",nzDuration:4500,nzMaxStack:7,nzPauseOnHover:!0,nzAnimate:!0},C=function(n){function e(t,e){var o=n.call(this,t,e)||this;return o.instances=[],o.topLeftInstances=[],o.topRightInstances=[],o.bottomLeftInstances=[],o.bottomRightInstances=[],o}return m(e,n),e.prototype.create=function(n){var t=this.onCreate(n),e=t.options.nzKey,o=this.instances.find((function(t){return t.options.nzKey===n.options.nzKey}));return e&&o?this.replaceNotification(o,t):(this.instances.length>=this.config.nzMaxStack&&(this.instances=this.instances.slice(1)),this.instances=function(){for(var n=[],t=0;t<arguments.length;t++)n=n.concat(z(arguments[t]));return n}(this.instances,[t])),this.readyInstances(),t},e.prototype.onCreate=function(n){return n.options=this.mergeOptions(n.options),n.onClose=new f.Subject,n.onClick=new f.Subject,n},e.prototype.subscribeConfigChange=function(){var n=this;this.nzConfigService.getConfigChangeEventForComponent("notification").pipe(u.takeUntil(this.destroy$)).subscribe((function(){return n.updateConfig()}))},e.prototype.updateConfig=function(){this.config=y(y(y({},v),this.config),this.nzConfigService.getConfigForComponent("notification")),this.top=l.toCssPixel(this.config.nzTop),this.bottom=l.toCssPixel(this.config.nzBottom),this.cdr.markForCheck()},e.prototype.replaceNotification=function(n,t){n.title=t.title,n.content=t.content,n.template=t.template,n.type=t.type},e.prototype.readyInstances=function(){this.topLeftInstances=this.instances.filter((function(n){return"topLeft"===n.options.nzPlacement})),this.topRightInstances=this.instances.filter((function(n){return"topRight"===n.options.nzPlacement||!n.options.nzPlacement})),this.bottomLeftInstances=this.instances.filter((function(n){return"bottomLeft"===n.options.nzPlacement})),this.bottomRightInstances=this.instances.filter((function(n){return"bottomRight"===n.options.nzPlacement})),this.cdr.detectChanges()},e.prototype.mergeOptions=function(n){var t=(null!=n?n:{}).nzPosition;t&&p.warnDeprecation("`nzPosition` of NzNotificationDataOptions is deprecated and would be removed in 10.0.0. Use `nzPlacement` instead.");var e=this.config,o=e.nzDuration,i=e.nzAnimate,r=e.nzPauseOnHover,c=e.nzPlacement;return y({nzDuration:o,nzAnimate:i,nzPauseOnHover:r,nzPlacement:c||t},n)},e.decorators=[{type:t.Component,args:[{changeDetection:t.ChangeDetectionStrategy.OnPush,encapsulation:t.ViewEncapsulation.None,selector:"nz-notification-container",exportAs:"nzNotificationContainer",preserveWhitespaces:!1,template:'\n <div class="ant-notification ant-notification-topLeft" [style.top]="top" [style.left]="\'0px\'">\n <nz-notification\n *ngFor="let instance of topLeftInstances"\n [instance]="instance"\n [placement]="config.nzPlacement"\n (destroyed)="remove($event.id, $event.userAction)"\n ></nz-notification>\n </div>\n <div class="ant-notification ant-notification-topRight" [style.top]="top" [style.right]="\'0px\'">\n <nz-notification\n *ngFor="let instance of topRightInstances"\n [instance]="instance"\n [placement]="config.nzPlacement"\n (destroyed)="remove($event.id, $event.userAction)"\n ></nz-notification>\n </div>\n <div class="ant-notification ant-notification-bottomLeft" [style.bottom]="bottom" [style.left]="\'0px\'">\n <nz-notification\n *ngFor="let instance of bottomLeftInstances"\n [instance]="instance"\n [placement]="config.nzPlacement"\n (destroyed)="remove($event.id, $event.userAction)"\n ></nz-notification>\n </div>\n <div class="ant-notification ant-notification-bottomRight" [style.bottom]="bottom" [style.right]="\'0px\'">\n <nz-notification\n *ngFor="let instance of bottomRightInstances"\n [instance]="instance"\n [placement]="config.nzPlacement"\n (destroyed)="remove($event.id, $event.userAction)"\n ></nz-notification>\n </div>\n '}]}],e.ctorParameters=function(){return[{type:t.ChangeDetectorRef},{type:s.NzConfigService}]},e}(o.NzMNContainerComponent);var b=function(){function n(){}return n.decorators=[{type:t.NgModule}],n}(),I=function(){function n(){}return n.decorators=[{type:t.NgModule,args:[{imports:[r.CommonModule,i.OverlayModule,a.NzIconModule,c.NzOutletModule,b],declarations:[h,C],entryComponents:[C]}]}],n}();var N=0,P=function(n){function e(t,e,o){var i=n.call(this,t,e,o)||this;return i.componentPrefix="notification-",i}return m(e,n),e.prototype.success=function(n,t,e){return this.createInstance({type:"success",title:n,content:t},e)},e.prototype.error=function(n,t,e){return this.createInstance({type:"error",title:n,content:t},e)},e.prototype.info=function(n,t,e){return this.createInstance({type:"info",title:n,content:t},e)},e.prototype.warning=function(n,t,e){return this.createInstance({type:"warning",title:n,content:t},e)},e.prototype.blank=function(n,t,e){return this.createInstance({type:"blank",title:n,content:t},e)},e.prototype.create=function(n,t,e,o){return this.createInstance({type:n,title:t,content:e},o)},e.prototype.template=function(n,t){return this.createInstance({template:n},t)},e.prototype.generateMessageId=function(){return this.componentPrefix+"-"+N++},e.prototype.createInstance=function(n,t){return this.container=this.withContainer(C),this.container.create(y(y({},n),{createdAt:new Date,messageId:this.generateMessageId(),options:t}))},e.decorators=[{type:t.Injectable,args:[{providedIn:b}]}],e.ctorParameters=function(){return[{type:g.NzSingletonService},{type:i.Overlay},{type:t.Injector}]},e.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e(t.ɵɵinject(g.NzSingletonService),t.ɵɵinject(i.Overlay),t.ɵɵinject(t.INJECTOR))},token:e,providedIn:b}),e}(o.NzMNService);n.NzNotificationComponent=h,n.NzNotificationContainerComponent=C,n.NzNotificationModule=I,n.NzNotificationService=P,n.NzNotificationServiceModule=b,Object.defineProperty(n,"__esModule",{value:!0})}));
//# sourceMappingURL=ng-zorro-antd-notification.umd.min.js.map