@m1z23r/ngx-ui 1.1.26 → 1.1.27

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.
@@ -513,6 +513,7 @@ const DEFAULT_TOAST_CONFIG = {
513
513
  position: 'top-right',
514
514
  dismissible: true,
515
515
  showProgress: true,
516
+ maxVisible: 3,
516
517
  };
517
518
  const TOAST_DATA = new InjectionToken('TOAST_DATA');
518
519
 
@@ -560,11 +561,23 @@ class ToastService {
560
561
  show(config) {
561
562
  const id = `toast-${++this.idCounter}`;
562
563
  const position = config.position ?? DEFAULT_TOAST_CONFIG.position;
564
+ const maxVisible = config.maxVisible ?? DEFAULT_TOAST_CONFIG.maxVisible;
563
565
  // If position changed, dismiss all existing toasts
564
566
  if (this.toasts().length > 0 && position !== this.currentPosition) {
565
567
  this.dismissAll();
566
568
  }
567
569
  this.currentPosition = position;
570
+ // Enforce max visible limit - dismiss oldest toasts to make room
571
+ if (maxVisible > 0) {
572
+ const currentToasts = this.toasts();
573
+ const toRemoveCount = currentToasts.length - maxVisible + 1;
574
+ if (toRemoveCount > 0) {
575
+ const toastsToRemove = currentToasts.slice(0, toRemoveCount);
576
+ for (const toast of toastsToRemove) {
577
+ this.dismiss(toast.id);
578
+ }
579
+ }
580
+ }
568
581
  const toastData = {
569
582
  id,
570
583
  message: config.message,