ngx-snotifire 1.0.0-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/README.md +19 -0
  2. package/esm2020/lib/components/buttons/buttons-config.interface.mjs +2 -0
  3. package/esm2020/lib/components/buttons/buttons.component.mjs +27 -0
  4. package/esm2020/lib/components/index.mjs +6 -0
  5. package/esm2020/lib/components/ngx-notifire/ngx-snotifire.component.mjs +130 -0
  6. package/esm2020/lib/components/prompt/prompt.component.mjs +26 -0
  7. package/esm2020/lib/components/toast/notifire-toast.model.mjs +61 -0
  8. package/esm2020/lib/components/toast/toast.component.mjs +186 -0
  9. package/esm2020/lib/decorators/set-toast-type.decorator.mjs +19 -0
  10. package/esm2020/lib/decorators/transform-argument.decorator.mjs +88 -0
  11. package/esm2020/lib/defaults/defaults.interface.mjs +2 -0
  12. package/esm2020/lib/defaults/global-config.interface.mjs +2 -0
  13. package/esm2020/lib/defaults/index.mjs +4 -0
  14. package/esm2020/lib/defaults/toast-defaults.mjs +68 -0
  15. package/esm2020/lib/models/index.mjs +7 -0
  16. package/esm2020/lib/models/snotifire-animate.interface.mjs +2 -0
  17. package/esm2020/lib/models/snotifire-config.interface.mjs +2 -0
  18. package/esm2020/lib/models/snotifire-event.type.mjs +14 -0
  19. package/esm2020/lib/models/snotifire-notifications.interface.mjs +2 -0
  20. package/esm2020/lib/models/snotifire-position.type.mjs +13 -0
  21. package/esm2020/lib/models/snotifire.model.mjs +26 -0
  22. package/esm2020/lib/models/snotifire.type.mjs +11 -0
  23. package/esm2020/lib/ngx-snotifire.module.mjs +38 -0
  24. package/esm2020/lib/pipes/index.mjs +3 -0
  25. package/esm2020/lib/pipes/keys.pipe.mjs +23 -0
  26. package/esm2020/lib/pipes/truncate.pipe.mjs +27 -0
  27. package/esm2020/lib/services/index.mjs +2 -0
  28. package/esm2020/lib/services/notification.service.mjs +274 -0
  29. package/esm2020/lib/utils.mjs +41 -0
  30. package/esm2020/ngx-snotifire.mjs +5 -0
  31. package/esm2020/public-api.mjs +10 -0
  32. package/fesm2015/ngx-snotifire.mjs +1038 -0
  33. package/fesm2015/ngx-snotifire.mjs.map +1 -0
  34. package/fesm2020/ngx-snotifire.mjs +1039 -0
  35. package/fesm2020/ngx-snotifire.mjs.map +1 -0
  36. package/index.d.ts +5 -0
  37. package/lib/components/buttons/buttons-config.interface.d.ts +17 -0
  38. package/lib/components/buttons/buttons.component.d.ts +17 -0
  39. package/lib/components/index.d.ts +5 -0
  40. package/lib/components/ngx-notifire/ngx-snotifire.component.d.ts +61 -0
  41. package/lib/components/prompt/prompt.component.d.ts +17 -0
  42. package/lib/components/toast/notifire-toast.model.d.ts +42 -0
  43. package/lib/components/toast/toast.component.d.ts +64 -0
  44. package/lib/decorators/set-toast-type.decorator.d.ts +10 -0
  45. package/lib/decorators/transform-argument.decorator.d.ts +10 -0
  46. package/lib/defaults/defaults.interface.d.ts +12 -0
  47. package/lib/defaults/global-config.interface.d.ts +34 -0
  48. package/lib/defaults/index.d.ts +3 -0
  49. package/lib/defaults/toast-defaults.d.ts +73 -0
  50. package/lib/models/index.d.ts +6 -0
  51. package/lib/models/snotifire-animate.interface.d.ts +19 -0
  52. package/lib/models/snotifire-config.interface.d.ts +82 -0
  53. package/lib/models/snotifire-event.type.d.ts +12 -0
  54. package/lib/models/snotifire-notifications.interface.d.ts +12 -0
  55. package/lib/models/snotifire-position.type.d.ts +11 -0
  56. package/lib/models/snotifire.model.d.ts +39 -0
  57. package/lib/models/snotifire.type.d.ts +9 -0
  58. package/lib/ngx-snotifire.module.d.ts +15 -0
  59. package/lib/pipes/index.d.ts +2 -0
  60. package/lib/pipes/keys.pipe.d.ts +7 -0
  61. package/lib/pipes/truncate.pipe.d.ts +9 -0
  62. package/lib/services/index.d.ts +1 -0
  63. package/lib/services/notification.service.d.ts +264 -0
  64. package/lib/utils.d.ts +17 -0
  65. package/package.json +31 -0
  66. package/public-api.d.ts +6 -0
