@ibragim-dev-org/ui-forge-library 1.4.1 → 1.4.2

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, fromEvent, tap, debounceTime, asyncScheduler, Subscription, timer, switchMap, scheduled, interval, takeWhile, finalize, Subject, takeUntil } from 'rxjs';
3
+ import { BehaviorSubject, filter, take, scheduled, fromEvent, asyncScheduler, mergeAll, tap, debounceTime, Subscription, timer, switchMap, interval, takeWhile, finalize, Subject, takeUntil } from 'rxjs';
4
4
  import * as i0 from '@angular/core';
5
- import { model, effect, Directive, Injectable, EventEmitter, Output, Input, input, PLATFORM_ID, Inject, 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, 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';
@@ -367,12 +367,23 @@ class FocusDirective {
367
367
  if (this.$focus()) {
368
368
  this.el.nativeElement.focus();
369
369
  }
370
+ else {
371
+ this.el.nativeElement.blur();
372
+ }
370
373
  });
371
374
  }
372
375
  ngAfterViewInit() {
373
- fromEvent(this.el.nativeElement, 'blur')
374
- .pipe(tap(() => {
375
- this.$focus.set(false);
376
+ scheduled([
377
+ fromEvent(this.el.nativeElement, 'blur'),
378
+ fromEvent(this.el.nativeElement, 'keydown'),
379
+ ], asyncScheduler)
380
+ .pipe(mergeAll(), tap((event) => {
381
+ if (event.type === 'blur') {
382
+ this.$focus.set(false);
383
+ }
384
+ if (event instanceof KeyboardEvent && event.key === 'Escape') {
385
+ this.$focus.set(false);
386
+ }
376
387
  }), takeUntilDestroyed(this.destroyRef))
377
388
  .subscribe();
378
389
  }
@@ -416,11 +427,15 @@ class LazyImgDirective {
416
427
  el;
417
428
  lazyService;
418
429
  lazySrc;
419
- loadError = new EventEmitter();
430
+ loadError = output();
431
+ loaded = output();
420
432
  observer;
421
433
  onError = () => {
422
434
  this.loadError.emit();
423
435
  };
436
+ onLoad = () => {
437
+ this.loaded.emit();
438
+ };
424
439
  constructor(el, lazyService) {
425
440
  this.el = el;
426
441
  this.lazyService = lazyService;
@@ -433,6 +448,7 @@ class LazyImgDirective {
433
448
  return;
434
449
  }
435
450
  img.addEventListener('error', this.onError);
451
+ img.addEventListener('load', this.onLoad);
436
452
  img.setAttribute('data-src', lazySrc);
437
453
  this.observer = this.lazyService.getObserver();
438
454
  this.observer.observe(img);
@@ -443,9 +459,10 @@ class LazyImgDirective {
443
459
  this.observer.unobserve(img);
444
460
  }
445
461
  img.removeEventListener('error', this.onError);
462
+ img.removeEventListener('load', this.onLoad);
446
463
  }
447
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 });
448
- 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" }, ngImport: i0 });
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 });
449
466
  }
450
467
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: LazyImgDirective, decorators: [{
451
468
  type: Directive,
@@ -454,9 +471,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
454
471
  }]
455
472
  }], ctorParameters: () => [{ type: i0.ElementRef }, { type: LazyImageService }], propDecorators: { lazySrc: [{
456
473
  type: Input
457
- }], loadError: [{
458
- type: Output
459
- }] } });
474
+ }], loadError: [{ type: i0.Output, args: ["loadError"] }], loaded: [{ type: i0.Output, args: ["loaded"] }] } });
460
475
 
461
476
  class MaskGradientDirective {
462
477
  elementRef;
@@ -642,6 +657,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
642
657
  }]
643
658
  }], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }] });
644
659
 
