@ibragim-dev-org/ui-forge-library 1.2.5 → 1.2.6
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.
|
@@ -2,7 +2,7 @@ import * as i0 from '@angular/core';
|
|
|
2
2
|
import { input, effect, Directive, Injectable, EventEmitter, Output, Input, PLATFORM_ID, Inject, Pipe, Attribute, ChangeDetectionStrategy, Component, signal, model, computed, viewChild, untracked, output, Injector, afterRenderEffect, contentChildren, contentChild, ViewChildren } from '@angular/core';
|
|
3
3
|
import { isPlatformBrowser, DOCUMENT, NgStyle } from '@angular/common';
|
|
4
4
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
5
|
-
import { fromEvent, tap, debounceTime, asyncScheduler, Subscription, timer, switchMap, scheduled, filter, take, BehaviorSubject, Subject, takeUntil } from 'rxjs';
|
|
5
|
+
import { fromEvent, tap, debounceTime, asyncScheduler, Subscription, timer, switchMap, scheduled, filter, take, interval, takeWhile, finalize, BehaviorSubject, Subject, takeUntil } from 'rxjs';
|
|
6
6
|
import * as i2 from '@angular/platform-browser';
|
|
7
7
|
import { PhoneNumberUtil, AsYouTypeFormatter } from 'google-libphonenumber';
|
|
8
8
|
import * as i1 from '@angular/cdk/overlay';
|
|
@@ -846,6 +846,8 @@ class UiAlertMessagesService {
|
|
|
846
846
|
$alerts = signal([], ...(ngDevMode ? [{ debugName: "$alerts" }] : []));
|
|
847
847
|
overlayRef;
|
|
848
848
|
component = null;
|
|
849
|
+
timerSubscriptions = new Map();
|
|
850
|
+
timerState = new Map();
|
|
849
851
|
constructor(overlay, router) {
|
|
850
852
|
this.overlay = overlay;
|
|
851
853
|
this.router = router;
|
|
@@ -882,7 +884,26 @@ class UiAlertMessagesService {
|
|
|
882
884
|
icon: 'warning.svg',
|
|
883
885
|
}));
|
|
884
886
|
}
|
|
887
|
+
pauseTimer(alert) {
|
|
888
|
+
const state = this.timerState.get(alert.id);
|
|
889
|
+
if (state) {
|
|
890
|
+
state.paused = true;
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
resumeTimer(alert) {
|
|
894
|
+
const state = this.timerState.get(alert.id);
|
|
895
|
+
if (state) {
|
|
896
|
+
state.paused = false;
|
|
897
|
+
}
|
|
898
|
+
}
|
|
885
899
|
remove(alert) {
|
|
900
|
+
// Cancel any active timer for this alert
|
|
901
|
+
const subscription = this.timerSubscriptions.get(alert.id);
|
|
902
|
+
if (subscription) {
|
|
903
|
+
subscription.unsubscribe();
|
|
904
|
+
this.timerSubscriptions.delete(alert.id);
|
|
905
|
+
}
|
|
906
|
+
this.timerState.delete(alert.id);
|
|
886
907
|
timer(250)
|
|
887
908
|
.pipe(tap(() => {
|
|
888
909
|
this.$alerts.set(this.$alerts().filter((x) => x !== alert));
|
|
@@ -927,11 +948,25 @@ class UiAlertMessagesService {
|
|
|
927
948
|
}), take(1))
|
|
928
949
|
.subscribe();
|
|
929
950
|
this.$alerts.set([...this.$alerts(), alert]);
|
|
930
|
-
timer
|
|
931
|
-
|
|
951
|
+
// Create pausable timer with 100ms intervals
|
|
952
|
+
this.timerState.set(alert.id, { paused: false, elapsed: 0 });
|
|
953
|
+
const DURATION = 10000; // 10 seconds
|
|
954
|
+
const CHECK_INTERVAL = 100; // Check every 100ms
|
|
955
|
+
const subscription = interval(CHECK_INTERVAL)
|
|
956
|
+
.pipe(takeWhile(() => {
|
|
957
|
+
const state = this.timerState.get(alert.id);
|
|
958
|
+
if (!state)
|
|
959
|
+
return false;
|
|
960
|
+
// Only increment elapsed time if not paused
|
|
961
|
+
if (!state.paused) {
|
|
962
|
+
state.elapsed += CHECK_INTERVAL;
|
|
963
|
+
}
|
|
964
|
+
return state.elapsed < DURATION;
|
|
965
|
+
}), finalize(() => {
|
|
932
966
|
this.remove(alert);
|
|
933
967
|
}))
|
|
934
968
|
.subscribe();
|
|
969
|
+
this.timerSubscriptions.set(alert.id, subscription);
|
|
935
970
|
}
|
|
936
971
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiAlertMessagesService, deps: [{ token: i1.Overlay }, { token: i2$1.Router }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
937
972
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiAlertMessagesService, providedIn: 'root' });
|