@ng-forge/dynamic-forms 0.1.2 → 0.2.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 +313 -0
- package/fesm2022/ng-forge-dynamic-forms-integration.mjs.map +1 -0
- package/fesm2022/{ng-forge-dynamic-forms-ng-forge-dynamic-forms-BWj75LVN.mjs → ng-forge-dynamic-forms-ng-forge-dynamic-forms-CZBdtTAU.mjs} +977 -1198
- package/fesm2022/ng-forge-dynamic-forms-ng-forge-dynamic-forms-CZBdtTAU.mjs.map +1 -0
- package/fesm2022/{ng-forge-dynamic-forms-page-field.component-ZVrJUMNb.mjs → ng-forge-dynamic-forms-page-field.component-BM32StxL.mjs} +18 -25
- package/fesm2022/ng-forge-dynamic-forms-page-field.component-BM32StxL.mjs.map +1 -0
- package/fesm2022/ng-forge-dynamic-forms-testing-test-button.harness-CbctXjtc.mjs +31 -0
- package/fesm2022/ng-forge-dynamic-forms-testing-test-button.harness-CbctXjtc.mjs.map +1 -0
- package/fesm2022/ng-forge-dynamic-forms-testing.mjs +971 -0
- package/fesm2022/ng-forge-dynamic-forms-testing.mjs.map +1 -0
- package/fesm2022/{ng-forge-dynamic-forms-text-field.component-BKTbxAKn.mjs → ng-forge-dynamic-forms-text-field.component-C0I8jf9T.mjs} +5 -5
- package/fesm2022/{ng-forge-dynamic-forms-text-field.component-BKTbxAKn.mjs.map → ng-forge-dynamic-forms-text-field.component-C0I8jf9T.mjs.map} +1 -1
- package/fesm2022/ng-forge-dynamic-forms.mjs +1 -1
- package/package.json +12 -4
- package/types/ng-forge-dynamic-forms-integration.d.ts +327 -0
- package/types/ng-forge-dynamic-forms-testing.d.ts +566 -0
- package/types/ng-forge-dynamic-forms.d.ts +217 -495
- package/fesm2022/ng-forge-dynamic-forms-ng-forge-dynamic-forms-BWj75LVN.mjs.map +0 -1
- package/fesm2022/ng-forge-dynamic-forms-page-field.component-ZVrJUMNb.mjs.map +0 -1
|
@@ -2,10 +2,10 @@ import * as rxjs from 'rxjs';
|
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
3
|
import * as _angular_forms from '@angular/forms';
|
|
4
4
|
import * as _angular_forms_signals from '@angular/forms/signals';
|
|
5
|
-
import { ValidationError as ValidationError$1, FieldContext, TreeValidationResult, FieldTree, Schema,
|
|
5
|
+
import { ValidationError as ValidationError$1, FieldContext, TreeValidationResult, FieldTree, Schema, SchemaPath, SchemaPathTree } from '@angular/forms/signals';
|
|
6
6
|
import * as _ng_forge_dynamic_forms from '@ng-forge/dynamic-forms';
|
|
7
7
|
import * as _angular_core from '@angular/core';
|
|
8
|
-
import { Signal, ResourceRef, Injector, WritableSignal, InjectionToken, Type, OnDestroy, InputSignal, EnvironmentProviders, PipeTransform } from '@angular/core';
|
|
8
|
+
import { Signal, ResourceRef, Injector, WritableSignal, InjectionToken, Type, OnDestroy, InputSignal, Provider, EnvironmentProviders, PipeTransform } from '@angular/core';
|
|
9
9
|
|
|
10
10
|
type WithInputSignals<T> = {
|
|
11
11
|
readonly [K in keyof T]-?: Signal<T[K]>;
|
|
@@ -236,7 +236,7 @@ type IncludedKeys = 'label' | 'className' | 'hidden' | 'tabIndex';
|
|
|
236
236
|
*
|
|
237
237
|
* @public
|
|
238
238
|
*/
|
|
239
|
-
type FieldComponent<T extends FieldDef<
|
|
239
|
+
type FieldComponent<T extends FieldDef<Record<string, unknown> | unknown>> = Prettify<WithInputSignals<Pick<T, IncludedKeys>>>;
|
|
240
240
|
|
|
241
241
|
/**
|
|
242
242
|
* Re-export Angular's ValidationError for consistency
|
|
@@ -707,10 +707,10 @@ type NarrowField<T> = T extends {
|
|
|
707
707
|
type NarrowFields = readonly NarrowField<RegisteredFieldTypes>[];
|
|
708
708
|
|
|
709
709
|
/**
|
|
710
|
-
* Helper type to convert union to intersection
|
|
711
|
-
*
|
|
710
|
+
* Helper type to convert union to intersection.
|
|
711
|
+
* Uses `U extends U` to trigger distributive conditional type behavior.
|
|
712
712
|
*/
|
|
713
|
-
type UnionToIntersection<U> = (U extends
|
|
713
|
+
type UnionToIntersection<U> = (U extends U ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
714
714
|
/**
|
|
715
715
|
* Depth counter for recursion limiting (prevents infinite type instantiation)
|
|
716
716
|
*/
|
|
@@ -928,8 +928,8 @@ interface SchemaDefinition {
|
|
|
928
928
|
* - Field state: `ctx.state` (errors, touched, dirty, etc.)
|
|
929
929
|
* - Other field values: `ctx.valueOf(path)` where path is a FieldPath
|
|
930
930
|
* - Other field states: `ctx.stateOf(path)`
|
|
931
|
-
* - Other fields: `ctx.
|
|
932
|
-
* - Current field tree: `ctx.
|
|
931
|
+
* - Other fields: `ctx.fieldTreeOf(path)`
|
|
932
|
+
* - Current field tree: `ctx.fieldTree`
|
|
933
933
|
*
|
|
934
934
|
* **Return Types:**
|
|
935
935
|
* - Single error: `{ kind: 'errorKind' }` for field-level validation
|
|
@@ -1083,7 +1083,7 @@ interface AsyncCustomValidator<TValue = unknown, TParams = unknown, TResult = un
|
|
|
1083
1083
|
interface HttpResourceRequest {
|
|
1084
1084
|
url: string;
|
|
1085
1085
|
method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
1086
|
-
body?:
|
|
1086
|
+
body?: unknown;
|
|
1087
1087
|
headers?: Record<string, string | string[]>;
|
|
1088
1088
|
}
|
|
1089
1089
|
/**
|
|
@@ -1180,6 +1180,33 @@ interface HttpCustomValidator<TValue = unknown, TResult = unknown> {
|
|
|
1180
1180
|
readonly onError?: (error: unknown, ctx: FieldContext<TValue>) => ValidationError$1 | ValidationError$1[] | null;
|
|
1181
1181
|
}
|
|
1182
1182
|
|
|
1183
|
+
/**
|
|
1184
|
+
* Interface for dynamic forms logger implementations.
|
|
1185
|
+
* Allows custom logging integrations (Sentry, DataDog, etc.)
|
|
1186
|
+
*/
|
|
1187
|
+
interface Logger {
|
|
1188
|
+
/**
|
|
1189
|
+
* Log a debug message.
|
|
1190
|
+
* Use for detailed diagnostic information during development.
|
|
1191
|
+
*/
|
|
1192
|
+
debug(message: string, ...args: unknown[]): void;
|
|
1193
|
+
/**
|
|
1194
|
+
* Log an info message.
|
|
1195
|
+
* Use for general operational information.
|
|
1196
|
+
*/
|
|
1197
|
+
info(message: string, ...args: unknown[]): void;
|
|
1198
|
+
/**
|
|
1199
|
+
* Log a warning message.
|
|
1200
|
+
* Use for potentially problematic situations that don't prevent operation.
|
|
1201
|
+
*/
|
|
1202
|
+
warn(message: string, ...args: unknown[]): void;
|
|
1203
|
+
/**
|
|
1204
|
+
* Log an error message.
|
|
1205
|
+
* Use for error conditions that may affect functionality.
|
|
1206
|
+
*/
|
|
1207
|
+
error(message: string, ...args: unknown[]): void;
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1183
1210
|
interface EvaluationContext<TValue = unknown> {
|
|
1184
1211
|
/** Current field value */
|
|
1185
1212
|
fieldValue: TValue;
|
|
@@ -1189,6 +1216,8 @@ interface EvaluationContext<TValue = unknown> {
|
|
|
1189
1216
|
fieldPath: string;
|
|
1190
1217
|
/** Custom evaluation functions */
|
|
1191
1218
|
customFunctions?: Record<string, (context: EvaluationContext) => unknown>;
|
|
1219
|
+
/** Logger for diagnostic output */
|
|
1220
|
+
logger: Logger;
|
|
1192
1221
|
/** Allow additional properties for flexible expression evaluation */
|
|
1193
1222
|
[key: string]: unknown;
|
|
1194
1223
|
}
|
|
@@ -1852,12 +1881,15 @@ interface NextButtonOptions {
|
|
|
1852
1881
|
*
|
|
1853
1882
|
* Gives mappers and components access to form state, values, and configuration.
|
|
1854
1883
|
* Container fields (Group, Array) create scoped contexts with nested forms.
|
|
1884
|
+
*
|
|
1885
|
+
* The `form` property uses Angular's FieldTree which includes Subfields<TModel>
|
|
1886
|
+
* for type-safe child field access via bracket notation when TModel is a Record.
|
|
1855
1887
|
*/
|
|
1856
|
-
interface FieldSignalContext<TModel
|
|
1888
|
+
interface FieldSignalContext<TModel extends Record<string, unknown> = Record<string, unknown>> {
|
|
1857
1889
|
injector: Injector;
|
|
1858
1890
|
value: WritableSignal<Partial<TModel> | undefined>;
|
|
1859
1891
|
defaultValues: () => TModel;
|
|
1860
|
-
form:
|
|
1892
|
+
form: FieldTree<TModel>;
|
|
1861
1893
|
defaultValidationMessages?: ValidationMessages;
|
|
1862
1894
|
/** Form-level options used by button mappers to determine disabled state defaults. */
|
|
1863
1895
|
formOptions?: FormOptions;
|
|
@@ -1924,7 +1956,10 @@ interface FieldTypeDefinition<T extends FieldDef<any> = any> {
|
|
|
1924
1956
|
name: string;
|
|
1925
1957
|
/** Field definition type marker (internal use) */
|
|
1926
1958
|
_fieldDef?: T;
|
|
1927
|
-
/**
|
|
1959
|
+
/**
|
|
1960
|
+
* Function to load the component (supports lazy loading)
|
|
1961
|
+
* Returns a Promise that resolves to the component class or module with default export
|
|
1962
|
+
*/
|
|
1928
1963
|
loadComponent?: () => Promise<any>;
|
|
1929
1964
|
/** Mapper function that converts field definition to component bindings */
|
|
1930
1965
|
mapper: MapperFn<T>;
|
|
@@ -1946,14 +1981,6 @@ interface FieldTypeDefinition<T extends FieldDef<any> = any> {
|
|
|
1946
1981
|
* ```
|
|
1947
1982
|
*/
|
|
1948
1983
|
declare const FIELD_REGISTRY: InjectionToken<Map<string, FieldTypeDefinition<any>>>;
|
|
1949
|
-
/**
|
|
1950
|
-
* Gets the value handling mode for a specific field type from the registry.
|
|
1951
|
-
*
|
|
1952
|
-
* @param fieldType - The field type identifier
|
|
1953
|
-
* @param registry - The field type registry
|
|
1954
|
-
* @returns The value handling mode ('include' is the default if not specified)
|
|
1955
|
-
*/
|
|
1956
|
-
declare function getFieldValueHandling(fieldType: string, registry: Map<string, FieldTypeDefinition>): ValueHandlingMode;
|
|
1957
1984
|
|
|
1958
1985
|
/**
|
|
1959
1986
|
* Resolved field ready for rendering with ngComponentOutlet.
|
|
@@ -2173,7 +2200,7 @@ declare class PageNavigationStateChangeEvent implements FormEvent {
|
|
|
2173
2200
|
* </form>
|
|
2174
2201
|
* ```
|
|
2175
2202
|
*/
|
|
2176
|
-
declare class DynamicForm<TFields extends RegisteredFieldTypes[] = RegisteredFieldTypes[], TModel = InferFormValue$1<TFields>> implements OnDestroy {
|
|
2203
|
+
declare class DynamicForm<TFields extends RegisteredFieldTypes[] = RegisteredFieldTypes[], TModel extends Record<string, unknown> = InferFormValue$1<TFields> & Record<string, unknown>> implements OnDestroy {
|
|
2177
2204
|
private readonly destroyRef;
|
|
2178
2205
|
private readonly fieldRegistry;
|
|
2179
2206
|
private readonly injector;
|
|
@@ -2181,6 +2208,7 @@ declare class DynamicForm<TFields extends RegisteredFieldTypes[] = RegisteredFie
|
|
|
2181
2208
|
private readonly rootFormRegistry;
|
|
2182
2209
|
private readonly functionRegistry;
|
|
2183
2210
|
private readonly schemaRegistry;
|
|
2211
|
+
private readonly logger;
|
|
2184
2212
|
/** Form configuration defining the structure, validation, and behavior. */
|
|
2185
2213
|
config: InputSignal<FormConfig<TFields>>;
|
|
2186
2214
|
/** Runtime form options that override config options when provided. */
|
|
@@ -2281,6 +2309,20 @@ declare class DynamicForm<TFields extends RegisteredFieldTypes[] = RegisteredFie
|
|
|
2281
2309
|
static ɵcmp: _angular_core.ɵɵComponentDeclaration<DynamicForm<any, any>, "form[dynamic-form]", never, { "config": { "alias": "dynamic-form"; "required": true; "isSignal": true; }; "formOptions": { "alias": "formOptions"; "required": false; "isSignal": true; }; "value": { "alias": "value"; "required": false; "isSignal": true; }; }, { "value": "valueChange"; "validityChange": "validityChange"; "dirtyChange": "dirtyChange"; "submitted": "submitted"; "reset": "reset"; "cleared": "cleared"; "events": "events"; "initialized": "initialized"; "onPageChange": "onPageChange"; "onPageNavigationStateChange": "onPageNavigationStateChange"; }, never, never, true, never>;
|
|
2282
2310
|
}
|
|
2283
2311
|
|
|
2312
|
+
/**
|
|
2313
|
+
* Base interface for dynamic form features.
|
|
2314
|
+
* Features are configuration options that can be passed to provideDynamicForm
|
|
2315
|
+
* alongside field type definitions.
|
|
2316
|
+
*
|
|
2317
|
+
* Uses Angular-style internal marker (ɵkind) to distinguish from field types.
|
|
2318
|
+
*/
|
|
2319
|
+
interface DynamicFormFeature<TKind extends string = string> {
|
|
2320
|
+
/** Internal marker to identify this as a feature, not a field type */
|
|
2321
|
+
ɵkind: TKind;
|
|
2322
|
+
/** Providers to register for this feature */
|
|
2323
|
+
ɵproviders: Provider[];
|
|
2324
|
+
}
|
|
2325
|
+
|
|
2284
2326
|
/**
|
|
2285
2327
|
* Extract FieldDef type from FieldTypeDefinition
|
|
2286
2328
|
*/
|
|
@@ -2291,9 +2333,11 @@ type ExtractFieldDef<T> = T extends FieldTypeDefinition<infer F> ? F : never;
|
|
|
2291
2333
|
type FieldDefUnion<T extends FieldTypeDefinition[]> = ExtractFieldDef<T[number]>;
|
|
2292
2334
|
/**
|
|
2293
2335
|
* Infer form value type from field definitions
|
|
2336
|
+
* Note: Full value type inference requires complex recursive type mapping.
|
|
2337
|
+
* Using unknown as placeholder until full inference is implemented.
|
|
2294
2338
|
*/
|
|
2295
|
-
type InferFormValue<TFieldDefs extends FieldDef<
|
|
2296
|
-
[K in TFieldDefs[number]['key']]:
|
|
2339
|
+
type InferFormValue<TFieldDefs extends FieldDef<unknown>[]> = {
|
|
2340
|
+
[K in TFieldDefs[number]['key']]: unknown;
|
|
2297
2341
|
};
|
|
2298
2342
|
/**
|
|
2299
2343
|
* Provider result with type inference
|
|
@@ -2302,13 +2346,23 @@ type ProvideDynamicFormResult<T extends FieldTypeDefinition[]> = EnvironmentProv
|
|
|
2302
2346
|
__fieldDefs?: FieldDefUnion<T>;
|
|
2303
2347
|
__formValue?: InferFormValue<FieldDefUnion<T>[]>;
|
|
2304
2348
|
};
|
|
2349
|
+
/**
|
|
2350
|
+
* Union type for items that can be passed to provideDynamicForm
|
|
2351
|
+
*/
|
|
2352
|
+
type FieldTypeOrFeature = FieldTypeDefinition | DynamicFormFeature;
|
|
2353
|
+
/**
|
|
2354
|
+
* Extract only FieldTypeDefinition items from a tuple type
|
|
2355
|
+
*/
|
|
2356
|
+
type ExtractFieldTypes<T extends FieldTypeOrFeature[]> = {
|
|
2357
|
+
[K in keyof T]: T[K] extends FieldTypeDefinition ? T[K] : never;
|
|
2358
|
+
}[number] extends infer U ? U extends FieldTypeDefinition ? U[] : never : never;
|
|
2305
2359
|
/**
|
|
2306
2360
|
* Provider function to configure the dynamic form system with field types and options.
|
|
2307
2361
|
*
|
|
2308
2362
|
* This function creates environment providers that can be used at application or route level
|
|
2309
2363
|
* to register field types. It provides type-safe field registration with automatic type inference.
|
|
2310
2364
|
*
|
|
2311
|
-
* @param
|
|
2365
|
+
* @param items - Field type definitions and/or features (like withLoggerConfig)
|
|
2312
2366
|
* @returns Environment providers for dependency injection with type inference
|
|
2313
2367
|
*
|
|
2314
2368
|
* @example
|
|
@@ -2323,14 +2377,15 @@ type ProvideDynamicFormResult<T extends FieldTypeDefinition[]> = EnvironmentProv
|
|
|
2323
2377
|
*
|
|
2324
2378
|
* @example
|
|
2325
2379
|
* ```typescript
|
|
2326
|
-
* //
|
|
2327
|
-
*
|
|
2328
|
-
*
|
|
2329
|
-
*
|
|
2330
|
-
*
|
|
2331
|
-
*
|
|
2332
|
-
*
|
|
2333
|
-
*
|
|
2380
|
+
* // Disable logging
|
|
2381
|
+
* bootstrapApplication(AppComponent, {
|
|
2382
|
+
* providers: [
|
|
2383
|
+
* provideDynamicForm(
|
|
2384
|
+
* ...withMaterialFields(),
|
|
2385
|
+
* withLoggerConfig(false)
|
|
2386
|
+
* )
|
|
2387
|
+
* ]
|
|
2388
|
+
* });
|
|
2334
2389
|
* ```
|
|
2335
2390
|
*
|
|
2336
2391
|
* @example
|
|
@@ -2349,7 +2404,7 @@ type ProvideDynamicFormResult<T extends FieldTypeDefinition[]> = EnvironmentProv
|
|
|
2349
2404
|
*
|
|
2350
2405
|
* @public
|
|
2351
2406
|
*/
|
|
2352
|
-
declare function provideDynamicForm<const T extends
|
|
2407
|
+
declare function provideDynamicForm<const T extends FieldTypeOrFeature[]>(...items: T): ProvideDynamicFormResult<ExtractFieldTypes<T> extends FieldTypeDefinition[] ? ExtractFieldTypes<T> : FieldTypeDefinition[]>;
|
|
2353
2408
|
/**
|
|
2354
2409
|
* Extract FieldDef types from provider result
|
|
2355
2410
|
*/
|
|
@@ -2394,8 +2449,71 @@ type ExtractFormValue<T> = T extends {
|
|
|
2394
2449
|
* { type: 'page', key: 'step1', fields: [...] }
|
|
2395
2450
|
* ```
|
|
2396
2451
|
*/
|
|
2452
|
+
/**
|
|
2453
|
+
* Built-in field types provided by the dynamic form library.
|
|
2454
|
+
*
|
|
2455
|
+
* Each field type is validated at compile time using satisfies, ensuring
|
|
2456
|
+
* type safety of the mapper function while allowing the array to be typed
|
|
2457
|
+
* as FieldTypeDefinition[] for consumer flexibility.
|
|
2458
|
+
*/
|
|
2397
2459
|
declare const BUILT_IN_FIELDS: FieldTypeDefinition[];
|
|
2398
2460
|
|
|
2461
|
+
/**
|
|
2462
|
+
* Configure logging for dynamic forms.
|
|
2463
|
+
*
|
|
2464
|
+
* By default, logging is enabled (ConsoleLogger). Use this feature to disable logging
|
|
2465
|
+
* or configure it conditionally.
|
|
2466
|
+
*
|
|
2467
|
+
* @example
|
|
2468
|
+
* ```typescript
|
|
2469
|
+
* // Disable logging
|
|
2470
|
+
* provideDynamicForm(
|
|
2471
|
+
* ...withMaterialFields(),
|
|
2472
|
+
* withLoggerConfig(false)
|
|
2473
|
+
* )
|
|
2474
|
+
*
|
|
2475
|
+
* // Conditional logging (e.g., only in dev mode)
|
|
2476
|
+
* provideDynamicForm(
|
|
2477
|
+
* ...withMaterialFields(),
|
|
2478
|
+
* withLoggerConfig(() => isDevMode())
|
|
2479
|
+
* )
|
|
2480
|
+
* ```
|
|
2481
|
+
*
|
|
2482
|
+
* @param enabled - Whether logging is enabled. Can be a boolean or a function that returns a boolean. Defaults to true.
|
|
2483
|
+
* @returns A DynamicFormFeature that configures logging
|
|
2484
|
+
*/
|
|
2485
|
+
declare function withLoggerConfig(enabled?: boolean | (() => boolean)): DynamicFormFeature<'logger'>;
|
|
2486
|
+
|
|
2487
|
+
/**
|
|
2488
|
+
* Injection token for the dynamic forms logger.
|
|
2489
|
+
*
|
|
2490
|
+
* Provided by provideDynamicForm() with ConsoleLogger as default.
|
|
2491
|
+
* Override with withLoggerConfig(false) to disable logging.
|
|
2492
|
+
*/
|
|
2493
|
+
declare const DynamicFormLogger: InjectionToken<Logger>;
|
|
2494
|
+
|
|
2495
|
+
/**
|
|
2496
|
+
* Console-based logger implementation.
|
|
2497
|
+
*/
|
|
2498
|
+
declare class ConsoleLogger implements Logger {
|
|
2499
|
+
private readonly prefix;
|
|
2500
|
+
debug(message: string, ...args: unknown[]): void;
|
|
2501
|
+
info(message: string, ...args: unknown[]): void;
|
|
2502
|
+
warn(message: string, ...args: unknown[]): void;
|
|
2503
|
+
error(message: string, ...args: unknown[]): void;
|
|
2504
|
+
}
|
|
2505
|
+
|
|
2506
|
+
/**
|
|
2507
|
+
* No-operation logger implementation.
|
|
2508
|
+
* All methods are no-ops - used in production by default.
|
|
2509
|
+
*/
|
|
2510
|
+
declare class NoopLogger implements Logger {
|
|
2511
|
+
debug(): void;
|
|
2512
|
+
info(): void;
|
|
2513
|
+
warn(): void;
|
|
2514
|
+
error(): void;
|
|
2515
|
+
}
|
|
2516
|
+
|
|
2399
2517
|
interface FieldOption<T = unknown> {
|
|
2400
2518
|
label: DynamicText;
|
|
2401
2519
|
value: T;
|
|
@@ -2432,7 +2550,7 @@ interface FieldOption<T = unknown> {
|
|
|
2432
2550
|
* }
|
|
2433
2551
|
* ```
|
|
2434
2552
|
*/
|
|
2435
|
-
declare const FIELD_SIGNAL_CONTEXT: InjectionToken<FieldSignalContext<unknown
|
|
2553
|
+
declare const FIELD_SIGNAL_CONTEXT: InjectionToken<FieldSignalContext<Record<string, unknown>>>;
|
|
2436
2554
|
/**
|
|
2437
2555
|
* Injection token for providing array context metadata to mappers and components.
|
|
2438
2556
|
*
|
|
@@ -2460,8 +2578,8 @@ declare const ARRAY_CONTEXT: InjectionToken<ArrayContext>;
|
|
|
2460
2578
|
* @public
|
|
2461
2579
|
*/
|
|
2462
2580
|
interface ButtonLogicContext {
|
|
2463
|
-
/** The form's FieldTree instance */
|
|
2464
|
-
form: FieldTree<unknown>;
|
|
2581
|
+
/** The form's FieldTree instance (supports both string and number keys for array indices) */
|
|
2582
|
+
form: FieldTree<unknown, string | number>;
|
|
2465
2583
|
/** Form-level options */
|
|
2466
2584
|
formOptions?: FormOptions;
|
|
2467
2585
|
/** Field-level logic array (if provided) */
|
|
@@ -2472,6 +2590,8 @@ interface ButtonLogicContext {
|
|
|
2472
2590
|
currentPageValid?: Signal<boolean>;
|
|
2473
2591
|
/** Current form value for evaluating conditional expressions */
|
|
2474
2592
|
formValue?: unknown;
|
|
2593
|
+
/** Optional logger for diagnostic output. Falls back to no-op logger if not provided. */
|
|
2594
|
+
logger?: Logger;
|
|
2475
2595
|
}
|
|
2476
2596
|
/**
|
|
2477
2597
|
* Resolves the disabled state for a submit button.
|
|
@@ -2556,7 +2676,7 @@ interface BaseValueField<TProps, TValue> extends FieldDef<TProps>, FieldWithVali
|
|
|
2556
2676
|
}
|
|
2557
2677
|
declare function isValueField<TProps>(field: FieldDef<TProps>): field is BaseValueField<TProps, ValueType>;
|
|
2558
2678
|
type ExcludedKeys$1 = 'type' | 'conditionals' | 'value' | 'valueType' | 'disabled' | 'readonly' | 'hidden' | 'col' | 'minValue' | 'maxValue' | 'step' | 'required' | 'email' | 'min' | 'max' | 'minLength' | 'maxLength' | 'pattern' | 'validators' | 'logic' | 'schemas';
|
|
2559
|
-
type ValueFieldComponent<T extends BaseValueField<
|
|
2679
|
+
type ValueFieldComponent<T extends BaseValueField<Record<string, unknown> | unknown, unknown>> = Prettify<WithInputSignals<Omit<T, ExcludedKeys$1>>>;
|
|
2560
2680
|
|
|
2561
2681
|
interface BaseCheckedField<TProps> extends FieldDef<TProps>, FieldWithValidation {
|
|
2562
2682
|
value?: boolean;
|
|
@@ -2569,222 +2689,10 @@ interface BaseCheckedField<TProps> extends FieldDef<TProps>, FieldWithValidation
|
|
|
2569
2689
|
}
|
|
2570
2690
|
declare function isCheckedField<TProps>(field: FieldDef<TProps>): field is BaseCheckedField<TProps>;
|
|
2571
2691
|
type ExcludedKeys = 'type' | 'conditionals' | 'value' | 'disabled' | 'readonly' | 'hidden' | 'col' | keyof FieldWithValidation;
|
|
2572
|
-
type CheckedFieldComponent<T extends BaseCheckedField<
|
|
2573
|
-
|
|
2574
|
-
/**
|
|
2575
|
-
* HTML input types supported by input fields
|
|
2576
|
-
*/
|
|
2577
|
-
type InputType = 'text' | 'email' | 'password' | 'number' | 'tel' | 'url';
|
|
2578
|
-
/**
|
|
2579
|
-
* Props for input fields with optional inputType specification.
|
|
2580
|
-
* This is a generic interface that can be extended by framework-specific implementations.
|
|
2581
|
-
*/
|
|
2582
|
-
interface InputProps<T extends InputType = InputType> {
|
|
2583
|
-
/**
|
|
2584
|
-
* The HTML input type. Determines the value type:
|
|
2585
|
-
* - 'number': value will be number
|
|
2586
|
-
* - 'text', 'email', 'password', 'tel', 'url': value will be string
|
|
2587
|
-
*/
|
|
2588
|
-
type?: T;
|
|
2589
|
-
placeholder?: DynamicText;
|
|
2590
|
-
}
|
|
2591
|
-
/**
|
|
2592
|
-
* Input types that produce string values
|
|
2593
|
-
*/
|
|
2594
|
-
type StringInputType = Exclude<InputType, 'number'>;
|
|
2595
|
-
/**
|
|
2596
|
-
* Number input field with strict number value type.
|
|
2597
|
-
* When props.type is 'number', value must be number.
|
|
2598
|
-
* Props is REQUIRED and must include type: 'number'.
|
|
2599
|
-
*/
|
|
2600
|
-
interface NumberInputField<TProps extends {
|
|
2601
|
-
type?: string;
|
|
2602
|
-
} = InputProps> extends BaseValueField<TProps & {
|
|
2603
|
-
type: 'number';
|
|
2604
|
-
}, number> {
|
|
2605
|
-
type: 'input';
|
|
2606
|
-
props: TProps & {
|
|
2607
|
-
type: 'number';
|
|
2608
|
-
};
|
|
2609
|
-
}
|
|
2610
|
-
/**
|
|
2611
|
-
* String input field with strict string value type.
|
|
2612
|
-
* When props.type is text/email/etc (or undefined), value must be string.
|
|
2613
|
-
* Props type cannot be 'number'.
|
|
2614
|
-
*/
|
|
2615
|
-
interface StringInputField<TProps extends {
|
|
2616
|
-
type?: string;
|
|
2617
|
-
} = InputProps> extends BaseValueField<TProps & {
|
|
2618
|
-
type?: StringInputType;
|
|
2619
|
-
}, string> {
|
|
2620
|
-
type: 'input';
|
|
2621
|
-
props?: TProps & {
|
|
2622
|
-
type?: StringInputType;
|
|
2623
|
-
};
|
|
2624
|
-
}
|
|
2625
|
-
/**
|
|
2626
|
-
* Builds discriminated union where props.type determines value type.
|
|
2627
|
-
* - If props.type is 'number', only NumberInputField matches (value: number)
|
|
2628
|
-
* - If props.type is undefined/text/email/etc, only StringInputField matches (value: string)
|
|
2629
|
-
*/
|
|
2630
|
-
type BuildInputFieldUnion<TProps extends {
|
|
2631
|
-
type?: string;
|
|
2632
|
-
}> = NumberInputField<TProps> | StringInputField<TProps>;
|
|
2633
|
-
/**
|
|
2634
|
-
* Input field with automatic type-safe value inference.
|
|
2635
|
-
* TypeScript automatically infers the correct value type based on props.type.
|
|
2636
|
-
*
|
|
2637
|
-
* @example
|
|
2638
|
-
* // Direct usage - automatic strict type safety
|
|
2639
|
-
* const numberField: InputField = {
|
|
2640
|
-
* type: 'input',
|
|
2641
|
-
* key: 'age',
|
|
2642
|
-
* props: { type: 'number' },
|
|
2643
|
-
* value: 25 // ✓ number only (string is type error!)
|
|
2644
|
-
* };
|
|
2645
|
-
*
|
|
2646
|
-
* const textField: InputField = {
|
|
2647
|
-
* type: 'input',
|
|
2648
|
-
* key: 'name',
|
|
2649
|
-
* props: { type: 'text' },
|
|
2650
|
-
* value: 'hello' // ✓ string only (number is type error!)
|
|
2651
|
-
* };
|
|
2652
|
-
*
|
|
2653
|
-
* @example
|
|
2654
|
-
* // Framework usage - extend with custom props
|
|
2655
|
-
* interface MatInputProps extends InputProps {
|
|
2656
|
-
* appearance?: 'fill' | 'outline';
|
|
2657
|
-
* hint?: string;
|
|
2658
|
-
* }
|
|
2659
|
-
* type MatInputField = InputField<MatInputProps>; // Automatically gets discriminated union
|
|
2660
|
-
*/
|
|
2661
|
-
type InputField<TProps extends {
|
|
2662
|
-
type?: string;
|
|
2663
|
-
} = InputProps> = BuildInputFieldUnion<TProps>;
|
|
2664
|
-
|
|
2665
|
-
interface CheckboxField<TProps> extends BaseCheckedField<TProps> {
|
|
2666
|
-
type: 'checkbox';
|
|
2667
|
-
}
|
|
2668
|
-
|
|
2669
|
-
interface SelectProps {
|
|
2670
|
-
placeholder?: DynamicText;
|
|
2671
|
-
}
|
|
2672
|
-
interface SelectField<T, TProps = SelectProps> extends BaseValueField<TProps, T> {
|
|
2673
|
-
type: 'select';
|
|
2674
|
-
readonly options: readonly FieldOption<T>[];
|
|
2675
|
-
}
|
|
2676
|
-
|
|
2677
|
-
/**
|
|
2678
|
-
* Event arguments that can contain static values or tokens to be resolved at runtime
|
|
2679
|
-
* Tokens supported: $key, $index, $arrayKey, formValue
|
|
2680
|
-
*/
|
|
2681
|
-
type EventArgs = readonly (string | number | boolean | null | undefined)[];
|
|
2682
|
-
/**
|
|
2683
|
-
* Interface for button fields
|
|
2684
|
-
*/
|
|
2685
|
-
interface ButtonField<TProps, TEvent extends FormEvent> extends FieldDef<TProps> {
|
|
2686
|
-
type: 'button';
|
|
2687
|
-
event: FormEventConstructor<TEvent>;
|
|
2688
|
-
/**
|
|
2689
|
-
* Optional arguments to pass to the event constructor.
|
|
2690
|
-
* Can contain special tokens that will be resolved at runtime:
|
|
2691
|
-
* - $key: The current field key
|
|
2692
|
-
* - $index: The array index (if inside an array field)
|
|
2693
|
-
* - $arrayKey: The parent array field key (if inside an array field)
|
|
2694
|
-
* - formValue: Access to the current form value for indexing
|
|
2695
|
-
*
|
|
2696
|
-
* @example
|
|
2697
|
-
* eventArgs: ['$arrayKey', '$index']
|
|
2698
|
-
* eventArgs: ['contacts', 0]
|
|
2699
|
-
*/
|
|
2700
|
-
eventArgs?: EventArgs;
|
|
2701
|
-
}
|
|
2702
|
-
|
|
2703
|
-
interface TextareaProps {
|
|
2704
|
-
placeholder?: DynamicText;
|
|
2705
|
-
rows?: number;
|
|
2706
|
-
cols?: number | undefined;
|
|
2707
|
-
}
|
|
2708
|
-
interface TextareaField<TProps = TextareaProps> extends BaseValueField<TProps, string> {
|
|
2709
|
-
type: 'textarea';
|
|
2710
|
-
maxLength?: number | undefined;
|
|
2711
|
-
}
|
|
2712
|
-
|
|
2713
|
-
interface RadioField<T, TProps> extends BaseValueField<TProps, T> {
|
|
2714
|
-
type: 'radio';
|
|
2715
|
-
options: FieldOption<T>[];
|
|
2716
|
-
}
|
|
2717
|
-
|
|
2718
|
-
/**
|
|
2719
|
-
* Multi-checkbox field for selecting multiple values from a list of options.
|
|
2720
|
-
* The value is an array of selected option values.
|
|
2721
|
-
*
|
|
2722
|
-
* @example
|
|
2723
|
-
* const tagsField: MultiCheckboxField<string> = {
|
|
2724
|
-
* type: 'multi-checkbox',
|
|
2725
|
-
* key: 'tags',
|
|
2726
|
-
* value: ['tag1', 'tag2'], // Array of selected values
|
|
2727
|
-
* options: [
|
|
2728
|
-
* { label: 'Tag 1', value: 'tag1' },
|
|
2729
|
-
* { label: 'Tag 2', value: 'tag2' },
|
|
2730
|
-
* { label: 'Tag 3', value: 'tag3' }
|
|
2731
|
-
* ]
|
|
2732
|
-
* };
|
|
2733
|
-
*/
|
|
2734
|
-
interface MultiCheckboxField<TValue, TProps = object> extends BaseValueField<TProps, TValue[]> {
|
|
2735
|
-
type: 'multi-checkbox';
|
|
2736
|
-
options: FieldOption<TValue>[];
|
|
2737
|
-
}
|
|
2738
|
-
|
|
2739
|
-
interface DatepickerProps {
|
|
2740
|
-
placeholder?: DynamicText;
|
|
2741
|
-
}
|
|
2742
|
-
interface DatepickerField<TProps> extends BaseValueField<TProps, Date | string> {
|
|
2743
|
-
type: 'datepicker';
|
|
2744
|
-
minDate?: Date | string | null;
|
|
2745
|
-
maxDate?: Date | string | null;
|
|
2746
|
-
startAt?: Date | null;
|
|
2747
|
-
}
|
|
2748
|
-
|
|
2749
|
-
interface SliderField<TProps> extends BaseValueField<TProps, number> {
|
|
2750
|
-
type: 'slider';
|
|
2751
|
-
minValue?: number;
|
|
2752
|
-
maxValue?: number;
|
|
2753
|
-
step?: number;
|
|
2754
|
-
}
|
|
2692
|
+
type CheckedFieldComponent<T extends BaseCheckedField<Record<string, unknown> | unknown>> = Prettify<WithInputSignals<Omit<T, ExcludedKeys>>>;
|
|
2755
2693
|
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
}
|
|
2759
|
-
|
|
2760
|
-
/**
|
|
2761
|
-
* Apply validator configuration to field path, following the logic pattern.
|
|
2762
|
-
*
|
|
2763
|
-
* Accepts both SchemaPath and SchemaPathTree to support being called from both
|
|
2764
|
-
* individual field mappings and schema functions.
|
|
2765
|
-
*
|
|
2766
|
-
* Note: ValidatorConfig is runtime configuration that doesn't encode the field's
|
|
2767
|
-
* TypeScript type. The type assertions to specific types (string, number) are safe
|
|
2768
|
-
* because Angular's validators perform runtime value checks regardless of the static
|
|
2769
|
-
* type parameter.
|
|
2770
|
-
*
|
|
2771
|
-
* Cross-field validators (those referencing formValue.*) are skipped at field level.
|
|
2772
|
-
* They are collected by the parent form component using collectCrossFieldEntries
|
|
2773
|
-
* and executed at form level using validateTree.
|
|
2774
|
-
*
|
|
2775
|
-
* @param config The validator configuration
|
|
2776
|
-
* @param fieldPath The field path to apply the validator to
|
|
2777
|
-
* @param fieldKey Optional field key (used for logging)
|
|
2778
|
-
*/
|
|
2779
|
-
declare function applyValidator(config: ValidatorConfig, fieldPath: SchemaPath<any> | SchemaPathTree<any>, fieldKey?: string): void;
|
|
2780
|
-
/**
|
|
2781
|
-
* Apply multiple validators to a field path
|
|
2782
|
-
*
|
|
2783
|
-
* @param configs Array of validator configurations
|
|
2784
|
-
* @param fieldPath The field path to apply validators to
|
|
2785
|
-
* @param fieldKey Optional field key (used for logging)
|
|
2786
|
-
*/
|
|
2787
|
-
declare function applyValidators(configs: ValidatorConfig[], fieldPath: SchemaPath<any> | SchemaPathTree<any>, fieldKey?: string): void;
|
|
2694
|
+
declare function applyValidator(config: ValidatorConfig, fieldPath: SchemaPath<any> | SchemaPathTree<any>): void;
|
|
2695
|
+
declare function applyValidators(configs: ValidatorConfig[], fieldPath: SchemaPath<any> | SchemaPathTree<any>): void;
|
|
2788
2696
|
|
|
2789
2697
|
declare class SubmitEvent implements FormEvent {
|
|
2790
2698
|
readonly type: "submit";
|
|
@@ -2922,7 +2830,7 @@ declare class EventBus {
|
|
|
2922
2830
|
* eventBus.dispatch(CustomFormEvent);
|
|
2923
2831
|
* ```
|
|
2924
2832
|
*/
|
|
2925
|
-
dispatch<T extends FormEventConstructor>(eventConstructor: T, ...args:
|
|
2833
|
+
dispatch<T extends FormEventConstructor>(eventConstructor: T, ...args: ConstructorParameters<T>): void;
|
|
2926
2834
|
/**
|
|
2927
2835
|
* Subscribes to events of a specific type.
|
|
2928
2836
|
*
|
|
@@ -2993,21 +2901,16 @@ interface ArrayItemContext {
|
|
|
2993
2901
|
}
|
|
2994
2902
|
|
|
2995
2903
|
/**
|
|
2996
|
-
*
|
|
2904
|
+
* Base error class for all Dynamic Forms errors.
|
|
2997
2905
|
*
|
|
2998
|
-
*
|
|
2999
|
-
*
|
|
3000
|
-
*
|
|
3001
|
-
* For fields with specific properties (select, datepicker, textarea, slider), use the specialized mappers:
|
|
3002
|
-
* - selectFieldMapper: for fields with options (select, radio, multi-checkbox)
|
|
3003
|
-
* - datepickerFieldMapper: for fields with minDate, maxDate, startAt
|
|
3004
|
-
* - textareaFieldMapper: for fields with rows, cols
|
|
3005
|
-
* - sliderFieldMapper: for fields with minValue, maxValue, step
|
|
3006
|
-
*
|
|
3007
|
-
* @param fieldDef The value field definition
|
|
3008
|
-
* @returns Signal containing Record of input names to values for ngComponentOutlet
|
|
2906
|
+
* This class centralizes the `[Dynamic Forms]` prefix, ensuring consistent
|
|
2907
|
+
* error messaging across the library without requiring each error site to
|
|
2908
|
+
* manually include the prefix.
|
|
3009
2909
|
*/
|
|
3010
|
-
declare
|
|
2910
|
+
declare class DynamicFormError extends Error {
|
|
2911
|
+
private static readonly PREFIX;
|
|
2912
|
+
constructor(message: string);
|
|
2913
|
+
}
|
|
3011
2914
|
|
|
3012
2915
|
/**
|
|
3013
2916
|
* Builds base input properties from a field definition.
|
|
@@ -3030,17 +2933,6 @@ declare function buildBaseInputs(fieldDef: FieldDef<unknown>): Record<string, un
|
|
|
3030
2933
|
*/
|
|
3031
2934
|
declare function baseFieldMapper(fieldDef: FieldDef<unknown>): Signal<Record<string, unknown>>;
|
|
3032
2935
|
|
|
3033
|
-
/**
|
|
3034
|
-
* Maps a checkbox/toggle field definition to component inputs.
|
|
3035
|
-
*
|
|
3036
|
-
* Checkbox fields are checked fields that contribute to the form's value as boolean.
|
|
3037
|
-
* This mapper injects FIELD_SIGNAL_CONTEXT to access the form structure and retrieve the field proxy.
|
|
3038
|
-
*
|
|
3039
|
-
* @param fieldDef The checkbox field definition
|
|
3040
|
-
* @returns Signal containing Record of input names to values for ngComponentOutlet
|
|
3041
|
-
*/
|
|
3042
|
-
declare function checkboxFieldMapper(fieldDef: BaseCheckedField<unknown>): Signal<Record<string, unknown>>;
|
|
3043
|
-
|
|
3044
2936
|
/**
|
|
3045
2937
|
* Maps a row field definition to component inputs.
|
|
3046
2938
|
*
|
|
@@ -3088,31 +2980,16 @@ declare function arrayFieldMapper(fieldDef: ArrayField): Signal<Record<string, u
|
|
|
3088
2980
|
declare function pageFieldMapper(fieldDef: PageField): Signal<Record<string, unknown>>;
|
|
3089
2981
|
|
|
3090
2982
|
/**
|
|
3091
|
-
*
|
|
3092
|
-
*/
|
|
3093
|
-
type FieldWithOptions<T = unknown, TProps = unknown> = SelectField<T, TProps> | RadioField<T, TProps> | MultiCheckboxField<T, TProps>;
|
|
3094
|
-
/**
|
|
3095
|
-
* Maps a field with options (select, radio, multi-checkbox) to component inputs.
|
|
3096
|
-
*
|
|
3097
|
-
* Extends the base value field mapper by adding the options property.
|
|
3098
|
-
*
|
|
3099
|
-
* @param fieldDef The field definition with options
|
|
3100
|
-
* @returns Signal containing Record of input names to values for ngComponentOutlet
|
|
3101
|
-
*/
|
|
3102
|
-
declare function optionsFieldMapper<T, TProps>(fieldDef: FieldWithOptions<T, TProps>): Signal<Record<string, unknown>>;
|
|
3103
|
-
|
|
3104
|
-
/**
|
|
3105
|
-
* Maps a datepicker field to component inputs.
|
|
2983
|
+
* Maps a text field definition to component inputs.
|
|
3106
2984
|
*
|
|
3107
|
-
*
|
|
3108
|
-
*
|
|
3109
|
-
*
|
|
3110
|
-
* - startAt: Initial date to display when opening the picker
|
|
2985
|
+
* Text fields are display-only fields that don't participate in the form schema.
|
|
2986
|
+
* This mapper handles the `logic` configuration by creating reactive signals
|
|
2987
|
+
* that evaluate conditions using the form value from RootFormRegistryService.
|
|
3111
2988
|
*
|
|
3112
|
-
* @param fieldDef The
|
|
2989
|
+
* @param fieldDef The text field definition
|
|
3113
2990
|
* @returns Signal containing Record of input names to values for ngComponentOutlet
|
|
3114
2991
|
*/
|
|
3115
|
-
declare function
|
|
2992
|
+
declare function textFieldMapper(fieldDef: TextField): Signal<Record<string, unknown>>;
|
|
3116
2993
|
|
|
3117
2994
|
/**
|
|
3118
2995
|
* Converts DynamicText (string | Observable | Signal) to Observable<string>
|
|
@@ -3124,65 +3001,6 @@ declare function datepickerFieldMapper<TProps>(fieldDef: DatepickerField<TProps>
|
|
|
3124
3001
|
*/
|
|
3125
3002
|
declare function dynamicTextToObservable(value: DynamicText | undefined, injector?: Injector): Observable<string>;
|
|
3126
3003
|
|
|
3127
|
-
/**
|
|
3128
|
-
* Computed signal that determines if errors should be displayed
|
|
3129
|
-
* Based on field's invalid, touched, and error count
|
|
3130
|
-
*
|
|
3131
|
-
* @param field - Signal containing FieldTree
|
|
3132
|
-
* @returns Signal<boolean> - True if errors should be displayed
|
|
3133
|
-
*/
|
|
3134
|
-
declare function shouldShowErrors<T>(field: Signal<FieldTree<T>>): Signal<boolean>;
|
|
3135
|
-
|
|
3136
|
-
/**
|
|
3137
|
-
* Resolved validation error with interpolated message
|
|
3138
|
-
*/
|
|
3139
|
-
interface ResolvedError {
|
|
3140
|
-
kind: string;
|
|
3141
|
-
message: string;
|
|
3142
|
-
}
|
|
3143
|
-
/**
|
|
3144
|
-
* Factory function that creates a signal of resolved validation errors
|
|
3145
|
-
* Handles async resolution of DynamicText validation messages
|
|
3146
|
-
*
|
|
3147
|
-
* @param field - Signal containing FieldTree
|
|
3148
|
-
* @param validationMessages - Signal containing custom field-level validation messages
|
|
3149
|
-
* @param defaultValidationMessages - Signal containing default validation messages (fallback)
|
|
3150
|
-
* @param injector - Optional injector for DynamicText resolution
|
|
3151
|
-
* @returns Signal<ResolvedError[]> - Reactively resolved error messages
|
|
3152
|
-
*
|
|
3153
|
-
* @example
|
|
3154
|
-
* ```typescript
|
|
3155
|
-
* readonly resolvedErrors = createResolvedErrorsSignal(
|
|
3156
|
-
* this.field,
|
|
3157
|
-
* this.validationMessages,
|
|
3158
|
-
* this.defaultValidationMessages
|
|
3159
|
-
* );
|
|
3160
|
-
* ```
|
|
3161
|
-
*/
|
|
3162
|
-
declare function createResolvedErrorsSignal<T>(field: Signal<FieldTree<T>>, validationMessages: Signal<ValidationMessages | undefined>, defaultValidationMessages?: Signal<ValidationMessages | undefined>, injector?: Injector): Signal<ResolvedError[]>;
|
|
3163
|
-
|
|
3164
|
-
interface ChildData {
|
|
3165
|
-
reader: FieldTree<unknown>;
|
|
3166
|
-
}
|
|
3167
|
-
interface ChildrenData {
|
|
3168
|
-
byPropertyKey: Map<string, ChildData>;
|
|
3169
|
-
}
|
|
3170
|
-
interface FormInternals<T = unknown> {
|
|
3171
|
-
structure: {
|
|
3172
|
-
childrenMap: () => ChildrenData;
|
|
3173
|
-
};
|
|
3174
|
-
fieldProxy?: FieldTree<T>;
|
|
3175
|
-
}
|
|
3176
|
-
type FormInput = FormInternals | Signal<FormInternals> | unknown;
|
|
3177
|
-
/**
|
|
3178
|
-
* Type guard that unwraps signals and checks for FormInternals structure.
|
|
3179
|
-
* Use this when the input might be a signal wrapping FormInternals.
|
|
3180
|
-
*/
|
|
3181
|
-
declare function hasFormStructure(form: FormInput): form is FormInternals | Signal<FormInternals>;
|
|
3182
|
-
declare function getChildrenMap(form: FormInput): Map<string, FieldTree<unknown>> | null;
|
|
3183
|
-
declare function getFieldProxy<T = unknown>(node: unknown): FieldTree<T> | null;
|
|
3184
|
-
declare function getChildFieldTree(form: unknown, key: string): FieldTree<unknown> | null;
|
|
3185
|
-
|
|
3186
3004
|
/**
|
|
3187
3005
|
* Pipe that handles dynamic text resolution with support for static strings,
|
|
3188
3006
|
* Observables, and Signals.
|
|
@@ -3231,6 +3049,7 @@ declare class RowFieldComponent {
|
|
|
3231
3049
|
private readonly fieldRegistry;
|
|
3232
3050
|
private readonly injector;
|
|
3233
3051
|
private readonly eventBus;
|
|
3052
|
+
private readonly logger;
|
|
3234
3053
|
field: _angular_core.InputSignal<RowField<readonly _ng_forge_dynamic_forms.RowAllowedChildren[]>>;
|
|
3235
3054
|
key: _angular_core.InputSignal<string>;
|
|
3236
3055
|
readonly disabled: _angular_core.Signal<boolean>;
|
|
@@ -3250,12 +3069,13 @@ declare class RowFieldComponent {
|
|
|
3250
3069
|
* Child fields receive a FIELD_SIGNAL_CONTEXT scoped to this group's form instance.
|
|
3251
3070
|
* Group values are nested under the group's key in the parent form.
|
|
3252
3071
|
*/
|
|
3253
|
-
declare class GroupFieldComponent<TModel = Record<string, unknown>> {
|
|
3072
|
+
declare class GroupFieldComponent<TModel extends Record<string, unknown> = Record<string, unknown>> {
|
|
3254
3073
|
private readonly destroyRef;
|
|
3255
3074
|
private readonly fieldRegistry;
|
|
3256
3075
|
private readonly parentFieldSignalContext;
|
|
3257
3076
|
private readonly injector;
|
|
3258
3077
|
private readonly eventBus;
|
|
3078
|
+
private readonly logger;
|
|
3259
3079
|
private readonly memoizedFlattenFields;
|
|
3260
3080
|
private readonly memoizedKeyBy;
|
|
3261
3081
|
private readonly memoizedDefaultValues;
|
|
@@ -3273,11 +3093,6 @@ declare class GroupFieldComponent<TModel = Record<string, unknown>> {
|
|
|
3273
3093
|
readonly touched: _angular_core.Signal<boolean>;
|
|
3274
3094
|
readonly errors: _angular_core.Signal<_angular_forms_signals.ValidationError.WithField[]>;
|
|
3275
3095
|
readonly disabled: _angular_core.Signal<boolean>;
|
|
3276
|
-
/**
|
|
3277
|
-
* Get the nested FieldTree from the parent form for this group.
|
|
3278
|
-
* This allows child fields to update the parent form directly,
|
|
3279
|
-
* avoiding the need for separate form synchronization.
|
|
3280
|
-
*/
|
|
3281
3096
|
private readonly nestedFieldTree;
|
|
3282
3097
|
private readonly groupInjector;
|
|
3283
3098
|
readonly validityChange: _angular_core.OutputRef<boolean>;
|
|
@@ -3314,12 +3129,13 @@ interface ResolvedArrayItem {
|
|
|
3314
3129
|
* Uses differential updates to optimize rendering - only recreates items when necessary.
|
|
3315
3130
|
* Each item gets a scoped injector with ARRAY_CONTEXT for position-aware operations.
|
|
3316
3131
|
*/
|
|
3317
|
-
declare class ArrayFieldComponent<TModel = Record<string, unknown>> {
|
|
3132
|
+
declare class ArrayFieldComponent<TModel extends Record<string, unknown> = Record<string, unknown>> {
|
|
3318
3133
|
private readonly destroyRef;
|
|
3319
3134
|
private readonly fieldRegistry;
|
|
3320
3135
|
private readonly parentFieldSignalContext;
|
|
3321
3136
|
private readonly parentInjector;
|
|
3322
3137
|
private readonly eventBus;
|
|
3138
|
+
private readonly logger;
|
|
3323
3139
|
field: _angular_core.InputSignal<ArrayField<readonly _ng_forge_dynamic_forms.ArrayAllowedChildren[]>>;
|
|
3324
3140
|
key: _angular_core.InputSignal<string>;
|
|
3325
3141
|
private readonly rawFieldRegistry;
|
|
@@ -3343,143 +3159,49 @@ declare class ArrayFieldComponent<TModel = Record<string, unknown>> {
|
|
|
3343
3159
|
}
|
|
3344
3160
|
|
|
3345
3161
|
/**
|
|
3346
|
-
*
|
|
3347
|
-
*
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3162
|
+
* Type representing a FieldTree for an array.
|
|
3163
|
+
* Extends FieldTree to add numeric indexing for accessing item FieldTrees.
|
|
3164
|
+
*/
|
|
3165
|
+
type ArrayFieldTree<T> = FieldTree<T[]> & {
|
|
3166
|
+
readonly [index: number]: FieldTree<T> | undefined;
|
|
3167
|
+
};
|
|
3168
|
+
/**
|
|
3169
|
+
* Get the length of an array FieldTree.
|
|
3170
|
+
*/
|
|
3171
|
+
declare function getArrayLength<T>(arrayFieldTree: ArrayFieldTree<T>): number;
|
|
3172
|
+
|
|
3173
|
+
/**
|
|
3174
|
+
* Native JavaScript utility functions to replace lodash-es
|
|
3175
|
+
* These are simple implementations for common object manipulation patterns
|
|
3176
|
+
*/
|
|
3177
|
+
/**
|
|
3178
|
+
* Creates a new object without the specified keys
|
|
3179
|
+
* Native replacement for lodash omit()
|
|
3351
3180
|
*
|
|
3352
|
-
* @
|
|
3181
|
+
* @param obj - Source object
|
|
3182
|
+
* @param keys - Keys to omit
|
|
3183
|
+
* @returns New object without specified keys
|
|
3353
3184
|
*
|
|
3354
3185
|
* @example
|
|
3355
3186
|
* ```typescript
|
|
3356
|
-
*
|
|
3357
|
-
*
|
|
3358
|
-
* private fieldRegistry = injectFieldRegistry();
|
|
3359
|
-
*
|
|
3360
|
-
* async loadCustomField() {
|
|
3361
|
-
* if (this.fieldRegistry.hasType('custom-input')) {
|
|
3362
|
-
* const component = await this.fieldRegistry.loadTypeComponent('custom-input');
|
|
3363
|
-
* // Use component...
|
|
3364
|
-
* }
|
|
3365
|
-
* }
|
|
3366
|
-
* }
|
|
3187
|
+
* const obj = { a: 1, b: 2, c: 3 };
|
|
3188
|
+
* omit(obj, ['b']); // { a: 1, c: 3 }
|
|
3367
3189
|
* ```
|
|
3190
|
+
*/
|
|
3191
|
+
declare function omit<T extends object, K extends keyof T>(obj: T, keys: K[]): Omit<T, K>;
|
|
3192
|
+
|
|
3193
|
+
/**
|
|
3194
|
+
* Interpolates {{param}} placeholders in message with error values
|
|
3368
3195
|
*
|
|
3369
|
-
* @
|
|
3370
|
-
*
|
|
3371
|
-
*
|
|
3372
|
-
* @Injectable()
|
|
3373
|
-
* export class FormBuilderService {
|
|
3374
|
-
* private fieldRegistry = injectFieldRegistry();
|
|
3375
|
-
*
|
|
3376
|
-
* getAvailableFieldTypes(): string[] {
|
|
3377
|
-
* return this.fieldRegistry.getTypes().map(type => type.name);
|
|
3378
|
-
* }
|
|
3379
|
-
* }
|
|
3380
|
-
* ```
|
|
3196
|
+
* @param message - Message template with {{param}} placeholders
|
|
3197
|
+
* @param error - Validation error containing parameter values
|
|
3198
|
+
* @returns Message with interpolated parameters
|
|
3381
3199
|
*
|
|
3382
|
-
* @
|
|
3200
|
+
* @example
|
|
3201
|
+
* interpolateParams("Min value is {{min}}", { kind: 'min', min: 5 })
|
|
3202
|
+
* // Returns: "Min value is 5"
|
|
3383
3203
|
*/
|
|
3384
|
-
declare function
|
|
3385
|
-
/**
|
|
3386
|
-
* Retrieves a field type definition by its registered name.
|
|
3387
|
-
*
|
|
3388
|
-
* @param name - The registered name of the field type
|
|
3389
|
-
* @returns The field type definition if found, undefined otherwise
|
|
3390
|
-
*
|
|
3391
|
-
* @example
|
|
3392
|
-
* ```typescript
|
|
3393
|
-
* const inputType = fieldRegistry.getType('input');
|
|
3394
|
-
* if (inputType) {
|
|
3395
|
-
* console.log('Input field type found:', inputType.name);
|
|
3396
|
-
* }
|
|
3397
|
-
* ```
|
|
3398
|
-
*/
|
|
3399
|
-
getType(name: string): FieldTypeDefinition | undefined;
|
|
3400
|
-
/**
|
|
3401
|
-
* Checks if a field type is registered in the registry.
|
|
3402
|
-
*
|
|
3403
|
-
* @param name - The name of the field type to check
|
|
3404
|
-
* @returns True if the field type exists, false otherwise
|
|
3405
|
-
*
|
|
3406
|
-
* @example
|
|
3407
|
-
* ```typescript
|
|
3408
|
-
* if (fieldRegistry.hasType('custom-input')) {
|
|
3409
|
-
* // Safe to use custom-input field type
|
|
3410
|
-
* const component = await fieldRegistry.loadTypeComponent('custom-input');
|
|
3411
|
-
* }
|
|
3412
|
-
* ```
|
|
3413
|
-
*/
|
|
3414
|
-
hasType(name: string): boolean;
|
|
3415
|
-
/**
|
|
3416
|
-
* Loads a field type component with support for lazy loading.
|
|
3417
|
-
*
|
|
3418
|
-
* Handles both synchronous component references and asynchronous
|
|
3419
|
-
* dynamic imports. Automatically extracts default exports from ES modules.
|
|
3420
|
-
*
|
|
3421
|
-
* @param name - The name of the field type to load
|
|
3422
|
-
* @returns Promise resolving to the component constructor
|
|
3423
|
-
* @throws {Error} When field type is not registered or loading fails
|
|
3424
|
-
*
|
|
3425
|
-
* @example
|
|
3426
|
-
* ```typescript
|
|
3427
|
-
* try {
|
|
3428
|
-
* const InputComponent = await fieldRegistry.loadTypeComponent('input');
|
|
3429
|
-
* const componentRef = vcr.createComponent(InputComponent);
|
|
3430
|
-
* } catch (error) {
|
|
3431
|
-
* console.error('Failed to load component:', error);
|
|
3432
|
-
* }
|
|
3433
|
-
* ```
|
|
3434
|
-
*/
|
|
3435
|
-
loadTypeComponent(name: string): Promise<Type<unknown>>;
|
|
3436
|
-
/**
|
|
3437
|
-
* Gets all registered field type definitions.
|
|
3438
|
-
*
|
|
3439
|
-
* @returns Array of all field type definitions in the registry
|
|
3440
|
-
*
|
|
3441
|
-
* @example
|
|
3442
|
-
* ```typescript
|
|
3443
|
-
* const allTypes = fieldRegistry.getTypes();
|
|
3444
|
-
* const typeNames = allTypes.map(type => type.name);
|
|
3445
|
-
* console.log('Available field types:', typeNames);
|
|
3446
|
-
* ```
|
|
3447
|
-
*/
|
|
3448
|
-
getTypes(): FieldTypeDefinition[];
|
|
3449
|
-
/**
|
|
3450
|
-
* Registers multiple field types at once.
|
|
3451
|
-
*
|
|
3452
|
-
* Useful for bulk registration of custom field types. Overwrites
|
|
3453
|
-
* existing registrations with the same name.
|
|
3454
|
-
*
|
|
3455
|
-
* @param types - Array of field type definitions to register
|
|
3456
|
-
*
|
|
3457
|
-
* @example
|
|
3458
|
-
* ```typescript
|
|
3459
|
-
* fieldRegistry.registerTypes([
|
|
3460
|
-
* CustomInputType,
|
|
3461
|
-
* CustomSelectType,
|
|
3462
|
-
* CustomDatePickerType
|
|
3463
|
-
* ]);
|
|
3464
|
-
* ```
|
|
3465
|
-
*/
|
|
3466
|
-
registerTypes(types: FieldTypeDefinition[]): void;
|
|
3467
|
-
/**
|
|
3468
|
-
* Provides direct access to the underlying registry Map.
|
|
3469
|
-
*
|
|
3470
|
-
* Use with caution - direct modification can affect form behavior.
|
|
3471
|
-
* Primarily intended for advanced use cases and debugging.
|
|
3472
|
-
*
|
|
3473
|
-
* @returns The raw Map containing field type registrations
|
|
3474
|
-
*
|
|
3475
|
-
* @example
|
|
3476
|
-
* ```typescript
|
|
3477
|
-
* const rawRegistry = fieldRegistry.raw;
|
|
3478
|
-
* console.log('Registry size:', rawRegistry.size);
|
|
3479
|
-
* ```
|
|
3480
|
-
*/
|
|
3481
|
-
readonly raw: Map<string, FieldTypeDefinition<any>>;
|
|
3482
|
-
};
|
|
3204
|
+
declare function interpolateParams(message: string, error: ValidationError): string;
|
|
3483
3205
|
|
|
3484
|
-
export { ARRAY_CONTEXT, AddArrayItemEvent, ArrayFieldComponent, BUILT_IN_FIELDS, DynamicForm, DynamicTextPipe, EventBus, FIELD_REGISTRY, FIELD_SIGNAL_CONTEXT, FormClearEvent, FormResetEvent, GroupFieldComponent, NextPageEvent, PageChangeEvent, PreviousPageEvent, RemoveArrayItemEvent, RowFieldComponent, SubmitEvent, applyValidator, applyValidators, arrayFieldMapper, baseFieldMapper, buildBaseInputs,
|
|
3485
|
-
export type { ArrayAllowedChildren, ArrayContext, ArrayField, ArrayItemContext, AsyncCustomValidator, AsyncValidatorConfig, AvailableFieldTypes, BaseCheckedField, BaseValidatorConfig, BaseValueField, BuiltInValidatorConfig,
|
|
3206
|
+
export { ARRAY_CONTEXT, AddArrayItemEvent, ArrayFieldComponent, BUILT_IN_FIELDS, ConsoleLogger, DynamicForm, DynamicFormError, DynamicFormLogger, DynamicTextPipe, EventBus, FIELD_REGISTRY, FIELD_SIGNAL_CONTEXT, FormClearEvent, FormResetEvent, GroupFieldComponent, NextPageEvent, NoopLogger, PageChangeEvent, PreviousPageEvent, RemoveArrayItemEvent, RowFieldComponent, SubmitEvent, applyValidator, applyValidators, arrayFieldMapper, baseFieldMapper, buildBaseInputs, dynamicTextToObservable, getArrayLength, groupFieldMapper, interpolateParams, isArrayField, isCheckedField, isContainerField, isDisplayOnlyField, isFormStateCondition, isGroupField, isLeafField, isPageField, isRowField, isValueBearingField, isValueField, omit, pageFieldMapper, provideDynamicForm, resolveNextButtonDisabled, resolveSubmitButtonDisabled, resolveTokens, rowFieldMapper, textFieldMapper, withLoggerConfig };
|
|
3207
|
+
export type { ArrayAllowedChildren, ArrayContext, ArrayField, ArrayFieldTree, ArrayItemContext, AsyncCustomValidator, AsyncValidatorConfig, AvailableFieldTypes, BaseCheckedField, BaseValidatorConfig, BaseValueField, BuiltInValidatorConfig, ButtonLogicContext, CheckedFieldComponent, ConditionalExpression, ContainerFieldTypes, CustomFnConfig, CustomValidator, CustomValidatorConfig, DynamicFormFieldRegistry, DynamicText, EvaluationContext, ExtractField, ExtractFieldDefs, ExtractFormValue, FieldComponent, FieldDef, FieldOption, FieldPathAccess, FieldRegistryContainers, FieldRegistryLeaves, FieldSignalContext, FieldTypeDefinition, FieldWithValidation, FormConfig, FormEvent, FormEventConstructor, FormMode, FormModeDetectionResult, FormOptions, FormStateCondition, GroupAllowedChildren, GroupField, HttpCustomValidator, HttpResourceRequest, HttpValidatorConfig, InferFormValue$1 as InferFormValue, LeafFieldTypes, Logger, LogicConfig, MapperFn, NarrowField, NarrowFields, NextButtonOptions, PageAllowedChildren, PageField, Prettify, RegisteredFieldTypes, RowAllowedChildren, RowField, SchemaApplicationConfig, SchemaDefinition, SubmissionActionResult, SubmissionConfig, SubmitButtonOptions, TextElementType, TextField, TextProps, TokenContext, ValidationError, ValidationMessages, ValidatorConfig, ValueFieldComponent, ValueHandlingMode, ValueType, WithInputSignals };
|