@ngx-formbar/core 0.11.0

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 (201) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +42 -0
  3. package/fesm2022/ngx-formbar-core.mjs +2429 -0
  4. package/fesm2022/ngx-formbar-core.mjs.map +1 -0
  5. package/index.d.ts +5 -0
  6. package/lib/components/form/ngxfb-form.component.d.ts +28 -0
  7. package/lib/composables/computed-value.d.ts +8 -0
  8. package/lib/composables/disabled.state.d.ts +36 -0
  9. package/lib/composables/dynamic-label.d.ts +9 -0
  10. package/lib/composables/dynamic-title.d.ts +9 -0
  11. package/lib/composables/hidden.state.d.ts +68 -0
  12. package/lib/composables/readonly.state.d.ts +19 -0
  13. package/lib/composables/testId.d.ts +16 -0
  14. package/lib/composables/update-strategy.d.ts +20 -0
  15. package/lib/composables/validators.d.ts +22 -0
  16. package/lib/config/config.d.ts +7 -0
  17. package/lib/config/provide-formbar.d.ts +38 -0
  18. package/lib/directives/ngxfb-abstract-control.directive.d.ts +53 -0
  19. package/lib/directives/ngxfb-block.directive.d.ts +124 -0
  20. package/lib/directives/ngxfb-control.directive.d.ts +203 -0
  21. package/lib/directives/ngxfb-group.directive.d.ts +253 -0
  22. package/lib/helper/control-container-view-providers.d.ts +33 -0
  23. package/lib/index.d.ts +23 -0
  24. package/lib/services/component-registration.service.d.ts +8 -0
  25. package/lib/services/configuration.service.d.ts +8 -0
  26. package/lib/services/expression.service.d.ts +148 -0
  27. package/lib/services/form.service.d.ts +10 -0
  28. package/lib/services/validator-registration.service.d.ts +10 -0
  29. package/lib/tokens/component-registrations.d.ts +2 -0
  30. package/lib/tokens/component-resolver.d.ts +3 -0
  31. package/lib/tokens/default-update-strategy.d.ts +3 -0
  32. package/lib/tokens/global-config.d.ts +5 -0
  33. package/lib/tokens/validator-registrations.d.ts +8 -0
  34. package/lib/tokens/validator-resolver.d.ts +3 -0
  35. package/lib/types/component-resolver.type.d.ts +4 -0
  36. package/lib/types/content.type.d.ts +137 -0
  37. package/lib/types/expression.type.d.ts +2 -0
  38. package/lib/types/form.type.d.ts +4 -0
  39. package/lib/types/functions.type.d.ts +4 -0
  40. package/lib/types/global-configuration.type.d.ts +4 -0
  41. package/lib/types/provide.type.d.ts +42 -0
  42. package/lib/types/registration.type.d.ts +18 -0
  43. package/lib/types/validation.type.d.ts +59 -0
  44. package/lib/types/validator-resolver.type.d.ts +6 -0
  45. package/package.json +52 -0
  46. package/public-api.d.ts +1 -0
  47. package/schematics/block/files/__componentName@dasherize__.component.html.template +1 -0
  48. package/schematics/block/files/__componentName@dasherize__.component.ts.template +29 -0
  49. package/schematics/block/files/__interfaceName@dasherize__.type.ts.template +6 -0
  50. package/schematics/block/index.d.ts +3 -0
  51. package/schematics/block/index.js +11 -0
  52. package/schematics/block/index.js.map +1 -0
  53. package/schematics/block/schema.json +62 -0
  54. package/schematics/collection.json +31 -0
  55. package/schematics/control/files/__componentName@dasherize__.component.html.template +0 -0
  56. package/schematics/control/files/__componentName@dasherize__.component.ts.template +29 -0
  57. package/schematics/control/files/__interfaceName@dasherize__.type.ts.template +6 -0
  58. package/schematics/control/index.d.ts +3 -0
  59. package/schematics/control/index.js +11 -0
  60. package/schematics/control/index.js.map +1 -0
  61. package/schematics/control/schema.json +61 -0
  62. package/schematics/group/files/__componentName@dasherize__.component.html.template +5 -0
  63. package/schematics/group/files/__componentName@dasherize__.component.ts.template +29 -0
  64. package/schematics/group/files/__interfaceName@dasherize__.type.ts.template +5 -0
  65. package/schematics/group/index.d.ts +3 -0
  66. package/schematics/group/index.js +11 -0
  67. package/schematics/group/index.js.map +1 -0
  68. package/schematics/group/schema.json +62 -0
  69. package/schematics/ng-add/files/config-registrations/async-validator-registrations.ts.template +4 -0
  70. package/schematics/ng-add/files/config-registrations/component-registrations.ts.template +4 -0
  71. package/schematics/ng-add/files/config-registrations/index.ts.template +3 -0
  72. package/schematics/ng-add/files/config-registrations/validator-registrations.ts.template +4 -0
  73. package/schematics/ng-add/files/helper/block.host-directive.ts.template +6 -0
  74. package/schematics/ng-add/files/helper/control.host-directive.ts.template +6 -0
  75. package/schematics/ng-add/files/helper/group.host-directive.ts.template +6 -0
  76. package/schematics/ng-add/files/helper/index.ts.template +4 -0
  77. package/schematics/ng-add/files/helper/view-provider.ts.template +9 -0
  78. package/schematics/ng-add/files/provider-config/config/__providerConfigFileName__.ts.template +9 -0
  79. package/schematics/ng-add/files/provider-config/inline/__providerConfigFileName__.ts.template +8 -0
  80. package/schematics/ng-add/files/provider-config/token/__providerConfigFileName__.ts.template +4 -0
  81. package/schematics/ng-add/files/schematics-config/__schematicConfigFileName__.json.template +1 -0
  82. package/schematics/ng-add/files/token-registrations/async-validator-registrations.ts.template +8 -0
  83. package/schematics/ng-add/files/token-registrations/component-registrations.ts.template +8 -0
  84. package/schematics/ng-add/files/token-registrations/index.ts.template +3 -0
  85. package/schematics/ng-add/files/token-registrations/validator-registrations.ts.template +8 -0
  86. package/schematics/ng-add/helper.d.ts +11 -0
  87. package/schematics/ng-add/helper.js +198 -0
  88. package/schematics/ng-add/helper.js.map +1 -0
  89. package/schematics/ng-add/index.d.ts +3 -0
  90. package/schematics/ng-add/index.js +68 -0
  91. package/schematics/ng-add/index.js.map +1 -0
  92. package/schematics/ng-add/rules/create-config-registration-files.rule.d.ts +3 -0
  93. package/schematics/ng-add/rules/create-config-registration-files.rule.js +32 -0
  94. package/schematics/ng-add/rules/create-config-registration-files.rule.js.map +1 -0
  95. package/schematics/ng-add/rules/create-formbar-registration-config.rule.d.ts +3 -0
  96. package/schematics/ng-add/rules/create-formbar-registration-config.rule.js +30 -0
  97. package/schematics/ng-add/rules/create-formbar-registration-config.rule.js.map +1 -0
  98. package/schematics/ng-add/rules/create-helper-files.rule.d.ts +6 -0
  99. package/schematics/ng-add/rules/create-helper-files.rule.js +22 -0
  100. package/schematics/ng-add/rules/create-helper-files.rule.js.map +1 -0
  101. package/schematics/ng-add/rules/create-schematics-config.rule.d.ts +3 -0
  102. package/schematics/ng-add/rules/create-schematics-config.rule.js +42 -0
  103. package/schematics/ng-add/rules/create-schematics-config.rule.js.map +1 -0
  104. package/schematics/ng-add/rules/create-token-registration-files.rule.d.ts +3 -0
  105. package/schematics/ng-add/rules/create-token-registration-files.rule.js +32 -0
  106. package/schematics/ng-add/rules/create-token-registration-files.rule.js.map +1 -0
  107. package/schematics/ng-add/rules/include-templates.rule.d.ts +3 -0
  108. package/schematics/ng-add/rules/include-templates.rule.js +11 -0
  109. package/schematics/ng-add/rules/include-templates.rule.js.map +1 -0
  110. package/schematics/ng-add/rules/install-dependencies.rule.d.ts +2 -0
  111. package/schematics/ng-add/rules/install-dependencies.rule.js +12 -0
  112. package/schematics/ng-add/rules/install-dependencies.rule.js.map +1 -0
  113. package/schematics/ng-add/rules/update-app-config.rule.d.ts +3 -0
  114. package/schematics/ng-add/rules/update-app-config.rule.js +48 -0
  115. package/schematics/ng-add/rules/update-app-config.rule.js.map +1 -0
  116. package/schematics/ng-add/rules/update-schematics-config.rule.d.ts +6 -0
  117. package/schematics/ng-add/rules/update-schematics-config.rule.js +28 -0
  118. package/schematics/ng-add/rules/update-schematics-config.rule.js.map +1 -0
  119. package/schematics/ng-add/schema.d.ts +23 -0
  120. package/schematics/ng-add/schema.js +3 -0
  121. package/schematics/ng-add/schema.js.map +1 -0
  122. package/schematics/ng-add/schema.json +81 -0
  123. package/schematics/register/component-info.type.d.ts +11 -0
  124. package/schematics/register/component-info.type.js +3 -0
  125. package/schematics/register/component-info.type.js.map +1 -0
  126. package/schematics/register/discover-components.d.ts +19 -0
  127. package/schematics/register/discover-components.js +267 -0
  128. package/schematics/register/discover-components.js.map +1 -0
  129. package/schematics/register/index.d.ts +3 -0
  130. package/schematics/register/index.js +49 -0
  131. package/schematics/register/index.js.map +1 -0
  132. package/schematics/register/register-components.d.ts +3 -0
  133. package/schematics/register/register-components.js +38 -0
  134. package/schematics/register/register-components.js.map +1 -0
  135. package/schematics/register/schema.d.ts +14 -0
  136. package/schematics/register/schema.js +3 -0
  137. package/schematics/register/schema.js.map +1 -0
  138. package/schematics/register/schema.json +44 -0
  139. package/schematics/shared/ast/decorators.d.ts +9 -0
  140. package/schematics/shared/ast/decorators.js +182 -0
  141. package/schematics/shared/ast/decorators.js.map +1 -0
  142. package/schematics/shared/ast/imports.d.ts +3 -0
  143. package/schematics/shared/ast/imports.js +93 -0
  144. package/schematics/shared/ast/imports.js.map +1 -0
  145. package/schematics/shared/ast/parse.d.ts +3 -0
  146. package/schematics/shared/ast/parse.js +17 -0
  147. package/schematics/shared/ast/parse.js.map +1 -0
  148. package/schematics/shared/ast/registrations.d.ts +22 -0
  149. package/schematics/shared/ast/registrations.js +654 -0
  150. package/schematics/shared/ast/registrations.js.map +1 -0
  151. package/schematics/shared/ast/types.d.ts +3 -0
  152. package/schematics/shared/ast/types.js +58 -0
  153. package/schematics/shared/ast/types.js.map +1 -0
  154. package/schematics/shared/file.d.ts +4 -0
  155. package/schematics/shared/file.js +60 -0
  156. package/schematics/shared/file.js.map +1 -0
  157. package/schematics/shared/helper.d.ts +2 -0
  158. package/schematics/shared/helper.js +29 -0
  159. package/schematics/shared/helper.js.map +1 -0
  160. package/schematics/shared/rules/create-component.rule.d.ts +3 -0
  161. package/schematics/shared/rules/create-component.rule.js +15 -0
  162. package/schematics/shared/rules/create-component.rule.js.map +1 -0
  163. package/schematics/shared/rules/register-control.rule.d.ts +3 -0
  164. package/schematics/shared/rules/register-control.rule.js +30 -0
  165. package/schematics/shared/rules/register-control.rule.js.map +1 -0
  166. package/schematics/shared/rules/register-type-map.rule.d.ts +3 -0
  167. package/schematics/shared/rules/register-type-map.rule.js +46 -0
  168. package/schematics/shared/rules/register-type-map.rule.js.map +1 -0
  169. package/schematics/shared/rules/register-type-token.rule.d.ts +3 -0
  170. package/schematics/shared/rules/register-type-token.rule.js +49 -0
  171. package/schematics/shared/rules/register-type-token.rule.js.map +1 -0
  172. package/schematics/shared/rules/scaffold-and-register.rule.d.ts +3 -0
  173. package/schematics/shared/rules/scaffold-and-register.rule.js +134 -0
  174. package/schematics/shared/rules/scaffold-and-register.rule.js.map +1 -0
  175. package/schematics/shared/schema.d.ts +32 -0
  176. package/schematics/shared/schema.js +3 -0
  177. package/schematics/shared/schema.js.map +1 -0
  178. package/schematics/tests/generators.spec.d.ts +1 -0
  179. package/schematics/tests/generators.spec.js +450 -0
  180. package/schematics/tests/generators.spec.js.map +1 -0
  181. package/schematics/tests/helper.d.ts +20 -0
  182. package/schematics/tests/helper.js +275 -0
  183. package/schematics/tests/helper.js.map +1 -0
  184. package/schematics/tests/ng-add.spec.d.ts +1 -0
  185. package/schematics/tests/ng-add.spec.js +380 -0
  186. package/schematics/tests/ng-add.spec.js.map +1 -0
  187. package/schematics/tests/register.spec.d.ts +1 -0
  188. package/schematics/tests/register.spec.js +340 -0
  189. package/schematics/tests/register.spec.js.map +1 -0
  190. package/schematics/tests/workspace-setup.d.ts +21 -0
  191. package/schematics/tests/workspace-setup.js +255 -0
  192. package/schematics/tests/workspace-setup.js.map +1 -0
  193. package/shared/ast.d.ts +10 -0
  194. package/shared/ast.js +93 -0
  195. package/shared/ast.js.map +1 -0
  196. package/shared/constants.d.ts +16 -0
  197. package/shared/constants.js +20 -0
  198. package/shared/constants.js.map +1 -0
  199. package/shared/shared-config.type.d.ts +20 -0
  200. package/shared/shared-config.type.js +3 -0
  201. package/shared/shared-config.type.js.map +1 -0
