ngx-toastr 14.1.2 → 14.2.1

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 (40) hide show
  1. package/{esm2015/ngx-toastr.js → esm2020/ngx-toastr.mjs} +0 -0
  2. package/esm2020/overlay/overlay-container.mjs +46 -0
  3. package/{esm2015/overlay/overlay-ref.js → esm2020/overlay/overlay-ref.mjs} +0 -0
  4. package/{esm2015/overlay/overlay.js → esm2020/overlay/overlay.mjs} +11 -14
  5. package/{esm2015/portal/dom-portal-host.js → esm2020/portal/dom-portal-host.mjs} +0 -0
  6. package/{esm2015/portal/portal.js → esm2020/portal/portal.mjs} +0 -0
  7. package/{esm2015/public_api.js → esm2020/public_api.mjs} +0 -0
  8. package/{esm2015/toastr/toast-injector.js → esm2020/toastr/toast-injector.mjs} +0 -0
  9. package/esm2020/toastr/toast-noanimation.component.mjs +237 -0
  10. package/esm2020/toastr/toast.component.mjs +251 -0
  11. package/esm2020/toastr/toast.directive.mjs +32 -0
  12. package/esm2020/toastr/toastr-config.mjs +72 -0
  13. package/esm2020/toastr/toastr.module.mjs +63 -0
  14. package/esm2020/toastr/toastr.service.mjs +197 -0
  15. package/fesm2015/{ngx-toastr.js → ngx-toastr.mjs} +339 -262
  16. package/fesm2015/ngx-toastr.mjs.map +1 -0
  17. package/fesm2020/ngx-toastr.mjs +1170 -0
  18. package/fesm2020/ngx-toastr.mjs.map +1 -0
  19. package/ngx-toastr.d.ts +1 -0
  20. package/overlay/overlay-container.d.ts +3 -0
  21. package/overlay/overlay.d.ts +3 -0
  22. package/package.json +29 -8
  23. package/toastr/toast-noanimation.component.d.ts +7 -0
  24. package/toastr/toast.component.d.ts +3 -0
  25. package/toastr/toast.directive.d.ts +6 -0
  26. package/toastr/toastr-config.d.ts +5 -0
  27. package/toastr/toastr.module.d.ts +9 -0
  28. package/toastr/toastr.service.d.ts +3 -0
  29. package/toastr.css +1 -1
  30. package/bundles/ngx-toastr.umd.js +0 -1507
  31. package/bundles/ngx-toastr.umd.js.map +0 -1
  32. package/esm2015/overlay/overlay-container.js +0 -45
  33. package/esm2015/toastr/toast-noanimation.component.js +0 -204
  34. package/esm2015/toastr/toast.component.js +0 -216
  35. package/esm2015/toastr/toast.directive.js +0 -27
  36. package/esm2015/toastr/toastr-config.js +0 -71
  37. package/esm2015/toastr/toastr.module.js +0 -51
  38. package/esm2015/toastr/toastr.service.js +0 -196
  39. package/fesm2015/ngx-toastr.js.map +0 -1
  40. package/ngx-toastr.metadata.json +0 -1
