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

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) {
@@ -1577,13 +1578,17 @@ class Alert {
1577
1578
 
1578
1579
  class UiAlertMessagesOverlayService {
1579
1580
  overlay;
1580
- component = null;
1581
+ isAttached = false;
1581
1582
  overlayRef;
1583
+ component = null;
1582
1584
  constructor(component, overlay) {
1583
1585
  this.overlay = overlay;
1584
1586
  this.init(component);
1585
1587
  }
1586
1588
  attachComponent() {
1589
+ if (this.isAttached) {
1590
+ return;
1591
+ }
1587
1592
  if (!this.component) {
1588
1593
  this.throwIfNotInitialized();
1589
1594
  return;
@@ -1594,6 +1599,7 @@ class UiAlertMessagesOverlayService {
1594
1599
  });
1595
1600
  this.overlayRef = this.overlay.create(config);
1596
1601
  this.overlayRef.attach(new ComponentPortal(this.component));
1602
+ this.isAttached = true;
1597
1603
  }
1598
1604
  init(component) {
1599
1605
  this.component = component;
@@ -1617,7 +1623,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
1617
1623
  class UiAlertMessagesService {
1618
1624
  uiAlertMessagesOverlayService;
1619
1625
  router;
1620
- $alerts = signal([], ...(ngDevMode ? [{ debugName: "$alerts" }] : []));
1626
+ $topAlerts = signal([], ...(ngDevMode ? [{ debugName: "$topAlerts" }] : []));
1627
+ $bottomAlerts = signal([], ...(ngDevMode ? [{ debugName: "$bottomAlerts" }] : []));
1628
+ $alerts = computed(() => [...this.$topAlerts(), ...this.$bottomAlerts()], ...(ngDevMode ? [{ debugName: "$alerts" }] : []));
1621
1629
  overlayRef;
1622
1630
  timerSubscriptions = new Map();
1623
1631
  timerState = new Map();
@@ -1631,6 +1639,7 @@ class UiAlertMessagesService {
1631
1639
  type: AlertType.SUCCESS,
1632
1640
  message: params.message,
1633
1641
  icon: 'success.svg',
1642
+ position: params.position ?? 'bottom',
1634
1643
  }));
1635
1644
  }
1636
1645
  error(params) {
@@ -1639,6 +1648,7 @@ class UiAlertMessagesService {
1639
1648
  type: AlertType.ERROR,
1640
1649
  message: params.message,
1641
1650
  icon: 'error.svg',
1651
+ position: params.position ?? 'bottom',
1642
1652
  }));
1643
1653
  }
1644
1654
  information(params) {
@@ -1647,6 +1657,7 @@ class UiAlertMessagesService {
1647
1657
  type: AlertType.INFO,
1648
1658
  message: params.message,
1649
1659
  icon: 'info.svg',
1660
+ position: params.position ?? 'bottom',
1650
1661
  }));
1651
1662
  }
1652
1663
  warning(params) {
@@ -1655,6 +1666,7 @@ class UiAlertMessagesService {
1655
1666
  type: AlertType.WARNING,
1656
1667
  message: params.message,
1657
1668
  icon: 'warning.svg',
1669
+ position: params.position ?? 'bottom',
1658
1670
  }));
1659
1671
  }
1660
1672
  pauseTimer(alert) {
@@ -1678,7 +1690,7 @@ class UiAlertMessagesService {
1678
1690
  this.timerState.delete(alert.id);
1679
1691
  timer(250)
1680
1692
  .pipe(tap(() => {
1681
- this.$alerts.set(this.$alerts().filter((x) => x !== alert));
1693
+ this.getAlertsList(alert.position).update((alerts) => alerts.filter((x) => x !== alert));
1682
1694
  }), switchMap(() => {
1683
1695
  if (!this.$alerts().length) {
1684
1696
  return timer(250).pipe(tap(() => {
@@ -1696,14 +1708,15 @@ class UiAlertMessagesService {
1696
1708
  }
1697
1709
  }
1698
1710
  removeAll() {
1699
- this.$alerts.set([]);
1711
+ this.$topAlerts.set([]);
1712
+ this.$bottomAlerts.set([]);
1700
1713
  timer(250)
1701
1714
  .pipe(tap(() => {
1702
1715
  this.overlayRef?.detach();
1703
1716
  }))
1704
1717
  .subscribe();
1705
1718
  }
1706
- open(alert) {
1719
+ open(alert, closeIntervalParams = { useTimer: true, duration: 10000 }) {
1707
1720
  if (!this.uiAlertMessagesOverlayService.component) {
1708
1721
  this.uiAlertMessagesOverlayService.throwIfNotInitialized();
1709
1722
  return;
@@ -1716,9 +1729,13 @@ class UiAlertMessagesService {
1716
1729
  this.removeAll();
1717
1730
  }), take(1))
1718
1731
  .subscribe();
1719
- this.$alerts.set([...this.$alerts(), alert]);
1732
+ this.getAlertsList(alert.position).update((alerts) => [...alerts, alert]);
1733
+ const { useTimer, duration } = closeIntervalParams;
1734
+ if (!useTimer) {
1735
+ return;
1736
+ }
1720
1737
  this.timerState.set(alert.id, { paused: false, elapsed: 0 });
1721
- const DURATION = 10000;
1738
+ const DURATION = duration;
1722
1739
  const CHECK_INTERVAL = 100;
1723
1740
  const subscription = interval(CHECK_INTERVAL)
1724
1741
  .pipe(takeWhile(() => {
@@ -1735,6 +1752,9 @@ class UiAlertMessagesService {
1735
1752
  .subscribe();
1736
1753
  this.timerSubscriptions.set(alert.id, subscription);
1737
1754
  }
1755
+ getAlertsList(position) {
1756
+ return position === 'top' ? this.$topAlerts : this.$bottomAlerts;
1757
+ }
1738
1758
  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
1759
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiAlertMessagesService, providedIn: 'root' });
1740
1760
  }