UNPKG

angular9-notifications-gpu

Version:

> A light and easy to use notifications library for Angular 2. ~~It features both regular page notifications (toasts) and push notifications.~~

688 lines (672 loc) 40.2 kB
(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/animations'), require('@angular/platform-browser'), require('rxjs'), require('@angular/common'), require('@angular/core')) : typeof define === 'function' && define.amd ? define('angular9-notifications-gpu', ['exports', '@angular/animations', '@angular/platform-browser', 'rxjs', '@angular/common', '@angular/core'], factory) : (factory((global['angular9-notifications-gpu'] = {}),global.ng.animations,global.ng.platformBrowser,global.rxjs,global.ng.common,global.ng.core)); }(this, (function (exports,animations,platformBrowser,rxjs,common,core) { 'use strict'; var DEFAULT_ICONS = { alert: "\n <svg class=\"simple-notification-svg\" xmlns=\"http://www.w3.org/2000/svg\" fill=\"#ffffff\" height=\"24\" viewBox=\"0 0 24 24\" width=\"24\">\n <path d=\"M0 0h24v24H0z\" fill=\"none\"/>\n <path d=\"M22 5.72l-4.6-3.86-1.29 1.53 4.6 3.86L22 5.72zM7.88 3.39L6.6 1.86 2 5.71l1.29 1.53 4.59-3.85zM12.5 8H11v6l4.75 2.85.75-1.23-4-2.37V8zM12 4c-4.97 0-9 4.03-9 9s4.02 9 9 9c4.97 0 9-4.03 9-9s-4.03-9-9-9zm0 16c-3.87 0-7-3.13-7-7s3.13-7 7-7 7 3.13 7 7-3.13 7-7 7z\"/>\n </svg>\n ", error: "\n <svg class=\"simple-notification-svg\" xmlns=\"http://www.w3.org/2000/svg\" fill=\"#ffffff\" height=\"24\" viewBox=\"0 0 24 24\" width=\"24\">\n <path d=\"M0 0h24v24H0V0z\" fill=\"none\"/>\n <path d=\"M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z\"/>\n </svg>\n ", info: "\n <svg class=\"simple-notification-svg\" xmlns=\"http://www.w3.org/2000/svg\" fill=\"#ffffff\" height=\"24\" viewBox=\"0 0 24 24\" width=\"24\">\n <path d=\"M0 0h24v24H0z\" fill=\"none\"/>\n <path d=\"M11 17h2v-6h-2v6zm1-15C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zM11 9h2V7h-2v2z\"/>\n </svg>\n ", success: "\n <svg class=\"simple-notification-svg\" xmlns=\"http://www.w3.org/2000/svg\" fill=\"#ffffff\" height=\"24\" viewBox=\"0 0 24 24\" width=\"24\">\n <path d=\"M0 0h24v24H0z\" fill=\"none\"/>\n <path d=\"M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z\"/>\n </svg>\n ", warn: "\n <svg class=\"simple-notification-svg\" xmlns=\"http://www.w3.org/2000/svg\" fill=\"#ffffff\" width=\"64\" viewBox=\"0 0 64 64\" height=\"64\">\n <circle cx=\"32.086\" cy=\"50.142\" r=\"2.256\"/>\n <path d=\"M30.08 25.012V42.32c0 1.107.897 2.005 2.006 2.005s2.006-.897 2.006-2.005V25.012c0-1.107-.897-2.006-2.006-2.006s-2.006.898-2.006 2.006z\"/>\n <path d=\"M63.766 59.234L33.856 3.082c-.697-1.308-2.844-1.308-3.54 0L.407 59.234c-.331.622-.312 1.372.051 1.975.362.605 1.015.975 1.72.975h59.816c.705 0 1.357-.369 1.721-.975.361-.603.381-1.353.051-1.975zM5.519 58.172L32.086 8.291l26.568 49.881H5.519z\"/>\n </svg>\n " }; (function (NotificationType) { NotificationType["Success"] = "success"; NotificationType["Error"] = "error"; NotificationType["Alert"] = "alert"; NotificationType["Info"] = "info"; NotificationType["Warn"] = "warn"; NotificationType["Bare"] = "bare"; })(exports.NotificationType || (exports.NotificationType = {})); var NotificationsService = /** @class */ (function () { function NotificationsService(globalOptions) { this.globalOptions = globalOptions; this.emitter = new rxjs.Subject(); this.icons = DEFAULT_ICONS; } NotificationsService.prototype.set = function (notification, to) { notification.id = notification.override && notification.override.id ? notification.override.id : Math.random().toString(36).substring(3); notification.click = new core.EventEmitter(); notification.clickIcon = new core.EventEmitter(); notification.timeoutEnd = new core.EventEmitter(); this.emitter.next({ command: 'set', notification: notification, add: to }); return notification; }; NotificationsService.prototype.success = function (title, content, override, context) { if (title === void 0) { title = ''; } if (content === void 0) { content = ''; } return this.set({ title: title, content: content || '', type: exports.NotificationType.Success, icon: this.icons.success, override: override, context: context }, true); }; NotificationsService.prototype.error = function (title, content, override, context) { if (title === void 0) { title = ''; } if (content === void 0) { content = ''; } return this.set({ title: title, content: content || '', type: exports.NotificationType.Error, icon: this.icons.error, override: override, context: context }, true); }; NotificationsService.prototype.alert = function (title, content, override, context) { if (title === void 0) { title = ''; } if (content === void 0) { content = ''; } return this.set({ title: title, content: content || '', type: exports.NotificationType.Alert, icon: this.icons.alert, override: override, context: context }, true); }; NotificationsService.prototype.info = function (title, content, override, context) { if (title === void 0) { title = ''; } if (content === void 0) { content = ''; } return this.set({ title: title, content: content || '', type: exports.NotificationType.Info, icon: this.icons.info, override: override, context: context }, true); }; NotificationsService.prototype.warn = function (title, content, override, context) { if (title === void 0) { title = ''; } if (content === void 0) { content = ''; } return this.set({ title: title, content: content || '', type: exports.NotificationType.Warn, icon: this.icons.warn, override: override, context: context }, true); }; NotificationsService.prototype.bare = function (title, content, override, context) { if (title === void 0) { title = ''; } if (content === void 0) { content = ''; } return this.set({ title: title, content: content || '', type: exports.NotificationType.Bare, icon: 'bare', override: override, context: context }, true); }; // With type method NotificationsService.prototype.create = function (title, content, type, override, context) { if (title === void 0) { title = ''; } if (content === void 0) { content = ''; } if (type === void 0) { type = exports.NotificationType.Success; } return this.set({ title: title, content: content, type: type, icon: this.icons[type], override: override, context: context }, true); }; // HTML Notification method NotificationsService.prototype.html = function (html, type, override, icon, context) { if (type === void 0) { type = exports.NotificationType.Success; } if (icon === void 0) { icon = 'bare'; } return this.set({ html: html, type: type, icon: this.icons[icon], override: override, context: context }, true); }; // Remove all notifications method NotificationsService.prototype.remove = function (id) { if (id) { this.emitter.next({ command: 'clean', id: id }); } else { this.emitter.next({ command: 'cleanAll' }); } }; NotificationsService.decorators = [ { type: core.Injectable } ]; /** @nocollapse */ NotificationsService.ctorParameters = function () { return [ { type: undefined, decorators: [{ type: core.Inject, args: ['options',] }] } ]; }; return NotificationsService; }()); var NotificationComponent = /** @class */ (function () { function NotificationComponent(notificationService, domSanitizer, cdr, zone) { var _this = this; this.notificationService = notificationService; this.domSanitizer = domSanitizer; this.cdr = cdr; this.zone = zone; this.titleIsTemplate = false; this.contentIsTemplate = false; this.htmlIsTemplate = false; this.progressWidth = 0; this.stopTime = false; this.framesPerSecond = 40; this.instance = function () { var now = new Date().getTime(); if (_this.endTime < now) { _this.remove(); _this.item.timeoutEnd.emit(); } else if (!_this.stopTime) { if (_this.showProgressBar) { _this.progressWidth = Math.min((now - _this.startTime + _this.sleepTime /* We add this.sleepTime just to have 100% before close */) * 100 / _this.timeOut, 100); } _this.timer = setTimeout(_this.instance, _this.sleepTime); } _this.zone.run(function () { if (!_this.cdr['destroyed']) { _this.cdr.detectChanges(); } }); }; } NotificationComponent.prototype.ngOnInit = function () { if (this.item.override) { this.attachOverrides(); } if (this.animate) { this.item.state = this.animate; } if (this.timeOut !== 0) { this.startTimeOut(); } this.contentType(this.item.title, 'title'); this.contentType(this.item.content, 'content'); this.contentType(this.item.html, 'html'); this.safeSvg = this.domSanitizer.bypassSecurityTrustHtml(this.icon || this.item.icon); this.safeInputHtml = this.domSanitizer.bypassSecurityTrustHtml(this.item.html); }; NotificationComponent.prototype.ngOnDestroy = function () { clearTimeout(this.timer); this.cdr.detach(); }; NotificationComponent.prototype.startTimeOut = function () { var _this = this; this.sleepTime = 1000 / this.framesPerSecond /* ms */; this.startTime = new Date().getTime(); this.endTime = this.startTime + this.timeOut; this.zone.runOutsideAngular(function () { return _this.timer = setTimeout(_this.instance, _this.sleepTime); }); }; NotificationComponent.prototype.onEnter = function () { if (this.pauseOnHover) { this.stopTime = true; } }; NotificationComponent.prototype.onLeave = function () { var _this = this; if (this.pauseOnHover) { this.stopTime = false; this.zone.runOutsideAngular(function () { return setTimeout(_this.instance, _this.sleepTime); }); } }; NotificationComponent.prototype.onClick = function (event) { this.item.click.emit(event); if (this.clickToClose) { this.remove(); } }; NotificationComponent.prototype.onClickIcon = function (event) { this.item.clickIcon.emit(event); if (this.clickIconToClose) { this.remove(); } }; // Attach all the overrides NotificationComponent.prototype.attachOverrides = function () { var _this = this; Object.keys(this.item.override).forEach(function (a) { if (_this.hasOwnProperty(a)) { _this[a] = _this.item.override[a]; } }); }; NotificationComponent.prototype.remove = function () { var _this = this; if (this.animate) { this.item.state = this.animate + 'Out'; setTimeout(function () { _this.notificationService.set(_this.item, false); }, 310); } else { this.notificationService.set(this.item, false); } }; NotificationComponent.prototype.contentType = function (item, key) { if (item instanceof core.TemplateRef) { this[key] = item; } else { this[key] = this.domSanitizer.bypassSecurityTrustHtml(item); } this[key + 'IsTemplate'] = item instanceof core.TemplateRef; }; NotificationComponent.decorators = [ { type: core.Component, args: [{ selector: 'simple-notification', encapsulation: core.ViewEncapsulation.None, animations: [ animations.trigger('enterLeave', [ // Fade animations.state('fade', animations.style({ opacity: 1 })), animations.transition('* => fade', [ animations.style({ opacity: 0 }), animations.animate('400ms ease-in-out') ]), animations.state('fadeOut', animations.style({ opacity: 0 })), animations.transition('fade => fadeOut', [ animations.style({ opacity: 1 }), animations.animate('300ms ease-in-out') ]), // Enter from top animations.state('fromTop', animations.style({ opacity: 1, transform: 'translateY(0)' })), animations.transition('* => fromTop', [ animations.style({ opacity: 0, transform: 'translateY(-5%)' }), animations.animate('400ms ease-in-out') ]), animations.state('fromTopOut', animations.style({ opacity: 0, transform: 'translateY(5%)' })), animations.transition('fromTop => fromTopOut', [ animations.style({ opacity: 1, transform: 'translateY(0)' }), animations.animate('300ms ease-in-out') ]), // Enter from right animations.state('fromRight', animations.style({ opacity: 1, transform: 'translateX(0)' })), animations.transition('* => fromRight', [ animations.style({ opacity: 0, transform: 'translateX(5%)' }), animations.animate('400ms ease-in-out') ]), animations.state('fromRightOut', animations.style({ opacity: 0, transform: 'translateX(-5%)' })), animations.transition('fromRight => fromRightOut', [ animations.style({ opacity: 1, transform: 'translateX(0)' }), animations.animate('300ms ease-in-out') ]), // Enter from bottom animations.state('fromBottom', animations.style({ opacity: 1, transform: 'translateY(0)' })), animations.transition('* => fromBottom', [ animations.style({ opacity: 0, transform: 'translateY(5%)' }), animations.animate('400ms ease-in-out') ]), animations.state('fromBottomOut', animations.style({ opacity: 0, transform: 'translateY(-5%)' })), animations.transition('fromBottom => fromBottomOut', [ animations.style({ opacity: 1, transform: 'translateY(0)' }), animations.animate('300ms ease-in-out') ]), // Enter from left animations.state('fromLeft', animations.style({ opacity: 1, transform: 'translateX(0)' })), animations.transition('* => fromLeft', [ animations.style({ opacity: 0, transform: 'translateX(-5%)' }), animations.animate('400ms ease-in-out') ]), animations.state('fromLeftOut', animations.style({ opacity: 0, transform: 'translateX(5%)' })), animations.transition('fromLeft => fromLeftOut', [ animations.style({ opacity: 1, transform: 'translateX(0)' }), animations.animate('300ms ease-in-out') ]), // Rotate animations.state('scale', animations.style({ opacity: 1, transform: 'scale(1)' })), animations.transition('* => scale', [ animations.style({ opacity: 0, transform: 'scale(0)' }), animations.animate('400ms ease-in-out') ]), animations.state('scaleOut', animations.style({ opacity: 0, transform: 'scale(0)' })), animations.transition('scale => scaleOut', [ animations.style({ opacity: 1, transform: 'scale(1)' }), animations.animate('400ms ease-in-out') ]), // Scale animations.state('rotate', animations.style({ opacity: 1, transform: 'rotate(0deg)' })), animations.transition('* => rotate', [ animations.style({ opacity: 0, transform: 'rotate(5deg)' }), animations.animate('400ms ease-in-out') ]), animations.state('rotateOut', animations.style({ opacity: 0, transform: 'rotate(-5deg)' })), animations.transition('rotate => rotateOut', [ animations.style({ opacity: 1, transform: 'rotate(0deg)' }), animations.animate('400ms ease-in-out') ]) ]) ], template: "<div class=\"simple-notification\"\r\n [@enterLeave]=\"item.state\"\r\n (click)=\"onClick($event)\"\r\n [class]=\"theClass\"\r\n [ngClass]=\"{\r\n 'alert': item.type === 'alert',\r\n 'error': item.type === 'error',\r\n 'warn': item.type === 'warn',\r\n 'success': item.type === 'success',\r\n 'info': item.type === 'info',\r\n 'bare': item.type === 'bare',\r\n 'rtl-mode': rtl,\r\n 'has-icon': item.icon !== 'bare'\r\n }\"\r\n (mouseenter)=\"onEnter()\"\r\n (mouseleave)=\"onLeave()\">\r\n\r\n <div *ngIf=\"!item.html\">\r\n\r\n <div class=\"sn-title\" *ngIf=\"titleIsTemplate; else regularTitle\">\r\n <ng-container *ngTemplateOutlet=\"title; context: item.context\"></ng-container>\r\n </div>\r\n\r\n <ng-template #regularTitle>\r\n <div class=\"sn-title\" [innerHTML]=\"title\"></div>\r\n </ng-template>\r\n\r\n <div class=\"sn-content\" *ngIf=\"contentIsTemplate else regularContent\">\r\n <ng-container *ngTemplateOutlet=\"content; context: item.context\"></ng-container>\r\n </div>\r\n\r\n <ng-template #regularContent>\r\n <div class=\"sn-content\" [innerHTML]=\"content\"></div>\r\n </ng-template>\r\n\r\n <div class=\"icon\" *ngIf=\"item.icon !== 'bare'\" [innerHTML]=\"safeSvg\"></div>\r\n </div>\r\n <div *ngIf=\"item.html\">\r\n <div class=\"sn-html\" *ngIf=\"htmlIsTemplate; else regularHtml\">\r\n <ng-container *ngTemplateOutlet=\"item.html; context: item.context\"></ng-container>\r\n </div>\r\n\r\n <ng-template #regularHtml>\r\n <div class=\"sn-content\" [innerHTML]=\"safeInputHtml\"></div>\r\n </ng-template>\r\n\r\n <div class=\"icon\" [class.icon-hover]=\"clickIconToClose\" *ngIf=\"item.icon\" [innerHTML]=\"safeSvg\" (click)=\"onClickIcon($event)\"></div>\r\n </div>\r\n\r\n <div class=\"sn-progress-loader\" *ngIf=\"showProgressBar\">\r\n <span [ngStyle]=\"{'width': progressWidth + '%'}\"></span>\r\n </div>\r\n\r\n</div>\r\n", changeDetection: core.ChangeDetectionStrategy.OnPush, styles: [".simple-notification{width:100%;padding:10px 20px;box-sizing:border-box;position:relative;float:left;margin-bottom:10px;color:#fff;cursor:pointer;transition:.5s;min-height:70px}.simple-notification .sn-content,.simple-notification .sn-html,.simple-notification .sn-title{margin:0}.simple-notification .sn-title{line-height:30px;font-size:20px}.simple-notification .sn-content{font-size:16px;line-height:20px}.simple-notification.has-icon .sn-content,.simple-notification.has-icon .sn-html,.simple-notification.has-icon .sn-title{padding:0 50px 0 0}.simple-notification .icon{position:absolute;box-sizing:border-box;top:0;right:0;width:70px;height:70px;padding:10px}.simple-notification .icon.icon-hover:hover{opacity:.5}.simple-notification .icon svg{fill:#fff;width:100%;height:100%}.simple-notification .icon svg g{fill:#fff}.simple-notification.rtl-mode.has-icon .sn-content,.simple-notification.rtl-mode.has-icon .sn-html,.simple-notification.rtl-mode.has-icon .sn-title{padding:0 0 0 50px}.simple-notification.rtl-mode{direction:rtl}.simple-notification.rtl-mode .sn-content{padding:0 0 0 50px}.simple-notification.rtl-mode svg{left:0;right:auto}.simple-notification.error{background:#f44336}.simple-notification.success{background:#8bc34a}.simple-notification.alert{background:#ffdb5b}.simple-notification.info{background:#03a9f4}.simple-notification.warn{background:#ffdb5b}.simple-notification .sn-progress-loader{position:absolute;top:0;left:0;width:100%;height:5px}.simple-notification .sn-progress-loader span{float:left;height:100%}.simple-notification.success .sn-progress-loader span{background:#689f38}.simple-notification.error .sn-progress-loader span{background:#d32f2f}.simple-notification.alert .sn-progress-loader span{background:#edc242}.simple-notification.info .sn-progress-loader span{background:#0288d1}.simple-notification.warn .sn-progress-loader span{background:#edc242}.simple-notification.bare .sn-progress-loader span{background:#ccc}.simple-notification.warn div .sn-content,.simple-notification.warn div .sn-html,.simple-notification.warn div .sn-title{color:#444}"] }] } ]; /** @nocollapse */ NotificationComponent.ctorParameters = function () { return [ { type: NotificationsService }, { type: platformBrowser.DomSanitizer }, { type: core.ChangeDetectorRef }, { type: core.NgZone } ]; }; NotificationComponent.propDecorators = { timeOut: [{ type: core.Input }], showProgressBar: [{ type: core.Input }], pauseOnHover: [{ type: core.Input }], clickToClose: [{ type: core.Input }], clickIconToClose: [{ type: core.Input }], maxLength: [{ type: core.Input }], theClass: [{ type: core.Input }], rtl: [{ type: core.Input }], animate: [{ type: core.Input }], position: [{ type: core.Input }], item: [{ type: core.Input }] }; return NotificationComponent; }()); (function (NotificationAnimationType) { NotificationAnimationType["Fade"] = "fade"; NotificationAnimationType["FromTop"] = "fromTop"; NotificationAnimationType["FromRight"] = "fromRight"; NotificationAnimationType["FromBottom"] = "fromBottom"; NotificationAnimationType["FromLeft"] = "fromLeft"; NotificationAnimationType["Scale"] = "scale"; NotificationAnimationType["Rotate"] = "rotate"; })(exports.NotificationAnimationType || (exports.NotificationAnimationType = {})); var SimpleNotificationsComponent = /** @class */ (function () { function SimpleNotificationsComponent(service, cdr) { this.service = service; this.cdr = cdr; this.onCreate = new core.EventEmitter(); this.onDestroy = new core.EventEmitter(); this.notifications = []; this.position = ['bottom', 'right']; // Received values this.lastOnBottom = true; this.maxStack = 8; this.preventLastDuplicates = false; this.preventDuplicates = false; // Sent values this.timeOut = 0; this.maxLength = 0; this.clickToClose = true; this.clickIconToClose = false; this.showProgressBar = true; this.pauseOnHover = true; this.theClass = ''; this.rtl = false; this.animate = exports.NotificationAnimationType.FromRight; this._usingComponentOptions = false; } Object.defineProperty(SimpleNotificationsComponent.prototype, "options", { set: function (opt) { this._usingComponentOptions = true; this.attachChanges(opt); }, enumerable: true, configurable: true }); SimpleNotificationsComponent.prototype.ngOnInit = function () { var _this = this; /** * Only attach global options if config * options were never sent through input */ if (!this._usingComponentOptions) { this.attachChanges(this.service.globalOptions); } this.listener = this.service.emitter .subscribe(function (item) { switch (item.command) { case 'cleanAll': _this.notifications = []; break; case 'clean': _this.cleanSingle(item.id); break; case 'set': if (item.add) { _this.add(item.notification); } else { _this.defaultBehavior(item); } break; default: _this.defaultBehavior(item); break; } if (!_this.cdr['destroyed']) { _this.cdr.detectChanges(); } }); }; SimpleNotificationsComponent.prototype.ngOnDestroy = function () { if (this.listener) { this.listener.unsubscribe(); } this.cdr.detach(); }; // Default behavior on event SimpleNotificationsComponent.prototype.defaultBehavior = function (value) { this.notifications.splice(this.notifications.indexOf(value.notification), 1); this.onDestroy.emit(this.buildEmit(value.notification, false)); }; // Add the new notification to the notification array SimpleNotificationsComponent.prototype.add = function (item) { item.createdOn = new Date(); var toBlock = this.preventLastDuplicates || this.preventDuplicates ? this.block(item) : false; // Save this as the last created notification this.lastNotificationCreated = item; // Override icon if set if (item.override && item.override.icons && item.override.icons[item.type]) { item.icon = item.override.icons[item.type]; } if (!toBlock) { // Check if the notification should be added at the start or the end of the array if (this.lastOnBottom) { if (this.notifications.length >= this.maxStack) { this.notifications.splice(0, 1); } this.notifications.push(item); } else { if (this.notifications.length >= this.maxStack) { this.notifications.splice(this.notifications.length - 1, 1); } this.notifications.splice(0, 0, item); } this.onCreate.emit(this.buildEmit(item, true)); } }; // Check if notifications should be prevented SimpleNotificationsComponent.prototype.block = function (item) { var toCheck = item.html ? this.checkHtml : this.checkStandard; if (this.preventDuplicates && this.notifications.length > 0) { for (var i = 0; i < this.notifications.length; i++) { if (toCheck(this.notifications[i], item)) { return true; } } } if (this.preventLastDuplicates) { var comp = void 0; if (this.preventLastDuplicates === 'visible' && this.notifications.length > 0) { if (this.lastOnBottom) { comp = this.notifications[this.notifications.length - 1]; } else { comp = this.notifications[0]; } } else if (this.preventLastDuplicates === 'all' && this.lastNotificationCreated) { comp = this.lastNotificationCreated; } else { return false; } return toCheck(comp, item); } return false; }; SimpleNotificationsComponent.prototype.checkStandard = function (checker, item) { return checker.type === item.type && checker.title === item.title && checker.content === item.content; }; SimpleNotificationsComponent.prototype.checkHtml = function (checker, item) { return checker.html ? checker.type === item.type && checker.title === item.title && checker.content === item.content && checker.html === item.html : false; }; // Attach all the changes received in the options object SimpleNotificationsComponent.prototype.attachChanges = function (options) { for (var key in options) { if (this.hasOwnProperty(key)) { this[key] = options[key]; } else if (key === 'icons') { this.service.icons = options[key]; } } }; SimpleNotificationsComponent.prototype.buildEmit = function (notification, to) { var toEmit = { createdOn: notification.createdOn, type: notification.type, icon: notification.icon, id: notification.id }; if (notification.html) { toEmit.html = notification.html; } else { toEmit.title = notification.title; toEmit.content = notification.content; } if (!to) { toEmit.destroyedOn = new Date(); } return toEmit; }; SimpleNotificationsComponent.prototype.cleanSingle = function (id) { var indexOfDelete = 0; var doDelete = false; var noti; this.notifications.forEach(function (notification, idx) { if (notification.id === id) { indexOfDelete = idx; noti = notification; doDelete = true; } }); if (doDelete) { this.notifications.splice(indexOfDelete, 1); this.onDestroy.emit(this.buildEmit(noti, false)); } }; SimpleNotificationsComponent.decorators = [ { type: core.Component, args: [{ selector: 'simple-notifications', encapsulation: core.ViewEncapsulation.None, template: "<div class=\"simple-notification-wrapper\" [ngClass]=\"position\">\r\n <simple-notification\r\n *ngFor=\"let a of notifications; let i = index\"\r\n [item]=\"a\"\r\n [timeOut]=\"timeOut\"\r\n [clickToClose]=\"clickToClose\"\r\n [clickIconToClose]=\"clickIconToClose\"\r\n [maxLength]=\"maxLength\"\r\n [showProgressBar]=\"showProgressBar\"\r\n [pauseOnHover]=\"pauseOnHover\"\r\n [theClass]=\"theClass\"\r\n [rtl]=\"rtl\"\r\n [animate]=\"animate\"\r\n [position]=\"i\">\r\n </simple-notification>\r\n</div>", changeDetection: core.ChangeDetectionStrategy.OnPush, styles: [".simple-notification-wrapper{position:fixed;width:300px;z-index:1000}.simple-notification-wrapper.left{left:20px}.simple-notification-wrapper.top{top:20px}.simple-notification-wrapper.right{right:20px}.simple-notification-wrapper.bottom{bottom:20px}.simple-notification-wrapper.center{left:50%;transform:translateX(-50%)}.simple-notification-wrapper.middle{top:50%;transform:translateY(-50%)}.simple-notification-wrapper.middle.center{transform:translate(-50%,-50%)}@media (max-width:340px){.simple-notification-wrapper{width:auto;left:20px;right:20px}}"] }] } ]; /** @nocollapse */ SimpleNotificationsComponent.ctorParameters = function () { return [ { type: NotificationsService }, { type: core.ChangeDetectorRef } ]; }; SimpleNotificationsComponent.propDecorators = { options: [{ type: core.Input }], onCreate: [{ type: core.Output }], onDestroy: [{ type: core.Output }] }; return SimpleNotificationsComponent; }()); /*! ***************************************************************************** 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 __assign = function () { __assign = Object.assign || function __assign(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; var DEFAULT_OPTIONS = { position: ['bottom', 'right'], timeOut: 0, showProgressBar: true, pauseOnHover: true, lastOnBottom: true, clickToClose: true, clickIconToClose: false, maxLength: 0, maxStack: 8, preventDuplicates: false, preventLastDuplicates: false, theClass: '', rtl: false, animate: exports.NotificationAnimationType.FromRight, icons: DEFAULT_ICONS }; var OPTIONS = new core.InjectionToken('options'); function optionsFactory(options) { return __assign(__assign({}, DEFAULT_OPTIONS), options); } var SimpleNotificationsModule = /** @class */ (function () { function SimpleNotificationsModule() { } SimpleNotificationsModule.forRoot = function (options) { if (options === void 0) { options = {}; } return { ngModule: SimpleNotificationsModule, providers: [ NotificationsService, { provide: OPTIONS, useValue: options }, { provide: 'options', useFactory: optionsFactory, deps: [OPTIONS] } ] }; }; SimpleNotificationsModule.decorators = [ { type: core.NgModule, args: [{ imports: [ common.CommonModule ], declarations: [ SimpleNotificationsComponent, NotificationComponent ], exports: [SimpleNotificationsComponent] },] } ]; return SimpleNotificationsModule; }()); /** * Generated bundle index. Do not edit. */ exports.NotificationComponent = NotificationComponent; exports.SimpleNotificationsComponent = SimpleNotificationsComponent; exports.NotificationsService = NotificationsService; exports.OPTIONS = OPTIONS; exports.optionsFactory = optionsFactory; exports.SimpleNotificationsModule = SimpleNotificationsModule; Object.defineProperty(exports, '__esModule', { value: true }); }))); //# sourceMappingURL=angular9-notifications-gpu.umd.js.map