@ibragim-dev-org/ui-forge-library 1.4.3 → 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.
@@ -1,10 +1,11 @@
1
1
  import * as i2$1 from '@angular/router';
2
2
  import { NavigationEnd, NavigationStart, ActivationEnd } from '@angular/router';
3
- import { BehaviorSubject, filter, take, scheduled, fromEvent, asyncScheduler, mergeAll, tap, debounceTime, Subscription, timer, switchMap, interval, takeWhile, finalize, Subject, takeUntil } from 'rxjs';
3
+ import { BehaviorSubject, filter, take, scheduled, fromEvent, asyncScheduler, mergeAll, tap, debounceTime, Subject, Subscription, timer, switchMap, interval, takeWhile, finalize, takeUntil as takeUntil$1 } from 'rxjs';
4
4
  import * as i0 from '@angular/core';
5
- import { model, effect, Directive, Injectable, output, Input, input, PLATFORM_ID, Inject, EventEmitter, Output, Pipe, Attribute, ChangeDetectionStrategy, Component, signal, computed, viewChild, untracked, Injector, afterRenderEffect, contentChildren, contentChild, ViewChildren } from '@angular/core';
5
+ import { model, effect, Directive, Injectable, output, Input, input, PLATFORM_ID, Inject, EventEmitter, Output, inject, Pipe, Attribute, ChangeDetectionStrategy, Component, signal, computed, viewChild, untracked, Injector, afterRenderEffect, contentChildren, contentChild, ViewChildren } from '@angular/core';
6
6
  import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
7
7
  import { isPlatformBrowser, DOCUMENT, NgStyle } from '@angular/common';
8
+ import { throttleTime, tap as tap$1, takeUntil, debounceTime as debounceTime$1 } from 'rxjs/operators';
8
9
  import * as i2 from '@angular/platform-browser';
9
10
  import { PhoneNumberUtil, AsYouTypeFormatter } from 'google-libphonenumber';
10
11
  import { ulid } from 'ulid';
@@ -784,6 +785,195 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
784
785
  args: [PLATFORM_ID]
785
786
  }] }], propDecorators: { sizeChange: [{ type: i0.Output, args: ["sizeChange"] }] } });
786
787
 
