@ngx-formbar/core 1.0.0 → 2.0.0-next.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 (202) hide show
  1. package/README.md +2 -34
  2. package/fesm2022/ngx-formbar-core.mjs +221 -1615
  3. package/fesm2022/ngx-formbar-core.mjs.map +1 -1
  4. package/package.json +5 -12
  5. package/types/ngx-formbar-core.d.ts +522 -0
  6. package/LICENSE +0 -21
  7. package/index.d.ts +0 -5
  8. package/lib/components/form/ngxfb-form.component.d.ts +0 -28
  9. package/lib/composables/computed-value.d.ts +0 -8
  10. package/lib/composables/disabled.state.d.ts +0 -36
  11. package/lib/composables/dynamic-label.d.ts +0 -9
  12. package/lib/composables/dynamic-title.d.ts +0 -9
  13. package/lib/composables/hidden.state.d.ts +0 -68
  14. package/lib/composables/readonly.state.d.ts +0 -19
  15. package/lib/composables/testId.d.ts +0 -16
  16. package/lib/composables/update-strategy.d.ts +0 -20
  17. package/lib/composables/validators.d.ts +0 -22
  18. package/lib/config/config.d.ts +0 -7
  19. package/lib/config/provide-formbar.d.ts +0 -38
  20. package/lib/directives/ngxfb-abstract-control.directive.d.ts +0 -53
  21. package/lib/directives/ngxfb-block.directive.d.ts +0 -124
  22. package/lib/directives/ngxfb-control.directive.d.ts +0 -203
  23. package/lib/directives/ngxfb-group.directive.d.ts +0 -253
  24. package/lib/helper/control-container-view-providers.d.ts +0 -33
  25. package/lib/index.d.ts +0 -23
  26. package/lib/services/component-registration.service.d.ts +0 -8
  27. package/lib/services/configuration.service.d.ts +0 -8
  28. package/lib/services/expression.service.d.ts +0 -148
  29. package/lib/services/form.service.d.ts +0 -10
  30. package/lib/services/validator-registration.service.d.ts +0 -10
  31. package/lib/tokens/component-registrations.d.ts +0 -2
  32. package/lib/tokens/component-resolver.d.ts +0 -3
  33. package/lib/tokens/default-update-strategy.d.ts +0 -3
  34. package/lib/tokens/global-config.d.ts +0 -5
  35. package/lib/tokens/validator-registrations.d.ts +0 -8
  36. package/lib/tokens/validator-resolver.d.ts +0 -3
  37. package/lib/types/component-resolver.type.d.ts +0 -4
  38. package/lib/types/content.type.d.ts +0 -137
  39. package/lib/types/expression.type.d.ts +0 -2
  40. package/lib/types/form.type.d.ts +0 -4
  41. package/lib/types/functions.type.d.ts +0 -4
  42. package/lib/types/global-configuration.type.d.ts +0 -4
  43. package/lib/types/provide.type.d.ts +0 -42
  44. package/lib/types/registration.type.d.ts +0 -18
  45. package/lib/types/validation.type.d.ts +0 -59
  46. package/lib/types/validator-resolver.type.d.ts +0 -6
  47. package/public-api.d.ts +0 -1
  48. package/schematics/block/files/__componentName@dasherize__.component.html.template +0 -1
  49. package/schematics/block/files/__componentName@dasherize__.component.ts.template +0 -29
  50. package/schematics/block/files/__interfaceName@dasherize__.type.ts.template +0 -6
  51. package/schematics/block/index.d.ts +0 -3
  52. package/schematics/block/index.js +0 -11
  53. package/schematics/block/index.js.map +0 -1
  54. package/schematics/block/schema.json +0 -62
  55. package/schematics/collection.json +0 -31
  56. package/schematics/control/files/__componentName@dasherize__.component.html.template +0 -0
  57. package/schematics/control/files/__componentName@dasherize__.component.ts.template +0 -29
  58. package/schematics/control/files/__interfaceName@dasherize__.type.ts.template +0 -6
  59. package/schematics/control/index.d.ts +0 -3
  60. package/schematics/control/index.js +0 -11
  61. package/schematics/control/index.js.map +0 -1
  62. package/schematics/control/schema.json +0 -61
  63. package/schematics/group/files/__componentName@dasherize__.component.html.template +0 -5
  64. package/schematics/group/files/__componentName@dasherize__.component.ts.template +0 -29
  65. package/schematics/group/files/__interfaceName@dasherize__.type.ts.template +0 -5
  66. package/schematics/group/index.d.ts +0 -3
  67. package/schematics/group/index.js +0 -11
  68. package/schematics/group/index.js.map +0 -1
  69. package/schematics/group/schema.json +0 -62
  70. package/schematics/ng-add/files/config-registrations/async-validator-registrations.ts.template +0 -4
  71. package/schematics/ng-add/files/config-registrations/component-registrations.ts.template +0 -4
  72. package/schematics/ng-add/files/config-registrations/index.ts.template +0 -3
  73. package/schematics/ng-add/files/config-registrations/validator-registrations.ts.template +0 -4
  74. package/schematics/ng-add/files/helper/block.host-directive.ts.template +0 -6
  75. package/schematics/ng-add/files/helper/control.host-directive.ts.template +0 -6
  76. package/schematics/ng-add/files/helper/group.host-directive.ts.template +0 -6
  77. package/schematics/ng-add/files/helper/index.ts.template +0 -4
  78. package/schematics/ng-add/files/helper/view-provider.ts.template +0 -9
  79. package/schematics/ng-add/files/provider-config/config/__providerConfigFileName__.ts.template +0 -9
  80. package/schematics/ng-add/files/provider-config/inline/__providerConfigFileName__.ts.template +0 -8
  81. package/schematics/ng-add/files/provider-config/token/__providerConfigFileName__.ts.template +0 -4
  82. package/schematics/ng-add/files/schematics-config/__schematicConfigFileName__.json.template +0 -1
  83. package/schematics/ng-add/files/token-registrations/async-validator-registrations.ts.template +0 -8
  84. package/schematics/ng-add/files/token-registrations/component-registrations.ts.template +0 -8
  85. package/schematics/ng-add/files/token-registrations/index.ts.template +0 -3
  86. package/schematics/ng-add/files/token-registrations/validator-registrations.ts.template +0 -8
  87. package/schematics/ng-add/helper.d.ts +0 -11
  88. package/schematics/ng-add/helper.js +0 -198
  89. package/schematics/ng-add/helper.js.map +0 -1
  90. package/schematics/ng-add/index.d.ts +0 -3
  91. package/schematics/ng-add/index.js +0 -68
  92. package/schematics/ng-add/index.js.map +0 -1
  93. package/schematics/ng-add/rules/create-config-registration-files.rule.d.ts +0 -3
  94. package/schematics/ng-add/rules/create-config-registration-files.rule.js +0 -32
  95. package/schematics/ng-add/rules/create-config-registration-files.rule.js.map +0 -1
  96. package/schematics/ng-add/rules/create-formbar-registration-config.rule.d.ts +0 -3
  97. package/schematics/ng-add/rules/create-formbar-registration-config.rule.js +0 -30
  98. package/schematics/ng-add/rules/create-formbar-registration-config.rule.js.map +0 -1
  99. package/schematics/ng-add/rules/create-helper-files.rule.d.ts +0 -6
  100. package/schematics/ng-add/rules/create-helper-files.rule.js +0 -22
  101. package/schematics/ng-add/rules/create-helper-files.rule.js.map +0 -1
  102. package/schematics/ng-add/rules/create-schematics-config.rule.d.ts +0 -3
  103. package/schematics/ng-add/rules/create-schematics-config.rule.js +0 -42
  104. package/schematics/ng-add/rules/create-schematics-config.rule.js.map +0 -1
  105. package/schematics/ng-add/rules/create-token-registration-files.rule.d.ts +0 -3
  106. package/schematics/ng-add/rules/create-token-registration-files.rule.js +0 -32
  107. package/schematics/ng-add/rules/create-token-registration-files.rule.js.map +0 -1
  108. package/schematics/ng-add/rules/include-templates.rule.d.ts +0 -3
  109. package/schematics/ng-add/rules/include-templates.rule.js +0 -11
  110. package/schematics/ng-add/rules/include-templates.rule.js.map +0 -1
  111. package/schematics/ng-add/rules/install-dependencies.rule.d.ts +0 -2
  112. package/schematics/ng-add/rules/install-dependencies.rule.js +0 -12
  113. package/schematics/ng-add/rules/install-dependencies.rule.js.map +0 -1
  114. package/schematics/ng-add/rules/update-app-config.rule.d.ts +0 -3
  115. package/schematics/ng-add/rules/update-app-config.rule.js +0 -49
  116. package/schematics/ng-add/rules/update-app-config.rule.js.map +0 -1
  117. package/schematics/ng-add/rules/update-schematics-config.rule.d.ts +0 -6
  118. package/schematics/ng-add/rules/update-schematics-config.rule.js +0 -28
  119. package/schematics/ng-add/rules/update-schematics-config.rule.js.map +0 -1
  120. package/schematics/ng-add/schema.d.ts +0 -23
  121. package/schematics/ng-add/schema.js +0 -3
  122. package/schematics/ng-add/schema.js.map +0 -1
  123. package/schematics/ng-add/schema.json +0 -81
  124. package/schematics/register/component-info.type.d.ts +0 -11
  125. package/schematics/register/component-info.type.js +0 -3
  126. package/schematics/register/component-info.type.js.map +0 -1
  127. package/schematics/register/discover-components.d.ts +0 -19
  128. package/schematics/register/discover-components.js +0 -267
  129. package/schematics/register/discover-components.js.map +0 -1
  130. package/schematics/register/index.d.ts +0 -3
  131. package/schematics/register/index.js +0 -49
  132. package/schematics/register/index.js.map +0 -1
  133. package/schematics/register/register-components.d.ts +0 -3
  134. package/schematics/register/register-components.js +0 -38
  135. package/schematics/register/register-components.js.map +0 -1
  136. package/schematics/register/schema.d.ts +0 -14
  137. package/schematics/register/schema.js +0 -3
  138. package/schematics/register/schema.js.map +0 -1
  139. package/schematics/register/schema.json +0 -44
  140. package/schematics/shared/ast/decorators.d.ts +0 -9
  141. package/schematics/shared/ast/decorators.js +0 -182
  142. package/schematics/shared/ast/decorators.js.map +0 -1
  143. package/schematics/shared/ast/imports.d.ts +0 -3
  144. package/schematics/shared/ast/imports.js +0 -93
  145. package/schematics/shared/ast/imports.js.map +0 -1
  146. package/schematics/shared/ast/parse.d.ts +0 -3
  147. package/schematics/shared/ast/parse.js +0 -17
  148. package/schematics/shared/ast/parse.js.map +0 -1
  149. package/schematics/shared/ast/registrations.d.ts +0 -22
  150. package/schematics/shared/ast/registrations.js +0 -654
  151. package/schematics/shared/ast/registrations.js.map +0 -1
  152. package/schematics/shared/ast/types.d.ts +0 -3
  153. package/schematics/shared/ast/types.js +0 -58
  154. package/schematics/shared/ast/types.js.map +0 -1
  155. package/schematics/shared/file.d.ts +0 -4
  156. package/schematics/shared/file.js +0 -60
  157. package/schematics/shared/file.js.map +0 -1
  158. package/schematics/shared/helper.d.ts +0 -2
  159. package/schematics/shared/helper.js +0 -29
  160. package/schematics/shared/helper.js.map +0 -1
  161. package/schematics/shared/rules/create-component.rule.d.ts +0 -3
  162. package/schematics/shared/rules/create-component.rule.js +0 -15
  163. package/schematics/shared/rules/create-component.rule.js.map +0 -1
  164. package/schematics/shared/rules/register-control.rule.d.ts +0 -3
  165. package/schematics/shared/rules/register-control.rule.js +0 -30
  166. package/schematics/shared/rules/register-control.rule.js.map +0 -1
  167. package/schematics/shared/rules/register-type-map.rule.d.ts +0 -3
  168. package/schematics/shared/rules/register-type-map.rule.js +0 -46
  169. package/schematics/shared/rules/register-type-map.rule.js.map +0 -1
  170. package/schematics/shared/rules/register-type-token.rule.d.ts +0 -3
  171. package/schematics/shared/rules/register-type-token.rule.js +0 -49
  172. package/schematics/shared/rules/register-type-token.rule.js.map +0 -1
  173. package/schematics/shared/rules/scaffold-and-register.rule.d.ts +0 -3
  174. package/schematics/shared/rules/scaffold-and-register.rule.js +0 -134
  175. package/schematics/shared/rules/scaffold-and-register.rule.js.map +0 -1
  176. package/schematics/shared/schema.d.ts +0 -32
  177. package/schematics/shared/schema.js +0 -3
  178. package/schematics/shared/schema.js.map +0 -1
  179. package/schematics/tests/generators.spec.d.ts +0 -1
  180. package/schematics/tests/generators.spec.js +0 -450
  181. package/schematics/tests/generators.spec.js.map +0 -1
  182. package/schematics/tests/helper.d.ts +0 -20
  183. package/schematics/tests/helper.js +0 -275
  184. package/schematics/tests/helper.js.map +0 -1
  185. package/schematics/tests/ng-add.spec.d.ts +0 -1
  186. package/schematics/tests/ng-add.spec.js +0 -380
  187. package/schematics/tests/ng-add.spec.js.map +0 -1
  188. package/schematics/tests/register.spec.d.ts +0 -1
  189. package/schematics/tests/register.spec.js +0 -340
  190. package/schematics/tests/register.spec.js.map +0 -1
  191. package/schematics/tests/workspace-setup.d.ts +0 -21
  192. package/schematics/tests/workspace-setup.js +0 -256
  193. package/schematics/tests/workspace-setup.js.map +0 -1
  194. package/shared/ast.d.ts +0 -10
  195. package/shared/ast.js +0 -93
  196. package/shared/ast.js.map +0 -1
  197. package/shared/constants.d.ts +0 -16
  198. package/shared/constants.js +0 -20
  199. package/shared/constants.js.map +0 -1
  200. package/shared/shared-config.type.d.ts +0 -20
  201. package/shared/shared-config.type.js +0 -3
  202. package/shared/shared-config.type.js.map +0 -1
