ng-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
16 lines (14 loc) • 13.2 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/bidi"),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/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/bidi","@angular/cdk/overlay","@angular/common","ng-zorro-antd/core/outlet","ng-zorro-antd/icon","ng-zorro-antd/core/config","ng-zorro-antd/core/util","rxjs","rxjs/operators","ng-zorro-antd/core/services"],t):t(((n="undefined"!=typeof globalThis?globalThis: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.bidi,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.util,n.rxjs,n.rxjs.operators,n["ng-zorro-antd"].core.services)}(this,(function(n,t,e,o,i,c,r,a,s,l,p,f,u,g){"use strict";
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */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)Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e])})(n,t)};function m(n,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function e(){this.constructor=n}d(n,t),n.prototype=null===t?Object.create(t):(e.prototype=t.prototype,new e)}Object.create;function y(n,t){var e="function"==typeof Symbol&&n[Symbol.iterator];if(!e)return n;var o,i,c=e.call(n),r=[];try{for(;(void 0===t||t-- >0)&&!(o=c.next()).done;)r.push(o.value)}catch(n){i={error:n}}finally{try{o&&!o.done&&(e=c.return)&&e.call(c)}finally{if(i)throw i.error}}return r}Object.create;var h=function(n){function e(e){var o=n.call(this,e)||this;return o.destroyed=new t.EventEmitter,o}return m(e,n),e.prototype.ngOnDestroy=function(){n.prototype.ngOnDestroy.call(this),this.instance.onClick.complete()},e.prototype.onClick=function(n){this.instance.onClick.next(n)},e.prototype.close=function(){this.destroy(!0)},Object.defineProperty(e.prototype,"state",{get:function(){return"enter"===this.instance.state?"topLeft"===this.placement||"bottomLeft"===this.placement?"enterLeft":"enterRight":this.instance.state},enumerable:!1,configurable:!0}),e}(o.NzMNComponent);h.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 || null"\n [ngClass]="instance.options?.nzClass || \'\'"\n [@notificationMotion]="state"\n (@notificationMotion.done)="animationStateChanged.next($event)"\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 ></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; let closeIcon">\n <i nz-icon [nzType]="closeIcon"></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 '}]}],h.ctorParameters=function(){return[{type:t.ChangeDetectorRef}]},h.propDecorators={instance:[{type:t.Input}],placement:[{type:t.Input}],index:[{type:t.Input}],destroyed:[{type:t.Output}]};var z="notification",v={nzTop:"24px",nzBottom:"24px",nzPlacement:"topRight",nzDuration:4500,nzMaxStack:7,nzPauseOnHover:!0,nzAnimate:!0,nzDirection:"ltr"},C=function(n){function t(t,e){var o=n.call(this,t,e)||this;o.dir="ltr",o.instances=[],o.topLeftInstances=[],o.topRightInstances=[],o.bottomLeftInstances=[],o.bottomRightInstances=[];var i=o.nzConfigService.getConfigForComponent(z);return o.dir=(null==i?void 0:i.nzDirection)||"ltr",o}return m(t,n),t.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(y(arguments[t]));return n}(this.instances,[t])),this.readyInstances(),t},t.prototype.onCreate=function(n){return n.options=this.mergeOptions(n.options),n.onClose=new f.Subject,n.onClick=new f.Subject,n},t.prototype.subscribeConfigChange=function(){var n=this;this.nzConfigService.getConfigChangeEventForComponent(z).pipe(u.takeUntil(this.destroy$)).subscribe((function(){n.updateConfig();var t=n.nzConfigService.getConfigForComponent(z);if(t){var e=t.nzDirection;n.dir=e||n.dir}}))},t.prototype.updateConfig=function(){this.config=Object.assign(Object.assign(Object.assign({},v),this.config),this.nzConfigService.getConfigForComponent(z)),this.top=p.toCssPixel(this.config.nzTop),this.bottom=p.toCssPixel(this.config.nzBottom),this.cdr.markForCheck()},t.prototype.replaceNotification=function(n,t){n.title=t.title,n.content=t.content,n.template=t.template,n.type=t.type,n.options=t.options},t.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()},t.prototype.mergeOptions=function(n){var t=this.config,e=t.nzDuration,o=t.nzAnimate,i=t.nzPauseOnHover,c=t.nzPlacement;return Object.assign({nzDuration:e,nzAnimate:o,nzPauseOnHover:i,nzPlacement:c},n)},t}(o.NzMNContainerComponent);C.decorators=[{type:t.Component,args:[{changeDetection:t.ChangeDetectionStrategy.OnPush,encapsulation:t.ViewEncapsulation.None,selector:"nz-notification-container",exportAs:"nzNotificationContainer",preserveWhitespaces:!1,template:'\n <div\n class="ant-notification ant-notification-topLeft"\n [class.ant-notification-rtl]="dir === \'rtl\'"\n [style.top]="top"\n [style.left]="\'0px\'"\n >\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\n class="ant-notification ant-notification-topRight"\n [class.ant-notification-rtl]="dir === \'rtl\'"\n [style.top]="top"\n [style.right]="\'0px\'"\n >\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\n class="ant-notification ant-notification-bottomLeft"\n [class.ant-notification-rtl]="dir === \'rtl\'"\n [style.bottom]="bottom"\n [style.left]="\'0px\'"\n >\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\n class="ant-notification ant-notification-bottomRight"\n [class.ant-notification-rtl]="dir === \'rtl\'"\n [style.bottom]="bottom"\n [style.right]="\'0px\'"\n >\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 '}]}],C.ctorParameters=function(){return[{type:t.ChangeDetectorRef},{type:l.NzConfigService}]};var b=function(){};b.decorators=[{type:t.NgModule}];var I=function(){};I.decorators=[{type:t.NgModule,args:[{imports:[i.BidiModule,r.CommonModule,c.OverlayModule,s.NzIconModule,a.NzOutletModule,b],declarations:[h,C],entryComponents:[C]}]}];var x=0,O=function(n){function t(t,e,o){var i=n.call(this,t,e,o)||this;return i.componentPrefix="notification-",i}return m(t,n),t.prototype.success=function(n,t,e){return this.createInstance({type:"success",title:n,content:t},e)},t.prototype.error=function(n,t,e){return this.createInstance({type:"error",title:n,content:t},e)},t.prototype.info=function(n,t,e){return this.createInstance({type:"info",title:n,content:t},e)},t.prototype.warning=function(n,t,e){return this.createInstance({type:"warning",title:n,content:t},e)},t.prototype.blank=function(n,t,e){return this.createInstance({type:"blank",title:n,content:t},e)},t.prototype.create=function(n,t,e,o){return this.createInstance({type:n,title:t,content:e},o)},t.prototype.template=function(n,t){return this.createInstance({template:n},t)},t.prototype.generateMessageId=function(){return this.componentPrefix+"-"+x++},t.prototype.createInstance=function(n,t){return this.container=this.withContainer(C),this.container.create(Object.assign(Object.assign({},n),{createdAt:new Date,messageId:this.generateMessageId(),options:t}))},t}(o.NzMNService);O.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new O(t.ɵɵinject(g.NzSingletonService),t.ɵɵinject(c.Overlay),t.ɵɵinject(t.INJECTOR))},token:O,providedIn:b}),O.decorators=[{type:t.Injectable,args:[{providedIn:b}]}],O.ctorParameters=function(){return[{type:g.NzSingletonService},{type:c.Overlay},{type:t.Injector}]},n.NzNotificationComponent=h,n.NzNotificationContainerComponent=C,n.NzNotificationModule=I,n.NzNotificationService=O,n.NzNotificationServiceModule=b,Object.defineProperty(n,"__esModule",{value:!0})}));
//# sourceMappingURL=ng-zorro-antd-notification.umd.min.js.map