788
+ class StableScrollDirective {
789
+ el;
790
+ platformId = inject(PLATFORM_ID);
791
+ isBrowser = isPlatformBrowser(this.platformId);
792
+ destroy$ = new Subject();
793
+ scrolling$ = new Subject();
794
+ _isScrolling = false;
795
+ mutationObserver;
796
+ restoreFrameId = null;
797
+ restoreMicrotaskPending = false;
798
+ // ---- thresholds ----
799
+ $topThreshold = input(0, ...(ngDevMode ? [{ debugName: "$topThreshold" }] : []));
800
+ $bottomThreshold = input(0, ...(ngDevMode ? [{ debugName: "$bottomThreshold" }] : []));
801
+ reachedTop = output();
802
+ reachedBottom = output();
803
+ // ---- anchor ----
804
+ anchorSnapshot = null;
805
+ // ---- direction tracking ----
806
+ lastScrollTop = 0;
807
+ scrollingUp = false;
808
+ scrollingDown = false;
809
+ constructor(elRef) {
810
+ this.el = elRef.nativeElement;
811
+ }
812
+ get scrolling() {
813
+ return this._isScrolling;
814
+ }
815
+ ngAfterViewInit() {
816
+ if (!this.isBrowser) {
817
+ return;
818
+ }
819
+ this.lastScrollTop = this.el.scrollTop;
820
+ this.refreshAnchorSnapshot();
821
+ this.observeContentChanges();
822
+ fromEvent(this.el, 'scroll')
823
+ .pipe(throttleTime(50), tap$1(() => {
824
+ const { scrollTop } = this.el;
825
+ // detect direction
826
+ this.scrollingUp = scrollTop < this.lastScrollTop;
827
+ this.scrollingDown = scrollTop > this.lastScrollTop;
828
+ this.lastScrollTop = scrollTop;
829
+ this._isScrolling = true;
830
+ this.scrolling$.next();
831
+ this.checkThresholds();
832
+ this.refreshAnchorSnapshot();
833
+ }), takeUntil(this.destroy$))
834
+ .subscribe();
835
+ this.scrolling$
836
+ .pipe(debounceTime$1(120), tap$1(() => (this._isScrolling = false)), takeUntil(this.destroy$))
837
+ .subscribe();
838
+ }
839
+ ngOnDestroy() {
840
+ this.mutationObserver?.disconnect();
841
+ if (this.restoreFrameId !== null && this.isBrowser) {
842
+ cancelAnimationFrame(this.restoreFrameId);
843
+ }
844
+ this.destroy$.next();
845
+ this.destroy$.complete();
846
+ }
847
+ /** Call BEFORE data changes */
848
+ captureBeforeChange() {
849
+ this.refreshAnchorSnapshot();
850
+ }
851
+ /** Call AFTER render */
852
+ restoreScrollPosition() {
853
+ this.scheduleRestore();
854
+ }
855
+ // ---- threshold logic ----
856
+ checkThresholds() {
857
+ const { scrollTop, scrollHeight, clientHeight } = this.el;
858
+ const topThreshold = this.$topThreshold();
859
+ const topPx = topThreshold <= 1 ? scrollHeight * topThreshold : topThreshold;
860
+ const bottomThreshold = this.$bottomThreshold();
861
+ const bottomPx = bottomThreshold <= 1 ? scrollHeight * bottomThreshold : bottomThreshold;
862
+ // emit top ONLY when scrolling UP
863
+ if (this.scrollingUp && scrollTop <= topPx) {
864
+ this.reachedTop.emit();
865
+ }
866
+ // emit bottom ONLY when scrolling DOWN
867
+ if (this.scrollingDown && scrollTop + clientHeight >= scrollHeight - bottomPx) {
868
+ this.reachedBottom.emit();
869
+ }
870
+ }
871
+ observeContentChanges() {
872
+ if (typeof MutationObserver === 'undefined') {
873
+ return;
874
+ }
875
+ this.mutationObserver = new MutationObserver((mutations) => {
876
+ if (!mutations.some((mutation) => mutation.addedNodes.length || mutation.removedNodes.length)) {
877
+ return;
878
+ }
879
+ if (!this.anchorSnapshot) {
880
+ this.refreshAnchorSnapshot();
881
+ return;
882
+ }
883
+ this.scheduleRestore();
884
+ });
885
+ this.mutationObserver.observe(this.el, {
886
+ childList: true,
887
+ });
888
+ }
889
+ scheduleRestore() {
890
+ if (!this.isBrowser || this.restoreMicrotaskPending) {
891
+ return;
892
+ }
893
+ this.restoreMicrotaskPending = true;
894
+ queueMicrotask(() => {
895
+ this.restoreMicrotaskPending = false;
896
+ this.restoreFromSnapshot();
897
+ this.scheduleAnimationFrameRestore();
898
+ });
899
+ }
900
+ restoreFromSnapshot() {
901
+ if (!this.anchorSnapshot) {
902
+ return;
903
+ }
904
+ const { element, topOffset } = this.anchorSnapshot;
905
+ if (!element.isConnected || element.parentElement !== this.el) {
906
+ this.anchorSnapshot = null;
907
+ return;
908
+ }
909
+ const containerTop = this.el.getBoundingClientRect().top;
910
+ const nextTopOffset = element.getBoundingClientRect().top - containerTop;
911
+ const delta = nextTopOffset - topOffset;
912
+ if (delta !== 0) {
913
+ this.el.scrollTop += delta;
914
+ }
915
+ this.lastScrollTop = this.el.scrollTop;
916
+ this.refreshAnchorSnapshot();
917
+ }
918
+ scheduleAnimationFrameRestore() {
919
+ if (!this.isBrowser) {
920
+ return;
921
+ }
922
+ if (this.restoreFrameId !== null) {
923
+ cancelAnimationFrame(this.restoreFrameId);
924
+ }
925
+ this.restoreFrameId = requestAnimationFrame(() => {
926
+ this.restoreFrameId = null;
927
+ this.restoreFromSnapshot();
928
+ });
929
+ }
930
+ refreshAnchorSnapshot() {
931
+ const anchor = this.resolveAnchorElement();
932
+ if (!anchor) {
933
+ this.anchorSnapshot = null;
934
+ return;
935
+ }
936
+ const containerTop = this.el.getBoundingClientRect().top;
937
+ const topOffset = anchor.getBoundingClientRect().top - containerTop;
938
+ this.anchorSnapshot = {
939
+ element: anchor,
940
+ topOffset,
941
+ };
942
+ }
943
+ resolveAnchorElement() {
944
+ const containerRect = this.el.getBoundingClientRect();
945
+ const candidates = this.resolveAnchorCandidates();
946
+ if (!candidates.length) {
947
+ return null;
948
+ }
949
+ const visibleCandidate = candidates.find((candidate) => {
950
+ const rect = candidate.getBoundingClientRect();
951
+ return rect.bottom > containerRect.top && rect.top < containerRect.bottom;
952
+ });
953
+ if (visibleCandidate) {
954
+ return visibleCandidate;
955
+ }
956
+ return candidates.reduce((closest, candidate) => {
957
+ const closestDistance = Math.abs(closest.getBoundingClientRect().top - containerRect.top);
958
+ const candidateDistance = Math.abs(candidate.getBoundingClientRect().top - containerRect.top);
959
+ return candidateDistance < closestDistance ? candidate : closest;
960
+ });
961
+ }
962
+ resolveAnchorCandidates() {
963
+ const children = Array.from(this.el.children);
964
+ const messageChildren = children.filter((child) => child.classList.contains('message'));
965
+ return messageChildren.length ? messageChildren : children;
966
+ }
967
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: StableScrollDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
968
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.1.1", type: StableScrollDirective, isStandalone: true, selector: "[stableScroll]", inputs: { $topThreshold: { classPropertyName: "$topThreshold", publicName: "$topThreshold", isSignal: true, isRequired: false, transformFunction: null }, $bottomThreshold: { classPropertyName: "$bottomThreshold", publicName: "$bottomThreshold", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { reachedTop: "reachedTop", reachedBottom: "reachedBottom" }, ngImport: i0 });
969
+ }
970
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: StableScrollDirective, decorators: [{
971
+ type: Directive,
972
+ args: [{
973
+ selector: '[stableScroll]',
974
+ }]
975
+ }], ctorParameters: () => [{ type: i0.ElementRef }], propDecorators: { $topThreshold: [{ type: i0.Input, args: [{ isSignal: true, alias: "$topThreshold", required: false }] }], $bottomThreshold: [{ type: i0.Input, args: [{ isSignal: true, alias: "$bottomThreshold", required: false }] }], reachedTop: [{ type: i0.Output, args: ["reachedTop"] }], reachedBottom: [{ type: i0.Output, args: ["reachedBottom"] }] } });
976
+
787
977
  class CenterEllipsisPipe {
788
978
  transform(value, visibleStart = 4, visibleEnd = 4) {
789
979
  if (!value) {
@@ -1994,19 +2184,29 @@ class UiPopupInstance {
1994
2184
  width = 0;
1995
2185
  animationOrigin$ = new BehaviorSubject('center');
1996
2186
  options = {
1997
- positionX: 0,
1998
- positionY: 0,
1999
- startTransition: 'scale(0)',
2000
- endTransition: 'scale(0)',
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',
2001
2195
  };
2196
+ triggerPulse$ = new Subject();
2197
+ isHide$ = new Subject();
2002
2198
  closed = new Subject();
2003
2199
  shouldClose = new Subject();
2004
2200
  isClosing = false;
2005
2201
  constructor(overlayRef, destroyRef, onClose = () => { }, options = {
2006
- positionX: 0,
2007
- positionY: 0,
2008
- startTransition: 'scale(0.8)',
2009
- endTransition: 'scale(1)',
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',
2010
2210
  }) {
2011
2211
  this.overlayRef = overlayRef;
2012
2212
  this.destroyRef = destroyRef;
@@ -2014,12 +2214,12 @@ class UiPopupInstance {
2014
2214
  this.options = options;
2015
2215
  this.overlayRef
2016
2216
  .detachments()
2017
- .pipe(takeUntilDestroyed(this.destroyRef))
2018
- .subscribe(() => {
2217
+ .pipe(tap(() => {
2019
2218
  this.closed.next();
2020
2219
  this.closed.complete();
2021
2220
  this.overlayRef.dispose();
2022
- });
2221
+ }), takeUntilDestroyed(this.destroyRef))
2222
+ .subscribe();
2023
2223
  }
2024
2224
  close() {
2025
2225
  if (this.isClosing) {
@@ -2038,32 +2238,13 @@ class UiPopupInstance {
2038
2238
  }
2039
2239
  }
2040
2240
 
2041
- class UiPopupBackdropService {
2042
- tipContainerPortal;
2043
- backdropPortal;
2044
- constructor(component, tipComponent) {
2045
- this.backdropPortal = new ComponentPortal(component);
2046
- if (tipComponent) {
2047
- this.tipContainerPortal = new ComponentPortal(tipComponent);
2048
- }
2049
- }
2050
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiPopupBackdropService, deps: [{ token: i0.Type }, { token: i0.Type }], target: i0.ɵɵFactoryTarget.Injectable });
2051
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiPopupBackdropService, providedIn: 'root' });
2052
- }
2053
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiPopupBackdropService, decorators: [{
2054
- type: Injectable,
2055
- args: [{
2056
- providedIn: 'root',
2057
- }]
2058
- }], ctorParameters: () => [{ type: i0.Type }, { type: i0.Type }] });
2059
-
2060
- class UiPopupService {
2241
+ class UiModal {
2061
2242
  overlay;
2062
2243
  injector;
2063
2244
  destroyRef;
2064
2245
  router;
2065
2246
  backdropService;
2066
- popupInstances = [];
2247
+ instances = [];
2067
2248
  backdropRef;
2068
2249
  backdropPortalRef;
2069
2250
  destroyDownloading$ = new Subject();
@@ -2075,67 +2256,27 @@ class UiPopupService {
2075
2256
  this.router = router;
2076
2257
  this.backdropService = backdropService;
2077
2258
  }
2078
- /**
2079
- * Opens a popup with the specified component and options.
2080
- *
2081
- * @param component - The component to be displayed in the popup.
2082
- * @param options - Configuration options for the popup, including inputs.
2083
- * @param id - A unique identifier for the popup instance.
2084
- * @param parameters - (Optional) Configuration options for the popup.
2085
- */
2086
- open(component, options, id, parameters) {
2087
- if (this.popupInstances.length) {
2088
- if (parameters.isClosePrevious) {
2089
- this.closePrevious();
2090
- }
2091
- }
2092
- this.showBackdrop(parameters.isStaticBackdrop);
2093
- const overlayRef = this.overlay.create({
2094
- hasBackdrop: false,
2095
- backdropClass: 'cdk-overlay-transparent-backdrop',
2096
- positionStrategy: this.overlay.position().global().centerHorizontally().centerVertically(),
2097
- });
2098
- this.subscribeToOutsideEvents();
2099
- this.createPopup(overlayRef, component, options, id, parameters);
2100
- }
2101
- /**
2102
- * Opens a popup that scales from the provided origin element to the centered popup size.
2103
- * Useful for image-preview transitions where the source element animates into the popup.
2104
- */
2105
- openScaledFromElement(component, options, id, originElement, sourceWidth, sourceHeight, parameters = {}) {
2106
- const animationOptions = this.createScaleAnimationOptionsFromElement(originElement, sourceWidth, sourceHeight);
2107
- this.open(component, options, id, {
2108
- ...parameters,
2109
- animationOptions,
2110
- });
2111
- }
2112
2259
  /**
2113
2260
  * Closes the last opened popup.
2114
2261
  */
2115
2262
  close() {
2116
- if (this.popupInstances.length >= 1) {
2117
- this.popupInstances[this.popupInstances.length - 1].close();
2118
- this.popupInstances.pop();
2119
- if (!this.popupInstances.length) {
2263
+ if (this.instances.length >= 1) {
2264
+ this.instances[this.instances.length - 1].close();
2265
+ this.instances.pop();
2266
+ if (!this.instances.length) {
2120
2267
  this.destroy();
2121
2268
  }
2122
2269
  }
2123
2270
  }
2124
- closePrevious() {
2125
- if (this.popupInstances.length >= 1) {
2126
- this.popupInstances[this.popupInstances.length - 1].close();
2127
- this.popupInstances.pop();
2128
- }
2129
- }
2130
2271
  /**
2131
- * Closes a popup by its index in the popupInstances array.
2272
+ * Closes a popup by its index in the instances array.
2132
2273
  *
2133
2274
  * @param index - The index of the popup to close.
2134
2275
  */
2135
2276
  closeByIndex(index) {
2136
- this.popupInstances[index].close();
2137
- this.popupInstances.splice(index, 1);
2138
- if (!this.popupInstances.length) {
2277
+ this.instances[index].close();
2278
+ this.instances.splice(index, 1);
2279
+ if (!this.instances.length) {
2139
2280
  this.destroy();
2140
2281
  }
2141
2282
  }
@@ -2145,7 +2286,7 @@ class UiPopupService {
2145
2286
  * @param id - The unique identifier of the popup to close.
2146
2287
  */
2147
2288
  closeById(id) {
2148
- const dropDownIndex = this.popupInstances.findIndex((v) => v.id === id);
2289
+ const dropDownIndex = this.instances.findIndex((v) => v.id === id);
2149
2290
  if (dropDownIndex >= 0) {
2150
2291
  this.closeByIndex(dropDownIndex);
2151
2292
  }
@@ -2154,10 +2295,10 @@ class UiPopupService {
2154
2295
  * Closes all currently opened popups.
2155
2296
  */
2156
2297
  closeAll() {
2157
- this.popupInstances.forEach((element) => {
2298
+ this.instances.forEach((element) => {
2158
2299
  element.close();
2159
2300
  });
2160
- this.popupInstances = [];
2301
+ this.instances = [];
2161
2302
  this.destroy();
2162
2303
  }
2163
2304
  /**
@@ -2170,7 +2311,7 @@ class UiPopupService {
2170
2311
  * @param parameters - (Optional) Configuration options for the popup.
2171
2312
  */
2172
2313
  createPopup(overlayRef, component, options, id, parameters) {
2173
- const newParameters = this.fetchPopupParameters(parameters);
2314
+ const newParameters = this.fetchParameters(parameters);
2174
2315
  const uiPopupInstance = new UiPopupInstance(overlayRef, this.destroyRef, options.onClose, newParameters.animationOptions);
2175
2316
  if (newParameters.width > 0) {
2176
2317
  uiPopupInstance.width = newParameters.width;
@@ -2190,7 +2331,7 @@ class UiPopupService {
2190
2331
  }
2191
2332
  }
2192
2333
  uiPopupInstance.id = id;
2193
- this.popupInstances.push(uiPopupInstance);
2334
+ this.instances.push(uiPopupInstance);
2194
2335
  }
2195
2336
  /**
2196
2337
  * Subscribes to outside events (e.g., scroll, router events) to close popups.
@@ -2201,13 +2342,13 @@ class UiPopupService {
2201
2342
  fromEvent(window, 'scroll')
2202
2343
  .pipe(tap(() => {
2203
2344
  this.closeAll();
2204
- }), takeUntil(this.destroyOutsideClickSubscription$))
2345
+ }), takeUntil$1(this.destroyOutsideClickSubscription$))
2205
2346
  .subscribe();
2206
2347
  }
2207
2348
  this.router.events
2208
2349
  .pipe(debounceTime(100), tap(() => {
2209
2350
  this.closeAll();
2210
- }), takeUntil(this.destroyOutsideClickSubscription$))
2351
+ }), takeUntil$1(this.destroyOutsideClickSubscription$))
2211
2352
  .subscribe();
2212
2353
  }
2213
2354
  destroy() {
@@ -2234,6 +2375,7 @@ class UiPopupService {
2234
2375
  if (this.backdropPortalRef) {
2235
2376
  this.backdropPortalRef.location.nativeElement.classList.add('animate-in');
2236
2377
  this.backdropPortalRef.setInput('isStaticBackdrop', isStaticBackdrop);
2378
+ this.backdropPortalRef.setInput('clicked', () => this.instances[this.instances.length - 1].triggerPulse$.next());
2237
2379
  }
2238
2380
  }
2239
2381
  hideBackdrop() {
@@ -2261,14 +2403,18 @@ class UiPopupService {
2261
2403
  * @param parameters - Partial configuration options for the popup.
2262
2404
  * @returns A complete set of popup parameters with default values applied.
2263
2405
  */
2264
- fetchPopupParameters(parameters) {
2406
+ fetchParameters(parameters) {
2265
2407
  return {
2266
2408
  animationOptions: parameters.animationOptions === undefined
2267
2409
  ? {
2268
- positionX: 0,
2269
- positionY: 0,
2270
- startTransition: 'scale(0.8)',
2271
- endTransition: 'scale(1)',
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',
2272
2418
  }
2273
2419
  : parameters.animationOptions,
2274
2420
  isClosePrevious: parameters.isClosePrevious === undefined ? false : parameters.isClosePrevious,
@@ -2276,35 +2422,7 @@ class UiPopupService {
2276
2422
  width: parameters.width === undefined ? 0 : parameters.width,
2277
2423
  };
2278
2424
  }
2279
- createScaleAnimationOptionsFromElement(originElement, sourceWidth, sourceHeight) {
2280
- const rect = originElement.getBoundingClientRect();
2281
- const viewportWidth = isBrowser() ? window.innerWidth : sourceWidth;
2282
- const viewportHeight = isBrowser() ? window.innerHeight : sourceHeight;
2283
- const centerX = viewportWidth / 2;
2284
- const centerY = viewportHeight / 2;
2285
- const targetX = rect.left + rect.width / 2;
2286
- const targetY = rect.top + rect.height / 2;
2287
- const offsetX = targetX - centerX;
2288
- const offsetY = targetY - centerY;
2289
- const fitted = getAspectRatioFit(viewportWidth - viewportWidth / 8, viewportHeight - viewportHeight / 8, sourceWidth, sourceHeight);
2290
- const scaleY = Math.trunc((sourceHeight / fitted.height) * 100) / 100;
2291
- const scaleX = Math.trunc((sourceWidth / fitted.width) * 100) / 100;
2292
- return {
2293
- positionX: offsetX,
2294
- positionY: offsetY,
2295
- startTransition: `scale(${scaleY}, ${scaleX})`,
2296
- endTransition: 'scale(1)',
2297
- };
2298
- }
2299
- 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 });
2300
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiPopupService, providedIn: 'root' });
2301
2425
  }
2302
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiPopupService, decorators: [{
2303
- type: Injectable,
2304
- args: [{
2305
- providedIn: 'root',
2306
- }]
2307
- }], ctorParameters: () => [{ type: i1.Overlay }, { type: i0.Injector }, { type: i0.DestroyRef }, { type: i2$1.Router }, { type: UiPopupBackdropService }] });
2308
2426
 
2309
2427
  class UiPopupContainerDirective {
2310
2428
  popupInstance;
@@ -2313,6 +2431,7 @@ class UiPopupContainerDirective {
2313
2431
  elementRef;
2314
2432
  $isShow = signal(false, ...(ngDevMode ? [{ debugName: "$isShow" }] : []));
2315
2433
  $pulseTrigger = signal(false, ...(ngDevMode ? [{ debugName: "$pulseTrigger" }] : []));
2434
+ $isHide = signal(false, ...(ngDevMode ? [{ debugName: "$isHide" }] : []));
2316
2435
  $overflowHidden = input(true, ...(ngDevMode ? [{ debugName: "$overflowHidden" }] : []));
2317
2436
  $shouldClose = model(false, ...(ngDevMode ? [{ debugName: "$shouldClose" }] : []));
2318
2437
  $hasCloseButton = input(false, ...(ngDevMode ? [{ debugName: "$hasCloseButton" }] : []));
@@ -2360,20 +2479,34 @@ class UiPopupContainerDirective {
2360
2479
  this.$isShow.set(false);
2361
2480
  }), takeUntilDestroyed(this.destroyRef))
2362
2481
  .subscribe();
2482
+ this.popupInstance.isHide$
2483
+ .pipe(tap((b) => {
2484
+ this.$isHide.set(b);
2485
+ }), takeUntilDestroyed(this.destroyRef))
2486
+ .subscribe();
2487
+ this.popupInstance.triggerPulse$
2488
+ .pipe(tap(() => {
2489
+ this.$pulseTrigger.set(true);
2490
+ asyncScheduler.schedule(() => {
2491
+ this.$pulseTrigger.set(false);
2492
+ }, 300);
2493
+ }), takeUntilDestroyed(this.destroyRef))
2494
+ .subscribe();
2363
2495
  this.popupInstance.animationOrigin$
2364
- .pipe(tap((e) => {
2496
+ .pipe(tap((origin) => {
2497
+ const animationParams = this.popupInstance.options;
2365
2498
  this.$animationParams.set({
2366
- startOrigin: e,
2367
- endOrigin: e,
2368
- start: this.popupInstance.options.startTransition,
2369
- end: this.popupInstance.options.endTransition,
2370
- leftStart: `${this.popupInstance.options.positionX}px`,
2371
- leftEnd: '0',
2372
- topStart: `${this.popupInstance.options.positionY}px`,
2373
- topEnd: '0',
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,
2374
2507
  });
2375
2508
  this.$isShow.set(true);
2376
- }), takeUntil(this.destroyAnimationOrigin$), takeUntilDestroyed(this.destroyRef))
2509
+ }), takeUntil$1(this.destroyAnimationOrigin$), takeUntilDestroyed(this.destroyRef))
2377
2510
  .subscribe();
2378
2511
  if (isBrowser()) {
2379
2512
  fromEvent(window, 'keydown')
@@ -2400,7 +2533,7 @@ class UiPopupContainerDirective {
2400
2533
  shouldClose() {
2401
2534
  this.$shouldClose.set(true);
2402
2535
  }
2403
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiPopupContainerDirective, deps: [{ token: UiPopupInstance }, { token: i0.DestroyRef }, { token: UiPopupService }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
2536
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiPopupContainerDirective, deps: [{ token: UiPopupInstance }, { token: i0.DestroyRef }, { token: UiModal }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
2404
2537
  static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.1.1", type: UiPopupContainerDirective, isStandalone: true, selector: "app-ui-popup-container", inputs: { $overflowHidden: { classPropertyName: "$overflowHidden", publicName: "$overflowHidden", isSignal: true, isRequired: false, transformFunction: null }, $shouldClose: { classPropertyName: "$shouldClose", publicName: "$shouldClose", isSignal: true, isRequired: false, transformFunction: null }, $hasCloseButton: { classPropertyName: "$hasCloseButton", publicName: "$hasCloseButton", isSignal: true, isRequired: false, transformFunction: null }, $isEnableFadeAnimation: { classPropertyName: "$isEnableFadeAnimation", publicName: "$isEnableFadeAnimation", isSignal: true, isRequired: false, transformFunction: null }, $iconClose: { classPropertyName: "$iconClose", publicName: "$iconClose", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { $shouldClose: "$shouldCloseChange", $iconClose: "$iconCloseChange" }, ngImport: i0 });
2405
2538
  }
2406
2539
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiPopupContainerDirective, decorators: [{
@@ -2411,122 +2544,533 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
2411
2544
  }], ctorParameters: () => [{ type: UiPopupInstance, decorators: [{
2412
2545
  type: Inject,
2413
2546
  args: [UiPopupInstance]
2414
- }] }, { type: i0.DestroyRef }, { type: UiPopupService }, { type: i0.ElementRef }], propDecorators: { $overflowHidden: [{ type: i0.Input, args: [{ isSignal: true, alias: "$overflowHidden", required: false }] }], $shouldClose: [{ type: i0.Input, args: [{ isSignal: true, alias: "$shouldClose", required: false }] }, { type: i0.Output, args: ["$shouldCloseChange"] }], $hasCloseButton: [{ type: i0.Input, args: [{ isSignal: true, alias: "$hasCloseButton", required: false }] }], $isEnableFadeAnimation: [{ type: i0.Input, args: [{ isSignal: true, alias: "$isEnableFadeAnimation", required: false }] }], $iconClose: [{ type: i0.Input, args: [{ isSignal: true, alias: "$iconClose", required: false }] }, { type: i0.Output, args: ["$iconCloseChange"] }] } });
2547
+ }] }, { type: i0.DestroyRef }, { type: UiModal }, { type: i0.ElementRef }], propDecorators: { $overflowHidden: [{ type: i0.Input, args: [{ isSignal: true, alias: "$overflowHidden", required: false }] }], $shouldClose: [{ type: i0.Input, args: [{ isSignal: true, alias: "$shouldClose", required: false }] }, { type: i0.Output, args: ["$shouldCloseChange"] }], $hasCloseButton: [{ type: i0.Input, args: [{ isSignal: true, alias: "$hasCloseButton", required: false }] }], $isEnableFadeAnimation: [{ type: i0.Input, args: [{ isSignal: true, alias: "$isEnableFadeAnimation", required: false }] }], $iconClose: [{ type: i0.Input, args: [{ isSignal: true, alias: "$iconClose", required: false }] }, { type: i0.Output, args: ["$iconCloseChange"] }] } });
2415
2548
 
