@ibragim-dev-org/ui-forge-library 1.4.3 → 1.4.4
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,
|
|
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) {
|
|
@@ -1999,6 +2189,7 @@ class UiPopupInstance {
|
|
|
1999
2189
|
startTransition: 'scale(0)',
|
|
2000
2190
|
endTransition: 'scale(0)',
|
|
2001
2191
|
};
|
|
2192
|
+
triggerPulse$ = new Subject();
|
|
2002
2193
|
closed = new Subject();
|
|
2003
2194
|
shouldClose = new Subject();
|
|
2004
2195
|
isClosing = false;
|
|
@@ -2038,26 +2229,7 @@ class UiPopupInstance {
|
|
|
2038
2229
|
}
|
|
2039
2230
|
}
|
|
2040
2231
|
|
|
2041
|
-
class
|
|
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 {
|
|
2232
|
+
class UiModal {
|
|
2061
2233
|
overlay;
|
|
2062
2234
|
injector;
|
|
2063
2235
|
destroyRef;
|
|
@@ -2075,40 +2247,6 @@ class UiPopupService {
|
|
|
2075
2247
|
this.router = router;
|
|
2076
2248
|
this.backdropService = backdropService;
|
|
2077
2249
|
}
|
|
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
2250
|
/**
|
|
2113
2251
|
* Closes the last opened popup.
|
|
2114
2252
|
*/
|
|
@@ -2170,7 +2308,7 @@ class UiPopupService {
|
|
|
2170
2308
|
* @param parameters - (Optional) Configuration options for the popup.
|
|
2171
2309
|
*/
|
|
2172
2310
|
createPopup(overlayRef, component, options, id, parameters) {
|
|
2173
|
-
const newParameters = this.
|
|
2311
|
+
const newParameters = this.fetchParameters(parameters);
|
|
2174
2312
|
const uiPopupInstance = new UiPopupInstance(overlayRef, this.destroyRef, options.onClose, newParameters.animationOptions);
|
|
2175
2313
|
if (newParameters.width > 0) {
|
|
2176
2314
|
uiPopupInstance.width = newParameters.width;
|
|
@@ -2201,13 +2339,13 @@ class UiPopupService {
|
|
|
2201
2339
|
fromEvent(window, 'scroll')
|
|
2202
2340
|
.pipe(tap(() => {
|
|
2203
2341
|
this.closeAll();
|
|
2204
|
-
}), takeUntil(this.destroyOutsideClickSubscription$))
|
|
2342
|
+
}), takeUntil$1(this.destroyOutsideClickSubscription$))
|
|
2205
2343
|
.subscribe();
|
|
2206
2344
|
}
|
|
2207
2345
|
this.router.events
|
|
2208
2346
|
.pipe(debounceTime(100), tap(() => {
|
|
2209
2347
|
this.closeAll();
|
|
2210
|
-
}), takeUntil(this.destroyOutsideClickSubscription$))
|
|
2348
|
+
}), takeUntil$1(this.destroyOutsideClickSubscription$))
|
|
2211
2349
|
.subscribe();
|
|
2212
2350
|
}
|
|
2213
2351
|
destroy() {
|
|
@@ -2234,6 +2372,7 @@ class UiPopupService {
|
|
|
2234
2372
|
if (this.backdropPortalRef) {
|
|
2235
2373
|
this.backdropPortalRef.location.nativeElement.classList.add('animate-in');
|
|
2236
2374
|
this.backdropPortalRef.setInput('isStaticBackdrop', isStaticBackdrop);
|
|
2375
|
+
this.backdropPortalRef.setInput('clicked', () => this.popupInstances[this.popupInstances.length - 1].triggerPulse$.next());
|
|
2237
2376
|
}
|
|
2238
2377
|
}
|
|
2239
2378
|
hideBackdrop() {
|
|
@@ -2261,7 +2400,7 @@ class UiPopupService {
|
|
|
2261
2400
|
* @param parameters - Partial configuration options for the popup.
|
|
2262
2401
|
* @returns A complete set of popup parameters with default values applied.
|
|
2263
2402
|
*/
|
|
2264
|
-
|
|
2403
|
+
fetchParameters(parameters) {
|
|
2265
2404
|
return {
|
|
2266
2405
|
animationOptions: parameters.animationOptions === undefined
|
|
2267
2406
|
? {
|
|
@@ -2276,35 +2415,7 @@ class UiPopupService {
|
|
|
2276
2415
|
width: parameters.width === undefined ? 0 : parameters.width,
|
|
2277
2416
|
};
|
|
2278
2417
|
}
|
|
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
2418
|
}
|
|
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
2419
|
|
|
2309
2420
|
class UiPopupContainerDirective {
|
|
2310
2421
|
popupInstance;
|
|
@@ -2360,6 +2471,15 @@ class UiPopupContainerDirective {
|
|
|
2360
2471
|
this.$isShow.set(false);
|
|
2361
2472
|
}), takeUntilDestroyed(this.destroyRef))
|
|
2362
2473
|
.subscribe();
|
|
2474
|
+
this.popupInstance.triggerPulse$
|
|
2475
|
+
.pipe(tap(() => {
|
|
2476
|
+
console.log('pulse');
|
|
2477
|
+
this.$pulseTrigger.set(true);
|
|
2478
|
+
asyncScheduler.schedule(() => {
|
|
2479
|
+
this.$pulseTrigger.set(false);
|
|
2480
|
+
}, 300);
|
|
2481
|
+
}), takeUntilDestroyed(this.destroyRef))
|
|
2482
|
+
.subscribe();
|
|
2363
2483
|
this.popupInstance.animationOrigin$
|
|
2364
2484
|
.pipe(tap((e) => {
|
|
2365
2485
|
this.$animationParams.set({
|
|
@@ -2373,7 +2493,7 @@ class UiPopupContainerDirective {
|
|
|
2373
2493
|
topEnd: '0',
|
|
2374
2494
|
});
|
|
2375
2495
|
this.$isShow.set(true);
|
|
2376
|
-
}), takeUntil(this.destroyAnimationOrigin$), takeUntilDestroyed(this.destroyRef))
|
|
2496
|
+
}), takeUntil$1(this.destroyAnimationOrigin$), takeUntilDestroyed(this.destroyRef))
|
|
2377
2497
|
.subscribe();
|
|
2378
2498
|
if (isBrowser()) {
|
|
2379
2499
|
fromEvent(window, 'keydown')
|
|
@@ -2400,7 +2520,7 @@ class UiPopupContainerDirective {
|
|
|
2400
2520
|
shouldClose() {
|
|
2401
2521
|
this.$shouldClose.set(true);
|
|
2402
2522
|
}
|
|
2403
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiPopupContainerDirective, deps: [{ token: UiPopupInstance }, { token: i0.DestroyRef }, { token:
|
|
2523
|
+
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
2524
|
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
2525
|
}
|
|
2406
2526
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiPopupContainerDirective, decorators: [{
|
|
@@ -2411,134 +2531,480 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
|
|
|
2411
2531
|
}], ctorParameters: () => [{ type: UiPopupInstance, decorators: [{
|
|
2412
2532
|
type: Inject,
|
|
2413
2533
|
args: [UiPopupInstance]
|
|
2414
|
-
}] }, { type: i0.DestroyRef }, { type:
|
|
2534
|
+
}] }, { 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
2535
|
|
|
2416
|
-
class
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
}
|
|
2476
|
-
},
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
}
|
|
2487
|
-
},
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2536
|
+
class UiPopupImageDirective {
|
|
2537
|
+
destroyRef;
|
|
2538
|
+
src = '';
|
|
2539
|
+
width = 0;
|
|
2540
|
+
height = 0;
|
|
2541
|
+
$imageWidth = signal(0, ...(ngDevMode ? [{ debugName: "$imageWidth" }] : []));
|
|
2542
|
+
$imageHeight = signal(0, ...(ngDevMode ? [{ debugName: "$imageHeight" }] : []));
|
|
2543
|
+
$imageStyleTransform = signal('', ...(ngDevMode ? [{ debugName: "$imageStyleTransform" }] : []));
|
|
2544
|
+
$container = viewChild('container', ...(ngDevMode ? [{ debugName: "$container" }] : []));
|
|
2545
|
+
$image = viewChild('image', ...(ngDevMode ? [{ debugName: "$image" }] : []));
|
|
2546
|
+
$cursor = signal('auto', ...(ngDevMode ? [{ debugName: "$cursor" }] : []));
|
|
2547
|
+
isDragging = false;
|
|
2548
|
+
isTouchDragging = false;
|
|
2549
|
+
isPinching = false;
|
|
2550
|
+
lastTouchX = 0;
|
|
2551
|
+
lastTouchY = 0;
|
|
2552
|
+
lastTouchDistance = 0;
|
|
2553
|
+
size = { w: 0, h: 0 };
|
|
2554
|
+
speed = 0.5;
|
|
2555
|
+
pos = { x: 0, y: 0 };
|
|
2556
|
+
target = { x: 0, y: 0 };
|
|
2557
|
+
pointer = { x: 0, y: 0 };
|
|
2558
|
+
scale = 1;
|
|
2559
|
+
constructor(destroyRef) {
|
|
2560
|
+
this.destroyRef = destroyRef;
|
|
2561
|
+
}
|
|
2562
|
+
ngOnInit() {
|
|
2563
|
+
if (!isBrowser()) {
|
|
2564
|
+
this.$imageWidth.set(this.width);
|
|
2565
|
+
this.$imageHeight.set(this.height);
|
|
2566
|
+
return;
|
|
2567
|
+
}
|
|
2568
|
+
const result = getAspectRatioFit(window.innerWidth - window.innerWidth / 8, window.innerHeight - window.innerHeight / 8, this.width, this.height);
|
|
2569
|
+
this.$imageWidth.set(result.width);
|
|
2570
|
+
this.$imageHeight.set(result.height);
|
|
2571
|
+
}
|
|
2572
|
+
ngAfterViewInit() {
|
|
2573
|
+
const container = this.$container()?.nativeElement;
|
|
2574
|
+
if (!container)
|
|
2575
|
+
return;
|
|
2576
|
+
if (!isBrowser())
|
|
2577
|
+
return;
|
|
2578
|
+
this.size = {
|
|
2579
|
+
w: container.offsetWidth,
|
|
2580
|
+
h: container.offsetHeight,
|
|
2581
|
+
};
|
|
2582
|
+
// -----------------------------
|
|
2583
|
+
// KEYBOARD CURSOR LOGIC
|
|
2584
|
+
// -----------------------------
|
|
2585
|
+
fromEvent(window, 'keydown')
|
|
2586
|
+
.pipe(tap((event) => {
|
|
2587
|
+
if (event.ctrlKey)
|
|
2588
|
+
this.$cursor.set('zoom-in');
|
|
2589
|
+
}), takeUntilDestroyed(this.destroyRef))
|
|
2590
|
+
.subscribe();
|
|
2591
|
+
fromEvent(window, 'keyup')
|
|
2592
|
+
.pipe(tap((event) => {
|
|
2593
|
+
if (event.key === 'Control') {
|
|
2594
|
+
this.$cursor.set(this.scale > 1 ? 'grab' : 'auto');
|
|
2595
|
+
}
|
|
2596
|
+
}), takeUntilDestroyed(this.destroyRef))
|
|
2597
|
+
.subscribe();
|
|
2598
|
+
// -----------------------------
|
|
2599
|
+
// MOUSE DRAG
|
|
2600
|
+
// -----------------------------
|
|
2601
|
+
fromEvent(window, 'mouseup')
|
|
2602
|
+
.pipe(tap((event) => {
|
|
2603
|
+
if (event.button === 0) {
|
|
2604
|
+
this.isDragging = false;
|
|
2605
|
+
this.$cursor.set(this.scale > 1 ? 'grab' : 'auto');
|
|
2606
|
+
}
|
|
2607
|
+
}), takeUntilDestroyed(this.destroyRef))
|
|
2608
|
+
.subscribe();
|
|
2609
|
+
fromEvent(container, 'mousedown')
|
|
2610
|
+
.pipe(tap((event) => {
|
|
2611
|
+
if (event.button === 0) {
|
|
2612
|
+
event.preventDefault();
|
|
2613
|
+
this.isDragging = true;
|
|
2614
|
+
this.$cursor.set(this.scale > 1 ? 'grabbing' : 'auto');
|
|
2615
|
+
}
|
|
2616
|
+
}), takeUntilDestroyed(this.destroyRef))
|
|
2617
|
+
.subscribe();
|
|
2618
|
+
fromEvent(window, 'mousemove')
|
|
2619
|
+
.pipe(tap((e) => {
|
|
2620
|
+
if (this.isDragging && this.scale > 1) {
|
|
2621
|
+
this.pos.x += e.movementX;
|
|
2622
|
+
this.pos.y += e.movementY;
|
|
2623
|
+
this.setPosition();
|
|
2624
|
+
this.$imageStyleTransform.set(`translate(${this.pos.x}px,${this.pos.y}px) scale(${this.scale})`);
|
|
2625
|
+
}
|
|
2626
|
+
}), takeUntilDestroyed(this.destroyRef))
|
|
2627
|
+
.subscribe();
|
|
2628
|
+
// -----------------------------
|
|
2629
|
+
// MOUSE WHEEL ZOOM
|
|
2630
|
+
// -----------------------------
|
|
2631
|
+
fromEvent(window, 'wheel', { passive: false })
|
|
2632
|
+
.pipe(tap((event) => {
|
|
2633
|
+
event.preventDefault();
|
|
2634
|
+
const rect = container.getBoundingClientRect();
|
|
2635
|
+
if (event.ctrlKey) {
|
|
2636
|
+
this.pointer.x = event.clientX - rect.left;
|
|
2637
|
+
this.pointer.y = event.clientY - rect.top;
|
|
2638
|
+
this.target.x = (this.pointer.x - this.pos.x) / this.scale;
|
|
2639
|
+
this.target.y = (this.pointer.y - this.pos.y) / this.scale;
|
|
2640
|
+
this.scale += -1 * Math.max(-1, Math.min(1, event.deltaY)) * this.speed * this.scale;
|
|
2641
|
+
const maxScale = 4;
|
|
2642
|
+
const minScale = 1;
|
|
2643
|
+
this.scale = Math.max(minScale, Math.min(maxScale, this.scale));
|
|
2644
|
+
this.pos.x = -this.target.x * this.scale + this.pointer.x;
|
|
2645
|
+
this.pos.y = -this.target.y * this.scale + this.pointer.y;
|
|
2646
|
+
this.setPosition();
|
|
2647
|
+
this.$imageStyleTransform.set(`translate(${this.pos.x}px,${this.pos.y}px) scale(${this.scale})`);
|
|
2648
|
+
}
|
|
2649
|
+
else {
|
|
2650
|
+
this.pos.x -= event.deltaX * 2;
|
|
2651
|
+
this.pos.y -= event.deltaY * 2;
|
|
2652
|
+
}
|
|
2653
|
+
}), takeUntilDestroyed(this.destroyRef))
|
|
2654
|
+
.subscribe();
|
|
2655
|
+
// -----------------------------
|
|
2656
|
+
// TOUCH PINCH ZOOM
|
|
2657
|
+
// -----------------------------
|
|
2658
|
+
fromEvent(container, 'touchstart')
|
|
2659
|
+
.pipe(tap((event) => {
|
|
2660
|
+
if (event.touches.length === 2) {
|
|
2661
|
+
this.isPinching = true;
|
|
2662
|
+
const [t1, t2] = event.touches;
|
|
2663
|
+
this.lastTouchDistance = Math.hypot(t2.clientX - t1.clientX, t2.clientY - t1.clientY);
|
|
2664
|
+
}
|
|
2665
|
+
if (event.touches.length === 1 && this.scale > 1) {
|
|
2666
|
+
const t = event.touches[0];
|
|
2667
|
+
this.lastTouchX = t.clientX;
|
|
2668
|
+
this.lastTouchY = t.clientY;
|
|
2669
|
+
this.isTouchDragging = true;
|
|
2670
|
+
this.$cursor.set('grabbing');
|
|
2671
|
+
}
|
|
2672
|
+
}), takeUntilDestroyed(this.destroyRef))
|
|
2673
|
+
.subscribe();
|
|
2674
|
+
fromEvent(container, 'touchmove')
|
|
2675
|
+
.pipe(tap((event) => {
|
|
2676
|
+
if (this.isPinching && event.touches.length === 2) {
|
|
2677
|
+
event.preventDefault();
|
|
2678
|
+
const [t1, t2] = event.touches;
|
|
2679
|
+
const newDistance = Math.hypot(t2.clientX - t1.clientX, t2.clientY - t1.clientY);
|
|
2680
|
+
const delta = newDistance - this.lastTouchDistance;
|
|
2681
|
+
this.lastTouchDistance = newDistance;
|
|
2682
|
+
const rect = container.getBoundingClientRect();
|
|
2683
|
+
const centerX = (t1.clientX + t2.clientX) / 2 - rect.left;
|
|
2684
|
+
const centerY = (t1.clientY + t2.clientY) / 2 - rect.top;
|
|
2685
|
+
this.pointer.x = centerX;
|
|
2686
|
+
this.pointer.y = centerY;
|
|
2687
|
+
this.target.x = (this.pointer.x - this.pos.x) / this.scale;
|
|
2688
|
+
this.target.y = (this.pointer.y - this.pos.y) / this.scale;
|
|
2689
|
+
const pinchSpeed = 0.005;
|
|
2690
|
+
this.scale += delta * pinchSpeed * this.scale;
|
|
2691
|
+
const maxScale = 4;
|
|
2692
|
+
const minScale = 1;
|
|
2693
|
+
this.scale = Math.max(minScale, Math.min(maxScale, this.scale));
|
|
2694
|
+
this.pos.x = -this.target.x * this.scale + this.pointer.x;
|
|
2695
|
+
this.pos.y = -this.target.y * this.scale + this.pointer.y;
|
|
2696
|
+
this.setPosition();
|
|
2697
|
+
this.$imageStyleTransform.set(`translate(${this.pos.x}px,${this.pos.y}px) scale(${this.scale})`);
|
|
2698
|
+
}
|
|
2699
|
+
if (this.isTouchDragging && event.touches.length === 1) {
|
|
2700
|
+
event.preventDefault();
|
|
2701
|
+
const t = event.touches[0];
|
|
2702
|
+
const dx = t.clientX - this.lastTouchX;
|
|
2703
|
+
const dy = t.clientY - this.lastTouchY;
|
|
2704
|
+
this.lastTouchX = t.clientX;
|
|
2705
|
+
this.lastTouchY = t.clientY;
|
|
2706
|
+
this.pos.x += dx;
|
|
2707
|
+
this.pos.y += dy;
|
|
2708
|
+
this.setPosition();
|
|
2709
|
+
this.$imageStyleTransform.set(`translate(${this.pos.x}px,${this.pos.y}px) scale(${this.scale})`);
|
|
2710
|
+
}
|
|
2711
|
+
}), takeUntilDestroyed(this.destroyRef))
|
|
2712
|
+
.subscribe();
|
|
2713
|
+
fromEvent(container, 'touchend')
|
|
2714
|
+
.pipe(tap(() => {
|
|
2715
|
+
this.isPinching = false;
|
|
2716
|
+
this.isTouchDragging = false;
|
|
2717
|
+
this.$cursor.set(this.scale > 1 ? 'grab' : 'auto');
|
|
2718
|
+
}), takeUntilDestroyed(this.destroyRef))
|
|
2719
|
+
.subscribe();
|
|
2720
|
+
}
|
|
2721
|
+
setPosition() {
|
|
2722
|
+
if (this.pos.x > 0)
|
|
2723
|
+
this.pos.x = 0;
|
|
2724
|
+
if (this.pos.x + this.size.w * this.scale < this.size.w) {
|
|
2725
|
+
this.pos.x = -this.size.w * (this.scale - 1);
|
|
2726
|
+
}
|
|
2727
|
+
if (this.pos.y > 0)
|
|
2728
|
+
this.pos.y = 0;
|
|
2729
|
+
if (this.pos.y + this.size.h * this.scale < this.size.h) {
|
|
2730
|
+
this.pos.y = -this.size.h * (this.scale - 1);
|
|
2731
|
+
}
|
|
2732
|
+
}
|
|
2733
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiPopupImageDirective, deps: [{ token: i0.DestroyRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
2734
|
+
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 });
|
|
2735
|
+
}
|
|
2736
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiPopupImageDirective, decorators: [{
|
|
2737
|
+
type: Directive,
|
|
2738
|
+
args: [{
|
|
2739
|
+
selector: 'app-ui-popup-image',
|
|
2740
|
+
}]
|
|
2741
|
+
}], ctorParameters: () => [{ type: i0.DestroyRef }], propDecorators: { src: [{
|
|
2742
|
+
type: Input,
|
|
2743
|
+
args: [{ required: true }]
|
|
2744
|
+
}], width: [{
|
|
2745
|
+
type: Input,
|
|
2746
|
+
args: [{ required: true }]
|
|
2747
|
+
}], height: [{
|
|
2748
|
+
type: Input,
|
|
2749
|
+
args: [{ required: true }]
|
|
2750
|
+
}], $container: [{ type: i0.ViewChild, args: ['container', { isSignal: true }] }], $image: [{ type: i0.ViewChild, args: ['image', { isSignal: true }] }] } });
|
|
2751
|
+
|
|
2752
|
+
class UiPopupBackdropService {
|
|
2753
|
+
tipContainerPortal;
|
|
2754
|
+
backdropPortal;
|
|
2755
|
+
constructor(component, tipComponent) {
|
|
2756
|
+
this.backdropPortal = new ComponentPortal(component);
|
|
2757
|
+
if (tipComponent) {
|
|
2758
|
+
this.tipContainerPortal = new ComponentPortal(tipComponent);
|
|
2759
|
+
}
|
|
2760
|
+
}
|
|
2761
|
+
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 });
|
|
2762
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiPopupBackdropService, providedIn: 'root' });
|
|
2763
|
+
}
|
|
2764
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiPopupBackdropService, decorators: [{
|
|
2765
|
+
type: Injectable,
|
|
2766
|
+
args: [{
|
|
2767
|
+
providedIn: 'root',
|
|
2768
|
+
}]
|
|
2769
|
+
}], ctorParameters: () => [{ type: i0.Type }, { type: i0.Type }] });
|
|
2770
|
+
|
|
2771
|
+
class UiPopupService extends UiModal {
|
|
2772
|
+
constructor(overlay, injector, destroyRef, router, backdropService) {
|
|
2773
|
+
super(overlay, injector, destroyRef, router, backdropService);
|
|
2774
|
+
}
|
|
2775
|
+
/**
|
|
2776
|
+
* Opens a popup with the specified component and options.
|
|
2777
|
+
*
|
|
2778
|
+
* @param component - The component to be displayed in the popup.
|
|
2779
|
+
* @param options - Configuration options for the popup, including inputs.
|
|
2780
|
+
* @param id - A unique identifier for the popup instance.
|
|
2781
|
+
* @param parameters - (Optional) Configuration options for the popup.
|
|
2782
|
+
*/
|
|
2783
|
+
open(component, options, id, parameters) {
|
|
2784
|
+
if (this.popupInstances.length) {
|
|
2785
|
+
this.closePrevious(parameters.isClosePrevious);
|
|
2786
|
+
}
|
|
2787
|
+
this.showBackdrop(parameters.isStaticBackdrop);
|
|
2788
|
+
const overlayRef = this.overlay.create({
|
|
2789
|
+
hasBackdrop: false,
|
|
2790
|
+
backdropClass: 'cdk-overlay-transparent-backdrop',
|
|
2791
|
+
positionStrategy: this.overlay.position().global().centerHorizontally().centerVertically(),
|
|
2792
|
+
});
|
|
2793
|
+
this.subscribeToOutsideEvents();
|
|
2794
|
+
this.createPopup(overlayRef, component, options, id, parameters);
|
|
2795
|
+
}
|
|
2796
|
+
closePrevious(isClosePrevious) {
|
|
2797
|
+
if (this.popupInstances.length >= 1) {
|
|
2798
|
+
if (isClosePrevious) {
|
|
2799
|
+
this.popupInstances[this.popupInstances.length - 1].close();
|
|
2800
|
+
this.popupInstances.pop();
|
|
2801
|
+
}
|
|
2802
|
+
}
|
|
2803
|
+
}
|
|
2804
|
+
/**
|
|
2805
|
+
* Opens a popup that scales from the provided origin element to the centered popup size.
|
|
2806
|
+
* Useful for image-preview transitions where the source element animates into the popup.
|
|
2807
|
+
*/
|
|
2808
|
+
openScaledFromElement(component, options, id, originElement, sourceWidth, sourceHeight, parameters = {}) {
|
|
2809
|
+
const animationOptions = this.createScaleAnimationOptionsFromElement(originElement, sourceWidth, sourceHeight);
|
|
2810
|
+
this.open(component, options, id, {
|
|
2811
|
+
...parameters,
|
|
2812
|
+
animationOptions,
|
|
2813
|
+
});
|
|
2814
|
+
}
|
|
2815
|
+
createScaleAnimationOptionsFromElement(originElement, sourceWidth, sourceHeight) {
|
|
2816
|
+
const rect = originElement.getBoundingClientRect();
|
|
2817
|
+
const viewportWidth = isBrowser() ? window.innerWidth : sourceWidth;
|
|
2818
|
+
const viewportHeight = isBrowser() ? window.innerHeight : sourceHeight;
|
|
2819
|
+
const centerX = viewportWidth / 2;
|
|
2820
|
+
const centerY = viewportHeight / 2;
|
|
2821
|
+
const targetX = rect.left + rect.width / 2;
|
|
2822
|
+
const targetY = rect.top + rect.height / 2;
|
|
2823
|
+
const offsetX = targetX - centerX;
|
|
2824
|
+
const offsetY = targetY - centerY;
|
|
2825
|
+
const fitted = getAspectRatioFit(viewportWidth - viewportWidth / 8, viewportHeight - viewportHeight / 8, sourceWidth, sourceHeight);
|
|
2826
|
+
const scaleY = Math.trunc((sourceHeight / fitted.height) * 100) / 100;
|
|
2827
|
+
const scaleX = Math.trunc((sourceWidth / fitted.width) * 100) / 100;
|
|
2828
|
+
return {
|
|
2829
|
+
positionX: offsetX,
|
|
2830
|
+
positionY: offsetY,
|
|
2831
|
+
startTransition: `scale(${scaleY}, ${scaleX})`,
|
|
2832
|
+
endTransition: 'scale(1)',
|
|
2833
|
+
};
|
|
2834
|
+
}
|
|
2835
|
+
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 });
|
|
2836
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiPopupService, providedIn: 'root' });
|
|
2837
|
+
}
|
|
2838
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiPopupService, decorators: [{
|
|
2839
|
+
type: Injectable,
|
|
2840
|
+
args: [{
|
|
2841
|
+
providedIn: 'root',
|
|
2842
|
+
}]
|
|
2843
|
+
}], ctorParameters: () => [{ type: i1.Overlay }, { type: i0.Injector }, { type: i0.DestroyRef }, { type: i2$1.Router }, { type: UiPopupBackdropService }] });
|
|
2844
|
+
|
|
2845
|
+
class UiPopupBackdropDirective {
|
|
2846
|
+
elementRef;
|
|
2847
|
+
uiPopupService;
|
|
2848
|
+
destroyRef;
|
|
2849
|
+
isStaticBackdrop = false;
|
|
2850
|
+
clicked = () => { };
|
|
2851
|
+
constructor(elementRef, uiPopupService, destroyRef) {
|
|
2852
|
+
this.elementRef = elementRef;
|
|
2853
|
+
this.uiPopupService = uiPopupService;
|
|
2854
|
+
this.destroyRef = destroyRef;
|
|
2855
|
+
}
|
|
2856
|
+
ngOnInit() {
|
|
2857
|
+
fromEvent(this.elementRef.nativeElement, 'click')
|
|
2858
|
+
.pipe(tap(() => {
|
|
2859
|
+
if (this.isStaticBackdrop) {
|
|
2860
|
+
this.clicked();
|
|
2861
|
+
return;
|
|
2862
|
+
}
|
|
2863
|
+
this.uiPopupService.closeAll();
|
|
2864
|
+
}), takeUntilDestroyed(this.destroyRef))
|
|
2865
|
+
.subscribe();
|
|
2866
|
+
}
|
|
2867
|
+
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 });
|
|
2868
|
+
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 });
|
|
2869
|
+
}
|
|
2870
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiPopupBackdropDirective, decorators: [{
|
|
2871
|
+
type: Directive,
|
|
2872
|
+
args: [{ selector: 'app-ui-popup-backdrop' }]
|
|
2873
|
+
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: UiPopupService }, { type: i0.DestroyRef }], propDecorators: { isStaticBackdrop: [{
|
|
2874
|
+
type: Input
|
|
2875
|
+
}], clicked: [{
|
|
2876
|
+
type: Input
|
|
2877
|
+
}] } });
|
|
2878
|
+
|
|
2879
|
+
class UiDropdownService extends UiModal {
|
|
2880
|
+
containerSize$ = new BehaviorSubject({
|
|
2881
|
+
width: 0,
|
|
2882
|
+
height: 0,
|
|
2883
|
+
});
|
|
2884
|
+
connectedPositions = {
|
|
2885
|
+
bottom: {
|
|
2886
|
+
animationOrigin: 'top center',
|
|
2887
|
+
connectedPosition: {
|
|
2888
|
+
originX: 'center',
|
|
2889
|
+
originY: 'bottom',
|
|
2890
|
+
overlayX: 'center',
|
|
2891
|
+
overlayY: 'top',
|
|
2892
|
+
offsetY: 0,
|
|
2893
|
+
offsetX: 0,
|
|
2894
|
+
},
|
|
2895
|
+
},
|
|
2896
|
+
top: {
|
|
2897
|
+
animationOrigin: 'bottom center',
|
|
2898
|
+
connectedPosition: {
|
|
2899
|
+
originX: 'center',
|
|
2900
|
+
originY: 'top',
|
|
2901
|
+
overlayX: 'center',
|
|
2902
|
+
overlayY: 'bottom',
|
|
2903
|
+
offsetY: 0,
|
|
2904
|
+
offsetX: 0,
|
|
2905
|
+
},
|
|
2906
|
+
},
|
|
2907
|
+
center: {
|
|
2908
|
+
animationOrigin: 'center center',
|
|
2909
|
+
connectedPosition: {
|
|
2910
|
+
originX: 'center',
|
|
2911
|
+
originY: 'center',
|
|
2912
|
+
overlayX: 'center',
|
|
2913
|
+
overlayY: 'center',
|
|
2914
|
+
offsetY: 0,
|
|
2915
|
+
offsetX: 0,
|
|
2916
|
+
},
|
|
2917
|
+
},
|
|
2918
|
+
left: {
|
|
2919
|
+
animationOrigin: 'right center',
|
|
2920
|
+
connectedPosition: {
|
|
2921
|
+
originX: 'start',
|
|
2922
|
+
originY: 'center',
|
|
2923
|
+
overlayX: 'end',
|
|
2924
|
+
overlayY: 'center',
|
|
2925
|
+
offsetY: 0,
|
|
2926
|
+
offsetX: 0,
|
|
2927
|
+
},
|
|
2928
|
+
},
|
|
2929
|
+
right: {
|
|
2930
|
+
animationOrigin: 'left center',
|
|
2931
|
+
connectedPosition: {
|
|
2932
|
+
originX: 'end',
|
|
2933
|
+
originY: 'center',
|
|
2934
|
+
overlayX: 'start',
|
|
2935
|
+
overlayY: 'center',
|
|
2936
|
+
offsetY: 0,
|
|
2937
|
+
offsetX: 0,
|
|
2938
|
+
},
|
|
2939
|
+
},
|
|
2940
|
+
'right-top': {
|
|
2941
|
+
animationOrigin: 'left bottom',
|
|
2942
|
+
connectedPosition: {
|
|
2943
|
+
originX: 'end',
|
|
2944
|
+
originY: 'top',
|
|
2945
|
+
overlayX: 'start',
|
|
2946
|
+
overlayY: 'bottom',
|
|
2947
|
+
offsetY: 0,
|
|
2948
|
+
offsetX: 0,
|
|
2949
|
+
},
|
|
2950
|
+
},
|
|
2951
|
+
'right-bottom': {
|
|
2952
|
+
animationOrigin: 'left top',
|
|
2953
|
+
connectedPosition: {
|
|
2954
|
+
originX: 'end',
|
|
2955
|
+
originY: 'bottom',
|
|
2956
|
+
overlayX: 'start',
|
|
2957
|
+
overlayY: 'top',
|
|
2958
|
+
offsetY: 0,
|
|
2959
|
+
offsetX: 0,
|
|
2960
|
+
},
|
|
2961
|
+
},
|
|
2962
|
+
'left-top': {
|
|
2963
|
+
animationOrigin: 'right bottom',
|
|
2964
|
+
connectedPosition: {
|
|
2965
|
+
originX: 'start',
|
|
2966
|
+
originY: 'top',
|
|
2967
|
+
overlayX: 'end',
|
|
2968
|
+
overlayY: 'bottom',
|
|
2969
|
+
offsetY: 0,
|
|
2970
|
+
offsetX: 0,
|
|
2971
|
+
},
|
|
2972
|
+
},
|
|
2973
|
+
'left-bottom': {
|
|
2974
|
+
animationOrigin: 'right top',
|
|
2975
|
+
connectedPosition: {
|
|
2976
|
+
originX: 'start',
|
|
2977
|
+
originY: 'bottom',
|
|
2978
|
+
overlayX: 'end',
|
|
2979
|
+
overlayY: 'top',
|
|
2980
|
+
offsetY: 0,
|
|
2981
|
+
offsetX: 0,
|
|
2982
|
+
},
|
|
2983
|
+
},
|
|
2984
|
+
};
|
|
2985
|
+
constructor(overlay, injector, destroyRef, router, backdropService) {
|
|
2986
|
+
super(overlay, injector, destroyRef, router, backdropService);
|
|
2987
|
+
}
|
|
2988
|
+
/**
|
|
2989
|
+
* Opens a tooltip (tip) component attached to a specific HTML element.
|
|
2990
|
+
* The tooltip displays text content with customizable position and offset.
|
|
2991
|
+
*
|
|
2992
|
+
* @param text - The text content to display in the tooltip.
|
|
2993
|
+
* @param attachedRef - The HTML element to which the tooltip is attached.
|
|
2994
|
+
* @param id - A unique identifier for the tooltip instance.
|
|
2995
|
+
* @param position - (Optional) The positioning of the tooltip relative to the attached element (default: 'top').
|
|
2996
|
+
* Available positions: 'top', 'bottom', 'left', 'right', 'center',
|
|
2997
|
+
* 'left-top', 'left-bottom', 'right-top', 'right-bottom'.
|
|
2998
|
+
* @param offsetY - (Optional) Vertical offset for tooltip positioning in pixels (default: 0).
|
|
2999
|
+
* @param offsetX - (Optional) Horizontal offset for tooltip positioning in pixels (default: 0).
|
|
3000
|
+
*
|
|
3001
|
+
*/
|
|
3002
|
+
openTip(text, attachedRef, id, position = 'top', offsetY = 0, offsetX = 0) {
|
|
3003
|
+
if (!this.backdropService.tipContainerPortal) {
|
|
3004
|
+
throw new Error('[UiDropdownService] Tip component is not defined. ' +
|
|
3005
|
+
'inject(UiPopupBackdropService) during application startup (e.g. in `app.config.ts`) to enable tip rendering.');
|
|
3006
|
+
}
|
|
3007
|
+
const tipComponent = this.backdropService.tipContainerPortal?.component;
|
|
2542
3008
|
if (tipComponent) {
|
|
2543
3009
|
this.openAttached(tipComponent, attachedRef, id, {
|
|
2544
3010
|
options: {
|
|
@@ -2639,7 +3105,7 @@ class UiDropdownService extends UiPopupService {
|
|
|
2639
3105
|
positionStrategy.setOrigin({ x: positionAdjustment.left, y: positionAdjustment.top });
|
|
2640
3106
|
overlayRef.updatePosition();
|
|
2641
3107
|
}
|
|
2642
|
-
}), takeUntil(this.destroyOutsideClickSubscription$))
|
|
3108
|
+
}), takeUntil$1(this.destroyOutsideClickSubscription$))
|
|
2643
3109
|
.subscribe();
|
|
2644
3110
|
}
|
|
2645
3111
|
/**
|
|
@@ -2726,7 +3192,7 @@ class UiDropdownService extends UiPopupService {
|
|
|
2726
3192
|
timer(150)
|
|
2727
3193
|
.pipe(switchMap(() => overlayRef.outsidePointerEvents()), tap(() => {
|
|
2728
3194
|
this.closeAll();
|
|
2729
|
-
}), takeUntil(this.destroyOutsideClickSubscription$))
|
|
3195
|
+
}), takeUntil$1(this.destroyOutsideClickSubscription$))
|
|
2730
3196
|
.subscribe();
|
|
2731
3197
|
}
|
|
2732
3198
|
/**
|
|
@@ -2768,7 +3234,7 @@ class UiDropdownService extends UiPopupService {
|
|
|
2768
3234
|
},
|
|
2769
3235
|
]);
|
|
2770
3236
|
}
|
|
2771
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiDropdownService, deps:
|
|
3237
|
+
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
3238
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiDropdownService, providedIn: 'root' });
|
|
2773
3239
|
}
|
|
2774
3240
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiDropdownService, decorators: [{
|
|
@@ -2776,7 +3242,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
|
|
|
2776
3242
|
args: [{
|
|
2777
3243
|
providedIn: 'root',
|
|
2778
3244
|
}]
|
|
2779
|
-
}] });
|
|
3245
|
+
}], ctorParameters: () => [{ type: i1.Overlay }, { type: i0.Injector }, { type: i0.DestroyRef }, { type: i2$1.Router }, { type: UiPopupBackdropService }] });
|
|
2780
3246
|
|
|
2781
3247
|
class UiDropdownContainerDirective extends UiPopupContainerDirective {
|
|
2782
3248
|
dropDownService;
|
|
@@ -3005,252 +3471,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
|
|
|
3005
3471
|
}]
|
|
3006
3472
|
}], 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
3473
|
|
|
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
3474
|
const buttonColors = [
|
|
3255
3475
|
'primary',
|
|
3256
3476
|
'secondary',
|
|
@@ -3425,7 +3645,7 @@ class UiCopyButtonDirective {
|
|
|
3425
3645
|
timer(5000)
|
|
3426
3646
|
.pipe(tap(() => {
|
|
3427
3647
|
this.$isCopied.set(false);
|
|
3428
|
-
}), takeUntil(this.destroyTimer$), takeUntilDestroyed(this.destroyRef))
|
|
3648
|
+
}), takeUntil$1(this.destroyTimer$), takeUntilDestroyed(this.destroyRef))
|
|
3429
3649
|
.subscribe();
|
|
3430
3650
|
})
|
|
3431
3651
|
.catch((err) => {
|
|
@@ -4370,5 +4590,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
|
|
|
4370
4590
|
* Generated bundle index. Do not edit.
|
|
4371
4591
|
*/
|
|
4372
4592
|
|
|
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 };
|
|
4593
|
+
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
4594
|
//# sourceMappingURL=ibragim-dev-org-ui-forge-library.mjs.map
|