@decaf-ts/for-angular 0.0.15 → 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.
Files changed (61) hide show
  1. package/assets/i18n/en.json +10 -0
  2. package/assets/i18n/pt.json +149 -0
  3. package/assets/icons/icon-128.webp +0 -0
  4. package/assets/icons/icon-192.webp +0 -0
  5. package/assets/icons/icon-256.webp +0 -0
  6. package/assets/icons/icon-48.webp +0 -0
  7. package/assets/icons/icon-512.webp +0 -0
  8. package/assets/icons/icon-72.webp +0 -0
  9. package/assets/icons/icon-96.webp +0 -0
  10. package/assets/images/apple-touch-icon.png +0 -0
  11. package/assets/images/favicon.png +0 -0
  12. package/assets/images/favicon.svg +29 -0
  13. package/components/component-renderer/component-renderer.component.d.ts +5 -4
  14. package/components/crud-field/crud-field.component.d.ts +174 -19
  15. package/components/crud-form/crud-form.component.d.ts +170 -6
  16. package/components/fieldset/fieldset.component.d.ts +374 -36
  17. package/components/list/list.component.d.ts +1 -1
  18. package/components/list-item/list-item.component.d.ts +2 -2
  19. package/components/model-renderer/model-renderer.component.d.ts +1 -5
  20. package/directives/collapsable.directive.d.ts +1 -0
  21. package/engine/NgxBaseComponent.d.ts +6 -6
  22. package/engine/NgxCrudFormField.d.ts +5 -2
  23. package/engine/NgxFormService.d.ts +113 -12
  24. package/engine/NgxRenderingEngine.d.ts +150 -25
  25. package/engine/constants.d.ts +11 -6
  26. package/engine/decorators.d.ts +2 -2
  27. package/engine/index.d.ts +4 -2
  28. package/engine/interfaces.d.ts +261 -0
  29. package/engine/types.d.ts +3 -206
  30. package/esm2022/components/component-renderer/component-renderer.component.mjs +13 -11
  31. package/esm2022/components/crud-field/crud-field.component.mjs +193 -8
  32. package/esm2022/components/crud-form/crud-form.component.mjs +116 -11
  33. package/esm2022/components/empty-state/empty-state.component.mjs +3 -3
  34. package/esm2022/components/fieldset/fieldset.component.mjs +482 -43
  35. package/esm2022/components/filter/filter.component.mjs +3 -3
  36. package/esm2022/components/layout/layout.component.mjs +3 -3
  37. package/esm2022/components/list/list.component.mjs +4 -5
  38. package/esm2022/components/list-item/list-item.component.mjs +9 -9
  39. package/esm2022/components/model-renderer/model-renderer.component.mjs +9 -8
  40. package/esm2022/components/pagination/pagination.component.mjs +4 -4
  41. package/esm2022/components/searchbar/searchbar.component.mjs +3 -3
  42. package/esm2022/directives/collapsable.directive.mjs +3 -2
  43. package/esm2022/engine/NgxBaseComponent.mjs +28 -22
  44. package/esm2022/engine/NgxCrudFormField.mjs +14 -4
  45. package/esm2022/engine/NgxFormService.mjs +239 -27
  46. package/esm2022/engine/NgxRenderingEngine.mjs +202 -46
  47. package/esm2022/engine/ValidatorFactory.mjs +6 -2
  48. package/esm2022/engine/constants.mjs +14 -9
  49. package/esm2022/engine/decorators.mjs +6 -6
  50. package/esm2022/engine/index.mjs +5 -3
  51. package/esm2022/engine/interfaces.mjs +4 -0
  52. package/esm2022/engine/types.mjs +1 -3
  53. package/esm2022/helpers/utils.mjs +6 -2
  54. package/fesm2022/decaf-ts-for-angular.mjs +2910 -2129
  55. package/fesm2022/decaf-ts-for-angular.mjs.map +1 -1
  56. package/helpers/utils.d.ts +1 -0
  57. package/package.json +2 -1
  58. package/engine/NgxRenderingEngine2.d.ts +0 -250
  59. package/esm2022/engine/NgxRenderingEngine2.mjs +0 -332
  60. package/esm2022/interfaces.mjs +0 -2
  61. package/interfaces.d.ts +0 -28
