@ibragim-dev-org/ui-forge-library 1.4.35 → 1.4.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,7 @@ import * as i2$1 from '@angular/router';
2
2
  import { NavigationEnd, NavigationStart, ActivationEnd } from '@angular/router';
3
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
8
  import { throttleTime, tap as tap$1, takeUntil, debounceTime as debounceTime$1 } from 'rxjs/operators';
@@ -787,18 +787,25 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
787
787
 
788
788
  class StableScrollDirective {
789
789
  el;
790
- resizeObserver;
790
+ platformId = inject(PLATFORM_ID);
791
+ isBrowser = isPlatformBrowser(this.platformId);
791
792
  destroy$ = new Subject();
792
793
  scrolling$ = new Subject();
793
794
  _isScrolling = false;
795
+ mutationObserver;
796
+ restoreFrameId = null;
797
+ restoreMicrotaskPending = false;
794
798
  // ---- thresholds ----
795
799
  $topThreshold = input(0, ...(ngDevMode ? [{ debugName: "$topThreshold" }] : []));
796
800
  $bottomThreshold = input(0, ...(ngDevMode ? [{ debugName: "$bottomThreshold" }] : []));
797
801
  reachedTop = output();
798
802
  reachedBottom = output();
799
803
  // ---- anchor ----
800
- anchorElement = null;
801
- anchorOffset = 0;
804
+ anchorSnapshot = null;
805
+ // ---- direction tracking ----
806
+ lastScrollTop = 0;
807
+ scrollingUp = false;
808
+ scrollingDown = false;
802
809
  constructor(elRef) {
803
810
  this.el = elRef.nativeElement;
804
811
  }
@@ -806,92 +813,156 @@ class StableScrollDirective {
806
813
  return this._isScrolling;
807
814
  }
808
815
  ngAfterViewInit() {
809
- // scroll listener
816
+ if (!this.isBrowser) {
817
+ return;
818
+ }
819
+ this.lastScrollTop = this.el.scrollTop;
820
+ this.refreshAnchorSnapshot();
821
+ this.observeContentChanges();
810
822
  fromEvent(this.el, 'scroll')
811
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;
812
829
  this._isScrolling = true;
813
830
  this.scrolling$.next();
814
831
  this.checkThresholds();
832
+ this.refreshAnchorSnapshot();
815
833
  }), takeUntil(this.destroy$))
816
834
  .subscribe();
817
- // scroll end detection
818
835
  this.scrolling$
819
836
  .pipe(debounceTime$1(120), tap$1(() => (this._isScrolling = false)), takeUntil(this.destroy$))
820
837
  .subscribe();
821
- // element resize
822
- this.resizeObserver = new ResizeObserver(() => {
823
- if (!this._isScrolling) {
824
- this.captureAnchor();
825
- requestAnimationFrame(() => this.restoreAnchor());
826
- }
827
- });
828
- this.resizeObserver.observe(this.el);
829
- // window resize
830
- fromEvent(window, 'resize')
831
- .pipe(throttleTime(50), tap$1(() => {
832
- if (!this._isScrolling) {
833
- this.captureAnchor();
834
- requestAnimationFrame(() => this.restoreAnchor());
835
- }
836
- }), takeUntil(this.destroy$))
837
- .subscribe();
838
838
  }
839
839
  ngOnDestroy() {
840
+ this.mutationObserver?.disconnect();
841
+ if (this.restoreFrameId !== null && this.isBrowser) {
842
+ cancelAnimationFrame(this.restoreFrameId);
843
+ }
840
844
  this.destroy$.next();
841
845
  this.destroy$.complete();
842
- if (this.resizeObserver) {
843
- this.resizeObserver.disconnect();
844
- }
845
846
  }
846
847
  /** Call BEFORE data changes */
847
848
  captureBeforeChange() {
848
- this.captureAnchor();
849
+ this.refreshAnchorSnapshot();
849
850
  }
850
851
  /** Call AFTER render */
851
852
  restoreScrollPosition() {
852
- this.restoreAnchor();
853
+ this.scheduleRestore();
853
854
  }
854
855
  // ---- threshold logic ----
855
856
  checkThresholds() {
856
857
  const { scrollTop, scrollHeight, clientHeight } = this.el;
857
- // top threshold
858
858
  const topThreshold = this.$topThreshold();
859
859
  const topPx = topThreshold <= 1 ? scrollHeight * topThreshold : topThreshold;
860
- if (scrollTop <= topPx) {
861
- this.reachedTop.emit();
862
- }
863
- // bottom threshold
864
860
  const bottomThreshold = this.$bottomThreshold();
865
861
  const bottomPx = bottomThreshold <= 1 ? scrollHeight * bottomThreshold : bottomThreshold;
866
- if (scrollTop + clientHeight >= scrollHeight - bottomPx) {
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) {
867
868
  this.reachedBottom.emit();
868
869
  }
869
870
  }
870
- // ---- anchor logic ----
871
- captureAnchor() {
872
- const el = this.el;
873
- const midY = el.scrollTop + el.clientHeight * 0.5;
874
- const children = Array.from(el.children);
875
- const anchor = children.find((c) => {
876
- const top = c.offsetTop;
877
- const bottom = top + c.offsetHeight;
878
- return top <= midY && bottom >= midY;
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();
879
884
  });
880
- if (!anchor) {
881
- this.anchorElement = null;
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;
882
907
  return;
883
908
  }
884
- this.anchorElement = anchor;
885
- this.anchorOffset = midY - anchor.offsetTop;
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
+ });
886
929
  }
