ngx-toastr 8.2.1 → 8.4.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.
@@ -1,91 +1,45 @@
1
- import * as tslib_1 from "tslib";
1
+ import { __extends, __values } from 'tslib';
2
2
  import { ApplicationRef, ComponentFactoryResolver, Injectable, Directive, ElementRef, NgModule, InjectionToken, Inject, Injector, NgZone, SecurityContext, Component, HostBinding, HostListener, Optional, SkipSelf } from '@angular/core';
3
3
  import { Subject } from 'rxjs/Subject';
4
4
  import { DomSanitizer } from '@angular/platform-browser';
5
5
  import { animate, state, style, transition, trigger } from '@angular/animations';
6
6
  import { CommonModule } from '@angular/common';
7
- /**
8
- * @fileoverview added by tsickle
9
- * @suppress {checkTypes} checked by tsc
10
- */
11
- /**
12
- * @record
13
- */
14
- /**
15
- * A `ComponentPortal` is a portal that instantiates some Component upon attachment.
16
- */
7
+
17
8
  var ComponentPortal = /** @class */ (function () {
18
- /**
19
- * @param {?} component
20
- * @param {?} injector
21
- */
22
9
  function ComponentPortal(component, injector) {
23
10
  this.component = component;
24
11
  this.injector = injector;
25
12
  }
26
- /**
27
- * Attach this portal to a host.
28
- * @param {?} host
29
- * @param {?} newestOnTop
30
- * @return {?}
31
- */
32
13
  ComponentPortal.prototype.attach = function (host, newestOnTop) {
33
14
  this._attachedHost = host;
34
15
  return host.attach(this, newestOnTop);
35
16
  };
36
- /**
37
- * Detach this portal from its host
38
- * @return {?}
39
- */
40
17
  ComponentPortal.prototype.detach = function () {
41
- var /** @type {?} */ host = this._attachedHost;
18
+ var host = this._attachedHost;
42
19
  if (host) {
43
20
  this._attachedHost = undefined;
44
21
  return host.detach();
45
22
  }
46
23
  };
47
24
  Object.defineProperty(ComponentPortal.prototype, "isAttached", {
48
- /**
49
- * Whether this portal is attached to a host.
50
- * @return {?}
51
- */
52
25
  get: function () {
53
26
  return this._attachedHost != null;
54
27
  },
55
28
  enumerable: true,
56
29
  configurable: true
57
30
  });
58
- /**
59
- * Sets the PortalHost reference without performing `attach()`. This is used directly by
60
- * the PortalHost when it is performing an `attach()` or `detach()`.
61
- * @param {?=} host
62
- * @return {?}
63
- */
64
31
  ComponentPortal.prototype.setAttachedHost = function (host) {
65
32
  this._attachedHost = host;
66
33
  };
67
34
  return ComponentPortal;
68
35
  }());
