@ibragim-dev-org/ui-forge-library 1.2.6 → 1.2.7
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,15 +1,15 @@
|
|
|
1
|
+
import * as i2$1 from '@angular/router';
|
|
2
|
+
import { NavigationEnd, NavigationStart, ActivationEnd } from '@angular/router';
|
|
3
|
+
import { BehaviorSubject, filter, take, fromEvent, tap, debounceTime, asyncScheduler, Subscription, timer, switchMap, scheduled, interval, takeWhile, finalize, Subject, takeUntil } from 'rxjs';
|
|
1
4
|
import * as i0 from '@angular/core';
|
|
2
5
|
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
6
|
import { isPlatformBrowser, DOCUMENT, NgStyle } from '@angular/common';
|
|
4
7
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
5
|
-
import { fromEvent, tap, debounceTime, asyncScheduler, Subscription, timer, switchMap, scheduled, filter, take, interval, takeWhile, finalize, BehaviorSubject, Subject, takeUntil } from 'rxjs';
|
|
6
8
|
import * as i2 from '@angular/platform-browser';
|
|
7
9
|
import { PhoneNumberUtil, AsYouTypeFormatter } from 'google-libphonenumber';
|
|
8
10
|
import * as i1 from '@angular/cdk/overlay';
|
|
9
11
|
import { OverlayConfig, FlexibleConnectedPositionStrategy } from '@angular/cdk/overlay';
|
|
10
12
|
import { ComponentPortal } from '@angular/cdk/portal';
|
|
11
|
-
import * as i2$1 from '@angular/router';
|
|
12
|
-
import { NavigationEnd } from '@angular/router';
|
|
13
13
|
import { ulid } from 'ulid';
|
|
14
14
|
import { form } from '@angular/forms/signals';
|
|
15
15
|
|
|
@@ -54,6 +54,138 @@ class DateUtils {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
class RouterBehavior {
|
|
58
|
+
static router;
|
|
59
|
+
static previousUrl;
|
|
60
|
+
static navigationState;
|
|
61
|
+
static routeDataSubj = new BehaviorSubject({});
|
|
62
|
+
static trigger;
|
|
63
|
+
static location;
|
|
64
|
+
static get routeData() {
|
|
65
|
+
return this.routeDataSubj.value;
|
|
66
|
+
}
|
|
67
|
+
static get navigationTrigger() {
|
|
68
|
+
return this.trigger;
|
|
69
|
+
}
|
|
70
|
+
static get isImperative() {
|
|
71
|
+
return this.trigger === 'imperative';
|
|
72
|
+
}
|
|
73
|
+
static setup(router, location) {
|
|
74
|
+
this.router = router;
|
|
75
|
+
this.location = location;
|
|
76
|
+
this.observeEvents();
|
|
77
|
+
}
|
|
78
|
+
static onNavEnd(cb) {
|
|
79
|
+
this.router.events
|
|
80
|
+
.pipe(filter((e) => e instanceof NavigationEnd), take(1))
|
|
81
|
+
.subscribe(() => cb());
|
|
82
|
+
}
|
|
83
|
+
static onNavEndInfinity(cb) {
|
|
84
|
+
this.router.events.pipe(filter((e) => e instanceof NavigationEnd)).subscribe(() => cb());
|
|
85
|
+
}
|
|
86
|
+
static getRouteDataChanges() {
|
|
87
|
+
return RouterBehavior.routeDataSubj.asObservable();
|
|
88
|
+
}
|
|
89
|
+
static clearQueryParam(currentParams, removeKey) {
|
|
90
|
+
if (typeof currentParams === 'string') {
|
|
91
|
+
currentParams = this.queryStringToObject(currentParams);
|
|
92
|
+
}
|
|
93
|
+
const params = { ...currentParams };
|
|
94
|
+
if (!params[removeKey]) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const path = this.location.path().split('?')[0];
|
|
98
|
+
const query = [];
|
|
99
|
+
delete params[removeKey];
|
|
100
|
+
Object.keys(params).forEach((key) => {
|
|
101
|
+
query.push(`${key}=${params[key]}`);
|
|
102
|
+
});
|
|
103
|
+
this.location.replaceState(path, query.join('&'));
|
|
104
|
+
}
|
|
105
|
+
static queryStringToObject(url) {
|
|
106
|
+
return [...new URLSearchParams(url.split('?')[1])].reduce((a, [k, v]) => ((a[k] = v), a), {});
|
|
107
|
+
}
|
|
108
|
+
static observeEvents() {
|
|
109
|
+
const isPrimaryOutlet = (snapshot) => snapshot.outlet === 'primary' && snapshot.parent?.outlet === 'primary';
|
|
110
|
+
let snapshotData = {};
|
|
111
|
+
let navStartUrl = '';
|
|
112
|
+
this.router.events.subscribe((event) => {
|
|
113
|
+
if (event instanceof NavigationStart) {
|
|
114
|
+
this.trigger = event.navigationTrigger;
|
|
115
|
+
this.navigationState = this.router.currentNavigation()?.extras.state || {};
|
|
116
|
+
snapshotData = {};
|
|
117
|
+
navStartUrl = this.router.url;
|
|
118
|
+
}
|
|
119
|
+
// we provide snapshot only of primary outlet of application routing
|
|
120
|
+
if (event instanceof ActivationEnd && isPrimaryOutlet(event.snapshot)) {
|
|
121
|
+
// aggregate snapshot date through all router levels
|
|
122
|
+
snapshotData = Object.assign(snapshotData, event.snapshot.data || {});
|
|
123
|
+
this.routeDataSubj.next(snapshotData);
|
|
124
|
+
}
|
|
125
|
+
// set snapshotData on activation end to prevent UI flickering
|
|
126
|
+
if (event instanceof NavigationEnd) {
|
|
127
|
+
this.previousUrl = navStartUrl;
|
|
128
|
+
this.routeDataSubj.next(snapshotData);
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/** Create UrlTree from string, same as default but use string instead string[] */
|
|
134
|
+
function createUrlTree(url, extras) {
|
|
135
|
+
const urlTree = RouterBehavior.router.createUrlTree([url], extras);
|
|
136
|
+
removeUrlTreeOutlet(urlTree, 'primaryModal');
|
|
137
|
+
return urlTree;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Navigate by string url using NavigationExtras,
|
|
141
|
+
* because Router allows only NavigationBehaviorOptions at navigateByUrl()
|
|
142
|
+
*/
|
|
143
|
+
function navigateByUrl(url, extras, removeOutlet) {
|
|
144
|
+
if (url.includes('?')) {
|
|
145
|
+
const queryString = url.split('?')[1];
|
|
146
|
+
const urlParams = new URLSearchParams(queryString);
|
|
147
|
+
const query = paramsToObject(urlParams.entries());
|
|
148
|
+
url = url.replace(`?${queryString}`, '');
|
|
149
|
+
if (extras && extras.queryParams) {
|
|
150
|
+
extras.queryParams = { ...extras.queryParams, ...query };
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
extras = { queryParams: query };
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
const urlTree = createUrlTree(url, extras);
|
|
157
|
+
// close any modals on primary router navigation
|
|
158
|
+
removeUrlTreeOutlet(urlTree, 'primaryModal');
|
|
159
|
+
if (removeOutlet) {
|
|
160
|
+
removeUrlTreeOutlet(urlTree, removeOutlet);
|
|
161
|
+
}
|
|
162
|
+
return RouterBehavior.router.navigateByUrl(urlTree, extras);
|
|
163
|
+
}
|
|
164
|
+
function removeUrlTreeOutlet(urlTree, outlet) {
|
|
165
|
+
delete urlTree.root.children[outlet];
|
|
166
|
+
}
|
|
167
|
+
function paramsToObject(entries) {
|
|
168
|
+
const result = {};
|
|
169
|
+
for (const [key, value] of entries) {
|
|
170
|
+
result[key] = value;
|
|
171
|
+
}
|
|
172
|
+
return result;
|
|
173
|
+
}
|
|
174
|
+
function createUrl(url, moduleRoot) {
|
|
175
|
+
moduleRoot = moduleRoot ? `/${moduleRoot}/` : '/';
|
|
176
|
+
return url ? `${moduleRoot}${url}` : moduleRoot.replace(/\/$/, '');
|
|
177
|
+
}
|
|
178
|
+
function createNavigation(from, moduleRoot, overrides) {
|
|
179
|
+
const createdRoutes = {};
|
|
180
|
+
Object.keys(from).forEach((key) => {
|
|
181
|
+
createdRoutes[key] = (...args) => createUrl(from[key].apply(null, args), moduleRoot || '/').replace('//', '/');
|
|
182
|
+
});
|
|
183
|
+
Object.assign(createdRoutes, overrides);
|
|
184
|
+
return createdRoutes;
|
|
185
|
+
}
|
|
186
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
187
|
+
const extractParam = (key) => `:${key}`;
|
|
188
|
+
|
|
57
189
|
class AutoFocusDirective {
|
|
58
190
|
el;
|
|
59
191
|
$shouldFocus = input.required({ debugName: 'appAutoFocus' });
|
|
@@ -3874,5 +4006,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
|
|
|
3874
4006
|
* Generated bundle index. Do not edit.
|
|
3875
4007
|
*/
|
|
3876
4008
|
|
|
3877
|
-
export { Alert, AlertType, AppIconsLibrary, AutoFocusDirective, CenterEllipsisPipe, CountryService, DateUtils, EMAIL, HAS_CAPITAL_CASE, HAS_NUMBER, HAS_SMALL_CASE, HAS_SPECIAL_CHARTERS, HoverTipDirective, IconComponent, LazyImgDirective, MIN_LENGTH, MaskGradientDirective, SkeletonDirective, StickyObserverDirective, ThemeService, TrackLifecycleDirective, UIInputDateDirective, UIPhoneNumberDirective, UiAccordionComponent, UiAlertMessagesService, UiAvatarDirective, UiButtonDirective, UiCalendarDropdownDirective, UiCodeDirective, UiCopyButtonDirective, UiDailyCalendarDirective, UiDropdownContainerDirective, UiDropdownService, UiFieldBaseDirective, UiImageDirective, UiInputCheckboxDirective, UiInputCountryDirective, UiInputDirective, UiInputSelectDirective, UiInputSequenceDirective, UiInputTimeDirective, UiMonthlyCalendarDirective, UiPaginationDirective, UiPopupBackdropDirective, UiPopupContainerDirective, UiPopupImageDirective, UiPopupInstance, UiPopupService, UiSelectButtonsDirective, UiTabsDirective, UiTimeDropdownDirective, UiValidationErrorsDirective, UiYearlyCalendarDirective, emptyCountry, getAspectRatioFit, stringToHslColor };
|
|
4009
|
+
export { Alert, AlertType, AppIconsLibrary, AutoFocusDirective, CenterEllipsisPipe, CountryService, DateUtils, EMAIL, HAS_CAPITAL_CASE, HAS_NUMBER, HAS_SMALL_CASE, HAS_SPECIAL_CHARTERS, HoverTipDirective, IconComponent, LazyImgDirective, MIN_LENGTH, MaskGradientDirective, RouterBehavior, SkeletonDirective, StickyObserverDirective, ThemeService, TrackLifecycleDirective, UIInputDateDirective, UIPhoneNumberDirective, UiAccordionComponent, UiAlertMessagesService, UiAvatarDirective, UiButtonDirective, UiCalendarDropdownDirective, UiCodeDirective, UiCopyButtonDirective, UiDailyCalendarDirective, UiDropdownContainerDirective, UiDropdownService, UiFieldBaseDirective, UiImageDirective, UiInputCheckboxDirective, UiInputCountryDirective, UiInputDirective, UiInputSelectDirective, UiInputSequenceDirective, UiInputTimeDirective, UiMonthlyCalendarDirective, UiPaginationDirective, UiPopupBackdropDirective, UiPopupContainerDirective, UiPopupImageDirective, UiPopupInstance, UiPopupService, UiSelectButtonsDirective, UiTabsDirective, UiTimeDropdownDirective, UiValidationErrorsDirective, UiYearlyCalendarDirective, createNavigation, createUrl, createUrlTree, emptyCountry, extractParam, getAspectRatioFit, navigateByUrl, stringToHslColor };
|
|
3878
4010
|
//# sourceMappingURL=ibragim-dev-org-ui-forge-library.mjs.map
|