@ibragim-dev-org/ui-forge-library 1.4.22 → 1.4.31
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,8 +1,8 @@
|
|
|
1
1
|
import * as i2$1 from '@angular/router';
|
|
2
2
|
import { NavigationEnd, NavigationStart, ActivationEnd } from '@angular/router';
|
|
3
|
-
import { BehaviorSubject, filter, take, scheduled, fromEvent, asyncScheduler, mergeAll, tap, debounceTime, Subscription, timer, switchMap, interval, takeWhile, finalize, Subject, takeUntil } from 'rxjs';
|
|
3
|
+
import { BehaviorSubject, filter, take, scheduled, fromEvent, asyncScheduler, mergeAll, tap, debounceTime, throttleTime, Subscription, timer, switchMap, interval, takeWhile, finalize, Subject, takeUntil } from 'rxjs';
|
|
4
4
|
import * as i0 from '@angular/core';
|
|
5
|
-
import { model, effect, Directive, output, Input, input, PLATFORM_ID, Inject, EventEmitter, Output, Pipe,
|
|
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';
|
|
6
6
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
7
7
|
import { isPlatformBrowser, DOCUMENT, NgStyle } from '@angular/common';
|
|
8
8
|
import * as i2 from '@angular/platform-browser';
|
|
@@ -397,61 +397,81 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
|
|
|
397
397
|
}]
|
|
398
398
|
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.DestroyRef }], propDecorators: { $focus: [{ type: i0.Input, args: [{ isSignal: true, alias: "appFocus", required: false }] }, { type: i0.Output, args: ["appFocusChange"] }] } });
|
|
399
399
|
|
|
400
|
+
class LazyImageService {
|
|
401
|
+
observer;
|
|
402
|
+
getObserver() {
|
|
403
|
+
if (!this.observer) {
|
|
404
|
+
this.observer = new IntersectionObserver((entries) => {
|
|
405
|
+
entries.forEach((entry) => {
|
|
406
|
+
const img = entry.target;
|
|
407
|
+
if (entry.isIntersecting) {
|
|
408
|
+
const src = img.getAttribute('data-src');
|
|
409
|
+
if (src)
|
|
410
|
+
img.src = src;
|
|
411
|
+
this.observer?.unobserve(img);
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
return this.observer;
|
|
417
|
+
}
|
|
418
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: LazyImageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
419
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: LazyImageService, providedIn: 'root' });
|
|
420
|
+
}
|
|
421
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: LazyImageService, decorators: [{
|
|
422
|
+
type: Injectable,
|
|
423
|
+
args: [{ providedIn: 'root' }]
|
|
424
|
+
}] });
|
|
425
|
+
|
|
400
426
|
class LazyImgDirective {
|
|
401
427
|
el;
|
|
428
|
+
lazyService;
|
|
402
429
|
lazySrc;
|
|
403
430
|
loadError = output();
|
|
404
431
|
loaded = output();
|
|
405
|
-
outOfView = output(); // emits when scrolled out
|
|
406
|
-
destroyed = output(); // emits when Angular destroys
|
|
407
432
|
observer;
|
|
408
|
-
|
|
433
|
+
onError = () => {
|
|
434
|
+
this.loadError.emit();
|
|
435
|
+
};
|
|
436
|
+
onLoad = () => {
|
|
437
|
+
this.loaded.emit();
|
|
438
|
+
};
|
|
439
|
+
constructor(el, lazyService) {
|
|
409
440
|
this.el = el;
|
|
441
|
+
this.lazyService = lazyService;
|
|
410
442
|
}
|
|
411
443
|
ngOnInit() {
|
|
412
444
|
const img = this.el.nativeElement;
|
|
413
445
|
const lazySrc = this.lazySrc?.trim() ?? '';
|
|
414
|
-
if (
|
|
446
|
+
if (lazySrc.length === 0 || /(?:^|\/)null(?:[?#].*)?$/i.test(lazySrc)) {
|
|
415
447
|
this.loadError.emit();
|
|
416
448
|
return;
|
|
417
449
|
}
|
|
418
|
-
img.addEventListener('error',
|
|
419
|
-
img.addEventListener('load',
|
|
450
|
+
img.addEventListener('error', this.onError);
|
|
451
|
+
img.addEventListener('load', this.onLoad);
|
|
420
452
|
img.setAttribute('data-src', lazySrc);
|
|
421
|
-
this.observer =
|
|
422
|
-
entries.forEach((entry) => {
|
|
423
|
-
if (entry.isIntersecting) {
|
|
424
|
-
const src = img.getAttribute('data-src');
|
|
425
|
-
if (src && img.src !== src) {
|
|
426
|
-
img.src = src;
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
else {
|
|
430
|
-
this.outOfView.emit();
|
|
431
|
-
// optional: unload to force reload later
|
|
432
|
-
// img.removeAttribute('src');
|
|
433
|
-
}
|
|
434
|
-
});
|
|
435
|
-
}, { threshold: 0.1 });
|
|
453
|
+
this.observer = this.lazyService.getObserver();
|
|
436
454
|
this.observer.observe(img);
|
|
437
455
|
}
|
|
438
456
|
ngOnDestroy() {
|
|
439
457
|
const img = this.el.nativeElement;
|
|
440
|
-
this.observer
|
|
441
|
-
|
|
442
|
-
|
|
458
|
+
if (this.observer) {
|
|
459
|
+
this.observer.unobserve(img);
|
|
460
|
+
}
|
|
461
|
+
img.removeEventListener('error', this.onError);
|
|
462
|
+
img.removeEventListener('load', this.onLoad);
|
|
443
463
|
}
|
|
444
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: LazyImgDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
445
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.1.1", type: LazyImgDirective, isStandalone: true, selector: "img[lazySrc]", inputs: { lazySrc: "lazySrc" }, outputs: { loadError: "loadError", loaded: "loaded"
|
|
464
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: LazyImgDirective, deps: [{ token: i0.ElementRef }, { token: LazyImageService }], target: i0.ɵɵFactoryTarget.Directive });
|
|
465
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.1.1", type: LazyImgDirective, isStandalone: true, selector: "img[lazySrc]", inputs: { lazySrc: "lazySrc" }, outputs: { loadError: "loadError", loaded: "loaded" }, ngImport: i0 });
|
|
446
466
|
}
|
|
447
467
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: LazyImgDirective, decorators: [{
|
|
448
468
|
type: Directive,
|
|
449
469
|
args: [{
|
|
450
470
|
selector: 'img[lazySrc]',
|
|
451
471
|
}]
|
|
452
|
-
}], ctorParameters: () => [{ type: i0.ElementRef }], propDecorators: { lazySrc: [{
|
|
472
|
+
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: LazyImageService }], propDecorators: { lazySrc: [{
|
|
453
473
|
type: Input
|
|
454
|
-
}], loadError: [{ type: i0.Output, args: ["loadError"] }], loaded: [{ type: i0.Output, args: ["loaded"] }]
|
|
474
|
+
}], loadError: [{ type: i0.Output, args: ["loadError"] }], loaded: [{ type: i0.Output, args: ["loaded"] }] } });
|
|
455
475
|
|
|
456
476
|
class MaskGradientDirective {
|
|
457
477
|
elementRef;
|
|
@@ -764,6 +784,66 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
|
|
|
764
784
|
args: [PLATFORM_ID]
|
|
765
785
|
}] }], propDecorators: { sizeChange: [{ type: i0.Output, args: ["sizeChange"] }] } });
|
|
766
786
|
|
|
787
|
+
class StableScrollDirective {
|
|
788
|
+
host;
|
|
789
|
+
el;
|
|
790
|
+
lastScrollHeight = 0;
|
|
791
|
+
/** Emit when user reaches top threshold */
|
|
792
|
+
reachedTop = output();
|
|
793
|
+
/** Emit when user reaches bottom threshold */
|
|
794
|
+
reachedBottom = output();
|
|
795
|
+
/** Top threshold in px or percentage (0–1). Default: 0 (exact top). */
|
|
796
|
+
$topThreshold = input(0, ...(ngDevMode ? [{ debugName: "$topThreshold" }] : []));
|
|
797
|
+
/** Bottom threshold in px or percentage (0–1). Default: 0 (exact bottom). */
|
|
798
|
+
$bottomThreshold = input(0, ...(ngDevMode ? [{ debugName: "$bottomThreshold" }] : []));
|
|
799
|
+
constructor(host) {
|
|
800
|
+
this.host = host;
|
|
801
|
+
this.el = this.host.nativeElement;
|
|
802
|
+
}
|
|
803
|
+
ngAfterViewInit() {
|
|
804
|
+
this.lastScrollHeight = this.el.scrollHeight;
|
|
805
|
+
fromEvent(this.el, 'scroll')
|
|
806
|
+
.pipe(throttleTime(50), tap(() => this.onScroll()))
|
|
807
|
+
.subscribe();
|
|
808
|
+
}
|
|
809
|
+
onScroll() {
|
|
810
|
+
const { scrollTop, scrollHeight, clientHeight } = this.el;
|
|
811
|
+
// --- TOP THRESHOLD ---
|
|
812
|
+
const topLimit = this.$topThreshold() <= 1
|
|
813
|
+
? scrollHeight * this.$topThreshold() // percentage
|
|
814
|
+
: this.$topThreshold(); // px
|
|
815
|
+
if (scrollTop <= topLimit) {
|
|
816
|
+
this.reachedTop.emit();
|
|
817
|
+
}
|
|
818
|
+
// --- BOTTOM THRESHOLD ---
|
|
819
|
+
const bottomLimit = this.$bottomThreshold() <= 1
|
|
820
|
+
? scrollHeight * this.$bottomThreshold() // percentage
|
|
821
|
+
: this.$bottomThreshold(); // px
|
|
822
|
+
const distanceFromBottom = scrollHeight - (scrollTop + clientHeight);
|
|
823
|
+
if (distanceFromBottom <= bottomLimit) {
|
|
824
|
+
this.reachedBottom.emit();
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
/** Call this BEFORE you change the data */
|
|
828
|
+
captureBeforeChange() {
|
|
829
|
+
this.lastScrollHeight = this.el.scrollHeight;
|
|
830
|
+
}
|
|
831
|
+
/** Call this AFTER Angular renders new items */
|
|
832
|
+
restoreScrollPosition() {
|
|
833
|
+
const newHeight = this.el.scrollHeight;
|
|
834
|
+
const diff = newHeight - this.lastScrollHeight;
|
|
835
|
+
this.el.scrollTop += diff;
|
|
836
|
+
}
|
|
837
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: StableScrollDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
838
|
+
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 });
|
|
839
|
+
}
|
|
840
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: StableScrollDirective, decorators: [{
|
|
841
|
+
type: Directive,
|
|
842
|
+
args: [{
|
|
843
|
+
selector: '[stableScroll]',
|
|
844
|
+
}]
|
|
845
|
+
}], ctorParameters: () => [{ type: i0.ElementRef }], propDecorators: { reachedTop: [{ type: i0.Output, args: ["reachedTop"] }], reachedBottom: [{ type: i0.Output, args: ["reachedBottom"] }], $topThreshold: [{ type: i0.Input, args: [{ isSignal: true, alias: "$topThreshold", required: false }] }], $bottomThreshold: [{ type: i0.Input, args: [{ isSignal: true, alias: "$bottomThreshold", required: false }] }] } });
|
|
846
|
+
|
|
767
847
|
class CenterEllipsisPipe {
|
|
768
848
|
transform(value, visibleStart = 4, visibleEnd = 4) {
|
|
769
849
|
if (!value) {
|
|
@@ -4350,5 +4430,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
|
|
|
4350
4430
|
* Generated bundle index. Do not edit.
|
|
4351
4431
|
*/
|
|
4352
4432
|
|
|
4353
|
-
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 };
|
|
4433
|
+
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 };
|
|
4354
4434
|
//# sourceMappingURL=ibragim-dev-org-ui-forge-library.mjs.map
|