@decaf-ts/for-angular 0.1.20 → 0.1.21
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,6 +1,6 @@
|
|
|
1
1
|
import { parseValueByType, HTML5InputTypes, UIKeys, HTML5CheckTypes, escapeHtml, parseToNumber, RenderingEngine, DecafTranslateService, DecafComponent, ComponentEventNames, UIValidator, RenderingError, UIMediaBreakPoints, LayoutGridGaps, ElementSizes, DecafEventHandler } from '@decaf-ts/ui-decorators';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
|
-
import { InjectionToken, isDevMode, provideEnvironmentInitializer, reflectComponentType, Injector, createEnvironmentInjector, runInInjectionContext, createComponent, inject, NgZone, Injectable, Input, Directive, signal, ChangeDetectorRef, EnvironmentInjector, Renderer2, EventEmitter, ElementRef, Output, ViewChild, Inject, ViewContainerRef, TemplateRef, Component, ViewEncapsulation, HostListener, Pipe, NgModule } from '@angular/core';
|
|
3
|
+
import { InjectionToken, isDevMode, provideEnvironmentInitializer, reflectComponentType, Injector, createEnvironmentInjector, runInInjectionContext, createComponent, inject, NgZone, Injectable, Input, Directive, signal, ChangeDetectorRef, EnvironmentInjector, Renderer2, EventEmitter, effect, ElementRef, Output, ViewChild, Inject, ViewContainerRef, TemplateRef, Component, ViewEncapsulation, HostListener, Pipe, NgModule } from '@angular/core';
|
|
4
4
|
import * as i1$1 from '@angular/common';
|
|
5
5
|
import { Location, NgComponentOutlet, CommonModule } from '@angular/common';
|
|
6
6
|
import { ValidationKeys, DEFAULT_PATTERNS, VALIDATION_PARENT_KEY, Primitives, Model, Validation, ComparisonValidationKeys, PathProxyEngine, ModelKeys, isValidDate as isValidDate$1, parseDate, sf as sf$1, ReservedModels } from '@decaf-ts/decorator-validation';
|
|
@@ -17,6 +17,7 @@ import { forkJoin, Subject, BehaviorSubject, fromEvent, of, merge, Observable, t
|
|
|
17
17
|
import { Title, DomSanitizer } from '@angular/platform-browser';
|
|
18
18
|
import { Router, NavigationStart, NavigationEnd, ActivatedRoute } from '@angular/router';
|
|
19
19
|
import { MenuController } from '@ionic/angular';
|
|
20
|
+
import { toSignal } from '@angular/core/rxjs-interop';
|
|
20
21
|
import { provideHttpClient, HttpClient } from '@angular/common/http';
|
|
21
22
|
import { TranslateParser, provideTranslateService, TranslateLoader, provideTranslateParser, TranslateService, TranslatePipe, TranslateModule } from '@ngx-translate/core';
|
|
22
23
|
import { map, distinctUntilChanged, takeUntil, shareReplay, tap, switchMap } from 'rxjs/operators';
|
|
@@ -3233,18 +3234,6 @@ function provideDecafI18nConfig(config = { fallbackLang: 'en', lang: 'en' }, res
|
|
|
3233
3234
|
];
|
|
3234
3235
|
}
|
|
3235
3236
|
|
|
3236
|
-
/**
|
|
3237
|
-
* @module NgxMediaService
|
|
3238
|
-
* @description Provides utilities for managing media-related features such as color scheme detection,
|
|
3239
|
-
* window resize observation, and SVG injection.
|
|
3240
|
-
* @summary
|
|
3241
|
-
* This module exposes the `NgxMediaService` class, which includes methods for observing the
|
|
3242
|
-
* application's color scheme, handling window resize events, and dynamically injecting SVG content
|
|
3243
|
-
* into the DOM. It leverages Angular's dependency injection system and RxJS for reactive programming.
|
|
3244
|
-
*
|
|
3245
|
-
* Key exports:
|
|
3246
|
-
* - {@link NgxMediaService}: The main service class providing media-related utilities.
|
|
3247
|
-
*/
|
|
3248
3237
|
/**
|
|
3249
3238
|
* @description Service for managing media-related features in an Angular application.
|
|
3250
3239
|
* @summary
|
|
@@ -3363,7 +3352,7 @@ class NgxMediaService {
|
|
|
3363
3352
|
const win = this._window;
|
|
3364
3353
|
this.angularZone.runOutsideAngular(() => {
|
|
3365
3354
|
fromEvent(win, 'resize')
|
|
3366
|
-
.pipe(distinctUntilChanged(), takeUntil(this.destroy$), shareReplay(1))
|
|
3355
|
+
.pipe(distinctUntilChanged(), takeUntil(this.destroy$), shareReplay({ bufferSize: 1, refCount: true }))
|
|
3367
3356
|
.subscribe(() => {
|
|
3368
3357
|
const dimensions = {
|
|
3369
3358
|
width: win.innerWidth,
|
|
@@ -3449,7 +3438,7 @@ class NgxMediaService {
|
|
|
3449
3438
|
}
|
|
3450
3439
|
// store the latest schema value
|
|
3451
3440
|
this.currentSchema = scheme;
|
|
3452
|
-
}), takeUntil(this.destroy$), shareReplay(1));
|
|
3441
|
+
}), takeUntil(this.destroy$), shareReplay({ bufferSize: 1, refCount: true }));
|
|
3453
3442
|
}
|
|
3454
3443
|
/**
|
|
3455
3444
|
* @description Observes the scroll state of the active page.
|
|
@@ -3471,12 +3460,9 @@ class NgxMediaService {
|
|
|
3471
3460
|
// await delay for page change to complete
|
|
3472
3461
|
return timer(awaitDelay).pipe(switchMap(() => new Observable((observer) => {
|
|
3473
3462
|
const activeContent = this._document.querySelector('ion-router-outlet .ion-page:not(.ion-page-hidden) ion-content');
|
|
3474
|
-
if (!(activeContent &&
|
|
3475
|
-
typeof activeContent.getScrollElement === 'function'))
|
|
3463
|
+
if (!(activeContent && typeof activeContent.getScrollElement === 'function'))
|
|
3476
3464
|
return this.angularZone.run(() => observer.next(false));
|
|
3477
|
-
activeContent
|
|
3478
|
-
.getScrollElement()
|
|
3479
|
-
.then((element) => {
|
|
3465
|
+
activeContent.getScrollElement().then((element) => {
|
|
3480
3466
|
const emitScrollState = () => {
|
|
3481
3467
|
const scrollTop = element.scrollTop || 0;
|
|
3482
3468
|
this.angularZone.run(() => observer.next(scrollTop > offset));
|
|
@@ -3485,7 +3471,7 @@ class NgxMediaService {
|
|
|
3485
3471
|
emitScrollState();
|
|
3486
3472
|
return () => element.removeEventListener('scroll', emitScrollState);
|
|
3487
3473
|
});
|
|
3488
|
-
})), distinctUntilChanged(), takeUntil(this.destroy$), shareReplay(1));
|
|
3474
|
+
})), distinctUntilChanged(), takeUntil(this.destroy$), shareReplay({ bufferSize: 1, refCount: true }));
|
|
3489
3475
|
}
|
|
3490
3476
|
/**
|
|
3491
3477
|
* @description Loads an SVG file and injects it into a target element.
|
|
@@ -3507,7 +3493,7 @@ class NgxMediaService {
|
|
|
3507
3493
|
this.angularZone.runOutsideAngular(() => {
|
|
3508
3494
|
const svg$ = http
|
|
3509
3495
|
.get(path, { responseType: 'text' })
|
|
3510
|
-
.pipe(takeUntil(this.destroy$), shareReplay(1));
|
|
3496
|
+
.pipe(takeUntil(this.destroy$), shareReplay({ bufferSize: 1, refCount: true }));
|
|
3511
3497
|
svg$.subscribe((svg) => {
|
|
3512
3498
|
this.angularZone.run(() => {
|
|
3513
3499
|
target.innerHTML = svg;
|
|
@@ -3532,8 +3518,7 @@ class NgxMediaService {
|
|
|
3532
3518
|
if (!this.darkModeEnabled())
|
|
3533
3519
|
return of(false);
|
|
3534
3520
|
const documentElement = this._document.documentElement;
|
|
3535
|
-
return this.colorScheme$.pipe(map((scheme) => documentElement.classList.contains(AngularEngineKeys.DARK_PALETTE_CLASS) ||
|
|
3536
|
-
scheme === WindowColorSchemes.dark), distinctUntilChanged(), shareReplay(1), takeUntil(this.destroy$));
|
|
3521
|
+
return this.colorScheme$.pipe(map((scheme) => documentElement.classList.contains(AngularEngineKeys.DARK_PALETTE_CLASS) || scheme === WindowColorSchemes.dark), distinctUntilChanged(), shareReplay({ bufferSize: 1, refCount: true }), takeUntil(this.destroy$));
|
|
3537
3522
|
}
|
|
3538
3523
|
/**
|
|
3539
3524
|
* @description Toggles dark mode for a specific component.
|
|
@@ -3813,7 +3798,7 @@ class NgxRepositoryDirective extends DecafComponent {
|
|
|
3813
3798
|
this.repository?.observe(this.repositoryObserver);
|
|
3814
3799
|
this.log.for(this.observe).info(`Registered repository observer for model ${this.modelName}`);
|
|
3815
3800
|
this.repositoryObserverSubject
|
|
3816
|
-
.pipe(debounceTime(100), shareReplay$1(1), takeUntil$1(this.destroySubscriptions$))
|
|
3801
|
+
.pipe(debounceTime(100), shareReplay$1({ bufferSize: 1, refCount: true }), takeUntil$1(this.destroySubscriptions$))
|
|
3817
3802
|
.subscribe(([model, action, uid, data]) => this.handleObserveEvent(data, model, action, uid));
|
|
3818
3803
|
}
|
|
3819
3804
|
}
|
|
@@ -4405,6 +4390,11 @@ class NgxComponentDirective extends NgxRepositoryDirective {
|
|
|
4405
4390
|
* @default WindowColorSchemes.light
|
|
4406
4391
|
*/
|
|
4407
4392
|
this.colorSchema = WindowColorSchemes.light;
|
|
4393
|
+
this.popState$ = fromEvent(window, 'popstate').pipe(shareReplay$1({ bufferSize: 1, refCount: true }));
|
|
4394
|
+
// Convertendo o Observable em Signal
|
|
4395
|
+
this.popStateSignal = toSignal(this.popState$, {
|
|
4396
|
+
initialValue: null,
|
|
4397
|
+
});
|
|
4408
4398
|
this.value = undefined;
|
|
4409
4399
|
this.componentName = componentName || this.constructor.name || 'NgxComponentDirective';
|
|
4410
4400
|
this.localeRoot = localeRoot;
|
|
@@ -4419,6 +4409,36 @@ class NgxComponentDirective extends NgxRepositoryDirective {
|
|
|
4419
4409
|
this.colorSchema = WindowColorSchemes.dark;
|
|
4420
4410
|
}
|
|
4421
4411
|
});
|
|
4412
|
+
effect(async () => {
|
|
4413
|
+
const event = this.popStateSignal();
|
|
4414
|
+
if (event) {
|
|
4415
|
+
console.log(`Back detectado!' no component ${this.componentName}`);
|
|
4416
|
+
await this.beforeInitialize(this);
|
|
4417
|
+
}
|
|
4418
|
+
});
|
|
4419
|
+
}
|
|
4420
|
+
async beforeInitialize(component) {
|
|
4421
|
+
console.log(`calling render for component ${this.componentName}`);
|
|
4422
|
+
if (!component) {
|
|
4423
|
+
component = this;
|
|
4424
|
+
}
|
|
4425
|
+
const instance = component;
|
|
4426
|
+
if (this.propsMapperFn) {
|
|
4427
|
+
for (const [key, fn] of Object.entries(this.propsMapperFn)) {
|
|
4428
|
+
if (key in instance)
|
|
4429
|
+
instance[key] = await fn(instance);
|
|
4430
|
+
}
|
|
4431
|
+
}
|
|
4432
|
+
// search for handler render
|
|
4433
|
+
const handler = this.handlers?.[ComponentEventNames.Render] || undefined;
|
|
4434
|
+
if (handler && typeof handler === 'function') {
|
|
4435
|
+
await handler.bind(instance)(instance, this.name, this.value);
|
|
4436
|
+
}
|
|
4437
|
+
// search for event render
|
|
4438
|
+
const event = this.events?.[ComponentEventNames.Render] || undefined;
|
|
4439
|
+
if (event && typeof event === 'function') {
|
|
4440
|
+
await event.bind(instance)(instance, this.name, this.value);
|
|
4441
|
+
}
|
|
4422
4442
|
}
|
|
4423
4443
|
async initialize() {
|
|
4424
4444
|
this.mediaService.darkModeEnabled();
|
|
@@ -4430,7 +4450,9 @@ class NgxComponentDirective extends NgxRepositoryDirective {
|
|
|
4430
4450
|
if (this.operation === OperationKeys.CREATE) {
|
|
4431
4451
|
this.refreshing = false;
|
|
4432
4452
|
}
|
|
4433
|
-
this.router.events
|
|
4453
|
+
this.router.events
|
|
4454
|
+
.pipe(shareReplay$1({ bufferSize: 1, refCount: true }), takeUntil$1(this.destroySubscriptions$))
|
|
4455
|
+
.subscribe(async (event) => {
|
|
4434
4456
|
if (event instanceof NavigationStart) {
|
|
4435
4457
|
if (this.value) {
|
|
4436
4458
|
await this.ngOnDestroy();
|
|
@@ -4438,24 +4460,9 @@ class NgxComponentDirective extends NgxRepositoryDirective {
|
|
|
4438
4460
|
}
|
|
4439
4461
|
});
|
|
4440
4462
|
this.route = this.router.url.replace('/', '');
|
|
4441
|
-
const instance = this;
|
|
4442
|
-
if (this.propsMapperFn) {
|
|
4443
|
-
for (const [key, fn] of Object.entries(this.propsMapperFn)) {
|
|
4444
|
-
if (key in instance)
|
|
4445
|
-
instance[key] = await fn(instance);
|
|
4446
|
-
}
|
|
4447
|
-
}
|
|
4448
4463
|
// search for handler to render event
|
|
4449
4464
|
if (!this.initialized) {
|
|
4450
|
-
|
|
4451
|
-
if (handler && typeof handler === 'function') {
|
|
4452
|
-
await handler.bind(instance)(instance, this.name, this.value);
|
|
4453
|
-
}
|
|
4454
|
-
// search for event to render event
|
|
4455
|
-
const event = this.events?.[ComponentEventNames.Render] || undefined;
|
|
4456
|
-
if (event && typeof event === 'function') {
|
|
4457
|
-
await event.bind(instance)(instance, this.name, this.value);
|
|
4458
|
-
}
|
|
4465
|
+
await this.beforeInitialize(this);
|
|
4459
4466
|
}
|
|
4460
4467
|
await super.initialize();
|
|
4461
4468
|
this.initialized = true;
|
|
@@ -5155,7 +5162,9 @@ class NgxPageDirective extends NgxComponentDirective {
|
|
|
5155
5162
|
* @memberOf module:lib/engine/NgxPageDirective
|
|
5156
5163
|
*/
|
|
5157
5164
|
async ngAfterViewInit() {
|
|
5158
|
-
this.router.events
|
|
5165
|
+
this.router.events
|
|
5166
|
+
.pipe(takeUntil$1(this.destroySubscriptions$), shareReplay$1({ bufferSize: 1, refCount: true }))
|
|
5167
|
+
.subscribe(async (event) => {
|
|
5159
5168
|
if (event instanceof NavigationEnd) {
|
|
5160
5169
|
const url = (event?.url || '').replace('/', '');
|
|
5161
5170
|
this.currentRoute = url;
|
|
@@ -5799,7 +5808,7 @@ class NgxRenderableComponentDirective extends NgxModelPageDirective {
|
|
|
5799
5808
|
const value = this.instance[key];
|
|
5800
5809
|
if (value instanceof EventEmitter)
|
|
5801
5810
|
this.instance[key]
|
|
5802
|
-
.pipe(shareReplay$1(1), takeUntil$1(this.destroySubscriptions$))
|
|
5811
|
+
.pipe(shareReplay$1({ bufferSize: 1, refCount: true }), takeUntil$1(this.destroySubscriptions$))
|
|
5803
5812
|
.subscribe(async (event) => {
|
|
5804
5813
|
await this.handleEvent({
|
|
5805
5814
|
component: component.name || '',
|
|
@@ -10530,7 +10539,7 @@ let FilterComponent = class FilterComponent extends NgxComponentDirective {
|
|
|
10530
10539
|
async ngOnInit() {
|
|
10531
10540
|
this.windowWidth = getWindowWidth();
|
|
10532
10541
|
this.windowResizeSubscription = fromEvent(window, 'resize')
|
|
10533
|
-
.pipe(debounceTime(300), takeUntil$1(this.destroySubscriptions$), shareReplay$1(1))
|
|
10542
|
+
.pipe(debounceTime(300), takeUntil$1(this.destroySubscriptions$), shareReplay$1({ bufferSize: 1, refCount: true }))
|
|
10534
10543
|
.subscribe(() => {
|
|
10535
10544
|
this.windowWidth = getWindowWidth();
|
|
10536
10545
|
});
|
|
@@ -11726,7 +11735,7 @@ let ListComponent = class ListComponent extends NgxComponentDirective {
|
|
|
11726
11735
|
if (!this.searchbarPlaceholder)
|
|
11727
11736
|
this.searchbarPlaceholder = `${this.locale}.search.placeholder`;
|
|
11728
11737
|
this.clickItemSubject
|
|
11729
|
-
.pipe(debounceTime(100), shareReplay$1(1), takeUntil$1(this.destroySubscriptions$))
|
|
11738
|
+
.pipe(debounceTime(100), shareReplay$1({ bufferSize: 1, refCount: true }), takeUntil$1(this.destroySubscriptions$))
|
|
11730
11739
|
.subscribe((event) => this.clickEventEmit(event));
|
|
11731
11740
|
this.limit = Number(this.limit);
|
|
11732
11741
|
this.start = Number(this.start);
|
|
@@ -14666,7 +14675,7 @@ let TableComponent = class TableComponent extends ListComponent {
|
|
|
14666
14675
|
this.type = ListComponentsTypes.PAGINATED;
|
|
14667
14676
|
this.empty = Object.assign({}, DefaultListEmptyOptions, this.empty);
|
|
14668
14677
|
this.repositoryObserverSubject
|
|
14669
|
-
.pipe(debounceTime(100), shareReplay$1(1), takeUntil$1(this.destroySubscriptions$))
|
|
14678
|
+
.pipe(debounceTime(100), shareReplay$1({ bufferSize: 1, refCount: true }), takeUntil$1(this.destroySubscriptions$))
|
|
14670
14679
|
.subscribe(([model, action, uid, data]) => this.handleObserveEvent(model, action, uid, data));
|
|
14671
14680
|
this.cols = this._cols;
|
|
14672
14681
|
this.getOperations();
|