ngx-toastr 16.1.1 → 16.2.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,9 +1,8 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Directive, NgModule, InjectionToken, Injectable, Inject, SecurityContext, Injector, Component, HostBinding, HostListener } from '@angular/core';
2
+ import { Directive, InjectionToken, inject, Injectable, ComponentFactoryResolver, ApplicationRef, SecurityContext, Injector, Inject, Component, HostBinding, HostListener, makeEnvironmentProviders, NgModule } from '@angular/core';
3
3
  import { trigger, state, style, transition, animate } from '@angular/animations';
4
+ import { DOCUMENT, NgIf } from '@angular/common';
4
5
  import { Subject } from 'rxjs';
5
- import * as i3 from '@angular/common';
6
- import { DOCUMENT, CommonModule } from '@angular/common';
7
6
  import * as i2 from '@angular/platform-browser';
8
7
 
9
8
  class ToastContainerDirective {
@@ -15,26 +14,15 @@ class ToastContainerDirective {
15
14
  }
16
15
  }
17
16
  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 });
17
+ ToastContainerDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.7", type: ToastContainerDirective, isStandalone: true, selector: "[toastContainer]", exportAs: ["toastContainer"], ngImport: i0 });
19
18
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ToastContainerDirective, decorators: [{
20
19
  type: Directive,
21
20
  args: [{
22
21
  selector: '[toastContainer]',
23
22
  exportAs: 'toastContainer',
23
+ standalone: true
24
24
  }]
25
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
26
 
39
27
  /**
40
28
  * A `ComponentPortal` is a portal that instantiates some Component upon attachment.
@@ -284,30 +272,10 @@ class DomPortalHost extends BasePortalHost {
284
272
  }
285
273
  }
286
274
 
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
275
  /** Container inside which all toasts will render. */
308
276
  class OverlayContainer {
309
- constructor(_document) {
310
- this._document = _document;
277
+ constructor() {
278
+ this._document = inject(DOCUMENT);
311
279
  }
312
280
  ngOnDestroy() {
313
281
  if (this._containerElement && this._containerElement.parentNode) {
@@ -339,17 +307,32 @@ class OverlayContainer {
339
307
  this._containerElement = container;
340
308
  }
341
309
  }
342
- OverlayContainer.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: OverlayContainer, deps: [{ token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable });
310
+ OverlayContainer.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: OverlayContainer, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
343
311
  OverlayContainer.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: OverlayContainer, providedIn: 'root' });
344
312
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: OverlayContainer, decorators: [{
345
313
  type: Injectable,
346
314
  args: [{ providedIn: 'root' }]
347
- }], ctorParameters: function () {
348
- return [{ type: undefined, decorators: [{
349
- type: Inject,
350
- args: [DOCUMENT]
351
- }] }];
352
- } });
315
+ }] });
316
+
317
+ /**
318
+ * Reference to an overlay that has been created with the Overlay service.
319
+ * Used to manipulate or dispose of said overlay.
320
+ */
321
+ class OverlayRef {
322
+ constructor(_portalHost) {
323
+ this._portalHost = _portalHost;
324
+ }
325
+ attach(portal, newestOnTop = true) {
326
+ return this._portalHost.attach(portal, newestOnTop);
327
+ }
328
+ /**
329
+ * Detaches an overlay from a portal.
330
+ * @returns Resolves when the overlay has been detached.
331
+ */
332
+ detach() {
333
+ return this._portalHost.detach();
334
+ }
335
+ }
353
336
 
354
337
  /* eslint-disable @typescript-eslint/no-non-null-assertion */
355
338
  /**
@@ -361,11 +344,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
361
344
  * An overlay *is* a PortalHost, so any kind of Portal can be loaded into one.
362
345
  */
363
346
  class Overlay {
364
- constructor(_overlayContainer, _componentFactoryResolver, _appRef, _document) {
365
- this._overlayContainer = _overlayContainer;
366
- this._componentFactoryResolver = _componentFactoryResolver;
367
- this._appRef = _appRef;
368
- this._document = _document;
347
+ constructor() {
348
+ this._overlayContainer = inject(OverlayContainer);
349
+ this._componentFactoryResolver = inject(ComponentFactoryResolver);
350
+ this._appRef = inject(ApplicationRef);
351
+ this._document = inject(DOCUMENT);
369
352
  // Namespace panes by overlay container
370
353
  this._paneElements = new Map();
371
354
  }
@@ -419,17 +402,12 @@ class Overlay {
419
402
  return new OverlayRef(this._createPortalHost(pane));
420
403
  }
421
404
  }
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 });
405
+ Overlay.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: Overlay, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
423
406
  Overlay.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: Overlay, providedIn: 'root' });
