@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,22 @@
1
+ import { Signal } from '@angular/core';
2
+ import { NgxFbAbstractControl } from '../types/content.type';
3
+ /**
4
+ * Computes a reactive array of validators based on control content
5
+ *
6
+ * Extracts validator keys from content and maps them to actual validator functions
7
+ * by looking them up in the validator registration service.
8
+ *
9
+ * @param content Signal containing control configuration with validator keys
10
+ * @returns Computed signal that resolves to an array of validator functions
11
+ */
12
+ export declare function withValidators(content: Signal<NgxFbAbstractControl>): Signal<import("@angular/forms").ValidatorFn[]>;
13
+ /**
14
+ * Computes a reactive array of async validators based on control content
15
+ *
16
+ * Extracts async validator keys from content and maps them to actual async validator
17
+ * functions by looking them up in the validator registration service.
18
+ *
19
+ * @param content Signal containing control configuration with async validator keys
20
+ * @returns Computed signal that resolves to an array of async validator functions
21
+ */
22
+ export declare function withAsyncValidators(content: Signal<NgxFbAbstractControl>): Signal<import("@angular/forms").AsyncValidatorFn[]>;
@@ -0,0 +1,7 @@
1
+ import { RegistrationRecord } from '../types/validation.type';
2
+ import { FormbarConfig } from '../types/provide.type';
3
+ /**
4
+ * Type helper to make it easier to use formbar.config.ts
5
+ * accepts a direct {@link FormbarConfig} object
6
+ */
7
+ export declare function defineFormbarConfig<S extends RegistrationRecord, A extends RegistrationRecord>(config: FormbarConfig<S, A>): FormbarConfig<S, A>;
@@ -0,0 +1,38 @@
1
+ import { EnvironmentProviders } from '@angular/core';
2
+ import { RegistrationRecord } from '../types/validation.type';
3
+ import { FormbarConfig } from '../types/provide.type';
4
+ /**
5
+ * Configures and provides ngx-formbar to your application.
6
+ *
7
+ * This function is used in app.config.ts to register form components, validators,
8
+ * and set global configuration for the formbar library.
9
+ *
10
+ * @param config Configuration object for ngx-formbar:
11
+ * - componentRegistrations: Optional mapping of control types to component implementations
12
+ * - validatorRegistrations: Optional mapping of validator names to validator functions
13
+ * (Angular's required, requiredTrue, email, and nullValidator are registered by default)
14
+ * - asyncValidatorRegistrations: Optional mapping of async validator names to async validator functions
15
+ * - updateOn: Optional default update strategy for all form controls
16
+ * - globalConfig: Optional global configuration settings
17
+ *
18
+ * @returns Angular environment providers to be included in application configuration
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * // app.config.ts
23
+ * export const appConfig: ApplicationConfig = {
24
+ * providers: [
25
+ * provideFormbar({
26
+ * componentRegistrations: {
27
+ * text: TextInputComponent,
28
+ * select: SelectComponent,
29
+ * },
30
+ * validatorRegistrations: {
31
+ * customValidator: [myCustomValidator]
32
+ * }
33
+ * })
34
+ * ]
35
+ * };
36
+ * ```
37
+ */
38
+ export declare function provideFormbar<S extends RegistrationRecord, A extends RegistrationRecord>(config?: FormbarConfig<S, A>): EnvironmentProviders;
@@ -0,0 +1,53 @@
1
+ import { NgxFbBaseContent } from '../types/content.type';
2
+ import * as i0 from "@angular/core";
3
+ /**
4
+ * Structural directive that renders the appropriate component based on the control's type.
5
+ *
6
+ * This directive acts as a dynamic renderer for form controls, blocks, and groups.
7
+ * It works by:
8
+ * 1. Receiving a content configuration and name
9
+ * 2. Looking up the registered component for the content's type
10
+ * 3. Creating an instance of that component and binding the content and name to it
11
+ *
12
+ * This allows forms to be composed declaratively through configuration objects
13
+ * rather than explicit templates.
14
+ *
15
+ * @example
16
+ * ```html
17
+ * <!-- Used with ngFor to render a list of controls -->
18
+ * @for (control of controls(); track control[0]) {
19
+ * <ng-template *ngxfbAbstractControl="control" />
20
+ * }
21
+ *
22
+ * <!-- Used directly with a specific control -->
23
+ * <ng-template *ngxfbAbstractControl="['name', nameControlConfig]" />
24
+ * ```
25
+ */
26
+ export declare class NgxfbAbstractControlDirective<T extends NgxFbBaseContent> {
27
+ private viewContainerRef;
28
+ /**
29
+ * Service for component registration
30
+ * Provides access to component type mappings
31
+ */
32
+ private readonly contentRegistrationService;
33
+ /**
34
+ * Required input for control configuration
35
+ * Defines properties like type, validation, and other control-specific settings
36
+ */
37
+ readonly content: import("@angular/core").InputSignal<[string, T]>;
38
+ readonly controlName: import("@angular/core").Signal<string>;
39
+ readonly controlConfig: import("@angular/core").Signal<T>;
40
+ /**
41
+ * Registration map of component types
42
+ * Maps control types to component implementations
43
+ */
44
+ readonly registrations: import("@angular/core").Signal<ReadonlyMap<string, import("@angular/core").Type<unknown>>>;
45
+ /**
46
+ * Computed component type based on content.type
47
+ * Looks up the component implementation from registrations map
48
+ */
49
+ readonly component: import("@angular/core").Signal<import("@angular/core").Type<unknown> | null>;
50
+ constructor();
51
+ static ɵfac: i0.ɵɵFactoryDeclaration<NgxfbAbstractControlDirective<any>, never>;
52
+ static ɵdir: i0.ɵɵDirectiveDeclaration<NgxfbAbstractControlDirective<any>, "[ngxfbAbstractControl]", never, { "content": { "alias": "ngxfbAbstractControl"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
53
+ }
@@ -0,0 +1,124 @@
1
+ import { ControlContainer } from '@angular/forms';
2
+ import { StateHandling } from '../types/registration.type';
3
+ import { TestIdBuilderFn } from '../types/functions.type';
4
+ import { NgxFbBaseContent } from '../types/content.type';
5
+ import * as i0 from "@angular/core";
6
+ /**
7
+ * Core directive for non-form elements that appear in forms.
8
+ *
9
+ * Block elements represent UI components that don't contribute to the form's value
10
+ * but provide information or functionality within forms, such as:
11
+ * - Information blocks
12
+ * - Images
13
+ * - Dividers
14
+ * - Help text
15
+ * - Custom UI elements
16
+ *
17
+ * This directive handles visibility conditions and test ID generation for block elements.
18
+ *
19
+ * Use this directive with hostDirectives in your custom block components:
20
+ *
21
+ * ```typescript
22
+ * @Component({
23
+ * hostDirectives: [
24
+ * {
25
+ * directive: NgxfbBlockDirective,
26
+ * inputs: ['content', 'name'],
27
+ * }
28
+ * ],
29
+ * })
30
+ * export class InfoBlockComponent {
31
+ * private readonly blockDirective = inject(NgxfbBlockDirective<InfoBlock>);
32
+ * readonly content = this.blockDirective.content;
33
+ * readonly message = computed(() => this.content().message);
34
+ * }
35
+ * ```
36
+ *
37
+ * @template T Type of the block configuration, must extend NgxFbBaseContent
38
+ */
39
+ export declare class NgxfbBlockDirective<T extends NgxFbBaseContent> {
40
+ /**
41
+ * Reference to the parent form container.
42
+ * Provides access to the form that contains this block.
43
+ */
44
+ private parentContainer;
45
+ /**
46
+ * Required input containing the block configuration.
47
+ * Defines properties like type, hidden condition, and custom properties.
48
+ */
49
+ readonly content: import("@angular/core").InputSignal<T>;
50
+ /**
51
+ * Required input for the block's name.
52
+ * Used as an identifier within the form.
53
+ */
54
+ readonly name: import("@angular/core").InputSignal<string>;
55
+ /**
56
+ * Signal for managing the visibility handling strategy ('auto' or 'manual').
57
+ * - 'auto': directive handles visibility via hidden attribute
58
+ * - 'manual': component handles visibility in its own template
59
+ */
60
+ private readonly visibilityHandling;
61
+ /**
62
+ * Signal for the test ID builder function.
63
+ * Used to customize how test IDs are generated.
64
+ */
65
+ private readonly testIdBuilder;
66
+ /**
67
+ * Computed test ID derived from the block's name.
68
+ * Used for automated testing identification.
69
+ *
70
+ * Access this in your component template:
71
+ * ```html
72
+ * <div [attr.data-testid]="testId()">...</div>
73
+ * ```
74
+ */
75
+ readonly testId: import("@angular/core").Signal<string>;
76
+ /**
77
+ * Computed signal for the hidden state.
78
+ * True when the block should be hidden based on 'hidden' expression.
79
+ *
80
+ * Use this in your component when implementing custom visibility handling:
81
+ * ```typescript
82
+ * readonly isHidden = this.blockDirective.isHidden;
83
+ * ```
84
+ */
85
+ readonly isHidden: import("@angular/core").Signal<boolean>;
86
+ /**
87
+ * Computed signal for the hidden attribute.
88
+ * Used in DOM binding to show/hide the block element.
89
+ */
90
+ readonly hiddenAttribute: import("@angular/core").Signal<true | null>;
91
+ /**
92
+ * Returns the parent form container.
93
+ * Provides access to the form instance that contains this block.
94
+ *
95
+ * Use this to access form data or methods:
96
+ * ```typescript
97
+ * const formData = this.blockDirective.rootForm.control.value;
98
+ * ```
99
+ */
100
+ get rootForm(): ControlContainer;
101
+ /**
102
+ * Sets the visibility handling strategy.
103
+ * Determines if visibility should be managed by the component (manual) or by Formbar (auto).
104
+ *
105
+ * Use 'manual' when implementing custom visibility handling in your component:
106
+ * ```typescript
107
+ * constructor() {
108
+ * this.blockDirective.setVisibilityHandling('manual');
109
+ * }
110
+ * ```
111
+ *
112
+ * @param visibilityHandling Strategy for handling visibility ('auto' or 'manual')
113
+ */
114
+ setVisibilityHandling(visibilityHandling: StateHandling): void;
115
+ /**
116
+ * Sets the function to use for building a test id.
117
+ * This allows custom test ID generation strategies to be used.
118
+ *
119
+ * @param builderFn Function that returns the test id
120
+ */
121
+ setTestIdBuilderFn(builderFn: TestIdBuilderFn | undefined): void;
122
+ static ɵfac: i0.ɵɵFactoryDeclaration<NgxfbBlockDirective<any>, never>;
123
+ static ɵdir: i0.ɵɵDirectiveDeclaration<NgxfbBlockDirective<any>, "[ngxfbBlock]", never, { "content": { "alias": "content"; "required": true; "isSignal": true; }; "name": { "alias": "name"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
124
+ }
@@ -0,0 +1,203 @@
1
+ import { OnDestroy } from '@angular/core';
2
+ import { NgxFbControl, 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 controls in ngx-formbar.
9
+ *
10
+ * This directive handles the integration between Angular's reactive forms and
11
+ * ngx-formbar's declarative configuration. It manages:
12
+ *
13
+ * - Control registration and lifecycle within parent form groups
14
+ * - State management (hidden, disabled, readonly)
15
+ * - Validation setup
16
+ * - Dynamic value computation
17
+ * - Test ID generation
18
+ * - Dynamic label support
19
+ *
20
+ * Use this directive with hostDirectives in your custom control components:
21
+ *
22
+ * ```typescript
23
+ * @Component({
24
+ * hostDirectives: [
25
+ * {
26
+ * directive: NgxfbControlDirective,
27
+ * inputs: ['content', 'name'],
28
+ * }
29
+ * ],
30
+ * })
31
+ * export class TextControlComponent {
32
+ * private readonly control = inject(NgxfbControlDirective<TextControl>);
33
+ * readonly content = this.control.content;
34
+ * readonly name = this.control.name;
35
+ * }
36
+ * ```
37
+ *
38
+ * @template T Type of the control configuration, must extend NgxFbControl
39
+ */
40
+ export declare class NgxfbControlDirective<T extends NgxFbControl> implements OnDestroy {
41
+ private parentContainer;
42
+ private readonly parentGroupDirective;
43
+ /**
44
+ * Required input containing the control configuration
45
+ * Defines properties like ID, default value, validation, and state expressions
46
+ */
47
+ readonly content: import("@angular/core").InputSignal<T>;
48
+ /**
49
+ * Required input for the controls name
50
+ */
51
+ readonly name: import("@angular/core").InputSignal<string>;
52
+ private readonly visibilityHandling;
53
+ private readonly disabledHandling;
54
+ private readonly testIdBuilder;
55
+ /**
56
+ * Computed test ID derived from the control's ID
57
+ * Used for automated testing identification
58
+ *
59
+ * Access this in your component template:
60
+ * ```html
61
+ * <input [attr.data-testid]="testId()" ... />
62
+ * ```
63
+ */
64
+ readonly testId: import("@angular/core").Signal<string>;
65
+ /**
66
+ * Computed signal for the control's hide strategy
67
+ * Determines how the control behaves when hidden (keep or remove from form)
68
+ */
69
+ readonly hideStrategy: import("@angular/core").Signal<import("@ngx-formbar/core").HideStrategy | undefined>;
70
+ /**
71
+ * Computed signal for the control's value strategy
72
+ * Determines how the control's value is managed when visibility changes
73
+ */
74
+ readonly valueStrategy: import("@angular/core").Signal<ValueStrategy | undefined>;
75
+ /**
76
+ * Computed signal for the parent's value strategy
77
+ * Used when control doesn't define its own strategy
78
+ */
79
+ readonly parentValueStrategy: import("@angular/core").Signal<ValueStrategy | undefined>;
80
+ /**
81
+ * Computed signal for the hidden state
82
+ * True when the control should be hidden based on 'hidden' expression
83
+ *
84
+ * Use this in your component when implementing custom visibility handling:
85
+ * ```typescript
86
+ * readonly isHidden = this.control.isHidden;
87
+ * ```
88
+ */
89
+ readonly isHidden: import("@angular/core").Signal<boolean>;
90
+ /**
91
+ * Computed signal for the hidden attribute
92
+ * Used in DOM binding to show/hide the control element
93
+ */
94
+ readonly hiddenAttribute: import("@angular/core").Signal<true | null>;
95
+ /**
96
+ * Computed signal for the disabled state
97
+ * True when the control should be disabled based on 'disabled' expression
98
+ *
99
+ * Use this in your component for custom disabled state handling:
100
+ * ```typescript
101
+ * readonly disabled = this.control.disabled;
102
+ * ```
103
+ */
104
+ readonly disabled: import("@angular/core").Signal<boolean>;
105
+ /**
106
+ * Computed signal for the readonly state
107
+ * True when the control should be readonly based on 'readonly' expression
108
+ *
109
+ * Use this in your component to implement readonly behavior:
110
+ * ```html
111
+ * <input [attr.readonly]="readonly() || null" ... />
112
+ * ```
113
+ */
114
+ readonly readonly: import("@angular/core").Signal<boolean>;
115
+ /**
116
+ * Computed signal for the update strategy
117
+ * Determines when form values are updated ('change', 'blur', or 'submit')
118
+ */
119
+ readonly updateStrategy: import("@angular/core").Signal<import("@ngx-formbar/core").UpdateStrategy>;
120
+ /**
121
+ * Computed signal for the dynamic label
122
+ * Contains the evaluated result of the dynamicLabel expression
123
+ *
124
+ * Use this in your component to display dynamic labels:
125
+ * ```typescript
126
+ * readonly displayLabel = computed(() => {
127
+ * const dynamic = this.control.dynamicLabel();
128
+ * return dynamic || this.content().label;
129
+ * });
130
+ * ```
131
+ */
132
+ readonly dynamicLabel: import("@angular/core").Signal<string | undefined>;
133
+ /**
134
+ * Computed signal for the validators
135
+ * Contains validator functions derived from configuration keys
136
+ */
137
+ private readonly validators;
138
+ /**
139
+ * Computed signal for the async validators
140
+ * Contains async validator functions derived from configuration keys
141
+ */
142
+ private readonly asyncValidators;
143
+ /**
144
+ * Computed signal for the computed value
145
+ * Contains the evaluated result of computedValue expressions
146
+ */
147
+ private readonly computedValue;
148
+ /**
149
+ * Computed signal for the form control instance
150
+ * Creates a new FormControl with appropriate validators and configuration
151
+ */
152
+ private readonly controlInstance;
153
+ /**
154
+ * Access to the parent FormGroup containing this control
155
+ */
156
+ get parentFormGroup(): FormGroup | null;
157
+ /**
158
+ * Access to this control's FormControl instance
159
+ * Use this to access validation state, errors, and other FormControl methods
160
+ *
161
+ * Example:
162
+ * ```typescript
163
+ * get hasError() {
164
+ * return this.control.formControl?.hasError('required');
165
+ * }
166
+ * ```
167
+ */
168
+ get formControl(): FormControl<any> | null;
169
+ constructor();
170
+ /**
171
+ * Sets the visibility handling strategy
172
+ * Determines if visibility should be managed by the component (manual) or by Formbar (auto)
173
+ *
174
+ * Use 'manual' when implementing custom visibility handling in your component:
175
+ * ```typescript
176
+ * constructor() {
177
+ * this.control.setVisibilityHandling('manual');
178
+ * }
179
+ * @param visibilityHandling Strategy for handling visibility ('auto' or 'manual')
180
+ */
181
+ setVisibilityHandling(visibilityHandling: StateHandling): void;
182
+ /**
183
+ * Sets the disabled handling strategy
184
+ * Determines if disabled state should be managed by the component (manual) or by Formbar (auto)
185
+ *
186
+ * @param disabledHandling Strategy for handling disabled state ('auto' or 'manual')
187
+ */
188
+ setDisabledHandling(disabledHandling: StateHandling): void;
189
+ /**
190
+ * Sets the function to use for building a test id.
191
+ *
192
+ * @param builderFn Function that returns the test id
193
+ */
194
+ setTestIdBuilderFn(builderFn: TestIdBuilderFn | undefined): void;
195
+ private setControl;
196
+ private removeControl;
197
+ private enableControl;
198
+ private disableControl;
199
+ private handleValue;
200
+ ngOnDestroy(): void;
201
+ static ɵfac: i0.ɵɵFactoryDeclaration<NgxfbControlDirective<any>, never>;
202
+ static ɵdir: i0.ɵɵDirectiveDeclaration<NgxfbControlDirective<any>, "[ngxfbControl]", never, { "content": { "alias": "content"; "required": true; "isSignal": true; }; "name": { "alias": "name"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
203
+ }