887
- restoreAnchor() {
888
- if (!this.anchorElement)
930
+ refreshAnchorSnapshot() {
931
+ const anchor = this.resolveAnchorElement();
932
+ if (!anchor) {
933
+ this.anchorSnapshot = null;
889
934
  return;
890
- const el = this.el;
891
- const anchor = this.anchorElement;
892
- const midY = anchor.offsetTop + this.anchorOffset;
893
- el.scrollTop = midY - el.clientHeight * 0.5;
894
- this.anchorElement = null;
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;
895
966
  }
896
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 });
897
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 });
@@ -2039,6 +2110,13 @@ class UiCodeDirective {
2039
2110
  $code = input.required(...(ngDevMode ? [{ debugName: "$code" }] : []));
2040
2111
  $language = signal('', ...(ngDevMode ? [{ debugName: "$language" }] : []));
2041
2112
  $highlightedArray = signal([], ...(ngDevMode ? [{ debugName: "$highlightedArray" }] : []));
2113
+ $codeToCopy = computed(() => {
2114
+ let code = this.$code();
2115
+ code = code.replace(/^\s*\n+|\n+\s*$/g, '');
2116
+ code = code.replace(/^(js|ts|css|html|xml|json)\s*\n/i, '');
2117
+ code = code.replace(/^const\s+codeLanguages\s*:\s*Record<string,\s*LangRegExps>\s*=\s*\{[\s\S]*?\};?\s*\n?/, '');
2118
+ return code.trim();
2119
+ }, ...(ngDevMode ? [{ debugName: "$codeToCopy" }] : []));
2042
2120
  constructor() {
2043
2121
  effect(() => {
2044
2122
  this.highlightCode(this.$code());
@@ -2113,19 +2191,29 @@ class UiPopupInstance {
2113
2191
  width = 0;
2114
2192
  animationOrigin$ = new BehaviorSubject('center');
2115
2193
  options = {
2116
- positionX: 0,
2117
- positionY: 0,
2118
- startTransition: 'scale(0)',
2119
- endTransition: 'scale(0)',
2194
+ startOrigin: 'center center',
2195
+ endOrigin: 'center center',
2196
+ start: 'scale(0)',
2197
+ end: 'scale(0)',
2198
+ leftStart: '0px',
2199
+ leftEnd: '0',
2200
+ topStart: '0px',
2201
+ topEnd: '0',
2120
2202
  };
2203
+ triggerPulse$ = new Subject();
2204
+ isHide$ = new Subject();
2121
2205
  closed = new Subject();
2122
2206
  shouldClose = new Subject();
2123
2207
  isClosing = false;
2124
2208
  constructor(overlayRef, destroyRef, onClose = () => { }, options = {
2125
- positionX: 0,
2126
- positionY: 0,
2127
- startTransition: 'scale(0.8)',
2128
- endTransition: 'scale(1)',
2209
+ startOrigin: 'center center',
2210
+ endOrigin: 'center center',
2211
+ start: 'scale(0.8)',
2212
+ end: 'scale(1)',
2213
+ leftStart: '0px',
2214
+ leftEnd: '0',
2215
+ topStart: '0px',
2216
+ topEnd: '0',
2129
2217
  }) {
2130
2218
  this.overlayRef = overlayRef;
2131
2219
  this.destroyRef = destroyRef;
@@ -2133,12 +2221,12 @@ class UiPopupInstance {
2133
2221
  this.options = options;
2134
2222
  this.overlayRef
2135
2223
  .detachments()
2136
- .pipe(takeUntilDestroyed(this.destroyRef))
2137
- .subscribe(() => {
2224
+ .pipe(tap(() => {
2138
2225
  this.closed.next();
2139
2226
  this.closed.complete();
2140
2227
  this.overlayRef.dispose();
2141
- });
2228
+ }), takeUntilDestroyed(this.destroyRef))
2229
+ .subscribe();
2142
2230
  }
2143
2231
  close() {
2144
2232
  if (this.isClosing) {
@@ -2157,32 +2245,13 @@ class UiPopupInstance {
2157
2245
  }
2158
2246
  }
2159
2247
 
2160
- class UiPopupBackdropService {
2161
- tipContainerPortal;
2162
- backdropPortal;
2163
- constructor(component, tipComponent) {
2164
- this.backdropPortal = new ComponentPortal(component);
2165
- if (tipComponent) {
2166
- this.tipContainerPortal = new ComponentPortal(tipComponent);
2167
- }
2168
- }
2169
- 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 });
2170
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiPopupBackdropService, providedIn: 'root' });
2171
- }
2172
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiPopupBackdropService, decorators: [{
2173
- type: Injectable,
2174
- args: [{
2175
- providedIn: 'root',
2176
- }]
2177
- }], ctorParameters: () => [{ type: i0.Type }, { type: i0.Type }] });
2178
-
2179
- class UiPopupService {
2248
+ class UiModal {
2180
2249
  overlay;
2181
2250
  injector;
2182
2251
  destroyRef;
2183
2252
  router;
2184
2253
  backdropService;
2185
- popupInstances = [];
2254
+ instances = [];
2186
2255
  backdropRef;
2187
2256
  backdropPortalRef;
2188
2257
  destroyDownloading$ = new Subject();
@@ -2194,67 +2263,27 @@ class UiPopupService {
2194
2263
  this.router = router;
2195
2264
  this.backdropService = backdropService;
2196
2265
  }
2197
- /**
2198
- * Opens a popup with the specified component and options.
2199
- *
2200
- * @param component - The component to be displayed in the popup.
2201
- * @param options - Configuration options for the popup, including inputs.
2202
- * @param id - A unique identifier for the popup instance.
2203
- * @param parameters - (Optional) Configuration options for the popup.
2204
- */
2205
- open(component, options, id, parameters) {
2206
- if (this.popupInstances.length) {
2207
- if (parameters.isClosePrevious) {
2208
- this.closePrevious();
2209
- }
2210
- }
2211
- this.showBackdrop(parameters.isStaticBackdrop);
2212
- const overlayRef = this.overlay.create({
2213
- hasBackdrop: false,
2214
- backdropClass: 'cdk-overlay-transparent-backdrop',
2215
- positionStrategy: this.overlay.position().global().centerHorizontally().centerVertically(),
2216
- });
2217
- this.subscribeToOutsideEvents();
2218
- this.createPopup(overlayRef, component, options, id, parameters);
2219
- }
2220
- /**
2221
- * Opens a popup that scales from the provided origin element to the centered popup size.
2222
- * Useful for image-preview transitions where the source element animates into the popup.
2223
- */
2224
- openScaledFromElement(component, options, id, originElement, sourceWidth, sourceHeight, parameters = {}) {
2225
- const animationOptions = this.createScaleAnimationOptionsFromElement(originElement, sourceWidth, sourceHeight);
2226
- this.open(component, options, id, {
2227
- ...parameters,
2228
- animationOptions,
2229
- });
2230
- }
2231
2266
  /**
2232
2267
  * Closes the last opened popup.
2233
2268
  */
2234
2269
  close() {
2235
- if (this.popupInstances.length >= 1) {
2236
- this.popupInstances[this.popupInstances.length - 1].close();
2237
- this.popupInstances.pop();
2238
- if (!this.popupInstances.length) {
2270
+ if (this.instances.length >= 1) {
2271
+ this.instances[this.instances.length - 1].close();
2272
+ this.instances.pop();
2273
+ if (!this.instances.length) {
2239
2274
  this.destroy();
2240
2275
  }
2241
2276
  }
2242
2277
  }
2243
- closePrevious() {
2244
- if (this.popupInstances.length >= 1) {
2245
- this.popupInstances[this.popupInstances.length - 1].close();
2246
- this.popupInstances.pop();
2247
- }
2248
- }
2249
2278
  /**
2250
- * Closes a popup by its index in the popupInstances array.
2279
+ * Closes a popup by its index in the instances array.
2251
2280
  *
2252
2281
  * @param index - The index of the popup to close.
2253
2282
  */
2254
2283
  closeByIndex(index) {
2255
- this.popupInstances[index].close();
2256
- this.popupInstances.splice(index, 1);
2257
- if (!this.popupInstances.length) {
2284
+ this.instances[index].close();
2285
+ this.instances.splice(index, 1);
2286
+ if (!this.instances.length) {
2258
2287
  this.destroy();
2259
2288
  }
2260
2289
  }
@@ -2264,7 +2293,7 @@ class UiPopupService {
2264
2293
  * @param id - The unique identifier of the popup to close.
2265
2294
  */
2266
2295
  closeById(id) {
2267
- const dropDownIndex = this.popupInstances.findIndex((v) => v.id === id);
2296
+ const dropDownIndex = this.instances.findIndex((v) => v.id === id);
2268
2297
  if (dropDownIndex >= 0) {
2269
2298
  this.closeByIndex(dropDownIndex);
2270
2299
  }
@@ -2273,10 +2302,10 @@ class UiPopupService {
2273
2302
  * Closes all currently opened popups.
2274
2303
  */
2275
2304
  closeAll() {
2276
- this.popupInstances.forEach((element) => {
2305
+ this.instances.forEach((element) => {
2277
2306
  element.close();
2278
2307
  });
2279
- this.popupInstances = [];
2308
+ this.instances = [];
2280
2309
  this.destroy();
2281
2310
  }
2282
2311
  /**
@@ -2289,7 +2318,7 @@ class UiPopupService {
2289
2318
  * @param parameters - (Optional) Configuration options for the popup.
2290
2319
  */
2291
2320
  createPopup(overlayRef, component, options, id, parameters) {
2292
- const newParameters = this.fetchPopupParameters(parameters);
2321
+ const newParameters = this.fetchParameters(parameters);
2293
2322
  const uiPopupInstance = new UiPopupInstance(overlayRef, this.destroyRef, options.onClose, newParameters.animationOptions);
2294
2323
  if (newParameters.width > 0) {
2295
2324
  uiPopupInstance.width = newParameters.width;
@@ -2309,7 +2338,7 @@ class UiPopupService {
2309
2338
  }
2310
2339
  }
2311
2340
  uiPopupInstance.id = id;
2312
- this.popupInstances.push(uiPopupInstance);
2341
+ this.instances.push(uiPopupInstance);
2313
2342
  }
2314
2343
  /**
2315
2344
  * Subscribes to outside events (e.g., scroll, router events) to close popups.
@@ -2353,6 +2382,7 @@ class UiPopupService {
2353
2382
  if (this.backdropPortalRef) {
2354
2383
  this.backdropPortalRef.location.nativeElement.classList.add('animate-in');
2355
2384
  this.backdropPortalRef.setInput('isStaticBackdrop', isStaticBackdrop);
2385
+ this.backdropPortalRef.setInput('clicked', () => this.instances[this.instances.length - 1].triggerPulse$.next());
2356
2386
  }
2357
2387
  }
2358
2388
  hideBackdrop() {
@@ -2380,14 +2410,18 @@ class UiPopupService {
2380
2410
  * @param parameters - Partial configuration options for the popup.
2381
2411
  * @returns A complete set of popup parameters with default values applied.
2382
2412
  */
2383
- fetchPopupParameters(parameters) {
2413
+ fetchParameters(parameters) {
2384
2414
  return {
2385
2415
  animationOptions: parameters.animationOptions === undefined
2386
2416
  ? {
2387
- positionX: 0,
2388
- positionY: 0,
2389
- startTransition: 'scale(0.8)',
2390
- endTransition: 'scale(1)',
2417
+ startOrigin: 'center center',
2418
+ endOrigin: 'center center',
2419
+ start: 'scale(0.8)',
2420
+ end: 'scale(1)',
2421
+ leftStart: '0px',
2422
+ leftEnd: '0',
2423
+ topStart: '0px',
2424
+ topEnd: '0',
2391
2425
  }
2392
2426
  : parameters.animationOptions,
2393
2427
  isClosePrevious: parameters.isClosePrevious === undefined ? false : parameters.isClosePrevious,
@@ -2395,35 +2429,7 @@ class UiPopupService {
2395
2429
  width: parameters.width === undefined ? 0 : parameters.width,
2396
2430
  };
2397
2431
  }
2398
- createScaleAnimationOptionsFromElement(originElement, sourceWidth, sourceHeight) {
2399
- const rect = originElement.getBoundingClientRect();
2400
- const viewportWidth = isBrowser() ? window.innerWidth : sourceWidth;
2401
- const viewportHeight = isBrowser() ? window.innerHeight : sourceHeight;
2402
- const centerX = viewportWidth / 2;
2403
- const centerY = viewportHeight / 2;
2404
- const targetX = rect.left + rect.width / 2;
2405
- const targetY = rect.top + rect.height / 2;
2406
- const offsetX = targetX - centerX;
2407
- const offsetY = targetY - centerY;
2408
- const fitted = getAspectRatioFit(viewportWidth - viewportWidth / 8, viewportHeight - viewportHeight / 8, sourceWidth, sourceHeight);
2409
- const scaleY = Math.trunc((sourceHeight / fitted.height) * 100) / 100;
2410
- const scaleX = Math.trunc((sourceWidth / fitted.width) * 100) / 100;
2411
- return {
2412
- positionX: offsetX,
2413
- positionY: offsetY,
2414
- startTransition: `scale(${scaleY}, ${scaleX})`,
2415
- endTransition: 'scale(1)',
2416
- };
2417
- }
2418
- 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 });
2419
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiPopupService, providedIn: 'root' });
2420
2432
  }
2421
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiPopupService, decorators: [{
2422
- type: Injectable,
2423
- args: [{
2424
- providedIn: 'root',
2425
- }]
2426
- }], ctorParameters: () => [{ type: i1.Overlay }, { type: i0.Injector }, { type: i0.DestroyRef }, { type: i2$1.Router }, { type: UiPopupBackdropService }] });
2427
2433
 
2428
2434
  class UiPopupContainerDirective {
2429
2435
  popupInstance;
@@ -2432,6 +2438,7 @@ class UiPopupContainerDirective {
2432
2438
  elementRef;
2433
2439
  $isShow = signal(false, ...(ngDevMode ? [{ debugName: "$isShow" }] : []));
2434
2440
  $pulseTrigger = signal(false, ...(ngDevMode ? [{ debugName: "$pulseTrigger" }] : []));
2441
+ $isHide = signal(false, ...(ngDevMode ? [{ debugName: "$isHide" }] : []));
2435
2442
  $overflowHidden = input(true, ...(ngDevMode ? [{ debugName: "$overflowHidden" }] : []));
2436
2443
  $shouldClose = model(false, ...(ngDevMode ? [{ debugName: "$shouldClose" }] : []));
2437
2444
  $hasCloseButton = input(false, ...(ngDevMode ? [{ debugName: "$hasCloseButton" }] : []));
@@ -2479,17 +2486,31 @@ class UiPopupContainerDirective {
2479
2486
  this.$isShow.set(false);
2480
2487
  }), takeUntilDestroyed(this.destroyRef))
2481
2488
  .subscribe();
2489
+ this.popupInstance.isHide$
2490
+ .pipe(tap((b) => {
2491
+ this.$isHide.set(b);
2492
+ }), takeUntilDestroyed(this.destroyRef))
2493
+ .subscribe();
2494
+ this.popupInstance.triggerPulse$
2495
+ .pipe(tap(() => {
2496
+ this.$pulseTrigger.set(true);
2497
+ asyncScheduler.schedule(() => {
2498
+ this.$pulseTrigger.set(false);
2499
+ }, 300);
2500
+ }), takeUntilDestroyed(this.destroyRef))
2501
+ .subscribe();
2482
2502
  this.popupInstance.animationOrigin$
2483
- .pipe(tap((e) => {
2503
+ .pipe(tap((origin) => {
2504
+ const animationParams = this.popupInstance.options;
2484
2505
  this.$animationParams.set({
2485
- startOrigin: e,
2486
- endOrigin: e,
2487
- start: this.popupInstance.options.startTransition,
2488
- end: this.popupInstance.options.endTransition,
2489
- leftStart: `${this.popupInstance.options.positionX}px`,
2490
- leftEnd: '0',
2491
- topStart: `${this.popupInstance.options.positionY}px`,
2492
- topEnd: '0',
2506
+ startOrigin: origin,
2507
+ endOrigin: origin,
2508
+ start: animationParams.start,
2509
+ end: animationParams.end,
2510
+ leftStart: animationParams.leftStart,
2511
+ leftEnd: animationParams.leftEnd,
2512
+ topStart: animationParams.topStart,
2513
+ topEnd: animationParams.topEnd,
2493
2514
  });
2494
2515
  this.$isShow.set(true);
2495
2516
  }), takeUntil$1(this.destroyAnimationOrigin$), takeUntilDestroyed(this.destroyRef))
@@ -2519,7 +2540,7 @@ class UiPopupContainerDirective {
2519
2540
  shouldClose() {
2520
2541
  this.$shouldClose.set(true);
2521
2542
  }
2522
- 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 });
2543
+ 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 });
2523
2544
  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 });
2524
2545
  }
2525
2546
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiPopupContainerDirective, decorators: [{
@@ -2530,123 +2551,534 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
2530
2551
  }], ctorParameters: () => [{ type: UiPopupInstance, decorators: [{
2531
2552
  type: Inject,
2532
2553
  args: [UiPopupInstance]
2533
- }] }, { 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"] }] } });
2554
+ }] }, { 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"] }] } });
2534
2555
 
2535
- class UiDropdownService extends UiPopupService {
2536
- containerSize$ = new BehaviorSubject({
2537
- width: 0,
2538
- height: 0,
2539
- });
2540
- connectedPositions = {
2541
- bottom: {
2542
- animationOrigin: 'top center',
2543
- connectedPosition: {
2544
- originX: 'center',
2545
- originY: 'bottom',
2546
- overlayX: 'center',
2547
- overlayY: 'top',
2548
- offsetY: 0,
2549
- offsetX: 0,
2550
- },
2551
- },
2552
- top: {
2553
- animationOrigin: 'bottom center',
2554
- connectedPosition: {
2555
- originX: 'center',
2556
- originY: 'top',
2557
- overlayX: 'center',
2558
- overlayY: 'bottom',
2559
- offsetY: 0,
2560
- offsetX: 0,
2561
- },
2562
- },
2563
- center: {
2564
- animationOrigin: 'center center',
2565
- connectedPosition: {
2566
- originX: 'center',
2567
- originY: 'center',
2568
- overlayX: 'center',
2569
- overlayY: 'center',
2570
- offsetY: 0,
2571
- offsetX: 0,
2572
- },
2573
- },
2574
- left: {
2575
- animationOrigin: 'right center',
2576
- connectedPosition: {
2577
- originX: 'start',
2578
- originY: 'center',
2579
- overlayX: 'end',
2580
- overlayY: 'center',
2581
- offsetY: 0,
2582
- offsetX: 0,
2583
- },
2584
- },
2585
- right: {
2586
- animationOrigin: 'left center',
2587
- connectedPosition: {
2588
- originX: 'end',
2589
- originY: 'center',
2590
- overlayX: 'start',
2591
- overlayY: 'center',
2592
- offsetY: 0,
2593
- offsetX: 0,
2594
- },
2595
- },
2596
- 'right-top': {
2597
- animationOrigin: 'left bottom',
2598
- connectedPosition: {
2599
- originX: 'end',
2600
- originY: 'top',
2601
- overlayX: 'start',
2602
- overlayY: 'bottom',
2603
- offsetY: 0,
2604
- offsetX: 0,
2605
- },
2606
- },
2607
- 'right-bottom': {
2608
- animationOrigin: 'left top',
2609
- connectedPosition: {
2610
- originX: 'end',
2611
- originY: 'bottom',
2612
- overlayX: 'start',
2613
- overlayY: 'top',
2614
- offsetY: 0,
2615
- offsetX: 0,
2616
- },
2617
- },
2618
- 'left-top': {
2619
- animationOrigin: 'right bottom',
2620
- connectedPosition: {
2621
- originX: 'start',
2622
- originY: 'top',
2623
- overlayX: 'end',
2624
- overlayY: 'bottom',
2625
- offsetY: 0,
2626
- offsetX: 0,
2627
- },
2628
- },
2629
- 'left-bottom': {
2630
- animationOrigin: 'right top',
2631
- connectedPosition: {
2632
- originX: 'start',
2633
- originY: 'bottom',
2634
- overlayX: 'end',
2635
- overlayY: 'top',
2636
- offsetY: 0,
2637
- offsetX: 0,
2638
- },
2639
- },
2640
- };
2641
- /**
2642
- * Opens a tooltip (tip) component attached to a specific HTML element.
2643
- * The tooltip displays text content with customizable position and offset.
2644
- *
2645
- * @param text - The text content to display in the tooltip.
2646
- * @param attachedRef - The HTML element to which the tooltip is attached.
2647
- * @param id - A unique identifier for the tooltip instance.
2648
- * @param position - (Optional) The positioning of the tooltip relative to the attached element (default: 'top').
2649
- * Available positions: 'top', 'bottom', 'left', 'right', 'center',
2556
+ class UiPopupImageDirective {
2557
+ destroyRef;
2558
+ src = '';
2559
+ width = 0;
2560
+ height = 0;
2561
+ $imageWidth = signal(0, ...(ngDevMode ? [{ debugName: "$imageWidth" }] : []));
2562
+ $imageHeight = signal(0, ...(ngDevMode ? [{ debugName: "$imageHeight" }] : []));
2563
+ $imageStyleTransform = signal('', ...(ngDevMode ? [{ debugName: "$imageStyleTransform" }] : []));
2564
+ $container = viewChild('container', ...(ngDevMode ? [{ debugName: "$container" }] : []));
2565
+ $image = viewChild('image', ...(ngDevMode ? [{ debugName: "$image" }] : []));
2566
+ $cursor = signal('auto', ...(ngDevMode ? [{ debugName: "$cursor" }] : []));
2567
+ isDragging = false;
2568
+ isTouchDragging = false;
2569
+ isPinching = false;
2570
+ lastTouchX = 0;
2571
+ lastTouchY = 0;
2572
+ lastTouchDistance = 0;
2573
+ size = { w: 0, h: 0 };
2574
+ speed = 0.5;
2575
+ pos = { x: 0, y: 0 };
2576
+ target = { x: 0, y: 0 };
2577
+ pointer = { x: 0, y: 0 };
2578
+ scale = 1;
2579
+ constructor(destroyRef) {
2580
+ this.destroyRef = destroyRef;
2581
+ }
2582
+ ngOnInit() {
2583
+ if (!isBrowser()) {
2584
+ this.$imageWidth.set(this.width);
2585
+ this.$imageHeight.set(this.height);
2586
+ return;
2587
+ }
2588
+ const result = getAspectRatioFit(window.innerWidth - window.innerWidth / 8, window.innerHeight - window.innerHeight / 8, this.width, this.height);
2589
+ this.$imageWidth.set(result.width);
2590
+ this.$imageHeight.set(result.height);
2591
+ }
2592
+ ngAfterViewInit() {
2593
+ const container = this.$container()?.nativeElement;
2594
+ if (!container)
2595
+ return;
2596
+ if (!isBrowser())
2597
+ return;
2598
+ this.size = {
2599
+ w: container.offsetWidth,
2600
+ h: container.offsetHeight,
2601
+ };
2602
+ // -----------------------------
2603
+ // KEYBOARD CURSOR LOGIC
2604
+ // -----------------------------
2605
+ fromEvent(window, 'keydown')
2606
+ .pipe(tap((event) => {
2607
+ if (event.ctrlKey)
2608
+ this.$cursor.set('zoom-in');
2609
+ }), takeUntilDestroyed(this.destroyRef))
2610
+ .subscribe();
2611
+ fromEvent(window, 'keyup')
2612
+ .pipe(tap((event) => {
2613
+ if (event.key === 'Control') {
2614
+ this.$cursor.set(this.scale > 1 ? 'grab' : 'auto');
2615
+ }
2616
+ }), takeUntilDestroyed(this.destroyRef))
2617
+ .subscribe();
2618
+ // -----------------------------
2619
+ // MOUSE DRAG
2620
+ // -----------------------------
2621
+ fromEvent(window, 'mouseup')
2622
+ .pipe(tap((event) => {
2623
+ if (event.button === 0) {
2624
+ this.isDragging = false;
2625
+ this.$cursor.set(this.scale > 1 ? 'grab' : 'auto');
2626
+ }
2627
+ }), takeUntilDestroyed(this.destroyRef))
2628
+ .subscribe();
2629
+ fromEvent(container, 'mousedown')
2630
+ .pipe(tap((event) => {
2631
+ if (event.button === 0) {
2632
+ event.preventDefault();
2633
+ this.isDragging = true;
2634
+ this.$cursor.set(this.scale > 1 ? 'grabbing' : 'auto');
2635
+ }
2636
+ }), takeUntilDestroyed(this.destroyRef))
2637
+ .subscribe();
2638
+ fromEvent(window, 'mousemove')
2639
+ .pipe(tap((e) => {
2640
+ if (this.isDragging && this.scale > 1) {
2641
+ this.pos.x += e.movementX;
2642
+ this.pos.y += e.movementY;
2643
+ this.setPosition();
2644
+ this.$imageStyleTransform.set(`translate(${this.pos.x}px,${this.pos.y}px) scale(${this.scale})`);
2645
+ }
2646
+ }), takeUntilDestroyed(this.destroyRef))
2647
+ .subscribe();
2648
+ // -----------------------------
2649
+ // MOUSE WHEEL ZOOM
2650
+ // -----------------------------
2651
+ fromEvent(window, 'wheel', { passive: false })
2652
+ .pipe(tap((event) => {
2653
+ event.preventDefault();
2654
+ const rect = container.getBoundingClientRect();
2655
+ if (event.ctrlKey) {
2656
+ this.pointer.x = event.clientX - rect.left;
2657
+ this.pointer.y = event.clientY - rect.top;
2658
+ this.target.x = (this.pointer.x - this.pos.x) / this.scale;
2659
+ this.target.y = (this.pointer.y - this.pos.y) / this.scale;
2660
+ this.scale += -1 * Math.max(-1, Math.min(1, event.deltaY)) * this.speed * this.scale;
2661
+ const maxScale = 4;
2662
+ const minScale = 1;
2663
+ this.scale = Math.max(minScale, Math.min(maxScale, this.scale));
2664
+ this.pos.x = -this.target.x * this.scale + this.pointer.x;
2665
+ this.pos.y = -this.target.y * this.scale + this.pointer.y;
2666
+ this.setPosition();
2667
+ this.$imageStyleTransform.set(`translate(${this.pos.x}px,${this.pos.y}px) scale(${this.scale})`);
2668
+ }
2669
+ else {
2670
+ this.pos.x -= event.deltaX * 2;
2671
+ this.pos.y -= event.deltaY * 2;
2672
+ }
2673
+ }), takeUntilDestroyed(this.destroyRef))
2674
+ .subscribe();
2675
+ // -----------------------------
2676
+ // TOUCH PINCH ZOOM
2677
+ // -----------------------------
2678
+ fromEvent(container, 'touchstart')
2679
+ .pipe(tap((event) => {
2680
+ if (event.touches.length === 2) {
2681
+ this.isPinching = true;
2682
+ const [t1, t2] = event.touches;
2683
+ this.lastTouchDistance = Math.hypot(t2.clientX - t1.clientX, t2.clientY - t1.clientY);
2684
+ }
2685
+ if (event.touches.length === 1 && this.scale > 1) {
2686
+ const t = event.touches[0];
2687
+ this.lastTouchX = t.clientX;
2688
+ this.lastTouchY = t.clientY;
2689
+ this.isTouchDragging = true;
2690
+ this.$cursor.set('grabbing');
2691
+ }
2692
+ }), takeUntilDestroyed(this.destroyRef))
2693
+ .subscribe();
2694
+ fromEvent(container, 'touchmove')
2695
+ .pipe(tap((event) => {
2696
+ if (this.isPinching && event.touches.length === 2) {
2697
+ event.preventDefault();
2698
+ const [t1, t2] = event.touches;
2699
+ const newDistance = Math.hypot(t2.clientX - t1.clientX, t2.clientY - t1.clientY);
2700
+ const delta = newDistance - this.lastTouchDistance;
2701
+ this.lastTouchDistance = newDistance;
2702
+ const rect = container.getBoundingClientRect();
2703
+ const centerX = (t1.clientX + t2.clientX) / 2 - rect.left;
2704
+ const centerY = (t1.clientY + t2.clientY) / 2 - rect.top;
2705
+ this.pointer.x = centerX;
2706
+ this.pointer.y = centerY;
2707
+ this.target.x = (this.pointer.x - this.pos.x) / this.scale;
2708
+ this.target.y = (this.pointer.y - this.pos.y) / this.scale;
2709
+ const pinchSpeed = 0.005;
2710
+ this.scale += delta * pinchSpeed * this.scale;
2711
+ const maxScale = 4;
2712
+ const minScale = 1;
2713
+ this.scale = Math.max(minScale, Math.min(maxScale, this.scale));
2714
+ this.pos.x = -this.target.x * this.scale + this.pointer.x;
2715
+ this.pos.y = -this.target.y * this.scale + this.pointer.y;
2716
+ this.setPosition();
2717
+ this.$imageStyleTransform.set(`translate(${this.pos.x}px,${this.pos.y}px) scale(${this.scale})`);
2718
+ }
2719
+ if (this.isTouchDragging && event.touches.length === 1) {
2720
+ event.preventDefault();
2721
+ const t = event.touches[0];
2722
+ const dx = t.clientX - this.lastTouchX;
2723
+ const dy = t.clientY - this.lastTouchY;
2724
+ this.lastTouchX = t.clientX;
2725
+ this.lastTouchY = t.clientY;
2726
+ this.pos.x += dx;
2727
+ this.pos.y += dy;
2728
+ this.setPosition();
2729
+ this.$imageStyleTransform.set(`translate(${this.pos.x}px,${this.pos.y}px) scale(${this.scale})`);
2730
+ }
2731
+ }), takeUntilDestroyed(this.destroyRef))
2732
+ .subscribe();
2733
+ fromEvent(container, 'touchend')
2734
+ .pipe(tap(() => {
2735
+ this.isPinching = false;
2736
+ this.isTouchDragging = false;
2737
+ this.$cursor.set(this.scale > 1 ? 'grab' : 'auto');
2738
+ }), takeUntilDestroyed(this.destroyRef))
2739
+ .subscribe();
2740
+ }
2741
+ setPosition() {
2742
+ if (this.pos.x > 0)
2743
+ this.pos.x = 0;
2744
+ if (this.pos.x + this.size.w * this.scale < this.size.w) {
2745
+ this.pos.x = -this.size.w * (this.scale - 1);
2746
+ }
2747
+ if (this.pos.y > 0)
2748
+ this.pos.y = 0;
2749
+ if (this.pos.y + this.size.h * this.scale < this.size.h) {
2750
+ this.pos.y = -this.size.h * (this.scale - 1);
2751
+ }
2752
+ }
2753
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiPopupImageDirective, deps: [{ token: i0.DestroyRef }], target: i0.ɵɵFactoryTarget.Directive });
2754
+ 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 });
2755
+ }
2756
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiPopupImageDirective, decorators: [{
2757
+ type: Directive,
2758
+ args: [{
2759
+ selector: 'app-ui-popup-image',
2760
+ }]
2761
+ }], ctorParameters: () => [{ type: i0.DestroyRef }], propDecorators: { src: [{
2762
+ type: Input,
2763
+ args: [{ required: true }]
2764
+ }], width: [{
2765
+ type: Input,
2766
+ args: [{ required: true }]
2767
+ }], height: [{
2768
+ type: Input,
2769
+ args: [{ required: true }]
2770
+ }], $container: [{ type: i0.ViewChild, args: ['container', { isSignal: true }] }], $image: [{ type: i0.ViewChild, args: ['image', { isSignal: true }] }] } });
2771
+
2772
+ class UiPopupBackdropService {
2773
+ tipContainerPortal;
2774
+ backdropPortal;
2775
+ constructor(component, tipComponent) {
2776
+ this.backdropPortal = new ComponentPortal(component);
2777
+ if (tipComponent) {
2778
+ this.tipContainerPortal = new ComponentPortal(tipComponent);
2779
+ }
2780
+ }
2781
+ 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 });
2782
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiPopupBackdropService, providedIn: 'root' });
2783
+ }
2784
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiPopupBackdropService, decorators: [{
2785
+ type: Injectable,
2786
+ args: [{
2787
+ providedIn: 'root',
2788
+ }]
2789
+ }], ctorParameters: () => [{ type: i0.Type }, { type: i0.Type }] });
2790
+
2791
+ class UiPopupService extends UiModal {
2792
+ defaultAnimationOptions = {
2793
+ startOrigin: '',
2794
+ endOrigin: '',
2795
+ start: '',
2796
+ end: '',
2797
+ leftStart: '',
2798
+ leftEnd: '',
2799
+ topStart: '',
2800
+ topEnd: '',
2801
+ };
2802
+ constructor(overlay, injector, destroyRef, router, backdropService) {
2803
+ super(overlay, injector, destroyRef, router, backdropService);
2804
+ }
2805
+ /**
2806
+ * Opens a popup with the specified component and options.
2807
+ *
2808
+ * @param component - The component to be displayed in the popup.
2809
+ * @param options - Configuration options for the popup, including inputs.
2810
+ * @param id - A unique identifier for the popup instance.
2811
+ * @param parameters - (Optional) Configuration options for the popup.
2812
+ */
2813
+ open(component, options, id, parameters) {
2814
+ if (this.instances.length) {
2815
+ this.closePrevious(parameters.isClosePrevious ?? false);
2816
+ parameters.animationOptions = {
2817
+ startOrigin: 'center center',
2818
+ endOrigin: 'center center',
2819
+ start: 'translateX(100%)',
2820
+ end: 'translateX(0)',
2821
+ leftStart: '0',
2822
+ leftEnd: '0',
2823
+ topStart: '0',
2824
+ topEnd: '0',
2825
+ };
2826
+ }
2827
+ this.showBackdrop(parameters.isStaticBackdrop);
2828
+ const overlayRef = this.overlay.create({
2829
+ hasBackdrop: false,
2830
+ backdropClass: 'cdk-overlay-transparent-backdrop',
2831
+ positionStrategy: this.overlay.position().global().centerHorizontally().centerVertically(),
2832
+ });
2833
+ this.subscribeToOutsideEvents();
2834
+ this.createPopup(overlayRef, component, options, id, parameters);
2835
+ if (this.instances.length === 1) {
2836
+ this.defaultAnimationOptions = this.instances[0].options;
2837
+ }
2838
+ }
2839
+ close() {
2840
+ this.resetAnimationForSingleInstance();
2841
+ super.close();
2842
+ this.applyHideToLastInstance();
2843
+ }
2844
+ closeAll() {
2845
+ this.instances.forEach((instance) => {
2846
+ instance.options = this.defaultAnimationOptions;
2847
+ instance.animationOrigin$.next('center');
2848
+ });
2849
+ super.closeAll();
2850
+ }
2851
+ closeById(id) {
2852
+ this.resetAnimationForSingleInstance();
2853
+ super.closeById(id);
2854
+ this.applyHideToLastInstance();
2855
+ }
2856
+ resetAnimationForSingleInstance() {
2857
+ if (this.instances.length === 1) {
2858
+ const instance = this.instances[0];
2859
+ instance.options = this.defaultAnimationOptions;
2860
+ instance.animationOrigin$.next('center');
2861
+ }
2862
+ }
2863
+ applyHideToLastInstance() {
2864
+ if (this.instances.length >= 1) {
2865
+ this.instances[this.instances.length - 1].isHide$.next(false);
2866
+ }
2867
+ }
2868
+ closePrevious(isClosePrevious) {
2869
+ if (this.instances.length === 0)
2870
+ return;
2871
+ const lastIndex = this.instances.length - 1;
2872
+ const lastPopupInstance = this.instances[lastIndex];
2873
+ lastPopupInstance.isHide$.next(true);
2874
+ if (isClosePrevious) {
2875
+ asyncScheduler.schedule(() => {
2876
+ // ensure the instance still exists
2877
+ const currentIndex = this.instances.indexOf(lastPopupInstance);
2878
+ if (currentIndex !== -1) {
2879
+ lastPopupInstance.close();
2880
+ this.instances.splice(currentIndex, 1);
2881
+ }
2882
+ }, 300);
2883
+ }
2884
+ }
2885
+ /**
2886
+ * Opens a popup that scales from the provided origin element to the centered popup size.
2887
+ * Useful for image-preview transitions where the source element animates into the popup.
2888
+ */
2889
+ openScaledFromElement(component, options, id, originElement, sourceWidth, sourceHeight, parameters = {}) {
2890
+ const animationOptions = this.createScaleAnimationOptionsFromElement(originElement, sourceWidth, sourceHeight);
2891
+ this.open(component, options, id, {
2892
+ ...parameters,
2893
+ animationOptions,
2894
+ });
2895
+ }
2896
+ createScaleAnimationOptionsFromElement(originElement, sourceWidth, sourceHeight) {
2897
+ const rect = originElement.getBoundingClientRect();
2898
+ const viewportWidth = isBrowser() ? window.innerWidth : sourceWidth;
2899
+ const viewportHeight = isBrowser() ? window.innerHeight : sourceHeight;
2900
+ const centerX = viewportWidth / 2;
2901
+ const centerY = viewportHeight / 2;
2902
+ const targetX = rect.left + rect.width / 2;
2903
+ const targetY = rect.top + rect.height / 2;
2904
+ const offsetX = targetX - centerX;
2905
+ const offsetY = targetY - centerY;
2906
+ const fitted = getAspectRatioFit(viewportWidth - viewportWidth / 8, viewportHeight - viewportHeight / 8, sourceWidth, sourceHeight);
2907
+ const scaleY = Math.trunc((sourceHeight / fitted.height) * 100) / 100;
2908
+ const scaleX = Math.trunc((sourceWidth / fitted.width) * 100) / 100;
2909
+ return {
2910
+ startOrigin: 'center center',
2911
+ endOrigin: 'center center',
2912
+ start: `scale(${scaleY}, ${scaleX})`,
2913
+ end: 'scale(1)',
2914
+ leftStart: `${offsetX}px`,
2915
+ leftEnd: '0',
2916
+ topStart: `${offsetY}px`,
2917
+ topEnd: '0',
2918
+ };
2919
+ }
2920
+ 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 });
2921
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiPopupService, providedIn: 'root' });
2922
+ }
2923
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiPopupService, decorators: [{
2924
+ type: Injectable,
2925
+ args: [{
2926
+ providedIn: 'root',
2927
+ }]
2928
+ }], ctorParameters: () => [{ type: i1.Overlay }, { type: i0.Injector }, { type: i0.DestroyRef }, { type: i2$1.Router }, { type: UiPopupBackdropService }] });
2929
+
2930
+ class UiPopupBackdropDirective {
2931
+ elementRef;
2932
+ uiPopupService;
2933
+ destroyRef;
2934
+ isStaticBackdrop = false;
2935
+ clicked = () => { };
2936
+ constructor(elementRef, uiPopupService, destroyRef) {
2937
+ this.elementRef = elementRef;
2938
+ this.uiPopupService = uiPopupService;
2939
+ this.destroyRef = destroyRef;
2940
+ }
2941
+ ngOnInit() {
2942
+ fromEvent(this.elementRef.nativeElement, 'click')
2943
+ .pipe(tap(() => {
2944
+ if (this.isStaticBackdrop) {
2945
+ this.clicked();
2946
+ return;
2947
+ }
2948
+ this.uiPopupService.closeAll();
2949
+ }), takeUntilDestroyed(this.destroyRef))
2950
+ .subscribe();
2951
+ }
2952
+ 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 });
2953
+ 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 });
2954
+ }
2955
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiPopupBackdropDirective, decorators: [{
2956
+ type: Directive,
2957
+ args: [{ selector: 'app-ui-popup-backdrop' }]
2958
+ }], ctorParameters: () => [{ type: i0.ElementRef }, { type: UiPopupService }, { type: i0.DestroyRef }], propDecorators: { isStaticBackdrop: [{
2959
+ type: Input
2960
+ }], clicked: [{
2961
+ type: Input
2962
+ }] } });
2963
+
2964
+ class UiDropdownService extends UiModal {
2965
+ containerSize$ = new BehaviorSubject({
2966
+ width: 0,
2967
+ height: 0,
2968
+ });
2969
+ connectedPositions = {
2970
+ bottom: {
2971
+ animationOrigin: 'top center',
2972
+ connectedPosition: {
2973
+ originX: 'center',
2974
+ originY: 'bottom',
2975
+ overlayX: 'center',
2976
+ overlayY: 'top',
2977
+ offsetY: 0,
2978
+ offsetX: 0,
2979
+ },
2980
+ },
2981
+ top: {
2982
+ animationOrigin: 'bottom center',
2983
+ connectedPosition: {
2984
+ originX: 'center',
2985
+ originY: 'top',
2986
+ overlayX: 'center',
2987
+ overlayY: 'bottom',
2988
+ offsetY: 0,
2989
+ offsetX: 0,
2990
+ },
2991
+ },
2992
+ center: {
2993
+ animationOrigin: 'center center',
2994
+ connectedPosition: {
2995
+ originX: 'center',
2996
+ originY: 'center',
2997
+ overlayX: 'center',
2998
+ overlayY: 'center',
2999
+ offsetY: 0,
3000
+ offsetX: 0,
3001
+ },
3002
+ },
3003
+ left: {
3004
+ animationOrigin: 'right center',
3005
+ connectedPosition: {
3006
+ originX: 'start',
3007
+ originY: 'center',
3008
+ overlayX: 'end',
3009
+ overlayY: 'center',
3010
+ offsetY: 0,
3011
+ offsetX: 0,
3012
+ },
3013
+ },
3014
+ right: {
3015
+ animationOrigin: 'left center',
3016
+ connectedPosition: {
3017
+ originX: 'end',
3018
+ originY: 'center',
3019
+ overlayX: 'start',
3020
+ overlayY: 'center',
3021
+ offsetY: 0,
3022
+ offsetX: 0,
3023
+ },
3024
+ },
3025
+ 'right-top': {
3026
+ animationOrigin: 'left bottom',
3027
+ connectedPosition: {
3028
+ originX: 'end',
3029
+ originY: 'top',
3030
+ overlayX: 'start',
3031
+ overlayY: 'bottom',
3032
+ offsetY: 0,
3033
+ offsetX: 0,
3034
+ },
3035
+ },
3036
+ 'right-bottom': {
3037
+ animationOrigin: 'left top',
3038
+ connectedPosition: {
3039
+ originX: 'end',
3040
+ originY: 'bottom',
3041
+ overlayX: 'start',
3042
+ overlayY: 'top',
3043
+ offsetY: 0,
3044
+ offsetX: 0,
3045
+ },
3046
+ },
3047
+ 'left-top': {
3048
+ animationOrigin: 'right bottom',
3049
+ connectedPosition: {
3050
+ originX: 'start',
3051
+ originY: 'top',
3052
+ overlayX: 'end',
3053
+ overlayY: 'bottom',
3054
+ offsetY: 0,
3055
+ offsetX: 0,
3056
+ },
3057
+ },
3058
+ 'left-bottom': {
3059
+ animationOrigin: 'right top',
3060
+ connectedPosition: {
3061
+ originX: 'start',
3062
+ originY: 'bottom',
3063
+ overlayX: 'end',
3064
+ overlayY: 'top',
3065
+ offsetY: 0,
3066
+ offsetX: 0,
3067
+ },
3068
+ },
3069
+ };
3070
+ constructor(overlay, injector, destroyRef, router, backdropService) {
3071
+ super(overlay, injector, destroyRef, router, backdropService);
3072
+ }
3073
+ /**
3074
+ * Opens a tooltip (tip) component attached to a specific HTML element.
3075
+ * The tooltip displays text content with customizable position and offset.
3076
+ *
3077
+ * @param text - The text content to display in the tooltip.
3078
+ * @param attachedRef - The HTML element to which the tooltip is attached.
3079
+ * @param id - A unique identifier for the tooltip instance.
3080
+ * @param position - (Optional) The positioning of the tooltip relative to the attached element (default: 'top').
3081
+ * Available positions: 'top', 'bottom', 'left', 'right', 'center',
2650
3082
  * 'left-top', 'left-bottom', 'right-top', 'right-bottom'.
2651
3083
  * @param offsetY - (Optional) Vertical offset for tooltip positioning in pixels (default: 0).
2652
3084
  * @param offsetX - (Optional) Horizontal offset for tooltip positioning in pixels (default: 0).
@@ -2688,10 +3120,10 @@ class UiDropdownService extends UiPopupService {
2688
3120
  if (fetchedParameters.hasAttachedWidth) {
2689
3121
  attachedWidth = attachedRef.clientWidth;
2690
3122
  }
2691
- if (fetchedParameters.removePrevious && this.popupInstances.length) {
3123
+ if (fetchedParameters.removePrevious && this.instances.length) {
2692
3124
  this.destroyOutsideClickSubscription$.next();
2693
3125
  }
2694
- if (fetchedParameters.removePrevious && this.popupInstances.length) {
3126
+ if (fetchedParameters.removePrevious && this.instances.length) {
2695
3127
  this.close();
2696
3128
  }
2697
3129
  if (isBrowser() && window.matchMedia('(max-width: 48rem)').matches) {
@@ -2706,7 +3138,7 @@ class UiDropdownService extends UiPopupService {
2706
3138
  this.subscribeToOutsideEvents(overlayRef);
2707
3139
  }
2708
3140
  this.createPopup(overlayRef, component, fetchedParameters.options ?? {}, id, { width: attachedWidth });
2709
- this.popupInstances[this.popupInstances.length - 1].animationOrigin$.next(this.connectedPositions[parameters.position ?? 'bottom'].animationOrigin);
3141
+ this.instances[this.instances.length - 1].animationOrigin$.next(this.connectedPositions[parameters.position ?? 'bottom'].animationOrigin);
2710
3142
  }
2711
3143
  /**
2712
3144
  * Opens a dropdown from the mouse position with intelligent border detection.
@@ -2720,10 +3152,10 @@ class UiDropdownService extends UiPopupService {
2720
3152
  */
2721
3153
  openAtMousePosition(component, event, id, parameters = {}) {
2722
3154
  const fetchedParameters = this.fetchDropDownParameters(parameters);
2723
- if (fetchedParameters.removePrevious && this.popupInstances.length) {
3155
+ if (fetchedParameters.removePrevious && this.instances.length) {
2724
3156
  this.destroyOutsideClickSubscription$.next();
2725
3157
  }
2726
- if (fetchedParameters.removePrevious && this.popupInstances.length) {
3158
+ if (fetchedParameters.removePrevious && this.instances.length) {
2727
3159
  this.close();
2728
3160
  }
2729
3161
  if (isBrowser() && window.matchMedia('(max-width: 48rem)').matches) {
@@ -2739,10 +3171,14 @@ class UiDropdownService extends UiPopupService {
2739
3171
  }
2740
3172
  this.createPopup(overlayRef, component, fetchedParameters.options ?? {}, id, {
2741
3173
  animationOptions: {
2742
- positionX: 0,
2743
- positionY: 0,
2744
- startTransition: 'scale(0.4)',
2745
- endTransition: 'scale(1)',
3174
+ startOrigin: 'center center',
3175
+ endOrigin: 'center center',
3176
+ start: 'scale(0.4)',
3177
+ end: 'scale(1)',
3178
+ leftStart: '0px',
3179
+ leftEnd: '0',
3180
+ topStart: '0px',
3181
+ topEnd: '0',
2746
3182
  },
2747
3183
  });
2748
3184
  this.containerSize$
@@ -2752,7 +3188,7 @@ class UiDropdownService extends UiPopupService {
2752
3188
  }
2753
3189
  const animationOrigin = this.calculateMousePositionAnimationOrigin(event, size);
2754
3190
  const positionAdjustment = this.calculateMousePositionAdjustment(event, size);
2755
- this.popupInstances[this.popupInstances.length - 1].animationOrigin$.next(animationOrigin);
3191
+ this.instances[this.instances.length - 1].animationOrigin$.next(animationOrigin);
2756
3192
  const positionStrategy = overlayRef.getConfig().positionStrategy;
2757
3193
  if (positionStrategy instanceof FlexibleConnectedPositionStrategy && positionAdjustment) {
2758
3194
  positionStrategy.setOrigin({ x: positionAdjustment.left, y: positionAdjustment.top });
@@ -2887,7 +3323,7 @@ class UiDropdownService extends UiPopupService {
2887
3323
  },
2888
3324
  ]);
2889
3325
  }
2890
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiDropdownService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
3326
+ 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 });
2891
3327
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiDropdownService, providedIn: 'root' });
2892
3328
  }