424
407
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: Overlay, decorators: [{
425
408
  type: Injectable,
426
409
  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
- } });
410
+ }] });
433
411
 
434
412
  class ToastrService {
435
413
  constructor(token, overlay, _injector, sanitizer, ngZone) {
@@ -787,7 +765,7 @@ class Toast {
787
765
  }
788
766
  }
789
767
  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: `
768
+ Toast.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.7", type: Toast, isStandalone: true, 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
769
  <button *ngIf="options.closeButton" (click)="remove()" type="button" class="toast-close-button" aria-label="Close">
792
770
  <span aria-hidden="true">&times;</span>
793
771
  </button>
@@ -804,14 +782,14 @@ Toast.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.7
804
782
  <div *ngIf="options.progressBar">
805
783
  <div class="toast-progress" [style.width]="width + '%'"></div>
806
784
  </div>
807
- `, isInline: true, dependencies: [{ kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], animations: [
785
+ `, isInline: true, dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], animations: [
808
786
  trigger('flyInOut', [
809
787
  state('inactive', style({ opacity: 0 })),
810
788
  state('active', style({ opacity: 1 })),
811
789
  state('removed', style({ opacity: 0 })),
812
790
  transition('inactive => active', animate('{{ easeTime }}ms {{ easing }}')),
813
- transition('active => removed', animate('{{ easeTime }}ms {{ easing }}'))
814
- ])
791
+ transition('active => removed', animate('{{ easeTime }}ms {{ easing }}')),
792
+ ]),
815
793
  ] });
816
794
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: Toast, decorators: [{
817
795
  type: Component,
@@ -841,10 +819,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
841
819
  state('active', style({ opacity: 1 })),
842
820
  state('removed', style({ opacity: 0 })),
843
821
  transition('inactive => active', animate('{{ easeTime }}ms {{ easing }}')),
844
- transition('active => removed', animate('{{ easeTime }}ms {{ easing }}'))
845
- ])
822
+ transition('active => removed', animate('{{ easeTime }}ms {{ easing }}')),
823
+ ]),
846
824
  ],
847
- preserveWhitespaces: false
825
+ preserveWhitespaces: false,
826
+ standalone: true,
827
+ imports: [NgIf],
848
828
  }]
849
829
  }], ctorParameters: function () { return [{ type: ToastrService }, { type: ToastPackage }, { type: i0.NgZone }]; }, propDecorators: { toastClasses: [{
850
830
  type: HostBinding,
@@ -867,30 +847,54 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
867
847
  }] } });
868
848
 
869
849
  const DefaultGlobalConfig = Object.assign(Object.assign({}, DefaultNoComponentGlobalConfig), { toastComponent: Toast });
850
+ /**
851
+ * @description
852
+ * Provides the `TOAST_CONFIG` token with the given config.
853
+ *
854
+ * @param config The config to configure toastr.
855
+ * @returns The environment providers.
856
+ *
857
+ * @example
858
+ * ```ts
859
+ * import { provideToastr } from 'ngx-toastr';
860
+ *
861
+ * bootstrap(AppComponent, {
862
+ * providers: [
863
+ * provideToastr({
864
+ * timeOut: 2000,
865
+ * positionClass: 'toast-top-right',
866
+ * }),
867
+ * ],
868
+ * })
869
+ */
870
+ const provideToastr = (config = {}) => {
871
+ const providers = [
872
+ {
873
+ provide: TOAST_CONFIG,
874
+ useValue: {
875
+ default: DefaultGlobalConfig,
876
+ config,
877
+ }
878
+ }
879
+ ];
880
+ return makeEnvironmentProviders(providers);
881
+ };
882
+
870
883
  class ToastrModule {
871
884
  static forRoot(config = {}) {
872
885
  return {
873
886
  ngModule: ToastrModule,
874
- providers: [
875
- {
876
- provide: TOAST_CONFIG,
877
- useValue: {
878
- default: DefaultGlobalConfig,
879
- config,
880
- },
881
- },
882
- ],
887
+ providers: [provideToastr(config)],
883
888
  };
884
889
  }
885
890
  }
886
891
  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] });
