wsuite-notification
Version:
Toast notification for angular 2,4,5,6,7,8+ version.
16 lines (14 loc) • 10.8 kB
JavaScript
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports,require("@angular/core"),require("rxjs"),require("@angular/platform-browser"),require("@angular/animations"),require("@angular/common")):"function"==typeof define&&define.amd?define("wsuite-notification",["exports","@angular/core","rxjs","@angular/platform-browser","@angular/animations","@angular/common"],i):i((t=t||self)["wsuite-notification"]={},t.ng.core,t.rxjs,t.ng.platformBrowser,t.ng.animations,t.ng.common)}(this,(function(t,i,e,n,o,s){"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.
***************************************************************************** */function r(t,i,e,n){var o,s=arguments.length,r=s<3?i:null===n?n=Object.getOwnPropertyDescriptor(i,e):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,i,e,n);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(r=(s<3?o(r):s>3?o(i,e,r):o(i,e))||r);return s>3&&r&&Object.defineProperty(i,e,r),r}var a,c=function(t,i,e,n,o){this.id=t,this.type=i,this.title=e,this.message=n,this.timeout=o};!function(t){t[t.success=0]="success",t[t.warning=1]="warning",t[t.error=2]="error",t[t.info=3]="info",t[t.darkgray=4]="darkgray",t[t.blue=5]="blue"}(a||(a={}));var u=function(t){void 0===t&&(t=3e3),this.timeout=t},M=function(){function t(t){this.notificationSubject=new e.Subject,this.nidx=0,this.timeout=3e3,void 0!==t&&(this.timeout=void 0!==t.timeout?t.timeout:3e3)}var n,o;return t.prototype.getObservable=function(){return this.notificationSubject.asObservable()},t.prototype.info=function(t,i,e){void 0===e&&(e=this.timeout),this.notificationSubject.next(new c(this.nidx++,a.info,t,i,e))},t.prototype.success=function(t,i,e){void 0===e&&(e=this.timeout),this.notificationSubject.next(new c(this.nidx++,a.success,t,i,e))},t.prototype.warning=function(t,i,e){void 0===e&&(e=this.timeout),this.notificationSubject.next(new c(this.nidx++,a.warning,t,i,e))},t.prototype.error=function(t,i,e){void 0===e&&(e=this.timeout),this.notificationSubject.next(new c(this.nidx++,a.error,t,i,e))},t.prototype.darkgray=function(t,i,e){void 0===e&&(e=this.timeout),this.notificationSubject.next(new c(this.nidx++,a.darkgray,t,i,e))},t.prototype.blue=function(t,i,e){void 0===e&&(e=this.timeout),this.notificationSubject.next(new c(this.nidx++,a.blue,t,i,e))},t.ctorParameters=function(){return[{type:u,decorators:[{type:i.Optional}]}]},t.ɵprov=i.ɵɵdefineInjectable({factory:function(){return new t(i.ɵɵinject(u,8))},token:t,providedIn:"root"}),t=r([i.Injectable({providedIn:"root"}),(n=0,o=i.Optional(),function(t,i){o(t,i,n)})],t)}(),w=function(){function t(t,i){this.notificationSvc=t,this.domSanitizer=i,this.notifications=[]}return t.prototype._addNotification=function(t){var i=this;this.notifications.push(t),0!==t.timeout&&setTimeout((function(){return i.close(t)}),t.timeout)},t.prototype.ngOnInit=function(){var t=this;this.subscription=this.notificationSvc.getObservable().subscribe((function(i){return t._addNotification(i)}))},t.prototype.ngOnDestroy=function(){this.subscription.unsubscribe()},t.prototype.close=function(t){this.notifications=this.notifications.filter((function(i){return i.id!==t.id}))},t.prototype.className=function(t){var i;switch(t.type){case a.success:i="wsuite-alert-success";break;case a.warning:i="wsuite-alert-warning";break;case a.error:i="wsuite-alert-error";break;case a.darkgray:i="wsuite-alert-darkgray";break;case a.blue:i="wsuite-alert-blue";break;default:i="info"}return i},t.prototype.setIcon=function(t){var i;switch(t.type){case a.success:i="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNCIgaGVpZ2h0PSIxMC43NjkiIHZpZXdCb3g9IjAgMCAxNCAxMC43NjkiPjxkZWZzPjxzdHlsZT4uYXtmaWxsOiNmZmY7fTwvc3R5bGU+PC9kZWZzPjxwYXRoIGNsYXNzPSJhIiBkPSJNLjE2Miw4LjkyM2EuNTIxLjUyMSwwLDAsMSwwLS43NTRsLjc1NC0uNzU0YS41MjEuNTIxLDAsMCwxLC43NTQsMGwuMDU0LjA1NCwyLjk2MiwzLjE3N2EuMjYuMjYsMCwwLDAsLjM3NywwbDcuMjE1LTcuNDg1aC4wNTRhLjUyMS41MjEsMCwwLDEsLjc1NCwwbC43NTQuNzU0YS41MjEuNTIxLDAsMCwxLDAsLjc1NGgwTDUuMjIzLDEzLjYwOGEuNTIxLjUyMSwwLDAsMS0uNzU0LDBMLjI2OSw5LjA4NS4xNjIsOC45MjNaIiB0cmFuc2Zvcm09InRyYW5zbGF0ZSgwIC0zKSIvPjwvc3ZnPg==";break;case a.warning:i="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxOCIgaGVpZ2h0PSIxNS40NzkiIHZpZXdCb3g9IjAgMCAxOCAxNS40NzkiPjxkZWZzPjxzdHlsZT4uYXtmaWxsOiNmZmY7fTwvc3R5bGU+PC9kZWZzPjxnIHRyYW5zZm9ybT0idHJhbnNsYXRlKDAgLTM1Ljg1NykiPjxnIHRyYW5zZm9ybT0idHJhbnNsYXRlKDAgMzUuODU3KSI+PHBhdGggY2xhc3M9ImEiIGQ9Ik0xNy43NjgsNDguODg0LDEwLjM4NCwzNi42M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NTkyLDUuNTkyLDAsMCwwLTEuNzUxLjc4M0wyNyw3LjMzN0E5Ljc4Miw5Ljc4MiwwLDAsMSwzMS43NjEsNC45MWMuNzQsMCwuODY0Ljg5MS40OTMsMi4yNjFsLS45NzMsMy43NDZjLS4xNzMuNjYyLS4xLjg5LjA3NC44OWEzLjgxMywzLjgxMywwLDAsMCwxLjY2NS0uODQ2bC40Mi41NzFBNy43LDcuNywwLDAsMSwyOS4wMzYsMTRaIiB0cmFuc2Zvcm09InRyYW5zbGF0ZSgtMjcpIi8+PC9nPjwvZz48L3N2Zz4="}return this.domSanitizer.bypassSecurityTrustResourceUrl(i)},t.ctorParameters=function(){return[{type:M},{type:n.DomSanitizer}]},t=r([i.Component({selector:"wsuite-notification",template:'<div class="wsuite-notifications">\n <div class="wsuite-alert wsuite-alert-dismissible w-350" [ngClass]="className(notification)"\n *ngFor="let notification of notifications" role="wsuite-alert" @fade>\n <span class="info"> <img [src]="setIcon(notification)" alt=""> </span>\n <div class="wsuite-alert-body">\n <p class="n1">{{notification.title}}</p>\n <small [innerHtml]="notification.message | wsuiteSafeHtml"></small>\n </div>\n <button type="button" class="close" (click)="close(notification)" aria-label="Close"> <span\n aria-hidden="true">×</span>\n </button>\n </div>\n</div>',animations:[o.trigger("fade",[o.transition("void => *",[o.style({opacity:0}),o.animate(500,o.style({opacity:1}))]),o.transition("* => void",[o.style({opacity:1}),o.animate(500,o.style({opacity:0}))])])],styles:[".wsuite-notifications{position:fixed;top:60px;right:0;z-index:99999999;left:50%;margin-left:-175px}.wsuite-alert .info{width:39px;display:flex;align-items:center;justify-content:center}.wsuite-alert-body{padding:4px 34px 4px 13px;flex:1;display:flex;flex-direction:column;justify-content:center}.wsuite-alert-body p{line-height:17px}.wsuite-alert-body small{font-size:10px;color:#868686;line-height:14px;display:block}.wsuite-alert{display:flex;align-items:stretch;box-shadow:0 3px 6px rgba(0,0,0,.16);margin:5px;left:50%;background-color:#fff;border-radius:.25rem;min-height:40px}.wsuite-alert .close{align-self:flex-start;margin-right:5px}.wsuite-alert-darkgray{border:1px solid #404040;padding:0}.wsuite-alert-darkgray .info{background-color:#404040}.wsuite-alert-blue{border:1px solid #41a3f3;padding:0}.wsuite-alert-blue .info{background-color:#41a3f3}.wsuite-alert-warning{border:1px solid #f5b829;padding:0}.wsuite-alert-warning .info{background-color:#f5b829}.wsuite-alert-error{border:1px solid #ff5c5c;padding:0}.wsuite-alert-error .info{background-color:#ff5c5c}.wsuite-alert-success{border:1px solid #5abe2b;padding:0}.wsuite-alert-success .info{background-color:#5abe2b}.w-250{max-width:250px}.w-350{max-width:350px}.wsuite-alert-example .wsuite-alert{margin-bottom:38px}"]})],t)}(),l=function(){function t(t){this.sanitized=t}return t.prototype.transform=function(t){return this.sanitized.bypassSecurityTrustHtml(t)},t.ctorParameters=function(){return[{type:n.DomSanitizer}]},t=r([i.Pipe({name:"wsuiteSafeHtml"})],t)}(),d=function(){function t(){}var e;return e=t,t.forRoot=function(t){return{ngModule:e,providers:[{provide:u,useValue:t}]}},t=e=r([i.NgModule({declarations:[w,l],imports:[s.CommonModule],providers:[M],exports:[w,l]})],t)}();t.NotificationComponent=w,t.NotificationService=M,t.WsuiteNotificationModule=d,t.ɵa=u,t.ɵb=l,Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=wsuite-notification.umd.min.js.map