660
+ const isBrowser = () => typeof window !== 'undefined' && typeof document !== 'undefined';
661
+
645
662
  class SkeletonDirective {
646
663
  el;
647
664
  renderer;
@@ -674,6 +691,8 @@ class SkeletonDirective {
674
691
  this.renderer.removeStyle(this.el.nativeElement, 'overflow');
675
692
  }
676
693
  injectKeyframes() {
694
+ if (!isBrowser())
695
+ return;
677
696
  const styleSheet = document.styleSheets[0];
678
697
  if (!styleSheet)
679
698
  return;
@@ -1420,7 +1439,7 @@ class UiAvatarDirective {
1420
1439
  $src = input.required(...(ngDevMode ? [{ debugName: "$src" }] : []));
1421
1440
  $acronym = input.required(...(ngDevMode ? [{ debugName: "$acronym" }] : []));
1422
1441
  $text = signal('', ...(ngDevMode ? [{ debugName: "$text" }] : []));
1423
- $canShowAvatar = signal(true, ...(ngDevMode ? [{ debugName: "$canShowAvatar" }] : []));
1442
+ $canShowAvatar = signal(false, ...(ngDevMode ? [{ debugName: "$canShowAvatar" }] : []));
1424
1443
  constructor(elementRef, renderer) {
1425
1444
  this.elementRef = elementRef;
1426
1445
  this.renderer = renderer;
@@ -2178,11 +2197,13 @@ class UiPopupService {
2178
2197
  */
2179
2198
  subscribeToOutsideEvents() {
2180
2199
  this.destroyOutsideClickSubscription$.next();
2181
- fromEvent(window, 'scroll')
2182
- .pipe(tap(() => {
2183
- this.closeAll();
2184
- }), takeUntil(this.destroyOutsideClickSubscription$))
2185
- .subscribe();
2200
+ if (isBrowser()) {
2201
+ fromEvent(window, 'scroll')
2202
+ .pipe(tap(() => {
2203
+ this.closeAll();
2204
+ }), takeUntil(this.destroyOutsideClickSubscription$))
2205
+ .subscribe();
2206
+ }
2186
2207
  this.router.events
2187
2208
  .pipe(debounceTime(100), tap(() => {
2188
2209
  this.closeAll();
@@ -2194,7 +2215,9 @@ class UiPopupService {
2194
2215
  this.destroyOutsideClickSubscription$.next();
2195
2216
  }
2196
2217
  showBackdrop(isStaticBackdrop = false) {
2197
- document.body.style.setProperty('overflow-y', 'hidden');
2218
+ if (isBrowser()) {
2219
+ document.body.style.setProperty('overflow-y', 'hidden');
2220
+ }
2198
2221
  if (this.backdropRef) {
2199
2222
  return;
2200
2223
  }
@@ -2226,7 +2249,9 @@ class UiPopupService {
2226
2249
  this.backdropRef?.detach();
2227
2250
  this.backdropRef?.dispose();
2228
2251
  this.backdropRef = undefined;
2229
- document.body.style.setProperty('overflow-y', 'auto');
2252
+ if (isBrowser()) {
2253
+ document.body.style.setProperty('overflow-y', 'auto');
2254
+ }
2230
2255
  }))
2231
2256
  .subscribe();
2232
2257
  }
@@ -2253,13 +2278,15 @@ class UiPopupService {
2253
2278
  }
2254
2279
  createScaleAnimationOptionsFromElement(originElement, sourceWidth, sourceHeight) {
2255
2280
  const rect = originElement.getBoundingClientRect();
2256
- const centerX = window.innerWidth / 2;
2257
- const centerY = window.innerHeight / 2;
2281
+ const viewportWidth = isBrowser() ? window.innerWidth : sourceWidth;
2282
+ const viewportHeight = isBrowser() ? window.innerHeight : sourceHeight;
2283
+ const centerX = viewportWidth / 2;
2284
+ const centerY = viewportHeight / 2;
2258
2285
  const targetX = rect.left + rect.width / 2;
2259
2286
  const targetY = rect.top + rect.height / 2;
2260
2287
  const offsetX = targetX - centerX;
2261
2288
  const offsetY = targetY - centerY;
2262
- const fitted = getAspectRatioFit(window.innerWidth - window.innerWidth / 8, window.innerHeight - window.innerHeight / 8, sourceWidth, sourceHeight);
2289
+ const fitted = getAspectRatioFit(viewportWidth - viewportWidth / 8, viewportHeight - viewportHeight / 8, sourceWidth, sourceHeight);
2263
2290
  const scaleY = Math.trunc((sourceHeight / fitted.height) * 100) / 100;
2264
2291
  const scaleX = Math.trunc((sourceWidth / fitted.width) * 100) / 100;
2265
2292
  return {
@@ -2348,13 +2375,15 @@ class UiPopupContainerDirective {
2348
2375
  this.$isShow.set(true);
2349
2376
  }), takeUntil(this.destroyAnimationOrigin$), takeUntilDestroyed(this.destroyRef))
2350
2377
  .subscribe();
2351
- fromEvent(window, 'keydown')
2352
- .pipe(tap((e) => {
2353
- if (e.key === 'Escape' || e.key === 'Esc') {
2354
- this.close();
2355
- }
2356
- }), takeUntilDestroyed(this.destroyRef))
2357
- .subscribe();
2378
+ if (isBrowser()) {
2379
+ fromEvent(window, 'keydown')
2380
+ .pipe(tap((e) => {
2381
+ if (e.key === 'Escape' || e.key === 'Esc') {
2382
+ this.close();
2383
+ }
2384
+ }), takeUntilDestroyed(this.destroyRef))
2385
+ .subscribe();
2386
+ }
2358
2387
  }
2359
2388
  close() {
2360
2389
  if (this.popupInstance.id) {
@@ -2546,7 +2575,7 @@ class UiDropdownService extends UiPopupService {
2546
2575
  if (fetchedParameters.removePrevious && this.popupInstances.length) {
2547
2576
  this.close();
2548
2577
  }
2549
- if (window.matchMedia('(max-width: 48rem)').matches) {
2578
+ if (isBrowser() && window.matchMedia('(max-width: 48rem)').matches) {
2550
2579
  this.showBackdrop();
2551
2580
  }
2552
2581
  const overlayRef = this.overlay.create({
@@ -2578,7 +2607,7 @@ class UiDropdownService extends UiPopupService {
2578
2607
  if (fetchedParameters.removePrevious && this.popupInstances.length) {
2579
2608
  this.close();
2580
2609
  }
2581
- if (window.matchMedia('(max-width: 48rem)').matches) {
2610
+ if (isBrowser() && window.matchMedia('(max-width: 48rem)').matches) {
2582
2611
  this.showBackdrop();
2583
2612
  }
2584
2613
  const overlayRef = this.overlay.create({
@@ -2622,8 +2651,10 @@ class UiDropdownService extends UiPopupService {
2622
2651
  */
2623
2652
  calculateMousePositionAnimationOrigin(event, containerSize) {
2624
2653
  const EDGE_MARGIN = 20;
2625
- const rightSpace = document.body.clientWidth - event.clientX;
2626
- const bottomSpace = document.body.clientHeight - event.clientY;
2654
+ const viewportWidth = isBrowser() ? document.body.clientWidth : 0;
2655
+ const viewportHeight = isBrowser() ? document.body.clientHeight : 0;
2656
+ const rightSpace = viewportWidth - event.clientX;
2657
+ const bottomSpace = viewportHeight - event.clientY;
2627
2658
  const hasRightSpace = rightSpace >= containerSize.width + EDGE_MARGIN;
2628
2659
  const hasBottomSpace = bottomSpace >= containerSize.height + EDGE_MARGIN;
2629
2660
  if (!hasRightSpace && !hasBottomSpace) {
@@ -2647,8 +2678,10 @@ class UiDropdownService extends UiPopupService {
2647
2678
  */
2648
2679
  calculateMousePositionAdjustment(event, containerSize) {
2649
2680
  const EDGE_MARGIN = 20;
2650
- const rightSpace = document.body.clientWidth - event.clientX;
2651
- const bottomSpace = document.body.clientHeight - event.clientY;
2681
+ const viewportWidth = isBrowser() ? document.body.clientWidth : 0;
2682
+ const viewportHeight = isBrowser() ? document.body.clientHeight : 0;
2683
+ const rightSpace = viewportWidth - event.clientX;
2684
+ const bottomSpace = viewportHeight - event.clientY;
2652
2685
  let left = event.clientX;
2653
2686
  let top = event.clientY;
2654
2687
  if (rightSpace < containerSize.width + EDGE_MARGIN && bottomSpace < containerSize.height + EDGE_MARGIN) {
@@ -2670,7 +2703,7 @@ class UiDropdownService extends UiPopupService {
2670
2703
  * @returns The configured PositionStrategy for the overlay.
2671
2704
  */
2672
2705
  createMousePositionStrategy(event) {
2673
- if (window.innerWidth <= 768) {
2706
+ if (!isBrowser() || window.innerWidth <= 768) {
2674
2707
  return this.overlay.position().global().bottom();
2675
2708
  }
2676
2709
  return this.overlay
@@ -2721,7 +2754,7 @@ class UiDropdownService extends UiPopupService {
2721
2754
  * @returns The configured PositionStrategy for the overlay.
2722
2755
  */
2723
2756
  createPositionStrategy(attachedRef, parameters, offsetX, offsetY) {
2724
- if (window.innerWidth <= 768) {
2757
+ if (!isBrowser() || window.innerWidth <= 768) {
2725
2758
  return this.overlay.position().global().bottom();
2726
2759
  }
2727
2760
  return this.overlay
@@ -2771,7 +2804,7 @@ class UiDropdownContainerDirective extends UiPopupContainerDirective {
2771
2804
  }
2772
2805
  ngOnInit() {
2773
2806
  super.ngOnInit();
2774
- if (window.innerWidth <= 768) {
2807
+ if (isBrowser() && window.innerWidth <= 768) {
2775
2808
  this.destroyAnimationOrigin$.next();
2776
2809
  this.$animationParams.set({
2777
2810
  startOrigin: 'bottom center',
@@ -2888,11 +2921,13 @@ class HoverTipDirective {
2888
2921
  this.closeTip();
2889
2922
  }), takeUntilDestroyed(this.destroyRef))
2890
2923
  .subscribe();
2891
- fromEvent(window, 'blur')
2892
- .pipe(tap(() => {
2893
- this.closeTip();
2894
- }), takeUntilDestroyed(this.destroyRef))
2895
- .subscribe();
2924
+ if (isBrowser()) {
2925
+ fromEvent(window, 'blur')
2926
+ .pipe(tap(() => {
2927
+ this.closeTip();
2928
+ }), takeUntilDestroyed(this.destroyRef))
2929
+ .subscribe();
2930
+ }
2896
2931
  }
2897
2932
  openTip() {
2898
2933
  const text = this.$text().trim();
@@ -2997,6 +3032,11 @@ class UiPopupImageDirective {
2997
3032
  this.destroyRef = destroyRef;
2998
3033
  }
2999
3034
  ngOnInit() {
3035
+ if (!isBrowser()) {
3036
+ this.$imageWidth.set(this.width);
3037
+ this.$imageHeight.set(this.height);
3038
+ return;
3039
+ }
3000
3040
  const result = getAspectRatioFit(window.innerWidth - window.innerWidth / 8, window.innerHeight - window.innerHeight / 8, this.width, this.height);
3001
3041
  this.$imageWidth.set(result.width);
3002
3042
  this.$imageHeight.set(result.height);
@@ -3005,6 +3045,8 @@ class UiPopupImageDirective {
3005
3045
  const container = this.$container()?.nativeElement;
3006
3046
  if (!container)
3007
3047
  return;
3048
+ if (!isBrowser())
3049
+ return;
3008
3050
  this.size = {
3009
3051
  w: container.offsetWidth,
3010
3052
  h: container.offsetHeight,
@@ -3370,6 +3412,9 @@ class UiCopyButtonDirective {
3370
3412
  this.destroyRef = destroyRef;
3371
3413
  }
3372
3414
  copy() {
3415
+ if (!isBrowser()) {
3416
+ return;
3417
+ }
3373
3418
  this.destroyTimer$.next();
3374
3419
  const text = this.$text();
3375
3420
  if (window.navigator.clipboard && window.navigator.clipboard.writeText) {
@@ -4325,5 +4370,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
4325
4370
  * Generated bundle index. Do not edit.
4326
4371
  */
4327
4372
 
4328
- 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, navigateByUrl, stringToColorGradient, stringToHslColor };
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 };
4329
4374
  //# sourceMappingURL=ibragim-dev-org-ui-forge-library.mjs.map