@ibragim-dev-org/ui-forge-library 1.4.71 → 1.4.72

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.
@@ -1568,6 +1568,7 @@ class Alert {
1568
1568
  title = '';
1569
1569
  message = '';
1570
1570
  icon = '';
1571
+ position = 'bottom';
1571
1572
  component;
1572
1573
  componentInputs;
1573
1574
  constructor(init) {
@@ -1617,7 +1618,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
1617
1618
  class UiAlertMessagesService {
1618
1619
  uiAlertMessagesOverlayService;
1619
1620
  router;
1620
- $alerts = signal([], ...(ngDevMode ? [{ debugName: "$alerts" }] : []));
1621
+ $topAlerts = signal([], ...(ngDevMode ? [{ debugName: "$topAlerts" }] : []));
1622
+ $bottomAlerts = signal([], ...(ngDevMode ? [{ debugName: "$bottomAlerts" }] : []));
1623
+ $alerts = computed(() => [...this.$topAlerts(), ...this.$bottomAlerts()], ...(ngDevMode ? [{ debugName: "$alerts" }] : []));
1621
1624
  overlayRef;
1622
1625
  timerSubscriptions = new Map();
1623
1626
  timerState = new Map();
@@ -1631,6 +1634,7 @@ class UiAlertMessagesService {
1631
1634
  type: AlertType.SUCCESS,
1632
1635
  message: params.message,
1633
1636
  icon: 'success.svg',
1637
+ position: params.position ?? 'bottom',
1634
1638
  }));
1635
1639
  }
1636
1640
  error(params) {
@@ -1639,6 +1643,7 @@ class UiAlertMessagesService {
1639
1643
  type: AlertType.ERROR,
1640
1644
  message: params.message,
1641
1645
  icon: 'error.svg',
1646
+ position: params.position ?? 'bottom',
1642
1647
  }));
1643
1648
  }
1644
1649
  information(params) {
@@ -1647,6 +1652,7 @@ class UiAlertMessagesService {
1647
1652
  type: AlertType.INFO,
1648
1653
  message: params.message,
1649
1654
  icon: 'info.svg',
1655
+ position: params.position ?? 'bottom',
1650
1656
  }));
1651
1657
  }
1652
1658
  warning(params) {
@@ -1655,6 +1661,7 @@ class UiAlertMessagesService {
1655
1661
  type: AlertType.WARNING,
1656
1662
  message: params.message,
1657
1663
  icon: 'warning.svg',
1664
+ position: params.position ?? 'bottom',
1658
1665
  }));
1659
1666
  }
1660
1667
  pauseTimer(alert) {
@@ -1678,7 +1685,7 @@ class UiAlertMessagesService {
1678
1685
  this.timerState.delete(alert.id);
1679
1686
  timer(250)
1680
1687
  .pipe(tap(() => {
1681
- this.$alerts.set(this.$alerts().filter((x) => x !== alert));
1688
+ this.getAlertsList(alert.position).update((alerts) => alerts.filter((x) => x !== alert));
1682
1689
  }), switchMap(() => {
1683
1690
  if (!this.$alerts().length) {
1684
1691
  return timer(250).pipe(tap(() => {
@@ -1696,14 +1703,15 @@ class UiAlertMessagesService {
1696
1703
  }
1697
1704
  }
1698
1705
  removeAll() {
1699
- this.$alerts.set([]);
1706
+ this.$topAlerts.set([]);
1707
+ this.$bottomAlerts.set([]);
1700
1708
  timer(250)
1701
1709
  .pipe(tap(() => {
1702
1710
  this.overlayRef?.detach();
1703
1711
  }))
1704
1712
  .subscribe();
1705
1713
  }
1706
- open(alert) {
1714
+ open(alert, closeIntervalParams = { useTimer: true, duration: 10000 }) {
1707
1715
  if (!this.uiAlertMessagesOverlayService.component) {
1708
1716
  this.uiAlertMessagesOverlayService.throwIfNotInitialized();
1709
1717
  return;
@@ -1716,9 +1724,13 @@ class UiAlertMessagesService {
1716
1724
  this.removeAll();
1717
1725
  }), take(1))
1718
1726
  .subscribe();
1719
- this.$alerts.set([...this.$alerts(), alert]);
1727
+ this.getAlertsList(alert.position).update((alerts) => [...alerts, alert]);
1728
+ const { useTimer, duration } = closeIntervalParams;
1729
+ if (!useTimer) {
1730
+ return;
1731
+ }
1720
1732
  this.timerState.set(alert.id, { paused: false, elapsed: 0 });
1721
- const DURATION = 10000;
1733
+ const DURATION = duration;
1722
1734
  const CHECK_INTERVAL = 100;
1723
1735
  const subscription = interval(CHECK_INTERVAL)
1724
1736
  .pipe(takeWhile(() => {
@@ -1735,6 +1747,9 @@ class UiAlertMessagesService {
1735
1747
  .subscribe();
1736
1748
  this.timerSubscriptions.set(alert.id, subscription);
1737
1749
  }
1750
+ getAlertsList(position) {
1751
+ return position === 'top' ? this.$topAlerts : this.$bottomAlerts;
1752
+ }
1738
1753
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiAlertMessagesService, deps: [{ token: UiAlertMessagesOverlayService }, { token: i2.Router }], target: i0.ɵɵFactoryTarget.Injectable });
1739
1754
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiAlertMessagesService, providedIn: 'root' });
1740
1755
  }