@@ -0,0 +1,253 @@
1
+ import { OnDestroy, Signal } from '@angular/core';
2
+ import { NgxFbFormGroup, ValueStrategy } from '../types/content.type';
3
+ import { FormControl, FormGroup } from '@angular/forms';
4
+ import { StateHandling } from '../types/registration.type';
5
+ import { TestIdBuilderFn } from '../types/functions.type';
6
+ import * as i0 from "@angular/core";
7
+ /**
8
+ * Core directive for creating form groups in ngx-formbar.
9
+ *
10
+ * This directive handles the integration between Angular's reactive forms and
11
+ * ngx-formbar's declarative configuration for FormGroups. It manages:
12
+ *
13
+ * - Group registration and lifecycle within parent forms
14
+ * - State management (hidden, disabled, readonly)
15
+ * - Validation setup
16
+ * - Test ID generation
17
+ * - Dynamic title support
18
+ * - Child control management
19
+ *
20
+ * Use this directive with hostDirectives in your custom group components:
21
+ *
22
+ * ```typescript
23
+ * @Component({
24
+ * hostDirectives: [
25
+ * {
26
+ * directive: NgxfbGroupDirective,
27
+ * inputs: ['content', 'name'],
28
+ * }
29
+ * ],
30
+ * })
31
+ * export class GroupComponent {
32
+ * private readonly control = inject(NgxfbGroupDirective<Group>);
33
+ * readonly content = this.control.content;
34
+ * readonly controls = this.control.controls;
35
+ * }
36
+ * ```
37
+ *
38
+ * @template T Type of the group configuration, must extend NgxFbFormGroup
39
+ */
40
+ export declare class NgxfbGroupDirective<T extends NgxFbFormGroup> implements OnDestroy {
41
+ private parentContainer;
42
+ private readonly parentGroupDirective;
43
+ /**
44
+ * Required input containing the group configuration
45
+ * Defines properties like type, controls, validation, and state expressions
46
+ */
47
+ readonly content: import("@angular/core").InputSignal<T>;
48
+ /**
49
+ * Required input for the group's name
50
+ * Used as the key in the parent FormGroup
51
+ */
52
+ readonly name: import("@angular/core").InputSignal<string>;
53
+ /**
54
+ * Signal for managing the visibility handling strategy ('auto' or 'manual')
55
+ * - 'auto': directive handles visibility via hidden attribute
56
+ * - 'manual': component handles visibility in its own template
57
+ */
58
+ private readonly visibilityHandling;
59
+ /**
60
+ * Signal for managing the disabled state handling strategy ('auto' or 'manual')
61
+ * - 'auto': directive handles disabled state via FormGroup methods
62
+ * - 'manual': component handles disabled state in its own template
63
+ */
64
+ private readonly disabledHandling;
65
+ /**
66
+ * Signal for the test ID builder function
67
+ * Used to customize how test IDs are generated
68
+ */
69
+ private readonly testIdBuilder;
70
+ /**
71
+ * Computed test ID derived from the group's name
72
+ * Used for automated testing identification
73
+ *
74
+ * Access this in your component template:
75
+ * ```html
76
+ * <div [attr.data-testid]="testId()">...</div>
77
+ * ```
78
+ */
79
+ readonly testId: Signal<string>;
80
+ /**
81
+ * Computed signal for the group's hide strategy
82
+ * Determines how the group behaves when hidden (keep or remove from form)
83
+ */
84
+ readonly hideStrategy: Signal<import("@ngx-formbar/core").HideStrategy | undefined>;
85
+ /**
86
+ * Computed signal for the group's value strategy
87
+ * Determines how the group's values are managed when visibility changes:
88
+ * - 'last': preserves last values
89
+ * - 'default': reverts to default values
90
+ * - 'reset': clears values
91
+ */
92
+ readonly valueStrategy: Signal<ValueStrategy | undefined>;
93
+ /**
94
+ * Computed signal for the parent's value strategy
95
+ * Used when group doesn't define its own strategy
96
+ */
97
+ readonly parentValueStrategy: Signal<ValueStrategy | undefined>;
98
+ /**
99
+ * Computed signal for the hidden state
100
+ * True when the group should be hidden based on 'hidden' expression
101
+ *
102
+ * Use this in your component when implementing custom visibility handling:
103
+ * ```typescript
104
+ * readonly isHidden = this.control.isHidden;
105
+ * ```
106
+ */
107
+ readonly isHidden: Signal<boolean>;
108
+ /**
109
+ * Computed signal for the hidden attribute
110
+ * Used in DOM binding to show/hide the group element
111
+ */
112
+ readonly hiddenAttribute: Signal<true | null>;
113
+ /**
114
+ * Computed signal for the disabled state
115
+ * True when the group should be disabled based on 'disabled' expression
116
+ *
117
+ * Use this in your component for custom disabled state handling:
118
+ * ```typescript
119
+ * readonly disabled = this.control.disabled;
120
+ * ```
121
+ */
122
+ readonly disabled: Signal<boolean>;
123
+ /**
124
+ * Computed signal for the readonly state
125
+ * True when the group should be readonly based on 'readonly' expression
126
+ *
127
+ * Use this in your component to implement readonly behavior:
128
+ * ```typescript
129
+ * readonly readonly = this.control.readonly;
130
+ * ```
131
+ */
132
+ readonly readonly: Signal<boolean>;
133
+ /**
134
+ * Computed signal for the update strategy
135
+ * Determines when form values are updated ('change', 'blur', or 'submit')
136
+ */
137
+ readonly updateStrategy: Signal<import("@ngx-formbar/core").UpdateStrategy>;
138
+ /**
139
+ * Computed signal for the dynamic title
140
+ * Contains the evaluated result of the dynamicTitle expression
141
+ *
142
+ * Use this in your component to display dynamic titles:
143
+ * ```typescript
144
+ * readonly displayTitle = computed(() => {
145
+ * const dynamic = this.control.dynamicTitle();
146
+ * return dynamic || this.content().title || '';
147
+ * });
148
+ * ```
149
+ */
150
+ readonly dynamicTitle: Signal<string | undefined>;
151
+ /**
152
+ * Computed signal for the validators
153
+ * Contains validator functions derived from configuration keys
154
+ */
155
+ private readonly validators;
156
+ /**
157
+ * Computed signal for the async validators
158
+ * Contains async validator functions derived from configuration keys
159
+ */
160
+ private readonly asyncValidators;
161
+ /**
162
+ * Computed signal for the form group instance
163
+ * Creates a new FormGroup with appropriate validators and configuration
164
+ */
165
+ private readonly groupInstance;
166
+ /**
167
+ * Computed signal for the title of the group
168
+ * Returns the static title from the configuration
169
+ */
170
+ readonly title: Signal<string | undefined>;
171
+ /**
172
+ * Computed signal for the child controls of the group
173
+ * Returns an array of [name, control] pairs for rendering
174
+ */
175
+ readonly controls: Signal<[string, import("@ngx-formbar/core").NgxFbContent][]>;
176
+ /**
177
+ * Access to the parent FormGroup containing this group
178
+ */
179
+ get parentFormGroup(): FormGroup | null;
180
+ /**
181
+ * Access to this group's FormGroup instance
182
+ * Use this to access validation state, errors, and other FormGroup methods
183
+ */
184
+ get formGroup(): FormControl | null;
185
+ constructor();
186
+ /**
187
+ * Sets the visibility handling strategy
188
+ * Determines if visibility should be managed by the component (manual) or by Formbar (auto)
189
+ *
190
+ * Use 'manual' when implementing custom visibility handling in your component:
191
+ * ```typescript
192
+ * constructor() {
193
+ * this.control.setVisibilityHandling('manual');
194
+ * }
195
+ * ```
196
+ *
197
+ * @param visibilityHandling Strategy for handling visibility ('auto' or 'manual')
198
+ */
199
+ setVisibilityHandling(visibilityHandling: StateHandling): void;
200
+ /**
201
+ * Sets the disabled handling strategy
202
+ * Determines if disabled state should be managed by the component (manual) or by Formbar (auto)
203
+ *
204
+ * Use 'manual' when implementing custom disabled state handling in your component:
205
+ * ```typescript
206
+ * constructor() {
207
+ * this.control.setDisabledHandling('manual');
208
+ * }
209
+ * ```
210
+ *
211
+ * @param disabledHandling Strategy for handling disabled state ('auto' or 'manual')
212
+ */
213
+ setDisabledHandling(disabledHandling: StateHandling): void;
214
+ /**
215
+ * Sets the function to use for building a test id.
216
+ * This allows custom test ID generation strategies to be used.
217
+ *
218
+ * @param builderFn Function that returns the test id
219
+ */
220
+ setTestIdBuilderFn(builderFn: TestIdBuilderFn | undefined): void;
221
+ /**
222
+ * Registers this group with the parent FormGroup
223
+ * @private
224
+ */
225
+ private setGroup;
226
+ /**
227
+ * Removes this group from the parent FormGroup
228
+ * @private
229
+ */
230
+ private removeGroup;
231
+ /**
232
+ * Enables the form group
233
+ * @private
234
+ */
235
+ private enableGroup;
236
+ /**
237
+ * Disables the form group
238
+ * @private
239
+ */
240
+ private disableGroup;
241
+ /**
242
+ * Handles value changes when visibility changes
243
+ * @param valueStrategy Strategy for handling values
244
+ * @private
245
+ */
246
+ private handleValue;
247
+ /**
248
+ * Removes the group when the directive is destroyed
249
+ */
250
+ ngOnDestroy(): void;
251
+ static ɵfac: i0.ɵɵFactoryDeclaration<NgxfbGroupDirective<any>, never>;
252
+ static ɵdir: i0.ɵɵDirectiveDeclaration<NgxfbGroupDirective<any>, "[ngxfbGroup]", never, { "content": { "alias": "content"; "required": true; "isSignal": true; }; "name": { "alias": "name"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
253
+ }
@@ -0,0 +1,33 @@
1
+ import { ControlContainer } from '@angular/forms';
2
+ /**
3
+ * Provides the parent ControlContainer to child components
4
+ *
5
+ * This provider configuration allows child form components to access their parent's
6
+ * ControlContainer through dependency injection. This is particularly useful for
7
+ * creating nested form components that inherit the parent form context without
8
+ * explicitly passing FormGroup instances.
9
+ *
10
+ * @remarks
11
+ * The `skipSelf` option ensures the provider looks for the ControlContainer in parent
12
+ * components rather than trying to resolve it from the component where this is used.
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * @Component({
17
+ * selector: 'app-child-form',
18
+ * template: '...',
19
+ * viewProviders: [controlContainerViewProviders]
20
+ * })
21
+ * export class ChildFormComponent {
22
+ * // Now this component can access the parent form
23
+ * private controlContainer = inject(ControlContainer);
24
+ *
25
+ * get parentFormGroup() {
26
+ * return this.parentContainer.control as FormGroup | null;
27
+ * }
28
+ * }
29
+ */
30
+ export declare const controlContainerViewProviders: {
31
+ provide: typeof ControlContainer;
32
+ useFactory: () => ControlContainer;
33
+ }[];
package/lib/index.d.ts ADDED
@@ -0,0 +1,23 @@
1
+ export * from './components/form/ngxfb-form.component';
2
+ export * from './types/component-resolver.type';
3
+ export * from './types/content.type';
4
+ export * from './types/expression.type';
5
+ export * from './types/form.type';
6
+ export * from './types/functions.type';
7
+ export * from './types/global-configuration.type';
8
+ export * from './types/provide.type';
9
+ export * from './types/registration.type';
10
+ export * from './types/validation.type';
11
+ export * from './types/validator-resolver.type';
12
+ export * from './config/config';
13
+ export * from './config/provide-formbar';
14
+ export * from './directives/ngxfb-control.directive';
15
+ export * from './directives/ngxfb-group.directive';
16
+ export * from './directives/ngxfb-block.directive';
17
+ export * from './directives/ngxfb-abstract-control.directive';
18
+ export * from './tokens/component-registrations';
19
+ export * from './tokens/component-resolver';
20
+ export * from './tokens/default-update-strategy';
21
+ export * from './tokens/global-config';
22
+ export * from './tokens/validator-registrations';
23
+ export * from './tokens/validator-resolver';
@@ -0,0 +1,8 @@
1
+ import { ComponentResolver } from '../types/component-resolver.type';
2
+ import * as i0 from "@angular/core";
3
+ export declare class ComponentRegistrationService implements ComponentResolver {
4
+ private readonly _registrations;
5
+ readonly registrations: import("@angular/core").Signal<ReadonlyMap<string, import("@angular/core").Type<unknown>>>;
6
+ static ɵfac: i0.ɵɵFactoryDeclaration<ComponentRegistrationService, never>;
7
+ static ɵprov: i0.ɵɵInjectableDeclaration<ComponentRegistrationService>;
8
+ }
@@ -0,0 +1,8 @@
1
+ import { TestIdBuilderFn } from '../types/functions.type';
2
+ import * as i0 from "@angular/core";
3
+ export declare class NgxFbConfigurationService {
4
+ private readonly _config;
5
+ get testIdBuilder(): TestIdBuilderFn | undefined;
6
+ static ɵfac: i0.ɵɵFactoryDeclaration<NgxFbConfigurationService, never>;
7
+ static ɵprov: i0.ɵɵInjectableDeclaration<NgxFbConfigurationService>;
8
+ }
@@ -0,0 +1,148 @@
1
+ import type { Program } from 'acorn';
2
+ import type { FormContext } from '../types/expression.type';
3
+ import * as i0 from "@angular/core";
4
+ /**
5
+ * Service for parsing and evaluating JavaScript expressions within a context object
6
+ */
7
+ export declare class ExpressionService {
8
+ /**
9
+ * Cache for parsed ASTs to avoid re-parsing the same expression
10
+ */
11
+ private readonly astCache;
12
+ /**
13
+ * Parses an expression string into an abstract syntax tree (AST)
14
+ * @param expressionString - The expression to parse
15
+ * @returns The parsed AST or null
16
+ */
17
+ parseExpressionToAst(expressionString?: string): Program | null;
18
+ /**
19
+ * Evaluates an expression AST within the provided context
20
+ * @param ast - The parsed AST to evaluate
21
+ * @param context - The context containing variables and objects referenced in the expression
22
+ * @returns The result of evaluating the expression
23
+ */
24
+ evaluateExpression(ast?: Program | null, context?: FormContext): unknown;
25
+ /**
26
+ * Evaluates a node in the AST
27
+ * @param node - The AST node to evaluate
28
+ * @param context - The context containing variables and objects
29
+ * @returns The result of evaluating the node
30
+ */
31
+ private evaluateAstNode;
32
+ /**
33
+ * Evaluates a literal value node
34
+ * @param node - The literal node to evaluate
35
+ * @returns The literal value
36
+ */
37
+ private evaluateLiteral;
38
+ /**
39
+ * Evaluates a binary expression (e.g., a + b, x > y)
40
+ * @param node - The binary expression node
41
+ * @param context - The context containing variables and objects
42
+ * @returns The result of the binary operation
43
+ */
44
+ private evaluateBinaryExpression;
45
+ /**
46
+ * Executes a binary operation with the given values and operator
47
+ * @param leftValue - The left operand
48
+ * @param operator - The binary operator
49
+ * @param rightValue - The right operand
50
+ * @returns The result of applying the operator to the operands
51
+ */
52
+ private executeBinaryOperation;
53
+ /**
54
+ * Evaluates a member expression (e.g., obj.prop, arr[0]) with improved safety
55
+ * @param node - The member expression node
56
+ * @param context - The context containing variables and objects
57
+ * @returns The value of the member
58
+ */
59
+ private evaluateMemberExpression;
60
+ /**
61
+ * Gets a property from an object by key
62
+ * @param object - The object to retrieve the property from
63
+ * @param propertyKey - The property key (string or number)
64
+ * @returns The value of the property
65
+ */
66
+ private getPropertyFromObject;
67
+ /**
68
+ * Evaluates an identifier node by looking it up in the context
69
+ * @param node - The identifier node
70
+ * @param context - The context containing variables and objects
71
+ * @returns The value of the identifier from the context
72
+ */
73
+ private evaluateIdentifier;
74
+ /**
75
+ * Evaluates an array expression node
76
+ * @param node - The array expression node
77
+ * @param context - The context containing variables and objects
78
+ * @returns The evaluated array
79
+ */
80
+ private evaluateArrayExpression;
81
+ /**
82
+ * Evaluates a unary expression (e.g., !x, -value, typeof obj)
83
+ * @param node - The unary expression node
84
+ * @param context - The context containing variables and objects
85
+ * @returns The result of the unary operation
86
+ */
87
+ private evaluateUnaryExpression;
88
+ /**
89
+ * Evaluates a logical expression (&&, ||, ??)
90
+ * @param node - The logical expression node
91
+ * @param context - The context containing variables and objects
92
+ * @returns The result of the logical operation
93
+ */
94
+ private evaluateLogicalExpression;
95
+ /**
96
+ * Evaluates a conditional (ternary) expression (condition ? trueValue : falseValue)
97
+ * @param node - The conditional expression node
98
+ * @param context - The context containing variables and objects
99
+ * @returns The result based on the condition evaluation
100
+ */
101
+ private evaluateConditionalExpression;
102
+ /**
103
+ * Evaluates an object expression (object literal)
104
+ * @param node - The object expression node
105
+ * @param context - The context containing variables and objects
106
+ * @returns The evaluated object
107
+ */
108
+ private evaluateObjectExpression;
109
+ /**
110
+ * Evaluates a sequence expression (comma-separated expressions)
111
+ * @param node - The sequence expression node
112
+ * @param context - The context containing variables and objects
113
+ * @returns The result of the last expression in the sequence
114
+ */
115
+ private evaluateSequenceExpression;
116
+ /**
117
+ * Evaluates a template literal
118
+ * @param node - The template literal node
119
+ * @param context - The context containing variables and objects
120
+ * @returns The evaluated template string
121
+ */
122
+ private evaluateTemplateLiteral;
123
+ /**
124
+ * Evaluates a function call expression with strict type checking
125
+ * @param node - The function call expression node
126
+ * @param context - The context containing variables and objects
127
+ * @returns The result of the function call
128
+ */
129
+ private evaluateCallExpression;
130
+ /**
131
+ * Calls a method on an object after verifying it's safe to do so
132
+ * @param object - The object to call the method on
133
+ * @param methodName - The name of the method to call
134
+ * @param args - The arguments to pass to the method
135
+ * @returns The result of the method call
136
+ */
137
+ private callSafeMethod;
138
+ private isAllowedMethod;
139
+ /**
140
+ * Evaluates an arrow function expression
141
+ * @param node - The arrow function expression node
142
+ * @param context - The context containing variables and objects
143
+ * @returns A function that can be called from other expressions
144
+ */
145
+ private evaluateArrowFunctionExpression;
146
+ static ɵfac: i0.ɵɵFactoryDeclaration<ExpressionService, never>;
147
+ static ɵprov: i0.ɵɵInjectableDeclaration<ExpressionService>;
148
+ }
@@ -0,0 +1,10 @@
1
+ import { FormGroup } from '@angular/forms';
2
+ import { FormContext } from '../types/expression.type';
3
+ import * as i0 from "@angular/core";
4
+ export declare class FormService {
5
+ private controlContainer;
6
+ readonly formGroup: FormGroup;
7
+ readonly formValue: import("@angular/core").Signal<FormContext | undefined>;
8
+ static ɵfac: i0.ɵɵFactoryDeclaration<FormService, never>;
9
+ static ɵprov: i0.ɵɵInjectableDeclaration<FormService>;
10
+ }
@@ -0,0 +1,10 @@
1
+ import { ValidatorResolver } from '../types/validator-resolver.type';
2
+ import * as i0 from "@angular/core";
3
+ export declare class ValidatorRegistrationService implements ValidatorResolver {
4
+ private readonly _registrations;
5
+ readonly registrations: import("@angular/core").Signal<ReadonlyMap<string, import("@angular/forms").ValidatorFn[]>>;
6
+ private readonly _asyncRegistrations;
7
+ readonly asyncRegistrations: import("@angular/core").Signal<ReadonlyMap<string, import("@angular/forms").AsyncValidatorFn[]>>;
8
+ static ɵfac: i0.ɵɵFactoryDeclaration<ValidatorRegistrationService, never>;
9
+ static ɵprov: i0.ɵɵInjectableDeclaration<ValidatorRegistrationService>;
10
+ }
@@ -0,0 +1,2 @@
1
+ import { InjectionToken, Type } from '@angular/core';
2
+ export declare const NGX_FW_COMPONENT_REGISTRATIONS: InjectionToken<ReadonlyMap<string, Type<unknown>>>;
@@ -0,0 +1,3 @@
1
+ import { InjectionToken } from '@angular/core';
2
+ import { ComponentResolver } from '../types/component-resolver.type';
3
+ export declare const NGX_FW_COMPONENT_RESOLVER: InjectionToken<ComponentResolver>;
@@ -0,0 +1,3 @@
1
+ import { InjectionToken } from '@angular/core';
2
+ import { UpdateStrategy } from '../types/content.type';
3
+ export declare const NGX_FW_DEFAULT_UPDATE_STRATEGY: InjectionToken<UpdateStrategy>;
@@ -0,0 +1,5 @@
1
+ import { InjectionToken } from '@angular/core';
2
+ import { NgxFbGlobalConfiguration } from '../types/global-configuration.type';
3
+ export declare const NGX_FW_DEFAULT_CONFIG: InjectionToken<NgxFbGlobalConfiguration>;
4
+ export declare const NGX_FW_CONFIG: InjectionToken<readonly Partial<NgxFbGlobalConfiguration>[]>;
5
+ export declare const NGX_FW_CONFIG_RESOLVED: InjectionToken<NgxFbGlobalConfiguration>;
@@ -0,0 +1,8 @@
1
+ import { InjectionToken } from '@angular/core';
2
+ import { AsyncValidatorFn, ValidatorFn } from '@angular/forms';
3
+ export declare const NGX_FW_DEFAULT_VALIDATOR_REGISTRATIONS: InjectionToken<ReadonlyMap<string, ValidatorFn[]>>;
4
+ export declare const NGX_FW_DEFAULT_ASYNC_VALIDATOR_REGISTRATIONS: InjectionToken<ReadonlyMap<string, AsyncValidatorFn[]>>;
5
+ export declare const NGX_FW_VALIDATOR_REGISTRATIONS: InjectionToken<ReadonlyMap<string, ValidatorFn[]>[]>;
6
+ export declare const NGX_FW_ASYNC_VALIDATOR_REGISTRATIONS: InjectionToken<ReadonlyMap<string, AsyncValidatorFn[]>[]>;
7
+ export declare const NGX_FW_VALIDATOR_REGISTRATIONS_RESOLVED: InjectionToken<ReadonlyMap<string, ValidatorFn[]>>;
8
+ export declare const NGX_FW_ASYNC_VALIDATOR_REGISTRATIONS_RESOLVED: InjectionToken<ReadonlyMap<string, AsyncValidatorFn[]>>;
@@ -0,0 +1,3 @@
1
+ import { InjectionToken } from '@angular/core';
2
+ import { ValidatorResolver } from '../types/validator-resolver.type';
3
+ export declare const NGX_VALIDATOR_RESOLVER: InjectionToken<ValidatorResolver>;
@@ -0,0 +1,4 @@
1
+ import { Signal, Type } from '@angular/core';
2
+ export interface ComponentResolver {
3
+ registrations: Signal<ReadonlyMap<string, Type<unknown>>>;
4
+ }