@ng-forge/dynamic-forms 0.1.2 → 0.1.3
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 +269 -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-B_676NHl.mjs} +881 -1103
- package/fesm2022/ng-forge-dynamic-forms-ng-forge-dynamic-forms-B_676NHl.mjs.map +1 -0
- package/fesm2022/{ng-forge-dynamic-forms-page-field.component-ZVrJUMNb.mjs → ng-forge-dynamic-forms-page-field.component-YHFQcpCS.mjs} +15 -22
- package/fesm2022/ng-forge-dynamic-forms-page-field.component-YHFQcpCS.mjs.map +1 -0
- package/fesm2022/ng-forge-dynamic-forms-testing-test-button.harness-BenmCFcM.mjs +31 -0
- package/fesm2022/ng-forge-dynamic-forms-testing-test-button.harness-BenmCFcM.mjs.map +1 -0
- package/fesm2022/ng-forge-dynamic-forms-testing.mjs +968 -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-CiYq73aF.mjs} +2 -2
- package/fesm2022/{ng-forge-dynamic-forms-text-field.component-BKTbxAKn.mjs.map → ng-forge-dynamic-forms-text-field.component-CiYq73aF.mjs.map} +1 -1
- package/fesm2022/ng-forge-dynamic-forms.mjs +1 -1
- package/package.json +9 -1
- package/types/ng-forge-dynamic-forms-integration.d.ts +315 -0
- package/types/ng-forge-dynamic-forms-testing.d.ts +565 -0
- package/types/ng-forge-dynamic-forms.d.ts +224 -479
- 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]>;
|
|
@@ -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 DynamicFormLogger {
|
|
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: DynamicFormLogger;
|
|
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;
|
|
@@ -1946,14 +1978,6 @@ interface FieldTypeDefinition<T extends FieldDef<any> = any> {
|
|
|
1946
1978
|
* ```
|
|
1947
1979
|
*/
|
|
1948
1980
|
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
1981
|
|
|
1958
1982
|
/**
|
|
1959
1983
|
* Resolved field ready for rendering with ngComponentOutlet.
|
|
@@ -2173,7 +2197,7 @@ declare class PageNavigationStateChangeEvent implements FormEvent {
|
|
|
2173
2197
|
* </form>
|
|
2174
2198
|
* ```
|
|
2175
2199
|
*/
|
|
2176
|
-
declare class DynamicForm<TFields extends RegisteredFieldTypes[] = RegisteredFieldTypes[], TModel = InferFormValue$1<TFields>> implements OnDestroy {
|
|
2200
|
+
declare class DynamicForm<TFields extends RegisteredFieldTypes[] = RegisteredFieldTypes[], TModel extends Record<string, unknown> = InferFormValue$1<TFields> & Record<string, unknown>> implements OnDestroy {
|
|
2177
2201
|
private readonly destroyRef;
|
|
2178
2202
|
private readonly fieldRegistry;
|
|
2179
2203
|
private readonly injector;
|
|
@@ -2181,6 +2205,7 @@ declare class DynamicForm<TFields extends RegisteredFieldTypes[] = RegisteredFie
|
|
|
2181
2205
|
private readonly rootFormRegistry;
|
|
2182
2206
|
private readonly functionRegistry;
|
|
2183
2207
|
private readonly schemaRegistry;
|
|
2208
|
+
private readonly logger;
|
|
2184
2209
|
/** Form configuration defining the structure, validation, and behavior. */
|
|
2185
2210
|
config: InputSignal<FormConfig<TFields>>;
|
|
2186
2211
|
/** Runtime form options that override config options when provided. */
|
|
@@ -2281,6 +2306,20 @@ declare class DynamicForm<TFields extends RegisteredFieldTypes[] = RegisteredFie
|
|
|
2281
2306
|
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
2307
|
}
|
|
2283
2308
|
|
|
2309
|
+
/**
|
|
2310
|
+
* Base interface for dynamic form features.
|
|
2311
|
+
* Features are configuration options that can be passed to provideDynamicForm
|
|
2312
|
+
* alongside field type definitions.
|
|
2313
|
+
*
|
|
2314
|
+
* Uses Angular-style internal marker (ɵkind) to distinguish from field types.
|
|
2315
|
+
*/
|
|
2316
|
+
interface DynamicFormFeature<TKind extends string = string> {
|
|
2317
|
+
/** Internal marker to identify this as a feature, not a field type */
|
|
2318
|
+
ɵkind: TKind;
|
|
2319
|
+
/** Providers to register for this feature */
|
|
2320
|
+
ɵproviders: Provider[];
|
|
2321
|
+
}
|
|
2322
|
+
|
|
2284
2323
|
/**
|
|
2285
2324
|
* Extract FieldDef type from FieldTypeDefinition
|
|
2286
2325
|
*/
|
|
@@ -2302,13 +2341,23 @@ type ProvideDynamicFormResult<T extends FieldTypeDefinition[]> = EnvironmentProv
|
|
|
2302
2341
|
__fieldDefs?: FieldDefUnion<T>;
|
|
2303
2342
|
__formValue?: InferFormValue<FieldDefUnion<T>[]>;
|
|
2304
2343
|
};
|
|
2344
|
+
/**
|
|
2345
|
+
* Union type for items that can be passed to provideDynamicForm
|
|
2346
|
+
*/
|
|
2347
|
+
type FieldTypeOrFeature = FieldTypeDefinition | DynamicFormFeature;
|
|
2348
|
+
/**
|
|
2349
|
+
* Extract only FieldTypeDefinition items from a tuple type
|
|
2350
|
+
*/
|
|
2351
|
+
type ExtractFieldTypes<T extends FieldTypeOrFeature[]> = {
|
|
2352
|
+
[K in keyof T]: T[K] extends FieldTypeDefinition ? T[K] : never;
|
|
2353
|
+
}[number] extends infer U ? U extends FieldTypeDefinition ? U[] : never : never;
|
|
2305
2354
|
/**
|
|
2306
2355
|
* Provider function to configure the dynamic form system with field types and options.
|
|
2307
2356
|
*
|
|
2308
2357
|
* This function creates environment providers that can be used at application or route level
|
|
2309
2358
|
* to register field types. It provides type-safe field registration with automatic type inference.
|
|
2310
2359
|
*
|
|
2311
|
-
* @param
|
|
2360
|
+
* @param items - Field type definitions and/or features (like withLogger)
|
|
2312
2361
|
* @returns Environment providers for dependency injection with type inference
|
|
2313
2362
|
*
|
|
2314
2363
|
* @example
|
|
@@ -2323,6 +2372,19 @@ type ProvideDynamicFormResult<T extends FieldTypeDefinition[]> = EnvironmentProv
|
|
|
2323
2372
|
*
|
|
2324
2373
|
* @example
|
|
2325
2374
|
* ```typescript
|
|
2375
|
+
* // With logging configuration
|
|
2376
|
+
* bootstrapApplication(AppComponent, {
|
|
2377
|
+
* providers: [
|
|
2378
|
+
* provideDynamicForm(
|
|
2379
|
+
* ...withMaterialFields(),
|
|
2380
|
+
* withLogger({ level: LogLevel.Debug })
|
|
2381
|
+
* )
|
|
2382
|
+
* ]
|
|
2383
|
+
* });
|
|
2384
|
+
* ```
|
|
2385
|
+
*
|
|
2386
|
+
* @example
|
|
2387
|
+
* ```typescript
|
|
2326
2388
|
* // Route-level setup
|
|
2327
2389
|
* const routes: Routes = [
|
|
2328
2390
|
* {
|
|
@@ -2349,7 +2411,7 @@ type ProvideDynamicFormResult<T extends FieldTypeDefinition[]> = EnvironmentProv
|
|
|
2349
2411
|
*
|
|
2350
2412
|
* @public
|
|
2351
2413
|
*/
|
|
2352
|
-
declare function provideDynamicForm<const T extends
|
|
2414
|
+
declare function provideDynamicForm<const T extends FieldTypeOrFeature[]>(...items: T): ProvideDynamicFormResult<ExtractFieldTypes<T> extends FieldTypeDefinition[] ? ExtractFieldTypes<T> : FieldTypeDefinition[]>;
|
|
2353
2415
|
/**
|
|
2354
2416
|
* Extract FieldDef types from provider result
|
|
2355
2417
|
*/
|
|
@@ -2396,6 +2458,97 @@ type ExtractFormValue<T> = T extends {
|
|
|
2396
2458
|
*/
|
|
2397
2459
|
declare const BUILT_IN_FIELDS: FieldTypeDefinition[];
|
|
2398
2460
|
|
|
2461
|
+
/**
|
|
2462
|
+
* Log levels for the dynamic forms logger.
|
|
2463
|
+
* Each level includes all levels above it (more severe).
|
|
2464
|
+
*
|
|
2465
|
+
* - Off: No logging
|
|
2466
|
+
* - Error: Only errors
|
|
2467
|
+
* - Warn: Errors + warnings
|
|
2468
|
+
* - Info: Errors + warnings + info
|
|
2469
|
+
* - Debug: All messages including debug
|
|
2470
|
+
*/
|
|
2471
|
+
declare enum LogLevel {
|
|
2472
|
+
/** Disable all logging */
|
|
2473
|
+
Off = 0,
|
|
2474
|
+
/** Only log errors */
|
|
2475
|
+
Error = 1,
|
|
2476
|
+
/** Log errors and warnings */
|
|
2477
|
+
Warn = 2,
|
|
2478
|
+
/** Log errors, warnings, and info messages */
|
|
2479
|
+
Info = 3,
|
|
2480
|
+
/** Log all messages including debug */
|
|
2481
|
+
Debug = 4
|
|
2482
|
+
}
|
|
2483
|
+
|
|
2484
|
+
/**
|
|
2485
|
+
* Configuration options for the logger feature
|
|
2486
|
+
*/
|
|
2487
|
+
interface LoggerFeatureOptions {
|
|
2488
|
+
/**
|
|
2489
|
+
* Log level to use. Messages below this level will be filtered.
|
|
2490
|
+
* @default LogLevel.Warn in dev, LogLevel.Off in prod
|
|
2491
|
+
*/
|
|
2492
|
+
level?: LogLevel;
|
|
2493
|
+
/**
|
|
2494
|
+
* Custom logger implementation.
|
|
2495
|
+
* Use this to integrate with external logging services (Sentry, DataDog, etc.)
|
|
2496
|
+
* If provided, `level` is ignored - your implementation controls filtering.
|
|
2497
|
+
*/
|
|
2498
|
+
logger?: DynamicFormLogger;
|
|
2499
|
+
}
|
|
2500
|
+
/**
|
|
2501
|
+
* Configure logging for dynamic forms.
|
|
2502
|
+
*
|
|
2503
|
+
* @example
|
|
2504
|
+
* ```typescript
|
|
2505
|
+
* // Set log level
|
|
2506
|
+
* provideDynamicForm(
|
|
2507
|
+
* ...withMaterialFields(),
|
|
2508
|
+
* withLogger({ level: LogLevel.Debug })
|
|
2509
|
+
* )
|
|
2510
|
+
*
|
|
2511
|
+
* // Disable logging entirely
|
|
2512
|
+
* provideDynamicForm(
|
|
2513
|
+
* ...withMaterialFields(),
|
|
2514
|
+
* withLogger({ level: LogLevel.Off })
|
|
2515
|
+
* )
|
|
2516
|
+
*
|
|
2517
|
+
* // Custom logger implementation
|
|
2518
|
+
* provideDynamicForm(
|
|
2519
|
+
* ...withMaterialFields(),
|
|
2520
|
+
* withLogger({ logger: mySentryLogger })
|
|
2521
|
+
* )
|
|
2522
|
+
* ```
|
|
2523
|
+
*
|
|
2524
|
+
* @param options - Logger configuration options
|
|
2525
|
+
* @returns A DynamicFormFeature that configures logging
|
|
2526
|
+
*/
|
|
2527
|
+
declare function withLogger(options?: LoggerFeatureOptions): DynamicFormFeature<'logger'>;
|
|
2528
|
+
|
|
2529
|
+
/**
|
|
2530
|
+
* Injection token for the dynamic forms logger.
|
|
2531
|
+
*
|
|
2532
|
+
* Default behavior:
|
|
2533
|
+
* - Development mode: ConsoleLogger with LogLevel.Warn
|
|
2534
|
+
* - Production mode: NoopLogger (silent)
|
|
2535
|
+
*
|
|
2536
|
+
* Override by providing a custom logger via withLogger() feature
|
|
2537
|
+
* or by providing directly to this token.
|
|
2538
|
+
*/
|
|
2539
|
+
declare const DYNAMIC_FORM_LOGGER: InjectionToken<DynamicFormLogger>;
|
|
2540
|
+
|
|
2541
|
+
/**
|
|
2542
|
+
* No-operation logger implementation.
|
|
2543
|
+
* All methods are no-ops - used in production by default.
|
|
2544
|
+
*/
|
|
2545
|
+
declare class NoopLogger implements DynamicFormLogger {
|
|
2546
|
+
debug(): void;
|
|
2547
|
+
info(): void;
|
|
2548
|
+
warn(): void;
|
|
2549
|
+
error(): void;
|
|
2550
|
+
}
|
|
2551
|
+
|
|
2399
2552
|
interface FieldOption<T = unknown> {
|
|
2400
2553
|
label: DynamicText;
|
|
2401
2554
|
value: T;
|
|
@@ -2432,7 +2585,7 @@ interface FieldOption<T = unknown> {
|
|
|
2432
2585
|
* }
|
|
2433
2586
|
* ```
|
|
2434
2587
|
*/
|
|
2435
|
-
declare const FIELD_SIGNAL_CONTEXT: InjectionToken<FieldSignalContext<unknown
|
|
2588
|
+
declare const FIELD_SIGNAL_CONTEXT: InjectionToken<FieldSignalContext<Record<string, unknown>>>;
|
|
2436
2589
|
/**
|
|
2437
2590
|
* Injection token for providing array context metadata to mappers and components.
|
|
2438
2591
|
*
|
|
@@ -2460,8 +2613,8 @@ declare const ARRAY_CONTEXT: InjectionToken<ArrayContext>;
|
|
|
2460
2613
|
* @public
|
|
2461
2614
|
*/
|
|
2462
2615
|
interface ButtonLogicContext {
|
|
2463
|
-
/** The form's FieldTree instance */
|
|
2464
|
-
form: FieldTree<unknown>;
|
|
2616
|
+
/** The form's FieldTree instance (supports both string and number keys for array indices) */
|
|
2617
|
+
form: FieldTree<unknown, string | number>;
|
|
2465
2618
|
/** Form-level options */
|
|
2466
2619
|
formOptions?: FormOptions;
|
|
2467
2620
|
/** Field-level logic array (if provided) */
|
|
@@ -2472,6 +2625,8 @@ interface ButtonLogicContext {
|
|
|
2472
2625
|
currentPageValid?: Signal<boolean>;
|
|
2473
2626
|
/** Current form value for evaluating conditional expressions */
|
|
2474
2627
|
formValue?: unknown;
|
|
2628
|
+
/** Optional logger for diagnostic output. Falls back to no-op logger if not provided. */
|
|
2629
|
+
logger?: DynamicFormLogger;
|
|
2475
2630
|
}
|
|
2476
2631
|
/**
|
|
2477
2632
|
* Resolves the disabled state for a submit button.
|
|
@@ -2571,220 +2726,8 @@ declare function isCheckedField<TProps>(field: FieldDef<TProps>): field is BaseC
|
|
|
2571
2726
|
type ExcludedKeys = 'type' | 'conditionals' | 'value' | 'disabled' | 'readonly' | 'hidden' | 'col' | keyof FieldWithValidation;
|
|
2572
2727
|
type CheckedFieldComponent<T extends BaseCheckedField<any>> = Prettify<WithInputSignals<Omit<T, ExcludedKeys>>>;
|
|
2573
2728
|
|
|
2574
|
-
|
|
2575
|
-
|
|
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
|
-
}
|
|
2755
|
-
|
|
2756
|
-
interface ToggleField<TProps> extends BaseCheckedField<TProps> {
|
|
2757
|
-
type: 'toggle';
|
|
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;
|
|
2729
|
+
declare function applyValidator(config: ValidatorConfig, fieldPath: SchemaPath<any> | SchemaPathTree<any>): void;
|
|
2730
|
+
declare function applyValidators(configs: ValidatorConfig[], fieldPath: SchemaPath<any> | SchemaPathTree<any>): void;
|
|
2788
2731
|
|
|
2789
2732
|
declare class SubmitEvent implements FormEvent {
|
|
2790
2733
|
readonly type: "submit";
|
|
@@ -2992,23 +2935,6 @@ interface ArrayItemContext {
|
|
|
2992
2935
|
formValue?: unknown;
|
|
2993
2936
|
}
|
|
2994
2937
|
|
|
2995
|
-
/**
|
|
2996
|
-
* Maps a value field definition to component inputs.
|
|
2997
|
-
*
|
|
2998
|
-
* Value fields are input fields that contribute to the form's value (text, number, etc.).
|
|
2999
|
-
* This mapper injects FIELD_SIGNAL_CONTEXT to access the form structure and retrieve the field proxy.
|
|
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
|
|
3009
|
-
*/
|
|
3010
|
-
declare function valueFieldMapper<TProps = unknown, TValue = unknown>(fieldDef: BaseValueField<TProps, TValue>): Signal<Record<string, unknown>>;
|
|
3011
|
-
|
|
3012
2938
|
/**
|
|
3013
2939
|
* Builds base input properties from a field definition.
|
|
3014
2940
|
*
|
|
@@ -3030,17 +2956,6 @@ declare function buildBaseInputs(fieldDef: FieldDef<unknown>): Record<string, un
|
|
|
3030
2956
|
*/
|
|
3031
2957
|
declare function baseFieldMapper(fieldDef: FieldDef<unknown>): Signal<Record<string, unknown>>;
|
|
3032
2958
|
|
|
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
2959
|
/**
|
|
3045
2960
|
* Maps a row field definition to component inputs.
|
|
3046
2961
|
*
|
|
@@ -3088,31 +3003,16 @@ declare function arrayFieldMapper(fieldDef: ArrayField): Signal<Record<string, u
|
|
|
3088
3003
|
declare function pageFieldMapper(fieldDef: PageField): Signal<Record<string, unknown>>;
|
|
3089
3004
|
|
|
3090
3005
|
/**
|
|
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.
|
|
3006
|
+
* Maps a text field definition to component inputs.
|
|
3096
3007
|
*
|
|
3097
|
-
*
|
|
3008
|
+
* Text fields are display-only fields that don't participate in the form schema.
|
|
3009
|
+
* This mapper handles the `logic` configuration by creating reactive signals
|
|
3010
|
+
* that evaluate conditions using the form value from RootFormRegistryService.
|
|
3098
3011
|
*
|
|
3099
|
-
* @param fieldDef The field definition
|
|
3012
|
+
* @param fieldDef The text field definition
|
|
3100
3013
|
* @returns Signal containing Record of input names to values for ngComponentOutlet
|
|
3101
3014
|
*/
|
|
3102
|
-
declare function
|
|
3103
|
-
|
|
3104
|
-
/**
|
|
3105
|
-
* Maps a datepicker field to component inputs.
|
|
3106
|
-
*
|
|
3107
|
-
* Extends the base value field mapper by adding datepicker-specific properties:
|
|
3108
|
-
* - minDate: Minimum selectable date
|
|
3109
|
-
* - maxDate: Maximum selectable date
|
|
3110
|
-
* - startAt: Initial date to display when opening the picker
|
|
3111
|
-
*
|
|
3112
|
-
* @param fieldDef The datepicker field definition
|
|
3113
|
-
* @returns Signal containing Record of input names to values for ngComponentOutlet
|
|
3114
|
-
*/
|
|
3115
|
-
declare function datepickerFieldMapper<TProps>(fieldDef: DatepickerField<TProps>): Signal<Record<string, unknown>>;
|
|
3015
|
+
declare function textFieldMapper(fieldDef: TextField): Signal<Record<string, unknown>>;
|
|
3116
3016
|
|
|
3117
3017
|
/**
|
|
3118
3018
|
* Converts DynamicText (string | Observable | Signal) to Observable<string>
|
|
@@ -3124,65 +3024,6 @@ declare function datepickerFieldMapper<TProps>(fieldDef: DatepickerField<TProps>
|
|
|
3124
3024
|
*/
|
|
3125
3025
|
declare function dynamicTextToObservable(value: DynamicText | undefined, injector?: Injector): Observable<string>;
|
|
3126
3026
|
|
|
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
3027
|
/**
|
|
3187
3028
|
* Pipe that handles dynamic text resolution with support for static strings,
|
|
3188
3029
|
* Observables, and Signals.
|
|
@@ -3231,6 +3072,7 @@ declare class RowFieldComponent {
|
|
|
3231
3072
|
private readonly fieldRegistry;
|
|
3232
3073
|
private readonly injector;
|
|
3233
3074
|
private readonly eventBus;
|
|
3075
|
+
private readonly logger;
|
|
3234
3076
|
field: _angular_core.InputSignal<RowField<readonly _ng_forge_dynamic_forms.RowAllowedChildren[]>>;
|
|
3235
3077
|
key: _angular_core.InputSignal<string>;
|
|
3236
3078
|
readonly disabled: _angular_core.Signal<boolean>;
|
|
@@ -3250,12 +3092,13 @@ declare class RowFieldComponent {
|
|
|
3250
3092
|
* Child fields receive a FIELD_SIGNAL_CONTEXT scoped to this group's form instance.
|
|
3251
3093
|
* Group values are nested under the group's key in the parent form.
|
|
3252
3094
|
*/
|
|
3253
|
-
declare class GroupFieldComponent<TModel = Record<string, unknown>> {
|
|
3095
|
+
declare class GroupFieldComponent<TModel extends Record<string, unknown> = Record<string, unknown>> {
|
|
3254
3096
|
private readonly destroyRef;
|
|
3255
3097
|
private readonly fieldRegistry;
|
|
3256
3098
|
private readonly parentFieldSignalContext;
|
|
3257
3099
|
private readonly injector;
|
|
3258
3100
|
private readonly eventBus;
|
|
3101
|
+
private readonly logger;
|
|
3259
3102
|
private readonly memoizedFlattenFields;
|
|
3260
3103
|
private readonly memoizedKeyBy;
|
|
3261
3104
|
private readonly memoizedDefaultValues;
|
|
@@ -3273,11 +3116,6 @@ declare class GroupFieldComponent<TModel = Record<string, unknown>> {
|
|
|
3273
3116
|
readonly touched: _angular_core.Signal<boolean>;
|
|
3274
3117
|
readonly errors: _angular_core.Signal<_angular_forms_signals.ValidationError.WithField[]>;
|
|
3275
3118
|
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
3119
|
private readonly nestedFieldTree;
|
|
3282
3120
|
private readonly groupInjector;
|
|
3283
3121
|
readonly validityChange: _angular_core.OutputRef<boolean>;
|
|
@@ -3314,12 +3152,13 @@ interface ResolvedArrayItem {
|
|
|
3314
3152
|
* Uses differential updates to optimize rendering - only recreates items when necessary.
|
|
3315
3153
|
* Each item gets a scoped injector with ARRAY_CONTEXT for position-aware operations.
|
|
3316
3154
|
*/
|
|
3317
|
-
declare class ArrayFieldComponent<TModel = Record<string, unknown>> {
|
|
3155
|
+
declare class ArrayFieldComponent<TModel extends Record<string, unknown> = Record<string, unknown>> {
|
|
3318
3156
|
private readonly destroyRef;
|
|
3319
3157
|
private readonly fieldRegistry;
|
|
3320
3158
|
private readonly parentFieldSignalContext;
|
|
3321
3159
|
private readonly parentInjector;
|
|
3322
3160
|
private readonly eventBus;
|
|
3161
|
+
private readonly logger;
|
|
3323
3162
|
field: _angular_core.InputSignal<ArrayField<readonly _ng_forge_dynamic_forms.ArrayAllowedChildren[]>>;
|
|
3324
3163
|
key: _angular_core.InputSignal<string>;
|
|
3325
3164
|
private readonly rawFieldRegistry;
|
|
@@ -3343,143 +3182,49 @@ declare class ArrayFieldComponent<TModel = Record<string, unknown>> {
|
|
|
3343
3182
|
}
|
|
3344
3183
|
|
|
3345
3184
|
/**
|
|
3346
|
-
*
|
|
3347
|
-
*
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3185
|
+
* Type representing a FieldTree for an array.
|
|
3186
|
+
* Extends FieldTree to add numeric indexing for accessing item FieldTrees.
|
|
3187
|
+
*/
|
|
3188
|
+
type ArrayFieldTree<T> = FieldTree<T[]> & {
|
|
3189
|
+
readonly [index: number]: FieldTree<T> | undefined;
|
|
3190
|
+
};
|
|
3191
|
+
/**
|
|
3192
|
+
* Get the length of an array FieldTree.
|
|
3193
|
+
*/
|
|
3194
|
+
declare function getArrayLength<T>(arrayFieldTree: ArrayFieldTree<T>): number;
|
|
3195
|
+
|
|
3196
|
+
/**
|
|
3197
|
+
* Native JavaScript utility functions to replace lodash-es
|
|
3198
|
+
* These are simple implementations for common object manipulation patterns
|
|
3199
|
+
*/
|
|
3200
|
+
/**
|
|
3201
|
+
* Creates a new object without the specified keys
|
|
3202
|
+
* Native replacement for lodash omit()
|
|
3351
3203
|
*
|
|
3352
|
-
* @
|
|
3204
|
+
* @param obj - Source object
|
|
3205
|
+
* @param keys - Keys to omit
|
|
3206
|
+
* @returns New object without specified keys
|
|
3353
3207
|
*
|
|
3354
3208
|
* @example
|
|
3355
3209
|
* ```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
|
-
* }
|
|
3210
|
+
* const obj = { a: 1, b: 2, c: 3 };
|
|
3211
|
+
* omit(obj, ['b']); // { a: 1, c: 3 }
|
|
3367
3212
|
* ```
|
|
3213
|
+
*/
|
|
3214
|
+
declare function omit<T extends object, K extends keyof T>(obj: T, keys: K[]): Omit<T, K>;
|
|
3215
|
+
|
|
3216
|
+
/**
|
|
3217
|
+
* Interpolates {{param}} placeholders in message with error values
|
|
3368
3218
|
*
|
|
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
|
-
* ```
|
|
3219
|
+
* @param message - Message template with {{param}} placeholders
|
|
3220
|
+
* @param error - Validation error containing parameter values
|
|
3221
|
+
* @returns Message with interpolated parameters
|
|
3381
3222
|
*
|
|
3382
|
-
* @
|
|
3223
|
+
* @example
|
|
3224
|
+
* interpolateParams("Min value is {{min}}", { kind: 'min', min: 5 })
|
|
3225
|
+
* // Returns: "Min value is 5"
|
|
3383
3226
|
*/
|
|
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
|
-
};
|
|
3227
|
+
declare function interpolateParams(message: string, error: ValidationError): string;
|
|
3483
3228
|
|
|
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,
|
|
3229
|
+
export { ARRAY_CONTEXT, AddArrayItemEvent, ArrayFieldComponent, BUILT_IN_FIELDS, DYNAMIC_FORM_LOGGER, DynamicForm, DynamicTextPipe, EventBus, FIELD_REGISTRY, FIELD_SIGNAL_CONTEXT, FormClearEvent, FormResetEvent, GroupFieldComponent, LogLevel, 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, withLogger };
|
|
3230
|
+
export type { ArrayAllowedChildren, ArrayContext, ArrayField, ArrayFieldTree, ArrayItemContext, AsyncCustomValidator, AsyncValidatorConfig, AvailableFieldTypes, BaseCheckedField, BaseValidatorConfig, BaseValueField, BuiltInValidatorConfig, ButtonLogicContext, CheckedFieldComponent, ConditionalExpression, ContainerFieldTypes, CustomFnConfig, CustomValidator, CustomValidatorConfig, DynamicFormFieldRegistry, DynamicFormLogger, 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, LoggerFeatureOptions, 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 };
|