69
- /**
70
- * Partial implementation of PortalHost that only deals with attaching a
71
- * ComponentPortal
72
- * @abstract
73
- */
74
36
  var BasePortalHost = /** @class */ (function () {
75
37
  function BasePortalHost() {
76
38
  }
77
- /**
78
- * @param {?} portal
79
- * @param {?} newestOnTop
80
- * @return {?}
81
- */
82
39
  BasePortalHost.prototype.attach = function (portal, newestOnTop) {
83
40
  this._attachedPortal = portal;
84
41
  return this.attachComponentPortal(portal, newestOnTop);
85
42
  };
86
- /**
87
- * @return {?}
88
- */
89
43
  BasePortalHost.prototype.detach = function () {
90
44
  if (this._attachedPortal) {
91
45
  this._attachedPortal.setAttachedHost();
@@ -96,32 +50,13 @@ var BasePortalHost = /** @class */ (function () {
96
50
  this._disposeFn = undefined;
97
51
  }
98
52
  };
99
- /**
100
- * @param {?} fn
101
- * @return {?}
102
- */
103
53
  BasePortalHost.prototype.setDisposeFn = function (fn) {
104
54
  this._disposeFn = fn;
105
55
  };
106
56
  return BasePortalHost;
107
57
  }());
108
- /**
109
- * @fileoverview added by tsickle
110
- * @suppress {checkTypes} checked by tsc
111
- */
112
- /**
113
- * A PortalHost for attaching portals to an arbitrary DOM element outside of the Angular
114
- * application context.
115
- *
116
- * This is the only part of the portal core that directly touches the DOM.
117
- */
118
58
  var DomPortalHost = /** @class */ (function (_super) {
119
- tslib_1.__extends(DomPortalHost, _super);
120
- /**
121
- * @param {?} _hostDomElement
122
- * @param {?} _componentFactoryResolver
123
- * @param {?} _appRef
124
- */
59
+ __extends(DomPortalHost, _super);
125
60
  function DomPortalHost(_hostDomElement, _componentFactoryResolver, _appRef) {
126
61
  var _this = _super.call(this) || this;
127
62
  _this._hostDomElement = _hostDomElement;
@@ -129,34 +64,16 @@ var DomPortalHost = /** @class */ (function (_super) {
129
64
  _this._appRef = _appRef;
130
65
  return _this;
131
66
  }
132
- /**
133
- * Attach the given ComponentPortal to DOM element using the ComponentFactoryResolver.
134
- * @template T
135
- * @param {?} portal Portal to be attached
136
- * @param {?} newestOnTop
137
- * @return {?}
138
- */
139
67
  DomPortalHost.prototype.attachComponentPortal = function (portal, newestOnTop) {
140
68
  var _this = this;
141
- var /** @type {?} */ componentFactory = this._componentFactoryResolver.resolveComponentFactory(portal.component);
142
- var /** @type {?} */ componentRef;
143
- // If the portal specifies a ViewContainerRef, we will use that as the attachment point
144
- // for the component (in terms of Angular's component tree, not rendering).
145
- // When the ViewContainerRef is missing, we use the factory to create the component directly
146
- // and then manually attach the ChangeDetector for that component to the application (which
147
- // happens automatically when using a ViewContainer).
69
+ var componentFactory = this._componentFactoryResolver.resolveComponentFactory(portal.component);
70
+ var componentRef;
148
71
  componentRef = componentFactory.create(portal.injector);
149
- // When creating a component outside of a ViewContainer, we need to manually register
150
- // its ChangeDetector with the application. This API is unfortunately not yet published
151
- // in Angular core. The change detector must also be deregistered when the component
152
- // is destroyed to prevent memory leaks.
153
72
  this._appRef.attachView(componentRef.hostView);
154
73
  this.setDisposeFn(function () {
155
74
  _this._appRef.detachView(componentRef.hostView);
156
75
  componentRef.destroy();
157
76
  });
158
- // At this point the component has been instantiated, so we move it to the location in the DOM
159
- // where we want it to be rendered.
160
77
  if (newestOnTop) {
161
78
  this._hostDomElement.insertBefore(this._getComponentRootNode(componentRef), this._hostDomElement.firstChild);
162
79
  }
@@ -165,124 +82,51 @@ var DomPortalHost = /** @class */ (function (_super) {
165
82
  }
166
83
  return componentRef;
167
84
  };
168
- /**
169
- * Gets the root HTMLElement for an instantiated component.
170
- * @param {?} componentRef
171
- * @return {?}
172
- */
173
85
  DomPortalHost.prototype._getComponentRootNode = function (componentRef) {
174
- return /** @type {?} */ (((componentRef.hostView)).rootNodes[0]);
86
+ return (((componentRef.hostView)).rootNodes[0]);
175
87
  };
176
88
  return DomPortalHost;
177
89
  }(BasePortalHost));
178
- /**
179
- * @fileoverview added by tsickle
180
- * @suppress {checkTypes} checked by tsc
181
- */
182
- /**
183
- * Reference to an overlay that has been created with the Overlay service.
184
- * Used to manipulate or dispose of said overlay.
185
- */
186
90
  var OverlayRef = /** @class */ (function () {
187
- /**
188
- * @param {?} _portalHost
189
- */
190
91
  function OverlayRef(_portalHost) {
191
92
  this._portalHost = _portalHost;
192
93
  }
193
- /**
194
- * @param {?} portal
195
- * @param {?=} newestOnTop
196
- * @return {?}
197
- */
198
94
  OverlayRef.prototype.attach = function (portal, newestOnTop) {
199
95
  if (newestOnTop === void 0) { newestOnTop = true; }
200
96
  return this._portalHost.attach(portal, newestOnTop);
201
97
  };
202
- /**
203
- * Detaches an overlay from a portal.
204
- * @return {?} Resolves when the overlay has been detached.
205
- */
206
98
  OverlayRef.prototype.detach = function () {
207
99
  return this._portalHost.detach();
208
100
  };
209
101
  return OverlayRef;
210
102
  }());
211
- /**
212
- * @fileoverview added by tsickle
213
- * @suppress {checkTypes} checked by tsc
214
- */
215
- /**
216
- * The OverlayContainer is the container in which all overlays will load.
217
- * It should be provided in the root component to ensure it is properly shared.
218
- */
219
103
  var OverlayContainer = /** @class */ (function () {
220
104
  function OverlayContainer() {
221
105
  }
222
- /**
223
- * This method returns the overlay container element. It will lazily
224
- * create the element the first time it is called to facilitate using
225
- * the container in non-browser environments.
226
- * @return {?} the container element
227
- */
228
106
  OverlayContainer.prototype.getContainerElement = function () {
229
107
  if (!this._containerElement) {
230
108
  this._createContainer();
231
109
  }
232
110
  return this._containerElement;
233
111
  };
234
- /**
235
- * Create the overlay container element, which is simply a div
236
- * with the 'cdk-overlay-container' class on the document body.
237
- * @return {?}
238
- */
239
112
  OverlayContainer.prototype._createContainer = function () {
240
- var /** @type {?} */ container = document.createElement('div');
113
+ var container = document.createElement('div');
241
114
  container.classList.add('overlay-container');
242
115
  document.body.appendChild(container);
243
116
  this._containerElement = container;
244
117
  };
245
118
  return OverlayContainer;
246
119
  }());
247
- /**
248
- * @fileoverview added by tsickle
249
- * @suppress {checkTypes} checked by tsc
250
- */
251
- /**
252
- * Service to create Overlays. Overlays are dynamically added pieces of floating UI, meant to be
253
- * used as a low-level building building block for other components. Dialogs, tooltips, menus,
254
- * selects, etc. can all be built using overlays. The service should primarily be used by authors
255
- * of re-usable components rather than developers building end-user applications.
256
- *
257
- * An overlay *is* a PortalHost, so any kind of Portal can be loaded into one.
258
- */
259
120
  var Overlay = /** @class */ (function () {
260
- /**
261
- * @param {?} _overlayContainer
262
- * @param {?} _componentFactoryResolver
263
- * @param {?} _appRef
264
- */
265
121
  function Overlay(_overlayContainer, _componentFactoryResolver, _appRef) {
266
122
  this._overlayContainer = _overlayContainer;
267
123
  this._componentFactoryResolver = _componentFactoryResolver;
268
124
  this._appRef = _appRef;
269
125
  this._paneElements = {};
270
126
  }
271
- /**
272
- * Creates an overlay.
273
- * @param {?=} positionClass
274
- * @param {?=} overlayContainer
275
- * @return {?} A reference to the created overlay.
276
- */
277
127
  Overlay.prototype.create = function (positionClass, overlayContainer) {
278
- // get existing pane if possible
279
128
  return this._createOverlayRef(this.getPaneElement(positionClass, overlayContainer));
280
129
  };
281
- /**
282
- * @param {?=} positionClass
283
- * @param {?=} overlayContainer
284
- * @return {?}
285
- */
286
130
  Overlay.prototype.getPaneElement = function (positionClass, overlayContainer) {
287
131
  if (positionClass === void 0) { positionClass = ''; }
288
132
  if (!this._paneElements[positionClass]) {
@@ -290,14 +134,8 @@ var Overlay = /** @class */ (function () {
290
134
  }
291
135
  return this._paneElements[positionClass];
292
136
  };
293
- /**
294
- * Creates the DOM element for an overlay and appends it to the overlay container.
295
- * @param {?} positionClass
296
- * @param {?=} overlayContainer
297
- * @return {?} Newly-created pane element
298
- */
299
137
  Overlay.prototype._createPaneElement = function (positionClass, overlayContainer) {
300
- var /** @type {?} */ pane = document.createElement('div');
138
+ var pane = document.createElement('div');
301
139
  pane.id = 'toast-container';
302
140
  pane.classList.add(positionClass);
303
141
  pane.classList.add('toast-container');
@@ -309,19 +147,9 @@ var Overlay = /** @class */ (function () {
309
147
  }
310
148
  return pane;
311
149
  };
312
- /**
313
- * Create a DomPortalHost into which the overlay content can be loaded.
314
- * @param {?} pane The DOM element to turn into a portal host.
315
- * @return {?} A portal host for the given DOM element.
316
- */
317
150
  Overlay.prototype._createPortalHost = function (pane) {
318
151
  return new DomPortalHost(pane, this._componentFactoryResolver, this._appRef);
319
152
  };
320
- /**
321
- * Creates an OverlayRef for an overlay in the given DOM element.
322
- * @param {?} pane DOM element for the overlay
323
- * @return {?}
324
- */
325
153
  Overlay.prototype._createOverlayRef = function (pane) {
326
154
  return new OverlayRef(this._createPortalHost(pane));
327
155
  };
@@ -330,33 +158,19 @@ var Overlay = /** @class */ (function () {
330
158
  Overlay.decorators = [
331
159
  { type: Injectable },
332
160
  ];
333
- /** @nocollapse */
334
161
  Overlay.ctorParameters = function () { return [
335
162
  { type: OverlayContainer, },
336
163
  { type: ComponentFactoryResolver, },
337
164
  { type: ApplicationRef, },
338
165
  ]; };
339
- /**
340
- * Providers for Overlay and its related injectables.
341
- */
342
166
  var OVERLAY_PROVIDERS = [
343
167
  Overlay,
344
168
  OverlayContainer,
345
169
  ];
346
- /**
347
- * @fileoverview added by tsickle
348
- * @suppress {checkTypes} checked by tsc
349
- */
350
170
  var ToastContainerDirective = /** @class */ (function () {
351
- /**
352
- * @param {?} el
353
- */
354
171
  function ToastContainerDirective(el) {
355
172
  this.el = el;
356
173
  }
357
- /**
358
- * @return {?}
359
- */
360
174
  ToastContainerDirective.prototype.getContainerElement = function () {
361
175
  return this.el.nativeElement;
362
176
  };
@@ -368,7 +182,6 @@ ToastContainerDirective.decorators = [
368
182
  exportAs: 'toastContainer',
369
183
  },] },
370
184
  ];
371
- /** @nocollapse */
372
185
  ToastContainerDirective.ctorParameters = function () { return [
373
186
  { type: ElementRef, },
374
187
  ]; };
@@ -383,36 +196,8 @@ ToastContainerModule.decorators = [
383
196
  exports: [ToastContainerDirective],
384
197
  },] },
385
198
  ];
386
- /** @nocollapse */
387
199
  ToastContainerModule.ctorParameters = function () { return []; };
388
- /**
389
- * @fileoverview added by tsickle
390
- * @suppress {checkTypes} checked by tsc
391
- */
392
- /**
393
- * Configuration for an individual toast.
394
- * @record
395
- */
396
- /**
397
- * @record
398
- */
399
- /**
400
- * Global Toast configuration
401
- * Includes all IndividualConfig
402
- * @record
403
- */
404
- /**
405
- * Everything a toast needs to launch
406
- */
407
200
  var ToastPackage = /** @class */ (function () {
408
- /**
409
- * @param {?} toastId
410
- * @param {?} config
411
- * @param {?} message
412
- * @param {?} title
413
- * @param {?} toastType
414
- * @param {?} toastRef
415
- */
416
201
  function ToastPackage(toastId, config, message, title, toastType, toastRef) {
417
202
  var _this = this;
418
203
  this.toastId = toastId;
@@ -428,88 +213,35 @@ var ToastPackage = /** @class */ (function () {
428
213
  _this._onTap.complete();
429
214
  });
430
215
  }
431
- /**
432
- * Fired on click
433
- * @return {?}
434
- */
435
216
  ToastPackage.prototype.triggerTap = function () {
436
217
  this._onTap.next();
437
218
  this._onTap.complete();
438
219
  };
439
- /**
440
- * @return {?}
441
- */
442
220
  ToastPackage.prototype.onTap = function () {
443
221
  return this._onTap.asObservable();
444
222
  };
445
- /**
446
- * available for use in custom toast
447
- * @param {?=} action
448
- * @return {?}
449
- */
450
223
  ToastPackage.prototype.triggerAction = function (action) {
451
224
  this._onAction.next(action);
452
225
  };
453
- /**
454
- * @return {?}
455
- */
456
226
  ToastPackage.prototype.onAction = function () {
457
227
  return this._onAction.asObservable();
458
228
  };
459
229
  return ToastPackage;
460
230
  }());
461
- /**
462
- * @record
463
- */
464
- /**
465
- * @record
466
- */
467
- /**
468
- * @record
469
- */
470
- /**
471
- * @fileoverview added by tsickle
472
- * @suppress {checkTypes} checked by tsc
473
- */
474
- /**
475
- * Reference to a toast opened via the Toastr service.
476
- */
477
231
  var ToastRef = /** @class */ (function () {
478
- /**
479
- * @param {?} _overlayRef
480
- */
481
232
  function ToastRef(_overlayRef) {
482
233
  this._overlayRef = _overlayRef;
483
- /**
484
- * Subject for notifying the user that the toast has finished closing.
485
- */
486
234
  this._afterClosed = new Subject();
487
- /**
488
- * triggered when toast is activated
489
- */
490
235
  this._activate = new Subject();
491
- /**
492
- * notifies the toast that it should close before the timeout
493
- */
494
236
  this._manualClose = new Subject();
495
237
  }
496
- /**
497
- * @return {?}
498
- */
499
238
  ToastRef.prototype.manualClose = function () {
500
239
  this._manualClose.next();
501
240
  this._manualClose.complete();
502
241
  };
503
- /**
504
- * @return {?}
505
- */
506
242
  ToastRef.prototype.manualClosed = function () {
507
243
  return this._manualClose.asObservable();
508
244
  };
509
- /**
510
- * Close the toast.
511
- * @return {?}
512
- */
513
245
  ToastRef.prototype.close = function () {
514
246
  this._overlayRef.detach();
515
247
  this._afterClosed.next();
@@ -517,52 +249,26 @@ var ToastRef = /** @class */ (function () {
517
249
  this._manualClose.complete();
518
250
  this._activate.complete();
519
251
  };
520
- /**
521
- * Gets an observable that is notified when the toast is finished closing.
522
- * @return {?}
523
- */
524
252
  ToastRef.prototype.afterClosed = function () {
525
253
  return this._afterClosed.asObservable();
526
254
  };
527
- /**
528
- * @return {?}
529
- */
530
255
  ToastRef.prototype.isInactive = function () {
531
256
  return this._activate.isStopped;
532
257
  };
533
- /**
534
- * @return {?}
535
- */
536
258
  ToastRef.prototype.activate = function () {
537
259
  this._activate.next();
538
260
  this._activate.complete();
539
261
  };
540
- /**
541
- * Gets an observable that is notified when the toast has started opening.
542
- * @return {?}
543
- */
544
262
  ToastRef.prototype.afterActivate = function () {
545
263
  return this._activate.asObservable();
546
264
  };
547
265
  return ToastRef;
548
266
  }());
549
- /**
550
- * Custom injector type specifically for instantiating components with a toast.
551
- */
552
267
  var ToastInjector = /** @class */ (function () {
553
- /**
554
- * @param {?} _toastPackage
555
- * @param {?} _parentInjector
556
- */
557
268
  function ToastInjector(_toastPackage, _parentInjector) {
558
269
  this._toastPackage = _toastPackage;
559
270
  this._parentInjector = _parentInjector;
560
271
  }
561
- /**
562
- * @param {?} token
563
- * @param {?=} notFoundValue
564
- * @return {?}
565
- */
566
272
  ToastInjector.prototype.get = function (token, notFoundValue) {
567
273
  if (token === ToastPackage && this._toastPackage) {
568
274
  return this._toastPackage;
@@ -571,29 +277,8 @@ var ToastInjector = /** @class */ (function () {
571
277
  };
572
278
  return ToastInjector;
573
279
  }());
574
- /**
575
- * @fileoverview added by tsickle
576
- * @suppress {checkTypes} checked by tsc
577
- */
578
- /**
579
- * @record
580
- */
581
280
  var TOAST_CONFIG = new InjectionToken('ToastConfig');
582
- /**
583
- * @fileoverview added by tsickle
584
- * @suppress {checkTypes} checked by tsc
585
- */
586
- /**
587
- * @record
588
- */
589
281
  var ToastrService = /** @class */ (function () {
590
- /**
591
- * @param {?} token
592
- * @param {?} overlay
593
- * @param {?} _injector
594
- * @param {?} sanitizer
595
- * @param {?} ngZone
596
- */
597
282
  function ToastrService(token, overlay, _injector, sanitizer, ngZone) {
598
283
  this.overlay = overlay;
599
284
  this._injector = _injector;
@@ -602,80 +287,38 @@ var ToastrService = /** @class */ (function () {
602
287
  this.currentlyActive = 0;
603
288
  this.toasts = [];
604
289
  this.index = 0;
605
- var /** @type {?} */ defaultConfig = new token.defaults;
290
+ var defaultConfig = new token.defaults;
606
291
  this.toastrConfig = Object.assign({}, defaultConfig, token.config);
607
292
  this.toastrConfig.iconClasses = Object.assign({}, defaultConfig.iconClasses, token.config.iconClasses);
608
293
  }
609
- /**
610
- * show toast
611
- * @param {?=} message
612
- * @param {?=} title
613
- * @param {?=} override
614
- * @param {?=} type
615
- * @return {?}
616
- */
617
294
  ToastrService.prototype.show = function (message, title, override, type) {
618
295
  if (override === void 0) { override = {}; }
619
296
  if (type === void 0) { type = ''; }
620
297
  return this._preBuildNotification(type, message, title, this.applyConfig(override));
621
298
  };
622
- /**
623
- * show successful toast
624
- * @param {?=} message
625
- * @param {?=} title
626
- * @param {?=} override
627
- * @return {?}
628
- */
629
299
  ToastrService.prototype.success = function (message, title, override) {
630
300
  if (override === void 0) { override = {}; }
631
- var /** @type {?} */ type = this.toastrConfig.iconClasses.success || '';
301
+ var type = this.toastrConfig.iconClasses.success || '';
632
302
  return this._preBuildNotification(type, message, title, this.applyConfig(override));
633
303
  };
634
- /**
635
- * show error toast
636
- * @param {?=} message
637
- * @param {?=} title
638
- * @param {?=} override
639
- * @return {?}
640
- */
641
304
  ToastrService.prototype.error = function (message, title, override) {
642
305
  if (override === void 0) { override = {}; }
643
- var /** @type {?} */ type = this.toastrConfig.iconClasses.error || '';
306
+ var type = this.toastrConfig.iconClasses.error || '';
644
307
  return this._preBuildNotification(type, message, title, this.applyConfig(override));
645
308
  };
646
- /**
647
- * show info toast
648
- * @param {?=} message
649
- * @param {?=} title
650
- * @param {?=} override
651
- * @return {?}
652
- */
653
309
  ToastrService.prototype.info = function (message, title, override) {
654
310
  if (override === void 0) { override = {}; }
655
- var /** @type {?} */ type = this.toastrConfig.iconClasses.info || '';
311
+ var type = this.toastrConfig.iconClasses.info || '';
656
312
  return this._preBuildNotification(type, message, title, this.applyConfig(override));
657
313
  };
658
- /**
659
- * show warning toast
660
- * @param {?=} message
661
- * @param {?=} title
662
- * @param {?=} override
663
- * @return {?}
664
- */
665
314
  ToastrService.prototype.warning = function (message, title, override) {
666
315
  if (override === void 0) { override = {}; }
667
- var /** @type {?} */ type = this.toastrConfig.iconClasses.warning || '';
316
+ var type = this.toastrConfig.iconClasses.warning || '';
668
317
  return this._preBuildNotification(type, message, title, this.applyConfig(override));
669
318
  };
670
- /**
671
- * Remove all or a single toast by id
672
- * @param {?=} toastId
673
- * @return {?}
674
- */
675
319
  ToastrService.prototype.clear = function (toastId) {
676
320
  try {
677
- // Call every toastRef manualClose function
678
- for (var _a = tslib_1.__values(this.toasts), _b = _a.next(); !_b.done; _b = _a.next()) {
321
+ for (var _a = __values(this.toasts), _b = _a.next(); !_b.done; _b = _a.next()) {
679
322
  var toast = _b.value;
680
323
  if (toastId !== undefined) {
681
324
  if (toast.toastId === toastId) {
@@ -697,13 +340,8 @@ var ToastrService = /** @class */ (function () {
697
340
  }
698
341
  var e_1, _c;
699
342
  };
700
- /**
701
- * Remove and destroy a single toast by id
702
- * @param {?} toastId
703
- * @return {?}
704
- */
705
343
  ToastrService.prototype.remove = function (toastId) {
706
- var /** @type {?} */ found = this._findToast(toastId);
344
+ var found = this._findToast(toastId);
707
345
  if (!found) {
708
346
  return false;
709
347
  }
@@ -713,8 +351,8 @@ var ToastrService = /** @class */ (function () {
713
351
  if (!this.toastrConfig.maxOpened || !this.toasts.length) {
714
352
  return false;
715
353
  }
716
- if (this.currentlyActive <= +this.toastrConfig.maxOpened && this.toasts[this.currentlyActive]) {
717
- var /** @type {?} */ p = this.toasts[this.currentlyActive].toastRef;
354
+ if (this.currentlyActive < this.toastrConfig.maxOpened && this.toasts[this.currentlyActive]) {
355
+ var p = this.toasts[this.currentlyActive].toastRef;
718
356
  if (!p.isInactive()) {
719
357
  this.currentlyActive = this.currentlyActive + 1;
720
358
  p.activate();
@@ -722,49 +360,26 @@ var ToastrService = /** @class */ (function () {
722
360
  }
723
361
  return true;
724
362
  };
725
- /**
726
- * Determines if toast message is already shown
727
- * @param {?} message
728
- * @return {?}
729
- */
730
363
  ToastrService.prototype.isDuplicate = function (message) {
731
- for (var /** @type {?} */ i = 0; i < this.toasts.length; i++) {
364
+ for (var i = 0; i < this.toasts.length; i++) {
732
365
  if (this.toasts[i].message === message) {
733
366
  return true;
734
367
  }
735
368
  }
736
369
  return false;
737
370
  };
738
- /**
739
- * create a clone of global config and apply individual settings
740
- * @param {?=} override
741
- * @return {?}
742
- */
743
371
  ToastrService.prototype.applyConfig = function (override) {
744
372
  if (override === void 0) { override = {}; }
745
373
  return Object.assign({}, this.toastrConfig, override);
746
374
  };
747
- /**
748
- * Find toast object by id
749
- * @param {?} toastId
750
- * @return {?}
751
- */
752
375
  ToastrService.prototype._findToast = function (toastId) {
753
- for (var /** @type {?} */ i = 0; i < this.toasts.length; i++) {
376
+ for (var i = 0; i < this.toasts.length; i++) {
754
377
  if (this.toasts[i].toastId === toastId) {
755
378
  return { index: i, activeToast: this.toasts[i] };
756
379
  }
757
380
  }
758
381
  return null;
759
382
  };
760
- /**
761
- * Determines the need to run inside angular's zone then builds the toast
762
- * @param {?} toastType
763
- * @param {?} message
764
- * @param {?} title
765
- * @param {?} config
766
- * @return {?}
767
- */
768
383
  ToastrService.prototype._preBuildNotification = function (toastType, message, title, config) {
769
384
  var _this = this;
770
385
  if (config.onActivateTick) {
@@ -772,43 +387,35 @@ var ToastrService = /** @class */ (function () {
772
387
  }
773
388
  return this._buildNotification(toastType, message, title, config);
774
389
  };
775
- /**
776
- * Creates and attaches toast data to component
777
- * returns null if toast is duplicate and preventDuplicates == True
778
- * @param {?} toastType
779
- * @param {?} message
780
- * @param {?} title
781
- * @param {?} config
782
- * @return {?}
783
- */
784
390
  ToastrService.prototype._buildNotification = function (toastType, message, title, config) {
785
391
  var _this = this;
786
392
  if (!config.toastComponent) {
787
393
  throw new Error('toastComponent required');
788
394
  }
789
- // max opened and auto dismiss = true
790
395
  if (message && this.toastrConfig.preventDuplicates && this.isDuplicate(message)) {
791
396
  return null;
792
397
  }
793
398
  this.previousToastMessage = message;
794
- var /** @type {?} */ keepInactive = false;
399
+ var keepInactive = false;
795
400
  if (this.toastrConfig.maxOpened && this.currentlyActive >= this.toastrConfig.maxOpened) {
796
401
  keepInactive = true;
797
402
  if (this.toastrConfig.autoDismiss) {
798
403
  this.clear(this.toasts[this.toasts.length - 1].toastId);
799
404
  }
800
405
  }
801
- var /** @type {?} */ overlayRef = this.overlay.create(config.positionClass, this.overlayContainer);
406
+ var overlayRef = this.overlay.create(config.positionClass, this.overlayContainer);
802
407
  this.index = this.index + 1;
803
- var /** @type {?} */ sanitizedMessage = message;
408
+ var sanitizedMessage = message;
804
409
  if (message && config.enableHtml) {
805
410
  sanitizedMessage = this.sanitizer.sanitize(SecurityContext.HTML, message);
806
411
  }
807
- var /** @type {?} */ toastRef = new ToastRef(overlayRef);
808
- var /** @type {?} */ toastPackage = new ToastPackage(this.index, config, sanitizedMessage, title, toastType, toastRef);
809
- var /** @type {?} */ toastInjector = new ToastInjector(toastPackage, this._injector);
810
- var /** @type {?} */ component = new ComponentPortal(config.toastComponent, toastInjector);
811
- var /** @type {?} */ ins = {
412
+ var toastRef = new ToastRef(overlayRef);
413
+ var toastPackage = new ToastPackage(this.index, config, sanitizedMessage, title, toastType, toastRef);
414
+ var toastInjector = new ToastInjector(toastPackage, this._injector);
415
+ var component = new ComponentPortal(config.toastComponent, toastInjector);
416
+ var portal = overlayRef.attach(component, this.toastrConfig.newestOnTop);
417
+ toastRef.componentInstance = ((portal))._component;
418
+ var ins = {
812
419
  toastId: this.index,
813
420
  message: message || '',
814
421
  toastRef: toastRef,
@@ -816,7 +423,7 @@ var ToastrService = /** @class */ (function () {
816
423
  onHidden: toastRef.afterClosed(),
817
424
  onTap: toastPackage.onTap(),
818
425
  onAction: toastPackage.onAction(),
819
- portal: overlayRef.attach(component, this.toastrConfig.newestOnTop),
426
+ portal: portal,
820
427
  };
821
428
  if (!keepInactive) {
822
429
  setTimeout(function () {
@@ -832,7 +439,6 @@ var ToastrService = /** @class */ (function () {
832
439
  ToastrService.decorators = [
833
440
  { type: Injectable },
834
441
  ];
835
- /** @nocollapse */
836
442
  ToastrService.ctorParameters = function () { return [
837
443
  { type: undefined, decorators: [{ type: Inject, args: [TOAST_CONFIG,] },] },
838
444
  { type: Overlay, },
@@ -840,32 +446,14 @@ ToastrService.ctorParameters = function () { return [
840
446
  { type: DomSanitizer, },
841
447
  { type: NgZone, },
842
448
  ]; };
843
- /**
844
- * @fileoverview added by tsickle
845
- * @suppress {checkTypes} checked by tsc
846
- */
847
449
  var Toast = /** @class */ (function () {
848
- /**
849
- * @param {?} toastrService
850
- * @param {?} toastPackage
851
- * @param {?=} ngZone
852
- */
853
450
  function Toast(toastrService, toastPackage, ngZone) {
854
451
  var _this = this;
855
452
  this.toastrService = toastrService;
856
453
  this.toastPackage = toastPackage;
857
454
  this.ngZone = ngZone;
858
- /**
859
- * width of progress bar
860
- */
861
455
  this.width = -1;
862
- /**
863
- * a combination of toast type and options.toastClass
864
- */
865
456
  this.toastClasses = '';
866
- /**
867
- * controls animation
868
- */
869
457
  this.state = {
870
458
  value: 'inactive',
871
459
  params: {
@@ -884,19 +472,12 @@ var Toast = /** @class */ (function () {
884
472
  _this.remove();
885
473
  });
886
474
  }
887
- /**
888
- * @return {?}
889
- */
890
475
  Toast.prototype.ngOnDestroy = function () {
891
476
  this.sub.unsubscribe();
892
477
  this.sub1.unsubscribe();
893
478
  clearInterval(this.intervalId);
894
479
  clearTimeout(this.timeout);
895
480
  };
896
- /**
897
- * activates toast and sets timeout
898
- * @return {?}
899
- */
900
481
  Toast.prototype.activateToast = function () {
901
482
  var _this = this;
902
483
  this.state = Object.assign({}, this.state, { value: 'active' });
@@ -908,16 +489,12 @@ var Toast = /** @class */ (function () {
908
489
  }
909
490
  }
910
491
  };
911
- /**
912
- * updates progress bar width
913
- * @return {?}
914
- */
915
492
  Toast.prototype.updateProgress = function () {
916
493
  if (this.width === 0 || this.width === 100 || !this.options.timeOut) {
917
494
  return;
918
495
  }
919
- var /** @type {?} */ now = new Date().getTime();
920
- var /** @type {?} */ remaining = this.hideTime - now;
496
+ var now = new Date().getTime();
497
+ var remaining = this.hideTime - now;
921
498
  this.width = (remaining / this.options.timeOut) * 100;
922
499
  if (this.options.progressAnimation === 'increasing') {
923
500
  this.width = 100 - this.width;
@@ -929,10 +506,6 @@ var Toast = /** @class */ (function () {
929
506
  this.width = 100;
930
507
  }
931
508
  };
932
- /**
933
- * tells toastrService to remove this toast after animation time
934
- * @return {?}
935
- */
936
509
  Toast.prototype.remove = function () {
937
510
  var _this = this;
938
511
  if (this.state.value === 'removed') {
@@ -942,9 +515,6 @@ var Toast = /** @class */ (function () {
942
515
  this.state = Object.assign({}, this.state, { value: 'removed' });
943
516
  this.outsideTimeout(function () { return _this.toastrService.remove(_this.toastPackage.toastId); }, +this.toastPackage.config.easeTime);
944
517
  };
945
- /**
946
- * @return {?}
947
- */
948
518
  Toast.prototype.tapToast = function () {
949
519
  if (this.state.value === 'removed') {
950
520
  return;
@@ -954,9 +524,6 @@ var Toast = /** @class */ (function () {
954
524
  this.remove();
955
525
  }
956
526
  };
957
- /**
958
- * @return {?}
959
- */
960
527
  Toast.prototype.stickAround = function () {
961
528
  if (this.state.value === 'removed') {
962
529
  return;
@@ -964,13 +531,9 @@ var Toast = /** @class */ (function () {
964
531
  clearTimeout(this.timeout);
965
532
  this.options.timeOut = 0;
966
533
  this.hideTime = 0;
967
- // disable progressBar
968
534
  clearInterval(this.intervalId);
969
535
  this.width = 0;
970
536
  };
971
- /**
972
- * @return {?}
973
- */
974
537
  Toast.prototype.delayedHideToast = function () {
975
538
  var _this = this;
976
539
  if (this.options.disableTimeOut
@@ -986,11 +549,6 @@ var Toast = /** @class */ (function () {
986
549
  this.outsideInterval(function () { return _this.updateProgress(); }, 10);
987
550
  }
988
551
  };
989
- /**
990
- * @param {?} func
991
- * @param {?} timeout
992
- * @return {?}
993
- */
994
552
  Toast.prototype.outsideTimeout = function (func, timeout) {
995
553
  var _this = this;
996
554
  if (this.ngZone) {
@@ -1000,11 +558,6 @@ var Toast = /** @class */ (function () {
1000
558
  this.timeout = setTimeout(function () { return func(); }, timeout);
1001
559
  }
1002
560
  };
1003
- /**
1004
- * @param {?} func
1005
- * @param {?} timeout
1006
- * @return {?}
1007
- */
1008
561
  Toast.prototype.outsideInterval = function (func, timeout) {
1009
562
  var _this = this;
1010
563
  if (this.ngZone) {
@@ -1014,10 +567,6 @@ var Toast = /** @class */ (function () {
1014
567
  this.intervalId = setInterval(function () { return func(); }, timeout);
1015
568
  }
1016
569
  };
1017
- /**
1018
- * @param {?} func
1019
- * @return {?}
1020
- */
1021
570
  Toast.prototype.runInsideAngular = function (func) {
1022
571
  if (this.ngZone) {
1023
572
  this.ngZone.run(function () { return func(); });
@@ -1047,7 +596,6 @@ Toast.decorators = [
1047
596
  preserveWhitespaces: false,
1048
597
  },] },
1049
598
  ];
1050
- /** @nocollapse */
1051
599
  Toast.ctorParameters = function () { return [
1052
600
  { type: ToastrService, },
1053
601
  { type: ToastPackage, },
@@ -1060,13 +608,8 @@ Toast.propDecorators = {
1060
608
  "stickAround": [{ type: HostListener, args: ['mouseenter',] },],
1061
609
  "delayedHideToast": [{ type: HostListener, args: ['mouseleave',] },],
1062
610
  };
1063
- /**
1064
- * @fileoverview added by tsickle
1065
- * @suppress {checkTypes} checked by tsc
1066
- */
1067
611
  var DefaultGlobalConfig = /** @class */ (function () {
1068
612
  function DefaultGlobalConfig() {
1069
- // Global
1070
613
  this.maxOpened = 0;
1071
614
  this.autoDismiss = false;
1072
615
  this.newestOnTop = true;
@@ -1077,7 +620,6 @@ var DefaultGlobalConfig = /** @class */ (function () {
1077
620
  success: 'toast-success',
1078
621
  warning: 'toast-warning',
1079
622
  };
1080
- // Individual
1081
623
  this.toastComponent = Toast;
1082
624
  this.closeButton = false;
1083
625
  this.timeOut = 5000;
@@ -1096,23 +638,12 @@ var DefaultGlobalConfig = /** @class */ (function () {
1096
638
  }
1097
639
  return DefaultGlobalConfig;
1098
640
  }());
1099
- /**
1100
- * @fileoverview added by tsickle
1101
- * @suppress {checkTypes} checked by tsc
1102
- */
1103
641
  var ToastrModule = /** @class */ (function () {
1104
- /**
1105
- * @param {?} parentModule
1106
- */
1107
642
  function ToastrModule(parentModule) {
1108
643
  if (parentModule) {
1109
644
  throw new Error('ToastrModule is already loaded. It should only be imported in your application\'s main module.');
1110
645
  }
1111
646
  }
1112
- /**
1113
- * @param {?=} config
1114
- * @return {?}
1115
- */
1116
647
  ToastrModule.forRoot = function (config) {
1117
648
  if (config === void 0) { config = {}; }
1118
649
  return {
@@ -1135,36 +666,17 @@ ToastrModule.decorators = [
1135
666
  entryComponents: [Toast],
1136
667
  },] },
1137
668
  ];
1138
- /** @nocollapse */
1139
669
  ToastrModule.ctorParameters = function () { return [
1140
670
  { type: ToastrModule, decorators: [{ type: Optional }, { type: SkipSelf },] },
1141
671
  ]; };
1142
- /**
1143
- * @fileoverview added by tsickle
1144
- * @suppress {checkTypes} checked by tsc
1145
- */
1146
672
  var ToastNoAnimation = /** @class */ (function () {
1147
- /**
1148
- * @param {?} toastrService
1149
- * @param {?} toastPackage
1150
- * @param {?} appRef
1151
- */
1152
673
  function ToastNoAnimation(toastrService, toastPackage, appRef) {
1153
674
  var _this = this;
1154
675
  this.toastrService = toastrService;
1155
676
  this.toastPackage = toastPackage;
1156
677
  this.appRef = appRef;
1157
- /**
1158
- * width of progress bar
1159
- */
1160
678
  this.width = -1;
1161
- /**
1162
- * a combination of toast type and options.toastClass
1163
- */
1164
679
  this.toastClasses = '';
1165
- /**
1166
- * controls animation
1167
- */
1168
680
  this.state = 'inactive';
1169
681
  this.message = toastPackage.message;
1170
682
  this.title = toastPackage.title;
@@ -1177,19 +689,22 @@ var ToastNoAnimation = /** @class */ (function () {
1177
689
  _this.remove();
1178
690
  });
1179
691
  }
1180
- /**
1181
- * @return {?}
1182
- */
692
+ Object.defineProperty(ToastNoAnimation.prototype, "displayStyle", {
693
+ get: function () {
694
+ if (this.state === 'inactive') {
695
+ return 'none';
696
+ }
697
+ return 'inherit';
698
+ },
699
+ enumerable: true,
700
+ configurable: true
701
+ });
1183
702
  ToastNoAnimation.prototype.ngOnDestroy = function () {
1184
703
  this.sub.unsubscribe();
1185
704
  this.sub1.unsubscribe();
1186
705
  clearInterval(this.intervalId);
1187
706
  clearTimeout(this.timeout);
1188
707
  };
1189
- /**
1190
- * activates toast and sets timeout
1191
- * @return {?}
1192
- */
1193
708
  ToastNoAnimation.prototype.activateToast = function () {
1194
709
  var _this = this;
1195
710
  this.state = 'active';
@@ -1206,16 +721,12 @@ var ToastNoAnimation = /** @class */ (function () {
1206
721
  this.appRef.tick();
1207
722
  }
1208
723
  };
1209
- /**
1210
- * updates progress bar width
1211
- * @return {?}
1212
- */
1213
724
  ToastNoAnimation.prototype.updateProgress = function () {
1214
725
  if (this.width === 0 || this.width === 100 || !this.options.timeOut) {
1215
726
  return;
1216
727
  }
1217
- var /** @type {?} */ now = new Date().getTime();
1218
- var /** @type {?} */ remaining = this.hideTime - now;
728
+ var now = new Date().getTime();
729
+ var remaining = this.hideTime - now;
1219
730
  this.width = remaining / this.options.timeOut * 100;
1220
731
  if (this.options.progressAnimation === 'increasing') {
1221
732
  this.width = 100 - this.width;
@@ -1227,10 +738,6 @@ var ToastNoAnimation = /** @class */ (function () {
1227
738
  this.width = 100;
1228
739
  }
1229
740
  };
1230
- /**
1231
- * tells toastrService to remove this toast after animation time
1232
- * @return {?}
1233
- */
1234
741
  ToastNoAnimation.prototype.remove = function () {
1235
742
  var _this = this;
1236
743
  if (this.state === 'removed') {
@@ -1240,9 +747,6 @@ var ToastNoAnimation = /** @class */ (function () {
1240
747
  this.state = 'removed';
1241
748
  this.timeout = setTimeout(function () { return _this.toastrService.remove(_this.toastPackage.toastId); });
1242
749
  };
1243
- /**
1244
- * @return {?}
1245
- */
1246
750
  ToastNoAnimation.prototype.tapToast = function () {
1247
751
  if (this.state === 'removed') {
1248
752
  return;
@@ -1252,9 +756,6 @@ var ToastNoAnimation = /** @class */ (function () {
1252
756
  this.remove();
1253
757
  }
1254
758
  };
1255
- /**
1256
- * @return {?}
1257
- */
1258
759
  ToastNoAnimation.prototype.stickAround = function () {
1259
760
  if (this.state === 'removed') {
1260
761
  return;
@@ -1262,13 +763,9 @@ var ToastNoAnimation = /** @class */ (function () {
1262
763
  clearTimeout(this.timeout);
1263
764
  this.options.timeOut = 0;
1264
765
  this.hideTime = 0;
1265
- // disable progressBar
1266
766
  clearInterval(this.intervalId);
1267
767
  this.width = 0;
1268
768
  };
1269
- /**
1270
- * @return {?}
1271
- */
1272
769
  ToastNoAnimation.prototype.delayedHideToast = function () {
1273
770
  var _this = this;
1274
771
  if (this.options.disableTimeOut
@@ -1292,7 +789,6 @@ ToastNoAnimation.decorators = [
1292
789
  template: "\n <button *ngIf=\"options.closeButton\" (click)=\"remove()\" class=\"toast-close-button\" aria-label=\"Close\">\n <span aria-hidden=\"true\">&times;</span>\n </button>\n <div *ngIf=\"title\" [class]=\"options.titleClass\" [attr.aria-label]=\"title\">\n {{ title }}\n </div>\n <div *ngIf=\"message && options.enableHtml\" role=\"alert\" aria-live=\"polite\"\n [class]=\"options.messageClass\" [innerHTML]=\"message\">\n </div>\n <div *ngIf=\"message && !options.enableHtml\" role=\"alert\" aria-live=\"polite\"\n [class]=\"options.messageClass\" [attr.aria-label]=\"message\">\n {{ message }}\n </div>\n <div *ngIf=\"options.progressBar\">\n <div class=\"toast-progress\" [style.width]=\"width + '%'\"></div>\n </div>\n ",
1293
790
  },] },
1294
791
  ];
1295
- /** @nocollapse */
1296
792
  ToastNoAnimation.ctorParameters = function () { return [
1297
793
  { type: ToastrService, },
1298
794
  { type: ToastPackage, },
@@ -1300,6 +796,7 @@ ToastNoAnimation.ctorParameters = function () { return [
1300
796
  ]; };
1301
797
  ToastNoAnimation.propDecorators = {
1302
798
  "toastClasses": [{ type: HostBinding, args: ['class',] },],
799
+ "displayStyle": [{ type: HostBinding, args: ['style.display',] },],
1303
800
  "tapToast": [{ type: HostListener, args: ['click',] },],
1304
801
  "stickAround": [{ type: HostListener, args: ['mouseenter',] },],
1305
802
  "delayedHideToast": [{ type: HostListener, args: ['mouseleave',] },],
@@ -1317,18 +814,7 @@ ToastNoAnimationModule.decorators = [
1317
814
  entryComponents: [ToastNoAnimation],
1318
815
  },] },
1319
816
  ];
1320
- /** @nocollapse */
1321
817
  ToastNoAnimationModule.ctorParameters = function () { return []; };
1322
- /**
1323
- * @fileoverview added by tsickle
1324
- * @suppress {checkTypes} checked by tsc
1325
- */
1326
- /**
1327
- * @fileoverview added by tsickle
1328
- * @suppress {checkTypes} checked by tsc
1329
- */
1330
- /**
1331
- * Generated bundle index. Do not edit.
1332
- */
818
+
1333
819
  export { ComponentPortal, BasePortalHost, Overlay, OVERLAY_PROVIDERS, OverlayContainer, OverlayRef, ToastContainerDirective, ToastContainerModule, Toast, ToastrService, ToastPackage, DefaultGlobalConfig, ToastrModule, ToastRef, ToastInjector, TOAST_CONFIG, ToastNoAnimation, ToastNoAnimationModule };
1334
820
  //# sourceMappingURL=ngx-toastr.js.map