@@ -0,0 +1,522 @@
1
+ import * as _angular_core from '@angular/core';
2
+ import { Signal, Type, InjectionToken } from '@angular/core';
3
+ import { Program } from 'acorn';
4
+
5
+ interface ComponentResolver {
6
+ registrations: Signal<ReadonlyMap<string, Type<unknown>>>;
7
+ }
8
+
9
+ type FormContext = Record<string, unknown>;
10
+ type Expression<T> = string | ((formValue: FormContext) => T);
11
+
12
+ /**
13
+ * The foundation for all form controls and groups. It defines the minimal set of
14
+ * properties shared across all content types: type identification and visibility.
15
+ */
16
+ interface NgxFbBaseContent {
17
+ /**
18
+ * Specifies the kind of form control. Determines what control is used and what
19
+ * additional properties are available.
20
+ */
21
+ type: string;
22
+ /**
23
+ * A string expression that determines when the control should be hidden.
24
+ * This condition is evaluated at runtime against the whole form object.
25
+ */
26
+ hidden?: Expression<boolean>;
27
+ }
28
+ /**
29
+ * Extends the base content with validation and control state management properties.
30
+ * Used as a base for both form controls and groups.
31
+ */
32
+ interface NgxFbAbstractControl extends NgxFbBaseContent {
33
+ /**
34
+ * Array of strings representing names of synchronous validators that apply to the control.
35
+ * These can be registered globally with a validator registration object.
36
+ */
37
+ validators?: string[];
38
+ /**
39
+ * Similar to validators, but for asynchronous validation logic that may involve
40
+ * API calls or other deferred operations.
41
+ */
42
+ asyncValidators?: string[];
43
+ /**
44
+ * Defines whether the control should be disabled. Can be a boolean value or a
45
+ * string expression that evaluates against the form object.
46
+ */
47
+ disabled?: Expression<boolean> | boolean;
48
+ /**
49
+ * Specifies how to handle the control when hidden.
50
+ * @see {@link HideStrategy}
51
+ */
52
+ hideStrategy?: HideStrategy;
53
+ /**
54
+ * Determines how the control's value is handled when visibility changes.
55
+ * @see {@link ValueStrategy}
56
+ */
57
+ valueStrategy?: ValueStrategy;
58
+ /**
59
+ * Indicates if the control is read-only (displayed but not modifiable).
60
+ * Accepts either a boolean value or a string expression for dynamic evaluation.
61
+ */
62
+ readonly?: Expression<boolean> | boolean;
63
+ /**
64
+ * Specifies when to update the control's value.
65
+ * @see {@link UpdateStrategy}
66
+ */
67
+ updateOn?: UpdateStrategy;
68
+ /**
69
+ * A value that is automatically derived and set for the control.
70
+ * It will overwrite user input if one of its dependencies changes.
71
+ */
72
+ computedValue?: Expression<unknown>;
73
+ }
74
+ /**
75
+ * Specifies when to update the control's value:
76
+ * - 'change': as user types (default)
77
+ * - 'blur': when control loses focus
78
+ * - 'submit': when form is submitted
79
+ */
80
+ type UpdateStrategy = 'change' | 'blur' | 'submit' | undefined;
81
+ /**
82
+ * Represents a group of controls that can be nested within a form.
83
+ */
84
+ interface NgxFbFormGroup<T extends NgxFbBaseContent = NgxFbContent> extends NgxFbAbstractControl {
85
+ /**
86
+ * Specifies a title for the group
87
+ */
88
+ title?: string;
89
+ /**
90
+ * Dynamic title that can be evaluated from form data
91
+ */
92
+ dynamicTitle?: Expression<string>;
93
+ /**
94
+ * Object mapping keys to NgxFbContent that configure the controls of the group
95
+ */
96
+ controls: Record<string, T>;
97
+ }
98
+ /**
99
+ * Represents an individual form control with label and value properties.
100
+ */
101
+ interface NgxFbControl extends NgxFbAbstractControl {
102
+ /**
103
+ * Specifies the label for the control
104
+ */
105
+ label?: string;
106
+ /**
107
+ * Dynamic label that can be evaluated from form data
108
+ */
109
+ dynamicLabel?: Expression<string>;
110
+ /**
111
+ * Default value for the control. Override this type in extending interfaces to match the control's value type.
112
+ */
113
+ defaultValue?: unknown;
114
+ /**
115
+ * Whether this control can have a null value. Used to set the same property through the reactive forms API.
116
+ */
117
+ nonNullable?: boolean;
118
+ }
119
+ /**
120
+ * Represents a block element that doesn't behave like a form control.
121
+ * Used for UI elements that aren't part of the form model.
122
+ */
123
+ interface NgxFbBlock extends NgxFbBaseContent {
124
+ /**
125
+ * Required property for TypeScript to properly do type narrowing
126
+ */
127
+ isControl: false;
128
+ [key: string]: unknown;
129
+ }
130
+ /**
131
+ * Union type representing all possible content types that can be used in a form.
132
+ */
133
+ type NgxFbContent = NgxFbFormGroup | NgxFbControl | NgxFbBlock;
134
+ /**
135
+ * Specifies how to handle the control when hidden:
136
+ * - 'keep': control remains in form model
137
+ * - 'remove': control is removed from form model
138
+ */
139
+ type HideStrategy = 'keep' | 'remove';
140
+ /**
141
+ * Determines how the control's value is handled when visibility changes:
142
+ * - 'last': preserves last value
143
+ * - 'default': reverts to default value
144
+ * - 'reset': clears value
145
+ */
146
+ type ValueStrategy = 'last' | 'default' | 'reset';
147
+
148
+ interface NgxFbForm<ContentType extends NgxFbBaseContent = NgxFbContent> {
149
+ content: Record<string, ContentType>;
150
+ }
151
+
152
+ type SimpleFunction = () => void;
153
+ type ValueHandleFunction = (valueStrategy?: ValueStrategy) => void;
154
+ type TestIdBuilderFn = (content: NgxFbBaseContent, name: string, parentTestId?: string) => string;
155
+
156
+ interface NgxFbGlobalConfiguration {
157
+ testIdBuilderFn: TestIdBuilderFn | undefined;
158
+ }
159
+
160
+ /**
161
+ * Configuration for registering component types
162
+ *
163
+ * Used to map string type identifiers to component implementations
164
+ * for dynamic rendering.
165
+ */
166
+ type ComponentRegistrationConfig = Record<string, Type<unknown>>;
167
+ /**
168
+ * Strategy for handling component states
169
+ *
170
+ * Determines how visibility, disabled, and other component states
171
+ * are managed.
172
+ *
173
+ * - 'auto': Formbar automatically manages the state
174
+ * - 'manual': The component/host manages the state itself
175
+ */
176
+ type StateHandling = 'auto' | 'manual';
177
+
178
+ /**
179
+ * Structural directive that renders the appropriate component based on the control's type.
180
+ *
181
+ * This directive acts as a dynamic renderer for form controls, blocks, and groups.
182
+ * It works by:
183
+ * 1. Receiving a content configuration and name
184
+ * 2. Looking up the registered component for the content's type
185
+ * 3. Creating an instance of that component and binding the content and name to it
186
+ *
187
+ * This allows forms to be composed declaratively through configuration objects
188
+ * rather than explicit templates.
189
+ *
190
+ * @example
191
+ * ```html
192
+ * <!-- Used with ngFor to render a list of controls -->
193
+ * @for (control of controls(); track control[0]) {
194
+ * <ng-template *ngxfbAbstractControl="control" />
195
+ * }
196
+ *
197
+ * <!-- Used directly with a specific control -->
198
+ * <ng-template *ngxfbAbstractControl="['name', nameControlConfig]" />
199
+ * ```
200
+ */
201
+ declare class NgxfbAbstractControlDirective<T extends NgxFbBaseContent> {
202
+ private viewContainerRef;
203
+ /**
204
+ * Service for component registration
205
+ * Provides access to component type mappings
206
+ */
207
+ private readonly contentRegistrationService;
208
+ /**
209
+ * Required input for control configuration
210
+ * Defines properties like type, validation, and other control-specific settings
211
+ */
212
+ readonly content: _angular_core.InputSignal<[string, T]>;
213
+ readonly controlName: _angular_core.Signal<string>;
214
+ readonly controlConfig: _angular_core.Signal<T>;
215
+ /**
216
+ * Registration map of component types
217
+ * Maps control types to component implementations
218
+ */
219
+ readonly registrations: _angular_core.Signal<ReadonlyMap<string, _angular_core.Type<unknown>>>;
220
+ /**
221
+ * Computed component type based on content.type
222
+ * Looks up the component implementation from registrations map
223
+ */
224
+ readonly component: _angular_core.Signal<_angular_core.Type<unknown> | null>;
225
+ constructor();
226
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgxfbAbstractControlDirective<any>, never>;
227
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<NgxfbAbstractControlDirective<any>, "[ngxfbAbstractControl]", never, { "content": { "alias": "ngxfbAbstractControl"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
228
+ }
229
+
230
+ declare const NGX_FW_COMPONENT_REGISTRATIONS: InjectionToken<ReadonlyMap<string, Type<unknown>>>;
231
+
232
+ declare const NGX_FW_COMPONENT_RESOLVER: InjectionToken<ComponentResolver>;
233
+
234
+ declare const NGX_FW_DEFAULT_CONFIG: InjectionToken<NgxFbGlobalConfiguration>;
235
+ declare const NGX_FW_CONFIG: InjectionToken<readonly Partial<NgxFbGlobalConfiguration>[]>;
236
+ declare const NGX_FW_CONFIG_RESOLVED: InjectionToken<NgxFbGlobalConfiguration>;
237
+
238
+ declare const NGX_FW_DEFAULT_UPDATE_STRATEGY: InjectionToken<UpdateStrategy>;
239
+
240
+ /**
241
+ * Service for parsing and evaluating JavaScript expressions within a context object
242
+ */
243
+ declare class ExpressionService {
244
+ /**
245
+ * Cache for parsed ASTs to avoid re-parsing the same expression
246
+ */
247
+ private readonly astCache;
248
+ /**
249
+ * Parses an expression string into an abstract syntax tree (AST)
250
+ * @param expressionString - The expression to parse
251
+ * @returns The parsed AST or null
252
+ */
253
+ parseExpressionToAst(expressionString?: string): Program | null;
254
+ /**
255
+ * Evaluates an expression AST within the provided context
256
+ * @param ast - The parsed AST to evaluate
257
+ * @param context - The context containing variables and objects referenced in the expression
258
+ * @returns The result of evaluating the expression
259
+ */
260
+ evaluateExpression(ast?: Program | null, context?: FormContext): unknown;
261
+ /**
262
+ * Evaluates a node in the AST
263
+ * @param node - The AST node to evaluate
264
+ * @param context - The context containing variables and objects
265
+ * @returns The result of evaluating the node
266
+ */
267
+ private evaluateAstNode;
268
+ /**
269
+ * Evaluates a literal value node
270
+ * @param node - The literal node to evaluate
271
+ * @returns The literal value
272
+ */
273
+ private evaluateLiteral;
274
+ /**
275
+ * Evaluates a binary expression (e.g., a + b, x > y)
276
+ * @param node - The binary expression node
277
+ * @param context - The context containing variables and objects
278
+ * @returns The result of the binary operation
279
+ */
280
+ private evaluateBinaryExpression;
281
+ /**
282
+ * Executes a binary operation with the given values and operator
283
+ * @param leftValue - The left operand
284
+ * @param operator - The binary operator
285
+ * @param rightValue - The right operand
286
+ * @returns The result of applying the operator to the operands
287
+ */
288
+ private executeBinaryOperation;
289
+ /**
290
+ * Evaluates a member expression (e.g., obj.prop, arr[0]) with improved safety
291
+ * @param node - The member expression node
292
+ * @param context - The context containing variables and objects
293
+ * @returns The value of the member
294
+ */
295
+ private evaluateMemberExpression;
296
+ /**
297
+ * Gets a property from an object by key
298
+ * @param object - The object to retrieve the property from
299
+ * @param propertyKey - The property key (string or number)
300
+ * @returns The value of the property
301
+ */
302
+ private getPropertyFromObject;
303
+ /**
304
+ * Evaluates an identifier node by looking it up in the context
305
+ * @param node - The identifier node
306
+ * @param context - The context containing variables and objects
307
+ * @returns The value of the identifier from the context
308
+ */
309
+ private evaluateIdentifier;
310
+ /**
311
+ * Evaluates an array expression node
312
+ * @param node - The array expression node
313
+ * @param context - The context containing variables and objects
314
+ * @returns The evaluated array
315
+ */
316
+ private evaluateArrayExpression;
317
+ /**
318
+ * Evaluates a unary expression (e.g., !x, -value, typeof obj)
319
+ * @param node - The unary expression node
320
+ * @param context - The context containing variables and objects
321
+ * @returns The result of the unary operation
322
+ */
323
+ private evaluateUnaryExpression;
324
+ /**
325
+ * Evaluates a logical expression (&&, ||, ??)
326
+ * @param node - The logical expression node
327
+ * @param context - The context containing variables and objects
328
+ * @returns The result of the logical operation
329
+ */
330
+ private evaluateLogicalExpression;
331
+ /**
332
+ * Evaluates a conditional (ternary) expression (condition ? trueValue : falseValue)
333
+ * @param node - The conditional expression node
334
+ * @param context - The context containing variables and objects
335
+ * @returns The result based on the condition evaluation
336
+ */
337
+ private evaluateConditionalExpression;
338
+ /**
339
+ * Evaluates an object expression (object literal)
340
+ * @param node - The object expression node
341
+ * @param context - The context containing variables and objects
342
+ * @returns The evaluated object
343
+ */
344
+ private evaluateObjectExpression;
345
+ /**
346
+ * Evaluates a sequence expression (comma-separated expressions)
347
+ * @param node - The sequence expression node
348
+ * @param context - The context containing variables and objects
349
+ * @returns The result of the last expression in the sequence
350
+ */
351
+ private evaluateSequenceExpression;
352
+ /**
353
+ * Evaluates a template literal
354
+ * @param node - The template literal node
355
+ * @param context - The context containing variables and objects
356
+ * @returns The evaluated template string
357
+ */
358
+ private evaluateTemplateLiteral;
359
+ /**
360
+ * Evaluates a function call expression with strict type checking
361
+ * @param node - The function call expression node
362
+ * @param context - The context containing variables and objects
363
+ * @returns The result of the function call
364
+ */
365
+ private evaluateCallExpression;
366
+ /**
367
+ * Calls a method on an object after verifying it's safe to do so
368
+ * @param object - The object to call the method on
369
+ * @param methodName - The name of the method to call
370
+ * @param args - The arguments to pass to the method
371
+ * @returns The result of the method call
372
+ */
373
+ private callSafeMethod;
374
+ private isAllowedMethod;
375
+ /**
376
+ * Evaluates an arrow function expression
377
+ * @param node - The arrow function expression node
378
+ * @param context - The context containing variables and objects
379
+ * @returns A function that can be called from other expressions
380
+ */
381
+ private evaluateArrowFunctionExpression;
382
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<ExpressionService, never>;
383
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<ExpressionService>;
384
+ }
385
+
386
+ declare class ComponentRegistrationService implements ComponentResolver {
387
+ private readonly _registrations;
388
+ readonly registrations: _angular_core.Signal<ReadonlyMap<string, _angular_core.Type<unknown>>>;
389
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<ComponentRegistrationService, never>;
390
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<ComponentRegistrationService>;
391
+ }
392
+
393
+ declare class NgxFbConfigurationService {
394
+ private readonly _config;
395
+ get testIdBuilder(): TestIdBuilderFn | undefined;
396
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgxFbConfigurationService, never>;
397
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<NgxFbConfigurationService>;
398
+ }
399
+
400
+ declare function toSafeString(value: unknown): string;
401
+
402
+ /**
403
+ * Resolves an expression option into a computed signal value
404
+ *
405
+ * Handles three expression types:
406
+ * - **string**: Parsed to AST and evaluated against the form context
407
+ * - **function**: Called with the form context as argument
408
+ * - **static value / undefined**: Returned as-is
409
+ *
410
+ * Internally caches the parsed AST in a separate computed signal
411
+ * so it is only recalculated when the option itself changes.
412
+ *
413
+ * @param option Signal containing the expression option (string, function, static value, or undefined)
414
+ * @param formContext Signal providing the current form context for expression evaluation
415
+ * @param expressionService Service used to parse and evaluate string expressions
416
+ * @returns Computed signal that resolves to the evaluated value or undefined
417
+ */
418
+ declare function resolveExpression<T>(option: Signal<Expression<T> | T | undefined>, formContext: Signal<FormContext>, expressionService: ExpressionService): Signal<T | undefined>;
419
+
420
+ /**
421
+ * Resolves an inheritable boolean expression with parent state fallback
422
+ *
423
+ * Used for states like disabled and readonly that follow a common pattern:
424
+ * 1. If the option is undefined, inherit the parent state
425
+ * 2. Otherwise, resolve the expression and default to false
426
+ *
427
+ * @param option Signal containing the expression option (boolean, string expression, function, or undefined)
428
+ * @param formContext Signal providing the current form context for expression evaluation
429
+ * @param expressionService Service used to parse and evaluate string expressions
430
+ * @param parentState Signal providing the parent group's state to inherit from
431
+ * @returns Computed signal that resolves to a boolean state
432
+ */
433
+ declare function resolveInheritableExpression(option: Signal<Expression<boolean> | boolean | undefined>, formContext: Signal<FormContext>, expressionService: ExpressionService, parentState: Signal<boolean>): Signal<boolean>;
434
+
435
+ /**
436
+ * Resolves the hidden state with parent combination logic
437
+ *
438
+ * The hidden state differs from disabled/readonly inheritance:
439
+ * 1. If the option is undefined, inherit the parent hidden state
440
+ * 2. If the option is a function expression, use only the resolved value
441
+ * 3. If the option is a string expression, OR with the parent hidden state
442
+ * (a child is hidden if either its own condition or its parent is hidden)
443
+ *
444
+ * @param option Signal containing the hidden expression option
445
+ * @param formContext Signal providing the current form context for expression evaluation
446
+ * @param expressionService Service used to parse and evaluate string expressions
447
+ * @param parentHiddenState Signal providing the parent group's hidden state
448
+ * @returns Computed signal that resolves to a boolean hidden state
449
+ */
450
+ declare function resolveHiddenState(option: Signal<Expression<boolean> | boolean | undefined>, formContext: Signal<FormContext>, expressionService: ExpressionService, parentHiddenState: Signal<boolean>): Signal<boolean>;
451
+
452
+ /**
453
+ * Creates an effect that manages disabled state transitions
454
+ *
455
+ * When disabledHandling is 'auto', calls the appropriate enable/disable
456
+ * function based on the disabled signal. When 'manual', does nothing.
457
+ *
458
+ * @param options Configuration object for disabled effect
459
+ * @param options.disabledSignal Signal that indicates if the component should be disabled
460
+ * @param options.disabledHandlingSignal Signal that determines how disabled state changes should be handled
461
+ * @param options.enableFunction Function to call when component should be enabled
462
+ * @param options.disableFunction Function to call when component should be disabled
463
+ */
464
+ declare function resolveDisabledEffect(options: {
465
+ disabledSignal: Signal<boolean>;
466
+ disabledHandlingSignal: Signal<StateHandling>;
467
+ enableFunction: SimpleFunction;
468
+ disableFunction: SimpleFunction;
469
+ }): void;
470
+
471
+ /**
472
+ * Resolves a test ID for a form element
473
+ *
474
+ * The test ID is determined using the following priority:
475
+ * 1. A local testIdBuilder function if provided
476
+ * 2. A global testIdBuilder function if provided
477
+ * 3. Default: joins parentTestId and name with '-', or just name if no parent
478
+ *
479
+ * @param content Signal containing the base content configuration
480
+ * @param name Signal containing the control/group name
481
+ * @param testIdBuilder Signal holding an optional local testIdBuilder function
482
+ * @param globalTestIdBuilder Optional global testIdBuilder function from configuration
483
+ * @param parentTestId Signal providing the parent group's test ID
484
+ * @returns Computed signal that resolves to the test ID string
485
+ */
486
+ declare function resolveTestId(content: Signal<NgxFbBaseContent>, name: Signal<string>, testIdBuilder: Signal<TestIdBuilderFn | undefined>, globalTestIdBuilder: TestIdBuilderFn | undefined, parentTestId: Signal<string | undefined>): Signal<string>;
487
+
488
+ /**
489
+ * Resolves the hidden attribute value for DOM binding
490
+ *
491
+ * When visibilityHandling is 'auto', returns `true` (attribute present)
492
+ * or `null` (attribute absent) based on the hidden state.
493
+ * When visibilityHandling is 'manual', always returns `null` so the
494
+ * component can handle visibility itself.
495
+ *
496
+ * @param options Configuration object
497
+ * @param options.hiddenSignal Signal indicating whether the element should be hidden
498
+ * @param options.hiddenHandlingSignal Signal for the visibility handling strategy
499
+ * @returns Computed signal resolving to `true` (hidden) or `null` (visible)
500
+ */
501
+ declare function resolveHiddenAttribute(options: {
502
+ hiddenSignal: Signal<boolean>;
503
+ hiddenHandlingSignal: Signal<StateHandling>;
504
+ }): Signal<true | null>;
505
+
506
+ /**
507
+ * Resolves the update strategy for a form control or group
508
+ *
509
+ * The strategy is determined using the following priority:
510
+ * 1. The control's own updateOn value if defined
511
+ * 2. The parent group's strategy if defined
512
+ * 3. The application-wide default strategy
513
+ *
514
+ * @param controlUpdateOn Signal containing the control's updateOn configuration
515
+ * @param parentStrategy Signal providing the parent group's update strategy
516
+ * @param defaultStrategy The application-wide default update strategy
517
+ * @returns Computed signal providing the resolved update strategy
518
+ */
519
+ declare function resolveUpdateStrategy(controlUpdateOn: Signal<UpdateStrategy | undefined>, parentStrategy: Signal<UpdateStrategy | undefined>, defaultStrategy: UpdateStrategy): Signal<UpdateStrategy>;
520
+
521
+ export { ComponentRegistrationService, ExpressionService, NGX_FW_COMPONENT_REGISTRATIONS, NGX_FW_COMPONENT_RESOLVER, NGX_FW_CONFIG, NGX_FW_CONFIG_RESOLVED, NGX_FW_DEFAULT_CONFIG, NGX_FW_DEFAULT_UPDATE_STRATEGY, NgxFbConfigurationService, NgxfbAbstractControlDirective, resolveDisabledEffect, resolveExpression, resolveHiddenAttribute, resolveHiddenState, resolveInheritableExpression, resolveTestId, resolveUpdateStrategy, toSafeString };
522
+ export type { ComponentRegistrationConfig, ComponentResolver, Expression, FormContext, HideStrategy, NgxFbAbstractControl, NgxFbBaseContent, NgxFbBlock, NgxFbContent, NgxFbControl, NgxFbForm, NgxFbFormGroup, NgxFbGlobalConfiguration, SimpleFunction, StateHandling, TestIdBuilderFn, UpdateStrategy, ValueHandleFunction, ValueStrategy };
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Alexander Pahn
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
package/index.d.ts DELETED
@@ -1,5 +0,0 @@
1
- /**
2
- * Generated bundle index. Do not edit.
3
- */
4
- /// <amd-module name="@ngx-formbar/core" />
5
- export * from './public-api';
@@ -1,28 +0,0 @@
1
- import { NgxFbBaseContent, NgxFbContent } from '../../types/content.type';
2
- import { NgxFbForm } from '../../types/form.type';
3
- import * as i0 from "@angular/core";
4
- /**
5
- * Ngx Formbar Form Component
6
- *
7
- * This component serves as the main container for Ngx Formbar forms:
8
- * - Takes a form configuration
9
- * - Establishes the form context through FormService provider
10
- * - Renders each content item using NgxfbAbstractControlDirective
11
- * - Handles component registration and dependency injection
12
- *
13
- * The component acts as the root element for declarative form creation,
14
- * processing the form content configuration and rendering the appropriate
15
- * components for each control defined in the configuration.
16
- */
17
- export declare class NgxfbFormComponent<T extends NgxFbBaseContent = NgxFbContent> {
18
- /**
19
- * Required input containing form configuration
20
- */
21
- readonly formConfig: import("@angular/core").InputSignal<NgxFbForm<T>>;
22
- /**
23
- * Computed value containing form content
24
- */
25
- readonly formContent: import("@angular/core").Signal<[string, T][]>;
26
- static ɵfac: i0.ɵɵFactoryDeclaration<NgxfbFormComponent<any>, never>;
27
- static ɵcmp: i0.ɵɵComponentDeclaration<NgxfbFormComponent<any>, "ngxfb-form", never, { "formConfig": { "alias": "formConfig"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
28
- }
@@ -1,8 +0,0 @@
1
- import { Signal } from '@angular/core';
2
- import { NgxFbAbstractControl } from '../types/content.type';
3
- import { AbstractControl } from '@angular/forms';
4
- export declare function withComputedValue<T>(content: Signal<NgxFbAbstractControl>): Signal<T | undefined>;
5
- export declare function setComputedValueEffect<T>(options: {
6
- controlInstance: Signal<AbstractControl>;
7
- computeValueSignal: Signal<T>;
8
- }): void;
@@ -1,36 +0,0 @@
1
- import { Signal } from '@angular/core';
2
- import { StateHandling } from '../types/registration.type';
3
- import { SimpleFunction } from '../types/functions.type';
4
- import { NgxFbAbstractControl } from '../types/content.type';
5
- /**
6
- * Computes a reactive disabled state based on control content
7
- *
8
- * The disabled state is determined using the following priority:
9
- * 1. If content.disabled is a boolean, that value is used directly
10
- * 2. If content.disabled is an expression string, it's parsed to AST and evaluated
11
- * against the current form values
12
- * 3. If no disabled property is defined, the control inherits the disabled state
13
- * from its parent group
14
- *
15
- * This hierarchical inheritance ensures that child controls are automatically
16
- * disabled when their parent group is disabled, unless explicitly overridden.
17
- *
18
- * @param content Signal containing control configuration with potential disabled property
19
- * @returns Computed signal that resolves to boolean disabled state
20
- */
21
- export declare function withDisabledState(content: Signal<NgxFbAbstractControl>): Signal<boolean>;
22
- /**
23
- * Creates an effect that manages control/group disabled state
24
- *
25
- * @param options Configuration object for disabled effect
26
- * @param options.disabledSignal Signal that indicates if the component should be disabled
27
- * @param options.disabledHandlingSignal Signal that determines how disabled state changes should be handled
28
- * @param options.enableFunction Function to call when component should be enabled
29
- * @param options.disableFunction Function to call when component should be disabled
30
- */
31
- export declare function disabledEffect(options: {
32
- disabledSignal: Signal<boolean>;
33
- disabledHandlingSignal: Signal<StateHandling>;
34
- enableFunction: SimpleFunction;
35
- disableFunction: SimpleFunction;
36
- }): void;
@@ -1,9 +0,0 @@
1
- import { Signal } from '@angular/core';
2
- import { NgxFbControl } from '../types/content.type';
3
- /**
4
- * Computes a dynamic label for a form control based on expression evaluation
5
- *
6
- * @param content Signal containing control configuration with dynamicLabel property
7
- * @returns Computed signal that resolves to the evaluated dynamic label string or undefined
8
- */
9
- export declare function withDynamicLabel(content: Signal<NgxFbControl>): Signal<string | undefined>;
@@ -1,9 +0,0 @@
1
- import { Signal } from '@angular/core';
2
- import { NgxFbFormGroup } from '../types/content.type';
3
- /**
4
- * Computes a dynamic title for a form control based on expression evaluation
5
- *
6
- * @param content Signal containing control configuration with dynamicTitle property
7
- * @returns Computed signal that resolves to the evaluated dynamic title string or undefined
8
- */
9
- export declare function withDynamicTitle(content: Signal<NgxFbFormGroup>): Signal<string | undefined>;