@ngx-formbar/core 1.0.0 → 2.0.0-next.1

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 +225 -1658
  3. package/fesm2022/ngx-formbar-core.mjs.map +1 -1
  4. package/package.json +5 -12
  5. package/types/ngx-formbar-core.d.ts +525 -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,525 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Type, Signal, InjectionToken } from '@angular/core';
3
+ import { Program } from 'acorn';
4
+ import * as _ngx_formbar_core from '@ngx-formbar/core';
5
+
6
+ /**
7
+ * Function that lazily loads a component.
8
+ * Works analog to lazily loading a component for a route.
9
+ */
10
+ type LoadComponentFn = () => Promise<Type<unknown>>;
11
+ /**
12
+ * Registration entry for a statically imported component.
13
+ */
14
+ interface StaticRegistration {
15
+ component: Type<unknown>;
16
+ }
17
+ /**
18
+ * Registration entry for a lazily loaded component.
19
+ */
20
+ interface LazyRegistration {
21
+ loadComponent: LoadComponentFn;
22
+ }
23
+ /**
24
+ * A component registration entry — either static or lazy.
25
+ *
26
+ * - Static: `{ component: MyComponent }` — component is eagerly imported
27
+ * - Lazy: `{ loadComponent: () => import(...).then(m => m.MyComponent) }` — loaded on demand
28
+ */
29
+ type ComponentRegistrationEntry = StaticRegistration | LazyRegistration;
30
+ /**
31
+ * Configuration for registering component types.
32
+ *
33
+ * Maps string type identifiers to component implementations for dynamic rendering.
34
+ * Supports both static and lazy component registrations.
35
+ */
36
+ type ComponentRegistrationConfig = Record<string, ComponentRegistrationEntry>;
37
+ /**
38
+ * Strategy for handling component states
39
+ *
40
+ * Determines how visibility, disabled, and other component states
41
+ * are managed.
42
+ *
43
+ * - 'auto': Formbar automatically manages the state
44
+ * - 'manual': The component/host manages the state itself
45
+ */
46
+ type StateHandling = 'auto' | 'manual';
47
+
48
+ interface ComponentResolver {
49
+ registrations: Signal<ReadonlyMap<string, ComponentRegistrationEntry>>;
50
+ }
51
+
52
+ type FormContext = Record<string, unknown>;
53
+ type Expression<T> = string | ((formValue: FormContext) => T);
54
+
55
+ /**
56
+ * The foundation for all form controls and groups. It defines the minimal set of
57
+ * properties shared across all content types: type identification and visibility.
58
+ */
59
+ interface NgxFbBaseContent {
60
+ /**
61
+ * Specifies the kind of form control. Determines what control is used and what
62
+ * additional properties are available.
63
+ */
64
+ type: string;
65
+ /**
66
+ * A string expression that determines when the control should be hidden.
67
+ * This condition is evaluated at runtime against the whole form object.
68
+ */
69
+ hidden?: Expression<boolean>;
70
+ }
71
+ /**
72
+ * Extends the base content with validation and control state management properties.
73
+ * Used as a base for both form controls and groups.
74
+ */
75
+ interface NgxFbAbstractControl extends NgxFbBaseContent {
76
+ /**
77
+ * Array of strings representing names of synchronous validators that apply to the control.
78
+ * These can be registered globally with a validator registration object.
79
+ */
80
+ validators?: string[];
81
+ /**
82
+ * Similar to validators, but for asynchronous validation logic that may involve
83
+ * API calls or other deferred operations.
84
+ */
85
+ asyncValidators?: string[];
86
+ /**
87
+ * Defines whether the control should be disabled. Can be a boolean value or a
88
+ * string expression that evaluates against the form object.
89
+ */
90
+ disabled?: Expression<boolean> | boolean;
91
+ /**
92
+ * Specifies how to handle the control when hidden.
93
+ * @see {@link HideStrategy}
94
+ */
95
+ hideStrategy?: HideStrategy;
96
+ /**
97
+ * Determines how the control's value is handled when visibility changes.
98
+ * @see {@link ValueStrategy}
99
+ */
100
+ valueStrategy?: ValueStrategy;
101
+ /**
102
+ * Indicates if the control is read-only (displayed but not modifiable).
103
+ * Accepts either a boolean value or a string expression for dynamic evaluation.
104
+ */
105
+ readonly?: Expression<boolean> | boolean;
106
+ /**
107
+ * Specifies when to update the control's value.
108
+ * @see {@link UpdateStrategy}
109
+ */
110
+ updateOn?: UpdateStrategy;
111
+ /**
112
+ * A value that is automatically derived and set for the control.
113
+ * It will overwrite user input if one of its dependencies changes.
114
+ */
115
+ computedValue?: Expression<unknown>;
116
+ }
117
+ /**
118
+ * Specifies when to update the control's value:
119
+ * - 'change': as user types (default)
120
+ * - 'blur': when control loses focus
121
+ * - 'submit': when form is submitted
122
+ */
123
+ type UpdateStrategy = 'change' | 'blur' | 'submit' | undefined;
124
+ /**
125
+ * Represents a group of controls that can be nested within a form.
126
+ */
127
+ interface NgxFbFormGroup<T extends NgxFbBaseContent = NgxFbContent> extends NgxFbAbstractControl {
128
+ /**
129
+ * Specifies a title for the group
130
+ */
131
+ title?: string;
132
+ /**
133
+ * Dynamic title that can be evaluated from form data
134
+ */
135
+ dynamicTitle?: Expression<string>;
136
+ /**
137
+ * Object mapping keys to NgxFbContent that configure the controls of the group
138
+ */
139
+ controls: Record<string, T>;
140
+ }
141
+ /**
142
+ * Represents an individual form control with label and value properties.
143
+ */
144
+ interface NgxFbControl extends NgxFbAbstractControl {
145
+ /**
146
+ * Specifies the label for the control
147
+ */
148
+ label?: string;
149
+ /**
150
+ * Dynamic label that can be evaluated from form data
151
+ */
152
+ dynamicLabel?: Expression<string>;
153
+ /**
154
+ * Default value for the control. Override this type in extending interfaces to match the control's value type.
155
+ */
156
+ defaultValue?: unknown;
157
+ /**
158
+ * Whether this control can have a null value. Used to set the same property through the reactive forms API.
159
+ */
160
+ nonNullable?: boolean;
161
+ }
162
+ /**
163
+ * Represents a block element that doesn't behave like a form control.
164
+ * Used for UI elements that aren't part of the form model.
165
+ */
166
+ interface NgxFbBlock extends NgxFbBaseContent {
167
+ /**
168
+ * Required property for TypeScript to properly do type narrowing
169
+ */
170
+ isControl: false;
171
+ [key: string]: unknown;
172
+ }
173
+ /**
174
+ * Union type representing all possible content types that can be used in a form.
175
+ */
176
+ type NgxFbContent = NgxFbFormGroup | NgxFbControl | NgxFbBlock;
177
+ /**
178
+ * Specifies how to handle the control when hidden:
179
+ * - 'keep': control remains in form model
180
+ * - 'remove': control is removed from form model
181
+ */
182
+ type HideStrategy = 'keep' | 'remove';
183
+ /**
184
+ * Determines how the control's value is handled when visibility changes:
185
+ * - 'last': preserves last value
186
+ * - 'default': reverts to default value
187
+ * - 'reset': clears value
188
+ */
189
+ type ValueStrategy = 'last' | 'default' | 'reset';
190
+
191
+ interface NgxFbForm<ContentType extends NgxFbBaseContent = NgxFbContent> {
192
+ content: Record<string, ContentType>;
193
+ }
194
+
195
+ type SimpleFunction = () => void;
196
+ type ValueHandleFunction = (valueStrategy?: ValueStrategy) => void;
197
+ type TestIdBuilderFn = (content: NgxFbBaseContent, name: string, parentTestId?: string) => string;
198
+
199
+ interface NgxFbGlobalConfiguration {
200
+ testIdBuilderFn: TestIdBuilderFn | undefined;
201
+ }
202
+
203
+ declare const NGX_FW_COMPONENT_REGISTRATIONS: InjectionToken<ReadonlyMap<string, ComponentRegistrationEntry>>;
204
+
205
+ declare const NGX_FW_COMPONENT_RESOLVER: InjectionToken<ComponentResolver>;
206
+
207
+ declare const NGX_FW_DEFAULT_CONFIG: InjectionToken<NgxFbGlobalConfiguration>;
208
+ declare const NGX_FW_CONFIG: InjectionToken<readonly Partial<NgxFbGlobalConfiguration>[]>;
209
+ declare const NGX_FW_CONFIG_RESOLVED: InjectionToken<NgxFbGlobalConfiguration>;
210
+
211
+ declare const NGX_FW_DEFAULT_UPDATE_STRATEGY: InjectionToken<UpdateStrategy>;
212
+
213
+ /**
214
+ * Service for parsing and evaluating JavaScript expressions within a context object
215
+ */
216
+ declare class ExpressionService {
217
+ /**
218
+ * Cache for parsed ASTs to avoid re-parsing the same expression
219
+ */
220
+ private readonly astCache;
221
+ /**
222
+ * Parses an expression string into an abstract syntax tree (AST)
223
+ * @param expressionString - The expression to parse
224
+ * @returns The parsed AST or null
225
+ */
226
+ parseExpressionToAst(expressionString?: string): Program | null;
227
+ /**
228
+ * Evaluates an expression AST within the provided context
229
+ * @param ast - The parsed AST to evaluate
230
+ * @param context - The context containing variables and objects referenced in the expression
231
+ * @returns The result of evaluating the expression
232
+ */
233
+ evaluateExpression(ast?: Program | null, context?: FormContext): unknown;
234
+ /**
235
+ * Evaluates a node in the AST
236
+ * @param node - The AST node to evaluate
237
+ * @param context - The context containing variables and objects
238
+ * @returns The result of evaluating the node
239
+ */
240
+ private evaluateAstNode;
241
+ /**
242
+ * Evaluates a literal value node
243
+ * @param node - The literal node to evaluate
244
+ * @returns The literal value
245
+ */
246
+ private evaluateLiteral;
247
+ /**
248
+ * Evaluates a binary expression (e.g., a + b, x > y)
249
+ * @param node - The binary expression node
250
+ * @param context - The context containing variables and objects
251
+ * @returns The result of the binary operation
252
+ */
253
+ private evaluateBinaryExpression;
254
+ /**
255
+ * Executes a binary operation with the given values and operator
256
+ * @param leftValue - The left operand
257
+ * @param operator - The binary operator
258
+ * @param rightValue - The right operand
259
+ * @returns The result of applying the operator to the operands
260
+ */
261
+ private executeBinaryOperation;
262
+ /**
263
+ * Evaluates a member expression (e.g., obj.prop, arr[0]) with improved safety
264
+ * @param node - The member expression node
265
+ * @param context - The context containing variables and objects
266
+ * @returns The value of the member
267
+ */
268
+ private evaluateMemberExpression;
269
+ /**
270
+ * Gets a property from an object by key
271
+ * @param object - The object to retrieve the property from
272
+ * @param propertyKey - The property key (string or number)
273
+ * @returns The value of the property
274
+ */
275
+ private getPropertyFromObject;
276
+ /**
277
+ * Evaluates an identifier node by looking it up in the context
278
+ * @param node - The identifier node
279
+ * @param context - The context containing variables and objects
280
+ * @returns The value of the identifier from the context
281
+ */
282
+ private evaluateIdentifier;
283
+ /**
284
+ * Evaluates an array expression node
285
+ * @param node - The array expression node
286
+ * @param context - The context containing variables and objects
287
+ * @returns The evaluated array
288
+ */
289
+ private evaluateArrayExpression;
290
+ /**
291
+ * Evaluates a unary expression (e.g., !x, -value, typeof obj)
292
+ * @param node - The unary expression node
293
+ * @param context - The context containing variables and objects
294
+ * @returns The result of the unary operation
295
+ */
296
+ private evaluateUnaryExpression;
297
+ /**
298
+ * Evaluates a logical expression (&&, ||, ??)
299
+ * @param node - The logical expression node
300
+ * @param context - The context containing variables and objects
301
+ * @returns The result of the logical operation
302
+ */
303
+ private evaluateLogicalExpression;
304
+ /**
305
+ * Evaluates a conditional (ternary) expression (condition ? trueValue : falseValue)
306
+ * @param node - The conditional expression node
307
+ * @param context - The context containing variables and objects
308
+ * @returns The result based on the condition evaluation
309
+ */
310
+ private evaluateConditionalExpression;
311
+ /**
312
+ * Evaluates an object expression (object literal)
313
+ * @param node - The object expression node
314
+ * @param context - The context containing variables and objects
315
+ * @returns The evaluated object
316
+ */
317
+ private evaluateObjectExpression;
318
+ /**
319
+ * Evaluates a sequence expression (comma-separated expressions)
320
+ * @param node - The sequence expression node
321
+ * @param context - The context containing variables and objects
322
+ * @returns The result of the last expression in the sequence
323
+ */
324
+ private evaluateSequenceExpression;
325
+ /**
326
+ * Evaluates a template literal
327
+ * @param node - The template literal node
328
+ * @param context - The context containing variables and objects
329
+ * @returns The evaluated template string
330
+ */
331
+ private evaluateTemplateLiteral;
332
+ /**
333
+ * Evaluates a function call expression with strict type checking
334
+ * @param node - The function call expression node
335
+ * @param context - The context containing variables and objects
336
+ * @returns The result of the function call
337
+ */
338
+ private evaluateCallExpression;
339
+ /**
340
+ * Calls a method on an object after verifying it's safe to do so
341
+ * @param object - The object to call the method on
342
+ * @param methodName - The name of the method to call
343
+ * @param args - The arguments to pass to the method
344
+ * @returns The result of the method call
345
+ */
346
+ private callSafeMethod;
347
+ private isAllowedMethod;
348
+ /**
349
+ * Evaluates an arrow function expression
350
+ * @param node - The arrow function expression node
351
+ * @param context - The context containing variables and objects
352
+ * @returns A function that can be called from other expressions
353
+ */
354
+ private evaluateArrowFunctionExpression;
355
+ static ɵfac: i0.ɵɵFactoryDeclaration<ExpressionService, never>;
356
+ static ɵprov: i0.ɵɵInjectableDeclaration<ExpressionService>;
357
+ }
358
+
359
+ declare class ComponentRegistrationService implements ComponentResolver {
360
+ private readonly _registrations;
361
+ readonly registrations: i0.Signal<ReadonlyMap<string, _ngx_formbar_core.ComponentRegistrationEntry>>;
362
+ static ɵfac: i0.ɵɵFactoryDeclaration<ComponentRegistrationService, never>;
363
+ static ɵprov: i0.ɵɵInjectableDeclaration<ComponentRegistrationService>;
364
+ }
365
+
366
+ declare class NgxFbConfigurationService {
367
+ private readonly _config;
368
+ get testIdBuilder(): TestIdBuilderFn | undefined;
369
+ static ɵfac: i0.ɵɵFactoryDeclaration<NgxFbConfigurationService, never>;
370
+ static ɵprov: i0.ɵɵInjectableDeclaration<NgxFbConfigurationService>;
371
+ }
372
+
373
+ /**
374
+ * Creates a static component registration entry.
375
+ * Use for eagerly imported components that don't need lazy loading.
376
+ *
377
+ * @example
378
+ * ```ts
379
+ * import { staticComponent } from '@ngx-formbar/core';
380
+ * import { TextComponent } from './text.component';
381
+ *
382
+ * const registrations = {
383
+ * text: staticComponent(TextComponent),
384
+ * };
385
+ * ```
386
+ */
387
+ declare function staticComponent(type: Type<unknown>): StaticRegistration;
388
+ /**
389
+ * Creates a lazy component registration entry.
390
+ * Use for components that should be loaded on demand.
391
+ *
392
+ * @example
393
+ * ```ts
394
+ * import { loadComponent } from '@ngx-formbar/core';
395
+ *
396
+ * const registrations = {
397
+ * text: loadComponent(() => import('./text.component').then(m => m.TextComponent)),
398
+ * };
399
+ * ```
400
+ */
401
+ declare function loadComponent(load: LoadComponentFn): LazyRegistration;
402
+
403
+ declare function toSafeString(value: unknown): string;
404
+
405
+ /**
406
+ * Resolves an expression option into a computed signal value
407
+ *
408
+ * Handles three expression types:
409
+ * - **string**: Parsed to AST and evaluated against the form context
410
+ * - **function**: Called with the form context as argument
411
+ * - **static value / undefined**: Returned as-is
412
+ *
413
+ * Internally caches the parsed AST in a separate computed signal
414
+ * so it is only recalculated when the option itself changes.
415
+ *
416
+ * @param option Signal containing the expression option (string, function, static value, or undefined)
417
+ * @param formContext Signal providing the current form context for expression evaluation
418
+ * @param expressionService Service used to parse and evaluate string expressions
419
+ * @returns Computed signal that resolves to the evaluated value or undefined
420
+ */
421
+ declare function resolveExpression<T>(option: Signal<Expression<T> | T | undefined>, formContext: Signal<FormContext>, expressionService: ExpressionService): Signal<T | undefined>;
422
+
423
+ /**
424
+ * Resolves an inheritable boolean expression with parent state fallback
425
+ *
426
+ * Used for states like disabled and readonly that follow a common pattern:
427
+ * 1. If the option is undefined, inherit the parent state
428
+ * 2. Otherwise, resolve the expression and default to false
429
+ *
430
+ * @param option Signal containing the expression option (boolean, string expression, function, or undefined)
431
+ * @param formContext Signal providing the current form context for expression evaluation
432
+ * @param expressionService Service used to parse and evaluate string expressions
433
+ * @param parentState Signal providing the parent group's state to inherit from
434
+ * @returns Computed signal that resolves to a boolean state
435
+ */
436
+ declare function resolveInheritableExpression(option: Signal<Expression<boolean> | boolean | undefined>, formContext: Signal<FormContext>, expressionService: ExpressionService, parentState: Signal<boolean>): Signal<boolean>;
437
+
438
+ /**
439
+ * Resolves the hidden state with parent combination logic
440
+ *
441
+ * The hidden state differs from disabled/readonly inheritance:
442
+ * 1. If the option is undefined, inherit the parent hidden state
443
+ * 2. If the option is a function expression, use only the resolved value
444
+ * 3. If the option is a string expression, OR with the parent hidden state
445
+ * (a child is hidden if either its own condition or its parent is hidden)
446
+ *
447
+ * @param option Signal containing the hidden expression option
448
+ * @param formContext Signal providing the current form context for expression evaluation
449
+ * @param expressionService Service used to parse and evaluate string expressions
450
+ * @param parentHiddenState Signal providing the parent group's hidden state
451
+ * @returns Computed signal that resolves to a boolean hidden state
452
+ */
453
+ declare function resolveHiddenState(option: Signal<Expression<boolean> | boolean | undefined>, formContext: Signal<FormContext>, expressionService: ExpressionService, parentHiddenState: Signal<boolean>): Signal<boolean>;
454
+
455
+ /**
456
+ * Creates an effect that manages disabled state transitions
457
+ *
458
+ * When disabledHandling is 'auto', calls the appropriate enable/disable
459
+ * function based on the disabled signal. When 'manual', does nothing.
460
+ *
461
+ * @param options Configuration object for disabled effect
462
+ * @param options.disabledSignal Signal that indicates if the component should be disabled
463
+ * @param options.disabledHandlingSignal Signal that determines how disabled state changes should be handled
464
+ * @param options.enableFunction Function to call when component should be enabled
465
+ * @param options.disableFunction Function to call when component should be disabled
466
+ */
467
+ declare function resolveDisabledEffect(options: {
468
+ disabledSignal: Signal<boolean>;
469
+ disabledHandlingSignal: Signal<StateHandling>;
470
+ enableFunction: SimpleFunction;
471
+ disableFunction: SimpleFunction;
472
+ }): void;
473
+
474
+ /**
475
+ * Resolves a test ID for a form element
476
+ *
477
+ * The test ID is determined using the following priority:
478
+ * 1. A local testIdBuilder function if provided
479
+ * 2. A global testIdBuilder function if provided
480
+ * 3. Default: joins parentTestId and name with '-', or just name if no parent
481
+ *
482
+ * @param content Signal containing the base content configuration
483
+ * @param name Signal containing the control/group name
484
+ * @param testIdBuilder Signal holding an optional local testIdBuilder function
485
+ * @param globalTestIdBuilder Optional global testIdBuilder function from configuration
486
+ * @param parentTestId Signal providing the parent group's test ID
487
+ * @returns Computed signal that resolves to the test ID string
488
+ */
489
+ declare function resolveTestId(content: Signal<NgxFbBaseContent>, name: Signal<string>, testIdBuilder: Signal<TestIdBuilderFn | undefined>, globalTestIdBuilder: TestIdBuilderFn | undefined, parentTestId: Signal<string | undefined>): Signal<string>;
490
+
491
+ /**
492
+ * Resolves the hidden attribute value for DOM binding
493
+ *
494
+ * When visibilityHandling is 'auto', returns `true` (attribute present)
495
+ * or `null` (attribute absent) based on the hidden state.
496
+ * When visibilityHandling is 'manual', always returns `null` so the
497
+ * component can handle visibility itself.
498
+ *
499
+ * @param options Configuration object
500
+ * @param options.hiddenSignal Signal indicating whether the element should be hidden
501
+ * @param options.hiddenHandlingSignal Signal for the visibility handling strategy
502
+ * @returns Computed signal resolving to `true` (hidden) or `null` (visible)
503
+ */
504
+ declare function resolveHiddenAttribute(options: {
505
+ hiddenSignal: Signal<boolean>;
506
+ hiddenHandlingSignal: Signal<StateHandling>;
507
+ }): Signal<true | null>;
508
+
509
+ /**
510
+ * Resolves the update strategy for a form control or group
511
+ *
512
+ * The strategy is determined using the following priority:
513
+ * 1. The control's own updateOn value if defined
514
+ * 2. The parent group's strategy if defined
515
+ * 3. The application-wide default strategy
516
+ *
517
+ * @param controlUpdateOn Signal containing the control's updateOn configuration
518
+ * @param parentStrategy Signal providing the parent group's update strategy
519
+ * @param defaultStrategy The application-wide default update strategy
520
+ * @returns Computed signal providing the resolved update strategy
521
+ */
522
+ declare function resolveUpdateStrategy(controlUpdateOn: Signal<UpdateStrategy | undefined>, parentStrategy: Signal<UpdateStrategy | undefined>, defaultStrategy: UpdateStrategy): Signal<UpdateStrategy>;
523
+
524
+ 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, loadComponent, resolveDisabledEffect, resolveExpression, resolveHiddenAttribute, resolveHiddenState, resolveInheritableExpression, resolveTestId, resolveUpdateStrategy, staticComponent, toSafeString };
525
+ export type { ComponentRegistrationConfig, ComponentRegistrationEntry, ComponentResolver, Expression, FormContext, HideStrategy, LazyRegistration, LoadComponentFn, NgxFbAbstractControl, NgxFbBaseContent, NgxFbBlock, NgxFbContent, NgxFbControl, NgxFbForm, NgxFbFormGroup, NgxFbGlobalConfiguration, SimpleFunction, StateHandling, StaticRegistration, 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>;