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,15 +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 () { return [{ type: undefined, decorators: [{
348
- type: Inject,
349
- args: [DOCUMENT]
350
- }] }]; } });
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
+ }
351
336
 
352
337
  /* eslint-disable @typescript-eslint/no-non-null-assertion */
353
338
  /**
@@ -359,11 +344,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
359
344
  * An overlay *is* a PortalHost, so any kind of Portal can be loaded into one.
360
345
  */
361
346
  class Overlay {
362
- constructor(_overlayContainer, _componentFactoryResolver, _appRef, _document) {
363
- this._overlayContainer = _overlayContainer;
364
- this._componentFactoryResolver = _componentFactoryResolver;
365
- this._appRef = _appRef;
366
- 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);
367
352
  // Namespace panes by overlay container
368
353
  this._paneElements = new Map();
369
354
  }
@@ -417,15 +402,12 @@ class Overlay {
417
402
  return new OverlayRef(this._createPortalHost(pane));
418
403
  }
419
404
  }
420
- 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 });
421
406
  Overlay.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: Overlay, providedIn: 'root' });
422
407
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: Overlay, decorators: [{
423
408
  type: Injectable,
424
409
  args: [{ providedIn: 'root' }]
425
- }], ctorParameters: function () { return [{ type: OverlayContainer }, { type: i0.ComponentFactoryResolver }, { type: i0.ApplicationRef }, { type: undefined, decorators: [{
426
- type: Inject,
427
- args: [DOCUMENT]
428
- }] }]; } });
410
+ }] });
429
411
 
430
412
  class ToastrService {
431
413
  constructor(token, overlay, _injector, sanitizer, ngZone) {
@@ -787,7 +769,7 @@ class Toast {
787
769
  }
788
770
  }
789
771
  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: `
772
+ 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
773
  <button *ngIf="options.closeButton" (click)="remove()" type="button" class="toast-close-button" aria-label="Close">
792
774
  <span aria-hidden="true">&times;</span>
793
775
  </button>
@@ -804,14 +786,14 @@ Toast.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.7
804
786
  <div *ngIf="options.progressBar">
805
787
  <div class="toast-progress" [style.width]="width + '%'"></div>
806
788
  </div>
807
- `, isInline: true, dependencies: [{ kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], animations: [
789
+ `, isInline: true, dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], animations: [
808
790
  trigger('flyInOut', [
809
791
  state('inactive', style({ opacity: 0 })),
810
792
  state('active', style({ opacity: 1 })),
811
793
  state('removed', style({ opacity: 0 })),
812
794
  transition('inactive => active', animate('{{ easeTime }}ms {{ easing }}')),
813
- transition('active => removed', animate('{{ easeTime }}ms {{ easing }}'))
814
- ])
795
+ transition('active => removed', animate('{{ easeTime }}ms {{ easing }}')),
796
+ ]),
815
797
  ] });
816
798
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: Toast, decorators: [{
817
799
  type: Component,
@@ -841,10 +823,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
841
823
  state('active', style({ opacity: 1 })),
842
824
  state('removed', style({ opacity: 0 })),
843
825
  transition('inactive => active', animate('{{ easeTime }}ms {{ easing }}')),
844
- transition('active => removed', animate('{{ easeTime }}ms {{ easing }}'))
845
- ])
826
+ transition('active => removed', animate('{{ easeTime }}ms {{ easing }}')),
827
+ ]),
846
828
  ],
847
- preserveWhitespaces: false
829
+ preserveWhitespaces: false,
830
+ standalone: true,
831
+ imports: [NgIf],
848
832
  }]
849
833
  }], ctorParameters: function () { return [{ type: ToastrService }, { type: ToastPackage }, { type: i0.NgZone }]; }, propDecorators: { toastClasses: [{
850
834
  type: HostBinding,
@@ -870,30 +854,54 @@ const DefaultGlobalConfig = {
870
854
  ...DefaultNoComponentGlobalConfig,
871
855
  toastComponent: Toast,
872
856
  };
857
+ /**
858
+ * @description
859
+ * Provides the `TOAST_CONFIG` token with the given config.
860
+ *
861
+ * @param config The config to configure toastr.
862
+ * @returns The environment providers.
863
+ *
864
+ * @example
865
+ * ```ts
866
+ * import { provideToastr } from 'ngx-toastr';
867
+ *
868
+ * bootstrap(AppComponent, {
869
+ * providers: [
870
+ * provideToastr({
871
+ * timeOut: 2000,
872
+ * positionClass: 'toast-top-right',
873
+ * }),
874
+ * ],
875
+ * })
876
+ */
877
+ const provideToastr = (config = {}) => {
878
+ const providers = [
879
+ {
880
+ provide: TOAST_CONFIG,
881
+ useValue: {
882
+ default: DefaultGlobalConfig,
883
+ config,
884
+ }
885
+ }
886
+ ];
887
+ return makeEnvironmentProviders(providers);
888
+ };
889
+
873
890
  class ToastrModule {
874
891
  static forRoot(config = {}) {
875
892
  return {
876
893
  ngModule: ToastrModule,
877
- providers: [
878
- {
879
- provide: TOAST_CONFIG,
880
- useValue: {
881
- default: DefaultGlobalConfig,
882
- config,
883
- },
884
- },
885
- ],
894
+ providers: [provideToastr(config)],
886
895
  };
887
896
  }
888
897
  }
889
898
  ToastrModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ToastrModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
890
- ToastrModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.7", ngImport: i0, type: ToastrModule, declarations: [Toast], imports: [CommonModule], exports: [Toast] });
891
- ToastrModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ToastrModule, imports: [CommonModule] });
899
+ ToastrModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.7", ngImport: i0, type: ToastrModule, imports: [Toast], exports: [Toast] });
900
+ ToastrModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ToastrModule, imports: [Toast] });
892
901
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ToastrModule, decorators: [{
893
902
  type: NgModule,
894
903
  args: [{
895
- imports: [CommonModule],
896
- declarations: [Toast],
904
+ imports: [Toast],
897
905
  exports: [Toast],
898
906
  }]
899
907
  }] });