2416
- class UiDropdownService extends UiPopupService {
2417
- containerSize$ = new BehaviorSubject({
2418
- width: 0,
2419
- height: 0,
2420
- });
2421
- connectedPositions = {
2422
- bottom: {
2423
- animationOrigin: 'top center',
2424
- connectedPosition: {
2425
- originX: 'center',
2426
- originY: 'bottom',
2427
- overlayX: 'center',
2428
- overlayY: 'top',
2429
- offsetY: 0,
2430
- offsetX: 0,
2431
- },
2432
- },
2433
- top: {
2434
- animationOrigin: 'bottom center',
2435
- connectedPosition: {
2436
- originX: 'center',
2437
- originY: 'top',
2438
- overlayX: 'center',
2439
- overlayY: 'bottom',
2440
- offsetY: 0,
2441
- offsetX: 0,
2442
- },
2443
- },
2444
- center: {
2445
- animationOrigin: 'center center',
2446
- connectedPosition: {
2447
- originX: 'center',
2448
- originY: 'center',
2449
- overlayX: 'center',
2450
- overlayY: 'center',
2451
- offsetY: 0,
2452
- offsetX: 0,
2453
- },
2454
- },
2455
- left: {
2456
- animationOrigin: 'right center',
2457
- connectedPosition: {
2458
- originX: 'start',
2459
- originY: 'center',
2460
- overlayX: 'end',
2461
- overlayY: 'center',
2462
- offsetY: 0,
2463
- offsetX: 0,
2464
- },
2465
- },
2466
- right: {
2467
- animationOrigin: 'left center',
2468
- connectedPosition: {
2469
- originX: 'end',
2470
- originY: 'center',
2471
- overlayX: 'start',
2472
- overlayY: 'center',
2473
- offsetY: 0,
2474
- offsetX: 0,
2475
- },
2476
- },
2477
- 'right-top': {
2478
- animationOrigin: 'left bottom',
2479
- connectedPosition: {
2480
- originX: 'end',
2481
- originY: 'top',
2482
- overlayX: 'start',
2483
- overlayY: 'bottom',
2484
- offsetY: 0,
2485
- offsetX: 0,
2486
- },
2487
- },
2488
- 'right-bottom': {
2489
- animationOrigin: 'left top',
2490
- connectedPosition: {
2491
- originX: 'end',
2492
- originY: 'bottom',
2493
- overlayX: 'start',
2494
- overlayY: 'top',
2495
- offsetY: 0,
2496
- offsetX: 0,
2497
- },
2498
- },
2499
- 'left-top': {
2500
- animationOrigin: 'right bottom',
2501
- connectedPosition: {
2502
- originX: 'start',
2503
- originY: 'top',
2504
- overlayX: 'end',
2505
- overlayY: 'bottom',
2506
- offsetY: 0,
2507
- offsetX: 0,
2508
- },
2509
- },
2510
- 'left-bottom': {
2511
- animationOrigin: 'right top',
2512
- connectedPosition: {
2513
- originX: 'start',
2514
- originY: 'bottom',
2515
- overlayX: 'end',
2516
- overlayY: 'top',
2517
- offsetY: 0,
2518
- offsetX: 0,
2519
- },
2520
- },
2521
- };
2522
- /**
2523
- * Opens a tooltip (tip) component attached to a specific HTML element.
2524
- * The tooltip displays text content with customizable position and offset.
2525
- *
2526
- * @param text - The text content to display in the tooltip.
2527
- * @param attachedRef - The HTML element to which the tooltip is attached.
2528
- * @param id - A unique identifier for the tooltip instance.
2529
- * @param position - (Optional) The positioning of the tooltip relative to the attached element (default: 'top').
2549
+ class UiPopupImageDirective {
2550
+ destroyRef;
2551
+ src = '';
2552
+ width = 0;
2553
+ height = 0;
2554
+ $imageWidth = signal(0, ...(ngDevMode ? [{ debugName: "$imageWidth" }] : []));
2555
+ $imageHeight = signal(0, ...(ngDevMode ? [{ debugName: "$imageHeight" }] : []));
2556
+ $imageStyleTransform = signal('', ...(ngDevMode ? [{ debugName: "$imageStyleTransform" }] : []));
2557
+ $container = viewChild('container', ...(ngDevMode ? [{ debugName: "$container" }] : []));
2558
+ $image = viewChild('image', ...(ngDevMode ? [{ debugName: "$image" }] : []));
2559
+ $cursor = signal('auto', ...(ngDevMode ? [{ debugName: "$cursor" }] : []));
2560
+ isDragging = false;
2561
+ isTouchDragging = false;
2562
+ isPinching = false;
2563
+ lastTouchX = 0;
2564
+ lastTouchY = 0;
2565
+ lastTouchDistance = 0;
2566
+ size = { w: 0, h: 0 };
2567
+ speed = 0.5;
2568
+ pos = { x: 0, y: 0 };
2569
+ target = { x: 0, y: 0 };
2570
+ pointer = { x: 0, y: 0 };
2571
+ scale = 1;
2572
+ constructor(destroyRef) {
2573
+ this.destroyRef = destroyRef;
2574
+ }
2575
+ ngOnInit() {
2576
+ if (!isBrowser()) {
2577
+ this.$imageWidth.set(this.width);
2578
+ this.$imageHeight.set(this.height);
2579
+ return;
2580
+ }
2581
+ const result = getAspectRatioFit(window.innerWidth - window.innerWidth / 8, window.innerHeight - window.innerHeight / 8, this.width, this.height);
2582
+ this.$imageWidth.set(result.width);
2583
+ this.$imageHeight.set(result.height);
2584
+ }
2585
+ ngAfterViewInit() {
2586
+ const container = this.$container()?.nativeElement;
2587
+ if (!container)
2588
+ return;
2589
+ if (!isBrowser())
2590
+ return;
2591
+ this.size = {
2592
+ w: container.offsetWidth,
2593
+ h: container.offsetHeight,
2594
+ };
2595
+ // -----------------------------
2596
+ // KEYBOARD CURSOR LOGIC
2597
+ // -----------------------------
2598
+ fromEvent(window, 'keydown')
2599
+ .pipe(tap((event) => {
2600
+ if (event.ctrlKey)
2601
+ this.$cursor.set('zoom-in');
2602
+ }), takeUntilDestroyed(this.destroyRef))
2603
+ .subscribe();
2604
+ fromEvent(window, 'keyup')
2605
+ .pipe(tap((event) => {
2606
+ if (event.key === 'Control') {
2607
+ this.$cursor.set(this.scale > 1 ? 'grab' : 'auto');
2608
+ }
2609
+ }), takeUntilDestroyed(this.destroyRef))
2610
+ .subscribe();
2611
+ // -----------------------------
2612
+ // MOUSE DRAG
2613
+ // -----------------------------
2614
+ fromEvent(window, 'mouseup')
2615
+ .pipe(tap((event) => {
2616
+ if (event.button === 0) {
2617
+ this.isDragging = false;
2618
+ this.$cursor.set(this.scale > 1 ? 'grab' : 'auto');
2619
+ }
2620
+ }), takeUntilDestroyed(this.destroyRef))
2621
+ .subscribe();
2622
+ fromEvent(container, 'mousedown')
2623
+ .pipe(tap((event) => {
2624
+ if (event.button === 0) {
2625
+ event.preventDefault();
2626
+ this.isDragging = true;
2627
+ this.$cursor.set(this.scale > 1 ? 'grabbing' : 'auto');
2628
+ }
2629
+ }), takeUntilDestroyed(this.destroyRef))
2630
+ .subscribe();
2631
+ fromEvent(window, 'mousemove')
2632
+ .pipe(tap((e) => {
2633
+ if (this.isDragging && this.scale > 1) {
2634
+ this.pos.x += e.movementX;
2635
+ this.pos.y += e.movementY;
2636
+ this.setPosition();
2637
+ this.$imageStyleTransform.set(`translate(${this.pos.x}px,${this.pos.y}px) scale(${this.scale})`);
2638
+ }
2639
+ }), takeUntilDestroyed(this.destroyRef))
2640
+ .subscribe();
2641
+ // -----------------------------
2642
+ // MOUSE WHEEL ZOOM
2643
+ // -----------------------------
2644
+ fromEvent(window, 'wheel', { passive: false })
2645
+ .pipe(tap((event) => {
2646
+ event.preventDefault();
2647
+ const rect = container.getBoundingClientRect();
2648
+ if (event.ctrlKey) {
2649
+ this.pointer.x = event.clientX - rect.left;
2650
+ this.pointer.y = event.clientY - rect.top;
2651
+ this.target.x = (this.pointer.x - this.pos.x) / this.scale;
2652
+ this.target.y = (this.pointer.y - this.pos.y) / this.scale;
2653
+ this.scale += -1 * Math.max(-1, Math.min(1, event.deltaY)) * this.speed * this.scale;
2654
+ const maxScale = 4;
2655
+ const minScale = 1;
2656
+ this.scale = Math.max(minScale, Math.min(maxScale, this.scale));
2657
+ this.pos.x = -this.target.x * this.scale + this.pointer.x;
2658
+ this.pos.y = -this.target.y * this.scale + this.pointer.y;
2659
+ this.setPosition();
2660
+ this.$imageStyleTransform.set(`translate(${this.pos.x}px,${this.pos.y}px) scale(${this.scale})`);
2661
+ }
2662
+ else {
2663
+ this.pos.x -= event.deltaX * 2;
2664
+ this.pos.y -= event.deltaY * 2;
2665
+ }
2666
+ }), takeUntilDestroyed(this.destroyRef))
2667
+ .subscribe();
2668
+ // -----------------------------
2669
+ // TOUCH PINCH ZOOM
2670
+ // -----------------------------
2671
+ fromEvent(container, 'touchstart')
2672
+ .pipe(tap((event) => {
2673
+ if (event.touches.length === 2) {
2674
+ this.isPinching = true;
2675
+ const [t1, t2] = event.touches;
2676
+ this.lastTouchDistance = Math.hypot(t2.clientX - t1.clientX, t2.clientY - t1.clientY);
2677
+ }
2678
+ if (event.touches.length === 1 && this.scale > 1) {
2679
+ const t = event.touches[0];
2680
+ this.lastTouchX = t.clientX;
2681
+ this.lastTouchY = t.clientY;
2682
+ this.isTouchDragging = true;
2683
+ this.$cursor.set('grabbing');
2684
+ }
2685
+ }), takeUntilDestroyed(this.destroyRef))
2686
+ .subscribe();
2687
+ fromEvent(container, 'touchmove')
2688
+ .pipe(tap((event) => {
2689
+ if (this.isPinching && event.touches.length === 2) {
2690
+ event.preventDefault();
2691
+ const [t1, t2] = event.touches;
2692
+ const newDistance = Math.hypot(t2.clientX - t1.clientX, t2.clientY - t1.clientY);
2693
+ const delta = newDistance - this.lastTouchDistance;
2694
+ this.lastTouchDistance = newDistance;
2695
+ const rect = container.getBoundingClientRect();
2696
+ const centerX = (t1.clientX + t2.clientX) / 2 - rect.left;
2697
+ const centerY = (t1.clientY + t2.clientY) / 2 - rect.top;
2698
+ this.pointer.x = centerX;
2699
+ this.pointer.y = centerY;
2700
+ this.target.x = (this.pointer.x - this.pos.x) / this.scale;
2701
+ this.target.y = (this.pointer.y - this.pos.y) / this.scale;
2702
+ const pinchSpeed = 0.005;
2703
+ this.scale += delta * pinchSpeed * this.scale;
2704
+ const maxScale = 4;
2705
+ const minScale = 1;
2706
+ this.scale = Math.max(minScale, Math.min(maxScale, this.scale));
2707
+ this.pos.x = -this.target.x * this.scale + this.pointer.x;
2708
+ this.pos.y = -this.target.y * this.scale + this.pointer.y;
2709
+ this.setPosition();
2710
+ this.$imageStyleTransform.set(`translate(${this.pos.x}px,${this.pos.y}px) scale(${this.scale})`);
2711
+ }
2712
+ if (this.isTouchDragging && event.touches.length === 1) {
2713
+ event.preventDefault();
2714
+ const t = event.touches[0];
2715
+ const dx = t.clientX - this.lastTouchX;
2716
+ const dy = t.clientY - this.lastTouchY;
2717
+ this.lastTouchX = t.clientX;
2718
+ this.lastTouchY = t.clientY;
2719
+ this.pos.x += dx;
2720
+ this.pos.y += dy;
2721
+ this.setPosition();
2722
+ this.$imageStyleTransform.set(`translate(${this.pos.x}px,${this.pos.y}px) scale(${this.scale})`);
2723
+ }
2724
+ }), takeUntilDestroyed(this.destroyRef))
2725
+ .subscribe();
2726
+ fromEvent(container, 'touchend')
2727
+ .pipe(tap(() => {
2728
+ this.isPinching = false;
2729
+ this.isTouchDragging = false;
2730
+ this.$cursor.set(this.scale > 1 ? 'grab' : 'auto');
2731
+ }), takeUntilDestroyed(this.destroyRef))
2732
+ .subscribe();
2733
+ }
2734
+ setPosition() {
2735
+ if (this.pos.x > 0)
2736
+ this.pos.x = 0;
2737
+ if (this.pos.x + this.size.w * this.scale < this.size.w) {
2738
+ this.pos.x = -this.size.w * (this.scale - 1);
2739
+ }
2740
+ if (this.pos.y > 0)
2741
+ this.pos.y = 0;
2742
+ if (this.pos.y + this.size.h * this.scale < this.size.h) {
2743
+ this.pos.y = -this.size.h * (this.scale - 1);
2744
+ }
2745
+ }
2746
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiPopupImageDirective, deps: [{ token: i0.DestroyRef }], target: i0.ɵɵFactoryTarget.Directive });
2747
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.1.1", type: UiPopupImageDirective, isStandalone: true, selector: "app-ui-popup-image", inputs: { src: "src", width: "width", height: "height" }, viewQueries: [{ propertyName: "$container", first: true, predicate: ["container"], descendants: true, isSignal: true }, { propertyName: "$image", first: true, predicate: ["image"], descendants: true, isSignal: true }], ngImport: i0 });
2748
+ }
2749
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiPopupImageDirective, decorators: [{
2750
+ type: Directive,
2751
+ args: [{
2752
+ selector: 'app-ui-popup-image',
2753
+ }]
2754
+ }], ctorParameters: () => [{ type: i0.DestroyRef }], propDecorators: { src: [{
2755
+ type: Input,
2756
+ args: [{ required: true }]
2757
+ }], width: [{
2758
+ type: Input,
2759
+ args: [{ required: true }]
2760
+ }], height: [{
2761
+ type: Input,
2762
+ args: [{ required: true }]
2763
+ }], $container: [{ type: i0.ViewChild, args: ['container', { isSignal: true }] }], $image: [{ type: i0.ViewChild, args: ['image', { isSignal: true }] }] } });
2764
+
2765
+ class UiPopupBackdropService {
2766
+ tipContainerPortal;
2767
+ backdropPortal;
2768
+ constructor(component, tipComponent) {
2769
+ this.backdropPortal = new ComponentPortal(component);
2770
+ if (tipComponent) {
2771
+ this.tipContainerPortal = new ComponentPortal(tipComponent);
2772
+ }
2773
+ }
2774
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiPopupBackdropService, deps: [{ token: i0.Type }, { token: i0.Type }], target: i0.ɵɵFactoryTarget.Injectable });
2775
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiPopupBackdropService, providedIn: 'root' });
2776
+ }
2777
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiPopupBackdropService, decorators: [{
2778
+ type: Injectable,
2779
+ args: [{
2780
+ providedIn: 'root',
2781
+ }]
2782
+ }], ctorParameters: () => [{ type: i0.Type }, { type: i0.Type }] });
2783
+
2784
+ class UiPopupService extends UiModal {
2785
+ defaultAnimationOptions = {
2786
+ startOrigin: '',
2787
+ endOrigin: '',
2788
+ start: '',
2789
+ end: '',
2790
+ leftStart: '',
2791
+ leftEnd: '',
2792
+ topStart: '',
2793
+ topEnd: '',
2794
+ };
2795
+ constructor(overlay, injector, destroyRef, router, backdropService) {
2796
+ super(overlay, injector, destroyRef, router, backdropService);
2797
+ }
2798
+ /**
2799
+ * Opens a popup with the specified component and options.
2800
+ *
2801
+ * @param component - The component to be displayed in the popup.
2802
+ * @param options - Configuration options for the popup, including inputs.
2803
+ * @param id - A unique identifier for the popup instance.
2804
+ * @param parameters - (Optional) Configuration options for the popup.
2805
+ */
2806
+ open(component, options, id, parameters) {
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
+ };
2819
+ }
2820
+ this.showBackdrop(parameters.isStaticBackdrop);
2821
+ const overlayRef = this.overlay.create({
2822
+ hasBackdrop: false,
2823
+ backdropClass: 'cdk-overlay-transparent-backdrop',
2824
+ positionStrategy: this.overlay.position().global().centerHorizontally().centerVertically(),
2825
+ });
2826
+ this.subscribeToOutsideEvents();
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
+ }
2860
+ }
2861
+ closePrevious(isClosePrevious) {
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);
2876
+ }
2877
+ }
2878
+ /**
2879
+ * Opens a popup that scales from the provided origin element to the centered popup size.
2880
+ * Useful for image-preview transitions where the source element animates into the popup.
2881
+ */
2882
+ openScaledFromElement(component, options, id, originElement, sourceWidth, sourceHeight, parameters = {}) {
2883
+ const animationOptions = this.createScaleAnimationOptionsFromElement(originElement, sourceWidth, sourceHeight);
2884
+ this.open(component, options, id, {
2885
+ ...parameters,
2886
+ animationOptions,
2887
+ });
2888
+ }
2889
+ createScaleAnimationOptionsFromElement(originElement, sourceWidth, sourceHeight) {
2890
+ const rect = originElement.getBoundingClientRect();
2891
+ const viewportWidth = isBrowser() ? window.innerWidth : sourceWidth;
2892
+ const viewportHeight = isBrowser() ? window.innerHeight : sourceHeight;
2893
+ const centerX = viewportWidth / 2;
2894
+ const centerY = viewportHeight / 2;
2895
+ const targetX = rect.left + rect.width / 2;
2896
+ const targetY = rect.top + rect.height / 2;
2897
+ const offsetX = targetX - centerX;
2898
+ const offsetY = targetY - centerY;
2899
+ const fitted = getAspectRatioFit(viewportWidth - viewportWidth / 8, viewportHeight - viewportHeight / 8, sourceWidth, sourceHeight);
2900
+ const scaleY = Math.trunc((sourceHeight / fitted.height) * 100) / 100;
2901
+ const scaleX = Math.trunc((sourceWidth / fitted.width) * 100) / 100;
2902
+ return {
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',
2911
+ };
2912
+ }
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 });
2914
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiPopupService, providedIn: 'root' });
2915
+ }
2916
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiPopupService, decorators: [{
2917
+ type: Injectable,
2918
+ args: [{
2919
+ providedIn: 'root',
2920
+ }]
2921
+ }], ctorParameters: () => [{ type: i1.Overlay }, { type: i0.Injector }, { type: i0.DestroyRef }, { type: i2$1.Router }, { type: UiPopupBackdropService }] });
2922
+
2923
+ class UiPopupBackdropDirective {
2924
+ elementRef;
2925
+ uiPopupService;
2926
+ destroyRef;
2927
+ isStaticBackdrop = false;
2928
+ clicked = () => { };
2929
+ constructor(elementRef, uiPopupService, destroyRef) {
2930
+ this.elementRef = elementRef;
2931
+ this.uiPopupService = uiPopupService;
2932
+ this.destroyRef = destroyRef;
2933
+ }
2934
+ ngOnInit() {
2935
+ fromEvent(this.elementRef.nativeElement, 'click')
2936
+ .pipe(tap(() => {
2937
+ if (this.isStaticBackdrop) {
2938
+ this.clicked();
2939
+ return;
2940
+ }
2941
+ this.uiPopupService.closeAll();
2942
+ }), takeUntilDestroyed(this.destroyRef))
2943
+ .subscribe();
2944
+ }
2945
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiPopupBackdropDirective, deps: [{ token: i0.ElementRef }, { token: UiPopupService }, { token: i0.DestroyRef }], target: i0.ɵɵFactoryTarget.Directive });
2946
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.1.1", type: UiPopupBackdropDirective, isStandalone: true, selector: "app-ui-popup-backdrop", inputs: { isStaticBackdrop: "isStaticBackdrop", clicked: "clicked" }, ngImport: i0 });
2947
+ }
2948
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiPopupBackdropDirective, decorators: [{
2949
+ type: Directive,
2950
+ args: [{ selector: 'app-ui-popup-backdrop' }]
2951
+ }], ctorParameters: () => [{ type: i0.ElementRef }, { type: UiPopupService }, { type: i0.DestroyRef }], propDecorators: { isStaticBackdrop: [{
2952
+ type: Input
2953
+ }], clicked: [{
2954
+ type: Input
2955
+ }] } });
2956
+
2957
+ class UiDropdownService extends UiModal {
2958
+ containerSize$ = new BehaviorSubject({
2959
+ width: 0,
2960
+ height: 0,
2961
+ });
2962
+ connectedPositions = {
2963
+ bottom: {
2964
+ animationOrigin: 'top center',
2965
+ connectedPosition: {
2966
+ originX: 'center',
2967
+ originY: 'bottom',
2968
+ overlayX: 'center',
2969
+ overlayY: 'top',
2970
+ offsetY: 0,
2971
+ offsetX: 0,
2972
+ },
2973
+ },
2974
+ top: {
2975
+ animationOrigin: 'bottom center',
2976
+ connectedPosition: {
2977
+ originX: 'center',
2978
+ originY: 'top',
2979
+ overlayX: 'center',
2980
+ overlayY: 'bottom',
2981
+ offsetY: 0,
2982
+ offsetX: 0,
2983
+ },
2984
+ },
2985
+ center: {
2986
+ animationOrigin: 'center center',
2987
+ connectedPosition: {
2988
+ originX: 'center',
2989
+ originY: 'center',
2990
+ overlayX: 'center',
2991
+ overlayY: 'center',
2992
+ offsetY: 0,
2993
+ offsetX: 0,
2994
+ },
2995
+ },
2996
+ left: {
2997
+ animationOrigin: 'right center',
2998
+ connectedPosition: {
2999
+ originX: 'start',
3000
+ originY: 'center',
3001
+ overlayX: 'end',
3002
+ overlayY: 'center',
3003
+ offsetY: 0,
3004
+ offsetX: 0,
3005
+ },
3006
+ },
3007
+ right: {
3008
+ animationOrigin: 'left center',
3009
+ connectedPosition: {
3010
+ originX: 'end',
3011
+ originY: 'center',
3012
+ overlayX: 'start',
3013
+ overlayY: 'center',
3014
+ offsetY: 0,
3015
+ offsetX: 0,
3016
+ },
3017
+ },
3018
+ 'right-top': {
3019
+ animationOrigin: 'left bottom',
3020
+ connectedPosition: {
3021
+ originX: 'end',
3022
+ originY: 'top',
3023
+ overlayX: 'start',
3024
+ overlayY: 'bottom',
3025
+ offsetY: 0,
3026
+ offsetX: 0,
3027
+ },
3028
+ },
3029
+ 'right-bottom': {
3030
+ animationOrigin: 'left top',
3031
+ connectedPosition: {
3032
+ originX: 'end',
3033
+ originY: 'bottom',
3034
+ overlayX: 'start',
3035
+ overlayY: 'top',
3036
+ offsetY: 0,
3037
+ offsetX: 0,
3038
+ },
3039
+ },
3040
+ 'left-top': {
3041
+ animationOrigin: 'right bottom',
3042
+ connectedPosition: {
3043
+ originX: 'start',
3044
+ originY: 'top',
3045
+ overlayX: 'end',
3046
+ overlayY: 'bottom',
3047
+ offsetY: 0,
3048
+ offsetX: 0,
3049
+ },
3050
+ },
3051
+ 'left-bottom': {
3052
+ animationOrigin: 'right top',
3053
+ connectedPosition: {
3054
+ originX: 'start',
3055
+ originY: 'bottom',
3056
+ overlayX: 'end',
3057
+ overlayY: 'top',
3058
+ offsetY: 0,
3059
+ offsetX: 0,
3060
+ },
3061
+ },
3062
+ };
3063
+ constructor(overlay, injector, destroyRef, router, backdropService) {
3064
+ super(overlay, injector, destroyRef, router, backdropService);
3065
+ }
3066
+ /**
3067
+ * Opens a tooltip (tip) component attached to a specific HTML element.
3068
+ * The tooltip displays text content with customizable position and offset.
3069
+ *
3070
+ * @param text - The text content to display in the tooltip.
3071
+ * @param attachedRef - The HTML element to which the tooltip is attached.
3072
+ * @param id - A unique identifier for the tooltip instance.
3073
+ * @param position - (Optional) The positioning of the tooltip relative to the attached element (default: 'top').
2530
3074
  * Available positions: 'top', 'bottom', 'left', 'right', 'center',
2531
3075
  * 'left-top', 'left-bottom', 'right-top', 'right-bottom'.
2532
3076
  * @param offsetY - (Optional) Vertical offset for tooltip positioning in pixels (default: 0).
@@ -2569,10 +3113,10 @@ class UiDropdownService extends UiPopupService {
2569
3113
  if (fetchedParameters.hasAttachedWidth) {
2570
3114
  attachedWidth = attachedRef.clientWidth;
2571
3115
  }
2572
- if (fetchedParameters.removePrevious && this.popupInstances.length) {
3116
+ if (fetchedParameters.removePrevious && this.instances.length) {
2573
3117
  this.destroyOutsideClickSubscription$.next();
2574
3118
  }
2575
- if (fetchedParameters.removePrevious && this.popupInstances.length) {
3119
+ if (fetchedParameters.removePrevious && this.instances.length) {
2576
3120
  this.close();
2577
3121
  }
2578
3122
  if (isBrowser() && window.matchMedia('(max-width: 48rem)').matches) {
@@ -2587,7 +3131,7 @@ class UiDropdownService extends UiPopupService {
2587
3131
  this.subscribeToOutsideEvents(overlayRef);
2588
3132
  }
2589
3133
  this.createPopup(overlayRef, component, fetchedParameters.options ?? {}, id, { width: attachedWidth });
2590
- this.popupInstances[this.popupInstances.length - 1].animationOrigin$.next(this.connectedPositions[parameters.position ?? 'bottom'].animationOrigin);
3134
+ this.instances[this.instances.length - 1].animationOrigin$.next(this.connectedPositions[parameters.position ?? 'bottom'].animationOrigin);
2591
3135
  }
2592
3136
  /**
2593
3137
  * Opens a dropdown from the mouse position with intelligent border detection.
@@ -2601,10 +3145,10 @@ class UiDropdownService extends UiPopupService {
2601
3145
  */
2602
3146
  openAtMousePosition(component, event, id, parameters = {}) {
2603
3147
  const fetchedParameters = this.fetchDropDownParameters(parameters);
2604
- if (fetchedParameters.removePrevious && this.popupInstances.length) {
3148
+ if (fetchedParameters.removePrevious && this.instances.length) {
2605
3149
  this.destroyOutsideClickSubscription$.next();
2606
3150
  }
2607
- if (fetchedParameters.removePrevious && this.popupInstances.length) {
3151
+ if (fetchedParameters.removePrevious && this.instances.length) {
2608
3152
  this.close();
2609
3153
  }
2610
3154
  if (isBrowser() && window.matchMedia('(max-width: 48rem)').matches) {
@@ -2620,10 +3164,14 @@ class UiDropdownService extends UiPopupService {
2620
3164
  }
2621
3165
  this.createPopup(overlayRef, component, fetchedParameters.options ?? {}, id, {
2622
3166
  animationOptions: {
2623
- positionX: 0,
2624
- positionY: 0,
2625
- startTransition: 'scale(0.4)',
2626
- endTransition: 'scale(1)',
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',
2627
3175
  },
2628
3176
  });
2629
3177
  this.containerSize$
@@ -2633,13 +3181,13 @@ class UiDropdownService extends UiPopupService {
2633
3181
  }
2634
3182
  const animationOrigin = this.calculateMousePositionAnimationOrigin(event, size);
2635
3183
  const positionAdjustment = this.calculateMousePositionAdjustment(event, size);
2636
- this.popupInstances[this.popupInstances.length - 1].animationOrigin$.next(animationOrigin);
3184
+ this.instances[this.instances.length - 1].animationOrigin$.next(animationOrigin);
2637
3185
  const positionStrategy = overlayRef.getConfig().positionStrategy;
2638
3186
  if (positionStrategy instanceof FlexibleConnectedPositionStrategy && positionAdjustment) {
2639
3187
  positionStrategy.setOrigin({ x: positionAdjustment.left, y: positionAdjustment.top });
2640
3188
  overlayRef.updatePosition();
2641
3189
  }
2642
- }), takeUntil(this.destroyOutsideClickSubscription$))
3190
+ }), takeUntil$1(this.destroyOutsideClickSubscription$))
2643
3191
  .subscribe();
