@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.
- package/README.md +2 -34
- package/fesm2022/ngx-formbar-core.mjs +221 -1615
- package/fesm2022/ngx-formbar-core.mjs.map +1 -1
- package/package.json +5 -12
- package/types/ngx-formbar-core.d.ts +522 -0
- package/LICENSE +0 -21
- package/index.d.ts +0 -5
- package/lib/components/form/ngxfb-form.component.d.ts +0 -28
- package/lib/composables/computed-value.d.ts +0 -8
- package/lib/composables/disabled.state.d.ts +0 -36
- package/lib/composables/dynamic-label.d.ts +0 -9
- package/lib/composables/dynamic-title.d.ts +0 -9
- package/lib/composables/hidden.state.d.ts +0 -68
- package/lib/composables/readonly.state.d.ts +0 -19
- package/lib/composables/testId.d.ts +0 -16
- package/lib/composables/update-strategy.d.ts +0 -20
- package/lib/composables/validators.d.ts +0 -22
- package/lib/config/config.d.ts +0 -7
- package/lib/config/provide-formbar.d.ts +0 -38
- package/lib/directives/ngxfb-abstract-control.directive.d.ts +0 -53
- package/lib/directives/ngxfb-block.directive.d.ts +0 -124
- package/lib/directives/ngxfb-control.directive.d.ts +0 -203
- package/lib/directives/ngxfb-group.directive.d.ts +0 -253
- package/lib/helper/control-container-view-providers.d.ts +0 -33
- package/lib/index.d.ts +0 -23
- package/lib/services/component-registration.service.d.ts +0 -8
- package/lib/services/configuration.service.d.ts +0 -8
- package/lib/services/expression.service.d.ts +0 -148
- package/lib/services/form.service.d.ts +0 -10
- package/lib/services/validator-registration.service.d.ts +0 -10
- package/lib/tokens/component-registrations.d.ts +0 -2
- package/lib/tokens/component-resolver.d.ts +0 -3
- package/lib/tokens/default-update-strategy.d.ts +0 -3
- package/lib/tokens/global-config.d.ts +0 -5
- package/lib/tokens/validator-registrations.d.ts +0 -8
- package/lib/tokens/validator-resolver.d.ts +0 -3
- package/lib/types/component-resolver.type.d.ts +0 -4
- package/lib/types/content.type.d.ts +0 -137
- package/lib/types/expression.type.d.ts +0 -2
- package/lib/types/form.type.d.ts +0 -4
- package/lib/types/functions.type.d.ts +0 -4
- package/lib/types/global-configuration.type.d.ts +0 -4
- package/lib/types/provide.type.d.ts +0 -42
- package/lib/types/registration.type.d.ts +0 -18
- package/lib/types/validation.type.d.ts +0 -59
- package/lib/types/validator-resolver.type.d.ts +0 -6
- package/public-api.d.ts +0 -1
- package/schematics/block/files/__componentName@dasherize__.component.html.template +0 -1
- package/schematics/block/files/__componentName@dasherize__.component.ts.template +0 -29
- package/schematics/block/files/__interfaceName@dasherize__.type.ts.template +0 -6
- package/schematics/block/index.d.ts +0 -3
- package/schematics/block/index.js +0 -11
- package/schematics/block/index.js.map +0 -1
- package/schematics/block/schema.json +0 -62
- package/schematics/collection.json +0 -31
- package/schematics/control/files/__componentName@dasherize__.component.html.template +0 -0
- package/schematics/control/files/__componentName@dasherize__.component.ts.template +0 -29
- package/schematics/control/files/__interfaceName@dasherize__.type.ts.template +0 -6
- package/schematics/control/index.d.ts +0 -3
- package/schematics/control/index.js +0 -11
- package/schematics/control/index.js.map +0 -1
- package/schematics/control/schema.json +0 -61
- package/schematics/group/files/__componentName@dasherize__.component.html.template +0 -5
- package/schematics/group/files/__componentName@dasherize__.component.ts.template +0 -29
- package/schematics/group/files/__interfaceName@dasherize__.type.ts.template +0 -5
- package/schematics/group/index.d.ts +0 -3
- package/schematics/group/index.js +0 -11
- package/schematics/group/index.js.map +0 -1
- package/schematics/group/schema.json +0 -62
- package/schematics/ng-add/files/config-registrations/async-validator-registrations.ts.template +0 -4
- package/schematics/ng-add/files/config-registrations/component-registrations.ts.template +0 -4
- package/schematics/ng-add/files/config-registrations/index.ts.template +0 -3
- package/schematics/ng-add/files/config-registrations/validator-registrations.ts.template +0 -4
- package/schematics/ng-add/files/helper/block.host-directive.ts.template +0 -6
- package/schematics/ng-add/files/helper/control.host-directive.ts.template +0 -6
- package/schematics/ng-add/files/helper/group.host-directive.ts.template +0 -6
- package/schematics/ng-add/files/helper/index.ts.template +0 -4
- package/schematics/ng-add/files/helper/view-provider.ts.template +0 -9
- package/schematics/ng-add/files/provider-config/config/__providerConfigFileName__.ts.template +0 -9
- package/schematics/ng-add/files/provider-config/inline/__providerConfigFileName__.ts.template +0 -8
- package/schematics/ng-add/files/provider-config/token/__providerConfigFileName__.ts.template +0 -4
- package/schematics/ng-add/files/schematics-config/__schematicConfigFileName__.json.template +0 -1
- package/schematics/ng-add/files/token-registrations/async-validator-registrations.ts.template +0 -8
- package/schematics/ng-add/files/token-registrations/component-registrations.ts.template +0 -8
- package/schematics/ng-add/files/token-registrations/index.ts.template +0 -3
- package/schematics/ng-add/files/token-registrations/validator-registrations.ts.template +0 -8
- package/schematics/ng-add/helper.d.ts +0 -11
- package/schematics/ng-add/helper.js +0 -198
- package/schematics/ng-add/helper.js.map +0 -1
- package/schematics/ng-add/index.d.ts +0 -3
- package/schematics/ng-add/index.js +0 -68
- package/schematics/ng-add/index.js.map +0 -1
- package/schematics/ng-add/rules/create-config-registration-files.rule.d.ts +0 -3
- package/schematics/ng-add/rules/create-config-registration-files.rule.js +0 -32
- package/schematics/ng-add/rules/create-config-registration-files.rule.js.map +0 -1
- package/schematics/ng-add/rules/create-formbar-registration-config.rule.d.ts +0 -3
- package/schematics/ng-add/rules/create-formbar-registration-config.rule.js +0 -30
- package/schematics/ng-add/rules/create-formbar-registration-config.rule.js.map +0 -1
- package/schematics/ng-add/rules/create-helper-files.rule.d.ts +0 -6
- package/schematics/ng-add/rules/create-helper-files.rule.js +0 -22
- package/schematics/ng-add/rules/create-helper-files.rule.js.map +0 -1
- package/schematics/ng-add/rules/create-schematics-config.rule.d.ts +0 -3
- package/schematics/ng-add/rules/create-schematics-config.rule.js +0 -42
- package/schematics/ng-add/rules/create-schematics-config.rule.js.map +0 -1
- package/schematics/ng-add/rules/create-token-registration-files.rule.d.ts +0 -3
- package/schematics/ng-add/rules/create-token-registration-files.rule.js +0 -32
- package/schematics/ng-add/rules/create-token-registration-files.rule.js.map +0 -1
- package/schematics/ng-add/rules/include-templates.rule.d.ts +0 -3
- package/schematics/ng-add/rules/include-templates.rule.js +0 -11
- package/schematics/ng-add/rules/include-templates.rule.js.map +0 -1
- package/schematics/ng-add/rules/install-dependencies.rule.d.ts +0 -2
- package/schematics/ng-add/rules/install-dependencies.rule.js +0 -12
- package/schematics/ng-add/rules/install-dependencies.rule.js.map +0 -1
- package/schematics/ng-add/rules/update-app-config.rule.d.ts +0 -3
- package/schematics/ng-add/rules/update-app-config.rule.js +0 -49
- package/schematics/ng-add/rules/update-app-config.rule.js.map +0 -1
- package/schematics/ng-add/rules/update-schematics-config.rule.d.ts +0 -6
- package/schematics/ng-add/rules/update-schematics-config.rule.js +0 -28
- package/schematics/ng-add/rules/update-schematics-config.rule.js.map +0 -1
- package/schematics/ng-add/schema.d.ts +0 -23
- package/schematics/ng-add/schema.js +0 -3
- package/schematics/ng-add/schema.js.map +0 -1
- package/schematics/ng-add/schema.json +0 -81
- package/schematics/register/component-info.type.d.ts +0 -11
- package/schematics/register/component-info.type.js +0 -3
- package/schematics/register/component-info.type.js.map +0 -1
- package/schematics/register/discover-components.d.ts +0 -19
- package/schematics/register/discover-components.js +0 -267
- package/schematics/register/discover-components.js.map +0 -1
- package/schematics/register/index.d.ts +0 -3
- package/schematics/register/index.js +0 -49
- package/schematics/register/index.js.map +0 -1
- package/schematics/register/register-components.d.ts +0 -3
- package/schematics/register/register-components.js +0 -38
- package/schematics/register/register-components.js.map +0 -1
- package/schematics/register/schema.d.ts +0 -14
- package/schematics/register/schema.js +0 -3
- package/schematics/register/schema.js.map +0 -1
- package/schematics/register/schema.json +0 -44
- package/schematics/shared/ast/decorators.d.ts +0 -9
- package/schematics/shared/ast/decorators.js +0 -182
- package/schematics/shared/ast/decorators.js.map +0 -1
- package/schematics/shared/ast/imports.d.ts +0 -3
- package/schematics/shared/ast/imports.js +0 -93
- package/schematics/shared/ast/imports.js.map +0 -1
- package/schematics/shared/ast/parse.d.ts +0 -3
- package/schematics/shared/ast/parse.js +0 -17
- package/schematics/shared/ast/parse.js.map +0 -1
- package/schematics/shared/ast/registrations.d.ts +0 -22
- package/schematics/shared/ast/registrations.js +0 -654
- package/schematics/shared/ast/registrations.js.map +0 -1
- package/schematics/shared/ast/types.d.ts +0 -3
- package/schematics/shared/ast/types.js +0 -58
- package/schematics/shared/ast/types.js.map +0 -1
- package/schematics/shared/file.d.ts +0 -4
- package/schematics/shared/file.js +0 -60
- package/schematics/shared/file.js.map +0 -1
- package/schematics/shared/helper.d.ts +0 -2
- package/schematics/shared/helper.js +0 -29
- package/schematics/shared/helper.js.map +0 -1
- package/schematics/shared/rules/create-component.rule.d.ts +0 -3
- package/schematics/shared/rules/create-component.rule.js +0 -15
- package/schematics/shared/rules/create-component.rule.js.map +0 -1
- package/schematics/shared/rules/register-control.rule.d.ts +0 -3
- package/schematics/shared/rules/register-control.rule.js +0 -30
- package/schematics/shared/rules/register-control.rule.js.map +0 -1
- package/schematics/shared/rules/register-type-map.rule.d.ts +0 -3
- package/schematics/shared/rules/register-type-map.rule.js +0 -46
- package/schematics/shared/rules/register-type-map.rule.js.map +0 -1
- package/schematics/shared/rules/register-type-token.rule.d.ts +0 -3
- package/schematics/shared/rules/register-type-token.rule.js +0 -49
- package/schematics/shared/rules/register-type-token.rule.js.map +0 -1
- package/schematics/shared/rules/scaffold-and-register.rule.d.ts +0 -3
- package/schematics/shared/rules/scaffold-and-register.rule.js +0 -134
- package/schematics/shared/rules/scaffold-and-register.rule.js.map +0 -1
- package/schematics/shared/schema.d.ts +0 -32
- package/schematics/shared/schema.js +0 -3
- package/schematics/shared/schema.js.map +0 -1
- package/schematics/tests/generators.spec.d.ts +0 -1
- package/schematics/tests/generators.spec.js +0 -450
- package/schematics/tests/generators.spec.js.map +0 -1
- package/schematics/tests/helper.d.ts +0 -20
- package/schematics/tests/helper.js +0 -275
- package/schematics/tests/helper.js.map +0 -1
- package/schematics/tests/ng-add.spec.d.ts +0 -1
- package/schematics/tests/ng-add.spec.js +0 -380
- package/schematics/tests/ng-add.spec.js.map +0 -1
- package/schematics/tests/register.spec.d.ts +0 -1
- package/schematics/tests/register.spec.js +0 -340
- package/schematics/tests/register.spec.js.map +0 -1
- package/schematics/tests/workspace-setup.d.ts +0 -21
- package/schematics/tests/workspace-setup.js +0 -256
- package/schematics/tests/workspace-setup.js.map +0 -1
- package/shared/ast.d.ts +0 -10
- package/shared/ast.js +0 -93
- package/shared/ast.js.map +0 -1
- package/shared/constants.d.ts +0 -16
- package/shared/constants.js +0 -20
- package/shared/constants.js.map +0 -1
- package/shared/shared-config.type.d.ts +0 -20
- package/shared/shared-config.type.js +0 -3
- package/shared/shared-config.type.js.map +0 -1
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { Signal } from '@angular/core';
|
|
2
|
-
import { HideStrategy, NgxFbBaseContent, NgxFbContent, ValueStrategy } from '../types/content.type';
|
|
3
|
-
import { StateHandling } from '../types/registration.type';
|
|
4
|
-
import { SimpleFunction, ValueHandleFunction } from '../types/functions.type';
|
|
5
|
-
import { AbstractControl } from '@angular/forms';
|
|
6
|
-
/**
|
|
7
|
-
* Computes a reactive hidden state based on control content
|
|
8
|
-
*
|
|
9
|
-
* The hidden state is determined using the following priority:
|
|
10
|
-
* 1. If content.hidden is an expression string, it's parsed to AST and evaluated
|
|
11
|
-
* against the current form values
|
|
12
|
-
* 2. If no hidden expression is defined, the control inherits the hidden state
|
|
13
|
-
* from its parent group
|
|
14
|
-
* 3. Both conditions can be combined - a control is hidden if either its own
|
|
15
|
-
* condition evaluates to true OR its parent group is hidden
|
|
16
|
-
*
|
|
17
|
-
* @param content Signal containing control configuration with potential hidden expression
|
|
18
|
-
* @returns Computed signal that resolves to boolean hidden state
|
|
19
|
-
*/
|
|
20
|
-
export declare function withHiddenState(content: Signal<NgxFbBaseContent>): Signal<boolean>;
|
|
21
|
-
/**
|
|
22
|
-
* Creates a computed attribute value for hidden DOM elements
|
|
23
|
-
*
|
|
24
|
-
* When visibilityHandling is set to 'auto', this returns a boolean attribute value
|
|
25
|
-
* that can be used with Angular's [attr.hidden] binding. When set to 'manual',
|
|
26
|
-
* it returns null so the attribute is not applied.
|
|
27
|
-
*
|
|
28
|
-
* @param options Configuration object for hidden attribute
|
|
29
|
-
* @param options.hiddenSignal Signal that indicates if the control should be hidden
|
|
30
|
-
* @param options.hiddenHandlingSignal Signal that determines how visibility is managed
|
|
31
|
-
* @returns Computed signal that resolves to attribute value (true or null)
|
|
32
|
-
*/
|
|
33
|
-
export declare function withHiddenAttribute(options: {
|
|
34
|
-
hiddenSignal: Signal<boolean>;
|
|
35
|
-
hiddenHandlingSignal: Signal<StateHandling>;
|
|
36
|
-
}): Signal<true | null>;
|
|
37
|
-
/**
|
|
38
|
-
* Creates an effect that manages control visibility in forms
|
|
39
|
-
*
|
|
40
|
-
* Based on visibility state and hide strategy, this effect:
|
|
41
|
-
* 1. Attaches the control to the form when visible
|
|
42
|
-
* 2. Detaches the control from the form when hidden and strategy is 'remove'
|
|
43
|
-
* 3. Manages control values based on the specified valueStrategy when visibility changes
|
|
44
|
-
*
|
|
45
|
-
* @param options Configuration object for hidden effect
|
|
46
|
-
* @param options.content Signal containing control configuration
|
|
47
|
-
* @param options.name Signal containing the name of the control
|
|
48
|
-
* @param options.controlInstance Signal with the form control instance
|
|
49
|
-
* @param options.hiddenSignal Signal that indicates if the control should be hidden
|
|
50
|
-
* @param options.hideStrategySignal Signal with the strategy for handling hidden controls
|
|
51
|
-
* @param options.valueStrategySignal Signal with the strategy for handling control values
|
|
52
|
-
* @param options.parentValueStrategySignal Signal with the parent's value strategy
|
|
53
|
-
* @param options.attachFunction Function to call when control should be attached
|
|
54
|
-
* @param options.detachFunction Function to call when control should be detached
|
|
55
|
-
* @param options.valueHandleFunction Function to handle control value based on strategy
|
|
56
|
-
*/
|
|
57
|
-
export declare function hiddenEffect(options: {
|
|
58
|
-
content: Signal<NgxFbContent>;
|
|
59
|
-
name: Signal<string>;
|
|
60
|
-
controlInstance: Signal<AbstractControl>;
|
|
61
|
-
hiddenSignal: Signal<boolean>;
|
|
62
|
-
hideStrategySignal: Signal<HideStrategy | undefined>;
|
|
63
|
-
valueStrategySignal: Signal<ValueStrategy | undefined>;
|
|
64
|
-
parentValueStrategySignal: Signal<ValueStrategy | undefined>;
|
|
65
|
-
attachFunction: SimpleFunction;
|
|
66
|
-
detachFunction: SimpleFunction;
|
|
67
|
-
valueHandleFunction: ValueHandleFunction;
|
|
68
|
-
}): void;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Signal } from '@angular/core';
|
|
2
|
-
import { NgxFbAbstractControl } from '../types/content.type';
|
|
3
|
-
/**
|
|
4
|
-
* Computes a reactive readonly state based on control content
|
|
5
|
-
*
|
|
6
|
-
* The readonly state is determined using the following priority:
|
|
7
|
-
* 1. If content.readonly is a boolean, that value is used directly
|
|
8
|
-
* 2. If content.readonly is an expression string, it's parsed to AST and evaluated
|
|
9
|
-
* against the current form values
|
|
10
|
-
* 3. If no readonly property is defined, the control inherits the readonly state
|
|
11
|
-
* from its parent group
|
|
12
|
-
*
|
|
13
|
-
* This hierarchical inheritance ensures that child controls are automatically
|
|
14
|
-
* set to readonly when their parent group is readonly, unless explicitly overridden.
|
|
15
|
-
*
|
|
16
|
-
* @param content Signal containing control configuration with potential readonly property
|
|
17
|
-
* @returns Computed signal that resolves to boolean readonly state
|
|
18
|
-
*/
|
|
19
|
-
export declare function withReadonlyState(content: Signal<NgxFbAbstractControl>): Signal<boolean>;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Signal } from '@angular/core';
|
|
2
|
-
import { TestIdBuilderFn } from '../types/functions.type';
|
|
3
|
-
import { NgxFbBaseContent } from '../types/content.type';
|
|
4
|
-
/**
|
|
5
|
-
* Creates a computed signal that extracts the ID for testing purposes
|
|
6
|
-
*
|
|
7
|
-
* This utility function derives a test identifier from a form control's content,
|
|
8
|
-
* which can be used for targeting elements in automated tests.
|
|
9
|
-
*
|
|
10
|
-
* @template T - Type extending NgxFbBaseContent
|
|
11
|
-
* @param content - Signal containing the control or group content configuration
|
|
12
|
-
* @param name - Signal containing the name of the control
|
|
13
|
-
* @param testIdBuilder - Signal holding a testIdBuilder function
|
|
14
|
-
* @returns Computed signal that resolves to the element's ID for testing
|
|
15
|
-
*/
|
|
16
|
-
export declare function withTestId(content: Signal<NgxFbBaseContent>, name: Signal<string>, testIdBuilder: Signal<TestIdBuilderFn | undefined>): Signal<string>;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Signal } from '@angular/core';
|
|
2
|
-
import { NgxFbAbstractControl, UpdateStrategy } from '../types/content.type';
|
|
3
|
-
/**
|
|
4
|
-
* Creates a computed signal for the control's update strategy
|
|
5
|
-
*
|
|
6
|
-
* This function determines when form controls should update:
|
|
7
|
-
* - Uses the control's specified updateOn strategy if defined
|
|
8
|
-
* - Falls back to parent group's strategy when not defined in the control
|
|
9
|
-
* - Handles inheritance of update strategies through the form hierarchy
|
|
10
|
-
* - Uses the application's default strategy as final fallback
|
|
11
|
-
*
|
|
12
|
-
* Update strategies control when form values and validation happen:
|
|
13
|
-
* - 'change': Update on every change event (default Angular behavior)
|
|
14
|
-
* - 'blur': Update when the control loses focus
|
|
15
|
-
* - 'submit': Update only when the form is submitted
|
|
16
|
-
*
|
|
17
|
-
* @param content Signal containing the NgxFbAbstractControl with possible updateOn configuration
|
|
18
|
-
* @returns Computed signal providing the resolved update strategy
|
|
19
|
-
*/
|
|
20
|
-
export declare function withUpdateStrategy(content: Signal<NgxFbAbstractControl>): Signal<UpdateStrategy>;
|
|
@@ -1,22 +0,0 @@
|
|
|
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[]>;
|
package/lib/config/config.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
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>;
|
|
@@ -1,38 +0,0 @@
|
|
|
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;
|
|
@@ -1,53 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,124 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,203 +0,0 @@
|
|
|
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
|
-
}
|