@@ -914,13 +922,11 @@ class ToastrComponentlessModule {
914
922
  }
915
923
  }
916
924
  ToastrComponentlessModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ToastrComponentlessModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
917
- ToastrComponentlessModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.7", ngImport: i0, type: ToastrComponentlessModule, imports: [CommonModule] });
918
- ToastrComponentlessModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ToastrComponentlessModule, imports: [CommonModule] });
925
+ ToastrComponentlessModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.7", ngImport: i0, type: ToastrComponentlessModule });
926
+ ToastrComponentlessModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ToastrComponentlessModule });
919
927
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ToastrComponentlessModule, decorators: [{
920
928
  type: NgModule,
921
- args: [{
922
- imports: [CommonModule],
923
- }]
929
+ args: [{}]
924
930
  }] });
925
931
 
926
932
  class ToastNoAnimation {
@@ -1063,7 +1069,7 @@ class ToastNoAnimation {
1063
1069
  }
1064
1070
  }
1065
1071
  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 });
1066
- 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: `
1072
+ 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: `
1067
1073
  <button *ngIf="options.closeButton" (click)="remove()" type="button" class="toast-close-button" aria-label="Close">
1068
1074
  <span aria-hidden="true">&times;</span>
1069
1075
  </button>
@@ -1080,7 +1086,7 @@ ToastNoAnimation.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", versi
1080
1086
  <div *ngIf="options.progressBar">
1081
1087
  <div class="toast-progress" [style.width]="width + '%'"></div>
1082
1088
  </div>
1083
- `, isInline: true, dependencies: [{ kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
1089
+ `, isInline: true, dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
1084
1090
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ToastNoAnimation, decorators: [{
1085
1091
  type: Component,
1086
1092
  args: [{
@@ -1103,6 +1109,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
1103
1109
  <div class="toast-progress" [style.width]="width + '%'"></div>
1104
1110
  </div>
1105
1111
  `,
1112
+ standalone: true,
1113
+ imports: [NgIf]
1106
1114
  }]
1107
1115
  }], ctorParameters: function () { return [{ type: ToastrService }, { type: ToastPackage }, { type: i0.ApplicationRef }]; }, propDecorators: { toastClasses: [{
1108
1116
  type: HostBinding,
@@ -1141,13 +1149,12 @@ class ToastNoAnimationModule {
1141
1149
  }
1142
1150
  }
1143
1151
  ToastNoAnimationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ToastNoAnimationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1144
- ToastNoAnimationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.7", ngImport: i0, type: ToastNoAnimationModule, declarations: [ToastNoAnimation], imports: [CommonModule], exports: [ToastNoAnimation] });
1145
- ToastNoAnimationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ToastNoAnimationModule, imports: [CommonModule] });
1152
+ ToastNoAnimationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.7", ngImport: i0, type: ToastNoAnimationModule, imports: [ToastNoAnimation], exports: [ToastNoAnimation] });
1153
+ ToastNoAnimationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ToastNoAnimationModule, imports: [ToastNoAnimation] });
1146
1154
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ToastNoAnimationModule, decorators: [{
1147
1155
  type: NgModule,
1148
1156
  args: [{
1149
- imports: [CommonModule],
1150
- declarations: [ToastNoAnimation],
1157
+ imports: [ToastNoAnimation],
1151
1158
  exports: [ToastNoAnimation],
1152
1159
  }]
1153
1160
  }] });
@@ -1156,5 +1163,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
1156
1163
  * Generated bundle index. Do not edit.
1157
1164
  */
1158
1165
 
1159
- export { BasePortalHost, ComponentPortal, DefaultGlobalConfig, DefaultNoAnimationsGlobalConfig, DefaultNoComponentGlobalConfig, Overlay, OverlayContainer, OverlayRef, TOAST_CONFIG, Toast, ToastContainerDirective, ToastContainerModule, ToastNoAnimation, ToastNoAnimationModule, ToastPackage, ToastRef, ToastrComponentlessModule, ToastrModule, ToastrService };
1166
+ export { BasePortalHost, ComponentPortal, DefaultGlobalConfig, DefaultNoAnimationsGlobalConfig, DefaultNoComponentGlobalConfig, Overlay, OverlayContainer, OverlayRef, TOAST_CONFIG, Toast, ToastContainerDirective, ToastNoAnimation, ToastNoAnimationModule, ToastPackage, ToastRef, ToastrComponentlessModule, ToastrModule, ToastrService, provideToastr };
1160
1167
  //# sourceMappingURL=ngx-toastr.mjs.map