2644
3192
  }
2645
3193
  /**
@@ -2726,7 +3274,7 @@ class UiDropdownService extends UiPopupService {
2726
3274
  timer(150)
2727
3275
  .pipe(switchMap(() => overlayRef.outsidePointerEvents()), tap(() => {
2728
3276
  this.closeAll();
2729
- }), takeUntil(this.destroyOutsideClickSubscription$))
3277
+ }), takeUntil$1(this.destroyOutsideClickSubscription$))
2730
3278
  .subscribe();
2731
3279
  }
2732
3280
  /**
@@ -2768,7 +3316,7 @@ class UiDropdownService extends UiPopupService {
2768
3316
  },
2769
3317
  ]);
2770
3318
  }
2771
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiDropdownService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
3319
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiDropdownService, deps: [{ token: i1.Overlay }, { token: i0.Injector }, { token: i0.DestroyRef }, { token: i2$1.Router }, { token: UiPopupBackdropService }], target: i0.ɵɵFactoryTarget.Injectable });
2772
3320
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiDropdownService, providedIn: 'root' });
2773
3321
  }
2774
3322
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiDropdownService, decorators: [{
@@ -2776,7 +3324,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
2776
3324
  args: [{
2777
3325
  providedIn: 'root',
2778
3326
  }]
2779
- }] });
3327
+ }], ctorParameters: () => [{ type: i1.Overlay }, { type: i0.Injector }, { type: i0.DestroyRef }, { type: i2$1.Router }, { type: UiPopupBackdropService }] });
2780
3328
 
2781
3329
  class UiDropdownContainerDirective extends UiPopupContainerDirective {
2782
3330
  dropDownService;
@@ -3005,252 +3553,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
3005
3553
  }]
3006
3554
  }], propDecorators: { $hasNext: [{ type: i0.Input, args: [{ isSignal: true, alias: "$hasNext", required: true }] }], $hasPrevious: [{ type: i0.Input, args: [{ isSignal: true, alias: "$hasPrevious", required: true }] }], $nextClicked: [{ type: i0.Output, args: ["$nextClicked"] }], $previousClicked: [{ type: i0.Output, args: ["$previousClicked"] }] } });
3007
3555
 
3008
- class UiPopupImageDirective {
3009
- destroyRef;
3010
- src = '';
3011
- width = 0;
3012
- height = 0;
3013
- $imageWidth = signal(0, ...(ngDevMode ? [{ debugName: "$imageWidth" }] : []));
3014
- $imageHeight = signal(0, ...(ngDevMode ? [{ debugName: "$imageHeight" }] : []));
3015
- $imageStyleTransform = signal('', ...(ngDevMode ? [{ debugName: "$imageStyleTransform" }] : []));
3016
- $container = viewChild('container', ...(ngDevMode ? [{ debugName: "$container" }] : []));
3017
- $image = viewChild('image', ...(ngDevMode ? [{ debugName: "$image" }] : []));
3018
- $cursor = signal('auto', ...(ngDevMode ? [{ debugName: "$cursor" }] : []));
3019
- isDragging = false;
3020
- isTouchDragging = false;
3021
- isPinching = false;
3022
- lastTouchX = 0;
3023
- lastTouchY = 0;
3024
- lastTouchDistance = 0;
3025
- size = { w: 0, h: 0 };
3026
- speed = 0.5;
3027
- pos = { x: 0, y: 0 };
3028
- target = { x: 0, y: 0 };
3029
- pointer = { x: 0, y: 0 };
3030
- scale = 1;
3031
- constructor(destroyRef) {
3032
- this.destroyRef = destroyRef;
3033
- }
3034
- ngOnInit() {
3035
- if (!isBrowser()) {
3036
- this.$imageWidth.set(this.width);
3037
- this.$imageHeight.set(this.height);
3038
- return;
3039
- }
3040
- const result = getAspectRatioFit(window.innerWidth - window.innerWidth / 8, window.innerHeight - window.innerHeight / 8, this.width, this.height);
3041
- this.$imageWidth.set(result.width);
3042
- this.$imageHeight.set(result.height);
3043
- }
3044
- ngAfterViewInit() {
3045
- const container = this.$container()?.nativeElement;
3046
- if (!container)
3047
- return;
3048
- if (!isBrowser())
3049
- return;
3050
- this.size = {
3051
- w: container.offsetWidth,
3052
- h: container.offsetHeight,
3053
- };
3054
- // -----------------------------
3055
- // KEYBOARD CURSOR LOGIC
3056
- // -----------------------------
3057
- fromEvent(window, 'keydown')
3058
- .pipe(tap((event) => {
3059
- if (event.ctrlKey)
3060
- this.$cursor.set('zoom-in');
3061
- }), takeUntilDestroyed(this.destroyRef))
3062
- .subscribe();
3063
- fromEvent(window, 'keyup')
3064
- .pipe(tap((event) => {
3065
- if (event.key === 'Control') {
3066
- this.$cursor.set(this.scale > 1 ? 'grab' : 'auto');
3067
- }
3068
- }), takeUntilDestroyed(this.destroyRef))
3069
- .subscribe();
3070
- // -----------------------------
3071
- // MOUSE DRAG
3072
- // -----------------------------
3073
- fromEvent(window, 'mouseup')
3074
- .pipe(tap((event) => {
3075
- if (event.button === 0) {
3076
- this.isDragging = false;
3077
- this.$cursor.set(this.scale > 1 ? 'grab' : 'auto');
3078
- }
3079
- }), takeUntilDestroyed(this.destroyRef))
3080
- .subscribe();
3081
- fromEvent(container, 'mousedown')
3082
- .pipe(tap((event) => {
3083
- if (event.button === 0) {
3084
- event.preventDefault();
3085
- this.isDragging = true;
3086
- this.$cursor.set(this.scale > 1 ? 'grabbing' : 'auto');
3087
- }
3088
- }), takeUntilDestroyed(this.destroyRef))
3089
- .subscribe();
3090
- fromEvent(window, 'mousemove')
3091
- .pipe(tap((e) => {
3092
- if (this.isDragging && this.scale > 1) {
3093
- this.pos.x += e.movementX;
3094
- this.pos.y += e.movementY;
3095
- this.setPosition();
3096
- this.$imageStyleTransform.set(`translate(${this.pos.x}px,${this.pos.y}px) scale(${this.scale})`);
3097
- }
3098
- }), takeUntilDestroyed(this.destroyRef))
3099
- .subscribe();
3100
- // -----------------------------
3101
- // MOUSE WHEEL ZOOM
3102
- // -----------------------------
3103
- fromEvent(window, 'wheel', { passive: false })
3104
- .pipe(tap((event) => {
3105
- event.preventDefault();
3106
- const rect = container.getBoundingClientRect();
3107
- if (event.ctrlKey) {
3108
- this.pointer.x = event.clientX - rect.left;
3109
- this.pointer.y = event.clientY - rect.top;
3110
- this.target.x = (this.pointer.x - this.pos.x) / this.scale;
3111
- this.target.y = (this.pointer.y - this.pos.y) / this.scale;
3112
- this.scale += -1 * Math.max(-1, Math.min(1, event.deltaY)) * this.speed * this.scale;
3113
- const maxScale = 4;
3114
- const minScale = 1;
3115
- this.scale = Math.max(minScale, Math.min(maxScale, this.scale));
3116
- this.pos.x = -this.target.x * this.scale + this.pointer.x;
3117
- this.pos.y = -this.target.y * this.scale + this.pointer.y;
3118
- this.setPosition();
3119
- this.$imageStyleTransform.set(`translate(${this.pos.x}px,${this.pos.y}px) scale(${this.scale})`);
3120
- }
3121
- else {
3122
- this.pos.x -= event.deltaX * 2;
3123
- this.pos.y -= event.deltaY * 2;
3124
- }
3125
- }), takeUntilDestroyed(this.destroyRef))
3126
- .subscribe();
3127
- // -----------------------------
3128
- // TOUCH PINCH ZOOM
3129
- // -----------------------------
3130
- fromEvent(container, 'touchstart')
3131
- .pipe(tap((event) => {
3132
- if (event.touches.length === 2) {
3133
- this.isPinching = true;
3134
- const [t1, t2] = event.touches;
3135
- this.lastTouchDistance = Math.hypot(t2.clientX - t1.clientX, t2.clientY - t1.clientY);
3136
- }
3137
- if (event.touches.length === 1 && this.scale > 1) {
3138
- const t = event.touches[0];
3139
- this.lastTouchX = t.clientX;
3140
- this.lastTouchY = t.clientY;
3141
- this.isTouchDragging = true;
3142
- this.$cursor.set('grabbing');
3143
- }
3144
- }), takeUntilDestroyed(this.destroyRef))
3145
- .subscribe();
3146
- fromEvent(container, 'touchmove')
3147
- .pipe(tap((event) => {
3148
- if (this.isPinching && event.touches.length === 2) {
3149
- event.preventDefault();
3150
- const [t1, t2] = event.touches;
3151
- const newDistance = Math.hypot(t2.clientX - t1.clientX, t2.clientY - t1.clientY);
3152
- const delta = newDistance - this.lastTouchDistance;
3153
- this.lastTouchDistance = newDistance;
3154
- const rect = container.getBoundingClientRect();
3155
- const centerX = (t1.clientX + t2.clientX) / 2 - rect.left;
3156
- const centerY = (t1.clientY + t2.clientY) / 2 - rect.top;
3157
- this.pointer.x = centerX;
3158
- this.pointer.y = centerY;
3159
- this.target.x = (this.pointer.x - this.pos.x) / this.scale;
3160
- this.target.y = (this.pointer.y - this.pos.y) / this.scale;
3161
- const pinchSpeed = 0.005;
3162
- this.scale += delta * pinchSpeed * this.scale;
3163
- const maxScale = 4;
3164
- const minScale = 1;
3165
- this.scale = Math.max(minScale, Math.min(maxScale, this.scale));
3166
- this.pos.x = -this.target.x * this.scale + this.pointer.x;
3167
- this.pos.y = -this.target.y * this.scale + this.pointer.y;
3168
- this.setPosition();
3169
- this.$imageStyleTransform.set(`translate(${this.pos.x}px,${this.pos.y}px) scale(${this.scale})`);
3170
- }
3171
- if (this.isTouchDragging && event.touches.length === 1) {
3172
- event.preventDefault();
3173
- const t = event.touches[0];
3174
- const dx = t.clientX - this.lastTouchX;
3175
- const dy = t.clientY - this.lastTouchY;
3176
- this.lastTouchX = t.clientX;
3177
- this.lastTouchY = t.clientY;
3178
- this.pos.x += dx;
3179
- this.pos.y += dy;
3180
- this.setPosition();
3181
- this.$imageStyleTransform.set(`translate(${this.pos.x}px,${this.pos.y}px) scale(${this.scale})`);
3182
- }
3183
- }), takeUntilDestroyed(this.destroyRef))
3184
- .subscribe();
3185
- fromEvent(container, 'touchend')
3186
- .pipe(tap(() => {
3187
- this.isPinching = false;
3188
- this.isTouchDragging = false;
3189
- this.$cursor.set(this.scale > 1 ? 'grab' : 'auto');
3190
- }), takeUntilDestroyed(this.destroyRef))
3191
- .subscribe();
3192
- }
3193
- setPosition() {
3194
- if (this.pos.x > 0)
3195
- this.pos.x = 0;
3196
- if (this.pos.x + this.size.w * this.scale < this.size.w) {
3197
- this.pos.x = -this.size.w * (this.scale - 1);
3198
- }
3199
- if (this.pos.y > 0)
3200
- this.pos.y = 0;
3201
- if (this.pos.y + this.size.h * this.scale < this.size.h) {
3202
- this.pos.y = -this.size.h * (this.scale - 1);
3203
- }
3204
- }
3205
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiPopupImageDirective, deps: [{ token: i0.DestroyRef }], target: i0.ɵɵFactoryTarget.Directive });
3206
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.1.1", type: UiPopupImageDirective, isStandalone: true, selector: "app-ui-popup-image", inputs: { src: "src", width: "width", height: "height" }, viewQueries: [{ propertyName: "$container", first: true, predicate: ["container"], descendants: true, isSignal: true }, { propertyName: "$image", first: true, predicate: ["image"], descendants: true, isSignal: true }], ngImport: i0 });
3207
- }
3208
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiPopupImageDirective, decorators: [{
3209
- type: Directive,
3210
- args: [{
3211
- selector: 'app-ui-popup-image',
3212
- }]
3213
- }], ctorParameters: () => [{ type: i0.DestroyRef }], propDecorators: { src: [{
3214
- type: Input,
3215
- args: [{ required: true }]
3216
- }], width: [{
3217
- type: Input,
3218
- args: [{ required: true }]
3219
- }], height: [{
3220
- type: Input,
3221
- args: [{ required: true }]
3222
- }], $container: [{ type: i0.ViewChild, args: ['container', { isSignal: true }] }], $image: [{ type: i0.ViewChild, args: ['image', { isSignal: true }] }] } });
3223
-
3224
- class UiPopupBackdropDirective {
3225
- elementRef;
3226
- uiPopupService;
3227
- destroyRef;
3228
- isStaticBackdrop = false;
3229
- constructor(elementRef, uiPopupService, destroyRef) {
3230
- this.elementRef = elementRef;
3231
- this.uiPopupService = uiPopupService;
3232
- this.destroyRef = destroyRef;
3233
- }
3234
- ngOnInit() {
3235
- fromEvent(this.elementRef.nativeElement, 'click')
3236
- .pipe(tap(() => {
3237
- if (this.isStaticBackdrop) {
3238
- return;
3239
- }
3240
- this.uiPopupService.closeAll();
3241
- }), takeUntilDestroyed(this.destroyRef))
3242
- .subscribe();
3243
- }
3244
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiPopupBackdropDirective, deps: [{ token: i0.ElementRef }, { token: UiPopupService }, { token: i0.DestroyRef }], target: i0.ɵɵFactoryTarget.Directive });
3245
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.1.1", type: UiPopupBackdropDirective, isStandalone: true, selector: "app-ui-popup-backdrop", inputs: { isStaticBackdrop: "isStaticBackdrop" }, ngImport: i0 });
3246
- }
3247
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiPopupBackdropDirective, decorators: [{
3248
- type: Directive,
3249
- args: [{ selector: 'app-ui-popup-backdrop' }]
3250
- }], ctorParameters: () => [{ type: i0.ElementRef }, { type: UiPopupService }, { type: i0.DestroyRef }], propDecorators: { isStaticBackdrop: [{
3251
- type: Input
3252
- }] } });
3253
-
3254
3556
  const buttonColors = [
3255
3557
  'primary',
3256
3558
  'secondary',
@@ -3425,7 +3727,7 @@ class UiCopyButtonDirective {
3425
3727
  timer(5000)
3426
3728
  .pipe(tap(() => {
3427
3729
  this.$isCopied.set(false);
3428
- }), takeUntil(this.destroyTimer$), takeUntilDestroyed(this.destroyRef))
3730
+ }), takeUntil$1(this.destroyTimer$), takeUntilDestroyed(this.destroyRef))
3429
3731
  .subscribe();
3430
3732
  })
3431
3733
  .catch((err) => {
@@ -4370,5 +4672,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
4370
4672
  * Generated bundle index. Do not edit.
4371
4673
  */
