@praxisui/crud 10.0.0-rc.7 → 10.0.0-rc.71

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.
@@ -0,0 +1,103 @@
1
+ import * as i0 from '@angular/core';
2
+ import { inject, Injector, DestroyRef, signal, effect, untracked, ViewChild, ChangeDetectionStrategy, Component } from '@angular/core';
3
+ import { NgComponentOutlet } from '@angular/common';
4
+ import { Router, ActivatedRoute } from '@angular/router';
5
+ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
6
+ import { EnterpriseRuntimeContextService, PraxisCustomizationModeService, PraxisI18nService, providePraxisI18nConfig } from '@praxisui/core';
7
+ import { d as CrudRouteFormHandoffService, e as DynamicFormDialogHostComponent, $ as translateCrudRuntimeText, J as crudRouteContextKey, i as PRAXIS_CRUD_RUNTIME_I18N_CONFIG } from './praxisui-crud-praxisui-crud-CZL9Mks8.mjs';
8
+ import { MAT_DIALOG_DATA } from '@angular/material/dialog';
9
+
10
+ /** Created only by createCrudFormRoute; owns the transferred form instance. */
11
+ class CrudRouteFormComponent {
12
+ router = inject(Router);
13
+ route = inject(ActivatedRoute);
14
+ parentInjector = inject(Injector);
15
+ destroyRef = inject(DestroyRef);
16
+ context = inject(EnterpriseRuntimeContextService, { optional: true });
17
+ customizationMode = inject(PraxisCustomizationModeService, { optional: true });
18
+ i18n = inject(PraxisI18nService);
19
+ data = inject(CrudRouteFormHandoffService).claim(this.route.snapshot.data['crudFormTarget']);
20
+ releaseCustomizationDisable = null;
21
+ _available = signal(!!this.data, ...(ngDevMode ? [{ debugName: "_available" }] : /* istanbul ignore next */ []));
22
+ available = this._available.asReadonly();
23
+ host = DynamicFormDialogHostComponent;
24
+ unavailableText = translateCrudRuntimeText(this.i18n, 'crud.route.unavailable', 'Esta cópia não está mais disponível. Volte à lista e prepare uma nova cópia.');
25
+ formInjector = Injector.create({
26
+ parent: this.parentInjector,
27
+ providers: [{ provide: MAT_DIALOG_DATA, useValue: {
28
+ ...this.data,
29
+ presentation: 'route',
30
+ closeRoute: () => this.router.navigateByUrl(this.data.returnUrl),
31
+ } }],
32
+ });
33
+ outlet;
34
+ constructor() {
35
+ this.syncCustomizationAvailability();
36
+ effect(() => {
37
+ this.available();
38
+ untracked(() => this.syncCustomizationAvailability());
39
+ });
40
+ // A route owns its context after handoff; it must not depend on the destroyed source.
41
+ const contextKey = crudRouteContextKey(this.context?.snapshot);
42
+ this.context?.contextChanges$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(current => {
43
+ if (crudRouteContextKey(current) !== contextKey) {
44
+ this._available.set(false);
45
+ this.syncCustomizationAvailability();
46
+ }
47
+ });
48
+ this.destroyRef.onDestroy(() => {
49
+ this.releaseCustomizationLock();
50
+ this.formInjector.destroy();
51
+ });
52
+ }
53
+ syncCustomizationAvailability() {
54
+ if (!this.available()) {
55
+ if (!this.releaseCustomizationDisable) {
56
+ this.releaseCustomizationDisable =
57
+ this.customizationMode?.disableCustomization?.(translateCrudRuntimeText(this.i18n, 'crud.route.customizationUnavailable', 'Customização indisponível para esta visualização de rota.')) ?? null;
58
+ }
59
+ return;
60
+ }
61
+ this.releaseCustomizationLock();
62
+ }
63
+ releaseCustomizationLock() {
64
+ if (!this.releaseCustomizationDisable) {
65
+ return;
66
+ }
67
+ const release = this.releaseCustomizationDisable;
68
+ this.releaseCustomizationDisable = null;
69
+ release();
70
+ }
71
+ canLeave() {
72
+ return this.outlet?.componentInstance?.canLeaveForm() ?? true;
73
+ }
74
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CrudRouteFormComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
75
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.14", type: CrudRouteFormComponent, isStandalone: true, selector: "praxis-crud-route-form", providers: [providePraxisI18nConfig(PRAXIS_CRUD_RUNTIME_I18N_CONFIG)], viewQueries: [{ propertyName: "outlet", first: true, predicate: NgComponentOutlet, descendants: true }], ngImport: i0, template: `
76
+ @if (available()) {
77
+ <ng-container *ngComponentOutlet="host; injector: formInjector"></ng-container>
78
+ } @else {
79
+ <p role="status">{{ unavailableText }}</p>
80
+ }
81
+ `, isInline: true, dependencies: [{ kind: "directive", type: NgComponentOutlet, selector: "[ngComponentOutlet]", inputs: ["ngComponentOutlet", "ngComponentOutletInputs", "ngComponentOutletInjector", "ngComponentOutletEnvironmentInjector", "ngComponentOutletContent", "ngComponentOutletNgModule"], exportAs: ["ngComponentOutlet"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
82
+ }
83
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CrudRouteFormComponent, decorators: [{
84
+ type: Component,
85
+ args: [{
86
+ selector: 'praxis-crud-route-form',
87
+ imports: [NgComponentOutlet],
88
+ providers: [providePraxisI18nConfig(PRAXIS_CRUD_RUNTIME_I18N_CONFIG)],
89
+ changeDetection: ChangeDetectionStrategy.OnPush,
90
+ template: `
91
+ @if (available()) {
92
+ <ng-container *ngComponentOutlet="host; injector: formInjector"></ng-container>
93
+ } @else {
94
+ <p role="status">{{ unavailableText }}</p>
95
+ }
96
+ `,
97
+ }]
98
+ }], ctorParameters: () => [], propDecorators: { outlet: [{
99
+ type: ViewChild,
100
+ args: [NgComponentOutlet]
101
+ }] } });
102
+
103
+ export { CrudRouteFormComponent };