@decaf-ts/for-angular 0.0.16 → 0.0.17
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.
- package/assets/i18n/en.json +10 -0
- package/assets/i18n/pt.json +149 -0
- package/assets/icons/icon-128.webp +0 -0
- package/assets/icons/icon-192.webp +0 -0
- package/assets/icons/icon-256.webp +0 -0
- package/assets/icons/icon-48.webp +0 -0
- package/assets/icons/icon-512.webp +0 -0
- package/assets/icons/icon-72.webp +0 -0
- package/assets/icons/icon-96.webp +0 -0
- package/assets/images/apple-touch-icon.png +0 -0
- package/assets/images/favicon.png +0 -0
- package/assets/images/favicon.svg +29 -0
- package/components/component-renderer/component-renderer.component.d.ts +5 -4
- package/components/crud-field/crud-field.component.d.ts +174 -19
- package/components/crud-form/crud-form.component.d.ts +170 -6
- package/components/fieldset/fieldset.component.d.ts +374 -36
- package/components/list/list.component.d.ts +1 -1
- package/components/list-item/list-item.component.d.ts +2 -2
- package/components/model-renderer/model-renderer.component.d.ts +1 -5
- package/directives/collapsable.directive.d.ts +1 -0
- package/engine/NgxBaseComponent.d.ts +6 -6
- package/engine/NgxCrudFormField.d.ts +5 -2
- package/engine/NgxFormService.d.ts +113 -12
- package/engine/NgxRenderingEngine.d.ts +150 -25
- package/engine/constants.d.ts +11 -6
- package/engine/decorators.d.ts +2 -2
- package/engine/index.d.ts +4 -2
- package/engine/interfaces.d.ts +261 -0
- package/engine/types.d.ts +3 -206
- package/esm2022/components/component-renderer/component-renderer.component.mjs +13 -11
- package/esm2022/components/crud-field/crud-field.component.mjs +193 -8
- package/esm2022/components/crud-form/crud-form.component.mjs +116 -11
- package/esm2022/components/empty-state/empty-state.component.mjs +3 -3
- package/esm2022/components/fieldset/fieldset.component.mjs +482 -43
- package/esm2022/components/filter/filter.component.mjs +3 -3
- package/esm2022/components/layout/layout.component.mjs +3 -3
- package/esm2022/components/list/list.component.mjs +4 -5
- package/esm2022/components/list-item/list-item.component.mjs +9 -9
- package/esm2022/components/model-renderer/model-renderer.component.mjs +9 -8
- package/esm2022/components/pagination/pagination.component.mjs +4 -4
- package/esm2022/components/searchbar/searchbar.component.mjs +3 -3
- package/esm2022/directives/collapsable.directive.mjs +3 -2
- package/esm2022/engine/NgxBaseComponent.mjs +28 -22
- package/esm2022/engine/NgxCrudFormField.mjs +14 -4
- package/esm2022/engine/NgxFormService.mjs +239 -27
- package/esm2022/engine/NgxRenderingEngine.mjs +202 -46
- package/esm2022/engine/ValidatorFactory.mjs +6 -4
- package/esm2022/engine/constants.mjs +14 -9
- package/esm2022/engine/decorators.mjs +6 -6
- package/esm2022/engine/index.mjs +5 -3
- package/esm2022/engine/interfaces.mjs +4 -0
- package/esm2022/engine/types.mjs +1 -3
- package/esm2022/helpers/utils.mjs +6 -2
- package/fesm2022/decaf-ts-for-angular.mjs +2909 -2130
- package/fesm2022/decaf-ts-for-angular.mjs.map +1 -1
- package/helpers/utils.d.ts +1 -0
- package/package.json +2 -1
- package/engine/NgxRenderingEngine2.d.ts +0 -250
- package/esm2022/engine/NgxRenderingEngine2.mjs +0 -332
- package/esm2022/interfaces.mjs +0 -2
- package/interfaces.d.ts +0 -28
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { FieldProperties } from '@decaf-ts/ui-decorators';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { FieldUpdateMode } from './types';
|
|
3
|
+
import { IComponentConfig } from './interfaces';
|
|
4
|
+
import { AbstractControl, FormArray, FormControl, FormGroup } from '@angular/forms';
|
|
5
|
+
import { OperationKeys } from '@decaf-ts/db-decorators';
|
|
4
6
|
/**
|
|
5
7
|
* @description Service for managing Angular forms and form controls.
|
|
6
8
|
* @summary The NgxFormService provides utility methods for creating, managing, and validating Angular forms and form controls. It includes functionality for registering forms, adding controls, validating fields, and handling form data.
|
|
@@ -40,7 +42,27 @@ import { AbstractControl, FormControl, FormGroup } from '@angular/forms';
|
|
|
40
42
|
* NFS-->>C: Return form data
|
|
41
43
|
*/
|
|
42
44
|
export declare class NgxFormService {
|
|
45
|
+
/**
|
|
46
|
+
* @description WeakMap that stores control properties for form controls.
|
|
47
|
+
* @summary A WeakMap that associates AbstractControl instances with their corresponding FieldProperties.
|
|
48
|
+
* This allows the service to track metadata for form controls without creating memory leaks.
|
|
49
|
+
*
|
|
50
|
+
* @type {WeakMap<AbstractControl, FieldProperties>}
|
|
51
|
+
* @private
|
|
52
|
+
* @static
|
|
53
|
+
* @memberOf NgxFormService
|
|
54
|
+
*/
|
|
43
55
|
private static controls;
|
|
56
|
+
/**
|
|
57
|
+
* @description Registry of form groups indexed by their unique identifiers.
|
|
58
|
+
* @summary A Map that stores FormGroup instances with their unique string identifiers.
|
|
59
|
+
* This allows global access to registered forms throughout the application.
|
|
60
|
+
*
|
|
61
|
+
* @type {Map<string, FormGroup>}
|
|
62
|
+
* @private
|
|
63
|
+
* @static
|
|
64
|
+
* @memberOf NgxFormService
|
|
65
|
+
*/
|
|
44
66
|
private static formRegistry;
|
|
45
67
|
/**
|
|
46
68
|
* @description Adds a form to the registry.
|
|
@@ -65,10 +87,89 @@ export declare class NgxFormService {
|
|
|
65
87
|
*/
|
|
66
88
|
private static resolveParentGroup;
|
|
67
89
|
/**
|
|
68
|
-
* @description
|
|
69
|
-
* @summary
|
|
70
|
-
*
|
|
71
|
-
*
|
|
90
|
+
* @description Retrieves component properties from a FormGroup or FormArray.
|
|
91
|
+
* @summary Extracts component properties stored in the form group metadata. If a FormGroup is provided
|
|
92
|
+
* and groupArrayName is specified, it will look for the FormArray within the form structure.
|
|
93
|
+
*
|
|
94
|
+
* @param {FormGroup | FormArray} formGroup - The form group or form array to extract properties from
|
|
95
|
+
* @param {string} [key] - Optional key to retrieve a specific property
|
|
96
|
+
* @param {string} [groupArrayName] - Optional name of the group array if formGroup is not a FormArray
|
|
97
|
+
* @return {Partial<FieldProperties>} The component properties or a specific property if key is provided
|
|
98
|
+
*
|
|
99
|
+
* @static
|
|
100
|
+
* @memberOf NgxFormService
|
|
101
|
+
*/
|
|
102
|
+
static getComponentPropsFromGroupArray(formGroup: FormGroup | FormArray, key?: string, groupArrayName?: string | undefined): Partial<FieldProperties>;
|
|
103
|
+
/**
|
|
104
|
+
* @description Adds a new group to a parent FormArray.
|
|
105
|
+
* @summary Creates and adds a new FormGroup to the specified parent FormArray based on the
|
|
106
|
+
* component properties stored in the parent's metadata. This is used for dynamic form arrays
|
|
107
|
+
* where new groups need to be added at runtime.
|
|
108
|
+
*
|
|
109
|
+
* @param {FormGroup} formGroup - The root form group containing the parent FormArray
|
|
110
|
+
* @param {string} parentName - The name of the parent FormArray to add the group to
|
|
111
|
+
* @param {number} [index=1] - The index position where the new group should be added
|
|
112
|
+
* @return {FormGroup} The newly created and added FormGroup
|
|
113
|
+
*
|
|
114
|
+
* @static
|
|
115
|
+
* @memberOf NgxFormService
|
|
116
|
+
*/
|
|
117
|
+
static addGroupToParent(formGroup: FormGroup, parentName: string, index?: number): FormGroup;
|
|
118
|
+
/**
|
|
119
|
+
* @description Retrieves a FormGroup from a parent FormArray at the specified index.
|
|
120
|
+
* @summary Gets a FormGroup from the specified parent FormArray. If the group doesn't exist
|
|
121
|
+
* at the given index, it will create a new one using addGroupToParent.
|
|
122
|
+
*
|
|
123
|
+
* @param {FormGroup} formGroup - The root form group containing the parent FormArray
|
|
124
|
+
* @param {string} parentName - The name of the parent FormArray to retrieve the group from
|
|
125
|
+
* @param {number} [index=1] - The index of the group to retrieve
|
|
126
|
+
* @return {FormGroup} The FormGroup at the specified index
|
|
127
|
+
*
|
|
128
|
+
* @static
|
|
129
|
+
* @memberOf NgxFormService
|
|
130
|
+
*/
|
|
131
|
+
static getGroupFromParent(formGroup: FormGroup, parentName: string, index?: number): FormGroup;
|
|
132
|
+
/**
|
|
133
|
+
* @description Checks if a value is unique within a FormArray group.
|
|
134
|
+
* @summary Validates that the primary key value in a FormGroup is unique among all groups
|
|
135
|
+
* in the parent FormArray. The uniqueness check behavior differs based on the operation type.
|
|
136
|
+
*
|
|
137
|
+
* @param {FormGroup} formGroup - The FormGroup to check for uniqueness
|
|
138
|
+
* @param {number} index - The index of the current group within the FormArray
|
|
139
|
+
* @param {OperationKeys} [operation=OperationKeys.CREATE] - The type of operation being performed
|
|
140
|
+
* @return {boolean} True if the value is unique, false otherwise
|
|
141
|
+
*
|
|
142
|
+
* @static
|
|
143
|
+
* @memberOf NgxFormService
|
|
144
|
+
*/
|
|
145
|
+
static isUniqueOnGroup(formGroup: FormGroup, index: number, operation?: OperationKeys): boolean;
|
|
146
|
+
/**
|
|
147
|
+
* @description Enables all controls within a FormGroup or FormArray.
|
|
148
|
+
* @summary Recursively enables all form controls within the provided FormGroup or FormArray.
|
|
149
|
+
* This is useful for making all controls interactive after they have been disabled.
|
|
150
|
+
*
|
|
151
|
+
* @param {FormArray | FormGroup} formGroup - The FormGroup or FormArray to enable all controls for
|
|
152
|
+
* @return {void}
|
|
153
|
+
*
|
|
154
|
+
* @static
|
|
155
|
+
* @memberOf NgxFormService
|
|
156
|
+
*/
|
|
157
|
+
static enableAllGroupControls(formGroup: FormArray | FormGroup): void;
|
|
158
|
+
/**
|
|
159
|
+
* @description Adds a form control to a form group based on component properties.
|
|
160
|
+
* @summary Creates and configures a FormControl within the specified FormGroup using the provided
|
|
161
|
+
* component properties. Handles nested paths, multiple controls (FormArrays), and control registration.
|
|
162
|
+
* This method supports complex form structures with nested groups and arrays.
|
|
163
|
+
*
|
|
164
|
+
* @param {FormGroup} formGroup - The form group to add the control to
|
|
165
|
+
* @param {IComponentInput} componentProps - The component properties defining the control configuration
|
|
166
|
+
* @param {KeyValue} [parentProps={}] - Properties from the parent component for context
|
|
167
|
+
* @param {number} [index=0] - The index for multiple controls in FormArrays
|
|
168
|
+
* @return {void}
|
|
169
|
+
*
|
|
170
|
+
* @private
|
|
171
|
+
* @static
|
|
172
|
+
* @memberOf NgxFormService
|
|
72
173
|
*/
|
|
73
174
|
private static addFormControl;
|
|
74
175
|
/**
|
|
@@ -84,11 +185,11 @@ export declare class NgxFormService {
|
|
|
84
185
|
* @description Creates a form from component configurations.
|
|
85
186
|
* @summary Generates a FormGroup based on an array of component configurations and optionally registers it.
|
|
86
187
|
* @param {string} id - The unique identifier for the form.
|
|
87
|
-
* @param {
|
|
188
|
+
* @param {IComponentConfig[]} components - An array of component configurations.
|
|
88
189
|
* @param {boolean} [registry=false] - Whether to register the created form.
|
|
89
190
|
* @return {FormGroup} The created FormGroup.
|
|
90
191
|
*/
|
|
91
|
-
static createFormFromComponents(id: string, components:
|
|
192
|
+
static createFormFromComponents(id: string, components: IComponentConfig[], registry?: boolean): FormGroup;
|
|
92
193
|
/**
|
|
93
194
|
* @description Adds a control to a form based on component properties.
|
|
94
195
|
* @summary Creates and adds a form control to a form (existing or new) based on the provided component properties.
|
|
@@ -96,7 +197,7 @@ export declare class NgxFormService {
|
|
|
96
197
|
* @param {FieldProperties} componentProperties - The properties of the component to create the control from.
|
|
97
198
|
* @return {AbstractControl} The form or created control.
|
|
98
199
|
*/
|
|
99
|
-
static addControlFromProps(id: string, componentProperties: FieldProperties): AbstractControl;
|
|
200
|
+
static addControlFromProps(id: string, componentProperties: FieldProperties, parentProps?: FieldProperties): AbstractControl;
|
|
100
201
|
/**
|
|
101
202
|
* @description Retrieves form data from a FormGroup.
|
|
102
203
|
* @summary Extracts and processes the data from a FormGroup, handling different input types and nested form groups.
|
|
@@ -112,7 +213,7 @@ export declare class NgxFormService {
|
|
|
112
213
|
* @return {boolean} True if all fields are valid, false otherwise.
|
|
113
214
|
* @throws {Error} If no control is found at the specified path or if the control type is unknown.
|
|
114
215
|
*/
|
|
115
|
-
static validateFields(control: AbstractControl, path?: string): boolean;
|
|
216
|
+
static validateFields(control: AbstractControl, pk?: string, path?: string): boolean;
|
|
116
217
|
/**
|
|
117
218
|
* @description Generates validators from component properties.
|
|
118
219
|
* @summary Creates an array of ValidatorFn based on the supported validation keys in the component properties.
|
|
@@ -134,7 +235,7 @@ export declare class NgxFormService {
|
|
|
134
235
|
* @param {FormControl} control - The FormControl to get properties for.
|
|
135
236
|
* @return {FieldProperties} The properties associated with the control.
|
|
136
237
|
*/
|
|
137
|
-
static getPropsFromControl(control: FormControl): FieldProperties;
|
|
238
|
+
static getPropsFromControl(control: FormControl | FormArray | FormGroup): FieldProperties;
|
|
138
239
|
/**
|
|
139
240
|
* @description Finds a parent element with a specific tag.
|
|
140
241
|
* @summary Traverses up the DOM tree to find the nearest parent element with the specified tag.
|
|
@@ -163,5 +264,5 @@ export declare class NgxFormService {
|
|
|
163
264
|
* @summary Recursively resets all controls in a form group, clearing values, errors, and marking them as pristine and untouched.
|
|
164
265
|
* @param {FormGroup} formGroup - The form group to reset.
|
|
165
266
|
*/
|
|
166
|
-
static reset(formGroup: FormGroup): void;
|
|
267
|
+
static reset(formGroup: FormGroup | FormControl): void;
|
|
167
268
|
}
|
|
@@ -1,71 +1,154 @@
|
|
|
1
|
-
import { RenderingEngine } from '@decaf-ts/ui-decorators';
|
|
2
|
-
import {
|
|
1
|
+
import { FieldDefinition, RenderingEngine } from '@decaf-ts/ui-decorators';
|
|
2
|
+
import { AngularFieldDefinition, KeyValue } from './types';
|
|
3
|
+
import { AngularDynamicOutput } from './interfaces';
|
|
3
4
|
import { Constructor, Model } from '@decaf-ts/decorator-validation';
|
|
4
|
-
import { Injector, TemplateRef, ViewContainerRef } from '@angular/core';
|
|
5
|
+
import { ComponentMirror, ComponentRef, Injector, TemplateRef, Type, ViewContainerRef } from '@angular/core';
|
|
5
6
|
/**
|
|
6
|
-
* @description Angular implementation of the RenderingEngine
|
|
7
|
-
* @summary This class extends the base RenderingEngine to provide Angular-specific rendering capabilities
|
|
8
|
-
* It handles the conversion of field definitions
|
|
7
|
+
* @description Angular implementation of the RenderingEngine with enhanced features
|
|
8
|
+
* @summary This class extends the base RenderingEngine to provide Angular-specific rendering capabilities
|
|
9
|
+
* with additional features compared to NgxRenderingEngine. It handles the conversion of field definitions
|
|
10
|
+
* to Angular components, manages component registration, and provides utilities for component creation
|
|
11
|
+
* and input handling. This implementation uses Angular's newer component APIs.
|
|
12
|
+
*
|
|
9
13
|
* @template AngularFieldDefinition - Type for Angular-specific field definitions
|
|
10
14
|
* @template AngularDynamicOutput - Type for Angular-specific component output
|
|
11
|
-
*
|
|
12
|
-
* @param {ViewContainerRef} vcr - View container reference for component creation
|
|
13
|
-
* @param {TemplateRef<any>} tpl - Template reference for content projection
|
|
15
|
+
*
|
|
14
16
|
* @class NgxRenderingEngine
|
|
15
17
|
* @example
|
|
16
18
|
* ```typescript
|
|
17
|
-
* const engine =
|
|
19
|
+
* const engine = NgxRenderingEngine.get();
|
|
18
20
|
* engine.initialize();
|
|
19
21
|
* const output = engine.render(myModel, {}, viewContainerRef, injector, templateRef);
|
|
20
22
|
* ```
|
|
23
|
+
*
|
|
21
24
|
* @mermaid
|
|
22
25
|
* sequenceDiagram
|
|
23
26
|
* participant Client
|
|
24
27
|
* participant Engine as NgxRenderingEngine
|
|
25
28
|
* participant Components as RegisteredComponents
|
|
26
29
|
*
|
|
27
|
-
* Client->>Engine:
|
|
30
|
+
* Client->>Engine: get()
|
|
28
31
|
* Client->>Engine: initialize()
|
|
29
32
|
* Client->>Engine: render(model, props, vcr, injector, tpl)
|
|
30
33
|
* Engine->>Engine: toFieldDefinition(model, props)
|
|
31
34
|
* Engine->>Engine: fromFieldDefinition(fieldDef, vcr, injector, tpl)
|
|
32
35
|
* Engine->>Components: components(fieldDef.tag)
|
|
33
36
|
* Components-->>Engine: component constructor
|
|
34
|
-
* Engine->>
|
|
37
|
+
* Engine->>Engine: createComponent(component, inputs, metadata, vcr, injector, template)
|
|
38
|
+
* Engine-->>Client: return AngularDynamicOutput
|
|
35
39
|
*/
|
|
36
40
|
export declare class NgxRenderingEngine extends RenderingEngine<AngularFieldDefinition, AngularDynamicOutput> {
|
|
41
|
+
/**
|
|
42
|
+
* @description Registry of registered components
|
|
43
|
+
* @summary Static registry that maps component names to their constructors.
|
|
44
|
+
* This allows the engine to look up components by name when rendering.
|
|
45
|
+
* @type {Record<string, { constructor: Constructor<unknown> }>}
|
|
46
|
+
*/
|
|
37
47
|
private static _components;
|
|
48
|
+
/**
|
|
49
|
+
* @description Collection of child component outputs
|
|
50
|
+
* @summary Stores the outputs of child components during rendering.
|
|
51
|
+
* @type {AngularDynamicOutput[]}
|
|
52
|
+
*/
|
|
53
|
+
private _childs;
|
|
54
|
+
/**
|
|
55
|
+
* @description Current model being rendered
|
|
56
|
+
* @summary Reference to the model currently being processed by the rendering engine.
|
|
57
|
+
* @type {Model}
|
|
58
|
+
*/
|
|
59
|
+
private _model;
|
|
60
|
+
private static _operation;
|
|
61
|
+
/**
|
|
62
|
+
* @description Static reference to the current instance
|
|
63
|
+
* @summary Singleton instance reference for the rendering engine.
|
|
64
|
+
* @type {Type<unknown> | undefined}
|
|
65
|
+
*/
|
|
66
|
+
private static _instance;
|
|
67
|
+
/**
|
|
68
|
+
* @description Creates a new instance of NgxRenderingEngine
|
|
69
|
+
* @summary Initializes the rendering engine with the 'angular' engine type.
|
|
70
|
+
* This constructor sets up the base configuration needed for Angular-specific rendering.
|
|
71
|
+
*/
|
|
38
72
|
constructor();
|
|
39
73
|
/**
|
|
40
74
|
* @description Converts a field definition to an Angular component output
|
|
41
75
|
* @summary This private method takes a field definition and creates the corresponding Angular component.
|
|
42
76
|
* It handles component instantiation, input property mapping, and child component rendering.
|
|
77
|
+
* The method validates input properties against the component's metadata and processes
|
|
78
|
+
* child components recursively.
|
|
79
|
+
*
|
|
43
80
|
* @param {FieldDefinition<AngularFieldDefinition>} fieldDef - The field definition to convert
|
|
44
81
|
* @param {ViewContainerRef} vcr - The view container reference for component creation
|
|
45
82
|
* @param {Injector} injector - The Angular injector for dependency injection
|
|
46
83
|
* @param {TemplateRef<any>} tpl - The template reference for content projection
|
|
84
|
+
* @param {string} registryFormId - Form identifier for the component renderer
|
|
47
85
|
* @return {AngularDynamicOutput} The Angular component output with component reference and inputs
|
|
86
|
+
*
|
|
48
87
|
* @mermaid
|
|
49
88
|
* sequenceDiagram
|
|
50
89
|
* participant Method as fromFieldDefinition
|
|
51
90
|
* participant Components as NgxRenderingEngine.components
|
|
52
91
|
* participant Angular as Angular Core
|
|
92
|
+
* participant Process as processChild
|
|
53
93
|
*
|
|
54
94
|
* Method->>Components: components(fieldDef.tag)
|
|
55
95
|
* Components-->>Method: component constructor
|
|
56
96
|
* Method->>Angular: reflectComponentType(component)
|
|
57
97
|
* Angular-->>Method: componentMetadata
|
|
58
|
-
* Method->>Method:
|
|
98
|
+
* Method->>Method: Validate input properties
|
|
59
99
|
* Method->>Method: Create result object
|
|
60
|
-
*
|
|
100
|
+
* alt Has children
|
|
101
|
+
* Method->>Process: Process children recursively
|
|
102
|
+
* Process->>Method: Return processed children
|
|
103
|
+
* Method->>Angular: Create embedded view
|
|
104
|
+
* Method->>Method: Create component instance
|
|
105
|
+
* end
|
|
61
106
|
* Method-->>Caller: return AngularDynamicOutput
|
|
62
107
|
*/
|
|
63
108
|
private fromFieldDefinition;
|
|
109
|
+
/**
|
|
110
|
+
* @description Creates an Angular component instance
|
|
111
|
+
* @summary This static utility method creates an Angular component instance with the specified
|
|
112
|
+
* inputs and template. It uses Angular's component creation API to instantiate the component
|
|
113
|
+
* and then sets the input properties using the provided metadata.
|
|
114
|
+
*
|
|
115
|
+
* @param {Type<unknown>} component - The component type to create
|
|
116
|
+
* @param {KeyValue} [inputs={}] - The input properties to set on the component
|
|
117
|
+
* @param {ComponentMirror<unknown>} metadata - The component metadata for input validation
|
|
118
|
+
* @param {ViewContainerRef} vcr - The view container reference for component creation
|
|
119
|
+
* @param {Injector} injector - The Angular injector for dependency injection
|
|
120
|
+
* @param {Node[]} [template=[]] - The template nodes to project into the component
|
|
121
|
+
* @return {ComponentRef<unknown>} The created component reference
|
|
122
|
+
*/
|
|
123
|
+
static createComponent(component: Type<unknown>, inputs: KeyValue | undefined, metadata: ComponentMirror<unknown>, vcr: ViewContainerRef, injector: Injector, template?: Node[]): ComponentRef<unknown>;
|
|
124
|
+
/**
|
|
125
|
+
* @description Extracts decorator metadata from a model
|
|
126
|
+
* @summary This method provides access to the field definition generated from a model's
|
|
127
|
+
* decorators. It's a convenience wrapper around the toFieldDefinition method that
|
|
128
|
+
* converts a model to a field definition based on its decorators and the provided
|
|
129
|
+
* global properties.
|
|
130
|
+
*
|
|
131
|
+
* @param {Model} model - The model to extract decorators from
|
|
132
|
+
* @param {Record<string, unknown>} globalProps - Global properties to include in the field definition
|
|
133
|
+
* @return {FieldDefinition<AngularFieldDefinition>} The field definition generated from the model
|
|
134
|
+
*/
|
|
135
|
+
getDecorators(model: Model, globalProps: Record<string, unknown>): FieldDefinition<AngularFieldDefinition>;
|
|
136
|
+
/**
|
|
137
|
+
* @description Destroys the current engine instance
|
|
138
|
+
* @summary This static method clears the current instance reference, effectively
|
|
139
|
+
* destroying the singleton instance of the rendering engine. This can be used
|
|
140
|
+
* to reset the engine state or to prepare for a new instance creation.
|
|
141
|
+
*
|
|
142
|
+
* @return {Promise<void>} A promise that resolves when the instance is destroyed
|
|
143
|
+
*/
|
|
144
|
+
static destroy(): Promise<void>;
|
|
64
145
|
/**
|
|
65
146
|
* @description Renders a model into an Angular component output
|
|
66
147
|
* @summary This method takes a model and converts it to an Angular component output.
|
|
67
|
-
* It first
|
|
68
|
-
*
|
|
148
|
+
* It first stores a reference to the model, then converts it to a field definition
|
|
149
|
+
* using the base RenderingEngine's toFieldDefinition method, and finally converts
|
|
150
|
+
* that field definition to an Angular component output using fromFieldDefinition.
|
|
151
|
+
*
|
|
69
152
|
* @template M - Type extending Model
|
|
70
153
|
* @param {M} model - The model to render
|
|
71
154
|
* @param {Record<string, unknown>} globalProps - Global properties to pass to the component
|
|
@@ -73,6 +156,7 @@ export declare class NgxRenderingEngine extends RenderingEngine<AngularFieldDefi
|
|
|
73
156
|
* @param {Injector} injector - The Angular injector for dependency injection
|
|
74
157
|
* @param {TemplateRef<any>} tpl - The template reference for content projection
|
|
75
158
|
* @return {AngularDynamicOutput} The Angular component output with component reference and inputs
|
|
159
|
+
*
|
|
76
160
|
* @mermaid
|
|
77
161
|
* sequenceDiagram
|
|
78
162
|
* participant Client as Client Code
|
|
@@ -81,6 +165,7 @@ export declare class NgxRenderingEngine extends RenderingEngine<AngularFieldDefi
|
|
|
81
165
|
* participant FromField as fromFieldDefinition
|
|
82
166
|
*
|
|
83
167
|
* Client->>Render: render(model, globalProps, vcr, injector, tpl)
|
|
168
|
+
* Render->>Render: Store model reference
|
|
84
169
|
* Render->>ToField: toFieldDefinition(model, globalProps)
|
|
85
170
|
* ToField-->>Render: fieldDef
|
|
86
171
|
* Render->>FromField: fromFieldDefinition(fieldDef, vcr, injector, tpl)
|
|
@@ -91,14 +176,19 @@ export declare class NgxRenderingEngine extends RenderingEngine<AngularFieldDefi
|
|
|
91
176
|
/**
|
|
92
177
|
* @description Initializes the rendering engine
|
|
93
178
|
* @summary This method initializes the rendering engine. It checks if the engine is already initialized
|
|
94
|
-
* and sets the initialized flag to true. This method is called before the engine is used
|
|
179
|
+
* and sets the initialized flag to true. This method is called before the engine is used
|
|
180
|
+
* to ensure it's properly set up for rendering operations.
|
|
181
|
+
*
|
|
95
182
|
* @return {Promise<void>} A promise that resolves when initialization is complete
|
|
96
183
|
*/
|
|
97
184
|
initialize(): Promise<void>;
|
|
98
185
|
/**
|
|
99
186
|
* @description Registers a component with the rendering engine
|
|
100
187
|
* @summary This static method registers a component constructor with the rendering engine
|
|
101
|
-
* under a specific name. It
|
|
188
|
+
* under a specific name. It initializes the components registry if needed and throws
|
|
189
|
+
* an error if a component is already registered under the same name to prevent
|
|
190
|
+
* accidental overrides.
|
|
191
|
+
*
|
|
102
192
|
* @param {string} name - The name to register the component under
|
|
103
193
|
* @param {Constructor<unknown>} constructor - The component constructor
|
|
104
194
|
* @return {void}
|
|
@@ -107,21 +197,56 @@ export declare class NgxRenderingEngine extends RenderingEngine<AngularFieldDefi
|
|
|
107
197
|
/**
|
|
108
198
|
* @description Retrieves registered components from the rendering engine
|
|
109
199
|
* @summary This static method retrieves either all registered components or a specific component
|
|
110
|
-
* by its selector.
|
|
200
|
+
* by its selector. When called without a selector, it returns an array of all registered
|
|
201
|
+
* components. When called with a selector, it returns the specific component if found,
|
|
202
|
+
* or throws an error if the component is not registered.
|
|
203
|
+
*
|
|
111
204
|
* @param {string} [selector] - Optional selector to retrieve a specific component
|
|
112
205
|
* @return {Object|Array} Either a specific component or an array of all components
|
|
113
206
|
*/
|
|
114
|
-
static components(selector?: string):
|
|
115
|
-
constructor: Constructor<unknown>;
|
|
116
|
-
} | {
|
|
117
|
-
constructor: Constructor<unknown>;
|
|
118
|
-
}[];
|
|
207
|
+
static components(selector?: string): object | string[];
|
|
119
208
|
/**
|
|
120
209
|
* @description Generates a key for reflection metadata
|
|
121
210
|
* @summary This static method generates a key for reflection metadata by prefixing the input key
|
|
122
|
-
* with the Angular engine's reflection prefix. This is used for storing and retrieving
|
|
211
|
+
* with the Angular engine's reflection prefix. This is used for storing and retrieving
|
|
212
|
+
* metadata in a namespaced way to avoid conflicts with other metadata.
|
|
213
|
+
*
|
|
123
214
|
* @param {string} key - The base key to prefix
|
|
124
215
|
* @return {string} The prefixed key for reflection metadata
|
|
125
216
|
*/
|
|
126
217
|
static key(key: string): string;
|
|
218
|
+
/**
|
|
219
|
+
* @description Sets input properties on a component instance
|
|
220
|
+
* @summary This static utility method sets input properties on a component instance
|
|
221
|
+
* based on the provided inputs object and component metadata. It handles both simple
|
|
222
|
+
* values and nested objects, recursively processing object properties. The method
|
|
223
|
+
* validates each input against the component's metadata to ensure only valid inputs
|
|
224
|
+
* are set.
|
|
225
|
+
*
|
|
226
|
+
* @param {ComponentRef<unknown>} component - The component reference to set inputs on
|
|
227
|
+
* @param {KeyValue} inputs - The input properties to set
|
|
228
|
+
* @param {ComponentMirror<unknown>} metadata - The component metadata for input validation
|
|
229
|
+
* @return {void}
|
|
230
|
+
*
|
|
231
|
+
* @mermaid
|
|
232
|
+
* sequenceDiagram
|
|
233
|
+
* participant Caller
|
|
234
|
+
* participant SetInputs as setInputs
|
|
235
|
+
* participant Parse as parseInputValue
|
|
236
|
+
* participant Component as ComponentRef
|
|
237
|
+
*
|
|
238
|
+
* Caller->>SetInputs: setInputs(component, inputs, metadata)
|
|
239
|
+
* SetInputs->>SetInputs: Iterate through inputs
|
|
240
|
+
* loop For each input
|
|
241
|
+
* SetInputs->>SetInputs: Check if input exists in metadata
|
|
242
|
+
* alt Input is 'props'
|
|
243
|
+
* SetInputs->>Parse: parseInputValue(component, value)
|
|
244
|
+
* Parse->>Parse: Recursively process nested objects
|
|
245
|
+
* Parse->>Component: setInput(key, value)
|
|
246
|
+
* else Input is valid
|
|
247
|
+
* SetInputs->>Component: setInput(key, value)
|
|
248
|
+
* end
|
|
249
|
+
* end
|
|
250
|
+
*/
|
|
251
|
+
static setInputs(component: ComponentRef<unknown>, inputs: KeyValue, metadata: ComponentMirror<unknown>): void;
|
|
127
252
|
}
|
package/engine/constants.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ export declare const AngularEngineKeys: {
|
|
|
32
32
|
RENDERED_ID: string;
|
|
33
33
|
PARENT: string;
|
|
34
34
|
VALIDATION_PARENT_KEY: symbol;
|
|
35
|
+
FORM_GROUP_COMPONENT_PROPS: string;
|
|
35
36
|
};
|
|
36
37
|
/**
|
|
37
38
|
* @description Form validation state constants
|
|
@@ -59,12 +60,16 @@ export declare const FormConstants: {
|
|
|
59
60
|
* @property {string} SUBMIT_EVENT - Event fired when a form submission occurs
|
|
60
61
|
* @memberOf module:engine
|
|
61
62
|
*/
|
|
62
|
-
export declare
|
|
63
|
-
BACK_BUTTON_NAVIGATION
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
63
|
+
export declare const EventConstants: {
|
|
64
|
+
BACK_BUTTON_NAVIGATION: string;
|
|
65
|
+
REFRESH: string;
|
|
66
|
+
CLICK: string;
|
|
67
|
+
SUBMIT: string;
|
|
68
|
+
VALIDATION_ERROR: string;
|
|
69
|
+
FIELDSET_ADD_GROUP: string;
|
|
70
|
+
FIELDSET_UPDATE_GROUP: string;
|
|
71
|
+
FIELDSET_REMOVE_GROUP: string;
|
|
72
|
+
};
|
|
68
73
|
/**
|
|
69
74
|
* @description Logger level constants
|
|
70
75
|
* @summary Enum defining the logging levels used in the application's logging system.
|
package/engine/decorators.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @description Marks an Angular component as dynamically loadable
|
|
3
|
-
* @summary Decorator that registers an Angular component with the
|
|
3
|
+
* @summary Decorator that registers an Angular component with the NgxRenderingEngine for dynamic loading.
|
|
4
4
|
* This decorator must be applied before the @Component decorator to properly extract component metadata.
|
|
5
5
|
* It adds metadata to the component class and registers it with the rendering engine using its selector.
|
|
6
6
|
* @function Dynamic
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* sequenceDiagram
|
|
10
10
|
* participant C as Component Class
|
|
11
11
|
* participant D as Dynamic Decorator
|
|
12
|
-
* participant R as
|
|
12
|
+
* participant R as NgxRenderingEngine
|
|
13
13
|
* participant M as Angular Metadata
|
|
14
14
|
* C->>D: Apply decorator
|
|
15
15
|
* D->>M: reflectComponentType()
|
package/engine/index.d.ts
CHANGED
|
@@ -9,8 +9,10 @@
|
|
|
9
9
|
*/
|
|
10
10
|
export * from './constants';
|
|
11
11
|
export * from './decorators';
|
|
12
|
+
export * from './types';
|
|
13
|
+
export * from './interfaces';
|
|
12
14
|
export * from './DynamicModule';
|
|
13
15
|
export * from './NgxRenderingEngine';
|
|
14
|
-
export * from './NgxRenderingEngine2';
|
|
15
|
-
export * from './types';
|
|
16
16
|
export * from './NgxBaseComponent';
|
|
17
|
+
export * from './NgxCrudFormField';
|
|
18
|
+
export * from './NgxFormService';
|