4372
4674
 
4373
- export { Alert, AlertType, AppIconsLibrary, CalendarUtils, CenterEllipsisPipe, ContainerSizeDirective, CountryService, DateUtils, EMAIL, FocusDirective, 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, UiAlertMessagesOverlayService, UiAlertMessagesService, UiAvatarDirective, UiButtonDirective, UiCalendarDropdownDirective, UiCodeDirective, UiCopyButtonDirective, UiDailyCalendarDirective, UiDropdownContainerDirective, UiDropdownService, UiFieldBaseDirective, UiImageDirective, UiInputCheckboxDirective, UiInputCountryDirective, UiInputDirective, UiInputSelectDirective, UiInputSequenceDirective, UiInputTimeDirective, UiMonthlyCalendarDirective, UiPaginationDirective, UiPopupBackdropDirective, UiPopupBackdropService, UiPopupContainerDirective, UiPopupImageDirective, UiPopupInstance, UiPopupService, UiSelectButtonsDirective, UiTabsDirective, UiTimeDropdownDirective, UiValidationErrorsDirective, UiYearlyCalendarDirective, createNavigation, createUrl, createUrlTree, emptyCountry, extractParam, getAspectRatioFit, isBrowser, navigateByUrl, stringToColorGradient, stringToHslColor };
4675
+ export { Alert, AlertType, AppIconsLibrary, CalendarUtils, CenterEllipsisPipe, ContainerSizeDirective, CountryService, DateUtils, EMAIL, FocusDirective, HAS_CAPITAL_CASE, HAS_NUMBER, HAS_SMALL_CASE, HAS_SPECIAL_CHARTERS, HoverTipDirective, IconComponent, LazyImgDirective, MIN_LENGTH, MaskGradientDirective, RouterBehavior, SkeletonDirective, StableScrollDirective, StickyObserverDirective, ThemeService, TrackLifecycleDirective, UIInputDateDirective, UIPhoneNumberDirective, UiAccordionComponent, UiAlertMessagesOverlayService, UiAlertMessagesService, UiAvatarDirective, UiButtonDirective, UiCalendarDropdownDirective, UiCodeDirective, UiCopyButtonDirective, UiDailyCalendarDirective, UiDropdownContainerDirective, UiDropdownService, UiFieldBaseDirective, UiImageDirective, UiInputCheckboxDirective, UiInputCountryDirective, UiInputDirective, UiInputSelectDirective, UiInputSequenceDirective, UiInputTimeDirective, UiMonthlyCalendarDirective, UiPaginationDirective, UiPopupBackdropDirective, UiPopupBackdropService, UiPopupContainerDirective, UiPopupImageDirective, UiPopupInstance, UiPopupService, UiSelectButtonsDirective, UiTabsDirective, UiTimeDropdownDirective, UiValidationErrorsDirective, UiYearlyCalendarDirective, createNavigation, createUrl, createUrlTree, emptyCountry, extractParam, getAspectRatioFit, isBrowser, navigateByUrl, stringToColorGradient, stringToHslColor };
4374
4676
  //# sourceMappingURL=ibragim-dev-org-ui-forge-library.mjs.map