@@ -251,3 +251,4 @@ export declare function itemMapper(item: KeyValue, mapper: KeyValue, props?: Key
251
251
  */
252
252
  export declare function dataMapper<T>(data: T[], mapper: KeyValue, props?: KeyValue): T[];
253
253
  export declare function removeFocusTrap(): void;
254
+ export declare function cleanSpaces(value: string, lowercase?: boolean): string;
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@decaf-ts/for-angular",
3
- "version": "0.0.15",
3
+ "version": "0.0.17",
4
4
  "author": "Tiago Venceslau",
5
5
  "license": "AGPL-3.0-or-later",
6
6
  "peerDependencies": {
7
7
  "@angular/animations": "^18.2.13",
8
+ "@angular/cdk": "^18.2.14",
8
9
  "@angular/common": "^18.2.13",
9
10
  "@angular/compiler": "^18.2.13",
10
11
  "@angular/core": "^18.2.13",
@@ -1,250 +0,0 @@
1
- import { FieldDefinition, RenderingEngine } from '@decaf-ts/ui-decorators';
2
- import { AngularDynamicOutput, AngularFieldDefinition, KeyValue } from './types';
3
- import { Constructor, Model } from '@decaf-ts/decorator-validation';
4
- import { ComponentMirror, ComponentRef, Injector, TemplateRef, Type, ViewContainerRef } from '@angular/core';
5
- /**
6
- * @description Angular implementation of the RenderingEngine with enhanced features
7
- * @summary This class extends the base RenderingEngine to provide Angular-specific rendering capabilities
8
- * with additional features compared to NgxRenderingEngine. It handles the conversion of field definitions
9
- * to Angular components, manages component registration, and provides utilities for component creation
10
- * and input handling. This implementation uses Angular's newer component APIs.
11
- *
12
- * @template AngularFieldDefinition - Type for Angular-specific field definitions
13
- * @template AngularDynamicOutput - Type for Angular-specific component output
14
- *
15
- * @class NgxRenderingEngine2
16
- * @example
17
- * ```typescript
18
- * const engine = NgxRenderingEngine2.get();
19
- * engine.initialize();
20
- * const output = engine.render(myModel, {}, viewContainerRef, injector, templateRef);
21
- * ```
22
- *
23
- * @mermaid
24
- * sequenceDiagram
25
- * participant Client
26
- * participant Engine as NgxRenderingEngine2
27
- * participant Components as RegisteredComponents
28
- *
29
- * Client->>Engine: get()
30
- * Client->>Engine: initialize()
31
- * Client->>Engine: render(model, props, vcr, injector, tpl)
32
- * Engine->>Engine: toFieldDefinition(model, props)
33
- * Engine->>Engine: fromFieldDefinition(fieldDef, vcr, injector, tpl)
34
- * Engine->>Components: components(fieldDef.tag)
35
- * Components-->>Engine: component constructor
36
- * Engine->>Engine: createComponent(component, inputs, metadata, vcr, injector, template)
37
- * Engine-->>Client: return AngularDynamicOutput
38
- */
39
- export declare class NgxRenderingEngine2 extends RenderingEngine<AngularFieldDefinition, AngularDynamicOutput> {
40
- /**
41
- * @description Registry of registered components
42
- * @summary Static registry that maps component names to their constructors.
43
- * This allows the engine to look up components by name when rendering.
44
- * @type {Record<string, { constructor: Constructor<unknown> }>}
45
- */
46
- private static _components;
47
- /**
48
- * @description Collection of child component outputs
49
- * @summary Stores the outputs of child components during rendering.
50
- * @type {AngularDynamicOutput[]}
51
- */
52
- private _childs;
53
- /**
54
- * @description Current model being rendered
55
- * @summary Reference to the model currently being processed by the rendering engine.
56
- * @type {Model}
57
- */
58
- private _model;
59
- /**
60
- * @description Static reference to the current instance
61
- * @summary Singleton instance reference for the rendering engine.
62
- * @type {Type<unknown> | undefined}
63
- */
64
- private static _instance;
65
- /**
66
- * @description Creates a new instance of NgxRenderingEngine2
67
- * @summary Initializes the rendering engine with the 'angular' engine type.
68
- * This constructor sets up the base configuration needed for Angular-specific rendering.
69
- */
70
- constructor();
71
- /**
72
- * @description Converts a field definition to an Angular component output
73
- * @summary This private method takes a field definition and creates the corresponding Angular component.
74
- * It handles component instantiation, input property mapping, and child component rendering.
75
- * The method validates input properties against the component's metadata and processes
76
- * child components recursively.
77
- *
78
- * @param {FieldDefinition<AngularFieldDefinition>} fieldDef - The field definition to convert
79
- * @param {ViewContainerRef} vcr - The view container reference for component creation
80
- * @param {Injector} injector - The Angular injector for dependency injection
81
- * @param {TemplateRef<any>} tpl - The template reference for content projection
82
- * @param {string} registryFormId - Form identifier for the component renderer
83
- * @return {AngularDynamicOutput} The Angular component output with component reference and inputs
84
- *
85
- * @mermaid
86
- * sequenceDiagram
87
- * participant Method as fromFieldDefinition
88
- * participant Components as NgxRenderingEngine2.components
89
- * participant Angular as Angular Core
90
- * participant Process as processChild
91
- *
92
- * Method->>Components: components(fieldDef.tag)
93
- * Components-->>Method: component constructor
94
- * Method->>Angular: reflectComponentType(component)
95
- * Angular-->>Method: componentMetadata
96
- * Method->>Method: Validate input properties
97
- * Method->>Method: Create result object
98
- * alt Has children
99
- * Method->>Process: Process children recursively
100
- * Process->>Method: Return processed children
101
- * Method->>Angular: Create embedded view
102
- * Method->>Method: Create component instance
103
- * end
104
- * Method-->>Caller: return AngularDynamicOutput
105
- */
106
- private fromFieldDefinition;
107
- /**
108
- * @description Creates an Angular component instance
109
- * @summary This static utility method creates an Angular component instance with the specified
110
- * inputs and template. It uses Angular's component creation API to instantiate the component
111
- * and then sets the input properties using the provided metadata.
112
- *
113
- * @param {Type<unknown>} component - The component type to create
114
- * @param {KeyValue} [inputs={}] - The input properties to set on the component
115
- * @param {ComponentMirror<unknown>} metadata - The component metadata for input validation
116
- * @param {ViewContainerRef} vcr - The view container reference for component creation
117
- * @param {Injector} injector - The Angular injector for dependency injection
118
- * @param {Node[]} [template=[]] - The template nodes to project into the component
119
- * @return {ComponentRef<unknown>} The created component reference
120
- */
121
- static createComponent(component: Type<unknown>, inputs: KeyValue | undefined, metadata: ComponentMirror<unknown>, vcr: ViewContainerRef, injector: Injector, template?: Node[]): ComponentRef<unknown>;
122
- /**
123
- * @description Extracts decorator metadata from a model
124
- * @summary This method provides access to the field definition generated from a model's
125
- * decorators. It's a convenience wrapper around the toFieldDefinition method that
126
- * converts a model to a field definition based on its decorators and the provided
127
- * global properties.
128
- *
129
- * @param {Model} model - The model to extract decorators from
130
- * @param {Record<string, unknown>} globalProps - Global properties to include in the field definition
131
- * @return {FieldDefinition<AngularFieldDefinition>} The field definition generated from the model
132
- */
133
- getDecorators(model: Model, globalProps: Record<string, unknown>): FieldDefinition<AngularFieldDefinition>;
134
- /**
135
- * @description Destroys the current engine instance
136
- * @summary This static method clears the current instance reference, effectively
137
- * destroying the singleton instance of the rendering engine. This can be used
138
- * to reset the engine state or to prepare for a new instance creation.
139
- *
140
- * @return {Promise<void>} A promise that resolves when the instance is destroyed
141
- */
142
- static destroy(): Promise<void>;
143
- /**
144
- * @description Renders a model into an Angular component output
145
- * @summary This method takes a model and converts it to an Angular component output.
146
- * It first stores a reference to the model, then converts it to a field definition
147
- * using the base RenderingEngine's toFieldDefinition method, and finally converts
148
- * that field definition to an Angular component output using fromFieldDefinition.
149
- *
150
- * @template M - Type extending Model
151
- * @param {M} model - The model to render
152
- * @param {Record<string, unknown>} globalProps - Global properties to pass to the component
153
- * @param {ViewContainerRef} vcr - The view container reference for component creation
154
- * @param {Injector} injector - The Angular injector for dependency injection
155
- * @param {TemplateRef<any>} tpl - The template reference for content projection
156
- * @return {AngularDynamicOutput} The Angular component output with component reference and inputs
157
- *
158
- * @mermaid
159
- * sequenceDiagram
160
- * participant Client as Client Code
161
- * participant Render as render method
162
- * participant ToField as toFieldDefinition
163
- * participant FromField as fromFieldDefinition
164
- *
165
- * Client->>Render: render(model, globalProps, vcr, injector, tpl)
166
- * Render->>Render: Store model reference
167
- * Render->>ToField: toFieldDefinition(model, globalProps)
168
- * ToField-->>Render: fieldDef
169
- * Render->>FromField: fromFieldDefinition(fieldDef, vcr, injector, tpl)
170
- * FromField-->>Render: AngularDynamicOutput
171
- * Render-->>Client: return AngularDynamicOutput
172
- */
173
- render<M extends Model>(model: M, globalProps: Record<string, unknown>, vcr: ViewContainerRef, injector: Injector, tpl: TemplateRef<unknown>): AngularDynamicOutput;
174
- /**
175
- * @description Initializes the rendering engine
176
- * @summary This method initializes the rendering engine. It checks if the engine is already initialized
177
- * and sets the initialized flag to true. This method is called before the engine is used
178
- * to ensure it's properly set up for rendering operations.
179
- *
180
- * @return {Promise<void>} A promise that resolves when initialization is complete
181
- */
182
- initialize(): Promise<void>;
183
- /**
184
- * @description Registers a component with the rendering engine
185
- * @summary This static method registers a component constructor with the rendering engine
186
- * under a specific name. It initializes the components registry if needed and throws
187
- * an error if a component is already registered under the same name to prevent
188
- * accidental overrides.
189
- *
190
- * @param {string} name - The name to register the component under
191
- * @param {Constructor<unknown>} constructor - The component constructor
192
- * @return {void}
193
- */
194
- static registerComponent(name: string, constructor: Constructor<unknown>): void;
195
- /**
196
- * @description Retrieves registered components from the rendering engine
197
- * @summary This static method retrieves either all registered components or a specific component
198
- * by its selector. When called without a selector, it returns an array of all registered
199
- * components. When called with a selector, it returns the specific component if found,
200
- * or throws an error if the component is not registered.
201
- *
202
- * @param {string} [selector] - Optional selector to retrieve a specific component
203
- * @return {Object|Array} Either a specific component or an array of all components
204
- */
205
- static components(selector?: string): object | string[];
206
- /**
207
- * @description Generates a key for reflection metadata
208
- * @summary This static method generates a key for reflection metadata by prefixing the input key
209
- * with the Angular engine's reflection prefix. This is used for storing and retrieving
210
- * metadata in a namespaced way to avoid conflicts with other metadata.
211
- *
212
- * @param {string} key - The base key to prefix
213
- * @return {string} The prefixed key for reflection metadata
214
- */
215
- static key(key: string): string;
216
- /**
217
- * @description Sets input properties on a component instance
218
- * @summary This static utility method sets input properties on a component instance
219
- * based on the provided inputs object and component metadata. It handles both simple
220
- * values and nested objects, recursively processing object properties. The method
221
- * validates each input against the component's metadata to ensure only valid inputs
222
- * are set.
223
- *
224
- * @param {ComponentRef<unknown>} component - The component reference to set inputs on
225
- * @param {KeyValue} inputs - The input properties to set
226
- * @param {ComponentMirror<unknown>} metadata - The component metadata for input validation
227
- * @return {void}
228
- *
229
- * @mermaid
230
- * sequenceDiagram
231
- * participant Caller
232
- * participant SetInputs as setInputs
233
- * participant Parse as parseInputValue
234
- * participant Component as ComponentRef
235
- *
236
- * Caller->>SetInputs: setInputs(component, inputs, metadata)
237
- * SetInputs->>SetInputs: Iterate through inputs
238
- * loop For each input
239
- * SetInputs->>SetInputs: Check if input exists in metadata
240
- * alt Input is 'props'
241
- * SetInputs->>Parse: parseInputValue(component, value)
242
- * Parse->>Parse: Recursively process nested objects
243
- * Parse->>Component: setInput(key, value)
244
- * else Input is valid
245
- * SetInputs->>Component: setInput(key, value)
246
- * end
247
- * end
248
- */
249
- static setInputs(component: ComponentRef<unknown>, inputs: KeyValue, metadata: ComponentMirror<unknown>): void;
250
- }