@ibragim-dev-org/ui-forge-library 1.4.4 → 1.4.5
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.
|
@@ -2184,20 +2184,29 @@ class UiPopupInstance {
|
|
|
2184
2184
|
width = 0;
|
|
2185
2185
|
animationOrigin$ = new BehaviorSubject('center');
|
|
2186
2186
|
options = {
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2187
|
+
startOrigin: 'center center',
|
|
2188
|
+
endOrigin: 'center center',
|
|
2189
|
+
start: 'scale(0)',
|
|
2190
|
+
end: 'scale(0)',
|
|
2191
|
+
leftStart: '0px',
|
|
2192
|
+
leftEnd: '0',
|
|
2193
|
+
topStart: '0px',
|
|
2194
|
+
topEnd: '0',
|
|
2191
2195
|
};
|
|
2192
2196
|
triggerPulse$ = new Subject();
|
|
2197
|
+
isHide$ = new Subject();
|
|
2193
2198
|
closed = new Subject();
|
|
2194
2199
|
shouldClose = new Subject();
|
|
2195
2200
|
isClosing = false;
|
|
2196
2201
|
constructor(overlayRef, destroyRef, onClose = () => { }, options = {
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2202
|
+
startOrigin: 'center center',
|
|
2203
|
+
endOrigin: 'center center',
|
|
2204
|
+
start: 'scale(0.8)',
|
|
2205
|
+
end: 'scale(1)',
|
|
2206
|
+
leftStart: '0px',
|
|
2207
|
+
leftEnd: '0',
|
|
2208
|
+
topStart: '0px',
|
|
2209
|
+
topEnd: '0',
|
|
2201
2210
|
}) {
|
|
2202
2211
|
this.overlayRef = overlayRef;
|
|
2203
2212
|
this.destroyRef = destroyRef;
|
|
@@ -2205,12 +2214,12 @@ class UiPopupInstance {
|
|
|
2205
2214
|
this.options = options;
|
|
2206
2215
|
this.overlayRef
|
|
2207
2216
|
.detachments()
|
|
2208
|
-
.pipe(
|
|
2209
|
-
.subscribe(() => {
|
|
2217
|
+
.pipe(tap(() => {
|
|
2210
2218
|
this.closed.next();
|
|
2211
2219
|
this.closed.complete();
|
|
2212
2220
|
this.overlayRef.dispose();
|
|
2213
|
-
})
|
|
2221
|
+
}), takeUntilDestroyed(this.destroyRef))
|
|
2222
|
+
.subscribe();
|
|
2214
2223
|
}
|
|
2215
2224
|
close() {
|
|
2216
2225
|
if (this.isClosing) {
|
|
@@ -2235,7 +2244,7 @@ class UiModal {
|
|
|
2235
2244
|
destroyRef;
|
|
2236
2245
|
router;
|
|
2237
2246
|
backdropService;
|
|
2238
|
-
|
|
2247
|
+
instances = [];
|
|
2239
2248
|
backdropRef;
|
|
2240
2249
|
backdropPortalRef;
|
|
2241
2250
|
destroyDownloading$ = new Subject();
|
|
@@ -2251,29 +2260,23 @@ class UiModal {
|
|
|
2251
2260
|
* Closes the last opened popup.
|
|
2252
2261
|
*/
|
|
2253
2262
|
close() {
|
|
2254
|
-
if (this.
|
|
2255
|
-
this.
|
|
2256
|
-
this.
|
|
2257
|
-
if (!this.
|
|
2263
|
+
if (this.instances.length >= 1) {
|
|
2264
|
+
this.instances[this.instances.length - 1].close();
|
|
2265
|
+
this.instances.pop();
|
|
2266
|
+
if (!this.instances.length) {
|
|
2258
2267
|
this.destroy();
|
|
2259
2268
|
}
|
|
2260
2269
|
}
|
|
2261
2270
|
}
|
|
2262
|
-
closePrevious() {
|
|
2263
|
-
if (this.popupInstances.length >= 1) {
|
|
2264
|
-
this.popupInstances[this.popupInstances.length - 1].close();
|
|
2265
|
-
this.popupInstances.pop();
|
|
2266
|
-
}
|
|
2267
|
-
}
|
|
2268
2271
|
/**
|
|
2269
|
-
* Closes a popup by its index in the
|
|
2272
|
+
* Closes a popup by its index in the instances array.
|
|
2270
2273
|
*
|
|
2271
2274
|
* @param index - The index of the popup to close.
|
|
2272
2275
|
*/
|
|
2273
2276
|
closeByIndex(index) {
|
|
2274
|
-
this.
|
|
2275
|
-
this.
|
|
2276
|
-
if (!this.
|
|
2277
|
+
this.instances[index].close();
|
|
2278
|
+
this.instances.splice(index, 1);
|
|
2279
|
+
if (!this.instances.length) {
|
|
2277
2280
|
this.destroy();
|
|
2278
2281
|
}
|
|
2279
2282
|
}
|
|
@@ -2283,7 +2286,7 @@ class UiModal {
|
|
|
2283
2286
|
* @param id - The unique identifier of the popup to close.
|
|
2284
2287
|
*/
|
|
2285
2288
|
closeById(id) {
|
|
2286
|
-
const dropDownIndex = this.
|
|
2289
|
+
const dropDownIndex = this.instances.findIndex((v) => v.id === id);
|
|
2287
2290
|
if (dropDownIndex >= 0) {
|
|
2288
2291
|
this.closeByIndex(dropDownIndex);
|
|
2289
2292
|
}
|
|
@@ -2292,10 +2295,10 @@ class UiModal {
|
|
|
2292
2295
|
* Closes all currently opened popups.
|
|
2293
2296
|
*/
|
|
2294
2297
|
closeAll() {
|
|
2295
|
-
this.
|
|
2298
|
+
this.instances.forEach((element) => {
|
|
2296
2299
|
element.close();
|
|
2297
2300
|
});
|
|
2298
|
-
this.
|
|
2301
|
+
this.instances = [];
|
|
2299
2302
|
this.destroy();
|
|
2300
2303
|
}
|
|
2301
2304
|
/**
|
|
@@ -2328,7 +2331,7 @@ class UiModal {
|
|
|
2328
2331
|
}
|
|
2329
2332
|
}
|
|
2330
2333
|
uiPopupInstance.id = id;
|
|
2331
|
-
this.
|
|
2334
|
+
this.instances.push(uiPopupInstance);
|
|
2332
2335
|
}
|
|
2333
2336
|
/**
|
|
2334
2337
|
* Subscribes to outside events (e.g., scroll, router events) to close popups.
|
|
@@ -2372,7 +2375,7 @@ class UiModal {
|
|
|
2372
2375
|
if (this.backdropPortalRef) {
|
|
2373
2376
|
this.backdropPortalRef.location.nativeElement.classList.add('animate-in');
|
|
2374
2377
|
this.backdropPortalRef.setInput('isStaticBackdrop', isStaticBackdrop);
|
|
2375
|
-
this.backdropPortalRef.setInput('clicked', () => this.
|
|
2378
|
+
this.backdropPortalRef.setInput('clicked', () => this.instances[this.instances.length - 1].triggerPulse$.next());
|
|
2376
2379
|
}
|
|
2377
2380
|
}
|
|
2378
2381
|
hideBackdrop() {
|
|
@@ -2404,10 +2407,14 @@ class UiModal {
|
|
|
2404
2407
|
return {
|
|
2405
2408
|
animationOptions: parameters.animationOptions === undefined
|
|
2406
2409
|
? {
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2410
|
+
startOrigin: 'center center',
|
|
2411
|
+
endOrigin: 'center center',
|
|
2412
|
+
start: 'scale(0.8)',
|
|
2413
|
+
end: 'scale(1)',
|
|
2414
|
+
leftStart: '0px',
|
|
2415
|
+
leftEnd: '0',
|
|
2416
|
+
topStart: '0px',
|
|
2417
|
+
topEnd: '0',
|
|
2411
2418
|
}
|
|
2412
2419
|
: parameters.animationOptions,
|
|
2413
2420
|
isClosePrevious: parameters.isClosePrevious === undefined ? false : parameters.isClosePrevious,
|
|
@@ -2424,6 +2431,7 @@ class UiPopupContainerDirective {
|
|
|
2424
2431
|
elementRef;
|
|
2425
2432
|
$isShow = signal(false, ...(ngDevMode ? [{ debugName: "$isShow" }] : []));
|
|
2426
2433
|
$pulseTrigger = signal(false, ...(ngDevMode ? [{ debugName: "$pulseTrigger" }] : []));
|
|
2434
|
+
$isHide = signal(false, ...(ngDevMode ? [{ debugName: "$isHide" }] : []));
|
|
2427
2435
|
$overflowHidden = input(true, ...(ngDevMode ? [{ debugName: "$overflowHidden" }] : []));
|
|
2428
2436
|
$shouldClose = model(false, ...(ngDevMode ? [{ debugName: "$shouldClose" }] : []));
|
|
2429
2437
|
$hasCloseButton = input(false, ...(ngDevMode ? [{ debugName: "$hasCloseButton" }] : []));
|
|
@@ -2471,9 +2479,13 @@ class UiPopupContainerDirective {
|
|
|
2471
2479
|
this.$isShow.set(false);
|
|
2472
2480
|
}), takeUntilDestroyed(this.destroyRef))
|
|
2473
2481
|
.subscribe();
|
|
2482
|
+
this.popupInstance.isHide$
|
|
2483
|
+
.pipe(tap((b) => {
|
|
2484
|
+
this.$isHide.set(b);
|
|
2485
|
+
}), takeUntilDestroyed(this.destroyRef))
|
|
2486
|
+
.subscribe();
|
|
2474
2487
|
this.popupInstance.triggerPulse$
|
|
2475
2488
|
.pipe(tap(() => {
|
|
2476
|
-
console.log('pulse');
|
|
2477
2489
|
this.$pulseTrigger.set(true);
|
|
2478
2490
|
asyncScheduler.schedule(() => {
|
|
2479
2491
|
this.$pulseTrigger.set(false);
|
|
@@ -2481,16 +2493,17 @@ class UiPopupContainerDirective {
|
|
|
2481
2493
|
}), takeUntilDestroyed(this.destroyRef))
|
|
2482
2494
|
.subscribe();
|
|
2483
2495
|
this.popupInstance.animationOrigin$
|
|
2484
|
-
.pipe(tap((
|
|
2496
|
+
.pipe(tap((origin) => {
|
|
2497
|
+
const animationParams = this.popupInstance.options;
|
|
2485
2498
|
this.$animationParams.set({
|
|
2486
|
-
startOrigin:
|
|
2487
|
-
endOrigin:
|
|
2488
|
-
start:
|
|
2489
|
-
end:
|
|
2490
|
-
leftStart:
|
|
2491
|
-
leftEnd:
|
|
2492
|
-
topStart:
|
|
2493
|
-
topEnd:
|
|
2499
|
+
startOrigin: origin,
|
|
2500
|
+
endOrigin: origin,
|
|
2501
|
+
start: animationParams.start,
|
|
2502
|
+
end: animationParams.end,
|
|
2503
|
+
leftStart: animationParams.leftStart,
|
|
2504
|
+
leftEnd: animationParams.leftEnd,
|
|
2505
|
+
topStart: animationParams.topStart,
|
|
2506
|
+
topEnd: animationParams.topEnd,
|
|
2494
2507
|
});
|
|
2495
2508
|
this.$isShow.set(true);
|
|
2496
2509
|
}), takeUntil$1(this.destroyAnimationOrigin$), takeUntilDestroyed(this.destroyRef))
|
|
@@ -2769,6 +2782,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
|
|
|
2769
2782
|
}], ctorParameters: () => [{ type: i0.Type }, { type: i0.Type }] });
|
|
2770
2783
|
|
|
2771
2784
|
class UiPopupService extends UiModal {
|
|
2785
|
+
defaultAnimationOptions = {
|
|
2786
|
+
startOrigin: '',
|
|
2787
|
+
endOrigin: '',
|
|
2788
|
+
start: '',
|
|
2789
|
+
end: '',
|
|
2790
|
+
leftStart: '',
|
|
2791
|
+
leftEnd: '',
|
|
2792
|
+
topStart: '',
|
|
2793
|
+
topEnd: '',
|
|
2794
|
+
};
|
|
2772
2795
|
constructor(overlay, injector, destroyRef, router, backdropService) {
|
|
2773
2796
|
super(overlay, injector, destroyRef, router, backdropService);
|
|
2774
2797
|
}
|
|
@@ -2781,8 +2804,18 @@ class UiPopupService extends UiModal {
|
|
|
2781
2804
|
* @param parameters - (Optional) Configuration options for the popup.
|
|
2782
2805
|
*/
|
|
2783
2806
|
open(component, options, id, parameters) {
|
|
2784
|
-
if (this.
|
|
2785
|
-
this.closePrevious(parameters.isClosePrevious);
|
|
2807
|
+
if (this.instances.length) {
|
|
2808
|
+
this.closePrevious(parameters.isClosePrevious ?? false);
|
|
2809
|
+
parameters.animationOptions = {
|
|
2810
|
+
startOrigin: 'center center',
|
|
2811
|
+
endOrigin: 'center center',
|
|
2812
|
+
start: 'translateX(100%)',
|
|
2813
|
+
end: 'translateX(0)',
|
|
2814
|
+
leftStart: '0',
|
|
2815
|
+
leftEnd: '0',
|
|
2816
|
+
topStart: '0',
|
|
2817
|
+
topEnd: '0',
|
|
2818
|
+
};
|
|
2786
2819
|
}
|
|
2787
2820
|
this.showBackdrop(parameters.isStaticBackdrop);
|
|
2788
2821
|
const overlayRef = this.overlay.create({
|
|
@@ -2792,13 +2825,54 @@ class UiPopupService extends UiModal {
|
|
|
2792
2825
|
});
|
|
2793
2826
|
this.subscribeToOutsideEvents();
|
|
2794
2827
|
this.createPopup(overlayRef, component, options, id, parameters);
|
|
2828
|
+
if (this.instances.length === 1) {
|
|
2829
|
+
this.defaultAnimationOptions = this.instances[0].options;
|
|
2830
|
+
}
|
|
2831
|
+
}
|
|
2832
|
+
close() {
|
|
2833
|
+
this.resetAnimationForSingleInstance();
|
|
2834
|
+
super.close();
|
|
2835
|
+
this.applyHideToLastInstance();
|
|
2836
|
+
}
|
|
2837
|
+
closeAll() {
|
|
2838
|
+
this.instances.forEach((instance) => {
|
|
2839
|
+
instance.options = this.defaultAnimationOptions;
|
|
2840
|
+
instance.animationOrigin$.next('center');
|
|
2841
|
+
});
|
|
2842
|
+
super.closeAll();
|
|
2843
|
+
}
|
|
2844
|
+
closeById(id) {
|
|
2845
|
+
this.resetAnimationForSingleInstance();
|
|
2846
|
+
super.closeById(id);
|
|
2847
|
+
this.applyHideToLastInstance();
|
|
2848
|
+
}
|
|
2849
|
+
resetAnimationForSingleInstance() {
|
|
2850
|
+
if (this.instances.length === 1) {
|
|
2851
|
+
const instance = this.instances[0];
|
|
2852
|
+
instance.options = this.defaultAnimationOptions;
|
|
2853
|
+
instance.animationOrigin$.next('center');
|
|
2854
|
+
}
|
|
2855
|
+
}
|
|
2856
|
+
applyHideToLastInstance() {
|
|
2857
|
+
if (this.instances.length >= 1) {
|
|
2858
|
+
this.instances[this.instances.length - 1].isHide$.next(false);
|
|
2859
|
+
}
|
|
2795
2860
|
}
|
|
2796
2861
|
closePrevious(isClosePrevious) {
|
|
2797
|
-
if (this.
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2862
|
+
if (this.instances.length === 0)
|
|
2863
|
+
return;
|
|
2864
|
+
const lastIndex = this.instances.length - 1;
|
|
2865
|
+
const lastPopupInstance = this.instances[lastIndex];
|
|
2866
|
+
lastPopupInstance.isHide$.next(true);
|
|
2867
|
+
if (isClosePrevious) {
|
|
2868
|
+
asyncScheduler.schedule(() => {
|
|
2869
|
+
// ensure the instance still exists
|
|
2870
|
+
const currentIndex = this.instances.indexOf(lastPopupInstance);
|
|
2871
|
+
if (currentIndex !== -1) {
|
|
2872
|
+
lastPopupInstance.close();
|
|
2873
|
+
this.instances.splice(currentIndex, 1);
|
|
2874
|
+
}
|
|
2875
|
+
}, 300);
|
|
2802
2876
|
}
|
|
2803
2877
|
}
|
|
2804
2878
|
/**
|
|
@@ -2826,10 +2900,14 @@ class UiPopupService extends UiModal {
|
|
|
2826
2900
|
const scaleY = Math.trunc((sourceHeight / fitted.height) * 100) / 100;
|
|
2827
2901
|
const scaleX = Math.trunc((sourceWidth / fitted.width) * 100) / 100;
|
|
2828
2902
|
return {
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2903
|
+
startOrigin: 'center center',
|
|
2904
|
+
endOrigin: 'center center',
|
|
2905
|
+
start: `scale(${scaleY}, ${scaleX})`,
|
|
2906
|
+
end: 'scale(1)',
|
|
2907
|
+
leftStart: `${offsetX}px`,
|
|
2908
|
+
leftEnd: '0',
|
|
2909
|
+
topStart: `${offsetY}px`,
|
|
2910
|
+
topEnd: '0',
|
|
2833
2911
|
};
|
|
2834
2912
|
}
|
|
2835
2913
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiPopupService, deps: [{ token: i1.Overlay }, { token: i0.Injector }, { token: i0.DestroyRef }, { token: i2$1.Router }, { token: UiPopupBackdropService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
@@ -3035,10 +3113,10 @@ class UiDropdownService extends UiModal {
|
|
|
3035
3113
|
if (fetchedParameters.hasAttachedWidth) {
|
|
3036
3114
|
attachedWidth = attachedRef.clientWidth;
|
|
3037
3115
|
}
|
|
3038
|
-
if (fetchedParameters.removePrevious && this.
|
|
3116
|
+
if (fetchedParameters.removePrevious && this.instances.length) {
|
|
3039
3117
|
this.destroyOutsideClickSubscription$.next();
|
|
3040
3118
|
}
|
|
3041
|
-
if (fetchedParameters.removePrevious && this.
|
|
3119
|
+
if (fetchedParameters.removePrevious && this.instances.length) {
|
|
3042
3120
|
this.close();
|
|
3043
3121
|
}
|
|
3044
3122
|
if (isBrowser() && window.matchMedia('(max-width: 48rem)').matches) {
|
|
@@ -3053,7 +3131,7 @@ class UiDropdownService extends UiModal {
|
|
|
3053
3131
|
this.subscribeToOutsideEvents(overlayRef);
|
|
3054
3132
|
}
|
|
3055
3133
|
this.createPopup(overlayRef, component, fetchedParameters.options ?? {}, id, { width: attachedWidth });
|
|
3056
|
-
this.
|
|
3134
|
+
this.instances[this.instances.length - 1].animationOrigin$.next(this.connectedPositions[parameters.position ?? 'bottom'].animationOrigin);
|
|
3057
3135
|
}
|
|
3058
3136
|
/**
|
|
3059
3137
|
* Opens a dropdown from the mouse position with intelligent border detection.
|
|
@@ -3067,10 +3145,10 @@ class UiDropdownService extends UiModal {
|
|
|
3067
3145
|
*/
|
|
3068
3146
|
openAtMousePosition(component, event, id, parameters = {}) {
|
|
3069
3147
|
const fetchedParameters = this.fetchDropDownParameters(parameters);
|
|
3070
|
-
if (fetchedParameters.removePrevious && this.
|
|
3148
|
+
if (fetchedParameters.removePrevious && this.instances.length) {
|
|
3071
3149
|
this.destroyOutsideClickSubscription$.next();
|
|
3072
3150
|
}
|
|
3073
|
-
if (fetchedParameters.removePrevious && this.
|
|
3151
|
+
if (fetchedParameters.removePrevious && this.instances.length) {
|
|
3074
3152
|
this.close();
|
|
3075
3153
|
}
|
|
3076
3154
|
if (isBrowser() && window.matchMedia('(max-width: 48rem)').matches) {
|
|
@@ -3086,10 +3164,14 @@ class UiDropdownService extends UiModal {
|
|
|
3086
3164
|
}
|
|
3087
3165
|
this.createPopup(overlayRef, component, fetchedParameters.options ?? {}, id, {
|
|
3088
3166
|
animationOptions: {
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3167
|
+
startOrigin: 'center center',
|
|
3168
|
+
endOrigin: 'center center',
|
|
3169
|
+
start: 'scale(0.4)',
|
|
3170
|
+
end: 'scale(1)',
|
|
3171
|
+
leftStart: '0px',
|
|
3172
|
+
leftEnd: '0',
|
|
3173
|
+
topStart: '0px',
|
|
3174
|
+
topEnd: '0',
|
|
3093
3175
|
},
|
|
3094
3176
|
});
|
|
3095
3177
|
this.containerSize$
|
|
@@ -3099,7 +3181,7 @@ class UiDropdownService extends UiModal {
|
|
|
3099
3181
|
}
|
|
3100
3182
|
const animationOrigin = this.calculateMousePositionAnimationOrigin(event, size);
|
|
3101
3183
|
const positionAdjustment = this.calculateMousePositionAdjustment(event, size);
|
|
3102
|
-
this.
|
|
3184
|
+
this.instances[this.instances.length - 1].animationOrigin$.next(animationOrigin);
|
|
3103
3185
|
const positionStrategy = overlayRef.getConfig().positionStrategy;
|
|
3104
3186
|
if (positionStrategy instanceof FlexibleConnectedPositionStrategy && positionAdjustment) {
|
|
3105
3187
|
positionStrategy.setOrigin({ x: positionAdjustment.left, y: positionAdjustment.top });
|