ngx-toastr 16.1.1 → 17.0.0

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