@@ -0,0 +1,1039 @@
1
+ import * as i2 from '@angular/common';
2
+ import { CommonModule } from '@angular/common';
3
+ import * as i0 from '@angular/core';
4
+ import { Injectable, Inject, Component, ChangeDetectionStrategy, ViewEncapsulation, Input, Pipe, EventEmitter, Output, NgModule } from '@angular/core';
5
+ import { __decorate } from 'tslib';
6
+ import { Subject, from, takeUntil } from 'rxjs';
7
+
8
+ /**
9
+ * Defines toast style depending on method name
10
+ * @param target any
11
+ * @param propertyKey NotificationType
12
+ * @param descriptor PropertyDescriptor
13
+ * @returns value: ((...args: any[]) => any)
14
+ */
15
+ function SetToastType(target, propertyKey, descriptor) {
16
+ return {
17
+ value(...args) {
18
+ args[0].config = {
19
+ ...args[0].config,
20
+ type: propertyKey,
21
+ };
22
+ return descriptor.value.apply(this, args);
23
+ },
24
+ };
25
+ }
26
+
27
+ var SnotifireEventType;
28
+ (function (SnotifireEventType) {
29
+ SnotifireEventType["MOUNTED"] = "mounted";
30
+ SnotifireEventType["BEFORE_SHOW"] = "beforeShow";
31
+ SnotifireEventType["SHOWN"] = "shown";
32
+ SnotifireEventType["INPUT"] = "input";
33
+ SnotifireEventType["CLICK"] = "click";
34
+ SnotifireEventType["MOUSE_ENTER"] = "mouseenter";
35
+ SnotifireEventType["MOUSE_LEAVE"] = "mouseleave";
36
+ SnotifireEventType["BEFORE_HIDE"] = "beforeHide";
37
+ SnotifireEventType["HIDDEN"] = "hidden";
38
+ SnotifireEventType["DESTROYED"] = "destroyed";
39
+ })(SnotifireEventType || (SnotifireEventType = {}));
40
+
41
+ var SnotificationPositionType;
42
+ (function (SnotificationPositionType) {
43
+ SnotificationPositionType["LEFT_TOP"] = "leftTop";
44
+ SnotificationPositionType["LEFT_CENTER"] = "leftCenter";
45
+ SnotificationPositionType["LEFT_BOTTOM"] = "leftBottom";
46
+ SnotificationPositionType["RIGHT_TOP"] = "rightTop";
47
+ SnotificationPositionType["RIGHT_CENTER"] = "rightCenter";
48
+ SnotificationPositionType["RIGHT_BOTTOM"] = "rightBottom";
49
+ SnotificationPositionType["CENTER_TOP"] = "centerTop";
50
+ SnotificationPositionType["CENTER_CENTER"] = "centerCenter";
51
+ SnotificationPositionType["CENTER_BOTTOM"] = "centerBottom";
52
+ })(SnotificationPositionType || (SnotificationPositionType = {}));
53
+
54
+ var SnotifireType;
55
+ (function (SnotifireType) {
56
+ SnotifireType["SUCCESS"] = "success";
57
+ SnotifireType["INFO"] = "info";
58
+ SnotifireType["WARNING"] = "warning";
59
+ SnotifireType["ERROR"] = "error";
60
+ SnotifireType["ASYNC"] = "async";
61
+ SnotifireType["CONFIRM"] = "confirm";
62
+ SnotifireType["PROMPT"] = "prompt";
63
+ })(SnotifireType || (SnotifireType = {}));
64
+
65
+ class SnotifireModel {
66
+ constructor(type,
67
+ /**
68
+ * Notification Title
69
+ */
70
+ title,
71
+ /**
72
+ * Notification message
73
+ */
74
+ body,
75
+ /**
76
+ * Config object
77
+ */
78
+ config,
79
+ /**
80
+ * Html content
81
+ */
82
+ html) {
83
+ this.type = type;
84
+ this.title = title;
85
+ this.body = body;
86
+ this.config = config;
87
+ this.html = html;
88
+ }
89
+ }
90
+
91
+ //todo: cp check if async
92
+ /**
93
+ * Transform arguments to Snotify object
94
+ * @param target any
95
+ * @param propertyKey SnotifyTypeType
96
+ * @param descriptor PropertyDescriptor
97
+ * @returns Snotify
98
+ */
99
+ function TransformArgument(target, propertyKey, descriptor) {
100
+ if (propertyKey === SnotifireType.ASYNC) {
101
+ return {
102
+ value(...args) {
103
+ let result;
104
+ if (args.length === 2) {
105
+ result = {
106
+ title: null,
107
+ body: args[0],
108
+ config: null,
109
+ action: args[1],
110
+ };
111
+ }
112
+ else if (args.length === 3) {
113
+ if (typeof args[1] === 'string') {
114
+ result = {
115
+ title: args[1],
116
+ body: args[0],
117
+ config: null,
118
+ action: args[2],
119
+ };
120
+ }
121
+ else {
122
+ result = {
123
+ title: null,
124
+ body: args[0],
125
+ config: args[2],
126
+ action: args[1],
127
+ };
128
+ }
129
+ }
130
+ else {
131
+ result = {
132
+ title: args[1],
133
+ body: args[0],
134
+ config: args[3],
135
+ action: args[2],
136
+ };
137
+ }
138
+ return descriptor.value.apply(this, [
139
+ result,
140
+ ]);
141
+ },
142
+ };
143
+ }
144
+ else {
145
+ return {
146
+ value(...args) {
147
+ let result;
148
+ if (args.length === 1) {
149
+ result = {
150
+ title: null,
151
+ body: args[0],
152
+ config: null,
153
+ };
154
+ }
155
+ else if (args.length === 3) {
156
+ result = {
157
+ title: args[1],
158
+ body: args[0],
159
+ config: args[2],
160
+ };
161
+ }
162
+ else {
163
+ result = {
164
+ title: null,
165
+ config: null,
166
+ body: args[0],
167
+ [typeof args[1] === 'string' ? 'title' : 'config']: args[1],
168
+ };
169
+ }
170
+ return descriptor.value.apply(this, [
171
+ result,
172
+ ]);
173
+ },
174
+ };
175
+ }
176
+ }
177
+
178
+ /**
179
+ * Toast main model
180
+ */
181
+ class NotifireModel {
182
+ constructor(id, title, body, config) {
183
+ this.id = id;
184
+ this.title = title;
185
+ this.body = body;
186
+ this.config = config;
187
+ /**
188
+ * Emits NotifireEventType
189
+ */
190
+ this.eventEmitter = new Subject();
191
+ /**
192
+ * Holds all subscribers because we need to unsubscribe from all before toast get destroyed
193
+ */
194
+ this.eventsHolder = [];
195
+ /**
196
+ * Toast validator
197
+ */
198
+ this.valid = true;
199
+ if (this.config && this.config.type === SnotifireType.PROMPT) {
200
+ this.value = '';
201
+ }
202
+ this.on(SnotifireEventType.HIDDEN, () => {
203
+ this.eventsHolder.forEach((subscription) => {
204
+ subscription.unsubscribe();
205
+ });
206
+ });
207
+ }
208
+ /**
209
+ * Subscribe to toast events
210
+ * @returns this
211
+ * @param event NotificationEventType
212
+ * @param action (toast: this) => void
213
+ */
214
+ on(event, action) {
215
+ this.eventsHolder.push(this.eventEmitter.subscribe((e) => {
216
+ if (e === event) {
217
+ action(this);
218
+ }
219
+ }));
220
+ return this;
221
+ }
222
+ /**
223
+ * Tests if a toast equals this toast.
224
+ * @returns boolean true then equals else false.
225
+ * @param toast notifire-toast
226
+ */
227
+ equals(toast) {
228
+ return this.config && toast.config
229
+ ? this.body === toast.body &&
230
+ this.title === toast.title &&
231
+ this.config.type === toast.config.type
232
+ : this.body === toast.body && this.title === toast.title;
233
+ }
234
+ }
235
+
236
+ /**
237
+ * Deep merge objects.
238
+ * @param sources Array<Object<any>>
239
+ * @returns Object<any>
240
+ */
241
+ function mergeDeep(...sources) {
242
+ const target = {};
243
+ if (!sources.length) {
244
+ return target;
245
+ }
246
+ while (sources.length > 0) {
247
+ const source = sources.shift();
248
+ if (isObject(source)) {
249
+ for (const key in source) {
250
+ if (isObject(source[key])) {
251
+ target[key] = mergeDeep(target[key], source[key]);
252
+ }
253
+ else {
254
+ Object.assign(target, { [key]: source[key] });
255
+ }
256
+ }
257
+ }
258
+ }
259
+ return target;
260
+ }
261
+ /**
262
+ * Generates random id
263
+ * @return number
264
+ */
265
+ function uuid() {
266
+ return Math.floor(Math.random() * (Date.now() - 1)) + 1;
267
+ }
268
+ /**
269
+ * Simple is object check.
270
+ * @param item Object<any>
271
+ * @returns boolean
272
+ */
273
+ function isObject(item) {
274
+ return item && typeof item === 'object' && !Array.isArray(item);
275
+ }
276
+
277
+ class SnotificationService {
278
+ constructor(defaultConfig) {
279
+ this.defaultConfig = defaultConfig;
280
+ /**
281
+ * Minimum display time of the notification message
282
+ */
283
+ this.minimumDisplayedTime = 3000;
284
+ /**
285
+ * Emits Notifire Notifications
286
+ */
287
+ this.emitter = new Subject();
288
+ this.toastDeleted = new Subject();
289
+ this.toastChanged = new Subject();
290
+ this.notifications = [];
291
+ }
292
+ /**
293
+ * Creates toast and add it to array, returns toast id
294
+ * @param NotificationModel NotificationModel
295
+ * @return number
296
+ */
297
+ create(notif) {
298
+ if (this.defaultConfig.type && notif.config && notif.config.type) {
299
+ const config = mergeDeep(this.defaultConfig.snotifireConfig, this.defaultConfig.type[notif.config.type], notif.config);
300
+ const toast = new NotifireModel(uuid(), notif.title ? notif.title : '', notif.body ? notif.body : '', config);
301
+ this.add(toast);
302
+ return toast;
303
+ }
304
+ const config = mergeDeep(this.defaultConfig.snotifireConfig, notif.config);
305
+ const defaulToast = new NotifireModel(uuid(), notif.title ? notif.title : '', notif.body ? notif.body : '', config);
306
+ this.add(defaulToast);
307
+ return defaulToast;
308
+ }
309
+ /**
310
+ * If ID passed, emits toast animation remove, if ID & REMOVE passed, removes toast from notifications array
311
+ * @param id number
312
+ * @param remove boolean
313
+ */
314
+ remove(id, remove) {
315
+ if (!id) {
316
+ return this.clear();
317
+ }
318
+ if (remove) {
319
+ this.notifications = this.notifications.filter((toast) => toast.id !== id);
320
+ return this.emit();
321
+ }
322
+ this.toastDeleted.next(id);
323
+ }
324
+ setDefaults(defaults) {
325
+ const mergedConfig = (this.defaultConfig = mergeDeep(this.defaultConfig, defaults));
326
+ return mergedConfig;
327
+ }
328
+ /**
329
+ * Clear notifications array
330
+ */
331
+ clear() {
332
+ this.notifications = [];
333
+ this.emit();
334
+ }
335
+ /**
336
+ * add NotifireToast to notifications array
337
+ * @param toast NotifireToast
338
+ */
339
+ add(toast) {
340
+ if (this.defaultConfig &&
341
+ this.defaultConfig.global &&
342
+ this.defaultConfig.global.filterDuplicates &&
343
+ this.containsToast(toast)) {
344
+ if (!this.defaultConfig.global.filterDuplicates) {
345
+ throw new Error('Missing global config');
346
+ }
347
+ return;
348
+ }
349
+ if (this.defaultConfig &&
350
+ this.defaultConfig.global &&
351
+ this.defaultConfig.global.newOnTop) {
352
+ this.notifications.unshift(toast);
353
+ }
354
+ else {
355
+ this.notifications.push(toast);
356
+ }
357
+ this.emit();
358
+ }
359
+ /**
360
+ * emit changes in notifications array
361
+ */
362
+ emit() {
363
+ this.emitter.next(this.notifications.slice());
364
+ }
365
+ /**
366
+ * checks if the toast is in the collection.
367
+ * @param inToast NotifireToast
368
+ * @returns boolean
369
+ */
370
+ containsToast(inToast) {
371
+ return this.notifications.some((toast) => toast.equals(inToast));
372
+ }
373
+ /**
374
+ * Creates empty toast with html string inside
375
+ * @param html string | SafeHtml
376
+ * @param config NotifireConfig
377
+ * @returns number
378
+ */
379
+ html(html, config) {
380
+ return this.create({
381
+ title: undefined,
382
+ body: undefined,
383
+ config: {
384
+ ...config,
385
+ ...{ html },
386
+ },
387
+ });
388
+ }
389
+ /**
390
+ * Transform toast arguments into NotificationModel object
391
+ */
392
+ success(args) {
393
+ if (!args.config) {
394
+ throw new Error('Missing config, please configure service accordingly');
395
+ }
396
+ return this.create(args);
397
+ }
398
+ /**
399
+ * Transform toast arguments into NotificationModel object
400
+ */
401
+ error(args) {
402
+ return this.create(args);
403
+ }
404
+ /**
405
+ * Transform toast arguments into NotificationModel object
406
+ */
407
+ info(args) {
408
+ return this.create(args);
409
+ }
410
+ /**
411
+ * Transform toast arguments into NotificationModel object
412
+ */
413
+ warning(args) {
414
+ return this.create(args);
415
+ }
416
+ /**
417
+ * Transform toast arguments into NotificationModel object
418
+ */
419
+ confirm(args) {
420
+ return this.create(args);
421
+ }
422
+ /**
423
+ * Transform toast arguments into NotificationModel object
424
+ */
425
+ prompt(args) {
426
+ return this.create(args);
427
+ }
428
+ /**
429
+ * Transform toast arguments into NotificationModel object
430
+ */
431
+ async(args) {
432
+ let async;
433
+ if (args.action instanceof Promise) {
434
+ async = from(args.action);
435
+ }
436
+ else {
437
+ async = args.action;
438
+ }
439
+ const toast = this.create(args);
440
+ toast.on(SnotifireEventType.MOUNTED, () => {
441
+ const subscription = async.subscribe({
442
+ next: (next) => {
443
+ this.mergeToast(toast, next);
444
+ },
445
+ error: (error) => {
446
+ this.mergeToast(toast, error, SnotifireType.ERROR);
447
+ subscription.unsubscribe();
448
+ },
449
+ complete: () => {
450
+ this.mergeToast(toast, {}, SnotifireType.SUCCESS);
451
+ subscription.unsubscribe();
452
+ },
453
+ });
454
+ });
455
+ return toast;
456
+ }
457
+ mergeToast(toast, next, type) {
458
+ if (next.body) {
459
+ toast.body = next.body;
460
+ }
461
+ if (next.title) {
462
+ toast.title = next.title;
463
+ }
464
+ if (type && this.defaultConfig) {
465
+ toast.config = mergeDeep(toast.config, this.defaultConfig.global, this.defaultConfig.snotifireConfig?.type, { type }, next.config);
466
+ }
467
+ else {
468
+ toast.config = mergeDeep(toast.config, next.config);
469
+ }
470
+ if (next.html) {
471
+ toast.config.html = next.html;
472
+ }
473
+ this.emit();
474
+ this.toastChanged.next(toast);
475
+ }
476
+ }
477
+ SnotificationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.10", ngImport: i0, type: SnotificationService, deps: [{ token: 'NotifireConfig' }], target: i0.ɵɵFactoryTarget.Injectable });
478
+ SnotificationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.10", ngImport: i0, type: SnotificationService });
479
+ __decorate([
480
+ TransformArgument
481
+ /**
482
+ * Determines current toast type and collects default configuration
483
+ */
484
+ ,
485
+ SetToastType
486
+ ], SnotificationService.prototype, "success", null);
487
+ __decorate([
488
+ TransformArgument
489
+ /**
490
+ * Determines current toast type and collects default configuration
491
+ */
492
+ ,
493
+ SetToastType
494
+ ], SnotificationService.prototype, "error", null);
495
+ __decorate([
496
+ TransformArgument
497
+ /**
498
+ * Determines current toast type and collects default configuration
499
+ */
500
+ ,
501
+ SetToastType
502
+ ], SnotificationService.prototype, "info", null);
503
+ __decorate([
504
+ TransformArgument
505
+ /**
506
+ * Determines current toast type and collects default configuration
507
+ */
508
+ ,
509
+ SetToastType
510
+ ], SnotificationService.prototype, "warning", null);
511
+ __decorate([
512
+ TransformArgument
513
+ /**
514
+ * Determines current toast type and collects default configuration
515
+ */
516
+ ,
517
+ SetToastType
518
+ ], SnotificationService.prototype, "confirm", null);
519
+ __decorate([
520
+ TransformArgument
521
+ /**
522
+ * Determines current toast type and collects default configuration
523
+ */
524
+ ,
525
+ SetToastType
526
+ ], SnotificationService.prototype, "prompt", null);
527
+ __decorate([
528
+ TransformArgument
529
+ /**
530
+ * Determines current toast type and collects default configuration
531
+ */
532
+ ,
533
+ SetToastType
534
+ ], SnotificationService.prototype, "async", null);
535
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.10", ngImport: i0, type: SnotificationService, decorators: [{
536
+ type: Injectable
537
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
538
+ type: Inject,
539
+ args: ['NotifireConfig']
540
+ }] }]; }, propDecorators: { success: [], error: [], info: [], warning: [], confirm: [], prompt: [], async: [] } });
541
+
542
+ /**
543
+ * Buttons component
544
+ */
545
+ class ButtonsComponent {
546
+ constructor(service) {
547
+ this.service = service;
548
+ }
549
+ /**
550
+ * remove toast
551
+ */
552
+ remove() {
553
+ this.service.remove(this.toast.id);
554
+ }
555
+ }
556
+ ButtonsComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.10", ngImport: i0, type: ButtonsComponent, deps: [{ token: SnotificationService }], target: i0.ɵɵFactoryTarget.Component });
557
+ ButtonsComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.10", type: ButtonsComponent, selector: "notifire-button", inputs: { toast: "toast" }, ngImport: i0, template: "<div class=\"notifire-toast__buttons\">\n <ng-container *ngIf=\"toast.config\">\n <button\n type=\"button\"\n *ngFor=\"let button of toast.config.buttons\"\n [ngClass]=\"{ 'notifire-toast__buttons--bold': button.bold }\"\n (click)=\"button.action ? button.action(toast) : remove()\"\n >\n {{ button.text }}\n </button>\n </ng-container>\n</div>\n", dependencies: [{ kind: "directive", type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
558
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.10", ngImport: i0, type: ButtonsComponent, decorators: [{
559
+ type: Component,
560
+ args: [{ selector: 'notifire-button', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, template: "<div class=\"notifire-toast__buttons\">\n <ng-container *ngIf=\"toast.config\">\n <button\n type=\"button\"\n *ngFor=\"let button of toast.config.buttons\"\n [ngClass]=\"{ 'notifire-toast__buttons--bold': button.bold }\"\n (click)=\"button.action ? button.action(toast) : remove()\"\n >\n {{ button.text }}\n </button>\n </ng-container>\n</div>\n" }]
561
+ }], ctorParameters: function () { return [{ type: SnotificationService }]; }, propDecorators: { toast: [{
562
+ type: Input
563
+ }] } });
564
+
565
+ /**
566
+ * Truncate toast text pipe
567
+ */
568
+ class TruncatePipe {
569
+ constructor() {
570
+ this.DEFAULT_LIMIT = 40;
571
+ this.DEFAULT_TRAIL = '...';
572
+ }
573
+ transform(value, ...args) {
574
+ const limit = args.length > 0 ? parseInt(args[0], 10) : this.DEFAULT_LIMIT;
575
+ return value.length > limit
576
+ ? value.substring(0, limit) +
577
+ (args.length > 1 ? args[1] : this.DEFAULT_TRAIL)
578
+ : value;
579
+ }
580
+ }
581
+ TruncatePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.10", ngImport: i0, type: TruncatePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
582
+ TruncatePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "14.2.10", ngImport: i0, type: TruncatePipe, name: "truncate" });
583
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.10", ngImport: i0, type: TruncatePipe, decorators: [{
584
+ type: Pipe,
585
+ args: [{
586
+ name: 'truncate',
587
+ }]
588
+ }] });
589
+
590
+ class PromptComponent {
591
+ constructor() {
592
+ this.inputType = SnotifireEventType.INPUT;
593
+ /**
594
+ * Is PROMPT focused
595
+ */
596
+ this.isPromptFocused = false;
597
+ }
598
+ getValue($event) {
599
+ return $event.target.value;
600
+ }
601
+ }
602
+ PromptComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.10", ngImport: i0, type: PromptComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
603
+ PromptComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.10", type: PromptComponent, selector: "ngx-snotify-prompt", inputs: { toast: "toast" }, ngImport: i0, template: "<span\n class=\"notifire-toast__input\"\n [ngClass]=\"{ 'notifire-toast__input--filled': isPromptFocused }\"\n>\n <input\n (input)=\"toast.value = getValue($event); toast.eventEmitter.next(inputType)\"\n autofocus\n class=\"notifire-toast__input__field\"\n type=\"text\"\n [id]=\"toast.id\"\n (focus)=\"isPromptFocused = true\"\n (blur)=\"isPromptFocused = !!toast.value && !!toast.value.length\"\n >\n <label\n class=\"notifire-toast__input__label\"\n [for]=\"toast.id\"\n >\n <span\n class=\"notifire-toast__input__labelContent\"\n *ngIf=\"toast.config && toast.config.placeholder \"\n >\n {{ toast.config.placeholder | truncate }}\n </span>\n </label>\n</span>\n", dependencies: [{ kind: "directive", type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: TruncatePipe, name: "truncate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
604
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.10", ngImport: i0, type: PromptComponent, decorators: [{
605
+ type: Component,
606
+ args: [{ selector: 'ngx-snotify-prompt', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, template: "<span\n class=\"notifire-toast__input\"\n [ngClass]=\"{ 'notifire-toast__input--filled': isPromptFocused }\"\n>\n <input\n (input)=\"toast.value = getValue($event); toast.eventEmitter.next(inputType)\"\n autofocus\n class=\"notifire-toast__input__field\"\n type=\"text\"\n [id]=\"toast.id\"\n (focus)=\"isPromptFocused = true\"\n (blur)=\"isPromptFocused = !!toast.value && !!toast.value.length\"\n >\n <label\n class=\"notifire-toast__input__label\"\n [for]=\"toast.id\"\n >\n <span\n class=\"notifire-toast__input__labelContent\"\n *ngIf=\"toast.config && toast.config.placeholder \"\n >\n {{ toast.config.placeholder | truncate }}\n </span>\n </label>\n</span>\n" }]
607
+ }], propDecorators: { toast: [{
608
+ type: Input
609
+ }] } });
610
+
611
+ class ToastComponent {
612
+ constructor(service) {
613
+ this.service = service;
614
+ this.unsubscribe$ = new Subject();
615
+ this.stateChanged = new EventEmitter();
616
+ /**
617
+ * Toast state
618
+ */
619
+ this.state = {
620
+ paused: false,
621
+ progress: 0,
622
+ animation: '',
623
+ isDestroying: false,
624
+ promptType: SnotifireType.PROMPT,
625
+ };
626
+ }
627
+ ngOnInit() {
628
+ this.service.toastChanged
629
+ .pipe(takeUntil(this.unsubscribe$))
630
+ .subscribe((toast) => {
631
+ console.log('toast');
632
+ if (this.toast.id === toast.id) {
633
+ this.initToast();
634
+ }
635
+ });
636
+ this.service.toastDeleted
637
+ .pipe(takeUntil(this.unsubscribe$))
638
+ .subscribe((id) => {
639
+ if (this.toast.id === id) {
640
+ this.onRemove();
641
+ }
642
+ });
643
+ if (this.toast && this.toast.config && !this.toast.config.timeout) {
644
+ this.toast.config.showProgressBar = false;
645
+ }
646
+ this.toast.eventEmitter.next(SnotifireEventType.MOUNTED);
647
+ this.state.animation = 'notifire-toast--in';
648
+ }
649
+ ngAfterContentInit() {
650
+ if (this.service.defaultConfig.snotifireConfig &&
651
+ this.service.defaultConfig.snotifireConfig.animation) {
652
+ setTimeout(() => {
653
+ this.stateChanged.emit(SnotifireEventType.BEFORE_SHOW);
654
+ this.toast.eventEmitter.next(SnotifireEventType.BEFORE_SHOW);
655
+ this.state.animation =
656
+ this.toast.config &&
657
+ this.toast.config.animation &&
658
+ this.toast.config.animation.enter
659
+ ? this.toast.config.animation.enter
660
+ : '';
661
+ }, this.service.defaultConfig.snotifireConfig.animation.time / 5); // time to show toast push animation (notifire-toast--in)
662
+ }
663
+ }
664
+ /**
665
+ * Trigger beforeDestroy lifecycle. Removes toast
666
+ */
667
+ onRemove() {
668
+ this.state.isDestroying = true;
669
+ this.toast.eventEmitter.next(SnotifireEventType.BEFORE_HIDE);
670
+ this.stateChanged.emit(SnotifireEventType.BEFORE_HIDE);
671
+ this.state.animation =
672
+ (this.toast.config &&
673
+ this.toast.config.animation &&
674
+ this.toast.config.animation.exit) ||
675
+ '';
676
+ setTimeout(() => {
677
+ this.stateChanged.emit(SnotifireEventType.HIDDEN);
678
+ this.state.animation = 'notifire-toast--out';
679
+ this.toast.eventEmitter.next(SnotifireEventType.HIDDEN);
680
+ setTimeout(() => this.service.remove(this.toast.id, true), this.toast.config &&
681
+ this.toast.config.animation &&
682
+ this.toast.config.animation.time / 2);
683
+ }, this.toast.config && this.toast.config.animation && this.toast.config.animation.time / 2);
684
+ }
685
+ /**
686
+ * Trigger OnClick lifecycle
687
+ */
688
+ onClick() {
689
+ this.toast.eventEmitter.next(SnotifireEventType.CLICK);
690
+ if (this.toast && this.toast.config && this.toast.config.closeOnClick) {
691
+ this.service.remove(this.toast.id);
692
+ }
693
+ }
694
+ /**
695
+ * Trigger onHoverEnter lifecycle
696
+ */
697
+ onMouseEnter() {
698
+ this.toast.eventEmitter.next(SnotifireEventType.MOUSE_ENTER);
699
+ if (this.toast && this.toast.config && this.toast.config.pauseOnHover) {
700
+ this.state.paused = true;
701
+ }
702
+ }
703
+ /**
704
+ * Trigger onHoverLeave lifecycle
705
+ */
706
+ onMouseLeave() {
707
+ if (this.toast &&
708
+ this.toast.config &&
709
+ this.toast.config.pauseOnHover &&
710
+ this.toast.config.timeout) {
711
+ this.state.paused = false;
712
+ this.startTimeout(this.toast.config.timeout * this.state.progress);
713
+ }
714
+ this.toast.eventEmitter.next(SnotifireEventType.MOUSE_LEAVE);
715
+ }
716
+ /**
717
+ * Remove toast completely after animation
718
+ */
719
+ onExitTransitionEnd() {
720
+ if (this.state.isDestroying) {
721
+ return;
722
+ }
723
+ this.initToast();
724
+ this.toast.eventEmitter.next(SnotifireEventType.SHOWN);
725
+ }
726
+ /*
727
+ Common
728
+ */
729
+ /**
730
+ * Initialize base toast config
731
+ *
732
+ */
733
+ initToast() {
734
+ if ((this.toast && this.toast.config && this.toast.config.timeout
735
+ ? this.toast.config.timeout
736
+ : 0) > 0) {
737
+ this.startTimeout(0);
738
+ }
739
+ }
740
+ /**
741
+ * Start progress bar
742
+ * @param startTime number
743
+ */
744
+ startTimeout(startTime = 0) {
745
+ const start = performance.now();
746
+ const calculate = () => {
747
+ this.animationFrame = requestAnimationFrame((timestamp) => {
748
+ const runtime = timestamp + startTime - start;
749
+ const progress = Math.min(runtime /
750
+ (this.toast && this.toast.config && this.toast.config.timeout
751
+ ? this.toast.config.timeout
752
+ : 1), 1);
753
+ if (this.state.paused) {
754
+ cancelAnimationFrame(this.animationFrame);
755
+ }
756
+ else if (runtime <
757
+ (this.toast && this.toast.config && this.toast.config.timeout
758
+ ? this.toast.config.timeout
759
+ : 1)) {
760
+ this.state.progress = progress;
761
+ calculate();
762
+ }
763
+ else {
764
+ this.state.progress = 1;
765
+ cancelAnimationFrame(this.animationFrame);
766
+ this.service.remove(this.toast.id);
767
+ }
768
+ });
769
+ };
770
+ calculate();
771
+ }
772
+ ngOnDestroy() {
773
+ this.unsubscribe$.next();
774
+ this.unsubscribe$.complete();
775
+ }
776
+ }
777
+ ToastComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.10", ngImport: i0, type: ToastComponent, deps: [{ token: SnotificationService }], target: i0.ɵɵFactoryTarget.Component });
778
+ ToastComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.10", type: ToastComponent, selector: "ngx-toast", inputs: { toast: "toast" }, outputs: { stateChanged: "stateChanged" }, ngImport: i0, template: "<ng-container *ngIf=\"toast && toast.config\">\n <div\n [attr.role]=\"toast.config.type === state.promptType ? 'dialog' : 'alert'\"\n [attr.aria-labelledby]=\"'snotify_' + toast.id\"\n [attr.aria-modal]=\"toast.config.type === state.promptType\"\n [ngClass]=\"[\n 'notifire-toast animated',\n 'snotify-' + toast.config.type,\n state.animation, toast.valid === undefined ? '' : toast.valid ? 'snotifyToast--valid' : 'snotifyToast--invalid'\n]\"\n [ngStyle]=\"{\n '-webkit-transition': toast.config.animation && toast.config.animation.time + 'ms',\n transition: toast.config.animation && toast.config.animation.time + 'ms',\n '-webkit-animation-duration': toast.config.animation && toast.config.animation.time + 'ms',\n 'animation-duration': toast.config.animation && toast.config.animation.time + 'ms'\n}\"\n (animationend)=\"onExitTransitionEnd()\"\n (click)=\"onClick()\"\n (mouseenter)=\"onMouseEnter()\"\n (mouseleave)=\"onMouseLeave()\"\n >\n <div\n class=\"notifire-toast__progressBar\"\n *ngIf=\"toast.config.showProgressBar\"\n >\n <span\n class=\"notifire-toast__progressBar__percentage\"\n [ngStyle]=\"{ width: state.progress * 100 + '%' }\"\n ></span>\n </div>\n <div\n class=\"notifire-toast__inner\"\n *ngIf=\"!toast.config.html; else toastHTML\"\n >\n <div\n class=\"notifire-toast__title\"\n [attr.id]=\"'snotify_' + toast.id\"\n *ngIf=\"toast.title\"\n >\n {{ toast.title | truncate: toast.config.titleMaxLength }}\n </div>\n <div\n class=\"notifire-toast__body\"\n *ngIf=\"toast.body\"\n >\n {{ toast.body | truncate: toast.config.bodyMaxLength }}\n </div>\n <ngx-snotify-prompt\n *ngIf=\"toast.config.type === state.promptType\"\n [toast]=\"toast\"\n >\n </ngx-snotify-prompt>\n <div\n *ngIf=\"!toast.config.icon; else elseBlock\"\n [ngClass]=\"['snotify-icon', toast.config.iconClass || 'snotify-icon--' + toast.config.type]\"\n ></div>\n <ng-template #elseBlock>\n <img\n class=\"snotify-icon\"\n [src]=\"toast.config.icon\"\n >\n </ng-template>\n </div>\n <ng-template #toastHTML>\n <div\n class=\"notifire-toast__inner\"\n [innerHTML]=\"toast.config.html\"\n ></div>\n </ng-template>\n <notifire-button\n *ngIf=\"toast.config.buttons\"\n [toast]=\"toast\"\n ></notifire-button>\n </div>\n</ng-container>\n", dependencies: [{ kind: "directive", type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "component", type: PromptComponent, selector: "ngx-snotify-prompt", inputs: ["toast"] }, { kind: "component", type: ButtonsComponent, selector: "notifire-button", inputs: ["toast"] }, { kind: "pipe", type: TruncatePipe, name: "truncate" }], encapsulation: i0.ViewEncapsulation.None });
779
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.10", ngImport: i0, type: ToastComponent, decorators: [{
780
+ type: Component,
781
+ args: [{ selector: 'ngx-toast', encapsulation: ViewEncapsulation.None, template: "<ng-container *ngIf=\"toast && toast.config\">\n <div\n [attr.role]=\"toast.config.type === state.promptType ? 'dialog' : 'alert'\"\n [attr.aria-labelledby]=\"'snotify_' + toast.id\"\n [attr.aria-modal]=\"toast.config.type === state.promptType\"\n [ngClass]=\"[\n 'notifire-toast animated',\n 'snotify-' + toast.config.type,\n state.animation, toast.valid === undefined ? '' : toast.valid ? 'snotifyToast--valid' : 'snotifyToast--invalid'\n]\"\n [ngStyle]=\"{\n '-webkit-transition': toast.config.animation && toast.config.animation.time + 'ms',\n transition: toast.config.animation && toast.config.animation.time + 'ms',\n '-webkit-animation-duration': toast.config.animation && toast.config.animation.time + 'ms',\n 'animation-duration': toast.config.animation && toast.config.animation.time + 'ms'\n}\"\n (animationend)=\"onExitTransitionEnd()\"\n (click)=\"onClick()\"\n (mouseenter)=\"onMouseEnter()\"\n (mouseleave)=\"onMouseLeave()\"\n >\n <div\n class=\"notifire-toast__progressBar\"\n *ngIf=\"toast.config.showProgressBar\"\n >\n <span\n class=\"notifire-toast__progressBar__percentage\"\n [ngStyle]=\"{ width: state.progress * 100 + '%' }\"\n ></span>\n </div>\n <div\n class=\"notifire-toast__inner\"\n *ngIf=\"!toast.config.html; else toastHTML\"\n >\n <div\n class=\"notifire-toast__title\"\n [attr.id]=\"'snotify_' + toast.id\"\n *ngIf=\"toast.title\"\n >\n {{ toast.title | truncate: toast.config.titleMaxLength }}\n </div>\n <div\n class=\"notifire-toast__body\"\n *ngIf=\"toast.body\"\n >\n {{ toast.body | truncate: toast.config.bodyMaxLength }}\n </div>\n <ngx-snotify-prompt\n *ngIf=\"toast.config.type === state.promptType\"\n [toast]=\"toast\"\n >\n </ngx-snotify-prompt>\n <div\n *ngIf=\"!toast.config.icon; else elseBlock\"\n [ngClass]=\"['snotify-icon', toast.config.iconClass || 'snotify-icon--' + toast.config.type]\"\n ></div>\n <ng-template #elseBlock>\n <img\n class=\"snotify-icon\"\n [src]=\"toast.config.icon\"\n >\n </ng-template>\n </div>\n <ng-template #toastHTML>\n <div\n class=\"notifire-toast__inner\"\n [innerHTML]=\"toast.config.html\"\n ></div>\n </ng-template>\n <notifire-button\n *ngIf=\"toast.config.buttons\"\n [toast]=\"toast\"\n ></notifire-button>\n </div>\n</ng-container>\n" }]
782
+ }], ctorParameters: function () { return [{ type: SnotificationService }]; }, propDecorators: { toast: [{
783
+ type: Input
784
+ }], stateChanged: [{
785
+ type: Output
786
+ }] } });
787
+
788
+ /**
789
+ * Extract object keys pipe
790
+ */
791
+ class KeysPipe {
792
+ transform(value) {
793
+ if (!value) {
794
+ return value;
795
+ }
796
+ return Object.keys(value);
797
+ }
798
+ }
799
+ KeysPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.10", ngImport: i0, type: KeysPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
800
+ KeysPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "14.2.10", ngImport: i0, type: KeysPipe, name: "keys", pure: false });
801
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.10", ngImport: i0, type: KeysPipe, decorators: [{
802
+ type: Pipe,
803
+ args: [{
804
+ name: 'keys',
805
+ pure: false,
806
+ }]
807
+ }] });
808
+
809
+ class NgxSnotifireComponent {
810
+ constructor(service) {
811
+ this.service = service;
812
+ this.unsubscribe$ = new Subject();
813
+ /**
814
+ * Backdrop Opacity
815
+ */
816
+ this.backdrop = -1;
817
+ /**
818
+ * How many toasts with backdrop in current queue
819
+ */
820
+ this.withBackdrop = [];
821
+ }
822
+ ngAfterViewInit() { }
823
+ ngOnInit() {
824
+ this.service.emitter
825
+ .pipe(takeUntil(this.unsubscribe$))
826
+ .subscribe((toasts) => {
827
+ if (this.service.defaultConfig &&
828
+ this.service.defaultConfig.global &&
829
+ this.service.defaultConfig.global.newOnTop) {
830
+ this.dockSizeA = this.service.defaultConfig.global.maxOnScreen
831
+ ? -this.service.defaultConfig.global.maxOnScreen
832
+ : 6;
833
+ this.dockSizeB = undefined;
834
+ this.blockSizeA = this.service.defaultConfig.global.maxAtPosition
835
+ ? -this.service.defaultConfig.global.maxAtPosition
836
+ : 4;
837
+ this.blockSizeB = undefined;
838
+ this.withBackdrop = toasts.filter((toast) => toast.config &&
839
+ toast.config.backdrop &&
840
+ toast.config.backdrop >= 0);
841
+ }
842
+ else {
843
+ this.dockSizeA = 0;
844
+ this.dockSizeB =
845
+ this.service.defaultConfig.global &&
846
+ this.service.defaultConfig.global.maxOnScreen;
847
+ this.blockSizeA = 0;
848
+ this.blockSizeB =
849
+ this.service.defaultConfig.global &&
850
+ this.service.defaultConfig.global.maxAtPosition;
851
+ this.withBackdrop = toasts
852
+ .filter((toast) => toast.config &&
853
+ toast.config.backdrop &&
854
+ toast.config.backdrop >= 0)
855
+ .reverse();
856
+ }
857
+ this.notifications = this.splitToasts(toasts.slice(this.dockSizeA, this.dockSizeB));
858
+ this.stateChanged(SnotifireEventType.MOUNTED);
859
+ });
860
+ }
861
+ /**
862
+ * Split toasts toasts into different objects
863
+ * @param toasts notifire-toast[]
864
+ * @returns SnotifyNotifications
865
+ */
866
+ splitToasts(toasts) {
867
+ const result = {};
868
+ for (const property in SnotificationPositionType) {
869
+ if (SnotificationPositionType.hasOwnProperty(property)) {
870
+ result[SnotificationPositionType[property]] = [];
871
+ }
872
+ }
873
+ toasts.forEach((toast) => {
874
+ if (toast.config.position) {
875
+ const keyIndex = Object.keys(SnotificationPositionType).indexOf(toast.config.position);
876
+ const searchedString = Object.values(SnotificationPositionType)[keyIndex];
877
+ result[searchedString]?.push(toast);
878
+ }
879
+ });
880
+ console.log(result);
881
+ return result;
882
+ }
883
+ getNotificationArray(notifications, position) {
884
+ return notifications[position];
885
+ }
886
+ /**
887
+ * Changes the backdrop opacity
888
+ * @param event NotificationEventType
889
+ */
890
+ stateChanged(event) {
891
+ if (!this.withBackdrop.length) {
892
+ if (this.backdrop && this.backdrop >= 0) {
893
+ this.backdrop = -1;
894
+ }
895
+ return;
896
+ }
897
+ switch (event) {
898
+ case 'mounted':
899
+ if (this.backdrop && this.backdrop < 0) {
900
+ this.backdrop = 0;
901
+ }
902
+ break;
903
+ case 'beforeShow':
904
+ this.backdrop =
905
+ this.withBackdrop[this.withBackdrop.length - 1].config?.backdrop;
906
+ break;
907
+ case 'beforeHide':
908
+ if (this.withBackdrop.length === 1) {
909
+ this.backdrop = 0;
910
+ }
911
+ break;
912
+ case 'hidden':
913
+ if (this.withBackdrop.length === 1) {
914
+ this.backdrop = -1;
915
+ }
916
+ break;
917
+ }
918
+ }
919
+ ngOnDestroy() {
920
+ this.unsubscribe$.next();
921
+ this.unsubscribe$.complete();
922
+ }
923
+ }
924
+ NgxSnotifireComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.10", ngImport: i0, type: NgxSnotifireComponent, deps: [{ token: SnotificationService }], target: i0.ɵɵFactoryTarget.Component });
925
+ NgxSnotifireComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.10", type: NgxSnotifireComponent, selector: "ngx-snotifire", ngImport: i0, template: "<div\n class=\"snotifire-backdrop\"\n *ngIf=\"backdrop && backdrop >= 0\"\n [style.opacity]=\"backdrop\"\n></div>\n\n<div\n *ngFor=\"let position of notifications | keys\"\n class=\"snotify snotify-{{ position }}\"\n>\n <ngx-toast\n *ngFor=\"let notification of getNotificationArray(notifications, position) | slice: blockSizeA:blockSizeB\"\n [toast]=\"notification\"\n (stateChanged)=\"stateChanged($event)\"\n >\n </ngx-toast>\n\n</div>\n", dependencies: [{ kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: ToastComponent, selector: "ngx-toast", inputs: ["toast"], outputs: ["stateChanged"] }, { kind: "pipe", type: i2.SlicePipe, name: "slice" }, { kind: "pipe", type: KeysPipe, name: "keys" }], encapsulation: i0.ViewEncapsulation.None });
926
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.10", ngImport: i0, type: NgxSnotifireComponent, decorators: [{
927
+ type: Component,
928
+ args: [{ selector: 'ngx-snotifire', encapsulation: ViewEncapsulation.None, template: "<div\n class=\"snotifire-backdrop\"\n *ngIf=\"backdrop && backdrop >= 0\"\n [style.opacity]=\"backdrop\"\n></div>\n\n<div\n *ngFor=\"let position of notifications | keys\"\n class=\"snotify snotify-{{ position }}\"\n>\n <ngx-toast\n *ngFor=\"let notification of getNotificationArray(notifications, position) | slice: blockSizeA:blockSizeB\"\n [toast]=\"notification\"\n (stateChanged)=\"stateChanged($event)\"\n >\n </ngx-toast>\n\n</div>\n" }]
929
+ }], ctorParameters: function () { return [{ type: SnotificationService }]; } });
930
+
931
+ class NgxSnotifireModule {
932
+ static forRoot() {
933
+ return {
934
+ ngModule: NgxSnotifireModule,
935
+ providers: [SnotificationService],
936
+ };
937
+ }
938
+ }
939
+ NgxSnotifireModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.10", ngImport: i0, type: NgxSnotifireModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
940
+ NgxSnotifireModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.10", ngImport: i0, type: NgxSnotifireModule, declarations: [PromptComponent,
941
+ ToastComponent,
942
+ ButtonsComponent,
943
+ TruncatePipe,
944
+ KeysPipe,
945
+ NgxSnotifireComponent], imports: [CommonModule], exports: [NgxSnotifireComponent] });
946
+ NgxSnotifireModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.10", ngImport: i0, type: NgxSnotifireModule, imports: [CommonModule] });
947
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.10", ngImport: i0, type: NgxSnotifireModule, decorators: [{
948
+ type: NgModule,
949
+ args: [{
950
+ declarations: [
951
+ PromptComponent,
952
+ ToastComponent,
953
+ ButtonsComponent,
954
+ TruncatePipe,
955
+ KeysPipe,
956
+ NgxSnotifireComponent,
957
+ ],
958
+ imports: [CommonModule],
959
+ exports: [NgxSnotifireComponent],
960
+ }]
961
+ }] });
962
+
963
+ /**
964
+ * Snotify default configuration object
965
+ */
966
+ const ToastDefaults = {
967
+ global: {
968
+ newOnTop: true,
969
+ maxOnScreen: 8,
970
+ maxAtPosition: 8,
971
+ filterDuplicates: false,
972
+ },
973
+ toast: {
974
+ type: SnotifireType.INFO,
975
+ showProgressBar: true,
976
+ timeout: 5000,
977
+ closeOnClick: true,
978
+ pauseOnHover: true,
979
+ bodyMaxLength: 150,
980
+ titleMaxLength: 16,
981
+ backdrop: -1,
982
+ icon: undefined,
983
+ iconClass: undefined,
984
+ html: undefined,
985
+ position: SnotificationPositionType.RIGHT_BOTTOM,
986
+ animation: { enter: 'fadeIn', exit: 'fadeOut', time: 400 },
987
+ },
988
+ type: {
989
+ [SnotifireType.PROMPT]: {
990
+ timeout: 0,
991
+ closeOnClick: false,
992
+ buttons: [
993
+ { text: 'Ok', action: null, bold: true },
994
+ { text: 'Cancel', action: null, bold: false },
995
+ ],
996
+ placeholder: 'Enter answer here...',
997
+ type: SnotifireType.PROMPT,
998
+ },
999
+ [SnotifireType.CONFIRM]: {
1000
+ timeout: 0,
1001
+ closeOnClick: false,
1002
+ buttons: [
1003
+ { text: 'Ok', action: null, bold: true },
1004
+ { text: 'Cancel', action: null, bold: false },
1005
+ ],
1006
+ type: SnotifireType.CONFIRM,
1007
+ },
1008
+ [SnotifireType.SUCCESS]: {
1009
+ type: SnotifireType.SUCCESS,
1010
+ },
1011
+ [SnotifireType.ERROR]: {
1012
+ type: SnotifireType.ERROR,
1013
+ },
1014
+ [SnotifireType.WARNING]: {
1015
+ type: SnotifireType.WARNING,
1016
+ },
1017
+ [SnotifireType.INFO]: {
1018
+ type: SnotifireType.INFO,
1019
+ },
1020
+ [SnotifireType.ASYNC]: {
1021
+ pauseOnHover: false,
1022
+ closeOnClick: false,
1023
+ timeout: 0,
1024
+ showProgressBar: false,
1025
+ type: SnotifireType.ASYNC,
1026
+ },
1027
+ },
1028
+ };
1029
+
1030
+ /*
1031
+ * Public API Surface of ngx-notifire
1032
+ */
1033
+
1034
+ /**
1035
+ * Generated bundle index. Do not edit.
1036
+ */
1037
+
1038
+ export { ButtonsComponent, KeysPipe, NgxSnotifireComponent, NgxSnotifireModule, NotifireModel, PromptComponent, SnotificationPositionType, SnotificationService, SnotifireEventType, SnotifireModel, SnotifireType, ToastComponent, ToastDefaults, TruncatePipe };
1039
+ //# sourceMappingURL=ngx-snotifire.mjs.map