@@ -0,0 +1,1170 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Directive, NgModule, InjectionToken, Injectable, Inject, SecurityContext, Component, HostBinding, HostListener } from '@angular/core';
3
+ import { trigger, state, style, transition, animate } from '@angular/animations';
4
+ import { Subject } from 'rxjs';
5
+ import * as i3 from '@angular/common';
6
+ import { DOCUMENT, CommonModule } from '@angular/common';
7
+ import * as i2 from '@angular/platform-browser';
8
+
9
+ class ToastContainerDirective {
10
+ constructor(el) {
11
+ this.el = el;
12
+ }
13
+ getContainerElement() {
14
+ return this.el.nativeElement;
15
+ }
16
+ }
17
+ ToastContainerDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: ToastContainerDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
18
+ ToastContainerDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.2", type: ToastContainerDirective, selector: "[toastContainer]", exportAs: ["toastContainer"], ngImport: i0 });
19
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: ToastContainerDirective, decorators: [{
20
+ type: Directive,
21
+ args: [{
22
+ selector: '[toastContainer]',
23
+ exportAs: 'toastContainer',
24
+ }]
25
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }]; } });
26
+ class ToastContainerModule {
27
+ }
28
+ ToastContainerModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: ToastContainerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
29
+ ToastContainerModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: ToastContainerModule, declarations: [ToastContainerDirective], exports: [ToastContainerDirective] });
30
+ ToastContainerModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: ToastContainerModule });
31
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: ToastContainerModule, decorators: [{
32
+ type: NgModule,
33
+ args: [{
34
+ declarations: [ToastContainerDirective],
35
+ exports: [ToastContainerDirective],
36
+ }]
37
+ }] });
38
+
39
+ /**
40
+ * A `ComponentPortal` is a portal that instantiates some Component upon attachment.
41
+ */
42
+ class ComponentPortal {
43
+ constructor(component, injector) {
44
+ this.component = component;
45
+ this.injector = injector;
46
+ }
47
+ /** Attach this portal to a host. */
48
+ attach(host, newestOnTop) {
49
+ this._attachedHost = host;
50
+ return host.attach(this, newestOnTop);
51
+ }
52
+ /** Detach this portal from its host */
53
+ detach() {
54
+ const host = this._attachedHost;
55
+ if (host) {
56
+ this._attachedHost = undefined;
57
+ return host.detach();
58
+ }
59
+ }
60
+ /** Whether this portal is attached to a host. */
61
+ get isAttached() {
62
+ return this._attachedHost != null;
63
+ }
64
+ /**
65
+ * Sets the PortalHost reference without performing `attach()`. This is used directly by
66
+ * the PortalHost when it is performing an `attach()` or `detach()`.
67
+ */
68
+ setAttachedHost(host) {
69
+ this._attachedHost = host;
70
+ }
71
+ }
72
+ /**
73
+ * Partial implementation of PortalHost that only deals with attaching a
74
+ * ComponentPortal
75
+ */
76
+ class BasePortalHost {
77
+ attach(portal, newestOnTop) {
78
+ this._attachedPortal = portal;
79
+ return this.attachComponentPortal(portal, newestOnTop);
80
+ }
81
+ detach() {
82
+ if (this._attachedPortal) {
83
+ this._attachedPortal.setAttachedHost();
84
+ }
85
+ this._attachedPortal = undefined;
86
+ if (this._disposeFn) {
87
+ this._disposeFn();
88
+ this._disposeFn = undefined;
89
+ }
90
+ }
91
+ setDisposeFn(fn) {
92
+ this._disposeFn = fn;
93
+ }
94
+ }
95
+
96
+ /**
97
+ * Everything a toast needs to launch
98
+ */
99
+ class ToastPackage {
100
+ constructor(toastId, config, message, title, toastType, toastRef) {
101
+ this.toastId = toastId;
102
+ this.config = config;
103
+ this.message = message;
104
+ this.title = title;
105
+ this.toastType = toastType;
106
+ this.toastRef = toastRef;
107
+ this._onTap = new Subject();
108
+ this._onAction = new Subject();
109
+ this.toastRef.afterClosed().subscribe(() => {
110
+ this._onAction.complete();
111
+ this._onTap.complete();
112
+ });
113
+ }
114
+ /** Fired on click */
115
+ triggerTap() {
116
+ this._onTap.next();
117
+ if (this.config.tapToDismiss) {
118
+ this._onTap.complete();
119
+ }
120
+ }
121
+ onTap() {
122
+ return this._onTap.asObservable();
123
+ }
124
+ /** available for use in custom toast */
125
+ triggerAction(action) {
126
+ this._onAction.next(action);
127
+ }
128
+ onAction() {
129
+ return this._onAction.asObservable();
130
+ }
131
+ }
132
+ const DefaultNoComponentGlobalConfig = {
133
+ maxOpened: 0,
134
+ autoDismiss: false,
135
+ newestOnTop: true,
136
+ preventDuplicates: false,
137
+ countDuplicates: false,
138
+ resetTimeoutOnDuplicate: false,
139
+ includeTitleDuplicates: false,
140
+ iconClasses: {
141
+ error: 'toast-error',
142
+ info: 'toast-info',
143
+ success: 'toast-success',
144
+ warning: 'toast-warning',
145
+ },
146
+ // Individual
147
+ closeButton: false,
148
+ disableTimeOut: false,
149
+ timeOut: 5000,
150
+ extendedTimeOut: 1000,
151
+ enableHtml: false,
152
+ progressBar: false,
153
+ toastClass: 'ngx-toastr',
154
+ positionClass: 'toast-top-right',
155
+ titleClass: 'toast-title',
156
+ messageClass: 'toast-message',
157
+ easing: 'ease-in',
158
+ easeTime: 300,
159
+ tapToDismiss: true,
160
+ onActivateTick: false,
161
+ progressAnimation: 'decreasing',
162
+ payload: null
163
+ };
164
+ const TOAST_CONFIG = new InjectionToken('ToastConfig');
165
+
166
+ /**
167
+ * Reference to a toast opened via the Toastr service.
168
+ */
169
+ class ToastRef {
170
+ constructor(_overlayRef) {
171
+ this._overlayRef = _overlayRef;
172
+ /** Count of duplicates of this toast */
173
+ this.duplicatesCount = 0;
174
+ /** Subject for notifying the user that the toast has finished closing. */
175
+ this._afterClosed = new Subject();
176
+ /** triggered when toast is activated */
177
+ this._activate = new Subject();
178
+ /** notifies the toast that it should close before the timeout */
179
+ this._manualClose = new Subject();
180
+ /** notifies the toast that it should reset the timeouts */
181
+ this._resetTimeout = new Subject();
182
+ /** notifies the toast that it should count a duplicate toast */
183
+ this._countDuplicate = new Subject();
184
+ }
185
+ manualClose() {
186
+ this._manualClose.next();
187
+ this._manualClose.complete();
188
+ }
189
+ manualClosed() {
190
+ return this._manualClose.asObservable();
191
+ }
192
+ timeoutReset() {
193
+ return this._resetTimeout.asObservable();
194
+ }
195
+ countDuplicate() {
196
+ return this._countDuplicate.asObservable();
197
+ }
198
+ /**
199
+ * Close the toast.
200
+ */
201
+ close() {
202
+ this._overlayRef.detach();
203
+ this._afterClosed.next();
204
+ this._manualClose.next();
205
+ this._afterClosed.complete();
206
+ this._manualClose.complete();
207
+ this._activate.complete();
208
+ this._resetTimeout.complete();
209
+ this._countDuplicate.complete();
210
+ }
211
+ /** Gets an observable that is notified when the toast is finished closing. */
212
+ afterClosed() {
213
+ return this._afterClosed.asObservable();
214
+ }
215
+ isInactive() {
216
+ return this._activate.isStopped;
217
+ }
218
+ activate() {
219
+ this._activate.next();
220
+ this._activate.complete();
221
+ }
222
+ /** Gets an observable that is notified when the toast has started opening. */
223
+ afterActivate() {
224
+ return this._activate.asObservable();
225
+ }
226
+ /** Reset the toast timouts and count duplicates */
227
+ onDuplicate(resetTimeout, countDuplicate) {
228
+ if (resetTimeout) {
229
+ this._resetTimeout.next();
230
+ }
231
+ if (countDuplicate) {
232
+ this._countDuplicate.next(++this.duplicatesCount);
233
+ }
234
+ }
235
+ }
236
+ /** Custom injector type specifically for instantiating components with a toast. */
237
+ class ToastInjector {
238
+ constructor(_toastPackage, _parentInjector) {
239
+ this._toastPackage = _toastPackage;
240
+ this._parentInjector = _parentInjector;
241
+ }
242
+ get(token, notFoundValue, flags) {
243
+ if (token === ToastPackage) {
244
+ return this._toastPackage;
245
+ }
246
+ return this._parentInjector.get(token, notFoundValue, flags);
247
+ }
248
+ }
249
+
250
+ /**
251
+ * A PortalHost for attaching portals to an arbitrary DOM element outside of the Angular
252
+ * application context.
253
+ *
254
+ * This is the only part of the portal core that directly touches the DOM.
255
+ */
256
+ class DomPortalHost extends BasePortalHost {
257
+ constructor(_hostDomElement, _componentFactoryResolver, _appRef) {
258
+ super();
259
+ this._hostDomElement = _hostDomElement;
260
+ this._componentFactoryResolver = _componentFactoryResolver;
261
+ this._appRef = _appRef;
262
+ }
263
+ /**
264
+ * Attach the given ComponentPortal to DOM element using the ComponentFactoryResolver.
265
+ * @param portal Portal to be attached
266
+ */
267
+ attachComponentPortal(portal, newestOnTop) {
268
+ const componentFactory = this._componentFactoryResolver.resolveComponentFactory(portal.component);
269
+ let componentRef;
270
+ // If the portal specifies a ViewContainerRef, we will use that as the attachment point
271
+ // for the component (in terms of Angular's component tree, not rendering).
272
+ // When the ViewContainerRef is missing, we use the factory to create the component directly
273
+ // and then manually attach the ChangeDetector for that component to the application (which
274
+ // happens automatically when using a ViewContainer).
275
+ componentRef = componentFactory.create(portal.injector);
276
+ // When creating a component outside of a ViewContainer, we need to manually register
277
+ // its ChangeDetector with the application. This API is unfortunately not yet published
278
+ // in Angular core. The change detector must also be deregistered when the component
279
+ // is destroyed to prevent memory leaks.
280
+ this._appRef.attachView(componentRef.hostView);
281
+ this.setDisposeFn(() => {
282
+ this._appRef.detachView(componentRef.hostView);
283
+ componentRef.destroy();
284
+ });
285
+ // At this point the component has been instantiated, so we move it to the location in the DOM
286
+ // where we want it to be rendered.
287
+ if (newestOnTop) {
288
+ this._hostDomElement.insertBefore(this._getComponentRootNode(componentRef), this._hostDomElement.firstChild);
289
+ }
290
+ else {
291
+ this._hostDomElement.appendChild(this._getComponentRootNode(componentRef));
292
+ }
293
+ return componentRef;
294
+ }
295
+ /** Gets the root HTMLElement for an instantiated component. */
296
+ _getComponentRootNode(componentRef) {
297
+ return componentRef.hostView.rootNodes[0];
298
+ }
299
+ }
300
+
301
+ /**
302
+ * Reference to an overlay that has been created with the Overlay service.
303
+ * Used to manipulate or dispose of said overlay.
304
+ */
305
+ class OverlayRef {
306
+ constructor(_portalHost) {
307
+ this._portalHost = _portalHost;
308
+ }
309
+ attach(portal, newestOnTop = true) {
310
+ return this._portalHost.attach(portal, newestOnTop);
311
+ }
312
+ /**
313
+ * Detaches an overlay from a portal.
314
+ * @returns Resolves when the overlay has been detached.
315
+ */
316
+ detach() {
317
+ return this._portalHost.detach();
318
+ }
319
+ }
320
+
321
+ /** Container inside which all toasts will render. */
322
+ class OverlayContainer {
323
+ constructor(_document) {
324
+ this._document = _document;
325
+ }
326
+ ngOnDestroy() {
327
+ if (this._containerElement && this._containerElement.parentNode) {
328
+ this._containerElement.parentNode.removeChild(this._containerElement);
329
+ }
330
+ }
331
+ /**
332
+ * This method returns the overlay container element. It will lazily
333
+ * create the element the first time it is called to facilitate using
334
+ * the container in non-browser environments.
335
+ * @returns the container element
336
+ */
337
+ getContainerElement() {
338
+ if (!this._containerElement) {
339
+ this._createContainer();
340
+ }
341
+ return this._containerElement;
342
+ }
343
+ /**
344
+ * Create the overlay container element, which is simply a div
345
+ * with the 'cdk-overlay-container' class on the document body.
346
+ */
347
+ _createContainer() {
348
+ const container = this._document.createElement('div');
349
+ container.classList.add('overlay-container');
350
+ this._document.body.appendChild(container);
351
+ this._containerElement = container;
352
+ }
353
+ }
354
+ OverlayContainer.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: OverlayContainer, deps: [{ token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable });
355
+ OverlayContainer.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: OverlayContainer, providedIn: 'root' });
356
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: OverlayContainer, decorators: [{
357
+ type: Injectable,
358
+ args: [{ providedIn: 'root' }]
359
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
360
+ type: Inject,
361
+ args: [DOCUMENT]
362
+ }] }]; } });
363
+
364
+ /* eslint-disable @typescript-eslint/no-non-null-assertion */
365
+ /**
366
+ * Service to create Overlays. Overlays are dynamically added pieces of floating UI, meant to be
367
+ * used as a low-level building building block for other components. Dialogs, tooltips, menus,
368
+ * selects, etc. can all be built using overlays. The service should primarily be used by authors
369
+ * of re-usable components rather than developers building end-user applications.
370
+ *
371
+ * An overlay *is* a PortalHost, so any kind of Portal can be loaded into one.
372
+ */
373
+ class Overlay {
374
+ constructor(_overlayContainer, _componentFactoryResolver, _appRef, _document) {
375
+ this._overlayContainer = _overlayContainer;
376
+ this._componentFactoryResolver = _componentFactoryResolver;
377
+ this._appRef = _appRef;
378
+ this._document = _document;
379
+ // Namespace panes by overlay container
380
+ this._paneElements = new Map();
381
+ }
382
+ /**
383
+ * Creates an overlay.
384
+ * @returns A reference to the created overlay.
385
+ */
386
+ create(positionClass, overlayContainer) {
387
+ // get existing pane if possible
388
+ return this._createOverlayRef(this.getPaneElement(positionClass, overlayContainer));
389
+ }
390
+ getPaneElement(positionClass = '', overlayContainer) {
391
+ if (!this._paneElements.get(overlayContainer)) {
392
+ this._paneElements.set(overlayContainer, {});
393
+ }
394
+ if (!this._paneElements.get(overlayContainer)[positionClass]) {
395
+ this._paneElements.get(overlayContainer)[positionClass] = this._createPaneElement(positionClass, overlayContainer);
396
+ }
397
+ return this._paneElements.get(overlayContainer)[positionClass];
398
+ }
399
+ /**
400
+ * Creates the DOM element for an overlay and appends it to the overlay container.
401
+ * @returns Newly-created pane element
402
+ */
403
+ _createPaneElement(positionClass, overlayContainer) {
404
+ const pane = this._document.createElement('div');
405
+ pane.id = 'toast-container';
406
+ pane.classList.add(positionClass);
407
+ pane.classList.add('toast-container');
408
+ if (!overlayContainer) {
409
+ this._overlayContainer.getContainerElement().appendChild(pane);
410
+ }
411
+ else {
412
+ overlayContainer.getContainerElement().appendChild(pane);
413
+ }
414
+ return pane;
415
+ }
416
+ /**
417
+ * Create a DomPortalHost into which the overlay content can be loaded.
418
+ * @param pane The DOM element to turn into a portal host.
419
+ * @returns A portal host for the given DOM element.
420
+ */
421
+ _createPortalHost(pane) {
422
+ return new DomPortalHost(pane, this._componentFactoryResolver, this._appRef);
423
+ }
424
+ /**
425
+ * Creates an OverlayRef for an overlay in the given DOM element.
426
+ * @param pane DOM element for the overlay
427
+ */
428
+ _createOverlayRef(pane) {
429
+ return new OverlayRef(this._createPortalHost(pane));
430
+ }
431
+ }
432
+ Overlay.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: Overlay, deps: [{ token: OverlayContainer }, { token: i0.ComponentFactoryResolver }, { token: i0.ApplicationRef }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable });
433
+ Overlay.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: Overlay, providedIn: 'root' });
434
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: Overlay, decorators: [{
435
+ type: Injectable,
436
+ args: [{ providedIn: 'root' }]
437
+ }], ctorParameters: function () { return [{ type: OverlayContainer }, { type: i0.ComponentFactoryResolver }, { type: i0.ApplicationRef }, { type: undefined, decorators: [{
438
+ type: Inject,
439
+ args: [DOCUMENT]
440
+ }] }]; } });
441
+
442
+ class ToastrService {
443
+ constructor(token, overlay, _injector, sanitizer, ngZone) {
444
+ this.overlay = overlay;
445
+ this._injector = _injector;
446
+ this.sanitizer = sanitizer;
447
+ this.ngZone = ngZone;
448
+ this.currentlyActive = 0;
449
+ this.toasts = [];
450
+ this.index = 0;
451
+ this.toastrConfig = {
452
+ ...token.default,
453
+ ...token.config,
454
+ };
455
+ if (token.config.iconClasses) {
456
+ this.toastrConfig.iconClasses = {
457
+ ...token.default.iconClasses,
458
+ ...token.config.iconClasses,
459
+ };
460
+ }
461
+ }
462
+ /** show toast */
463
+ show(message, title, override = {}, type = '') {
464
+ return this._preBuildNotification(type, message, title, this.applyConfig(override));
465
+ }
466
+ /** show successful toast */
467
+ success(message, title, override = {}) {
468
+ const type = this.toastrConfig.iconClasses.success || '';
469
+ return this._preBuildNotification(type, message, title, this.applyConfig(override));
470
+ }
471
+ /** show error toast */
472
+ error(message, title, override = {}) {
473
+ const type = this.toastrConfig.iconClasses.error || '';
474
+ return this._preBuildNotification(type, message, title, this.applyConfig(override));
475
+ }
476
+ /** show info toast */
477
+ info(message, title, override = {}) {
478
+ const type = this.toastrConfig.iconClasses.info || '';
479
+ return this._preBuildNotification(type, message, title, this.applyConfig(override));
480
+ }
481
+ /** show warning toast */
482
+ warning(message, title, override = {}) {
483
+ const type = this.toastrConfig.iconClasses.warning || '';
484
+ return this._preBuildNotification(type, message, title, this.applyConfig(override));
485
+ }
486
+ /**
487
+ * Remove all or a single toast by id
488
+ */
489
+ clear(toastId) {
490
+ // Call every toastRef manualClose function
491
+ for (const toast of this.toasts) {
492
+ if (toastId !== undefined) {
493
+ if (toast.toastId === toastId) {
494
+ toast.toastRef.manualClose();
495
+ return;
496
+ }
497
+ }
498
+ else {
499
+ toast.toastRef.manualClose();
500
+ }
501
+ }
502
+ }
503
+ /**
504
+ * Remove and destroy a single toast by id
505
+ */
506
+ remove(toastId) {
507
+ const found = this._findToast(toastId);
508
+ if (!found) {
509
+ return false;
510
+ }
511
+ found.activeToast.toastRef.close();
512
+ this.toasts.splice(found.index, 1);
513
+ this.currentlyActive = this.currentlyActive - 1;
514
+ if (!this.toastrConfig.maxOpened || !this.toasts.length) {
515
+ return false;
516
+ }
517
+ if (this.currentlyActive < this.toastrConfig.maxOpened && this.toasts[this.currentlyActive]) {
518
+ const p = this.toasts[this.currentlyActive].toastRef;
519
+ if (!p.isInactive()) {
520
+ this.currentlyActive = this.currentlyActive + 1;
521
+ p.activate();
522
+ }
523
+ }
524
+ return true;
525
+ }
526
+ /**
527
+ * Determines if toast message is already shown
528
+ */
529
+ findDuplicate(title = '', message = '', resetOnDuplicate, countDuplicates) {
530
+ const { includeTitleDuplicates } = this.toastrConfig;
531
+ for (const toast of this.toasts) {
532
+ const hasDuplicateTitle = includeTitleDuplicates && toast.title === title;
533
+ if ((!includeTitleDuplicates || hasDuplicateTitle) && toast.message === message) {
534
+ toast.toastRef.onDuplicate(resetOnDuplicate, countDuplicates);
535
+ return toast;
536
+ }
537
+ }
538
+ return null;
539
+ }
540
+ /** create a clone of global config and apply individual settings */
541
+ applyConfig(override = {}) {
542
+ return { ...this.toastrConfig, ...override };
543
+ }
544
+ /**
545
+ * Find toast object by id
546
+ */
547
+ _findToast(toastId) {
548
+ for (let i = 0; i < this.toasts.length; i++) {
549
+ if (this.toasts[i].toastId === toastId) {
550
+ return { index: i, activeToast: this.toasts[i] };
551
+ }
552
+ }
553
+ return null;
554
+ }
555
+ /**
556
+ * Determines the need to run inside angular's zone then builds the toast
557
+ */
558
+ _preBuildNotification(toastType, message, title, config) {
559
+ if (config.onActivateTick) {
560
+ return this.ngZone.run(() => this._buildNotification(toastType, message, title, config));
561
+ }
562
+ return this._buildNotification(toastType, message, title, config);
563
+ }
564
+ /**
565
+ * Creates and attaches toast data to component
566
+ * returns the active toast, or in case preventDuplicates is enabled the original/non-duplicate active toast.
567
+ */
568
+ _buildNotification(toastType, message, title, config) {
569
+ if (!config.toastComponent) {
570
+ throw new Error('toastComponent required');
571
+ }
572
+ // max opened and auto dismiss = true
573
+ // if timeout = 0 resetting it would result in setting this.hideTime = Date.now(). Hence, we only want to reset timeout if there is
574
+ // a timeout at all
575
+ const duplicate = this.findDuplicate(title, message, this.toastrConfig.resetTimeoutOnDuplicate && config.timeOut > 0, this.toastrConfig.countDuplicates);
576
+ if (((this.toastrConfig.includeTitleDuplicates && title) || message) &&
577
+ this.toastrConfig.preventDuplicates &&
578
+ duplicate !== null) {
579
+ return duplicate;
580
+ }
581
+ this.previousToastMessage = message;
582
+ let keepInactive = false;
583
+ if (this.toastrConfig.maxOpened && this.currentlyActive >= this.toastrConfig.maxOpened) {
584
+ keepInactive = true;
585
+ if (this.toastrConfig.autoDismiss) {
586
+ this.clear(this.toasts[0].toastId);
587
+ }
588
+ }
589
+ const overlayRef = this.overlay.create(config.positionClass, this.overlayContainer);
590
+ this.index = this.index + 1;
591
+ let sanitizedMessage = message;
592
+ if (message && config.enableHtml) {
593
+ sanitizedMessage = this.sanitizer.sanitize(SecurityContext.HTML, message);
594
+ }
595
+ const toastRef = new ToastRef(overlayRef);
596
+ const toastPackage = new ToastPackage(this.index, config, sanitizedMessage, title, toastType, toastRef);
597
+ const toastInjector = new ToastInjector(toastPackage, this._injector);
598
+ const component = new ComponentPortal(config.toastComponent, toastInjector);
599
+ const portal = overlayRef.attach(component, this.toastrConfig.newestOnTop);
600
+ toastRef.componentInstance = portal.instance;
601
+ const ins = {
602
+ toastId: this.index,
603
+ title: title || '',
604
+ message: message || '',
605
+ toastRef,
606
+ onShown: toastRef.afterActivate(),
607
+ onHidden: toastRef.afterClosed(),
608
+ onTap: toastPackage.onTap(),
609
+ onAction: toastPackage.onAction(),
610
+ portal,
611
+ };
612
+ if (!keepInactive) {
613
+ this.currentlyActive = this.currentlyActive + 1;
614
+ setTimeout(() => {
615
+ ins.toastRef.activate();
616
+ });
617
+ }
618
+ this.toasts.push(ins);
619
+ return ins;
620
+ }
621
+ }
622
+ ToastrService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: ToastrService, deps: [{ token: TOAST_CONFIG }, { token: Overlay }, { token: i0.Injector }, { token: i2.DomSanitizer }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Injectable });
623
+ ToastrService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: ToastrService, providedIn: 'root' });
624
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: ToastrService, decorators: [{
625
+ type: Injectable,
626
+ args: [{ providedIn: 'root' }]
627
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
628
+ type: Inject,
629
+ args: [TOAST_CONFIG]
630
+ }] }, { type: Overlay }, { type: i0.Injector }, { type: i2.DomSanitizer }, { type: i0.NgZone }]; } });
631
+
632
+ class Toast {
633
+ constructor(toastrService, toastPackage, ngZone) {
634
+ this.toastrService = toastrService;
635
+ this.toastPackage = toastPackage;
636
+ this.ngZone = ngZone;
637
+ /** width of progress bar */
638
+ this.width = -1;
639
+ /** a combination of toast type and options.toastClass */
640
+ this.toastClasses = '';
641
+ /** controls animation */
642
+ this.state = {
643
+ value: 'inactive',
644
+ params: {
645
+ easeTime: this.toastPackage.config.easeTime,
646
+ easing: 'ease-in'
647
+ }
648
+ };
649
+ this.message = toastPackage.message;
650
+ this.title = toastPackage.title;
651
+ this.options = toastPackage.config;
652
+ this.originalTimeout = toastPackage.config.timeOut;
653
+ this.toastClasses = `${toastPackage.toastType} ${toastPackage.config.toastClass}`;
654
+ this.sub = toastPackage.toastRef.afterActivate().subscribe(() => {
655
+ this.activateToast();
656
+ });
657
+ this.sub1 = toastPackage.toastRef.manualClosed().subscribe(() => {
658
+ this.remove();
659
+ });
660
+ this.sub2 = toastPackage.toastRef.timeoutReset().subscribe(() => {
661
+ this.resetTimeout();
662
+ });
663
+ this.sub3 = toastPackage.toastRef.countDuplicate().subscribe(count => {
664
+ this.duplicatesCount = count;
665
+ });
666
+ }
667
+ /** hides component when waiting to be displayed */
668
+ get displayStyle() {
669
+ if (this.state.value === 'inactive') {
670
+ return 'none';
671
+ }
672
+ return;
673
+ }
674
+ ngOnDestroy() {
675
+ this.sub.unsubscribe();
676
+ this.sub1.unsubscribe();
677
+ this.sub2.unsubscribe();
678
+ this.sub3.unsubscribe();
679
+ clearInterval(this.intervalId);
680
+ clearTimeout(this.timeout);
681
+ }
682
+ /**
683
+ * activates toast and sets timeout
684
+ */
685
+ activateToast() {
686
+ this.state = { ...this.state, value: 'active' };
687
+ if (!(this.options.disableTimeOut === true || this.options.disableTimeOut === 'timeOut') && this.options.timeOut) {
688
+ this.outsideTimeout(() => this.remove(), this.options.timeOut);
689
+ this.hideTime = new Date().getTime() + this.options.timeOut;
690
+ if (this.options.progressBar) {
691
+ this.outsideInterval(() => this.updateProgress(), 10);
692
+ }
693
+ }
694
+ }
695
+ /**
696
+ * updates progress bar width
697
+ */
698
+ updateProgress() {
699
+ if (this.width === 0 || this.width === 100 || !this.options.timeOut) {
700
+ return;
701
+ }
702
+ const now = new Date().getTime();
703
+ const remaining = this.hideTime - now;
704
+ this.width = (remaining / this.options.timeOut) * 100;
705
+ if (this.options.progressAnimation === 'increasing') {
706
+ this.width = 100 - this.width;
707
+ }
708
+ if (this.width <= 0) {
709
+ this.width = 0;
710
+ }
711
+ if (this.width >= 100) {
712
+ this.width = 100;
713
+ }
714
+ }
715
+ resetTimeout() {
716
+ clearTimeout(this.timeout);
717
+ clearInterval(this.intervalId);
718
+ this.state = { ...this.state, value: 'active' };
719
+ this.outsideTimeout(() => this.remove(), this.originalTimeout);
720
+ this.options.timeOut = this.originalTimeout;
721
+ this.hideTime = new Date().getTime() + (this.options.timeOut || 0);
722
+ this.width = -1;
723
+ if (this.options.progressBar) {
724
+ this.outsideInterval(() => this.updateProgress(), 10);
725
+ }
726
+ }
727
+ /**
728
+ * tells toastrService to remove this toast after animation time
729
+ */
730
+ remove() {
731
+ if (this.state.value === 'removed') {
732
+ return;
733
+ }
734
+ clearTimeout(this.timeout);
735
+ this.state = { ...this.state, value: 'removed' };
736
+ this.outsideTimeout(() => this.toastrService.remove(this.toastPackage.toastId), +this.toastPackage.config.easeTime);
737
+ }
738
+ tapToast() {
739
+ if (this.state.value === 'removed') {
740
+ return;
741
+ }
742
+ this.toastPackage.triggerTap();
743
+ if (this.options.tapToDismiss) {
744
+ this.remove();
745
+ }
746
+ }
747
+ stickAround() {
748
+ if (this.state.value === 'removed') {
749
+ return;
750
+ }
751
+ clearTimeout(this.timeout);
752
+ this.options.timeOut = 0;
753
+ this.hideTime = 0;
754
+ // disable progressBar
755
+ clearInterval(this.intervalId);
756
+ this.width = 0;
757
+ }
758
+ delayedHideToast() {
759
+ if ((this.options.disableTimeOut === true || this.options.disableTimeOut === 'extendedTimeOut') ||
760
+ this.options.extendedTimeOut === 0 ||
761
+ this.state.value === 'removed') {
762
+ return;
763
+ }
764
+ this.outsideTimeout(() => this.remove(), this.options.extendedTimeOut);
765
+ this.options.timeOut = this.options.extendedTimeOut;
766
+ this.hideTime = new Date().getTime() + (this.options.timeOut || 0);
767
+ this.width = -1;
768
+ if (this.options.progressBar) {
769
+ this.outsideInterval(() => this.updateProgress(), 10);
770
+ }
771
+ }
772
+ outsideTimeout(func, timeout) {
773
+ if (this.ngZone) {
774
+ this.ngZone.runOutsideAngular(() => (this.timeout = setTimeout(() => this.runInsideAngular(func), timeout)));
775
+ }
776
+ else {
777
+ this.timeout = setTimeout(() => func(), timeout);
778
+ }
779
+ }
780
+ outsideInterval(func, timeout) {
781
+ if (this.ngZone) {
782
+ this.ngZone.runOutsideAngular(() => (this.intervalId = setInterval(() => this.runInsideAngular(func), timeout)));
783
+ }
784
+ else {
785
+ this.intervalId = setInterval(() => func(), timeout);
786
+ }
787
+ }
788
+ runInsideAngular(func) {
789
+ if (this.ngZone) {
790
+ this.ngZone.run(() => func());
791
+ }
792
+ else {
793
+ func();
794
+ }
795
+ }
796
+ }
797
+ Toast.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: Toast, deps: [{ token: ToastrService }, { token: ToastPackage }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
798
+ Toast.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.2", type: Toast, selector: "[toast-component]", host: { listeners: { "click": "tapToast()", "mouseenter": "stickAround()", "mouseleave": "delayedHideToast()" }, properties: { "class": "this.toastClasses", "@flyInOut": "this.state", "style.display": "this.displayStyle" } }, ngImport: i0, template: `
799
+ <button *ngIf="options.closeButton" (click)="remove()" type="button" class="toast-close-button" aria-label="Close">
800
+ <span aria-hidden="true">&times;</span>
801
+ </button>
802
+ <div *ngIf="title" [class]="options.titleClass" [attr.aria-label]="title">
803
+ {{ title }} <ng-container *ngIf="duplicatesCount">[{{ duplicatesCount + 1 }}]</ng-container>
804
+ </div>
805
+ <div *ngIf="message && options.enableHtml" role="alertdialog" aria-live="polite"
806
+ [class]="options.messageClass" [innerHTML]="message">
807
+ </div>
808
+ <div *ngIf="message && !options.enableHtml" role="alertdialog" aria-live="polite"
809
+ [class]="options.messageClass" [attr.aria-label]="message">
810
+ {{ message }}
811
+ </div>
812
+ <div *ngIf="options.progressBar">
813
+ <div class="toast-progress" [style.width]="width + '%'"></div>
814
+ </div>
815
+ `, isInline: true, directives: [{ type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], animations: [
816
+ trigger('flyInOut', [
817
+ state('inactive', style({ opacity: 0 })),
818
+ state('active', style({ opacity: 1 })),
819
+ state('removed', style({ opacity: 0 })),
820
+ transition('inactive => active', animate('{{ easeTime }}ms {{ easing }}')),
821
+ transition('active => removed', animate('{{ easeTime }}ms {{ easing }}'))
822
+ ])
823
+ ] });
824
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: Toast, decorators: [{
825
+ type: Component,
826
+ args: [{
827
+ selector: '[toast-component]',
828
+ template: `
829
+ <button *ngIf="options.closeButton" (click)="remove()" type="button" class="toast-close-button" aria-label="Close">
830
+ <span aria-hidden="true">&times;</span>
831
+ </button>
832
+ <div *ngIf="title" [class]="options.titleClass" [attr.aria-label]="title">
833
+ {{ title }} <ng-container *ngIf="duplicatesCount">[{{ duplicatesCount + 1 }}]</ng-container>
834
+ </div>
835
+ <div *ngIf="message && options.enableHtml" role="alertdialog" aria-live="polite"
836
+ [class]="options.messageClass" [innerHTML]="message">
837
+ </div>
838
+ <div *ngIf="message && !options.enableHtml" role="alertdialog" aria-live="polite"
839
+ [class]="options.messageClass" [attr.aria-label]="message">
840
+ {{ message }}
841
+ </div>
842
+ <div *ngIf="options.progressBar">
843
+ <div class="toast-progress" [style.width]="width + '%'"></div>
844
+ </div>
845
+ `,
846
+ animations: [
847
+ trigger('flyInOut', [
848
+ state('inactive', style({ opacity: 0 })),
849
+ state('active', style({ opacity: 1 })),
850
+ state('removed', style({ opacity: 0 })),
851
+ transition('inactive => active', animate('{{ easeTime }}ms {{ easing }}')),
852
+ transition('active => removed', animate('{{ easeTime }}ms {{ easing }}'))
853
+ ])
854
+ ],
855
+ preserveWhitespaces: false
856
+ }]
857
+ }], ctorParameters: function () { return [{ type: ToastrService }, { type: ToastPackage }, { type: i0.NgZone }]; }, propDecorators: { toastClasses: [{
858
+ type: HostBinding,
859
+ args: ['class']
860
+ }], state: [{
861
+ type: HostBinding,
862
+ args: ['@flyInOut']
863
+ }], displayStyle: [{
864
+ type: HostBinding,
865
+ args: ['style.display']
866
+ }], tapToast: [{
867
+ type: HostListener,
868
+ args: ['click']
869
+ }], stickAround: [{
870
+ type: HostListener,
871
+ args: ['mouseenter']
872
+ }], delayedHideToast: [{
873
+ type: HostListener,
874
+ args: ['mouseleave']
875
+ }] } });
876
+
877
+ const DefaultGlobalConfig = {
878
+ ...DefaultNoComponentGlobalConfig,
879
+ toastComponent: Toast,
880
+ };
881
+ class ToastrModule {
882
+ static forRoot(config = {}) {
883
+ return {
884
+ ngModule: ToastrModule,
885
+ providers: [
886
+ {
887
+ provide: TOAST_CONFIG,
888
+ useValue: {
889
+ default: DefaultGlobalConfig,
890
+ config,
891
+ },
892
+ },
893
+ ],
894
+ };
895
+ }
896
+ }
897
+ ToastrModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: ToastrModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
898
+ ToastrModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: ToastrModule, declarations: [Toast], imports: [CommonModule], exports: [Toast] });
899
+ ToastrModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: ToastrModule, imports: [[CommonModule]] });
900
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: ToastrModule, decorators: [{
901
+ type: NgModule,
902
+ args: [{
903
+ imports: [CommonModule],
904
+ declarations: [Toast],
905
+ exports: [Toast],
906
+ entryComponents: [Toast],
907
+ }]
908
+ }] });
909
+ class ToastrComponentlessModule {
910
+ static forRoot(config = {}) {
911
+ return {
912
+ ngModule: ToastrModule,
913
+ providers: [
914
+ {
915
+ provide: TOAST_CONFIG,
916
+ useValue: {
917
+ default: DefaultNoComponentGlobalConfig,
918
+ config,
919
+ },
920
+ },
921
+ ],
922
+ };
923
+ }
924
+ }
925
+ ToastrComponentlessModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: ToastrComponentlessModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
926
+ ToastrComponentlessModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: ToastrComponentlessModule, imports: [CommonModule] });
927
+ ToastrComponentlessModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: ToastrComponentlessModule, imports: [[CommonModule]] });
928
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: ToastrComponentlessModule, decorators: [{
929
+ type: NgModule,
930
+ args: [{
931
+ imports: [CommonModule],
932
+ }]
933
+ }] });
934
+
935
+ class ToastNoAnimation {
936
+ constructor(toastrService, toastPackage, appRef) {
937
+ this.toastrService = toastrService;
938
+ this.toastPackage = toastPackage;
939
+ this.appRef = appRef;
940
+ /** width of progress bar */
941
+ this.width = -1;
942
+ /** a combination of toast type and options.toastClass */
943
+ this.toastClasses = '';
944
+ /** controls animation */
945
+ this.state = 'inactive';
946
+ this.message = toastPackage.message;
947
+ this.title = toastPackage.title;
948
+ this.options = toastPackage.config;
949
+ this.originalTimeout = toastPackage.config.timeOut;
950
+ this.toastClasses = `${toastPackage.toastType} ${toastPackage.config.toastClass}`;
951
+ this.sub = toastPackage.toastRef.afterActivate().subscribe(() => {
952
+ this.activateToast();
953
+ });
954
+ this.sub1 = toastPackage.toastRef.manualClosed().subscribe(() => {
955
+ this.remove();
956
+ });
957
+ this.sub2 = toastPackage.toastRef.timeoutReset().subscribe(() => {
958
+ this.resetTimeout();
959
+ });
960
+ this.sub3 = toastPackage.toastRef.countDuplicate().subscribe(count => {
961
+ this.duplicatesCount = count;
962
+ });
963
+ }
964
+ /** hides component when waiting to be displayed */
965
+ get displayStyle() {
966
+ if (this.state === 'inactive') {
967
+ return 'none';
968
+ }
969
+ }
970
+ ngOnDestroy() {
971
+ this.sub.unsubscribe();
972
+ this.sub1.unsubscribe();
973
+ this.sub2.unsubscribe();
974
+ this.sub3.unsubscribe();
975
+ clearInterval(this.intervalId);
976
+ clearTimeout(this.timeout);
977
+ }
978
+ /**
979
+ * activates toast and sets timeout
980
+ */
981
+ activateToast() {
982
+ this.state = 'active';
983
+ if (!(this.options.disableTimeOut === true || this.options.disableTimeOut === 'timeOut') && this.options.timeOut) {
984
+ this.timeout = setTimeout(() => {
985
+ this.remove();
986
+ }, this.options.timeOut);
987
+ this.hideTime = new Date().getTime() + this.options.timeOut;
988
+ if (this.options.progressBar) {
989
+ this.intervalId = setInterval(() => this.updateProgress(), 10);
990
+ }
991
+ }
992
+ if (this.options.onActivateTick) {
993
+ this.appRef.tick();
994
+ }
995
+ }
996
+ /**
997
+ * updates progress bar width
998
+ */
999
+ updateProgress() {
1000
+ if (this.width === 0 || this.width === 100 || !this.options.timeOut) {
1001
+ return;
1002
+ }
1003
+ const now = new Date().getTime();
1004
+ const remaining = this.hideTime - now;
1005
+ this.width = (remaining / this.options.timeOut) * 100;
1006
+ if (this.options.progressAnimation === 'increasing') {
1007
+ this.width = 100 - this.width;
1008
+ }
1009
+ if (this.width <= 0) {
1010
+ this.width = 0;
1011
+ }
1012
+ if (this.width >= 100) {
1013
+ this.width = 100;
1014
+ }
1015
+ }
1016
+ resetTimeout() {
1017
+ clearTimeout(this.timeout);
1018
+ clearInterval(this.intervalId);
1019
+ this.state = 'active';
1020
+ this.options.timeOut = this.originalTimeout;
1021
+ this.timeout = setTimeout(() => this.remove(), this.originalTimeout);
1022
+ this.hideTime = new Date().getTime() + (this.originalTimeout || 0);
1023
+ this.width = -1;
1024
+ if (this.options.progressBar) {
1025
+ this.intervalId = setInterval(() => this.updateProgress(), 10);
1026
+ }
1027
+ }
1028
+ /**
1029
+ * tells toastrService to remove this toast after animation time
1030
+ */
1031
+ remove() {
1032
+ if (this.state === 'removed') {
1033
+ return;
1034
+ }
1035
+ clearTimeout(this.timeout);
1036
+ this.state = 'removed';
1037
+ this.timeout = setTimeout(() => this.toastrService.remove(this.toastPackage.toastId));
1038
+ }
1039
+ tapToast() {
1040
+ if (this.state === 'removed') {
1041
+ return;
1042
+ }
1043
+ this.toastPackage.triggerTap();
1044
+ if (this.options.tapToDismiss) {
1045
+ this.remove();
1046
+ }
1047
+ }
1048
+ stickAround() {
1049
+ if (this.state === 'removed') {
1050
+ return;
1051
+ }
1052
+ clearTimeout(this.timeout);
1053
+ this.options.timeOut = 0;
1054
+ this.hideTime = 0;
1055
+ // disable progressBar
1056
+ clearInterval(this.intervalId);
1057
+ this.width = 0;
1058
+ }
1059
+ delayedHideToast() {
1060
+ if ((this.options.disableTimeOut === true || this.options.disableTimeOut === 'extendedTimeOut') ||
1061
+ this.options.extendedTimeOut === 0 ||
1062
+ this.state === 'removed') {
1063
+ return;
1064
+ }
1065
+ this.timeout = setTimeout(() => this.remove(), this.options.extendedTimeOut);
1066
+ this.options.timeOut = this.options.extendedTimeOut;
1067
+ this.hideTime = new Date().getTime() + (this.options.timeOut || 0);
1068
+ this.width = -1;
1069
+ if (this.options.progressBar) {
1070
+ this.intervalId = setInterval(() => this.updateProgress(), 10);
1071
+ }
1072
+ }
1073
+ }
1074
+ ToastNoAnimation.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: ToastNoAnimation, deps: [{ token: ToastrService }, { token: ToastPackage }, { token: i0.ApplicationRef }], target: i0.ɵɵFactoryTarget.Component });
1075
+ ToastNoAnimation.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.2", type: ToastNoAnimation, selector: "[toast-component]", host: { listeners: { "click": "tapToast()", "mouseenter": "stickAround()", "mouseleave": "delayedHideToast()" }, properties: { "class": "this.toastClasses", "style.display": "this.displayStyle" } }, ngImport: i0, template: `
1076
+ <button *ngIf="options.closeButton" (click)="remove()" type="button" class="toast-close-button" aria-label="Close">
1077
+ <span aria-hidden="true">&times;</span>
1078
+ </button>
1079
+ <div *ngIf="title" [class]="options.titleClass" [attr.aria-label]="title">
1080
+ {{ title }} <ng-container *ngIf="duplicatesCount">[{{ duplicatesCount + 1 }}]</ng-container>
1081
+ </div>
1082
+ <div *ngIf="message && options.enableHtml" role="alert" aria-live="polite"
1083
+ [class]="options.messageClass" [innerHTML]="message">
1084
+ </div>
1085
+ <div *ngIf="message && !options.enableHtml" role="alert" aria-live="polite"
1086
+ [class]="options.messageClass" [attr.aria-label]="message">
1087
+ {{ message }}
1088
+ </div>
1089
+ <div *ngIf="options.progressBar">
1090
+ <div class="toast-progress" [style.width]="width + '%'"></div>
1091
+ </div>
1092
+ `, isInline: true, directives: [{ type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
1093
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: ToastNoAnimation, decorators: [{
1094
+ type: Component,
1095
+ args: [{
1096
+ selector: '[toast-component]',
1097
+ template: `
1098
+ <button *ngIf="options.closeButton" (click)="remove()" type="button" class="toast-close-button" aria-label="Close">
1099
+ <span aria-hidden="true">&times;</span>
1100
+ </button>
1101
+ <div *ngIf="title" [class]="options.titleClass" [attr.aria-label]="title">
1102
+ {{ title }} <ng-container *ngIf="duplicatesCount">[{{ duplicatesCount + 1 }}]</ng-container>
1103
+ </div>
1104
+ <div *ngIf="message && options.enableHtml" role="alert" aria-live="polite"
1105
+ [class]="options.messageClass" [innerHTML]="message">
1106
+ </div>
1107
+ <div *ngIf="message && !options.enableHtml" role="alert" aria-live="polite"
1108
+ [class]="options.messageClass" [attr.aria-label]="message">
1109
+ {{ message }}
1110
+ </div>
1111
+ <div *ngIf="options.progressBar">
1112
+ <div class="toast-progress" [style.width]="width + '%'"></div>
1113
+ </div>
1114
+ `,
1115
+ }]
1116
+ }], ctorParameters: function () { return [{ type: ToastrService }, { type: ToastPackage }, { type: i0.ApplicationRef }]; }, propDecorators: { toastClasses: [{
1117
+ type: HostBinding,
1118
+ args: ['class']
1119
+ }], displayStyle: [{
1120
+ type: HostBinding,
1121
+ args: ['style.display']
1122
+ }], tapToast: [{
1123
+ type: HostListener,
1124
+ args: ['click']
1125
+ }], stickAround: [{
1126
+ type: HostListener,
1127
+ args: ['mouseenter']
1128
+ }], delayedHideToast: [{
1129
+ type: HostListener,
1130
+ args: ['mouseleave']
1131
+ }] } });
1132
+ const DefaultNoAnimationsGlobalConfig = {
1133
+ ...DefaultNoComponentGlobalConfig,
1134
+ toastComponent: ToastNoAnimation,
1135
+ };
1136
+ class ToastNoAnimationModule {
1137
+ static forRoot(config = {}) {
1138
+ return {
1139
+ ngModule: ToastNoAnimationModule,
1140
+ providers: [
1141
+ {
1142
+ provide: TOAST_CONFIG,
1143
+ useValue: {
1144
+ default: DefaultNoAnimationsGlobalConfig,
1145
+ config,
1146
+ },
1147
+ },
1148
+ ],
1149
+ };
1150
+ }
1151
+ }
1152
+ ToastNoAnimationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: ToastNoAnimationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1153
+ ToastNoAnimationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: ToastNoAnimationModule, declarations: [ToastNoAnimation], imports: [CommonModule], exports: [ToastNoAnimation] });
1154
+ ToastNoAnimationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: ToastNoAnimationModule, imports: [[CommonModule]] });
1155
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: ToastNoAnimationModule, decorators: [{
1156
+ type: NgModule,
1157
+ args: [{
1158
+ imports: [CommonModule],
1159
+ declarations: [ToastNoAnimation],
1160
+ exports: [ToastNoAnimation],
1161
+ entryComponents: [ToastNoAnimation],
1162
+ }]
1163
+ }] });
1164
+
1165
+ /**
1166
+ * Generated bundle index. Do not edit.
1167
+ */
1168
+
1169
+ export { BasePortalHost, ComponentPortal, DefaultGlobalConfig, DefaultNoAnimationsGlobalConfig, DefaultNoComponentGlobalConfig, Overlay, OverlayContainer, OverlayRef, TOAST_CONFIG, Toast, ToastContainerDirective, ToastContainerModule, ToastInjector, ToastNoAnimation, ToastNoAnimationModule, ToastPackage, ToastRef, ToastrComponentlessModule, ToastrModule, ToastrService };
1170
+ //# sourceMappingURL=ngx-toastr.mjs.map