892
+ ToastrModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.7", ngImport: i0, type: ToastrModule, imports: [Toast], exports: [Toast] });
893
+ ToastrModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ToastrModule, imports: [Toast] });
889
894
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ToastrModule, decorators: [{
890
895
  type: NgModule,
891
896
  args: [{
892
- imports: [CommonModule],
893
- declarations: [Toast],
897
+ imports: [Toast],
894
898
  exports: [Toast],
895
899
  }]
896
900
  }] });
@@ -911,13 +915,11 @@ class ToastrComponentlessModule {
911
915
  }
912
916
  }
913
917
  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] });
918
+ ToastrComponentlessModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.7", ngImport: i0, type: ToastrComponentlessModule });
919
+ ToastrComponentlessModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ToastrComponentlessModule });
916
920
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ToastrComponentlessModule, decorators: [{
917
921
  type: NgModule,
918
- args: [{
919
- imports: [CommonModule],
920
- }]
922
+ args: [{}]
921
923
  }] });
922
924
 
923
925
  class ToastNoAnimation {
@@ -1060,7 +1062,7 @@ class ToastNoAnimation {
1060
1062
  }
1061
1063
  }
1062
1064
  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: `
1065
+ ToastNoAnimation.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.7", type: ToastNoAnimation, isStandalone: true, selector: "[toast-component]", host: { listeners: { "click": "tapToast()", "mouseenter": "stickAround()", "mouseleave": "delayedHideToast()" }, properties: { "class": "this.toastClasses", "style.display": "this.displayStyle" } }, ngImport: i0, template: `
1064
1066
  <button *ngIf="options.closeButton" (click)="remove()" type="button" class="toast-close-button" aria-label="Close">
1065
1067
  <span aria-hidden="true">&times;</span>
1066
1068
  </button>
@@ -1077,7 +1079,7 @@ ToastNoAnimation.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", versi
1077
1079
  <div *ngIf="options.progressBar">
1078
1080
  <div class="toast-progress" [style.width]="width + '%'"></div>
1079
1081
  </div>
1080
- `, isInline: true, dependencies: [{ kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
1082
+ `, isInline: true, dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
1081
1083
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ToastNoAnimation, decorators: [{
1082
1084
  type: Component,
1083
1085
  args: [{
@@ -1100,6 +1102,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
1100
1102
  <div class="toast-progress" [style.width]="width + '%'"></div>
1101
1103
  </div>
1102
1104
  `,
1105
+ standalone: true,
1106
+ imports: [NgIf]
1103
1107
  }]
1104
1108
  }], ctorParameters: function () { return [{ type: ToastrService }, { type: ToastPackage }, { type: i0.ApplicationRef }]; }, propDecorators: { toastClasses: [{
1105
1109
  type: HostBinding,
@@ -1135,13 +1139,12 @@ class ToastNoAnimationModule {
1135
1139
  }
1136
1140
  }
1137
1141
  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] });
1142
+ ToastNoAnimationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.7", ngImport: i0, type: ToastNoAnimationModule, imports: [ToastNoAnimation], exports: [ToastNoAnimation] });
1143
+ ToastNoAnimationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ToastNoAnimationModule, imports: [ToastNoAnimation] });
1140
1144
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ToastNoAnimationModule, decorators: [{
1141
1145
  type: NgModule,
1142
1146
  args: [{
1143
- imports: [CommonModule],
1144
- declarations: [ToastNoAnimation],
1147
+ imports: [ToastNoAnimation],
1145
1148
  exports: [ToastNoAnimation],
1146
1149
  }]
1147
1150
  }] });
@@ -1150,5 +1153,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
1150
1153
  * Generated bundle index. Do not edit.
1151
1154
  */
1152
1155
 
1153
- export { BasePortalHost, ComponentPortal, DefaultGlobalConfig, DefaultNoAnimationsGlobalConfig, DefaultNoComponentGlobalConfig, Overlay, OverlayContainer, OverlayRef, TOAST_CONFIG, Toast, ToastContainerDirective, ToastContainerModule, ToastNoAnimation, ToastNoAnimationModule, ToastPackage, ToastRef, ToastrComponentlessModule, ToastrModule, ToastrService };
1156
+ export { BasePortalHost, ComponentPortal, DefaultGlobalConfig, DefaultNoAnimationsGlobalConfig, DefaultNoComponentGlobalConfig, Overlay, OverlayContainer, OverlayRef, TOAST_CONFIG, Toast, ToastContainerDirective, ToastNoAnimation, ToastNoAnimationModule, ToastPackage, ToastRef, ToastrComponentlessModule, ToastrModule, ToastrService, provideToastr };
1154
1157
  //# sourceMappingURL=ngx-toastr.mjs.map