@ng-forge/dynamic-forms 0.6.1 → 0.7.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/fesm2022/ng-forge-dynamic-forms-integration.mjs +4 -4
- package/fesm2022/ng-forge-dynamic-forms-integration.mjs.map +1 -1
- package/fesm2022/{ng-forge-dynamic-forms-ng-forge-dynamic-forms-DXXp5M0q.mjs → ng-forge-dynamic-forms-ng-forge-dynamic-forms-Sad9wa1d.mjs} +423 -499
- package/fesm2022/ng-forge-dynamic-forms-ng-forge-dynamic-forms-Sad9wa1d.mjs.map +1 -0
- package/fesm2022/{ng-forge-dynamic-forms-page-field.component-D6M_uJKu.mjs → ng-forge-dynamic-forms-page-field.component-Cen4ArED.mjs} +23 -18
- package/fesm2022/ng-forge-dynamic-forms-page-field.component-Cen4ArED.mjs.map +1 -0
- package/fesm2022/{ng-forge-dynamic-forms-text-field.component-Ael-STTb.mjs → ng-forge-dynamic-forms-text-field.component-cE1EUmYR.mjs} +18 -12
- package/fesm2022/ng-forge-dynamic-forms-text-field.component-cE1EUmYR.mjs.map +1 -0
- package/fesm2022/ng-forge-dynamic-forms.mjs +1 -1
- package/package.json +1 -1
- package/types/ng-forge-dynamic-forms.d.ts +54 -333
- package/fesm2022/ng-forge-dynamic-forms-ng-forge-dynamic-forms-DXXp5M0q.mjs.map +0 -1
- package/fesm2022/ng-forge-dynamic-forms-page-field.component-D6M_uJKu.mjs.map +0 -1
- package/fesm2022/ng-forge-dynamic-forms-text-field.component-Ael-STTb.mjs.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as rxjs from 'rxjs';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
3
|
import * as _angular_core from '@angular/core';
|
|
4
|
-
import { Signal, Injector, WritableSignal, InjectionToken, Type, ResourceRef, Provider, EnvironmentProviders, PipeTransform } from '@angular/core';
|
|
4
|
+
import { Signal, Injector, WritableSignal, InjectionToken, Type, ResourceRef, EnvironmentInjector, Provider, EnvironmentProviders, Resource, PipeTransform } from '@angular/core';
|
|
5
5
|
import * as _angular_forms_signals from '@angular/forms/signals';
|
|
6
6
|
import { FieldTree, FieldContext, TreeValidationResult, ValidationError as ValidationError$1, SchemaPath, SchemaPathTree } from '@angular/forms/signals';
|
|
7
7
|
import * as _angular_forms from '@angular/forms';
|
|
@@ -379,6 +379,14 @@ type MapperFn<T extends FieldDef<unknown>> = (input: T) => Signal<Record<string,
|
|
|
379
379
|
* - 'flatten': Field's children are flattened to parent level (for container fields)
|
|
380
380
|
*/
|
|
381
381
|
type ValueHandlingMode = 'include' | 'exclude' | 'flatten';
|
|
382
|
+
/**
|
|
383
|
+
* Semantic grouping of interchangeable field UI alternatives.
|
|
384
|
+
*
|
|
385
|
+
* Used by tooling (e.g., openapi-generator) to discover which field types
|
|
386
|
+
* can substitute for each other. A field with scope 'boolean' means it's
|
|
387
|
+
* one of several ways to render a boolean value (checkbox, toggle, etc.).
|
|
388
|
+
*/
|
|
389
|
+
type FieldScope = 'boolean' | 'single-select' | 'multi-select' | 'text-input' | 'numeric' | 'date';
|
|
382
390
|
/**
|
|
383
391
|
* Configuration interface for registering custom field types.
|
|
384
392
|
*
|
|
@@ -444,6 +452,8 @@ interface FieldTypeDefinition<T extends FieldDef<any> = any> {
|
|
|
444
452
|
* ```
|
|
445
453
|
*/
|
|
446
454
|
propsToMeta?: string[];
|
|
455
|
+
/** Semantic scope for tooling to discover interchangeable field alternatives */
|
|
456
|
+
scope?: FieldScope | FieldScope[];
|
|
447
457
|
}
|
|
448
458
|
/**
|
|
449
459
|
* Injection token for the global field type registry.
|
|
@@ -533,56 +543,17 @@ interface FieldValueCondition {
|
|
|
533
543
|
value?: unknown;
|
|
534
544
|
}
|
|
535
545
|
/**
|
|
536
|
-
* Condition that
|
|
537
|
-
*
|
|
538
|
-
* @deprecated Use `FieldValueCondition` for specific field checks, or
|
|
539
|
-
* `JavascriptCondition` with an expression for complex form-level comparisons.
|
|
540
|
-
* Will be removed in a future minor version.
|
|
541
|
-
*
|
|
542
|
-
* @public
|
|
543
|
-
*/
|
|
544
|
-
interface FormValueCondition {
|
|
545
|
-
type: 'formValue';
|
|
546
|
-
/** Comparison operator */
|
|
547
|
-
operator: ComparisonOperator;
|
|
548
|
-
/** Value to compare against */
|
|
549
|
-
value?: unknown;
|
|
550
|
-
}
|
|
551
|
-
/**
|
|
552
|
-
* Condition that invokes a registered custom function by name (new API).
|
|
546
|
+
* Condition that invokes a registered custom function by name.
|
|
553
547
|
*
|
|
554
548
|
* Register functions via `customFnConfig.customFunctions`.
|
|
555
549
|
*
|
|
556
|
-
* @
|
|
550
|
+
* @public
|
|
557
551
|
*/
|
|
558
|
-
interface
|
|
552
|
+
interface CustomCondition {
|
|
559
553
|
type: 'custom';
|
|
560
554
|
/** Name of the registered custom function to invoke */
|
|
561
555
|
functionName: string;
|
|
562
556
|
}
|
|
563
|
-
/**
|
|
564
|
-
* @deprecated Use `CustomCondition` with `functionName` instead.
|
|
565
|
-
* The `expression` field was misnamed — it holds a function registry key, not a JS expression.
|
|
566
|
-
* Will be removed in a future minor version.
|
|
567
|
-
*
|
|
568
|
-
* @internal
|
|
569
|
-
*/
|
|
570
|
-
interface CustomConditionDeprecated {
|
|
571
|
-
type: 'custom';
|
|
572
|
-
/**
|
|
573
|
-
* @deprecated Use `functionName` instead. Will be removed in a future minor version.
|
|
574
|
-
*/
|
|
575
|
-
expression: string;
|
|
576
|
-
}
|
|
577
|
-
/**
|
|
578
|
-
* Condition that invokes a registered custom function by name.
|
|
579
|
-
*
|
|
580
|
-
* Use `functionName` (new API). The `expression` field is deprecated.
|
|
581
|
-
* Register functions via `customFnConfig.customFunctions`.
|
|
582
|
-
*
|
|
583
|
-
* @public
|
|
584
|
-
*/
|
|
585
|
-
type CustomCondition = CustomConditionNew | CustomConditionDeprecated;
|
|
586
557
|
/**
|
|
587
558
|
* Condition that evaluates a JavaScript expression using the secure AST-based parser.
|
|
588
559
|
*
|
|
@@ -697,7 +668,7 @@ interface OrCondition {
|
|
|
697
668
|
*
|
|
698
669
|
* @public
|
|
699
670
|
*/
|
|
700
|
-
type ConditionalExpression = FieldValueCondition |
|
|
671
|
+
type ConditionalExpression = FieldValueCondition | CustomCondition | JavascriptCondition | HttpCondition | AsyncCondition | AndCondition | OrCondition;
|
|
701
672
|
|
|
702
673
|
/**
|
|
703
674
|
* Logic configuration for container fields (page, group, row, array).
|
|
@@ -1772,161 +1743,15 @@ type DebouncedFunctionDerivationLogicConfig = FunctionDerivationBase & Debounced
|
|
|
1772
1743
|
* @public
|
|
1773
1744
|
*/
|
|
1774
1745
|
type DerivationLogicConfig = OnChangeHttpDerivationLogicConfig | DebouncedHttpDerivationLogicConfig | OnChangeAsyncFunctionDerivationLogicConfig | DebouncedAsyncFunctionDerivationLogicConfig | OnChangeExpressionDerivationLogicConfig | DebouncedExpressionDerivationLogicConfig | OnChangeValueDerivationLogicConfig | DebouncedValueDerivationLogicConfig | OnChangeFunctionDerivationLogicConfig | DebouncedFunctionDerivationLogicConfig;
|
|
1775
|
-
/**
|
|
1776
|
-
* Base configuration for property derivation logic.
|
|
1777
|
-
*
|
|
1778
|
-
* Property derivations compute values for field properties (like `minDate`, `options`,
|
|
1779
|
-
* `label`, `placeholder`) based on form values and external data. Unlike value derivations
|
|
1780
|
-
* which set the field's value, property derivations update component input properties.
|
|
1781
|
-
*
|
|
1782
|
-
* All property derivations are self-targeting: the logic is placed on the field whose
|
|
1783
|
-
* property should be derived.
|
|
1784
|
-
*
|
|
1785
|
-
* @internal
|
|
1786
|
-
*/
|
|
1787
|
-
interface BasePropertyDerivationLogicConfig {
|
|
1788
|
-
/**
|
|
1789
|
-
* Logic type identifier for property derivation.
|
|
1790
|
-
*/
|
|
1791
|
-
type: 'propertyDerivation';
|
|
1792
|
-
/**
|
|
1793
|
-
* The target property to set on the field component.
|
|
1794
|
-
*
|
|
1795
|
-
* **Depth limit (max 2 levels):** Only simple and single-dot-nested paths are
|
|
1796
|
-
* supported. Paths with 2+ dots (e.g., `'a.b.c'`) will throw a `DynamicFormError`
|
|
1797
|
-
* at runtime. This is an architectural constraint of the override merging strategy.
|
|
1798
|
-
*
|
|
1799
|
-
* Supported formats:
|
|
1800
|
-
* - Simple: `'minDate'`, `'options'`, `'label'`, `'placeholder'`
|
|
1801
|
-
* - Nested (1 dot): `'props.appearance'`, `'meta.autocomplete'`
|
|
1802
|
-
*
|
|
1803
|
-
* **Note:** There is no compile-time validation that the property name matches
|
|
1804
|
-
* an actual input on the field component. Typos will silently write to the
|
|
1805
|
-
* override store with no visible effect. A dev-mode warning is emitted when
|
|
1806
|
-
* the override key doesn't match any existing input property.
|
|
1807
|
-
*
|
|
1808
|
-
* @example
|
|
1809
|
-
* ```typescript
|
|
1810
|
-
* targetProperty: 'minDate' // ✅ Simple property
|
|
1811
|
-
* targetProperty: 'options' // ✅ Simple property
|
|
1812
|
-
* targetProperty: 'props.appearance' // ✅ Single-nested property
|
|
1813
|
-
* targetProperty: 'a.b.c' // ❌ Throws DynamicFormError (too deep)
|
|
1814
|
-
* ```
|
|
1815
|
-
*/
|
|
1816
|
-
targetProperty: string;
|
|
1817
|
-
/**
|
|
1818
|
-
* Optional name for this derivation for debugging purposes.
|
|
1819
|
-
*
|
|
1820
|
-
* When provided, this name appears in property derivation debug logs.
|
|
1821
|
-
*/
|
|
1822
|
-
debugName?: string;
|
|
1823
|
-
/**
|
|
1824
|
-
* Condition that determines when this property derivation applies.
|
|
1825
|
-
*
|
|
1826
|
-
* Defaults to `true` (always apply).
|
|
1827
|
-
*
|
|
1828
|
-
* Note: FormStateCondition is not supported for property derivations.
|
|
1829
|
-
*/
|
|
1830
|
-
condition?: ConditionalExpression | boolean;
|
|
1831
|
-
/**
|
|
1832
|
-
* Static value to set on the target property.
|
|
1833
|
-
*
|
|
1834
|
-
* Mutually exclusive with `expression` and `functionName`.
|
|
1835
|
-
*/
|
|
1836
|
-
value?: unknown;
|
|
1837
|
-
/**
|
|
1838
|
-
* JavaScript expression to evaluate for the derived property value.
|
|
1839
|
-
*
|
|
1840
|
-
* Has access to `formValue` object containing all form values.
|
|
1841
|
-
* For array fields, `formValue` is scoped to the current array item.
|
|
1842
|
-
*
|
|
1843
|
-
* Mutually exclusive with `value` and `functionName`.
|
|
1844
|
-
*
|
|
1845
|
-
* @example
|
|
1846
|
-
* ```typescript
|
|
1847
|
-
* expression: 'formValue.startDate'
|
|
1848
|
-
* expression: 'formValue.quantity > 10 ? "bulk" : "standard"'
|
|
1849
|
-
* ```
|
|
1850
|
-
*/
|
|
1851
|
-
expression?: string;
|
|
1852
|
-
/**
|
|
1853
|
-
* Name of a registered custom property derivation function.
|
|
1854
|
-
*
|
|
1855
|
-
* Register functions in `customFnConfig.propertyDerivations`.
|
|
1856
|
-
* Mutually exclusive with `value` and `expression`.
|
|
1857
|
-
*/
|
|
1858
|
-
functionName?: string;
|
|
1859
|
-
/**
|
|
1860
|
-
* Explicit field dependencies for property derivations.
|
|
1861
|
-
*
|
|
1862
|
-
* When using `functionName`, you can optionally specify which fields
|
|
1863
|
-
* the function depends on. If not provided with `functionName`, defaults
|
|
1864
|
-
* to all fields ('*').
|
|
1865
|
-
* For `expression`, dependencies are automatically extracted.
|
|
1866
|
-
* For `value`, no dependencies are needed (static value).
|
|
1867
|
-
*/
|
|
1868
|
-
dependsOn?: string[];
|
|
1869
|
-
}
|
|
1870
|
-
/**
|
|
1871
|
-
* Property derivation that evaluates immediately on change (default).
|
|
1872
|
-
*
|
|
1873
|
-
* @internal
|
|
1874
|
-
*/
|
|
1875
|
-
interface OnChangePropertyDerivationLogicConfig extends BasePropertyDerivationLogicConfig {
|
|
1876
|
-
/**
|
|
1877
|
-
* Trigger for immediate evaluation.
|
|
1878
|
-
* @default 'onChange'
|
|
1879
|
-
*/
|
|
1880
|
-
trigger?: 'onChange';
|
|
1881
|
-
/** Not allowed for onChange trigger */
|
|
1882
|
-
debounceMs?: never;
|
|
1883
|
-
}
|
|
1884
|
-
/**
|
|
1885
|
-
* Property derivation that evaluates after a debounce period.
|
|
1886
|
-
*
|
|
1887
|
-
* @internal
|
|
1888
|
-
*/
|
|
1889
|
-
interface DebouncedPropertyDerivationLogicConfig extends BasePropertyDerivationLogicConfig {
|
|
1890
|
-
/**
|
|
1891
|
-
* Trigger for debounced evaluation.
|
|
1892
|
-
*/
|
|
1893
|
-
trigger: 'debounced';
|
|
1894
|
-
/**
|
|
1895
|
-
* Debounce duration in milliseconds.
|
|
1896
|
-
* @default 500
|
|
1897
|
-
*/
|
|
1898
|
-
debounceMs?: number;
|
|
1899
|
-
}
|
|
1900
|
-
/**
|
|
1901
|
-
* Configuration for property derivation logic.
|
|
1902
|
-
*
|
|
1903
|
-
* @deprecated Use `DerivationLogicConfig` with `targetProperty` instead.
|
|
1904
|
-
* The unified `type: 'derivation'` with `targetProperty` provides the same
|
|
1905
|
-
* functionality with a simpler API surface.
|
|
1906
|
-
*
|
|
1907
|
-
* ```typescript
|
|
1908
|
-
* // Before (deprecated)
|
|
1909
|
-
* { type: 'propertyDerivation', targetProperty: 'minDate', expression: '...' }
|
|
1910
|
-
*
|
|
1911
|
-
* // After (preferred)
|
|
1912
|
-
* { type: 'derivation', targetProperty: 'minDate', expression: '...' }
|
|
1913
|
-
* ```
|
|
1914
|
-
*
|
|
1915
|
-
* Will be removed in a future minor version.
|
|
1916
|
-
*
|
|
1917
|
-
* @public
|
|
1918
|
-
*/
|
|
1919
|
-
type PropertyDerivationLogicConfig = OnChangePropertyDerivationLogicConfig | DebouncedPropertyDerivationLogicConfig;
|
|
1920
1746
|
/**
|
|
1921
1747
|
* Union type for all logic configurations.
|
|
1922
1748
|
*
|
|
1923
1749
|
* - `StateLogicConfig`: For field state changes (hidden, readonly, disabled, required)
|
|
1924
|
-
* - `DerivationLogicConfig`: For value derivation
|
|
1925
|
-
* - `PropertyDerivationLogicConfig`: For property derivation
|
|
1750
|
+
* - `DerivationLogicConfig`: For value derivation (including property derivation via `targetProperty`)
|
|
1926
1751
|
*
|
|
1927
1752
|
* @public
|
|
1928
1753
|
*/
|
|
1929
|
-
type LogicConfig = StateLogicConfig | DerivationLogicConfig
|
|
1754
|
+
type LogicConfig = StateLogicConfig | DerivationLogicConfig;
|
|
1930
1755
|
/**
|
|
1931
1756
|
* Log level for derivation debug output.
|
|
1932
1757
|
*
|
|
@@ -1946,18 +1771,6 @@ type DerivationLogLevel = 'none' | 'summary' | 'verbose';
|
|
|
1946
1771
|
* @public
|
|
1947
1772
|
*/
|
|
1948
1773
|
declare function isFormStateCondition(condition: StateLogicConfig['condition'] | DerivationLogicConfig['condition']): condition is FormStateCondition;
|
|
1949
|
-
/**
|
|
1950
|
-
* Type guard to check if a logic config is a PropertyDerivationLogicConfig.
|
|
1951
|
-
*
|
|
1952
|
-
* @deprecated Use `isDerivationLogicConfig(config) && hasTargetProperty(config)` instead.
|
|
1953
|
-
* Will be removed in a future minor version.
|
|
1954
|
-
*
|
|
1955
|
-
* @param config - The logic config to check
|
|
1956
|
-
* @returns true if the config is for property derivation
|
|
1957
|
-
*
|
|
1958
|
-
* @public
|
|
1959
|
-
*/
|
|
1960
|
-
declare function isPropertyDerivationLogicConfig(config: LogicConfig): config is PropertyDerivationLogicConfig;
|
|
1961
1774
|
|
|
1962
1775
|
/**
|
|
1963
1776
|
* Interface for dynamic forms logger implementations.
|
|
@@ -2544,16 +2357,10 @@ interface CustomValidatorConfig extends BaseValidatorConfig {
|
|
|
2544
2357
|
* Async custom validator configuration using Angular's validateAsync API.
|
|
2545
2358
|
* Returns Observable<ValidationError | ValidationError[] | null>.
|
|
2546
2359
|
*
|
|
2547
|
-
* Accepts both `'async'` (preferred) and `'customAsync'` (deprecated) type literals.
|
|
2548
2360
|
*/
|
|
2549
2361
|
interface AsyncValidatorConfig extends BaseValidatorConfig {
|
|
2550
|
-
/**
|
|
2551
|
-
|
|
2552
|
-
*
|
|
2553
|
-
* Use `'async'` for new code. `'customAsync'` is accepted for backward compatibility
|
|
2554
|
-
* but emits a deprecation warning in dev mode.
|
|
2555
|
-
*/
|
|
2556
|
-
type: 'async' | 'customAsync';
|
|
2362
|
+
/** Validator type identifier. */
|
|
2363
|
+
type: 'async';
|
|
2557
2364
|
/** Name of registered async validator function */
|
|
2558
2365
|
functionName: string;
|
|
2559
2366
|
/** Optional parameters to pass to validator function */
|
|
@@ -2567,28 +2374,15 @@ interface AsyncValidatorConfig extends BaseValidatorConfig {
|
|
|
2567
2374
|
*
|
|
2568
2375
|
* Discriminated from `DeclarativeHttpValidatorConfig` by the presence of `functionName`.
|
|
2569
2376
|
*
|
|
2570
|
-
* Accepts both `'http'` (preferred) and `'customHttp'` (deprecated) type literals.
|
|
2571
|
-
*
|
|
2572
|
-
* @deprecated Prefer `DeclarativeHttpValidatorConfig` (`type: 'http'` with `http` + `responseMapping`)
|
|
2573
|
-
* for fully JSON-serializable validation. Use this form only when function registration is required.
|
|
2574
2377
|
*/
|
|
2575
2378
|
interface FunctionHttpValidatorConfig extends BaseValidatorConfig {
|
|
2576
|
-
/**
|
|
2577
|
-
|
|
2578
|
-
*
|
|
2579
|
-
* Use `'http'` for new code. `'customHttp'` is accepted for backward compatibility
|
|
2580
|
-
* but emits a deprecation warning in dev mode.
|
|
2581
|
-
*/
|
|
2582
|
-
type: 'http' | 'customHttp';
|
|
2379
|
+
/** Validator type identifier. */
|
|
2380
|
+
type: 'http';
|
|
2583
2381
|
/** Name of registered HTTP validator configuration */
|
|
2584
2382
|
functionName: string;
|
|
2585
2383
|
/** Optional parameters to pass to HTTP validator */
|
|
2586
2384
|
params?: Record<string, unknown>;
|
|
2587
2385
|
}
|
|
2588
|
-
/**
|
|
2589
|
-
* @deprecated Use `FunctionHttpValidatorConfig` instead. Will be removed in a future minor version.
|
|
2590
|
-
*/
|
|
2591
|
-
type HttpValidatorConfig = FunctionHttpValidatorConfig;
|
|
2592
2386
|
/**
|
|
2593
2387
|
* Declarative HTTP validator configuration — fully JSON-serializable, no function registration required.
|
|
2594
2388
|
*
|
|
@@ -3675,49 +3469,6 @@ interface CustomFnConfig<TFormValue extends Record<string, unknown> = Record<str
|
|
|
3675
3469
|
* ```
|
|
3676
3470
|
*/
|
|
3677
3471
|
derivations?: Record<string, CustomFunction<TFormValue>>;
|
|
3678
|
-
/**
|
|
3679
|
-
* @deprecated Register functions under `derivations` instead. Use `type: 'derivation'`
|
|
3680
|
-
* with `targetProperty` in field logic configs. Will be removed in a future minor version.
|
|
3681
|
-
*
|
|
3682
|
-
* Custom property derivation functions for reactive property updates.
|
|
3683
|
-
*
|
|
3684
|
-
* These functions compute derived values for field properties (like `minDate`,
|
|
3685
|
-
* `options`, `label`, `placeholder`) and are called when a
|
|
3686
|
-
* `PropertyDerivationLogicConfig` references them by `functionName`.
|
|
3687
|
-
*
|
|
3688
|
-
* Property derivation functions:
|
|
3689
|
-
* - Receive an `EvaluationContext` with access to `formValue`
|
|
3690
|
-
* - Return the value to set on the target property
|
|
3691
|
-
* - Are called reactively when dependencies change
|
|
3692
|
-
*
|
|
3693
|
-
* @example
|
|
3694
|
-
* ```typescript
|
|
3695
|
-
* propertyDerivations: {
|
|
3696
|
-
* getCitiesForCountry: (context) => {
|
|
3697
|
-
* const countryCities: Record<string, Array<{ label: string; value: string }>> = {
|
|
3698
|
-
* 'USA': [{ label: 'New York', value: 'ny' }, { label: 'LA', value: 'la' }],
|
|
3699
|
-
* 'Germany': [{ label: 'Berlin', value: 'berlin' }, { label: 'Munich', value: 'munich' }],
|
|
3700
|
-
* };
|
|
3701
|
-
* return countryCities[context.formValue.country as string] ?? [];
|
|
3702
|
-
* },
|
|
3703
|
-
* }
|
|
3704
|
-
* ```
|
|
3705
|
-
*
|
|
3706
|
-
* Field configuration using a property derivation function:
|
|
3707
|
-
* ```typescript
|
|
3708
|
-
* {
|
|
3709
|
-
* key: 'city',
|
|
3710
|
-
* type: 'select',
|
|
3711
|
-
* logic: [{
|
|
3712
|
-
* type: 'propertyDerivation',
|
|
3713
|
-
* targetProperty: 'options',
|
|
3714
|
-
* functionName: 'getCitiesForCountry',
|
|
3715
|
-
* dependsOn: ['country']
|
|
3716
|
-
* }]
|
|
3717
|
-
* }
|
|
3718
|
-
* ```
|
|
3719
|
-
*/
|
|
3720
|
-
propertyDerivations?: Record<string, CustomFunction<TFormValue>>;
|
|
3721
3472
|
/**
|
|
3722
3473
|
* Async derivation functions for asynchronous value derivation logic.
|
|
3723
3474
|
*
|
|
@@ -3889,72 +3640,18 @@ interface CustomFnConfig<TFormValue extends Record<string, unknown> = Record<str
|
|
|
3889
3640
|
*/
|
|
3890
3641
|
asyncValidators?: Record<string, AsyncCustomValidator>;
|
|
3891
3642
|
/**
|
|
3892
|
-
*
|
|
3893
|
-
* in the validators array. Function-based HTTP validators now also use `type: 'http'` with `functionName`.
|
|
3894
|
-
* Will be removed in a future minor version.
|
|
3895
|
-
*
|
|
3896
|
-
* HTTP validators using Angular's validateHttp() API
|
|
3643
|
+
* HTTP validators using Angular's validateHttp() API.
|
|
3897
3644
|
*
|
|
3898
|
-
*
|
|
3899
|
-
*
|
|
3645
|
+
* For function-based HTTP validation with automatic request cancellation.
|
|
3646
|
+
* Prefer declarative HTTP validators (`type: 'http'` with `http` + `responseMapping`)
|
|
3647
|
+
* for fully JSON-serializable validation when possible.
|
|
3900
3648
|
*
|
|
3901
|
-
*
|
|
3902
|
-
* - `request`: Function that returns URL string or HttpResourceRequest
|
|
3903
|
-
* - `onSuccess`: REQUIRED - Maps HTTP response to validation errors (inverted logic!)
|
|
3904
|
-
* - `onError`: Optional handler for HTTP errors
|
|
3905
|
-
*
|
|
3906
|
-
* **Benefits:**
|
|
3907
|
-
* - Automatic request cancellation when field value changes
|
|
3908
|
-
* - Built-in integration with Angular's resource management
|
|
3909
|
-
* - Simpler than asyncValidators for HTTP use cases
|
|
3910
|
-
*
|
|
3911
|
-
* **Important:** `onSuccess` uses inverted logic - it maps SUCCESSFUL HTTP responses
|
|
3912
|
-
* to validation errors. For example, if the API returns `{ available: false }`,
|
|
3913
|
-
* your `onSuccess` should return `{ kind: 'usernameTaken' }`.
|
|
3914
|
-
*
|
|
3915
|
-
* @example Username Availability Check (GET)
|
|
3649
|
+
* @example
|
|
3916
3650
|
* ```typescript
|
|
3917
3651
|
* httpValidators: {
|
|
3918
3652
|
* checkUsername: {
|
|
3919
|
-
* request: (ctx) => {
|
|
3920
|
-
*
|
|
3921
|
-
* if (!username) return undefined; // Skip validation if empty
|
|
3922
|
-
* return `/api/users/check-username?username=${encodeURIComponent(username)}`;
|
|
3923
|
-
* },
|
|
3924
|
-
* onSuccess: (response, ctx) => {
|
|
3925
|
-
* // Inverted logic: successful response may indicate validation failure
|
|
3926
|
-
* return response.available ? null : { kind: 'usernameTaken' };
|
|
3927
|
-
* },
|
|
3928
|
-
* onError: (error, ctx) => {
|
|
3929
|
-
* console.error('Availability check failed:', error);
|
|
3930
|
-
* return null; // Don't block form on network errors
|
|
3931
|
-
* }
|
|
3932
|
-
* }
|
|
3933
|
-
* }
|
|
3934
|
-
* ```
|
|
3935
|
-
*
|
|
3936
|
-
* @example Address Validation (POST with Body)
|
|
3937
|
-
* ```typescript
|
|
3938
|
-
* httpValidators: {
|
|
3939
|
-
* validateAddress: {
|
|
3940
|
-
* request: (ctx) => {
|
|
3941
|
-
* const zipCode = ctx.value();
|
|
3942
|
-
* if (!zipCode) return undefined;
|
|
3943
|
-
*
|
|
3944
|
-
* return {
|
|
3945
|
-
* url: '/api/validate-address',
|
|
3946
|
-
* method: 'POST',
|
|
3947
|
-
* body: {
|
|
3948
|
-
* street: ctx.valueOf('street' as any),
|
|
3949
|
-
* city: ctx.valueOf('city' as any),
|
|
3950
|
-
* zipCode: zipCode
|
|
3951
|
-
* },
|
|
3952
|
-
* headers: { 'Content-Type': 'application/json' }
|
|
3953
|
-
* };
|
|
3954
|
-
* },
|
|
3955
|
-
* onSuccess: (response) => {
|
|
3956
|
-
* return response.valid ? null : { kind: 'invalidAddress' };
|
|
3957
|
-
* }
|
|
3653
|
+
* request: (ctx) => `/api/users/check?username=${encodeURIComponent(ctx.value())}`,
|
|
3654
|
+
* onSuccess: (response) => response.available ? null : { kind: 'usernameTaken' },
|
|
3958
3655
|
* }
|
|
3959
3656
|
* }
|
|
3960
3657
|
* ```
|
|
@@ -4339,6 +4036,7 @@ declare class DynamicForm<TFields extends RegisteredFieldTypes[] = RegisteredFie
|
|
|
4339
4036
|
value: _angular_core.ModelSignal<Partial<TModel> | undefined>;
|
|
4340
4037
|
private destroyRef;
|
|
4341
4038
|
private injector;
|
|
4039
|
+
protected environmentInjector: EnvironmentInjector;
|
|
4342
4040
|
private eventBus;
|
|
4343
4041
|
private logger;
|
|
4344
4042
|
private dispatcher;
|
|
@@ -5945,6 +5643,26 @@ declare function dynamicTextToObservable(value: DynamicText | undefined, injecto
|
|
|
5945
5643
|
*/
|
|
5946
5644
|
declare function applyMetaToElement(element: Element, meta: FieldMeta | undefined, previouslyApplied: Set<string>): Set<string>;
|
|
5947
5645
|
|
|
5646
|
+
/**
|
|
5647
|
+
* Wraps a `Resource` so that the previous resolved value is preserved while the resource
|
|
5648
|
+
* is loading or reloading. This prevents UI flicker when params change and a new request
|
|
5649
|
+
* is in-flight — the consumer sees the stale value with a `loading`/`reloading` status
|
|
5650
|
+
* instead of `undefined`.
|
|
5651
|
+
*
|
|
5652
|
+
* Uses Angular's `resource.snapshot` + `resourceFromSnapshots` composition pattern.
|
|
5653
|
+
*
|
|
5654
|
+
* @example
|
|
5655
|
+
* ```typescript
|
|
5656
|
+
* const user = withPreviousValue(
|
|
5657
|
+
* resource({ params: () => userId(), loader: ({ params }) => fetchUser(params) })
|
|
5658
|
+
* );
|
|
5659
|
+
* // user.value() keeps the old user data during loading transitions
|
|
5660
|
+
* ```
|
|
5661
|
+
*
|
|
5662
|
+
* @experimental Uses Angular's experimental resource composition APIs.
|
|
5663
|
+
*/
|
|
5664
|
+
declare function withPreviousValue<T>(input: Resource<T>): Resource<T>;
|
|
5665
|
+
|
|
5948
5666
|
/**
|
|
5949
5667
|
* Pipe that handles dynamic text resolution with support for static strings,
|
|
5950
5668
|
* Observables, and Signals.
|
|
@@ -5992,6 +5710,7 @@ declare class RowFieldComponent {
|
|
|
5992
5710
|
private readonly destroyRef;
|
|
5993
5711
|
private readonly fieldRegistry;
|
|
5994
5712
|
private readonly injector;
|
|
5713
|
+
protected readonly environmentInjector: EnvironmentInjector;
|
|
5995
5714
|
private readonly eventBus;
|
|
5996
5715
|
private readonly logger;
|
|
5997
5716
|
field: _angular_core.InputSignal<RowField<readonly _ng_forge_dynamic_forms.RowAllowedChildren[]>>;
|
|
@@ -6021,6 +5740,7 @@ declare class GroupFieldComponent<TModel extends Record<string, unknown> = Recor
|
|
|
6021
5740
|
private readonly fieldRegistry;
|
|
6022
5741
|
private readonly parentFieldSignalContext;
|
|
6023
5742
|
private readonly injector;
|
|
5743
|
+
protected readonly environmentInjector: EnvironmentInjector;
|
|
6024
5744
|
private readonly eventBus;
|
|
6025
5745
|
private readonly logger;
|
|
6026
5746
|
private readonly fieldProcessors;
|
|
@@ -6097,6 +5817,7 @@ declare class ArrayFieldComponent<TModel extends Record<string, unknown> = Recor
|
|
|
6097
5817
|
private readonly fieldRegistry;
|
|
6098
5818
|
private readonly parentFieldSignalContext;
|
|
6099
5819
|
private readonly parentInjector;
|
|
5820
|
+
protected readonly environmentInjector: EnvironmentInjector;
|
|
6100
5821
|
private readonly eventBus;
|
|
6101
5822
|
private readonly logger;
|
|
6102
5823
|
private readonly templateRegistry;
|
|
@@ -6301,5 +6022,5 @@ declare class RootFormRegistryService {
|
|
|
6301
6022
|
*/
|
|
6302
6023
|
declare const INITIALIZATION_TIMEOUT_MS: InjectionToken<number>;
|
|
6303
6024
|
|
|
6304
|
-
export { ARRAY_CONTEXT, AppendArrayItemEvent, ArrayFieldComponent, BUILT_IN_FIELDS, ConsoleLogger, DEFAULT_PROPS, DEFAULT_VALIDATION_MESSAGES, DynamicForm, DynamicFormError, DynamicFormLogger, DynamicTextPipe, EventBus, EventDispatcher, FIELD_REGISTRY, FIELD_SIGNAL_CONTEXT, FORM_OPTIONS, FormClearEvent, FormResetEvent, GroupFieldComponent, INITIALIZATION_TIMEOUT_MS, InsertArrayItemEvent, NextPageEvent, NoopLogger, PageChangeEvent, PopArrayItemEvent, PrependArrayItemEvent, PreviousPageEvent, RemoveAtIndexEvent, RootFormRegistryService, RowFieldComponent, ShiftArrayItemEvent, SubmitEvent, applyMetaToElement, applyValidator, applyValidators, arrayEvent, arrayFieldMapper, baseFieldMapper, buildBaseInputs, createField, dynamicTextToObservable, evaluateNonFieldDisabled, evaluateNonFieldHidden, field, formConfig, getArrayLength, groupFieldMapper, hasFormValue, interpolateParams, isArrayField, isCheckedField, isContainerField, isDisplayOnlyField, isEqual, isFormStateCondition, isGroupField, isLeafField, isPageField,
|
|
6305
|
-
export type { ArrayAllowedChildren, ArrayButtonConfig, ArrayContext, ArrayField, ArrayFieldTree, ArrayItemContext, ArrayItemDefinitionTemplate, ArrayItemTemplate, AsyncCondition, AsyncConditionFunction, AsyncCustomValidator, AsyncDerivationFunction, AsyncValidatorConfig, AvailableFieldTypes, BaseCheckedField, BaseValidatorConfig, BaseValueField, BuiltInValidatorConfig, ButtonLogicContext, CheckedFieldComponent, ConditionalExpression, ContainerFieldTypes, CustomFnConfig, CustomValidator, CustomValidatorConfig, DeclarativeHttpValidatorConfig, DynamicFormFieldRegistry, DynamicText, EvaluationContext, ExtractField, ExtractFieldDefs, ExtractFormValue, FieldComponent, FieldDef, FieldMeta, FieldOption, FieldPathAccess, FieldRegistryContainers, FieldRegistryLeaves, FieldSignalContext, FieldStateContext, FieldStateInfo, FieldTypeDefinition, FieldWithValidation, FormConfig, FormEvent, FormEventConstructor, FormFieldStateMap, FormMode, FormModeDetectionResult, FormOptions, FormStateCondition, GroupAllowedChildren, GroupField, HttpCondition, HttpCustomValidator, HttpRequestConfig, HttpResourceRequest, HttpValidationResponseMapping,
|
|
6025
|
+
export { ARRAY_CONTEXT, AppendArrayItemEvent, ArrayFieldComponent, BUILT_IN_FIELDS, ConsoleLogger, DEFAULT_PROPS, DEFAULT_VALIDATION_MESSAGES, DynamicForm, DynamicFormError, DynamicFormLogger, DynamicTextPipe, EventBus, EventDispatcher, FIELD_REGISTRY, FIELD_SIGNAL_CONTEXT, FORM_OPTIONS, FormClearEvent, FormResetEvent, GroupFieldComponent, INITIALIZATION_TIMEOUT_MS, InsertArrayItemEvent, NextPageEvent, NoopLogger, PageChangeEvent, PopArrayItemEvent, PrependArrayItemEvent, PreviousPageEvent, RemoveAtIndexEvent, RootFormRegistryService, RowFieldComponent, ShiftArrayItemEvent, SubmitEvent, applyMetaToElement, applyValidator, applyValidators, arrayEvent, arrayFieldMapper, baseFieldMapper, buildBaseInputs, createField, dynamicTextToObservable, evaluateNonFieldDisabled, evaluateNonFieldHidden, field, formConfig, getArrayLength, groupFieldMapper, hasFormValue, interpolateParams, isArrayField, isCheckedField, isContainerField, isDisplayOnlyField, isEqual, isFormStateCondition, isGroupField, isLeafField, isPageField, isRowField, isSimplifiedArrayField, isValueBearingField, isValueField, omit, pageFieldMapper, provideDynamicForm, resolveNextButtonDisabled, resolveNonFieldDisabled, resolveNonFieldHidden, resolveSubmitButtonDisabled, resolveTokens, rowFieldMapper, textFieldMapper, withEventFormValue, withLoggerConfig, withPreviousValue, withValueExclusionDefaults };
|
|
6026
|
+
export type { ArrayAllowedChildren, ArrayButtonConfig, ArrayContext, ArrayField, ArrayFieldTree, ArrayItemContext, ArrayItemDefinitionTemplate, ArrayItemTemplate, AsyncCondition, AsyncConditionFunction, AsyncCustomValidator, AsyncDerivationFunction, AsyncValidatorConfig, AvailableFieldTypes, BaseCheckedField, BaseValidatorConfig, BaseValueField, BuiltInValidatorConfig, ButtonLogicContext, CheckedFieldComponent, ConditionalExpression, ContainerFieldTypes, CustomFnConfig, CustomValidator, CustomValidatorConfig, DeclarativeHttpValidatorConfig, DynamicFormFieldRegistry, DynamicText, EvaluationContext, ExtractField, ExtractFieldDefs, ExtractFormValue, FieldComponent, FieldDef, FieldMeta, FieldOption, FieldPathAccess, FieldRegistryContainers, FieldRegistryLeaves, FieldScope, FieldSignalContext, FieldStateContext, FieldStateInfo, FieldTypeDefinition, FieldWithValidation, FormConfig, FormEvent, FormEventConstructor, FormFieldStateMap, FormMode, FormModeDetectionResult, FormOptions, FormStateCondition, GroupAllowedChildren, GroupField, HttpCondition, HttpCustomValidator, HttpRequestConfig, HttpResourceRequest, HttpValidationResponseMapping, InferFormValue$1 as InferFormValue, LeafFieldTypes, Logger, LogicConfig, MapperFn, NarrowField, NarrowFields, NextButtonOptions, NonFieldLogicConfig, NonFieldLogicContext, NonFieldLogicType, PageAllowedChildren, PageField, Prettify, RegisteredFieldTypes, ResolvedValueExclusionConfig, RowAllowedChildren, RowField, SchemaApplicationConfig, SchemaDefinition, SimplifiedArrayField, StateLogicConfig, SubmissionActionResult, SubmissionConfig, SubmitButtonOptions, TextElementType, TextField, TextProps, TokenContext, ValidationError, ValidationMessages, ValidatorConfig, ValueExclusionConfig, ValueFieldComponent, ValueHandlingMode, ValueType, WithInputSignals };
|