2893
3329
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiDropdownService, decorators: [{
@@ -2895,7 +3331,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
2895
3331
  args: [{
2896
3332
  providedIn: 'root',
2897
3333
  }]
2898
- }] });
3334
+ }], ctorParameters: () => [{ type: i1.Overlay }, { type: i0.Injector }, { type: i0.DestroyRef }, { type: i2$1.Router }, { type: UiPopupBackdropService }] });
2899
3335
 
2900
3336
  class UiDropdownContainerDirective extends UiPopupContainerDirective {
2901
3337
  dropDownService;
@@ -3124,252 +3560,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
3124
3560
  }]
3125
3561
  }], 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"] }] } });
3126
3562
 
3127
- class UiPopupImageDirective {
3128
- destroyRef;
3129
- src = '';
3130
- width = 0;
3131
- height = 0;
3132
- $imageWidth = signal(0, ...(ngDevMode ? [{ debugName: "$imageWidth" }] : []));
3133
- $imageHeight = signal(0, ...(ngDevMode ? [{ debugName: "$imageHeight" }] : []));
3134
- $imageStyleTransform = signal('', ...(ngDevMode ? [{ debugName: "$imageStyleTransform" }] : []));
3135
- $container = viewChild('container', ...(ngDevMode ? [{ debugName: "$container" }] : []));
3136
- $image = viewChild('image', ...(ngDevMode ? [{ debugName: "$image" }] : []));
3137
- $cursor = signal('auto', ...(ngDevMode ? [{ debugName: "$cursor" }] : []));
3138
- isDragging = false;
3139
- isTouchDragging = false;
3140
- isPinching = false;
3141
- lastTouchX = 0;
3142
- lastTouchY = 0;
3143
- lastTouchDistance = 0;
3144
- size = { w: 0, h: 0 };
3145
- speed = 0.5;
3146
- pos = { x: 0, y: 0 };
3147
- target = { x: 0, y: 0 };
3148
- pointer = { x: 0, y: 0 };
3149
- scale = 1;
3150
- constructor(destroyRef) {
3151
- this.destroyRef = destroyRef;
3152
- }
3153
- ngOnInit() {
3154
- if (!isBrowser()) {
3155
- this.$imageWidth.set(this.width);
3156
- this.$imageHeight.set(this.height);
3157
- return;
3158
- }
3159
- const result = getAspectRatioFit(window.innerWidth - window.innerWidth / 8, window.innerHeight - window.innerHeight / 8, this.width, this.height);
3160
- this.$imageWidth.set(result.width);
3161
- this.$imageHeight.set(result.height);
3162
- }
3163
- ngAfterViewInit() {
3164
- const container = this.$container()?.nativeElement;
3165
- if (!container)
3166
- return;
3167
- if (!isBrowser())
3168
- return;
3169
- this.size = {
3170
- w: container.offsetWidth,
3171
- h: container.offsetHeight,
3172
- };
3173
- // -----------------------------
3174
- // KEYBOARD CURSOR LOGIC
3175
- // -----------------------------
3176
- fromEvent(window, 'keydown')
3177
- .pipe(tap((event) => {
3178
- if (event.ctrlKey)
3179
- this.$cursor.set('zoom-in');
3180
- }), takeUntilDestroyed(this.destroyRef))
3181
- .subscribe();
3182
- fromEvent(window, 'keyup')
3183
- .pipe(tap((event) => {
3184
- if (event.key === 'Control') {
3185
- this.$cursor.set(this.scale > 1 ? 'grab' : 'auto');
3186
- }
3187
- }), takeUntilDestroyed(this.destroyRef))
3188
- .subscribe();
3189
- // -----------------------------
3190
- // MOUSE DRAG
3191
- // -----------------------------
3192
- fromEvent(window, 'mouseup')
3193
- .pipe(tap((event) => {
3194
- if (event.button === 0) {
3195
- this.isDragging = false;
3196
- this.$cursor.set(this.scale > 1 ? 'grab' : 'auto');
3197
- }
3198
- }), takeUntilDestroyed(this.destroyRef))
3199
- .subscribe();
3200
- fromEvent(container, 'mousedown')
3201
- .pipe(tap((event) => {
3202
- if (event.button === 0) {
3203
- event.preventDefault();
3204
- this.isDragging = true;
3205
- this.$cursor.set(this.scale > 1 ? 'grabbing' : 'auto');
3206
- }
3207
- }), takeUntilDestroyed(this.destroyRef))
3208
- .subscribe();
3209
- fromEvent(window, 'mousemove')
3210
- .pipe(tap((e) => {
3211
- if (this.isDragging && this.scale > 1) {
3212
- this.pos.x += e.movementX;
3213
- this.pos.y += e.movementY;
3214
- this.setPosition();
3215
- this.$imageStyleTransform.set(`translate(${this.pos.x}px,${this.pos.y}px) scale(${this.scale})`);
3216
- }
3217
- }), takeUntilDestroyed(this.destroyRef))
3218
- .subscribe();
3219
- // -----------------------------
3220
- // MOUSE WHEEL ZOOM
3221
- // -----------------------------
3222
- fromEvent(window, 'wheel', { passive: false })
3223
- .pipe(tap((event) => {
3224
- event.preventDefault();
3225
- const rect = container.getBoundingClientRect();
3226
- if (event.ctrlKey) {
3227
- this.pointer.x = event.clientX - rect.left;
3228
- this.pointer.y = event.clientY - rect.top;
3229
- this.target.x = (this.pointer.x - this.pos.x) / this.scale;
3230
- this.target.y = (this.pointer.y - this.pos.y) / this.scale;
3231
- this.scale += -1 * Math.max(-1, Math.min(1, event.deltaY)) * this.speed * this.scale;
3232
- const maxScale = 4;
3233
- const minScale = 1;
3234
- this.scale = Math.max(minScale, Math.min(maxScale, this.scale));
3235
- this.pos.x = -this.target.x * this.scale + this.pointer.x;
3236
- this.pos.y = -this.target.y * this.scale + this.pointer.y;
3237
- this.setPosition();
3238
- this.$imageStyleTransform.set(`translate(${this.pos.x}px,${this.pos.y}px) scale(${this.scale})`);
3239
- }
3240
- else {
3241
- this.pos.x -= event.deltaX * 2;
3242
- this.pos.y -= event.deltaY * 2;
3243
- }
3244
- }), takeUntilDestroyed(this.destroyRef))
3245
- .subscribe();
3246
- // -----------------------------
3247
- // TOUCH PINCH ZOOM
3248
- // -----------------------------
3249
- fromEvent(container, 'touchstart')
3250
- .pipe(tap((event) => {
3251
- if (event.touches.length === 2) {
3252
- this.isPinching = true;
3253
- const [t1, t2] = event.touches;
3254
- this.lastTouchDistance = Math.hypot(t2.clientX - t1.clientX, t2.clientY - t1.clientY);
3255
- }
3256
- if (event.touches.length === 1 && this.scale > 1) {
3257
- const t = event.touches[0];
3258
- this.lastTouchX = t.clientX;
3259
- this.lastTouchY = t.clientY;
3260
- this.isTouchDragging = true;
3261
- this.$cursor.set('grabbing');
3262
- }
3263
- }), takeUntilDestroyed(this.destroyRef))
3264
- .subscribe();
3265
- fromEvent(container, 'touchmove')
3266
- .pipe(tap((event) => {
3267
- if (this.isPinching && event.touches.length === 2) {
3268
- event.preventDefault();
3269
- const [t1, t2] = event.touches;
3270
- const newDistance = Math.hypot(t2.clientX - t1.clientX, t2.clientY - t1.clientY);
3271
- const delta = newDistance - this.lastTouchDistance;
3272
- this.lastTouchDistance = newDistance;
3273
- const rect = container.getBoundingClientRect();
3274
- const centerX = (t1.clientX + t2.clientX) / 2 - rect.left;
3275
- const centerY = (t1.clientY + t2.clientY) / 2 - rect.top;
3276
- this.pointer.x = centerX;
3277
- this.pointer.y = centerY;
3278
- this.target.x = (this.pointer.x - this.pos.x) / this.scale;
3279
- this.target.y = (this.pointer.y - this.pos.y) / this.scale;
3280
- const pinchSpeed = 0.005;
3281
- this.scale += delta * pinchSpeed * this.scale;
3282
- const maxScale = 4;
3283
- const minScale = 1;
3284
- this.scale = Math.max(minScale, Math.min(maxScale, this.scale));
3285
- this.pos.x = -this.target.x * this.scale + this.pointer.x;
3286
- this.pos.y = -this.target.y * this.scale + this.pointer.y;
3287
- this.setPosition();
3288
- this.$imageStyleTransform.set(`translate(${this.pos.x}px,${this.pos.y}px) scale(${this.scale})`);
3289
- }
3290
- if (this.isTouchDragging && event.touches.length === 1) {
3291
- event.preventDefault();
3292
- const t = event.touches[0];
3293
- const dx = t.clientX - this.lastTouchX;
3294
- const dy = t.clientY - this.lastTouchY;
3295
- this.lastTouchX = t.clientX;
3296
- this.lastTouchY = t.clientY;
3297
- this.pos.x += dx;
3298
- this.pos.y += dy;
3299
- this.setPosition();
3300
- this.$imageStyleTransform.set(`translate(${this.pos.x}px,${this.pos.y}px) scale(${this.scale})`);
3301
- }
3302
- }), takeUntilDestroyed(this.destroyRef))
3303
- .subscribe();
3304
- fromEvent(container, 'touchend')
3305
- .pipe(tap(() => {
3306
- this.isPinching = false;
3307
- this.isTouchDragging = false;
3308
- this.$cursor.set(this.scale > 1 ? 'grab' : 'auto');
3309
- }), takeUntilDestroyed(this.destroyRef))
3310
- .subscribe();
3311
- }
3312
- setPosition() {
3313
- if (this.pos.x > 0)
3314
- this.pos.x = 0;
3315
- if (this.pos.x + this.size.w * this.scale < this.size.w) {
3316
- this.pos.x = -this.size.w * (this.scale - 1);
3317
- }
3318
- if (this.pos.y > 0)
3319
- this.pos.y = 0;
3320
- if (this.pos.y + this.size.h * this.scale < this.size.h) {
3321
- this.pos.y = -this.size.h * (this.scale - 1);
3322
- }
3323
- }
3324
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiPopupImageDirective, deps: [{ token: i0.DestroyRef }], target: i0.ɵɵFactoryTarget.Directive });
3325
- 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 });
3326
- }
3327
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiPopupImageDirective, decorators: [{
3328
- type: Directive,
3329
- args: [{
3330
- selector: 'app-ui-popup-image',
3331
- }]
3332
- }], ctorParameters: () => [{ type: i0.DestroyRef }], propDecorators: { src: [{
3333
- type: Input,
3334
- args: [{ required: true }]
3335
- }], width: [{
3336
- type: Input,
3337
- args: [{ required: true }]
3338
- }], height: [{
3339
- type: Input,
3340
- args: [{ required: true }]
3341
- }], $container: [{ type: i0.ViewChild, args: ['container', { isSignal: true }] }], $image: [{ type: i0.ViewChild, args: ['image', { isSignal: true }] }] } });
3342
-
3343
- class UiPopupBackdropDirective {
3344
- elementRef;
3345
- uiPopupService;
3346
- destroyRef;
3347
- isStaticBackdrop = false;
3348
- constructor(elementRef, uiPopupService, destroyRef) {
3349
- this.elementRef = elementRef;
3350
- this.uiPopupService = uiPopupService;
3351
- this.destroyRef = destroyRef;
3352
- }
3353
- ngOnInit() {
3354
- fromEvent(this.elementRef.nativeElement, 'click')
3355
- .pipe(tap(() => {
3356
- if (this.isStaticBackdrop) {
3357
- return;
3358
- }
3359
- this.uiPopupService.closeAll();
3360
- }), takeUntilDestroyed(this.destroyRef))
3361
- .subscribe();
3362
- }
3363
- 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 });
3364
- 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 });
3365
- }
3366
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiPopupBackdropDirective, decorators: [{
3367
- type: Directive,
3368
- args: [{ selector: 'app-ui-popup-backdrop' }]
3369
- }], ctorParameters: () => [{ type: i0.ElementRef }, { type: UiPopupService }, { type: i0.DestroyRef }], propDecorators: { isStaticBackdrop: [{
3370
- type: Input
3371
- }] } });
3372
-
3373
3563
  const buttonColors = [
3374
3564
  'primary',
3375
3565
  'secondary',