@ng-forge/dynamic-forms 1.0.0-rc.1 → 1.0.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. package/README.md +16 -0
  2. package/fesm2022/{ng-forge-dynamic-forms-array-field.component-By12r5Cj.mjs → ng-forge-dynamic-forms-array-field.component-8rodySeE.mjs} +2 -2
  3. package/fesm2022/{ng-forge-dynamic-forms-array-field.component-By12r5Cj.mjs.map → ng-forge-dynamic-forms-array-field.component-8rodySeE.mjs.map} +1 -1
  4. package/fesm2022/{ng-forge-dynamic-forms-bootstrap-derivation-orchestrator-QJzwEYSj.mjs → ng-forge-dynamic-forms-bootstrap-derivation-orchestrator-C8kpF0tw.mjs} +2 -2
  5. package/fesm2022/{ng-forge-dynamic-forms-bootstrap-derivation-orchestrator-QJzwEYSj.mjs.map → ng-forge-dynamic-forms-bootstrap-derivation-orchestrator-C8kpF0tw.mjs.map} +1 -1
  6. package/fesm2022/{ng-forge-dynamic-forms-container-field.component-BGFguOa9.mjs → ng-forge-dynamic-forms-container-field.component-DFgjWEZN.mjs} +2 -2
  7. package/fesm2022/{ng-forge-dynamic-forms-container-field.component-BGFguOa9.mjs.map → ng-forge-dynamic-forms-container-field.component-DFgjWEZN.mjs.map} +1 -1
  8. package/fesm2022/{ng-forge-dynamic-forms-group-field.component-Bz4GD8Hy.mjs → ng-forge-dynamic-forms-group-field.component-Ca4AqdZu.mjs} +2 -2
  9. package/fesm2022/ng-forge-dynamic-forms-group-field.component-Ca4AqdZu.mjs.map +1 -0
  10. package/fesm2022/ng-forge-dynamic-forms-integration.mjs +6 -6
  11. package/fesm2022/ng-forge-dynamic-forms-integration.mjs.map +1 -1
  12. package/fesm2022/ng-forge-dynamic-forms-internal.mjs +281 -42
  13. package/fesm2022/ng-forge-dynamic-forms-internal.mjs.map +1 -1
  14. package/fesm2022/{ng-forge-dynamic-forms-ng-forge-dynamic-forms-DTkMZcnb.mjs → ng-forge-dynamic-forms-ng-forge-dynamic-forms-BJi_rtey.mjs} +86 -407
  15. package/fesm2022/ng-forge-dynamic-forms-ng-forge-dynamic-forms-BJi_rtey.mjs.map +1 -0
  16. package/fesm2022/{ng-forge-dynamic-forms-page-field.component-CjCd5Byo.mjs → ng-forge-dynamic-forms-page-field.component-IsAtMNjD.mjs} +2 -2
  17. package/fesm2022/{ng-forge-dynamic-forms-page-field.component-CjCd5Byo.mjs.map → ng-forge-dynamic-forms-page-field.component-IsAtMNjD.mjs.map} +1 -1
  18. package/fesm2022/ng-forge-dynamic-forms.mjs +2 -2
  19. package/package.json +1 -1
  20. package/types/ng-forge-dynamic-forms-integration.d.ts +5 -5
  21. package/types/ng-forge-dynamic-forms-internal.d.ts +1947 -1769
  22. package/types/ng-forge-dynamic-forms.d.ts +57 -266
  23. package/fesm2022/ng-forge-dynamic-forms-group-field.component-Bz4GD8Hy.mjs.map +0 -1
  24. package/fesm2022/ng-forge-dynamic-forms-ng-forge-dynamic-forms-DTkMZcnb.mjs.map +0 -1
@@ -1,10 +1,190 @@
1
+ import * as _ng_forge_dynamic_forms_internal from '@ng-forge/dynamic-forms/internal';
2
+ import * as i0 from '@angular/core';
3
+ import { Signal, Type, ResourceRef, ViewContainerRef, InjectionToken, WritableSignal, Injector, TemplateRef, PipeTransform, Resource } from '@angular/core';
1
4
  import { Observable, OperatorFunction } from 'rxjs';
2
5
  import { FieldContext, TreeValidationResult, ValidationError as ValidationError$1, FieldTree, ReadonlyFieldState, LogicFn, SchemaPath, SchemaPathTree } from '@angular/forms/signals';
3
- import * as i0 from '@angular/core';
4
- import { Signal, ResourceRef, Injector, WritableSignal, InjectionToken, Type, ViewContainerRef, TemplateRef, PipeTransform, Resource } from '@angular/core';
5
- import * as _ng_forge_dynamic_forms_internal from '@ng-forge/dynamic-forms/internal';
6
6
  import { FormSchema } from '@ng-forge/dynamic-forms/schema';
7
7
 
8
+ type DynamicText = string | Observable<string> | Signal<string>;
9
+
10
+ /** Generic reactive value — a static value, an Angular Signal, or an RxJS Observable. */
11
+ type DynamicValue<T> = T | Signal<T> | Observable<T>;
12
+
13
+ /** Universal addon slot names supported by every adapter. */
14
+ type CommonAddonSlot = 'prefix' | 'suffix';
15
+ /** Module-augmentable registry of adapter-specific addon slot names. */
16
+ interface DynamicFormAddonSlotRegistry {
17
+ }
18
+ /**
19
+ * Union of every valid addon slot — universal slots plus any registered via
20
+ * {@link DynamicFormAddonSlotRegistry} module augmentation.
21
+ */
22
+ type AddonSlot = CommonAddonSlot | keyof DynamicFormAddonSlotRegistry;
23
+
24
+ /** Base shape every addon type extends. */
25
+ interface BaseAddon<TSlot extends AddonSlot = AddonSlot> {
26
+ /** Slot to render this addon in. */
27
+ readonly slot: TSlot;
28
+ /** CSS class applied to the addon host element. */
29
+ readonly className?: string;
30
+ /** Reactive visibility — when `true`, the addon is removed from layout. */
31
+ readonly hidden?: DynamicValue<boolean>;
32
+ /** Reactive disabled state — primarily relevant for interactive types. */
33
+ readonly disabled?: DynamicValue<boolean>;
34
+ }
35
+ /** Module-augmentable registry of addon types. */
36
+ interface DynamicFormAddonRegistry {
37
+ text: TextAddon;
38
+ template: TemplateAddon;
39
+ component: ComponentAddon;
40
+ }
41
+ /** Union of every registered addon shape. */
42
+ type AnyAddon = DynamicFormAddonRegistry[keyof DynamicFormAddonRegistry];
43
+ /** Renders text content inline. */
44
+ interface TextAddon extends BaseAddon {
45
+ readonly type: 'text';
46
+ readonly text: DynamicText;
47
+ }
48
+ /** Renders a named `<ng-template>` projected into the host `<df-dynamic-form>`. */
49
+ interface TemplateAddon extends BaseAddon {
50
+ readonly type: 'template';
51
+ readonly templateKey: string;
52
+ }
53
+ /**
54
+ * Renders an arbitrary Angular component as the addon body.
55
+ *
56
+ * @codeOnly The `component` loader is a function and cannot survive
57
+ * `JSON.stringify`/`parse`. The lenient validator drops this type when the
58
+ * config originated from JSON (set via `sanitizeFormConfig({ source: 'json' })`).
59
+ */
60
+ interface ComponentAddon extends BaseAddon {
61
+ readonly type: 'component';
62
+ readonly component: () => Promise<Type<unknown> | {
63
+ default: Type<unknown>;
64
+ }>;
65
+ readonly inputs?: Record<string, unknown>;
66
+ }
67
+
68
+ type WithInputSignals<T> = {
69
+ readonly [K in keyof T]-?: Signal<T[K]>;
70
+ };
71
+
72
+ type Prettify<T> = {
73
+ [K in keyof T]: T[K];
74
+ } & {};
75
+
76
+ /** Base interface for native HTML attributes that can be passed to form field elements. */
77
+ interface FieldMeta {
78
+ /** Allows any data-* attribute */
79
+ [key: `data-${string}`]: string | undefined;
80
+ /** Allows any aria-* attribute */
81
+ [key: `aria-${string}`]: string | boolean | undefined;
82
+ /** Allows additional custom attributes as escape hatch */
83
+ [key: string]: string | number | boolean | undefined;
84
+ }
85
+
86
+ /**
87
+ * Base interface for all dynamic form field definitions.
88
+ *
89
+ * @typeParam TProps - Field-specific properties interface
90
+ * @typeParam TMeta - Native HTML attributes interface (extends FieldMeta)
91
+ */
92
+ interface FieldDef<TProps, TMeta extends FieldMeta = FieldMeta> {
93
+ /** Unique field identifier used for form binding and value tracking. */
94
+ key: string;
95
+ /** Field type identifier for component selection. */
96
+ type: RegisteredFieldTypes['type'] | (string & {});
97
+ /** Human-readable field label displayed to users. */
98
+ label?: DynamicText;
99
+ /** Field-specific properties and configuration options. */
100
+ props?: TProps;
101
+ /** Native HTML attributes to pass through to the underlying element. */
102
+ meta?: TMeta;
103
+ /** Additional CSS classes for custom styling. */
104
+ className?: string;
105
+ /**
106
+ * Whether the field is disabled and cannot be interacted with.
107
+ *
108
+ * @value false
109
+ */
110
+ disabled?: boolean;
111
+ /**
112
+ * Whether the field is read-only.
113
+ *
114
+ * @value false
115
+ */
116
+ readonly?: boolean;
117
+ /**
118
+ * Whether the field is hidden from view.
119
+ *
120
+ * @value false
121
+ */
122
+ hidden?: boolean;
123
+ /** Tab index for keyboard navigation. */
124
+ tabIndex?: number | undefined;
125
+ /**
126
+ * Whether to exclude this field's value from submission output when hidden.
127
+ *
128
+ * @default undefined (uses form-level or global setting)
129
+ */
130
+ excludeValueIfHidden?: boolean;
131
+ /**
132
+ * Whether to exclude this field's value from submission output when disabled.
133
+ *
134
+ * @default undefined (uses form-level or global setting)
135
+ */
136
+ excludeValueIfDisabled?: boolean;
137
+ /**
138
+ * Whether to exclude this field's value from submission output when readonly.
139
+ *
140
+ * @default undefined (uses form-level or global setting)
141
+ */
142
+ excludeValueIfReadonly?: boolean;
143
+ /**
144
+ * Whether to run validation when this field is hidden — statically (`hidden: true`),
145
+ * via a `hidden` logic rule, or via any hidden ancestor.
146
+ *
147
+ * @default undefined — inherits from parent / form / global default (which is `false`)
148
+ */
149
+ validateWhenHidden?: boolean;
150
+ /**
151
+ * Column sizing configuration for responsive grid layout.
152
+ *
153
+ * @value 12
154
+ */
155
+ col?: number;
156
+ /** Wrapper components to chain around this field. */
157
+ wrappers?: readonly WrapperConfig[] | null;
158
+ /**
159
+ * Skip the auto-association layer (`WrapperTypeDefinition.types`) while
160
+ * keeping form-level defaults and any field-level `wrappers`. Use when a
161
+ * global wrapper auto-applies to this field type but isn't wanted here.
162
+ */
163
+ skipAutoWrappers?: boolean;
164
+ /**
165
+ * Skip the form-level `defaultWrappers` layer while keeping auto-associations
166
+ * and any field-level `wrappers`.
167
+ */
168
+ skipDefaultWrappers?: boolean;
169
+ /** Addons rendered inside this field's slots (typically `prefix` / `suffix`). */
170
+ addons?: ReadonlyArray<AnyAddon>;
171
+ }
172
+ type IncludedKeys = 'label' | 'className' | 'hidden' | 'tabIndex';
173
+ /**
174
+ * Type utility for extracting component input properties from field definitions.
175
+ *
176
+ * @Component({...})
177
+ * export class MyFieldComponent implements FieldComponent<MyFieldDef> {
178
+ * label = input<string>();
179
+ * className = input<string>();
180
+ * hidden = input<boolean>();
181
+ * tabIndex = input<number>();
182
+ * }
183
+ * ```
184
+ * @typeParam T - Field definition type to extract properties from
185
+ */
186
+ type FieldComponent<T extends FieldDef<unknown, FieldMeta>> = Prettify<WithInputSignals<Pick<T, IncludedKeys>>>;
187
+
8
188
  /**
9
189
  * Interface for dynamic forms logger implementations.
10
190
  * Allows custom logging integrations (Sentry, DataDog, etc.)
@@ -257,370 +437,438 @@ interface OrCondition {
257
437
  /** Discriminated union of all conditional expression types. */
258
438
  type ConditionalExpression = FieldValueCondition | CustomCondition | JavascriptCondition | HttpCondition | AsyncCondition | AndCondition | OrCondition;
259
439
 
260
- /** Special form-state conditions for button disabled logic. */
261
- type FormStateCondition =
262
- /** True when form.valid() === false */
263
- 'formInvalid'
264
- /** True when form.submitting() === true */
265
- | 'formSubmitting'
266
- /** True when fields on the current page are invalid (for paged forms) */
267
- | 'pageInvalid';
268
- /** Logic type for controlling field state (hidden, readonly, disabled, required). */
269
- type StateLogicType = 'hidden' | 'readonly' | 'disabled' | 'required';
270
440
  /**
271
- * Base configuration for conditional field state logic.
272
- *
273
- * @internal
441
+ * Logic configuration for container fields (page, group, row, array).
442
+ * Containers only support the 'hidden' logic type since they are layout containers,
443
+ * not form controls (they can't be readonly, disabled, or required).
274
444
  */
275
- interface BaseStateLogicConfig {
276
- /** Logic type identifier for field state. */
277
- type: StateLogicType;
278
- /** Condition that determines when this logic applies. */
279
- condition: ConditionalExpression | boolean | FormStateCondition;
445
+ interface ContainerLogicConfig {
446
+ /** Only 'hidden' is supported for container fields */
447
+ type: 'hidden';
448
+ /**
449
+ * Condition that determines when this container is hidden.
450
+ * Can be a boolean or a conditional expression evaluated against form values.
451
+ */
452
+ condition: ConditionalExpression | boolean;
280
453
  }
454
+
281
455
  /**
282
- * State logic that evaluates immediately on change (default).
283
- *
284
- * @internal
456
+ * Row field interface for creating horizontal layouts.
457
+ * A row is a synthetic field type that resolves to a Container at runtime,
458
+ * with a synthesized `{ type: 'row' }` wrapper applied for layout. The row
459
+ * itself does not hold a value — its children flatten into the parent form.
285
460
  */
286
- interface ImmediateStateLogicConfig extends BaseStateLogicConfig {
461
+ interface RowField<TFields extends readonly RowAllowedChildren[] = readonly RowAllowedChildren[]> extends FieldDef<never> {
462
+ type: 'row';
463
+ /** Child definitions to render within this row */
464
+ readonly fields: TFields;
465
+ /** Row fields do not have a label property * */
466
+ readonly label?: never;
467
+ /** Rows do not support meta - they have no native form element * */
468
+ readonly meta?: never;
287
469
  /**
288
- * Trigger for immediate evaluation.
289
- *
290
- * @default 'onChange'
470
+ * Logic configurations for conditional row visibility.
471
+ * Only 'hidden' type logic is supported for rows.
291
472
  */
292
- trigger?: 'onChange';
293
- /** Not allowed for onChange trigger */
294
- debounceMs?: never;
473
+ readonly logic?: ContainerLogicConfig[];
295
474
  }
475
+ /** Type guard for RowField with proper type narrowing */
476
+ declare function isRowField(field: FieldDef<any>): field is RowField;
477
+ type RowComponent = FieldComponent<RowField<RowAllowedChildren[]>>;
478
+
296
479
  /**
297
- * State logic that evaluates after a debounce period.
298
- *
299
- * @internal
480
+ * Group field interface for creating logical field groupings that map to object values
481
+ * Groups create nested form structures where child field values are collected into an object
482
+ * This is a programmatic grouping only - users cannot customize this field type
300
483
  */
301
- interface DebouncedStateLogicConfig extends BaseStateLogicConfig {
484
+ interface GroupField<TFields extends readonly GroupAllowedChildren[] = readonly GroupAllowedChildren[]> extends FieldDef<never> {
485
+ type: 'group';
486
+ readonly fields: TFields;
487
+ /** Groups do not have a label property - they are logical containers only * */
488
+ readonly label?: never;
489
+ /** Groups do not support meta - they have no native form element * */
490
+ readonly meta?: never;
302
491
  /**
303
- * Trigger for debounced evaluation.
304
- * Evaluates after the value has stabilized for the debounce duration.
492
+ * Logic configurations for conditional group visibility.
493
+ * Only 'hidden' type logic is supported for groups.
305
494
  */
306
- trigger: 'debounced';
307
- /**
308
- * Debounce duration in milliseconds.
309
- *
310
- * @default 500
311
- */
312
- debounceMs?: number;
495
+ readonly logic?: ContainerLogicConfig[];
313
496
  }
314
- /** Configuration for conditional field state logic. */
315
- type StateLogicConfig = ImmediateStateLogicConfig | DebouncedStateLogicConfig;
316
- /** Trigger timing for when logic is evaluated. */
317
- type LogicTrigger = 'onChange' | 'debounced';
318
- /**
319
- * Shared fields that appear on all derivation logic config variants.
320
- *
321
- * @internal
322
- */
323
- interface SharedDerivationFields {
324
- /** Logic type identifier for value derivation. */
325
- type: 'derivation';
326
- /** Target property name for property derivation. */
327
- targetProperty?: string;
328
- /** Optional name for this derivation for debugging purposes. */
329
- debugName?: string;
330
- /** Condition that determines when this derivation applies. */
331
- condition?: ConditionalExpression | boolean;
497
+ /** Type guard for GroupField with proper type narrowing */
498
+ declare function isGroupField(field: FieldDef<any>): field is GroupField;
499
+ type GroupComponent<T extends GroupAllowedChildren[]> = FieldComponent<GroupField<T>>;
500
+
501
+ /** Container field interface for wrapping child fields with UI chrome. */
502
+ interface ContainerField<TFields extends readonly ContainerAllowedChildren[] = readonly ContainerAllowedChildren[], TWrapperConfigs extends readonly WrapperConfig[] = readonly WrapperConfig[]> extends FieldDef<never> {
503
+ type: 'container';
504
+ /** Child definitions to render within this container */
505
+ readonly fields: TFields;
332
506
  /**
333
- * When true, the derivation stops running after the user manually
334
- * edits the target field.
507
+ * Wrapper components to chain around the children.
508
+ * Applied outermost-first: the first wrapper in the array is the outermost.
509
+ * Each wrapper component receives the subsequent wrapper (or children) inside
510
+ * its `#fieldComponent` ViewContainerRef slot.
335
511
  */
336
- stopOnUserOverride?: boolean;
512
+ readonly wrappers: TWrapperConfigs;
513
+ /** Container fields do not have a label property */
514
+ readonly label?: never;
515
+ /** Containers do not support meta — they have no native form element */
516
+ readonly meta?: never;
337
517
  /**
338
- * When true (and `stopOnUserOverride` is also true), clears the
339
- * user-override flag when any dependency of this derivation changes,
340
- * allowing the derivation to run again.
518
+ * Logic configurations for conditional container visibility.
519
+ * Only 'hidden' type logic is supported for containers.
341
520
  */
342
- reEngageOnDependencyChange?: boolean;
521
+ readonly logic?: ContainerLogicConfig[];
343
522
  }
523
+ /** Type guard for ContainerField with proper type narrowing. */
524
+ declare function isGenericContainerField(field: FieldDef<any>): field is ContainerField;
525
+ type ContainerComponent = FieldComponent<ContainerField<ContainerAllowedChildren[]>>;
526
+
344
527
  /**
345
- * Trigger variants for derivation timing.
346
- *
347
- * @internal
528
+ * Type constraints for field nesting rules
529
+ * These ensure that container fields can only contain valid child field types
348
530
  */
349
- type ImmediateDerivationTrigger = {
350
- trigger?: 'onChange';
351
- debounceMs?: never;
352
- };
353
- type DebouncedDerivationTrigger = {
354
- trigger: 'debounced';
355
- debounceMs?: number;
356
- };
357
531
  /**
358
- * Base for HTTP derivations. `source: 'http'` is required.
359
- * TypeScript enforces `dependsOn` and `responseExpression` at the type level.
360
- *
361
- * @internal
532
+ * Fields that are allowed as children of Page fields
533
+ * Pages can contain: rows, groups, arrays, and leaf fields (but NOT other pages)
362
534
  */
363
- interface HttpDerivationBase extends SharedDerivationFields {
364
- /** Identifies this derivation as HTTP-driven. */
365
- source: 'http';
366
- /** Forbidden on HTTP source */
367
- fn?: never;
368
- /** Forbidden on HTTP source */
369
- asyncFn?: never;
370
- /** HTTP request configuration for server-driven derivations. */
371
- http: HttpRequestConfig;
372
- /**
373
- * Explicit field dependencies. Required for HTTP derivations to prevent
374
- * wildcard triggering on every keystroke.
375
- */
376
- dependsOn: string[];
377
- /** Expression to extract the derived value from the HTTP response. */
378
- responseExpression: string;
379
- value?: never;
380
- expression?: never;
381
- functionName?: never;
382
- asyncFunctionName?: never;
383
- }
535
+ type PageAllowedChildren = LeafFieldTypes | RowField | GroupField | ArrayField | SimplifiedArrayField | ContainerField;
384
536
  /**
385
- * Shared fields for both branches of {@link AsyncFunctionDerivationBase}.
386
- *
387
- * @internal
537
+ * Fields that are allowed as children of Group fields
538
+ * Groups can contain: rows, arrays, and leaf fields (but NOT pages or other groups)
388
539
  */
389
- interface AsyncFunctionDerivationShared extends SharedDerivationFields {
390
- /** Identifies this derivation as async-function-driven. */
391
- source: 'asyncFunction';
392
- /** Forbidden on asyncFunction source */
393
- fn?: never;
394
- /**
395
- * Explicit field dependencies. Required for async derivations to prevent
396
- * wildcard triggering on every form change.
397
- */
398
- dependsOn: string[];
399
- value?: never;
400
- expression?: never;
401
- functionName?: never;
402
- http?: never;
403
- responseExpression?: never;
404
- }
540
+ type GroupAllowedChildren = LeafFieldTypes | RowField | ArrayField | SimplifiedArrayField | ContainerField;
405
541
  /**
406
- * Base for async function derivations. `source: 'asyncFunction'` is required.
407
- * TypeScript enforces `dependsOn` at the type level, and `asyncFunctionName` /
408
- * `asyncFn` are mutually exclusive (XOR).
409
- *
410
- * @internal
542
+ * Fields that are allowed as children of Array fields
543
+ * Arrays can contain: rows, groups, and leaf fields (but NOT pages or other arrays)
544
+ * Groups are used for creating object arrays where each array item is an object
411
545
  */
412
- type AsyncFunctionDerivationBase = (AsyncFunctionDerivationShared & {
413
- /** Name of a registered async derivation function. */
414
- asyncFunctionName: string;
415
- /** Inline form is forbidden when `asyncFunctionName` is set */
416
- asyncFn?: never;
417
- }) | (AsyncFunctionDerivationShared & {
418
- /** Inline async derivation function. Mutually exclusive with `asyncFunctionName`. */
419
- asyncFn: AsyncDerivationFunction;
420
- /** Registered form is forbidden when `asyncFn` is set */
421
- asyncFunctionName?: never;
422
- });
546
+ type ArrayAllowedChildren = LeafFieldTypes | RowField | GroupField | ContainerField;
423
547
  /**
424
- * Base for expression derivations.
425
- *
426
- * @internal
548
+ * Fields that are allowed as children of Container fields.
549
+ * Containers are pure layout primitives that flatten their children into the
550
+ * parent form, so most registered field types may appear inside — including
551
+ * hidden fields and other containers — but NOT pages.
427
552
  */
428
- interface ExpressionDerivationBase extends SharedDerivationFields {
429
- source?: never;
430
- /** Forbidden on expression mode */
431
- fn?: never;
432
- /** Forbidden on expression mode */
433
- asyncFn?: never;
434
- /** JavaScript expression to evaluate for the derived value. */
435
- expression: string;
436
- /** Explicit field dependencies for expressions. */
437
- dependsOn?: string[];
438
- value?: never;
439
- functionName?: never;
440
- http?: never;
441
- asyncFunctionName?: never;
442
- responseExpression?: never;
443
- }
553
+ type ContainerAllowedChildren = LeafFieldTypes | RowField | GroupField | ArrayField | SimplifiedArrayField | ContainerField;
444
554
  /**
445
- * Base for value derivations.
446
- *
447
- * @internal
555
+ * Row is a synthetic field type that resolves to a Container at runtime, so
556
+ * it accepts the same children as a Container.
448
557
  */
449
- interface ValueDerivationBase extends SharedDerivationFields {
450
- source?: never;
451
- /** Forbidden on value mode */
452
- fn?: never;
453
- /** Forbidden on value mode */
454
- asyncFn?: never;
455
- /** Static value to set on this field. */
456
- value: unknown;
457
- /** Explicit field dependencies for value derivations. */
458
- dependsOn?: string[];
459
- expression?: never;
460
- functionName?: never;
461
- http?: never;
462
- asyncFunctionName?: never;
463
- responseExpression?: never;
464
- }
558
+ type RowAllowedChildren = ContainerAllowedChildren;
559
+
465
560
  /**
466
- * Shared fields for both branches of {@link FunctionDerivationBase}.
467
- *
468
- * @internal
561
+ * An array item template is an array of allowed children that defines one OBJECT array item's fields.
562
+ * Used for object arrays where each item is `{ key1: value1, key2: value2, ... }`.
469
563
  */
470
- interface FunctionDerivationShared extends SharedDerivationFields {
471
- source?: never;
472
- /** Forbidden on function-derivation mode */
473
- asyncFn?: never;
474
- /** Explicit field dependencies for function derivations. */
475
- dependsOn?: string[];
476
- value?: never;
477
- expression?: never;
478
- http?: never;
479
- asyncFunctionName?: never;
480
- responseExpression?: never;
481
- }
564
+ type ArrayItemTemplate = readonly ArrayAllowedChildren[];
482
565
  /**
483
- * Base for custom sync function derivations. `functionName` and `fn` are
484
- * mutually exclusive (XOR).
485
- *
486
- * @internal
566
+ * An array item definition can be either:
567
+ * - A single field (ArrayAllowedChildren) for PRIMITIVE array items - extracts field value directly
568
+ * - An array of fields (ArrayItemTemplate) for OBJECT array items - merges fields into object
487
569
  */
488
- type FunctionDerivationBase = (FunctionDerivationShared & {
489
- /** Name of a registered custom derivation function. */
490
- functionName: string;
491
- /** Inline form is forbidden when `functionName` is set */
492
- fn?: never;
493
- }) | (FunctionDerivationShared & {
494
- /** Inline custom derivation function. Mutually exclusive with `functionName`. */
495
- fn: CustomFunction;
496
- /** Registered form is forbidden when `fn` is set */
497
- functionName?: never;
498
- });
570
+ type ArrayItemDefinition = ArrayAllowedChildren | ArrayItemTemplate;
571
+ /** Array field interface for creating dynamic field collections that map to array values. */
572
+ interface ArrayField<TFields extends readonly ArrayItemDefinition[] = readonly ArrayItemDefinition[]> extends FieldDef<never> {
573
+ type: 'array';
574
+ /**
575
+ * Array of item definitions. Each element defines one array item:
576
+ * - Single FieldDef = primitive item (field's value is extracted directly)
577
+ * - Array of FieldDefs = object item (fields are merged into an object)
578
+ * - Empty array `[]` = no initial items (add via buttons with explicit templates)
579
+ * - Items can have different configurations (heterogeneous arrays supported)
580
+ * - Initial values are set via `value` property on each field definition
581
+ */
582
+ readonly fields: TFields;
583
+ /** Array fields do not have a label property * */
584
+ readonly label?: never;
585
+ /** Arrays do not support meta - they have no native form element * */
586
+ readonly meta?: never;
587
+ /**
588
+ * Logic configurations for conditional array visibility.
589
+ * Only 'hidden' type logic is supported for arrays.
590
+ */
591
+ readonly logic?: ContainerLogicConfig[];
592
+ /**
593
+ * Minimum number of items required in the array.
594
+ * Validation fails if the array has fewer items than this value.
595
+ */
596
+ readonly minLength?: number;
597
+ /**
598
+ * Maximum number of items allowed in the array.
599
+ * Validation fails if the array has more items than this value.
600
+ */
601
+ readonly maxLength?: number;
602
+ }
499
603
  /**
500
- * HTTP derivation that evaluates immediately on change (default).
501
- *
502
- * @internal
503
- */
504
- type OnChangeHttpDerivationLogicConfig = HttpDerivationBase & ImmediateDerivationTrigger;
505
- /**
506
- * HTTP derivation that evaluates after a debounce period.
507
- *
508
- * @internal
509
- */
510
- type DebouncedHttpDerivationLogicConfig = HttpDerivationBase & DebouncedDerivationTrigger;
511
- /**
512
- * Async function derivation that evaluates immediately on change (default).
513
- *
514
- * @internal
515
- */
516
- type OnChangeAsyncFunctionDerivationLogicConfig = AsyncFunctionDerivationBase & ImmediateDerivationTrigger;
517
- /**
518
- * Async function derivation that evaluates after a debounce period.
519
- *
520
- * @internal
604
+ * Type guard for ArrayField with proper type narrowing.
605
+ * Validates that the field is an array type with a fields property that is an array.
606
+ * Fields can contain either single FieldDefs (primitive items) or arrays of FieldDefs (object items).
521
607
  */
522
- type DebouncedAsyncFunctionDerivationLogicConfig = AsyncFunctionDerivationBase & DebouncedDerivationTrigger;
608
+ declare function isArrayField(field: FieldDef<any>): field is ArrayField;
609
+ type ArrayComponent<T extends ArrayItemTemplate[]> = FieldComponent<ArrayField<T>>;
610
+ /** Configuration for auto-generated add/remove buttons in simplified array fields. */
611
+ interface ArrayButtonConfig {
612
+ /** Custom label for the button */
613
+ readonly label?: string;
614
+ /** Additional properties passed to the button component */
615
+ readonly props?: Record<string, unknown>;
616
+ }
617
+ /** Simplified array field interface for common use cases. */
618
+ interface SimplifiedArrayField extends FieldDef<never> {
619
+ type: 'array';
620
+ /**
621
+ * Template defining the structure of a single array item.
622
+ * - Single field (ArrayAllowedChildren) → primitive array (each item is a single value)
623
+ * - Array of fields (readonly ArrayAllowedChildren[]) → object array (each item is an object)
624
+ */
625
+ readonly template: ArrayAllowedChildren | readonly ArrayAllowedChildren[];
626
+ /** Initial values for the array. Each element creates one array item. */
627
+ readonly value?: readonly unknown[];
628
+ /**
629
+ * Configuration for the auto-generated "Add" button, or `false` to disable it.
630
+ * Defaults to a button with label "Add".
631
+ */
632
+ readonly addButton?: ArrayButtonConfig | false;
633
+ /**
634
+ * Configuration for the auto-generated "Remove" button on each item, or `false` to disable it.
635
+ * Defaults to a button with label "Remove".
636
+ */
637
+ readonly removeButton?: ArrayButtonConfig | false;
638
+ /** Simplified arrays do not support the label property */
639
+ readonly label?: never;
640
+ /** Simplified arrays do not support meta */
641
+ readonly meta?: never;
642
+ /**
643
+ * Logic configurations for conditional array visibility.
644
+ * Only 'hidden' type logic is supported for arrays.
645
+ */
646
+ readonly logic?: ContainerLogicConfig[];
647
+ /**
648
+ * Minimum number of items required in the array.
649
+ * Validation fails if the array has fewer items than this value.
650
+ */
651
+ readonly minLength?: number;
652
+ /**
653
+ * Maximum number of items allowed in the array.
654
+ * Validation fails if the array has more items than this value.
655
+ */
656
+ readonly maxLength?: number;
657
+ /** Mutually exclusive with `template` — use `fields` for the full API instead */
658
+ readonly fields?: never;
659
+ }
523
660
  /**
524
- * Expression derivation that evaluates immediately on change (default).
525
- *
526
- * @internal
661
+ * Type guard for SimplifiedArrayField.
662
+ * Checks for `type: 'array'` with a `template` property (discriminant from full ArrayField).
527
663
  */
528
- type OnChangeExpressionDerivationLogicConfig = ExpressionDerivationBase & ImmediateDerivationTrigger;
664
+ declare function isSimplifiedArrayField(field: FieldDef<any>): field is SimplifiedArrayField;
665
+
529
666
  /**
530
- * Expression derivation that evaluates after a debounce period.
531
- *
532
- * @internal
667
+ * Scalar types supported by hidden fields.
668
+ * These are the primitive value types that can be stored.
533
669
  */
534
- type DebouncedExpressionDerivationLogicConfig = ExpressionDerivationBase & DebouncedDerivationTrigger;
670
+ type HiddenScalar = string | number | boolean;
535
671
  /**
536
- * Value derivation that evaluates immediately on change (default).
537
- *
538
- * @internal
672
+ * All value types supported by hidden fields.
673
+ * Supports both scalar values and arrays of scalars for storing
674
+ * multiple IDs or similar data.
539
675
  */
540
- type OnChangeValueDerivationLogicConfig = ValueDerivationBase & ImmediateDerivationTrigger;
676
+ type HiddenValue = HiddenScalar | HiddenScalar[];
541
677
  /**
542
- * Value derivation that evaluates after a debounce period.
678
+ * Hidden field definition for storing values without rendering UI.
543
679
  *
544
- * @internal
680
+ * @typeParam TValue - The type of value stored (must be HiddenValue compatible)
545
681
  */
546
- type DebouncedValueDerivationLogicConfig = ValueDerivationBase & DebouncedDerivationTrigger;
682
+ interface HiddenField<TValue extends HiddenValue = HiddenValue> extends FieldDef<never> {
683
+ /** Discriminant for hidden field type */
684
+ type: 'hidden';
685
+ /**
686
+ * The value to store in the form.
687
+ * This is required - a hidden field without a value serves no purpose.
688
+ */
689
+ value: TValue;
690
+ }
547
691
  /**
548
- * Function derivation that evaluates immediately on change (default).
692
+ * Type guard to check if a field is a hidden field.
549
693
  *
550
- * @internal
694
+ * @param field - The field to check
695
+ * @returns True if the field is a HiddenField
551
696
  */
552
- type OnChangeFunctionDerivationLogicConfig = FunctionDerivationBase & ImmediateDerivationTrigger;
697
+ declare function isHiddenField(field: FieldDef<unknown>): field is HiddenField;
698
+
553
699
  /**
554
- * Function derivation that evaluates after a debounce period.
555
- *
556
- * @internal
700
+ * Page field interface for creating top-level page layouts
701
+ * This is a special field type that contains other field definitions
702
+ * The page itself doesn't have a value - it's a layout container like row
703
+ * Pages can only be used at the top level and cannot be nested
704
+ * This is a programmatic field type only - users cannot customize this field type
557
705
  */
558
- type DebouncedFunctionDerivationLogicConfig = FunctionDerivationBase & DebouncedDerivationTrigger;
559
- /** Configuration for value derivation logic. */
560
- type DerivationLogicConfig = OnChangeHttpDerivationLogicConfig | DebouncedHttpDerivationLogicConfig | OnChangeAsyncFunctionDerivationLogicConfig | DebouncedAsyncFunctionDerivationLogicConfig | OnChangeExpressionDerivationLogicConfig | DebouncedExpressionDerivationLogicConfig | OnChangeValueDerivationLogicConfig | DebouncedValueDerivationLogicConfig | OnChangeFunctionDerivationLogicConfig | DebouncedFunctionDerivationLogicConfig;
561
- /** Union type for all logic configurations. */
562
- type LogicConfig = StateLogicConfig | DerivationLogicConfig;
563
- /** Log level for derivation debug output. */
564
- type DerivationLogLevel = 'none' | 'summary' | 'verbose';
565
- /** Configuration for derivation debug logging. */
566
- interface DerivationLogConfig {
567
- /** Log level for derivation debugging. Defaults to 'none'. */
568
- level: DerivationLogLevel;
706
+ interface PageField<TFields extends readonly PageAllowedChildren[] = PageAllowedChildren[]> extends FieldDef<never> {
707
+ type: 'page';
708
+ /** Child field definitions to render within this page */
709
+ readonly fields: TFields;
710
+ /** Page fields do not have a label property * */
711
+ readonly label?: never;
712
+ /** Pages do not support meta - they have no native form element * */
713
+ readonly meta?: never;
714
+ /**
715
+ * Logic configurations for conditional page visibility.
716
+ * Only 'hidden' type logic is supported for pages.
717
+ */
718
+ readonly logic?: ContainerLogicConfig[];
569
719
  }
720
+ /** Type guard for PageField with proper type narrowing */
721
+ declare function isPageField(field: FieldDef<unknown>): field is PageField;
570
722
  /**
571
- * Creates the default derivation log configuration.
723
+ * Validates that a page field doesn't contain nested page fields
572
724
  *
573
- * @returns Default DerivationLogConfig
725
+ * @param pageField The page field to validate
726
+ * @returns true if valid (no nested pages), false otherwise
574
727
  */
575
- declare function createDefaultDerivationLogConfig(): DerivationLogConfig;
728
+ declare function validatePageNesting(pageField: PageField): boolean;
729
+
576
730
  /**
577
- * Checks if logging should occur at the specified level.
578
- *
579
- * @param config - Current log configuration
580
- * @param minLevel - Minimum level required for logging
581
- * @returns True if logging should occur
731
+ * Helper type to convert union to intersection.
732
+ * Uses `U extends U` to trigger distributive conditional type behavior.
582
733
  */
583
- declare function shouldLog(config: DerivationLogConfig, minLevel: 'summary' | 'verbose'): boolean;
734
+ type UnionToIntersection<U> = (U extends U ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
735
+ /** Depth counter for recursion limiting (prevents infinite type instantiation) */
736
+ type Depth = [never, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
584
737
  /**
585
- * Type guard to check if a condition is a FormStateCondition.
586
- *
587
- * @param condition - The condition to check
588
- * @returns true if the condition is a FormStateCondition
738
+ * Widens literal types to their primitive equivalents, recursively for objects and arrays.
739
+ * This prevents `as const` from over-narrowing types like `''` to literal `''` instead of `string`.
589
740
  */
590
- declare function isFormStateCondition(condition: StateLogicConfig['condition'] | DerivationLogicConfig['condition']): condition is FormStateCondition;
741
+ type Widen<T, D extends number = 5> = [D] extends [never] ? T : T extends string ? string : T extends number ? number : T extends boolean ? boolean : T extends readonly (infer U)[] ? Widen<U, Depth[D]>[] : T extends Record<string, unknown> ? {
742
+ -readonly [K in keyof T]: Widen<T[K], Depth[D]>;
743
+ } : T;
591
744
  /**
592
- * Type guard to check if a logic config is a StateLogicConfig.
593
- *
594
- * @param config - The logic config to check
595
- * @returns true if the config is for field state logic
745
+ * Resolves the "underlying" non-null value type for a field, based on its `type`
746
+ * discriminator and (where it matters) its `value` literal. Used when we need a
747
+ * base type independent of whether the literal happens to be `null` — i.e., when
748
+ * computing the nullable widening for `value: null, nullable: true`.
596
749
  */
597
- declare function isStateLogicConfig(config: LogicConfig): config is StateLogicConfig;
750
+ type ResolveBaseValueType<T, V> = T extends {
751
+ type: 'slider';
752
+ } ? number : T extends {
753
+ type: 'input';
754
+ props: {
755
+ type: 'number';
756
+ };
757
+ } ? number : T extends {
758
+ type: 'checkbox' | 'toggle';
759
+ } ? boolean : [V] extends [null] ? string : Widen<V>;
598
760
  /**
599
- * Type guard to check if a logic config is a DerivationLogicConfig.
600
- *
601
- * @param config - The logic config to check
602
- * @returns true if the config is for value derivation
761
+ * Infer value type based on field type, value literal, and the `nullable` flag.
762
+ * - Slider fields: always number
763
+ * - Input fields with props.type: 'number': number
764
+ * - Checkbox / toggle fields: always boolean
765
+ * - Other fields: widen the literal value type (default to string when value is null)
766
+ * - When `nullable: true` is declared, widens the result to `T | null`.
603
767
  */
604
- declare function isDerivationLogicConfig(config: LogicConfig): config is DerivationLogicConfig;
768
+ type InferValueType<T, V> = T extends {
769
+ nullable: true;
770
+ } ? ResolveBaseValueType<T, V> | null : ResolveBaseValueType<T, V>;
605
771
  /**
606
- * Type guard to check if a derivation config targets a property rather than the field value.
607
- *
608
- * @param config - The derivation logic config to check
609
- * @returns true if the config has a targetProperty (property derivation)
772
+ * Make type optional if field is not required.
773
+ * Hidden fields are never optional since they require a value property.
610
774
  */
611
- declare function hasTargetProperty(config: DerivationLogicConfig): config is DerivationLogicConfig & {
612
- targetProperty: string;
613
- };
614
-
775
+ type MaybeOptional<T, V> = T extends {
776
+ type: 'hidden';
777
+ } ? V : T extends {
778
+ required: true;
779
+ } ? V : V | undefined;
615
780
  /**
616
- * Custom validator function signature using Angular's public FieldContext API
617
- *
618
- * @template TValue The type of value stored in the field being validated
781
+ * Infers the value type from a single template field (for primitive arrays).
782
+ * Mirrors InferValueType logic: slider → number, input[number] → number,
783
+ * checkbox/toggle → boolean, else widen `value` (string fallback). Widens to
784
+ * `T | null` when `nullable: true` is declared on the template field.
619
785
  */
620
- type CustomValidator<TValue = unknown> = (ctx: FieldContext<TValue>, params?: Record<string, unknown>) => ValidationError$1 | ValidationError$1[] | null;
786
+ type InferSingleTemplateValueBase<T, D extends number> = T extends {
787
+ type: 'slider';
788
+ } ? number : T extends {
789
+ type: 'input';
790
+ props: {
791
+ type: 'number';
792
+ };
793
+ } ? number : T extends {
794
+ type: 'checkbox' | 'toggle';
795
+ } ? boolean : T extends {
796
+ value: infer V;
797
+ } ? [V] extends [null] ? string : Widen<V, Depth[D]> : string;
798
+ type InferSingleTemplateValue<T, D extends number> = T extends {
799
+ nullable: true;
800
+ } ? InferSingleTemplateValueBase<T, D> | null : InferSingleTemplateValueBase<T, D>;
621
801
  /**
622
- * Async custom validator configuration using Angular's resource-based API
623
- *
802
+ * Infers the value type for an array field.
803
+ * Handles four cases:
804
+ * 1. Simplified array with template + value → infer item type from value
805
+ * 2. Simplified array with array template (no value) → infer object type from template fields
806
+ * 3. Simplified array with single-field template (no value) → infer primitive type from template field
807
+ * 4. Full-API array with fields → infer from children
808
+ */
809
+ type InferArrayValue<T, D extends number> = T extends {
810
+ template: unknown;
811
+ value: readonly (infer Item)[];
812
+ } ? Widen<Item>[] : T extends {
813
+ template: infer TArr;
814
+ } ? TArr extends readonly RegisteredFieldTypes[] ? InferFormValueWithDepth<[...TArr], Depth[D]>[] : InferSingleTemplateValue<TArr, D>[] : T extends {
815
+ fields: infer F;
816
+ } ? F extends RegisteredFieldTypes[] ? InferFormValueWithDepth<F, Depth[D]>[] : unknown[] : unknown[];
817
+ /** Process a single field and determine its contribution to the form value type */
818
+ type ProcessField<T, D extends number = 5> = [D] extends [never] ? Record<string, unknown> : T extends {
819
+ type: 'page' | 'row';
820
+ fields: infer F;
821
+ } ? F extends RegisteredFieldTypes[] ? InferFormValueWithDepth<F, Depth[D]> : never : T extends {
822
+ type: 'group';
823
+ key: infer K;
824
+ fields: infer F;
825
+ } ? K extends string ? F extends RegisteredFieldTypes[] ? {
826
+ [P in K]: InferFormValueWithDepth<F, Depth[D]>;
827
+ } : {
828
+ [P in K]: Record<string, unknown>;
829
+ } : never : T extends {
830
+ type: 'array';
831
+ key: infer K;
832
+ } ? K extends string ? {
833
+ [P in K]: InferArrayValue<T, D>;
834
+ } : never : T extends {
835
+ type: 'text';
836
+ } ? never : T extends {
837
+ type: 'submit' | 'button' | 'next' | 'previous' | 'addArrayItem' | 'removeArrayItem';
838
+ } ? never : T extends {
839
+ key: infer K;
840
+ value: infer V;
841
+ } ? K extends string ? {
842
+ [P in K]: MaybeOptional<T, InferValueType<T, V>>;
843
+ } : never : T extends {
844
+ key: infer K;
845
+ } ? K extends string ? {
846
+ [P in K]: MaybeOptional<T, T extends {
847
+ nullable: true;
848
+ } ? string | null : string>;
849
+ } : never : never;
850
+ /** Internal helper with depth tracking */
851
+ type InferFormValueWithDepth<T extends RegisteredFieldTypes[], D extends number = 5> = UnionToIntersection<ProcessField<T[number], D>>;
852
+ /** Helper to extract fields from either fields array or FormConfig */
853
+ type ExtractFields<T> = T extends {
854
+ fields: infer TFields;
855
+ } ? TFields extends readonly RegisteredFieldTypes[] ? TFields : never : T extends readonly RegisteredFieldTypes[] ? T : never;
856
+ /**
857
+ * Infer form value type from fields array or FormConfig.
858
+ * Recursively processes nested structures and merges the results.
859
+ * Limited to 5 levels of nesting to prevent infinite type instantiation.
860
+ */
861
+ type InferFormValue<T> = ExtractFields<T> extends readonly RegisteredFieldTypes[] ? InferFormValueWithDepth<ExtractFields<T> extends RegisteredFieldTypes[] ? ExtractFields<T> : [...ExtractFields<T>], 5> : never;
862
+
863
+ /**
864
+ * Custom validator function signature using Angular's public FieldContext API
865
+ *
866
+ * @template TValue The type of value stored in the field being validated
867
+ */
868
+ type CustomValidator<TValue = unknown> = (ctx: FieldContext<TValue>, params?: Record<string, unknown>) => ValidationError$1 | ValidationError$1[] | null;
869
+ /**
870
+ * Async custom validator configuration using Angular's resource-based API
871
+ *
624
872
  * @template TValue The type of value stored in the field being validated
625
873
  * @template TParams The type of params passed to the resource
626
874
  * @template TResult The type of result returned by the resource
@@ -797,629 +1045,753 @@ type ValidatorConfig = BuiltInValidatorConfig | CustomValidatorConfig | AsyncVal
797
1045
  /** Type guard to distinguish function-based HTTP validators from declarative ones. */
798
1046
  declare function isFunctionHttpValidator(config: FunctionHttpValidatorConfig | DeclarativeHttpValidatorConfig): config is FunctionHttpValidatorConfig;
799
1047
 
800
- /** Configuration for applying predefined schemas */
801
- interface SchemaApplicationConfig {
802
- /** Schema application type */
803
- type: 'apply' | 'applyWhen' | 'applyWhenValue' | 'applyEach';
804
- /** Schema identifier or inline schema definition */
805
- schema: string | SchemaDefinition;
806
- /** Condition for conditional application */
807
- condition?: ConditionalExpression;
808
- /** Type predicate for applyWhenValue */
809
- typePredicate?: string;
810
- }
811
- /** Reusable schema definition that can be referenced by name */
812
- interface SchemaDefinition {
813
- /** Unique schema identifier */
814
- name: string;
815
- /** Schema description */
816
- description?: string;
817
- /** Field path pattern this schema applies to */
818
- pathPattern?: string;
819
- /** Validators to apply */
820
- validators?: ValidatorConfig[];
821
- /** Logic rules to apply */
822
- logic?: LogicConfig[];
823
- /** Nested schema applications */
824
- subSchemas?: SchemaApplicationConfig[];
825
- }
826
-
827
- /** Context for cross-field detection, providing access to function scope information. */
828
- interface CrossFieldDetectionContext {
829
- /**
830
- * Lookup function to get the scope of a registered custom function.
831
- *
832
- * @param functionName The name of the custom function
833
- * @returns The function's scope, or undefined if not registered
834
- */
835
- getFunctionScope?: (functionName: string) => CustomFunctionScope | undefined;
836
- }
1048
+ /** Special form-state conditions for button disabled logic. */
1049
+ type FormStateCondition =
1050
+ /** True when form.valid() === false */
1051
+ 'formInvalid'
1052
+ /** True when form.submitting() === true */
1053
+ | 'formSubmitting'
1054
+ /** True when fields on the current page are invalid (for paged forms) */
1055
+ | 'pageInvalid';
1056
+ /** Logic type for controlling field state (hidden, readonly, disabled, required). */
1057
+ type StateLogicType = 'hidden' | 'readonly' | 'disabled' | 'required';
837
1058
  /**
838
- * Detects if a ConditionalExpression references other fields (cross-field).
1059
+ * Base configuration for conditional field state logic.
839
1060
  *
840
- * @param expr The conditional expression to analyze
841
- * @param context Optional context providing function scope lookup
842
- * @returns true if the expression references other fields
1061
+ * @internal
843
1062
  */
844
- declare function isCrossFieldExpression(expr: ConditionalExpression | boolean | FormStateCondition | undefined, context?: CrossFieldDetectionContext): boolean;
1063
+ interface BaseStateLogicConfig {
1064
+ /** Logic type identifier for field state. */
1065
+ type: StateLogicType;
1066
+ /** Condition that determines when this logic applies. */
1067
+ condition: ConditionalExpression | boolean | FormStateCondition;
1068
+ }
845
1069
  /**
846
- * Extracts field dependencies from a ConditionalExpression.
1070
+ * State logic that evaluates immediately on change (default).
847
1071
  *
848
- * @param expr The conditional expression to analyze
849
- * @returns Array of field keys that this expression depends on
850
- */
851
- declare function extractExpressionDependencies(expr: ConditionalExpression | boolean | undefined): string[];
852
- /**
853
- * Extracts field names from a JavaScript expression string.
854
- * Handles both dot notation (formValue.field) and bracket notation (formValue['field']).
1072
+ * @internal
855
1073
  */
856
- declare function extractStringDependencies(expression: string): string[];
1074
+ interface ImmediateStateLogicConfig extends BaseStateLogicConfig {
1075
+ /**
1076
+ * Trigger for immediate evaluation.
1077
+ *
1078
+ * @default 'onChange'
1079
+ */
1080
+ trigger?: 'onChange';
1081
+ /** Not allowed for onChange trigger */
1082
+ debounceMs?: never;
1083
+ }
857
1084
  /**
858
- * Detects if a custom validator configuration references formValue (cross-field validation).
1085
+ * State logic that evaluates after a debounce period.
859
1086
  *
860
- * @param config The custom validator configuration to check
861
- * @returns true if the validator references formValue
1087
+ * @internal
862
1088
  */
863
- declare function isCrossFieldValidator(config: CustomValidatorConfig): boolean;
1089
+ interface DebouncedStateLogicConfig extends BaseStateLogicConfig {
1090
+ /**
1091
+ * Trigger for debounced evaluation.
1092
+ * Evaluates after the value has stabilized for the debounce duration.
1093
+ */
1094
+ trigger: 'debounced';
1095
+ /**
1096
+ * Debounce duration in milliseconds.
1097
+ *
1098
+ * @default 500
1099
+ */
1100
+ debounceMs?: number;
1101
+ }
1102
+ /** Configuration for conditional field state logic. */
1103
+ type StateLogicConfig = ImmediateStateLogicConfig | DebouncedStateLogicConfig;
1104
+ /** Trigger timing for when logic is evaluated. */
1105
+ type LogicTrigger = 'onChange' | 'debounced';
864
1106
  /**
865
- * Detects if a built-in validator has a dynamic expression that references formValue.
1107
+ * Shared fields that appear on all derivation logic config variants.
866
1108
  *
867
- * @param config The validator configuration to check
868
- * @returns true if the validator has a cross-field dynamic expression
1109
+ * @internal
869
1110
  */
870
- declare function isCrossFieldBuiltInValidator(config: ValidatorConfig): boolean;
871
- /** Checks if a validator uses Angular's resource API (validateHttp / validateAsync). */
872
- declare function isResourceBasedValidator(config: ValidatorConfig): boolean;
1111
+ interface SharedDerivationFields {
1112
+ /** Logic type identifier for value derivation. */
1113
+ type: 'derivation';
1114
+ /** Target property name for property derivation. */
1115
+ targetProperty?: string;
1116
+ /** Optional name for this derivation for debugging purposes. */
1117
+ debugName?: string;
1118
+ /** Condition that determines when this derivation applies. */
1119
+ condition?: ConditionalExpression | boolean;
1120
+ /**
1121
+ * When true, the derivation stops running after the user manually
1122
+ * edits the target field.
1123
+ */
1124
+ stopOnUserOverride?: boolean;
1125
+ /**
1126
+ * When true (and `stopOnUserOverride` is also true), clears the
1127
+ * user-override flag when any dependency of this derivation changes,
1128
+ * allowing the derivation to run again.
1129
+ */
1130
+ reEngageOnDependencyChange?: boolean;
1131
+ }
873
1132
  /**
874
- * Detects if a validator's `when` condition is cross-field.
1133
+ * Trigger variants for derivation timing.
875
1134
  *
876
- * @param config The validator configuration to check
877
- * @param context Optional context providing function scope lookup
878
- * @returns true if the when condition references other fields
1135
+ * @internal
879
1136
  */
880
- declare function hasCrossFieldWhenCondition(config: ValidatorConfig, context?: CrossFieldDetectionContext): boolean;
1137
+ type ImmediateDerivationTrigger = {
1138
+ trigger?: 'onChange';
1139
+ debounceMs?: never;
1140
+ };
1141
+ type DebouncedDerivationTrigger = {
1142
+ trigger: 'debounced';
1143
+ debounceMs?: number;
1144
+ };
881
1145
  /**
882
- * Detects if a StateLogicConfig has a cross-field condition.
1146
+ * Base for HTTP derivations. `source: 'http'` is required.
1147
+ * TypeScript enforces `dependsOn` and `responseExpression` at the type level.
883
1148
  *
884
- * @param config The state logic configuration to check
885
- * @param context Optional context providing function scope lookup
886
- * @returns true if the logic condition references other fields
1149
+ * @internal
887
1150
  */
888
- declare function isCrossFieldStateLogic(config: StateLogicConfig, context?: CrossFieldDetectionContext): boolean;
1151
+ interface HttpDerivationBase extends SharedDerivationFields {
1152
+ /** Identifies this derivation as HTTP-driven. */
1153
+ source: 'http';
1154
+ /** Forbidden on HTTP source */
1155
+ fn?: never;
1156
+ /** Forbidden on HTTP source */
1157
+ asyncFn?: never;
1158
+ /** HTTP request configuration for server-driven derivations. */
1159
+ http: HttpRequestConfig;
1160
+ /**
1161
+ * Explicit field dependencies. Required for HTTP derivations to prevent
1162
+ * wildcard triggering on every keystroke.
1163
+ */
1164
+ dependsOn: string[];
1165
+ /** Expression to extract the derived value from the HTTP response. */
1166
+ responseExpression: string;
1167
+ value?: never;
1168
+ expression?: never;
1169
+ functionName?: never;
1170
+ asyncFunctionName?: never;
1171
+ }
889
1172
  /**
890
- * Detects if a SchemaApplicationConfig has a cross-field condition.
1173
+ * Shared fields for both branches of {@link AsyncFunctionDerivationBase}.
891
1174
  *
892
- * @param config The schema application configuration to check
893
- * @param context Optional context providing function scope lookup
894
- * @returns true if the schema condition references other fields
1175
+ * @internal
895
1176
  */
896
- declare function isCrossFieldSchema(config: SchemaApplicationConfig, context?: CrossFieldDetectionContext): boolean;
897
-
898
- /**
899
- * Creates a lazy FieldStateInfo that only reads state properties when accessed.
1177
+ interface AsyncFunctionDerivationShared extends SharedDerivationFields {
1178
+ /** Identifies this derivation as async-function-driven. */
1179
+ source: 'asyncFunction';
1180
+ /** Forbidden on asyncFunction source */
1181
+ fn?: never;
1182
+ /**
1183
+ * Explicit field dependencies. Required for async derivations to prevent
1184
+ * wildcard triggering on every form change.
1185
+ */
1186
+ dependsOn: string[];
1187
+ value?: never;
1188
+ expression?: never;
1189
+ functionName?: never;
1190
+ http?: never;
1191
+ responseExpression?: never;
1192
+ }
1193
+ /**
1194
+ * Base for async function derivations. `source: 'asyncFunction'` is required.
1195
+ * TypeScript enforces `dependsOn` at the type level, and `asyncFunctionName` /
1196
+ * `asyncFn` are mutually exclusive (XOR).
900
1197
  *
901
- * @param fieldSource - A FieldTree or direct FieldState instance
902
- * @param reactive - If true, reads signals reactively (creates dependencies).
903
- * If false, reads signals with `untracked()` (no dependencies).
904
- * @returns A FieldStateInfo proxy with lazy property access, or undefined if the source is invalid
905
1198
  * @internal
906
1199
  */
907
- declare function readFieldStateInfo(fieldSource: FieldTree<unknown> | ReadonlyFieldState<unknown> | undefined, reactive: boolean): FieldStateInfo | undefined;
1200
+ type AsyncFunctionDerivationBase = (AsyncFunctionDerivationShared & {
1201
+ /** Name of a registered async derivation function. */
1202
+ asyncFunctionName: string;
1203
+ /** Inline form is forbidden when `asyncFunctionName` is set */
1204
+ asyncFn?: never;
1205
+ }) | (AsyncFunctionDerivationShared & {
1206
+ /** Inline async derivation function. Mutually exclusive with `asyncFunctionName`. */
1207
+ asyncFn: AsyncDerivationFunction;
1208
+ /** Registered form is forbidden when `asyncFn` is set */
1209
+ asyncFunctionName?: never;
1210
+ });
908
1211
  /**
909
- * Creates a Proxy-based FormFieldStateMap for accessing any field's state by key.
1212
+ * Base for expression derivations.
910
1213
  *
911
- * @param rootForm - The root FieldTree of the form
912
- * @param reactive - If true, reads signals reactively (creates dependencies).
913
- * If false, reads signals with `untracked()` (no dependencies).
914
- * @returns A FormFieldStateMap proxy
915
1214
  * @internal
916
1215
  */
917
- declare function createFormFieldStateMap(rootForm: FieldTree<unknown>, reactive: boolean): FormFieldStateMap;
918
-
919
- /** DI-scoped cache for async condition logic functions. */
920
- declare class AsyncConditionFunctionCacheService {
921
- /** Cache for async condition logic functions, keyed by serialized condition. */
922
- readonly asyncConditionFunctionCache: Map<string, LogicFn<unknown, boolean>>;
1216
+ interface ExpressionDerivationBase extends SharedDerivationFields {
1217
+ source?: never;
1218
+ /** Forbidden on expression mode */
1219
+ fn?: never;
1220
+ /** Forbidden on expression mode */
1221
+ asyncFn?: never;
1222
+ /** JavaScript expression to evaluate for the derived value. */
1223
+ expression: string;
1224
+ /** Explicit field dependencies for expressions. */
1225
+ dependsOn?: string[];
1226
+ value?: never;
1227
+ functionName?: never;
1228
+ http?: never;
1229
+ asyncFunctionName?: never;
1230
+ responseExpression?: never;
923
1231
  }
924
-
925
- /** Creates a logic function for an async condition. */
926
- declare function createAsyncConditionLogicFunction<TValue>(condition: AsyncCondition): LogicFn<TValue, boolean>;
927
-
928
1232
  /**
929
- * Evaluate conditional expression
930
- * Uses secure AST-based parsing for JavaScript expressions
1233
+ * Base for value derivations.
1234
+ *
1235
+ * @internal
931
1236
  */
932
- declare function evaluateCondition(expression: ConditionalExpression, context: EvaluationContext): boolean;
933
-
1237
+ interface ValueDerivationBase extends SharedDerivationFields {
1238
+ source?: never;
1239
+ /** Forbidden on value mode */
1240
+ fn?: never;
1241
+ /** Forbidden on value mode */
1242
+ asyncFn?: never;
1243
+ /** Static value to set on this field. */
1244
+ value: unknown;
1245
+ /** Explicit field dependencies for value derivations. */
1246
+ dependsOn?: string[];
1247
+ expression?: never;
1248
+ functionName?: never;
1249
+ http?: never;
1250
+ asyncFunctionName?: never;
1251
+ responseExpression?: never;
1252
+ }
934
1253
  /**
935
- * Trigger value carried through the debounced reactive pipeline.
1254
+ * Shared fields for both branches of {@link FunctionDerivationBase}.
936
1255
  *
937
1256
  * @internal
938
1257
  */
939
- interface Trigger<TPayload> {
940
- key: string;
941
- payload: TPayload;
1258
+ interface FunctionDerivationShared extends SharedDerivationFields {
1259
+ source?: never;
1260
+ /** Forbidden on function-derivation mode */
1261
+ asyncFn?: never;
1262
+ /** Explicit field dependencies for function derivations. */
1263
+ dependsOn?: string[];
1264
+ value?: never;
1265
+ expression?: never;
1266
+ http?: never;
1267
+ asyncFunctionName?: never;
1268
+ responseExpression?: never;
942
1269
  }
943
1270
  /**
944
- * Configuration passed to {@link createDebouncedResourceLogicFn}.
1271
+ * Base for custom sync function derivations. `functionName` and `fn` are
1272
+ * mutually exclusive (XOR).
945
1273
  *
946
1274
  * @internal
947
1275
  */
948
- interface DebouncedResourceLogicFnConfig<TValue, TPayload, TResult> {
949
- /** Default value returned by the resource while loading / pending. */
950
- pendingValue: TResult;
951
- /** Debounce window (ms) applied to the trigger signal before the resource sees it. */
952
- debounceMs: number;
953
- injector: Injector;
954
- /**
955
- * Builds the per-emission inner observable. Called every time the debounced
956
- * trigger key changes; the resource swaps to the new stream automatically.
957
- */
958
- buildStream: (payload: TPayload) => Observable<TResult>;
959
- /**
960
- * Called per LogicFn invocation. Returns one of:
961
- * - `{ kind: 'trigger', key, payload }` — set the trigger to this and
962
- * return the (potentially still-loading) resource value.
963
- * - `{ kind: 'returnEarly', value }` — bypass the resource and return
964
- * this value directly (used by HTTP for response-cache hits — the
965
- * cached value is authoritative and overrides any sticky resource value).
966
- * - `{ kind: 'holdPrevious' }` — bypass the resource update but return
967
- * the resource's current sticky value (its last resolved value via
968
- * `withPreviousValue`, or `pendingValue` if it never resolved). Used
969
- * by HTTP when the request template is temporarily unresolvable so
970
- * the UI doesn't flicker back to `pendingValue`.
971
- */
972
- resolve: (ctx: FieldContext<TValue>) => {
973
- kind: 'trigger';
974
- key: string;
975
- payload: TPayload;
976
- } | {
977
- kind: 'returnEarly';
978
- value: TResult;
979
- } | {
980
- kind: 'holdPrevious';
981
- };
982
- }
1276
+ type FunctionDerivationBase = (FunctionDerivationShared & {
1277
+ /** Name of a registered custom derivation function. */
1278
+ functionName: string;
1279
+ /** Inline form is forbidden when `functionName` is set */
1280
+ fn?: never;
1281
+ }) | (FunctionDerivationShared & {
1282
+ /** Inline custom derivation function. Mutually exclusive with `functionName`. */
1283
+ fn: CustomFunction;
1284
+ /** Registered form is forbidden when `fn` is set */
1285
+ functionName?: never;
1286
+ });
983
1287
  /**
984
- * Shared scaffolding for both async-function and HTTP condition LogicFns.
1288
+ * HTTP derivation that evaluates immediately on change (default).
985
1289
  *
986
1290
  * @internal
987
1291
  */
988
- declare function createDebouncedResourceLogicFn<TValue, TPayload, TResult>(config: DebouncedResourceLogicFnConfig<TValue, TPayload, TResult>): LogicFn<TValue, TResult>;
989
-
990
- /** DI-scoped cache for HTTP condition logic functions. */
991
- declare class HttpConditionFunctionCacheService {
992
- /** Cache for HTTP condition logic functions, keyed by serialized condition. */
993
- readonly httpConditionFunctionCache: Map<string, LogicFn<unknown, boolean>>;
994
- }
995
-
996
- /** Creates a logic function for an HTTP condition. */
997
- declare function createHttpConditionLogicFunction<TValue>(condition: HttpCondition): LogicFn<TValue, boolean>;
998
-
1292
+ type OnChangeHttpDerivationLogicConfig = HttpDerivationBase & ImmediateDerivationTrigger;
999
1293
  /**
1000
- * Create a logic function from a conditional expression.
1294
+ * HTTP derivation that evaluates after a debounce period.
1001
1295
  *
1002
- * @param expression The conditional expression to evaluate
1003
- * @returns A LogicFn that evaluates the condition in the context of a field
1296
+ * @internal
1004
1297
  */
1005
- declare function createLogicFunction<TValue>(expression: ConditionalExpression): LogicFn<TValue, boolean>;
1298
+ type DebouncedHttpDerivationLogicConfig = HttpDerivationBase & DebouncedDerivationTrigger;
1006
1299
  /**
1007
- * Create a debounced logic function from a conditional expression.
1300
+ * Async function derivation that evaluates immediately on change (default).
1008
1301
  *
1009
- * @param expression The conditional expression to evaluate
1010
- * @param debounceMs The debounce duration in milliseconds
1011
- * @returns A LogicFn that evaluates the condition with debouncing
1302
+ * @internal
1012
1303
  */
1013
- declare function createDebouncedLogicFunction<TValue>(expression: ConditionalExpression, debounceMs: number): LogicFn<TValue, boolean>;
1014
-
1304
+ type OnChangeAsyncFunctionDerivationLogicConfig = AsyncFunctionDerivationBase & ImmediateDerivationTrigger;
1015
1305
  /**
1016
- * Compares two values using the specified comparison operator.
1306
+ * Async function derivation that evaluates after a debounce period.
1017
1307
  *
1018
- * @param actual - The value to compare
1019
- * @param expected - The value to compare against
1020
- * @param operator - Comparison operator to use
1021
- * @returns True if the comparison succeeds, false otherwise
1308
+ * @internal
1022
1309
  */
1023
- declare function compareValues(actual: unknown, expected: unknown, operator: string): boolean;
1310
+ type DebouncedAsyncFunctionDerivationLogicConfig = AsyncFunctionDerivationBase & DebouncedDerivationTrigger;
1024
1311
  /**
1025
- * Retrieves a nested value from an object using dot notation path.
1312
+ * Expression derivation that evaluates immediately on change (default).
1026
1313
  *
1027
- * @param obj - The object to traverse
1028
- * @param path - Dot-separated path to the desired property
1029
- * @returns The value at the specified path, or undefined if not found
1314
+ * @internal
1030
1315
  */
1031
- declare function getNestedValue(obj: unknown, path: string): unknown;
1316
+ type OnChangeExpressionDerivationLogicConfig = ExpressionDerivationBase & ImmediateDerivationTrigger;
1032
1317
  /**
1033
- * Checks whether a nested property exists in an object using dot notation path.
1318
+ * Expression derivation that evaluates after a debounce period.
1034
1319
  *
1035
- * @param obj - The object to check
1036
- * @param path - Dot-separated path to the property
1037
- * @returns True if the property exists (even if its value is undefined)
1320
+ * @internal
1038
1321
  */
1039
- declare function hasNestedProperty(obj: unknown, path: string): boolean;
1040
-
1041
- /** Per-field debounced signal pair. */
1042
- interface DebouncedSignalPair {
1043
- immediateValue: WritableSignal<boolean>;
1044
- debouncedValue: Signal<boolean | undefined>;
1045
- }
1046
- /** DI-scoped cache for logic functions and debounced signals. */
1047
- declare class LogicFunctionCacheService {
1048
- /** Cache for memoized logic functions, keyed by serialized expression. */
1049
- readonly logicFunctionCache: Map<string, LogicFn<unknown, boolean>>;
1050
- /** Cache for debounced logic functions, keyed by serialized expression + debounceMs. */
1051
- readonly debouncedLogicFunctionCache: Map<string, LogicFn<unknown, boolean>>;
1052
- /** Per-field signal store for debounced logic, keyed by field path. */
1053
- readonly debouncedSignalStore: Map<string, DebouncedSignalPair>;
1054
- }
1055
-
1056
- /** Base error class for all Dynamic Forms errors. */
1057
- declare class DynamicFormError extends Error {
1058
- private static readonly PREFIX;
1059
- constructor(message: string);
1322
+ type DebouncedExpressionDerivationLogicConfig = ExpressionDerivationBase & DebouncedDerivationTrigger;
1323
+ /**
1324
+ * Value derivation that evaluates immediately on change (default).
1325
+ *
1326
+ * @internal
1327
+ */
1328
+ type OnChangeValueDerivationLogicConfig = ValueDerivationBase & ImmediateDerivationTrigger;
1329
+ /**
1330
+ * Value derivation that evaluates after a debounce period.
1331
+ *
1332
+ * @internal
1333
+ */
1334
+ type DebouncedValueDerivationLogicConfig = ValueDerivationBase & DebouncedDerivationTrigger;
1335
+ /**
1336
+ * Function derivation that evaluates immediately on change (default).
1337
+ *
1338
+ * @internal
1339
+ */
1340
+ type OnChangeFunctionDerivationLogicConfig = FunctionDerivationBase & ImmediateDerivationTrigger;
1341
+ /**
1342
+ * Function derivation that evaluates after a debounce period.
1343
+ *
1344
+ * @internal
1345
+ */
1346
+ type DebouncedFunctionDerivationLogicConfig = FunctionDerivationBase & DebouncedDerivationTrigger;
1347
+ /** Configuration for value derivation logic. */
1348
+ type DerivationLogicConfig = OnChangeHttpDerivationLogicConfig | DebouncedHttpDerivationLogicConfig | OnChangeAsyncFunctionDerivationLogicConfig | DebouncedAsyncFunctionDerivationLogicConfig | OnChangeExpressionDerivationLogicConfig | DebouncedExpressionDerivationLogicConfig | OnChangeValueDerivationLogicConfig | DebouncedValueDerivationLogicConfig | OnChangeFunctionDerivationLogicConfig | DebouncedFunctionDerivationLogicConfig;
1349
+ /** Union type for all logic configurations. */
1350
+ type LogicConfig = StateLogicConfig | DerivationLogicConfig;
1351
+ /** Log level for derivation debug output. */
1352
+ type DerivationLogLevel = 'none' | 'summary' | 'verbose';
1353
+ /** Configuration for derivation debug logging. */
1354
+ interface DerivationLogConfig {
1355
+ /** Log level for derivation debugging. Defaults to 'none'. */
1356
+ level: DerivationLogLevel;
1060
1357
  }
1358
+ /**
1359
+ * Creates the default derivation log configuration.
1360
+ *
1361
+ * @returns Default DerivationLogConfig
1362
+ */
1363
+ declare function createDefaultDerivationLogConfig(): DerivationLogConfig;
1364
+ /**
1365
+ * Checks if logging should occur at the specified level.
1366
+ *
1367
+ * @param config - Current log configuration
1368
+ * @param minLevel - Minimum level required for logging
1369
+ * @returns True if logging should occur
1370
+ */
1371
+ declare function shouldLog(config: DerivationLogConfig, minLevel: 'summary' | 'verbose'): boolean;
1372
+ /**
1373
+ * Type guard to check if a condition is a FormStateCondition.
1374
+ *
1375
+ * @param condition - The condition to check
1376
+ * @returns true if the condition is a FormStateCondition
1377
+ */
1378
+ declare function isFormStateCondition(condition: StateLogicConfig['condition'] | DerivationLogicConfig['condition']): condition is FormStateCondition;
1379
+ /**
1380
+ * Type guard to check if a logic config is a StateLogicConfig.
1381
+ *
1382
+ * @param config - The logic config to check
1383
+ * @returns true if the config is for field state logic
1384
+ */
1385
+ declare function isStateLogicConfig(config: LogicConfig): config is StateLogicConfig;
1386
+ /**
1387
+ * Type guard to check if a logic config is a DerivationLogicConfig.
1388
+ *
1389
+ * @param config - The logic config to check
1390
+ * @returns true if the config is for value derivation
1391
+ */
1392
+ declare function isDerivationLogicConfig(config: LogicConfig): config is DerivationLogicConfig;
1393
+ /**
1394
+ * Type guard to check if a derivation config targets a property rather than the field value.
1395
+ *
1396
+ * @param config - The derivation logic config to check
1397
+ * @returns true if the config has a targetProperty (property derivation)
1398
+ */
1399
+ declare function hasTargetProperty(config: DerivationLogicConfig): config is DerivationLogicConfig & {
1400
+ targetProperty: string;
1401
+ };
1061
1402
 
1062
- /** Token types for expression parsing */
1063
- declare enum TokenType {
1064
- NUMBER = "NUMBER",
1065
- STRING = "STRING",
1066
- TRUE = "TRUE",
1067
- FALSE = "FALSE",
1068
- NULL = "NULL",
1069
- UNDEFINED = "UNDEFINED",
1070
- IDENTIFIER = "IDENTIFIER",
1071
- PLUS = "PLUS",
1072
- MINUS = "MINUS",
1073
- MULTIPLY = "MULTIPLY",
1074
- DIVIDE = "DIVIDE",
1075
- MODULO = "MODULO",
1076
- EQUAL = "EQUAL",
1077
- NOT_EQUAL = "NOT_EQUAL",
1078
- GREATER = "GREATER",
1079
- LESS = "LESS",
1080
- GREATER_EQUAL = "GREATER_EQUAL",
1081
- LESS_EQUAL = "LESS_EQUAL",
1082
- AND = "AND",
1083
- OR = "OR",
1084
- NOT = "NOT",
1085
- DOT = "DOT",
1086
- COMMA = "COMMA",
1087
- COLON = "COLON",
1088
- LPAREN = "LPAREN",
1089
- RPAREN = "RPAREN",
1090
- LBRACKET = "LBRACKET",
1091
- RBRACKET = "RBRACKET",
1092
- LBRACE = "LBRACE",
1093
- RBRACE = "RBRACE",
1094
- ARROW = "ARROW",
1095
- QUESTION = "QUESTION",
1096
- OPTIONAL_DOT = "OPTIONAL_DOT",
1097
- EOF = "EOF"
1098
- }
1099
- /** Token with type, value, and position */
1100
- interface Token {
1101
- type: TokenType;
1102
- value: string;
1103
- position: number;
1104
- }
1105
- /** AST Node types */
1106
- type ASTNode = LiteralNode | IdentifierNode | MemberAccessNode | ComputedMemberAccessNode | BinaryOpNode | UnaryOpNode | CallExpressionNode | ConditionalNode | ArrayLiteralNode | ObjectLiteralNode | ArrowFunctionNode;
1107
- interface LiteralNode {
1108
- type: 'Literal';
1109
- value: string | number | boolean | null | undefined;
1403
+ /** Configuration for applying predefined schemas */
1404
+ interface SchemaApplicationConfig {
1405
+ /** Schema application type */
1406
+ type: 'apply' | 'applyWhen' | 'applyWhenValue' | 'applyEach';
1407
+ /** Schema identifier or inline schema definition */
1408
+ schema: string | SchemaDefinition;
1409
+ /** Condition for conditional application */
1410
+ condition?: ConditionalExpression;
1411
+ /** Type predicate for applyWhenValue */
1412
+ typePredicate?: string;
1110
1413
  }
1111
- interface IdentifierNode {
1112
- type: 'Identifier';
1414
+ /** Reusable schema definition that can be referenced by name */
1415
+ interface SchemaDefinition {
1416
+ /** Unique schema identifier */
1113
1417
  name: string;
1114
- }
1115
- interface MemberAccessNode {
1116
- type: 'MemberAccess';
1117
- object: ASTNode;
1118
- property: string;
1119
- /** True when this access used `?.` (optional chaining). */
1120
- optional?: boolean;
1121
- }
1122
- interface ComputedMemberAccessNode {
1123
- type: 'ComputedMemberAccess';
1124
- object: ASTNode;
1125
- /** Expression evaluated at runtime to produce the property key. */
1126
- property: ASTNode;
1127
- /** True when this access used `?.[ ... ]` (optional chaining). */
1128
- optional?: boolean;
1129
- }
1130
- interface ConditionalNode {
1131
- type: 'Conditional';
1132
- test: ASTNode;
1133
- consequent: ASTNode;
1134
- alternate: ASTNode;
1135
- }
1136
- interface BinaryOpNode {
1137
- type: 'BinaryOp';
1138
- operator: string;
1139
- left: ASTNode;
1140
- right: ASTNode;
1141
- }
1142
- interface UnaryOpNode {
1143
- type: 'UnaryOp';
1144
- operator: string;
1145
- operand: ASTNode;
1146
- }
1147
- interface CallExpressionNode {
1148
- type: 'CallExpression';
1149
- callee: ASTNode;
1150
- arguments: ASTNode[];
1151
- /** True when this call used `?.( ... )` (optional chaining). */
1152
- optional?: boolean;
1153
- }
1154
- interface ArrayLiteralNode {
1155
- type: 'ArrayLiteral';
1156
- elements: ASTNode[];
1157
- }
1158
- interface ObjectLiteralNode {
1159
- type: 'ObjectLiteral';
1160
- properties: Array<{
1161
- key: string;
1162
- value: ASTNode;
1163
- }>;
1164
- }
1165
- interface ArrowFunctionNode {
1166
- type: 'ArrowFunction';
1167
- params: string[];
1168
- body: ASTNode;
1169
- }
1170
- /** Parser error with position information */
1171
- declare class ExpressionParserError extends DynamicFormError {
1172
- position: number;
1173
- expression: string;
1174
- constructor(message: string, position: number, expression: string);
1418
+ /** Schema description */
1419
+ description?: string;
1420
+ /** Field path pattern this schema applies to */
1421
+ pathPattern?: string;
1422
+ /** Validators to apply */
1423
+ validators?: ValidatorConfig[];
1424
+ /** Logic rules to apply */
1425
+ logic?: LogicConfig[];
1426
+ /** Nested schema applications */
1427
+ subSchemas?: SchemaApplicationConfig[];
1175
1428
  }
1176
1429
 
1177
- /** Evaluation context for safe expression evaluation */
1178
- interface EvaluationScope {
1179
- [key: string]: unknown;
1180
- }
1181
- /** Safely evaluates an AST node with a given context */
1182
- declare class Evaluator {
1183
- private readonly scope;
1184
- private readonly expression;
1185
- constructor(scope: EvaluationScope, expression: string);
1186
- /** Evaluate an AST node */
1187
- evaluate(node: ASTNode): unknown;
1188
- private evaluateIdentifier;
1189
- private evaluateMemberAccess;
1190
- private evaluateComputedMemberAccess;
1191
- private evaluateBinaryOp;
1192
- private evaluateUnaryOp;
1193
- private evaluateCallExpression;
1194
- private evaluateArrayLiteral;
1195
- private evaluateObjectLiteral;
1196
- private evaluateArrowFunction;
1197
- private isMethodSafe;
1430
+ /**
1431
+ * Re-export Angular's ValidationError for consistency
1432
+ * This replaces our custom ValidationError interface
1433
+ */
1434
+ type ValidationError = ValidationError$1;
1435
+ interface ValidationMessages {
1436
+ required?: DynamicText;
1437
+ email?: DynamicText;
1438
+ min?: DynamicText;
1439
+ max?: DynamicText;
1440
+ minLength?: DynamicText;
1441
+ maxLength?: DynamicText;
1442
+ pattern?: DynamicText;
1443
+ [key: string]: DynamicText | undefined;
1198
1444
  }
1199
1445
 
1200
- /** Secure expression parser that uses AST-based evaluation */
1201
- declare class ExpressionParser {
1446
+ /**
1447
+ * The result type for submission actions.
1448
+ * Can be either a Promise or an Observable.
1449
+ */
1450
+ type SubmissionActionResult = Promise<TreeValidationResult> | Observable<TreeValidationResult | unknown>;
1451
+ /**
1452
+ * Configuration for form submission handling.
1453
+ *
1454
+ * @typeParam TValue - The form value type
1455
+ */
1456
+ interface SubmissionConfig<TValue = unknown> {
1202
1457
  /**
1203
- * Parse an expression string into an AST
1204
- * Results are cached for performance using LRU eviction
1458
+ * Action called when the form is submitted.
1459
+ *
1460
+ * @param form - The form's FieldTree instance
1461
+ * @returns Promise or Observable - for errors, return TreeValidationResult
1205
1462
  */
1206
- static parse(expression: string): ASTNode;
1207
- /** Evaluate an expression with a given scope */
1208
- static evaluate(expression: string, scope: EvaluationScope): unknown;
1209
- /** Clear the AST cache */
1210
- static clearCache(): void;
1211
- /** Get cache statistics */
1212
- static getCacheStats(): {
1213
- size: number;
1214
- maxSize: number;
1215
- };
1463
+ action: (form: FieldTree<TValue>) => SubmissionActionResult;
1216
1464
  }
1217
1465
 
1218
1466
  /**
1219
- * Parses tokens into an Abstract Syntax Tree (AST)
1220
- * Uses recursive descent parsing with operator precedence
1221
- */
1222
- declare class Parser {
1223
- private tokens;
1224
- private current;
1225
- private readonly expression;
1226
- constructor(expression: string);
1227
- /** Parse the expression into an AST */
1228
- parse(): ASTNode;
1229
- private parseExpression;
1467
+ * Configuration interface for defining dynamic form structure and behavior.
1468
+ *
1469
+ * @typeParam TFields - Array of registered field types available for this form
1470
+ * @typeParam TValue - The strongly-typed interface for form values
1471
+ * @typeParam TProps - The type for form-level default props (library-specific)
1472
+ */
1473
+ interface FormConfig<TFields extends NarrowFields | RegisteredFieldTypes[] = RegisteredFieldTypes[], TValue = InferFormValue<TFields extends readonly RegisteredFieldTypes[] ? TFields : RegisteredFieldTypes[]>, TProps extends object = Record<string, unknown>, TSchemaValue = unknown> {
1474
+ /** Array of field definitions that define the form structure. */
1475
+ fields: TFields;
1476
+ /** Optional form-level validation schema using Standard Schema spec. */
1477
+ schema?: FormSchema<TSchemaValue>;
1230
1478
  /**
1231
- * Ternary `test ? consequent : alternate` — right-associative, sits between
1232
- * the arrow-function check and logical-or in precedence.
1479
+ * Global form configuration options.
1480
+ *
1481
+ * @value {}
1233
1482
  */
1234
- private parseConditional;
1483
+ options?: FormOptions;
1484
+ /** Global schemas available to all fields. */
1485
+ schemas?: SchemaDefinition[];
1486
+ /** Form-level validation messages that act as fallback for field-level messages. */
1487
+ defaultValidationMessages?: ValidationMessages;
1488
+ /** Signal forms adapter configuration. */
1489
+ customFnConfig?: CustomFnConfig<TValue extends Record<string, unknown> ? TValue : Record<string, unknown>>;
1490
+ /** Form submission configuration. */
1491
+ submission?: SubmissionConfig<TValue>;
1492
+ /** Default props applied to all fields in the form. */
1493
+ defaultProps?: TProps;
1494
+ /** External data signals available to conditional logic and derivations. */
1495
+ externalData?: Record<string, Signal<unknown>>;
1496
+ /** Form-wide default wrappers applied to every field that does not explicitly opt out. */
1497
+ defaultWrappers?: readonly WrapperConfig[];
1498
+ }
1499
+ /** Signal forms adapter configuration for advanced form behavior. */
1500
+ interface CustomFnConfig<TFormValue extends Record<string, unknown> = Record<string, unknown>> {
1501
+ /** Custom evaluation functions for conditional expressions. */
1502
+ customFunctions?: Record<string, CustomFunction<TFormValue>>;
1503
+ /** Custom derivation functions for value derivation logic. */
1504
+ derivations?: Record<string, CustomFunction<TFormValue>>;
1505
+ /** Async derivation functions for asynchronous value derivation logic. */
1506
+ asyncDerivations?: Record<string, AsyncDerivationFunction<TFormValue>>;
1507
+ /** Async condition functions for asynchronous field state logic. */
1508
+ asyncConditions?: Record<string, AsyncConditionFunction<TFormValue>>;
1509
+ /** Custom validators using Angular's public FieldContext API */
1510
+ validators?: Record<string, CustomValidator>;
1511
+ /** Async custom validators using Angular's resource-based validateAsync() API */
1512
+ asyncValidators?: Record<string, AsyncCustomValidator>;
1513
+ /** HTTP validators using Angular's validateHttp() API. */
1514
+ httpValidators?: Record<string, HttpCustomValidator>;
1515
+ }
1516
+ /** Global form configuration options. */
1517
+ interface FormOptions {
1235
1518
  /**
1236
- * Attempts to parse an arrow function. Returns null and leaves position
1237
- * unchanged if the next tokens don't form an arrow function head.
1519
+ * Disable the entire form.
1520
+ *
1521
+ * @value false
1238
1522
  */
1239
- private tryParseArrowFunction;
1240
- private checkAt;
1241
- private parseLogicalOr;
1242
- private parseLogicalAnd;
1243
- private parseEquality;
1244
- private parseComparison;
1245
- private parseAddition;
1246
- private parseMultiplication;
1247
- private parseUnary;
1248
- private parsePostfix;
1249
- private parsePrimary;
1250
- private parseArgumentList;
1251
- private parseArrayElements;
1252
- private parseObjectProperties;
1253
- private match;
1254
- private check;
1255
- private advance;
1256
- private isAtEnd;
1257
- private peek;
1258
- private previous;
1259
- private consume;
1523
+ disabled?: boolean;
1524
+ /**
1525
+ * Prefix scoping every field's DOM `id` (and matching `for` / `data-testid` /
1526
+ * `aria-describedby`) to this form instance, as the outermost id segment:
1527
+ * `{idPrefix}_{group}_{key}_{index}`. Use it when rendering multiple forms
1528
+ * from the same config on one page so their ids don't collide.
1529
+ *
1530
+ * When omitted, a lone form stays unprefixed and a generated prefix (`df-1`,
1531
+ * `df-2`, …) is applied automatically once a second form is mounted. Characters
1532
+ * invalid in an id token (whitespace, punctuation) are replaced with `_`.
1533
+ *
1534
+ * @example
1535
+ * ```typescript
1536
+ * options: { idPrefix: 'billing' } // → id="billing_email-input"
1537
+ * ```
1538
+ *
1539
+ * @default undefined (auto-prefix only when multiple forms are mounted)
1540
+ */
1541
+ idPrefix?: string;
1542
+ /**
1543
+ * Maximum number of iterations for derivation chain processing.
1544
+ *
1545
+ * @default 10
1546
+ */
1547
+ maxDerivationIterations?: number;
1548
+ /** Default disabled behavior for submit buttons. */
1549
+ submitButton?: SubmitButtonOptions;
1550
+ /** Default disabled behavior for next page buttons. */
1551
+ nextButton?: NextButtonOptions;
1552
+ /**
1553
+ * Whether to exclude values of hidden fields from submission output.
1554
+ *
1555
+ * @default undefined (uses global setting)
1556
+ */
1557
+ excludeValueIfHidden?: boolean;
1558
+ /**
1559
+ * Whether to exclude values of disabled fields from submission output.
1560
+ *
1561
+ * @default undefined (uses global setting)
1562
+ */
1563
+ excludeValueIfDisabled?: boolean;
1564
+ /**
1565
+ * Whether to exclude values of readonly fields from submission output.
1566
+ *
1567
+ * @default undefined (uses global setting)
1568
+ */
1569
+ excludeValueIfReadonly?: boolean;
1570
+ /**
1571
+ * Whether to run validation when a field is hidden.
1572
+ *
1573
+ * @default undefined (uses global setting, which defaults to `false`)
1574
+ */
1575
+ validateWhenHidden?: boolean;
1576
+ /**
1577
+ * Whether to attach the current form value to all events dispatched through the EventBus.
1578
+ *
1579
+ * @default undefined (uses global setting)
1580
+ */
1581
+ emitFormValueOnEvents?: boolean;
1260
1582
  }
1261
-
1262
- /** Tokenizes an expression string into tokens */
1263
- declare class Tokenizer {
1264
- private position;
1265
- private readonly expression;
1266
- constructor(expression: string);
1267
- /** Tokenize the entire expression */
1268
- tokenize(): Token[];
1269
- private skipWhitespace;
1270
- private nextToken;
1271
- private readString;
1272
- private readNumber;
1273
- private readIdentifierOrKeyword;
1274
- private getKeywordType;
1275
- private readOperatorOrPunctuation;
1583
+ /** Options for controlling submit button disabled behavior. */
1584
+ interface SubmitButtonOptions {
1585
+ /**
1586
+ * Disable submit button when the form is invalid.
1587
+ *
1588
+ * @default true
1589
+ */
1590
+ disableWhenInvalid?: boolean;
1591
+ /**
1592
+ * Disable submit button while the form is submitting.
1593
+ *
1594
+ * @default true
1595
+ */
1596
+ disableWhileSubmitting?: boolean;
1597
+ }
1598
+ /** Options for controlling next page button disabled behavior. */
1599
+ interface NextButtonOptions {
1600
+ /**
1601
+ * Disable next button when the current page has invalid fields.
1602
+ *
1603
+ * @default true
1604
+ */
1605
+ disableWhenPageInvalid?: boolean;
1606
+ /**
1607
+ * Disable next button while the form is submitting.
1608
+ *
1609
+ * @default true
1610
+ */
1611
+ disableWhileSubmitting?: boolean;
1276
1612
  }
1277
1613
 
1278
- /** Represents a FieldTree node for dynamic bracket-access navigation. */
1279
- type FieldTreeRecord = Record<string, FieldTree<unknown> | undefined>;
1280
- /**
1281
- * Type representing a FieldTree for an array.
1282
- * Extends FieldTree to add numeric indexing for accessing item FieldTrees.
1283
- */
1284
- type ArrayFieldTree<T> = FieldTree<T[]> & {
1285
- readonly [index: number]: FieldTree<T> | undefined;
1286
- };
1287
- /** Get the length of an array FieldTree. */
1288
- declare function getArrayLength<T>(arrayFieldTree: ArrayFieldTree<T>): number;
1289
- /** Read-only view of a single field's observable state. */
1290
- interface ReadonlyFieldTree<TValue = unknown> {
1291
- readonly value: Signal<TValue>;
1292
- readonly valid: Signal<boolean>;
1293
- readonly invalid: Signal<boolean>;
1294
- readonly touched: Signal<boolean>;
1295
- readonly dirty: Signal<boolean>;
1296
- readonly required: Signal<boolean>;
1297
- readonly disabled: Signal<boolean>;
1298
- readonly hidden: Signal<boolean>;
1299
- readonly errors: Signal<readonly unknown[]>;
1614
+ /** Context for resolving button disabled state. */
1615
+ interface ButtonLogicContext {
1616
+ /** The form's FieldTree instance (supports both string and number keys for array indices) */
1617
+ form: FieldTree<unknown, string | number>;
1618
+ /** Form-level options */
1619
+ formOptions?: FormOptions;
1620
+ /** Field-level logic array (if provided) */
1621
+ fieldLogic?: LogicConfig[];
1622
+ /** Explicit disabled state from field definition */
1623
+ explicitlyDisabled?: boolean;
1624
+ /** Current page validity signal (for paged forms) */
1625
+ currentPageValid?: Signal<boolean>;
1626
+ /** Current form value for evaluating conditional expressions */
1627
+ formValue?: unknown;
1628
+ /** Optional logger for diagnostic output. Falls back to no-op logger if not provided. */
1629
+ logger?: Logger;
1300
1630
  }
1301
1631
  /**
1302
- * Build a `ReadonlyFieldTree` by extracting the whitelisted read signals from a
1303
- * Signal Forms `FieldTree`. Returns a fresh plain object — no casting, no proxying,
1304
- * so consumers only see the narrow surface and Angular's `WritableSignal` capability
1305
- * on `value` is hidden.
1306
- */
1307
- declare function toReadonlyFieldTree<TValue>(field: FieldTree<TValue>): ReadonlyFieldTree<TValue>;
1308
- /**
1309
- * Write a value into a FieldTree's underlying signal. Signal Forms stores
1310
- * `FieldState.value` as a `WritableSignal`; this helper centralises the cast
1311
- * and warns if that contract ever changes (vs a silent no-op).
1632
+ * Allowed logic types for non-form-bound elements (buttons, text fields, etc.).
1633
+ * These elements only support hidden and disabled states - not readonly or required
1634
+ * since they don't participate in form validation.
1312
1635
  */
1313
- declare function writeToFieldValue<T>(value: Signal<T>, next: T, logger?: {
1314
- warn: (msg: string) => void;
1315
- }): boolean;
1636
+ type NonFieldLogicType = 'hidden' | 'disabled';
1316
1637
  /**
1317
- * DI-scoped cache for `ReadonlyFieldTree` views, keyed on the source FieldTree
1318
- * identity. A fresh WeakMap per root injector keeps renders isolated under SSR —
1319
- * Angular creates a new root injector per request, so there's no shared state
1320
- * between server renders (same pattern as `COMPONENT_CACHE`).
1321
- *
1322
- * @internal
1638
+ * Logic config restricted to types valid for non-form-bound elements.
1639
+ * This is a subset of LogicConfig that only includes hidden and disabled types.
1323
1640
  */
1324
- declare const READONLY_FIELD_TREE_CACHE: InjectionToken<WeakMap<FieldTree<unknown>, ReadonlyFieldTree<unknown>>>;
1325
- /**
1326
- * Cached variant of {@link toReadonlyFieldTree}. Each FieldTree instance is a
1327
- * stable reference for the lifetime of its form, so one `ReadonlyFieldTree`
1328
- * view per tree is enough. Callers on hot paths (`pushInputs` on every mapper
1329
- * emission) avoid re-allocating the nine-property view object.
1641
+ type NonFieldLogicConfig = LogicConfig & {
1642
+ type: NonFieldLogicType;
1643
+ };
1644
+ /** Context for resolving state (hidden/disabled) for non-form-bound elements. */
1645
+ interface NonFieldLogicContext {
1646
+ /** The form's FieldTree instance (supports both string and number keys for array indices) */
1647
+ form: FieldTree<unknown, string | number>;
1648
+ /**
1649
+ * Field-level logic array containing conditions.
1650
+ * Accepts full LogicConfig[] for compatibility, but only hidden and disabled types are processed.
1651
+ */
1652
+ fieldLogic?: LogicConfig[];
1653
+ /** Explicit state from field definition (e.g., `hidden: true` or `disabled: true`) */
1654
+ explicitValue?: boolean;
1655
+ /** Current form value for evaluating conditional expressions */
1656
+ formValue?: unknown;
1657
+ /** Optional logger for diagnostic output. Falls back to no-op logger if not provided. */
1658
+ logger?: Logger;
1659
+ }
1660
+ /**
1661
+ * Resolves the disabled state for a submit button.
1330
1662
  *
1331
- * @internal
1663
+ * @param ctx - The button logic context
1664
+ * @returns A computed signal that returns true when the button should be disabled
1332
1665
  */
1333
- declare function toReadonlyFieldTreeCached<TValue>(cache: WeakMap<FieldTree<unknown>, ReadonlyFieldTree<unknown>>, field: FieldTree<TValue>): ReadonlyFieldTree<TValue>;
1334
-
1335
- /** TTL cache for HTTP condition responses with max entries eviction. */
1336
- declare class HttpConditionCache {
1337
- private readonly cache;
1338
- private readonly maxEntries;
1339
- constructor(maxEntries?: number);
1340
- get(key: string): boolean | undefined;
1341
- set(key: string, value: boolean, ttlMs: number): void;
1342
- clear(): void;
1343
- }
1344
- /** @internal */
1345
- declare const HTTP_CONDITION_CACHE: InjectionToken<HttpConditionCache>;
1346
-
1666
+ declare function resolveSubmitButtonDisabled(ctx: ButtonLogicContext): Signal<boolean>;
1347
1667
  /**
1348
- * Resolves an `HttpRequestConfig` into an `HttpResourceRequest` by evaluating
1349
- * expression-based query params and (optionally) body values.
1668
+ * Resolves the disabled state for a next page button.
1669
+ *
1670
+ * @param ctx - The button logic context
1671
+ * @returns A computed signal that returns true when the button should be disabled
1350
1672
  */
1351
- declare function resolveHttpRequest(config: HttpRequestConfig, context: EvaluationContext): HttpResourceRequest | null;
1352
-
1353
- /** Evaluates an HTTP response against a `HttpValidationResponseMapping` to produce a validation result. */
1354
- declare function evaluateHttpValidationResponse(response: unknown, mapping: HttpValidationResponseMapping, logger: Logger): ValidationError$1 | null;
1355
-
1356
- type DynamicText = string | Observable<string> | Signal<string>;
1673
+ declare function resolveNextButtonDisabled(ctx: ButtonLogicContext): Signal<boolean>;
1674
+ /**
1675
+ * Evaluates the hidden state for non-form-bound elements synchronously.
1676
+ *
1677
+ * @param ctx - The context containing form, logic array, and explicit hidden state
1678
+ * @returns true when the element should be hidden
1679
+ */
1680
+ declare function evaluateNonFieldHidden(ctx: NonFieldLogicContext): boolean;
1681
+ /**
1682
+ * Resolves the hidden state for non-form-bound elements as a reactive signal.
1683
+ *
1684
+ * @param ctx - The context containing form, logic array, and explicit hidden state
1685
+ * @returns A computed signal that returns true when the element should be hidden
1686
+ */
1687
+ declare function resolveNonFieldHidden(ctx: NonFieldLogicContext): Signal<boolean>;
1688
+ /**
1689
+ * Evaluates the disabled state for non-form-bound elements synchronously.
1690
+ *
1691
+ * @param ctx - The context containing form, logic array, and explicit disabled state
1692
+ * @returns true when the element should be disabled
1693
+ */
1694
+ declare function evaluateNonFieldDisabled(ctx: NonFieldLogicContext): boolean;
1695
+ /**
1696
+ * Resolves the disabled state for non-form-bound elements as a reactive signal.
1697
+ *
1698
+ * @param ctx - The context containing form, logic array, and explicit disabled state
1699
+ * @returns A computed signal that returns true when the element should be disabled
1700
+ */
1701
+ declare function resolveNonFieldDisabled(ctx: NonFieldLogicContext): Signal<boolean>;
1357
1702
 
1358
- /** Generic reactive value — a static value, an Angular Signal, or an RxJS Observable. */
1359
- type DynamicValue<T> = T | Signal<T> | Observable<T>;
1703
+ /** Text element type for rendering different HTML text elements */
1704
+ type TextElementType = 'p' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'span';
1705
+ /** Properties for text field configuration */
1706
+ type TextProps = {
1707
+ /** The HTML element type to render */
1708
+ elementType: TextElementType;
1709
+ };
1710
+ /** Text field definition for displaying translatable text content */
1711
+ interface TextField extends FieldDef<TextProps> {
1712
+ type: 'text';
1713
+ /**
1714
+ * Logic rules for conditional visibility.
1715
+ * Text fields only support 'hidden' logic type since they are display-only
1716
+ * and don't participate in form validation (no disabled/readonly/required).
1717
+ */
1718
+ readonly logic?: NonFieldLogicConfig[];
1719
+ }
1360
1720
 
1361
- /** Universal addon slot names supported by every adapter. */
1362
- type CommonAddonSlot = 'prefix' | 'suffix';
1363
- /** Module-augmentable registry of adapter-specific addon slot names. */
1364
- interface DynamicFormAddonSlotRegistry {
1721
+ /** Configuration for the built-in 'css' wrapper type. */
1722
+ interface CssWrapper {
1723
+ readonly type: 'css';
1724
+ /** CSS classes to apply to the wrapper */
1725
+ readonly cssClasses?: DynamicText;
1365
1726
  }
1366
- /**
1367
- * Union of every valid addon slot — universal slots plus any registered via
1368
- * {@link DynamicFormAddonSlotRegistry} module augmentation.
1369
- */
1370
- type AddonSlot = CommonAddonSlot | keyof DynamicFormAddonSlotRegistry;
1371
1727
 
1372
- /** Base shape every addon kind extends. */
1373
- interface BaseAddon<TSlot extends AddonSlot = AddonSlot> {
1374
- /** Slot to render this addon in. */
1375
- readonly slot: TSlot;
1376
- /** CSS class applied to the addon host element. */
1377
- readonly className?: string;
1378
- /** Reactive visibility — when `true`, the addon is removed from layout. */
1379
- readonly hidden?: DynamicValue<boolean>;
1380
- /** Reactive disabled state — primarily relevant for interactive kinds. */
1381
- readonly disabled?: DynamicValue<boolean>;
1728
+ /** Configuration for the built-in 'row' wrapper type. */
1729
+ interface RowWrapper {
1730
+ readonly type: 'row';
1382
1731
  }
1383
- /** Module-augmentable registry of addon kinds. */
1384
- interface DynamicFormAddonRegistry {
1385
- text: TextAddon;
1386
- template: TemplateAddon;
1387
- component: ComponentAddon;
1732
+
1733
+ /** Container fields registry - augment this interface to add custom container fields */
1734
+ interface FieldRegistryContainers {
1735
+ page: PageField;
1736
+ row: RowField;
1737
+ group: GroupField;
1738
+ array: ArrayField | SimplifiedArrayField;
1739
+ container: ContainerField;
1388
1740
  }
1389
- /** Union of every registered addon shape. */
1390
- type AnyAddon = DynamicFormAddonRegistry[keyof DynamicFormAddonRegistry];
1391
- /** Renders text content inline. */
1392
- interface TextAddon extends BaseAddon {
1393
- readonly kind: 'text';
1394
- readonly text: DynamicText;
1741
+ /** Leaf fields registry - augment this interface to add custom leaf fields */
1742
+ interface FieldRegistryLeaves {
1743
+ text: TextField;
1744
+ hidden: HiddenField;
1395
1745
  }
1396
- /** Renders a named `<ng-template>` projected into the host `<df-dynamic-form>`. */
1397
- interface TemplateAddon extends BaseAddon {
1398
- readonly kind: 'template';
1399
- readonly templateKey: string;
1746
+ /** Wrapper type registry for module augmentation. */
1747
+ interface FieldRegistryWrappers {
1748
+ css: CssWrapper;
1749
+ row: RowWrapper;
1400
1750
  }
1401
1751
  /**
1402
- * Renders an arbitrary Angular component as the addon body.
1403
- *
1404
- * @codeOnly The `component` loader is a function and cannot survive
1405
- * `JSON.stringify`/`parse`. The lenient validator drops this kind when the
1406
- * config originated from JSON (set via `sanitizeFormConfig({ source: 'json' })`).
1752
+ * Global interface for dynamic form field definitions with categorization
1753
+ * This interface combines containers and leaves from their respective registries
1407
1754
  */
1408
- interface ComponentAddon extends BaseAddon {
1409
- readonly kind: 'component';
1410
- readonly component: () => Promise<Type<unknown> | {
1411
- default: Type<unknown>;
1412
- }>;
1413
- readonly inputs?: Record<string, unknown>;
1755
+ interface DynamicFormFieldRegistry {
1756
+ /** Container fields that hold other fields (no value, have children) */
1757
+ containers: FieldRegistryContainers;
1758
+ /** Leaf fields that have values or display content */
1759
+ leaves: FieldRegistryLeaves;
1760
+ /** Field wrappers types */
1761
+ wrappers: FieldRegistryWrappers;
1414
1762
  }
1415
-
1416
- type WithInputSignals<T> = {
1417
- readonly [K in keyof T]-?: Signal<T[K]>;
1418
- };
1419
-
1420
- type Prettify<T> = {
1421
- [K in keyof T]: T[K];
1422
- } & {};
1763
+ /** Union type of all registered container field definitions */
1764
+ type ContainerFieldTypes = DynamicFormFieldRegistry['containers'][keyof DynamicFormFieldRegistry['containers']];
1765
+ /** Union type of all registered leaf field definitions */
1766
+ type LeafFieldTypes = DynamicFormFieldRegistry['leaves'][keyof DynamicFormFieldRegistry['leaves']];
1767
+ /** Union type of all registered field definitions */
1768
+ type RegisteredFieldTypes = ContainerFieldTypes | LeafFieldTypes;
1769
+ /** Extract field types that are available in the registry */
1770
+ type AvailableFieldTypes = keyof DynamicFormFieldRegistry['containers'] | keyof DynamicFormFieldRegistry['leaves'];
1771
+ /** Extract wrapper types that are available in the registry */
1772
+ type RegisteredWrapperTypes = keyof DynamicFormFieldRegistry['wrappers'];
1773
+ /**
1774
+ * Combined registry mapping type names to field definitions.
1775
+ * This flattens containers and leaves into a single mapping.
1776
+ */
1777
+ type FieldTypeMap = DynamicFormFieldRegistry['containers'] & DynamicFormFieldRegistry['leaves'];
1778
+ /**
1779
+ * Extract a specific field type from RegisteredFieldTypes based on the `type` discriminant.
1780
+ * This enables proper type narrowing when defining fields.
1781
+ */
1782
+ type ExtractField<T extends AvailableFieldTypes> = T extends keyof FieldTypeMap ? FieldTypeMap[T] : never;
1783
+ /**
1784
+ * Narrow a field definition based on its `type` property.
1785
+ * Use this to get proper type inference when working with field unions.
1786
+ */
1787
+ type NarrowField<T> = T extends {
1788
+ type: infer TType;
1789
+ } ? (TType extends AvailableFieldTypes ? ExtractField<TType> : T) : T;
1790
+ /**
1791
+ * Narrow each field in an array based on its `type` property.
1792
+ * Use with `satisfies` to get proper type inference for field arrays.
1793
+ */
1794
+ type NarrowFields = readonly NarrowField<RegisteredFieldTypes>[];
1423
1795
 
1424
1796
  /** Resolves a wrapper type name to its registered config interface. */
1425
1797
  type WrapperConfig<TWrappers extends RegisteredWrapperTypes = RegisteredWrapperTypes> = TWrappers extends keyof FieldRegistryWrappers ? FieldRegistryWrappers[TWrappers] : {
@@ -1490,906 +1862,853 @@ declare const WRAPPER_COMPONENT_CACHE: InjectionToken<Map<string, Type<unknown>>
1490
1862
  */
1491
1863
  declare const WRAPPER_AUTO_ASSOCIATIONS: InjectionToken<WrapperAutoAssociations>;
1492
1864
 
1493
- /** Base interface for native HTML attributes that can be passed to form field elements. */
1494
- interface FieldMeta {
1495
- /** Allows any data-* attribute */
1496
- [key: `data-${string}`]: string | undefined;
1497
- /** Allows any aria-* attribute */
1498
- [key: `aria-${string}`]: string | boolean | undefined;
1499
- /** Allows additional custom attributes as escape hatch */
1500
- [key: string]: string | number | boolean | undefined;
1865
+ /**
1866
+ * Minimal JSON Schema fragment used by the MCP server to surface an addon
1867
+ * type's shape to AI form generators. Covers the common subset
1868
+ * (`type`/`properties`/`required`/`enum`/etc.) without pulling in a full JSON
1869
+ * Schema dependency. Extra keys are allowed via the `[key: string]` index so
1870
+ * vendor-specific annotations (`x-foo`, `markdownDescription`) still typecheck.
1871
+ */
1872
+ interface AddonTypeSchema {
1873
+ readonly $ref?: string;
1874
+ readonly $schema?: string;
1875
+ readonly title?: string;
1876
+ readonly description?: string;
1877
+ readonly type?: 'object' | 'array' | 'string' | 'number' | 'integer' | 'boolean' | 'null' | ReadonlyArray<'object' | 'array' | 'string' | 'number' | 'integer' | 'boolean' | 'null'>;
1878
+ readonly enum?: ReadonlyArray<unknown>;
1879
+ readonly const?: unknown;
1880
+ readonly properties?: Readonly<Record<string, AddonTypeSchema>>;
1881
+ readonly required?: ReadonlyArray<string>;
1882
+ readonly additionalProperties?: boolean | AddonTypeSchema;
1883
+ readonly items?: AddonTypeSchema | ReadonlyArray<AddonTypeSchema>;
1884
+ readonly oneOf?: ReadonlyArray<AddonTypeSchema>;
1885
+ readonly anyOf?: ReadonlyArray<AddonTypeSchema>;
1886
+ readonly allOf?: ReadonlyArray<AddonTypeSchema>;
1887
+ readonly not?: AddonTypeSchema;
1888
+ readonly default?: unknown;
1889
+ readonly examples?: ReadonlyArray<unknown>;
1890
+ readonly minimum?: number;
1891
+ readonly maximum?: number;
1892
+ readonly minLength?: number;
1893
+ readonly maxLength?: number;
1894
+ readonly pattern?: string;
1895
+ readonly format?: string;
1896
+ /** Vendor extensions and unrecognised keywords pass through untyped. */
1897
+ readonly [key: string]: unknown;
1501
1898
  }
1502
-
1503
1899
  /**
1504
- * Base interface for all dynamic form field definitions.
1505
- *
1506
- * @typeParam TProps - Field-specific properties interface
1507
- * @typeParam TMeta - Native HTML attributes interface (extends FieldMeta)
1900
+ * Optional shape validator a type ships to enforce its required fields at
1901
+ * runtime. Throws are caught by the validator and converted into lenient
1902
+ * warnings; the offending addon is dropped and the form keeps rendering.
1508
1903
  */
1509
- interface FieldDef<TProps, TMeta extends FieldMeta = FieldMeta> {
1510
- /** Unique field identifier used for form binding and value tracking. */
1511
- key: string;
1512
- /** Field type identifier for component selection. */
1513
- type: RegisteredFieldTypes['type'] | (string & {});
1514
- /** Human-readable field label displayed to users. */
1515
- label?: DynamicText;
1516
- /** Field-specific properties and configuration options. */
1517
- props?: TProps;
1518
- /** Native HTML attributes to pass through to the underlying element. */
1519
- meta?: TMeta;
1520
- /** Additional CSS classes for custom styling. */
1521
- className?: string;
1522
- /**
1523
- * Whether the field is disabled and cannot be interacted with.
1524
- *
1525
- * @value false
1526
- */
1527
- disabled?: boolean;
1528
- /**
1529
- * Whether the field is read-only.
1530
- *
1531
- * @value false
1532
- */
1533
- readonly?: boolean;
1534
- /**
1535
- * Whether the field is hidden from view.
1536
- *
1537
- * @value false
1538
- */
1539
- hidden?: boolean;
1540
- /** Tab index for keyboard navigation. */
1541
- tabIndex?: number | undefined;
1542
- /**
1543
- * Whether to exclude this field's value from submission output when hidden.
1544
- *
1545
- * @default undefined (uses form-level or global setting)
1546
- */
1547
- excludeValueIfHidden?: boolean;
1548
- /**
1549
- * Whether to exclude this field's value from submission output when disabled.
1550
- *
1551
- * @default undefined (uses form-level or global setting)
1552
- */
1553
- excludeValueIfDisabled?: boolean;
1554
- /**
1555
- * Whether to exclude this field's value from submission output when readonly.
1556
- *
1557
- * @default undefined (uses form-level or global setting)
1558
- */
1559
- excludeValueIfReadonly?: boolean;
1560
- /**
1561
- * Whether to run validation when this field is hidden — statically (`hidden: true`),
1562
- * via a `hidden` logic rule, or via any hidden ancestor.
1563
- *
1564
- * @default undefined — inherits from parent / form / global default (which is `false`)
1565
- */
1566
- validateWhenHidden?: boolean;
1567
- /**
1568
- * Column sizing configuration for responsive grid layout.
1569
- *
1570
- * @value 12
1571
- */
1572
- col?: number;
1573
- /** Wrapper components to chain around this field. */
1574
- wrappers?: readonly WrapperConfig[] | null;
1575
- /**
1576
- * Skip the auto-association layer (`WrapperTypeDefinition.types`) while
1577
- * keeping form-level defaults and any field-level `wrappers`. Use when a
1578
- * global wrapper auto-applies to this field type but isn't wanted here.
1579
- */
1580
- skipAutoWrappers?: boolean;
1904
+ type AddonShapeValidator<T extends BaseAddon = BaseAddon> = (addon: T, fieldKey: string) => void;
1905
+ /** Per-type registration metadata. */
1906
+ interface AddonTypeDefinition<T extends BaseAddon = BaseAddon> {
1907
+ /** Discriminant matching `addon.type`. */
1908
+ readonly type: string;
1909
+ /** Lazy loader for the type's renderer component. */
1910
+ readonly loadComponent: LazyComponentLoader;
1911
+ /** Optional shape validator — throw `DynamicFormError` to drop the addon with a warning. */
1912
+ readonly validate?: AddonShapeValidator<T>;
1913
+ /** Optional JSON Schema fragment for MCP / pre-flight tooling. */
1914
+ readonly schema?: AddonTypeSchema;
1581
1915
  /**
1582
- * Skip the form-level `defaultWrappers` layer while keeping auto-associations
1583
- * and any field-level `wrappers`.
1916
+ * Whether the type survives `JSON.stringify` / `JSON.parse`. Types whose
1917
+ * shape includes a function payload (e.g., the built-in `'component'`
1918
+ * loader, inline `prime-button` `action` handlers) declare `jsonSafe: false`
1919
+ * so the validator drops them when the config was loaded from a JSON
1920
+ * source (`sanitizeFormConfig(config, { source: 'json' })`). Defaults to
1921
+ * `true` — types are JSON-safe unless explicitly opted out.
1584
1922
  */
1585
- skipDefaultWrappers?: boolean;
1586
- /** Addons rendered inside this field's slots (typically `prefix` / `suffix`). */
1587
- addons?: ReadonlyArray<AnyAddon>;
1923
+ readonly jsonSafe?: boolean;
1588
1924
  }
1589
- type IncludedKeys = 'label' | 'className' | 'hidden' | 'tabIndex';
1925
+ /** Per-field-type addon-support metadata declared at field registration. */
1926
+ interface FieldAddonSupport {
1927
+ /** Slots a field of this type accepts. */
1928
+ readonly slots: readonly AddonSlot[];
1929
+ /** Optional whitelist of allowed addon types. Omitted = any registered type. */
1930
+ readonly allowedTypes?: readonly string[];
1931
+ }
1932
+ /** Global registry of addon types. */
1933
+ declare const ADDON_TYPE_REGISTRY: InjectionToken<Map<string, AddonTypeDefinition<BaseAddon<AddonSlot>>>>;
1590
1934
  /**
1591
- * Type utility for extracting component input properties from field definitions.
1935
+ * Cache for resolved addon-type components. Provided at form scope by
1936
+ * `provideDynamicForm`.
1592
1937
  *
1593
- * @Component({...})
1594
- * export class MyFieldComponent implements FieldComponent<MyFieldDef> {
1595
- * label = input<string>();
1596
- * className = input<string>();
1597
- * hidden = input<boolean>();
1598
- * tabIndex = input<number>();
1599
- * }
1600
- * ```
1601
- * @typeParam T - Field definition type to extract properties from
1938
+ * @internal
1602
1939
  */
1603
- type FieldComponent<T extends FieldDef<unknown, FieldMeta>> = Prettify<WithInputSignals<Pick<T, IncludedKeys>>>;
1940
+ declare const ADDON_TYPE_COMPONENT_CACHE: InjectionToken<Map<string, Type<unknown>>>;
1604
1941
 
1605
1942
  /**
1606
- * Logic configuration for container fields (page, group, row, array).
1607
- * Containers only support the 'hidden' logic type since they are layout containers,
1608
- * not form controls (they can't be readonly, disabled, or required).
1943
+ * Multi-provider token used by `withCustomAddon(...)` features to contribute
1944
+ * addon type definitions. `provideDynamicForm` aggregates all values into
1945
+ * the form-scoped `ADDON_TYPE_REGISTRY` map.
1946
+ *
1947
+ * @internal
1609
1948
  */
1610
- interface ContainerLogicConfig {
1611
- /** Only 'hidden' is supported for container fields */
1612
- type: 'hidden';
1613
- /**
1614
- * Condition that determines when this container is hidden.
1615
- * Can be a boolean or a conditional expression evaluated against form values.
1616
- */
1617
- condition: ConditionalExpression | boolean;
1618
- }
1949
+ declare const ADDON_TYPE_DEFINITIONS: InjectionToken<readonly AddonTypeDefinition<_ng_forge_dynamic_forms_internal.BaseAddon<_ng_forge_dynamic_forms_internal.AddonSlot>>[]>;
1619
1950
 
1951
+ /** Represents a FieldTree node for dynamic bracket-access navigation. */
1952
+ type FieldTreeRecord = Record<string, FieldTree<unknown> | undefined>;
1620
1953
  /**
1621
- * Row field interface for creating horizontal layouts.
1622
- * A row is a synthetic field type that resolves to a Container at runtime,
1623
- * with a synthesized `{ type: 'row' }` wrapper applied for layout. The row
1624
- * itself does not hold a value — its children flatten into the parent form.
1954
+ * Type representing a FieldTree for an array.
1955
+ * Extends FieldTree to add numeric indexing for accessing item FieldTrees.
1625
1956
  */
1626
- interface RowField<TFields extends readonly RowAllowedChildren[] = readonly RowAllowedChildren[]> extends FieldDef<never> {
1627
- type: 'row';
1628
- /** Child definitions to render within this row */
1629
- readonly fields: TFields;
1630
- /** Row fields do not have a label property * */
1631
- readonly label?: never;
1632
- /** Rows do not support meta - they have no native form element * */
1633
- readonly meta?: never;
1634
- /**
1635
- * Logic configurations for conditional row visibility.
1636
- * Only 'hidden' type logic is supported for rows.
1637
- */
1638
- readonly logic?: ContainerLogicConfig[];
1957
+ type ArrayFieldTree<T> = FieldTree<T[]> & {
1958
+ readonly [index: number]: FieldTree<T> | undefined;
1959
+ };
1960
+ /** Get the length of an array FieldTree. */
1961
+ declare function getArrayLength<T>(arrayFieldTree: ArrayFieldTree<T>): number;
1962
+ /** Read-only view of a single field's observable state. */
1963
+ interface ReadonlyFieldTree<TValue = unknown> {
1964
+ readonly value: Signal<TValue>;
1965
+ readonly valid: Signal<boolean>;
1966
+ readonly invalid: Signal<boolean>;
1967
+ readonly touched: Signal<boolean>;
1968
+ readonly dirty: Signal<boolean>;
1969
+ readonly required: Signal<boolean>;
1970
+ readonly disabled: Signal<boolean>;
1971
+ readonly hidden: Signal<boolean>;
1972
+ readonly errors: Signal<readonly unknown[]>;
1639
1973
  }
1640
- /** Type guard for RowField with proper type narrowing */
1641
- declare function isRowField(field: FieldDef<any>): field is RowField;
1642
- type RowComponent = FieldComponent<RowField<RowAllowedChildren[]>>;
1643
-
1644
1974
  /**
1645
- * Group field interface for creating logical field groupings that map to object values
1646
- * Groups create nested form structures where child field values are collected into an object
1647
- * This is a programmatic grouping only - users cannot customize this field type
1975
+ * Build a `ReadonlyFieldTree` by extracting the whitelisted read signals from a
1976
+ * Signal Forms `FieldTree`. Returns a fresh plain object — no casting, no proxying,
1977
+ * so consumers only see the narrow surface and Angular's `WritableSignal` capability
1978
+ * on `value` is hidden.
1648
1979
  */
1649
- interface GroupField<TFields extends readonly GroupAllowedChildren[] = readonly GroupAllowedChildren[]> extends FieldDef<never> {
1650
- type: 'group';
1651
- readonly fields: TFields;
1652
- /** Groups do not have a label property - they are logical containers only * */
1653
- readonly label?: never;
1654
- /** Groups do not support meta - they have no native form element * */
1655
- readonly meta?: never;
1656
- /**
1657
- * Logic configurations for conditional group visibility.
1658
- * Only 'hidden' type logic is supported for groups.
1659
- */
1660
- readonly logic?: ContainerLogicConfig[];
1661
- }
1662
- /** Type guard for GroupField with proper type narrowing */
1663
- declare function isGroupField(field: FieldDef<any>): field is GroupField;
1664
- type GroupComponent<T extends GroupAllowedChildren[]> = FieldComponent<GroupField<T>>;
1980
+ declare function toReadonlyFieldTree<TValue>(field: FieldTree<TValue>): ReadonlyFieldTree<TValue>;
1981
+ /**
1982
+ * Write a value into a FieldTree's underlying signal. Signal Forms stores
1983
+ * `FieldState.value` as a `WritableSignal`; this helper centralises the cast
1984
+ * and warns if that contract ever changes (vs a silent no-op).
1985
+ */
1986
+ declare function writeToFieldValue<T>(value: Signal<T>, next: T, logger?: {
1987
+ warn: (msg: string) => void;
1988
+ }): boolean;
1989
+ /**
1990
+ * DI-scoped cache for `ReadonlyFieldTree` views, keyed on the source FieldTree
1991
+ * identity. A fresh WeakMap per root injector keeps renders isolated under SSR —
1992
+ * Angular creates a new root injector per request, so there's no shared state
1993
+ * between server renders (same pattern as `COMPONENT_CACHE`).
1994
+ *
1995
+ * @internal
1996
+ */
1997
+ declare const READONLY_FIELD_TREE_CACHE: InjectionToken<WeakMap<FieldTree<unknown>, ReadonlyFieldTree<unknown>>>;
1998
+ /**
1999
+ * Cached variant of {@link toReadonlyFieldTree}. Each FieldTree instance is a
2000
+ * stable reference for the lifetime of its form, so one `ReadonlyFieldTree`
2001
+ * view per tree is enough. Callers on hot paths (`pushInputs` on every mapper
2002
+ * emission) avoid re-allocating the nine-property view object.
2003
+ *
2004
+ * @internal
2005
+ */
2006
+ declare function toReadonlyFieldTreeCached<TValue>(cache: WeakMap<FieldTree<unknown>, ReadonlyFieldTree<unknown>>, field: FieldTree<TValue>): ReadonlyFieldTree<TValue>;
1665
2007
 
1666
- /** Container field interface for wrapping child fields with UI chrome. */
1667
- interface ContainerField<TFields extends readonly ContainerAllowedChildren[] = readonly ContainerAllowedChildren[], TWrapperConfigs extends readonly WrapperConfig[] = readonly WrapperConfig[]> extends FieldDef<never> {
1668
- type: 'container';
1669
- /** Child definitions to render within this container */
1670
- readonly fields: TFields;
1671
- /**
1672
- * Wrapper components to chain around the children.
1673
- * Applied outermost-first: the first wrapper in the array is the outermost.
1674
- * Each wrapper component receives the subsequent wrapper (or children) inside
1675
- * its `#fieldComponent` ViewContainerRef slot.
1676
- */
1677
- readonly wrappers: TWrapperConfigs;
1678
- /** Container fields do not have a label property */
1679
- readonly label?: never;
1680
- /** Containers do not support meta — they have no native form element */
1681
- readonly meta?: never;
2008
+ /** Input shape passed to a wrapper component via the `fieldInputs` input. */
2009
+ interface WrapperFieldInputs {
2010
+ readonly key: string;
2011
+ /** Field-type discriminant (mirrors `FieldDef.type`) — useful for kind-aware addons. */
2012
+ readonly type?: string;
2013
+ readonly label?: string;
2014
+ readonly placeholder?: string;
2015
+ readonly className?: string;
2016
+ readonly props?: Record<string, unknown>;
2017
+ readonly validationMessages?: Record<string, string>;
2018
+ readonly defaultValidationMessages?: Record<string, string>;
2019
+ readonly field?: ReadonlyFieldTree;
1682
2020
  /**
1683
- * Logic configurations for conditional container visibility.
1684
- * Only 'hidden' type logic is supported for containers.
2021
+ * Write a value into the wrapped field's tree. Provided by `buildFieldInputs`
2022
+ * when a `FieldTree` is present. Addons (e.g., `prime-button` presets) use this
2023
+ * to mutate the host field; wrappers should treat the field as read-only.
1685
2024
  */
1686
- readonly logic?: ContainerLogicConfig[];
2025
+ readonly setValue?: (next: unknown) => void;
2026
+ readonly [key: string]: unknown;
1687
2027
  }
1688
- /** Type guard for ContainerField with proper type narrowing. */
1689
- declare function isContainerTypedField(field: FieldDef<any>): field is ContainerField;
1690
- type ContainerComponent = FieldComponent<ContainerField<ContainerAllowedChildren[]>>;
1691
2028
 
1692
2029
  /**
1693
- * Type constraints for field nesting rules
1694
- * These ensure that container fields can only contain valid child field types
2030
+ * Dispatcher component that renders an addon by looking up its `type` in
2031
+ * `ADDON_TYPE_REGISTRY` and instantiating the registered component.
1695
2032
  */
2033
+ declare class DfAddonSlot {
2034
+ private readonly registry;
2035
+ private readonly logger;
2036
+ private readonly hostInjector;
2037
+ readonly addon: i0.InputSignal<AnyAddon>;
2038
+ /**
2039
+ * Optional read-only view of the host field's mapped inputs — same shape
2040
+ * wrappers receive (`field?: ReadonlyFieldTree`, `key`, `props`, etc.).
2041
+ * Forwarded to type components so they can read field state without
2042
+ * re-injecting `FIELD_SIGNAL_CONTEXT` and rebuilding context themselves.
2043
+ */
2044
+ readonly fieldInputs: i0.InputSignal<WrapperFieldInputs | undefined>;
2045
+ /**
2046
+ * Pre-resolved `hidden` signal supplied by the host field. When provided,
2047
+ * the dispatcher reads this instead of re-resolving `addon.hidden` —
2048
+ * lets the host (e.g., `prime-input`) share a single subscription per
2049
+ * Observable-typed `hidden` between its own visibility filter and the
2050
+ * slot's `[style.display]` binding.
2051
+ */
2052
+ readonly hidden: i0.InputSignal<Signal<boolean> | undefined>;
2053
+ /** `slot` HTML attribute forwarded to host — needed for Ionic shadow projection. */
2054
+ protected readonly slotAttr: Signal<_ng_forge_dynamic_forms_internal.AddonSlot>;
2055
+ protected readonly className: Signal<string | null>;
2056
+ /**
2057
+ * Locally-resolved `hidden` signal — always reflects `addon.hidden`
2058
+ * regardless of whether the host supplied a pre-resolved signal.
2059
+ * Populated via `explicitEffect` so `resolveDynamicValue` (which may call
2060
+ * `toSignal` for Observable-typed values) does NOT run inside a reactive
2061
+ * context (NG0602). The WeakMap caches per `hidden`-value identity, so
2062
+ * swapping `addon` inputs that share the same Observable reuses the
2063
+ * subscription instead of leaking a fresh one per swap.
2064
+ */
2065
+ private readonly _hiddenByValue;
2066
+ private readonly _resolvedHidden;
2067
+ /**
2068
+ * `hidden` resolved from `DynamicValue<boolean>` to a flat `Signal<boolean>`.
2069
+ * Prefers the host-supplied signal when present (avoids duplicate `toSignal`
2070
+ * subscriptions for Observable-typed `hidden`); falls back to the locally-
2071
+ * resolved signal, which is always populated by the addon-tracking effect.
2072
+ */
2073
+ protected readonly isHidden: Signal<boolean>;
2074
+ /**
2075
+ * Latest async-loaded `{ type, component }` pair. Tagging the result with
2076
+ * its type lets `resolvedComponent` filter stale loads structurally — no
2077
+ * monotonic token needed. When `addon.type` changes mid-load, the prior
2078
+ * load still completes and writes here, but the computed ignores it
2079
+ * because the recorded type no longer matches the current one.
2080
+ */
2081
+ private readonly asyncLoaded;
2082
+ /**
2083
+ * Resolved type component — composed declaratively from two sources of
2084
+ * truth: the registry's synchronous cache (warm hits, e.g., a second
2085
+ * `<df-addon-slot>` for an already-loaded type) and the type-tagged async
2086
+ * loader result. Reading `addon().type` first makes the computed react to
2087
+ * addon swaps and naturally invalidate stale async-load results.
2088
+ */
2089
+ protected readonly resolvedComponent: Signal<Type<unknown> | undefined>;
2090
+ /** Inputs passed to the type component — addon plus the wrapper-style host bag. */
2091
+ protected readonly typeInputs: Signal<{
2092
+ addon: AnyAddon;
2093
+ fieldInputs: WrapperFieldInputs | undefined;
2094
+ }>;
2095
+ constructor();
2096
+ static ɵfac: i0.ɵɵFactoryDeclaration<DfAddonSlot, never>;
2097
+ static ɵcmp: i0.ɵɵComponentDeclaration<DfAddonSlot, "df-addon-slot", never, { "addon": { "alias": "addon"; "required": true; "isSignal": true; }; "fieldInputs": { "alias": "fieldInputs"; "required": false; "isSignal": true; }; "hidden": { "alias": "hidden"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
2098
+ }
2099
+
1696
2100
  /**
1697
- * Fields that are allowed as children of Page fields
1698
- * Pages can contain: rows, groups, arrays, and leaf fields (but NOT other pages)
2101
+ * Public shape returned by {@link injectAddonTypeRegistry}. Pinned explicitly
2102
+ * so the API extractor doesn't churn between versions when the inner factory
2103
+ * gets refactored.
1699
2104
  */
1700
- type PageAllowedChildren = LeafFieldTypes | RowField | GroupField | ArrayField | SimplifiedArrayField | ContainerField;
2105
+ interface AddonTypeRegistryRef {
2106
+ getType(type: string): AddonTypeDefinition | undefined;
2107
+ hasType(type: string): boolean;
2108
+ getTypeNames(): string[];
2109
+ loadTypeComponent(type: string): Promise<Type<unknown>>;
2110
+ getLoadedTypeComponent(type: string): Type<unknown> | undefined;
2111
+ readonly raw: ReadonlyMap<string, AddonTypeDefinition>;
2112
+ }
2113
+ /** Injection function for accessing the addon type registry. */
2114
+ declare function injectAddonTypeRegistry(): AddonTypeRegistryRef;
2115
+
2116
+ /** One entry per field type that declares addon support. */
2117
+ interface FieldAddonSupportEntry {
2118
+ readonly name: string;
2119
+ readonly slots: FieldAddonSupport['slots'];
2120
+ readonly allowedTypes: FieldAddonSupport['allowedTypes'];
2121
+ }
1701
2122
  /**
1702
- * Fields that are allowed as children of Group fields
1703
- * Groups can contain: rows, arrays, and leaf fields (but NOT pages or other groups)
2123
+ * Walk `FIELD_REGISTRY` and return every field type that opted into addons
2124
+ * (i.e., declared `addons` on its `FieldTypeDefinition`).
2125
+ *
2126
+ * @Component({ ... })
2127
+ * class FormBuilder {
2128
+ * protected readonly addonable = injectFieldsSupportingAddons();
2129
+ *
2130
+ * constructor() {
2131
+ * // -> [{ name: 'prime-input', slots: ['prefix', 'suffix'], allowedTypes: [...] }, ...]
2132
+ * }
2133
+ * }
2134
+ * ```
1704
2135
  */
1705
- type GroupAllowedChildren = LeafFieldTypes | RowField | ArrayField | SimplifiedArrayField | ContainerField;
2136
+ declare function injectFieldsSupportingAddons(): FieldAddonSupportEntry[];
2137
+
1706
2138
  /**
1707
- * Fields that are allowed as children of Array fields
1708
- * Arrays can contain: rows, groups, and leaf fields (but NOT pages or other arrays)
1709
- * Groups are used for creating object arrays where each array item is an object
2139
+ * Fields every addon-action context carries, regardless of whether the
2140
+ * addon is bound to a host field or rendered orphaned.
1710
2141
  */
1711
- type ArrayAllowedChildren = LeafFieldTypes | RowField | GroupField | ContainerField;
2142
+ interface AddonActionContextBase<TValue> {
2143
+ /**
2144
+ * Identity of the host field this addon is attached to. Empty strings
2145
+ * indicate the addon is rendered outside an active field context (rare).
2146
+ * Use {@link isFieldBoundContext} or the `form !== null` check to
2147
+ * narrow before relying on field identity.
2148
+ */
2149
+ readonly field: {
2150
+ readonly key: string;
2151
+ readonly type: string;
2152
+ };
2153
+ /**
2154
+ * Current value of the host field at the time the action fires.
2155
+ * `undefined` when the host field has no value yet (initial render before
2156
+ * defaultValue resolution) or when the addon is rendered outside a field.
2157
+ */
2158
+ readonly value: TValue | undefined;
2159
+ }
1712
2160
  /**
1713
- * Fields that are allowed as children of Container fields.
1714
- * Containers are pure layout primitives that flatten their children into the
1715
- * parent form, so most registered field types may appear inside — including
1716
- * hidden fields and other containers — but NOT pages.
2161
+ * Field-bound variant — the addon is attached to a real field and has a
2162
+ * working value-writer. The common case for `pi-button` / `mat-button` /
2163
+ * `bs-button` / `ion-button` inside an adapter input field.
1717
2164
  */
1718
- type ContainerAllowedChildren = LeafFieldTypes | RowField | GroupField | ArrayField | SimplifiedArrayField | ContainerField;
2165
+ interface FieldBoundAddonActionContext<TValue = unknown> extends AddonActionContextBase<TValue> {
2166
+ /** Read-only view of the host field's tree — same view wrappers receive. */
2167
+ readonly form: ReadonlyFieldTree<TValue>;
2168
+ /** Push a new value into the host field. */
2169
+ readonly setValue: (next: TValue) => void;
2170
+ }
1719
2171
  /**
1720
- * Row is a synthetic field type that resolves to a Container at runtime, so
1721
- * it accepts the same children as a Container.
2172
+ * Orphan variant — the addon is rendered outside any field component (rare;
2173
+ * happens when consumers compose `<df-addon-slot>` directly without a host
2174
+ * field). No writer is reachable; reading `value` may also yield `undefined`.
1722
2175
  */
1723
- type RowAllowedChildren = ContainerAllowedChildren;
1724
-
2176
+ interface OrphanAddonActionContext<TValue = unknown> extends AddonActionContextBase<TValue> {
2177
+ readonly form: null;
2178
+ /** Always absent in the orphan variant — distinguishes the union members. */
2179
+ readonly setValue?: undefined;
2180
+ }
2181
+ /** Context handed to inline addon actions and registered handler functions. */
2182
+ type AddonActionContext<TValue = unknown> = FieldBoundAddonActionContext<TValue> | OrphanAddonActionContext<TValue>;
2183
+ /** Type guard narrowing {@link AddonActionContext} to its field-bound variant. */
2184
+ declare function isFieldBoundContext<TValue>(ctx: AddonActionContext<TValue>): ctx is FieldBoundAddonActionContext<TValue>;
2185
+ /** Built-in preset actions shared across adapters. */
2186
+ type CommonAddonActionPreset = 'clear' | 'reset' | 'paste' | 'copy' | 'toggle-password-visibility';
2187
+ /** Module-augmentable registry of adapter-specific preset names. */
2188
+ interface DynamicFormAddonActionPresetRegistry {
2189
+ }
1725
2190
  /**
1726
- * An array item template is an array of allowed children that defines one OBJECT array item's fields.
1727
- * Used for object arrays where each item is `{ key1: value1, key2: value2, ... }`.
2191
+ * Union of every preset name an addon may reference — universal presets
2192
+ * plus any contributed via {@link DynamicFormAddonActionPresetRegistry}.
1728
2193
  */
1729
- type ArrayItemTemplate = readonly ArrayAllowedChildren[];
2194
+ type AddonActionPreset = CommonAddonActionPreset | keyof DynamicFormAddonActionPresetRegistry | (string & {});
2195
+ /** Module-augmentable registry of user-defined named action handlers. */
2196
+ interface DynamicFormActionRegistry {
2197
+ }
1730
2198
  /**
1731
- * An array item definition can be either:
1732
- * - A single field (ArrayAllowedChildren) for PRIMITIVE array items - extracts field value directly
1733
- * - An array of fields (ArrayItemTemplate) for OBJECT array items - merges fields into object
2199
+ * Typed string handle to a registered action handler. The empty registry
2200
+ * resolves to `never`; augmenting `DynamicFormActionRegistry` populates the
2201
+ * union and unlocks autocomplete.
1734
2202
  */
1735
- type ArrayItemDefinition = ArrayAllowedChildren | ArrayItemTemplate;
1736
- /** Array field interface for creating dynamic field collections that map to array values. */
1737
- interface ArrayField<TFields extends readonly ArrayItemDefinition[] = readonly ArrayItemDefinition[]> extends FieldDef<never> {
1738
- type: 'array';
1739
- /**
1740
- * Array of item definitions. Each element defines one array item:
1741
- * - Single FieldDef = primitive item (field's value is extracted directly)
1742
- * - Array of FieldDefs = object item (fields are merged into an object)
1743
- * - Empty array `[]` = no initial items (add via buttons with explicit templates)
1744
- * - Items can have different configurations (heterogeneous arrays supported)
1745
- * - Initial values are set via `value` property on each field definition
1746
- */
1747
- readonly fields: TFields;
1748
- /** Array fields do not have a label property * */
1749
- readonly label?: never;
1750
- /** Arrays do not support meta - they have no native form element * */
1751
- readonly meta?: never;
1752
- /**
1753
- * Logic configurations for conditional array visibility.
1754
- * Only 'hidden' type logic is supported for arrays.
1755
- */
1756
- readonly logic?: ContainerLogicConfig[];
2203
+ type RegisteredActionRef = keyof DynamicFormActionRegistry;
2204
+
2205
+ /**
2206
+ * Optional collaborators a preset may need beyond the base context. Passed
2207
+ * by the button kind component which has access to its own DI scope.
2208
+ */
2209
+ interface PresetCollaborators {
2210
+ /** Per-field input-type override signal — populated only inside an input field. */
2211
+ readonly typeOverride?: WritableSignal<string | undefined>;
2212
+ /** Writer that pushes a value into the host field's tree. */
2213
+ readonly fieldValueSetter?: (next: unknown) => void;
1757
2214
  /**
1758
- * Minimum number of items required in the array.
1759
- * Validation fails if the array has fewer items than this value.
2215
+ * Read the host field's configured default value (from the form's
2216
+ * `defaultValues` map keyed by `field.key`). Used by the `'reset'`
2217
+ * preset; absent when the addon is rendered outside an active field
2218
+ * context, in which case `'reset'` falls back to clearing.
1760
2219
  */
1761
- readonly minLength?: number;
2220
+ readonly fieldDefaultValueGetter?: () => unknown;
1762
2221
  /**
1763
- * Maximum number of items allowed in the array.
1764
- * Validation fails if the array has more items than this value.
2222
+ * Baseline configured input type (from `props().type`), read at preset-run
2223
+ * time. Used by `toggle-password-visibility` to refuse to corrupt
2224
+ * `'email'`/`'number'`/etc. inputs into `'password'` when no override is
2225
+ * yet set.
1765
2226
  */
1766
- readonly maxLength?: number;
2227
+ readonly baselineType?: () => string | undefined;
2228
+ /** Logger for warnings about presets that can't be fulfilled in this context. */
2229
+ readonly logger: Logger;
1767
2230
  }
1768
2231
  /**
1769
- * Type guard for ArrayField with proper type narrowing.
1770
- * Validates that the field is an array type with a fields property that is an array.
1771
- * Fields can contain either single FieldDefs (primitive items) or arrays of FieldDefs (object items).
2232
+ * Apply a built-in preset action against the addon's host field. Shared
2233
+ * across all adapters — each adapter's `ADDON_PRESET_HANDLER` provider
2234
+ * delegates here.
2235
+ *
2236
+ * @param adapterLabel Used in warnings — `'Material'` / `'Bootstrap'` / etc.
2237
+ * @param fieldLabel Used in warnings — `'mat-input'` / `'bs-input'` / etc.
1772
2238
  */
1773
- declare function isArrayField(field: FieldDef<any>): field is ArrayField;
1774
- type ArrayComponent<T extends ArrayItemTemplate[]> = FieldComponent<ArrayField<T>>;
1775
- /** Configuration for auto-generated add/remove buttons in simplified array fields. */
1776
- interface ArrayButtonConfig {
1777
- /** Custom label for the button */
1778
- readonly label?: string;
1779
- /** Additional properties passed to the button component */
1780
- readonly props?: Record<string, unknown>;
1781
- }
1782
- /** Simplified array field interface for common use cases. */
1783
- interface SimplifiedArrayField extends FieldDef<never> {
1784
- type: 'array';
1785
- /**
1786
- * Template defining the structure of a single array item.
1787
- * - Single field (ArrayAllowedChildren) → primitive array (each item is a single value)
1788
- * - Array of fields (readonly ArrayAllowedChildren[]) → object array (each item is an object)
1789
- */
1790
- readonly template: ArrayAllowedChildren | readonly ArrayAllowedChildren[];
1791
- /** Initial values for the array. Each element creates one array item. */
1792
- readonly value?: readonly unknown[];
1793
- /**
1794
- * Configuration for the auto-generated "Add" button, or `false` to disable it.
1795
- * Defaults to a button with label "Add".
1796
- */
1797
- readonly addButton?: ArrayButtonConfig | false;
1798
- /**
1799
- * Configuration for the auto-generated "Remove" button on each item, or `false` to disable it.
1800
- * Defaults to a button with label "Remove".
1801
- */
1802
- readonly removeButton?: ArrayButtonConfig | false;
1803
- /** Simplified arrays do not support the label property */
1804
- readonly label?: never;
1805
- /** Simplified arrays do not support meta */
1806
- readonly meta?: never;
1807
- /**
1808
- * Logic configurations for conditional array visibility.
1809
- * Only 'hidden' type logic is supported for arrays.
1810
- */
1811
- readonly logic?: ContainerLogicConfig[];
1812
- /**
1813
- * Minimum number of items required in the array.
1814
- * Validation fails if the array has fewer items than this value.
1815
- */
1816
- readonly minLength?: number;
2239
+ declare function runPresetAction(preset: AddonActionPreset, ctx: AddonActionContext, collaborators: PresetCollaborators, adapterLabel: string, fieldLabel: string): Promise<void>;
2240
+
2241
+ /** Context for cross-field detection, providing access to function scope information. */
2242
+ interface CrossFieldDetectionContext {
1817
2243
  /**
1818
- * Maximum number of items allowed in the array.
1819
- * Validation fails if the array has more items than this value.
2244
+ * Lookup function to get the scope of a registered custom function.
2245
+ *
2246
+ * @param functionName The name of the custom function
2247
+ * @returns The function's scope, or undefined if not registered
1820
2248
  */
1821
- readonly maxLength?: number;
1822
- /** Mutually exclusive with `template` — use `fields` for the full API instead */
1823
- readonly fields?: never;
2249
+ getFunctionScope?: (functionName: string) => CustomFunctionScope | undefined;
1824
2250
  }
1825
2251
  /**
1826
- * Type guard for SimplifiedArrayField.
1827
- * Checks for `type: 'array'` with a `template` property (discriminant from full ArrayField).
2252
+ * Detects if a ConditionalExpression references other fields (cross-field).
2253
+ *
2254
+ * @param expr The conditional expression to analyze
2255
+ * @param context Optional context providing function scope lookup
2256
+ * @returns true if the expression references other fields
1828
2257
  */
1829
- declare function isSimplifiedArrayField(field: FieldDef<any>): field is SimplifiedArrayField;
1830
-
2258
+ declare function isCrossFieldExpression(expr: ConditionalExpression | boolean | FormStateCondition | undefined, context?: CrossFieldDetectionContext): boolean;
1831
2259
  /**
1832
- * Scalar types supported by hidden fields.
1833
- * These are the primitive value types that can be stored.
2260
+ * Extracts field dependencies from a ConditionalExpression.
2261
+ *
2262
+ * @param expr The conditional expression to analyze
2263
+ * @returns Array of field keys that this expression depends on
1834
2264
  */
1835
- type HiddenScalar = string | number | boolean;
2265
+ declare function extractExpressionDependencies(expr: ConditionalExpression | boolean | undefined): string[];
1836
2266
  /**
1837
- * All value types supported by hidden fields.
1838
- * Supports both scalar values and arrays of scalars for storing
1839
- * multiple IDs or similar data.
2267
+ * Extracts field names from a JavaScript expression string.
2268
+ * Handles both dot notation (formValue.field) and bracket notation (formValue['field']).
1840
2269
  */
1841
- type HiddenValue = HiddenScalar | HiddenScalar[];
2270
+ declare function extractStringDependencies(expression: string): string[];
1842
2271
  /**
1843
- * Hidden field definition for storing values without rendering UI.
2272
+ * Detects if a custom validator configuration references formValue (cross-field validation).
1844
2273
  *
1845
- * @typeParam TValue - The type of value stored (must be HiddenValue compatible)
2274
+ * @param config The custom validator configuration to check
2275
+ * @returns true if the validator references formValue
1846
2276
  */
1847
- interface HiddenField<TValue extends HiddenValue = HiddenValue> extends FieldDef<never> {
1848
- /** Discriminant for hidden field type */
1849
- type: 'hidden';
1850
- /**
1851
- * The value to store in the form.
1852
- * This is required - a hidden field without a value serves no purpose.
1853
- */
1854
- value: TValue;
1855
- }
2277
+ declare function isCrossFieldValidator(config: CustomValidatorConfig): boolean;
1856
2278
  /**
1857
- * Type guard to check if a field is a hidden field.
2279
+ * Detects if a built-in validator has a dynamic expression that references formValue.
1858
2280
  *
1859
- * @param field - The field to check
1860
- * @returns True if the field is a HiddenField
2281
+ * @param config The validator configuration to check
2282
+ * @returns true if the validator has a cross-field dynamic expression
1861
2283
  */
1862
- declare function isHiddenField(field: FieldDef<unknown>): field is HiddenField;
1863
-
2284
+ declare function isCrossFieldBuiltInValidator(config: ValidatorConfig): boolean;
2285
+ /** Checks if a validator uses Angular's resource API (validateHttp / validateAsync). */
2286
+ declare function isResourceBasedValidator(config: ValidatorConfig): boolean;
1864
2287
  /**
1865
- * Page field interface for creating top-level page layouts
1866
- * This is a special field type that contains other field definitions
1867
- * The page itself doesn't have a value - it's a layout container like row
1868
- * Pages can only be used at the top level and cannot be nested
1869
- * This is a programmatic field type only - users cannot customize this field type
2288
+ * Detects if a validator's `when` condition is cross-field.
2289
+ *
2290
+ * @param config The validator configuration to check
2291
+ * @param context Optional context providing function scope lookup
2292
+ * @returns true if the when condition references other fields
1870
2293
  */
1871
- interface PageField<TFields extends readonly PageAllowedChildren[] = PageAllowedChildren[]> extends FieldDef<never> {
1872
- type: 'page';
1873
- /** Child field definitions to render within this page */
1874
- readonly fields: TFields;
1875
- /** Page fields do not have a label property * */
1876
- readonly label?: never;
1877
- /** Pages do not support meta - they have no native form element * */
1878
- readonly meta?: never;
1879
- /**
1880
- * Logic configurations for conditional page visibility.
1881
- * Only 'hidden' type logic is supported for pages.
1882
- */
1883
- readonly logic?: ContainerLogicConfig[];
1884
- }
1885
- /** Type guard for PageField with proper type narrowing */
1886
- declare function isPageField(field: FieldDef<unknown>): field is PageField;
2294
+ declare function hasCrossFieldWhenCondition(config: ValidatorConfig, context?: CrossFieldDetectionContext): boolean;
1887
2295
  /**
1888
- * Validates that a page field doesn't contain nested page fields
2296
+ * Detects if a StateLogicConfig has a cross-field condition.
1889
2297
  *
1890
- * @param pageField The page field to validate
1891
- * @returns true if valid (no nested pages), false otherwise
1892
- */
1893
- declare function validatePageNesting(pageField: PageField): boolean;
1894
-
1895
- /** Text element type for rendering different HTML text elements */
1896
- type TextElementType = 'p' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'span';
1897
- /** Properties for text field configuration */
1898
- type TextProps = {
1899
- /** The HTML element type to render */
1900
- elementType: TextElementType;
1901
- };
1902
- /** Text field definition for displaying translatable text content */
1903
- interface TextField extends FieldDef<TextProps> {
1904
- type: 'text';
1905
- /**
1906
- * Logic rules for conditional visibility.
1907
- * Text fields only support 'hidden' logic type since they are display-only
1908
- * and don't participate in form validation (no disabled/readonly/required).
1909
- */
1910
- readonly logic?: NonFieldLogicConfig[];
1911
- }
1912
-
1913
- /** Configuration for the built-in 'css' wrapper type. */
1914
- interface CssWrapper {
1915
- readonly type: 'css';
1916
- /** CSS classes to apply to the wrapper */
1917
- readonly cssClasses?: DynamicText;
1918
- }
1919
-
1920
- /** Configuration for the built-in 'row' wrapper type. */
1921
- interface RowWrapper {
1922
- readonly type: 'row';
1923
- }
1924
-
1925
- /** Container fields registry - augment this interface to add custom container fields */
1926
- interface FieldRegistryContainers {
1927
- page: PageField;
1928
- row: RowField;
1929
- group: GroupField;
1930
- array: ArrayField | SimplifiedArrayField;
1931
- container: ContainerField;
1932
- }
1933
- /** Leaf fields registry - augment this interface to add custom leaf fields */
1934
- interface FieldRegistryLeaves {
1935
- text: TextField;
1936
- hidden: HiddenField;
1937
- }
1938
- /** Wrapper type registry for module augmentation. */
1939
- interface FieldRegistryWrappers {
1940
- css: CssWrapper;
1941
- row: RowWrapper;
1942
- }
1943
- /**
1944
- * Global interface for dynamic form field definitions with categorization
1945
- * This interface combines containers and leaves from their respective registries
2298
+ * @param config The state logic configuration to check
2299
+ * @param context Optional context providing function scope lookup
2300
+ * @returns true if the logic condition references other fields
1946
2301
  */
1947
- interface DynamicFormFieldRegistry {
1948
- /** Container fields that hold other fields (no value, have children) */
1949
- containers: FieldRegistryContainers;
1950
- /** Leaf fields that have values or display content */
1951
- leaves: FieldRegistryLeaves;
1952
- /** Field wrappers types */
1953
- wrappers: FieldRegistryWrappers;
1954
- }
1955
- /** Union type of all registered container field definitions */
1956
- type ContainerFieldTypes = DynamicFormFieldRegistry['containers'][keyof DynamicFormFieldRegistry['containers']];
1957
- /** Union type of all registered leaf field definitions */
1958
- type LeafFieldTypes = DynamicFormFieldRegistry['leaves'][keyof DynamicFormFieldRegistry['leaves']];
1959
- /** Union type of all registered field definitions */
1960
- type RegisteredFieldTypes = ContainerFieldTypes | LeafFieldTypes;
1961
- /** Extract field types that are available in the registry */
1962
- type AvailableFieldTypes = keyof DynamicFormFieldRegistry['containers'] | keyof DynamicFormFieldRegistry['leaves'];
1963
- /** Extract wrapper types that are available in the registry */
1964
- type RegisteredWrapperTypes = keyof DynamicFormFieldRegistry['wrappers'];
2302
+ declare function isCrossFieldStateLogic(config: StateLogicConfig, context?: CrossFieldDetectionContext): boolean;
1965
2303
  /**
1966
- * Combined registry mapping type names to field definitions.
1967
- * This flattens containers and leaves into a single mapping.
2304
+ * Detects if a SchemaApplicationConfig has a cross-field condition.
2305
+ *
2306
+ * @param config The schema application configuration to check
2307
+ * @param context Optional context providing function scope lookup
2308
+ * @returns true if the schema condition references other fields
1968
2309
  */
1969
- type FieldTypeMap = DynamicFormFieldRegistry['containers'] & DynamicFormFieldRegistry['leaves'];
2310
+ declare function isCrossFieldSchema(config: SchemaApplicationConfig, context?: CrossFieldDetectionContext): boolean;
2311
+
1970
2312
  /**
1971
- * Extract a specific field type from RegisteredFieldTypes based on the `type` discriminant.
1972
- * This enables proper type narrowing when defining fields.
2313
+ * Creates a lazy FieldStateInfo that only reads state properties when accessed.
2314
+ *
2315
+ * @param fieldSource - A FieldTree or direct FieldState instance
2316
+ * @param reactive - If true, reads signals reactively (creates dependencies).
2317
+ * If false, reads signals with `untracked()` (no dependencies).
2318
+ * @returns A FieldStateInfo proxy with lazy property access, or undefined if the source is invalid
2319
+ * @internal
1973
2320
  */
1974
- type ExtractField<T extends AvailableFieldTypes> = T extends keyof FieldTypeMap ? FieldTypeMap[T] : never;
2321
+ declare function readFieldStateInfo(fieldSource: FieldTree<unknown> | ReadonlyFieldState<unknown> | undefined, reactive: boolean): FieldStateInfo | undefined;
1975
2322
  /**
1976
- * Narrow a field definition based on its `type` property.
1977
- * Use this to get proper type inference when working with field unions.
2323
+ * Creates a Proxy-based FormFieldStateMap for accessing any field's state by key.
2324
+ *
2325
+ * @param rootForm - The root FieldTree of the form
2326
+ * @param reactive - If true, reads signals reactively (creates dependencies).
2327
+ * If false, reads signals with `untracked()` (no dependencies).
2328
+ * @returns A FormFieldStateMap proxy
2329
+ * @internal
1978
2330
  */
1979
- type NarrowField<T> = T extends {
1980
- type: infer TType;
1981
- } ? (TType extends AvailableFieldTypes ? ExtractField<TType> : T) : T;
2331
+ declare function createFormFieldStateMap(rootForm: FieldTree<unknown>, reactive: boolean): FormFieldStateMap;
2332
+
2333
+ /** DI-scoped cache for async condition logic functions. */
2334
+ declare class AsyncConditionFunctionCacheService {
2335
+ /** Cache for async condition logic functions, keyed by serialized condition. */
2336
+ readonly asyncConditionFunctionCache: Map<string, LogicFn<unknown, boolean>>;
2337
+ }
2338
+
2339
+ /** Creates a logic function for an async condition. */
2340
+ declare function createAsyncConditionLogicFunction<TValue>(condition: AsyncCondition): LogicFn<TValue, boolean>;
2341
+
1982
2342
  /**
1983
- * Narrow each field in an array based on its `type` property.
1984
- * Use with `satisfies` to get proper type inference for field arrays.
2343
+ * Evaluate conditional expression
2344
+ * Uses secure AST-based parsing for JavaScript expressions
1985
2345
  */
1986
- type NarrowFields = readonly NarrowField<RegisteredFieldTypes>[];
2346
+ declare function evaluateCondition(expression: ConditionalExpression, context: EvaluationContext): boolean;
1987
2347
 
1988
2348
  /**
1989
- * Helper type to convert union to intersection.
1990
- * Uses `U extends U` to trigger distributive conditional type behavior.
2349
+ * Trigger value carried through the debounced reactive pipeline.
2350
+ *
2351
+ * @internal
1991
2352
  */
1992
- type UnionToIntersection<U> = (U extends U ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
1993
- /** Depth counter for recursion limiting (prevents infinite type instantiation) */
1994
- type Depth = [never, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
2353
+ interface Trigger<TPayload> {
2354
+ key: string;
2355
+ payload: TPayload;
2356
+ }
1995
2357
  /**
1996
- * Widens literal types to their primitive equivalents, recursively for objects and arrays.
1997
- * This prevents `as const` from over-narrowing types like `''` to literal `''` instead of `string`.
2358
+ * Configuration passed to {@link createDebouncedResourceLogicFn}.
2359
+ *
2360
+ * @internal
1998
2361
  */
1999
- type Widen<T, D extends number = 5> = [D] extends [never] ? T : T extends string ? string : T extends number ? number : T extends boolean ? boolean : T extends readonly (infer U)[] ? Widen<U, Depth[D]>[] : T extends Record<string, unknown> ? {
2000
- -readonly [K in keyof T]: Widen<T[K], Depth[D]>;
2001
- } : T;
2362
+ interface DebouncedResourceLogicFnConfig<TValue, TPayload, TResult> {
2363
+ /** Default value returned by the resource while loading / pending. */
2364
+ pendingValue: TResult;
2365
+ /** Debounce window (ms) applied to the trigger signal before the resource sees it. */
2366
+ debounceMs: number;
2367
+ injector: Injector;
2368
+ /**
2369
+ * Builds the per-emission inner observable. Called every time the debounced
2370
+ * trigger key changes; the resource swaps to the new stream automatically.
2371
+ */
2372
+ buildStream: (payload: TPayload) => Observable<TResult>;
2373
+ /**
2374
+ * Called per LogicFn invocation. Returns one of:
2375
+ * - `{ kind: 'trigger', key, payload }` — set the trigger to this and
2376
+ * return the (potentially still-loading) resource value.
2377
+ * - `{ kind: 'returnEarly', value }` — bypass the resource and return
2378
+ * this value directly (used by HTTP for response-cache hits — the
2379
+ * cached value is authoritative and overrides any sticky resource value).
2380
+ * - `{ kind: 'holdPrevious' }` — bypass the resource update but return
2381
+ * the resource's current sticky value (its last resolved value via
2382
+ * `withPreviousValue`, or `pendingValue` if it never resolved). Used
2383
+ * by HTTP when the request template is temporarily unresolvable so
2384
+ * the UI doesn't flicker back to `pendingValue`.
2385
+ */
2386
+ resolve: (ctx: FieldContext<TValue>) => {
2387
+ kind: 'trigger';
2388
+ key: string;
2389
+ payload: TPayload;
2390
+ } | {
2391
+ kind: 'returnEarly';
2392
+ value: TResult;
2393
+ } | {
2394
+ kind: 'holdPrevious';
2395
+ };
2396
+ }
2002
2397
  /**
2003
- * Resolves the "underlying" non-null value type for a field, based on its `type`
2004
- * discriminator and (where it matters) its `value` literal. Used when we need a
2005
- * base type independent of whether the literal happens to be `null` — i.e., when
2006
- * computing the nullable widening for `value: null, nullable: true`.
2398
+ * Shared scaffolding for both async-function and HTTP condition LogicFns.
2399
+ *
2400
+ * @internal
2007
2401
  */
2008
- type ResolveBaseValueType<T, V> = T extends {
2009
- type: 'slider';
2010
- } ? number : T extends {
2011
- type: 'input';
2012
- props: {
2013
- type: 'number';
2014
- };
2015
- } ? number : T extends {
2016
- type: 'checkbox' | 'toggle';
2017
- } ? boolean : [V] extends [null] ? string : Widen<V>;
2402
+ declare function createDebouncedResourceLogicFn<TValue, TPayload, TResult>(config: DebouncedResourceLogicFnConfig<TValue, TPayload, TResult>): LogicFn<TValue, TResult>;
2403
+
2404
+ /** DI-scoped cache for HTTP condition logic functions. */
2405
+ declare class HttpConditionFunctionCacheService {
2406
+ /** Cache for HTTP condition logic functions, keyed by serialized condition. */
2407
+ readonly httpConditionFunctionCache: Map<string, LogicFn<unknown, boolean>>;
2408
+ }
2409
+
2410
+ /** Creates a logic function for an HTTP condition. */
2411
+ declare function createHttpConditionLogicFunction<TValue>(condition: HttpCondition): LogicFn<TValue, boolean>;
2412
+
2018
2413
  /**
2019
- * Infer value type based on field type, value literal, and the `nullable` flag.
2020
- * - Slider fields: always number
2021
- * - Input fields with props.type: 'number': number
2022
- * - Checkbox / toggle fields: always boolean
2023
- * - Other fields: widen the literal value type (default to string when value is null)
2024
- * - When `nullable: true` is declared, widens the result to `T | null`.
2414
+ * Create a logic function from a conditional expression.
2415
+ *
2416
+ * @param expression The conditional expression to evaluate
2417
+ * @returns A LogicFn that evaluates the condition in the context of a field
2025
2418
  */
2026
- type InferValueType<T, V> = T extends {
2027
- nullable: true;
2028
- } ? ResolveBaseValueType<T, V> | null : ResolveBaseValueType<T, V>;
2419
+ declare function createLogicFunction<TValue>(expression: ConditionalExpression): LogicFn<TValue, boolean>;
2029
2420
  /**
2030
- * Make type optional if field is not required.
2031
- * Hidden fields are never optional since they require a value property.
2421
+ * Create a debounced logic function from a conditional expression.
2422
+ *
2423
+ * @param expression The conditional expression to evaluate
2424
+ * @param debounceMs The debounce duration in milliseconds
2425
+ * @returns A LogicFn that evaluates the condition with debouncing
2032
2426
  */
2033
- type MaybeOptional<T, V> = T extends {
2034
- type: 'hidden';
2035
- } ? V : T extends {
2036
- required: true;
2037
- } ? V : V | undefined;
2427
+ declare function createDebouncedLogicFunction<TValue>(expression: ConditionalExpression, debounceMs: number): LogicFn<TValue, boolean>;
2428
+
2038
2429
  /**
2039
- * Infers the value type from a single template field (for primitive arrays).
2040
- * Mirrors InferValueType logic: slider → number, input[number] → number,
2041
- * checkbox/toggle → boolean, else widen `value` (string fallback). Widens to
2042
- * `T | null` when `nullable: true` is declared on the template field.
2430
+ * Compares two values using the specified comparison operator.
2431
+ *
2432
+ * @param actual - The value to compare
2433
+ * @param expected - The value to compare against
2434
+ * @param operator - Comparison operator to use
2435
+ * @returns True if the comparison succeeds, false otherwise
2043
2436
  */
2044
- type InferSingleTemplateValueBase<T, D extends number> = T extends {
2045
- type: 'slider';
2046
- } ? number : T extends {
2047
- type: 'input';
2048
- props: {
2049
- type: 'number';
2050
- };
2051
- } ? number : T extends {
2052
- type: 'checkbox' | 'toggle';
2053
- } ? boolean : T extends {
2054
- value: infer V;
2055
- } ? [V] extends [null] ? string : Widen<V, Depth[D]> : string;
2056
- type InferSingleTemplateValue<T, D extends number> = T extends {
2057
- nullable: true;
2058
- } ? InferSingleTemplateValueBase<T, D> | null : InferSingleTemplateValueBase<T, D>;
2437
+ declare function compareValues(actual: unknown, expected: unknown, operator: string): boolean;
2059
2438
  /**
2060
- * Infers the value type for an array field.
2061
- * Handles four cases:
2062
- * 1. Simplified array with template + value → infer item type from value
2063
- * 2. Simplified array with array template (no value) → infer object type from template fields
2064
- * 3. Simplified array with single-field template (no value) → infer primitive type from template field
2065
- * 4. Full-API array with fields → infer from children
2439
+ * Retrieves a nested value from an object using dot notation path.
2440
+ *
2441
+ * @param obj - The object to traverse
2442
+ * @param path - Dot-separated path to the desired property
2443
+ * @returns The value at the specified path, or undefined if not found
2066
2444
  */
2067
- type InferArrayValue<T, D extends number> = T extends {
2068
- template: unknown;
2069
- value: readonly (infer Item)[];
2070
- } ? Widen<Item>[] : T extends {
2071
- template: infer TArr;
2072
- } ? TArr extends readonly RegisteredFieldTypes[] ? InferFormValueWithDepth<[...TArr], Depth[D]>[] : InferSingleTemplateValue<TArr, D>[] : T extends {
2073
- fields: infer F;
2074
- } ? F extends RegisteredFieldTypes[] ? InferFormValueWithDepth<F, Depth[D]>[] : unknown[] : unknown[];
2075
- /** Process a single field and determine its contribution to the form value type */
2076
- type ProcessField<T, D extends number = 5> = [D] extends [never] ? Record<string, unknown> : T extends {
2077
- type: 'page' | 'row';
2078
- fields: infer F;
2079
- } ? F extends RegisteredFieldTypes[] ? InferFormValueWithDepth<F, Depth[D]> : never : T extends {
2080
- type: 'group';
2081
- key: infer K;
2082
- fields: infer F;
2083
- } ? K extends string ? F extends RegisteredFieldTypes[] ? {
2084
- [P in K]: InferFormValueWithDepth<F, Depth[D]>;
2085
- } : {
2086
- [P in K]: Record<string, unknown>;
2087
- } : never : T extends {
2088
- type: 'array';
2089
- key: infer K;
2090
- } ? K extends string ? {
2091
- [P in K]: InferArrayValue<T, D>;
2092
- } : never : T extends {
2093
- type: 'text';
2094
- } ? never : T extends {
2095
- type: 'submit' | 'button' | 'next' | 'previous' | 'addArrayItem' | 'removeArrayItem';
2096
- } ? never : T extends {
2097
- key: infer K;
2098
- value: infer V;
2099
- } ? K extends string ? {
2100
- [P in K]: MaybeOptional<T, InferValueType<T, V>>;
2101
- } : never : T extends {
2102
- key: infer K;
2103
- } ? K extends string ? {
2104
- [P in K]: MaybeOptional<T, T extends {
2105
- nullable: true;
2106
- } ? string | null : string>;
2107
- } : never : never;
2108
- /** Internal helper with depth tracking */
2109
- type InferFormValueWithDepth<T extends RegisteredFieldTypes[], D extends number = 5> = UnionToIntersection<ProcessField<T[number], D>>;
2110
- /** Helper to extract fields from either fields array or FormConfig */
2111
- type ExtractFields<T> = T extends {
2112
- fields: infer TFields;
2113
- } ? TFields extends readonly RegisteredFieldTypes[] ? TFields : never : T extends readonly RegisteredFieldTypes[] ? T : never;
2445
+ declare function getNestedValue(obj: unknown, path: string): unknown;
2114
2446
  /**
2115
- * Infer form value type from fields array or FormConfig.
2116
- * Recursively processes nested structures and merges the results.
2117
- * Limited to 5 levels of nesting to prevent infinite type instantiation.
2447
+ * Checks whether a nested property exists in an object using dot notation path.
2448
+ *
2449
+ * @param obj - The object to check
2450
+ * @param path - Dot-separated path to the property
2451
+ * @returns True if the property exists (even if its value is undefined)
2118
2452
  */
2119
- type InferFormValue<T> = ExtractFields<T> extends readonly RegisteredFieldTypes[] ? InferFormValueWithDepth<ExtractFields<T> extends RegisteredFieldTypes[] ? ExtractFields<T> : [...ExtractFields<T>], 5> : never;
2453
+ declare function hasNestedProperty(obj: unknown, path: string): boolean;
2454
+
2455
+ /** Per-field debounced signal pair. */
2456
+ interface DebouncedSignalPair {
2457
+ immediateValue: WritableSignal<boolean>;
2458
+ debouncedValue: Signal<boolean | undefined>;
2459
+ }
2460
+ /** DI-scoped cache for logic functions and debounced signals. */
2461
+ declare class LogicFunctionCacheService {
2462
+ /** Cache for memoized logic functions, keyed by serialized expression. */
2463
+ readonly logicFunctionCache: Map<string, LogicFn<unknown, boolean>>;
2464
+ /** Cache for debounced logic functions, keyed by serialized expression + debounceMs. */
2465
+ readonly debouncedLogicFunctionCache: Map<string, LogicFn<unknown, boolean>>;
2466
+ /** Per-field signal store for debounced logic, keyed by field path. */
2467
+ readonly debouncedSignalStore: Map<string, DebouncedSignalPair>;
2468
+ }
2469
+
2470
+ /** Base error class for all Dynamic Forms errors. */
2471
+ declare class DynamicFormError extends Error {
2472
+ private static readonly PREFIX;
2473
+ constructor(message: string);
2474
+ }
2475
+
2476
+ /** Token types for expression parsing */
2477
+ declare enum TokenType {
2478
+ NUMBER = "NUMBER",
2479
+ STRING = "STRING",
2480
+ TRUE = "TRUE",
2481
+ FALSE = "FALSE",
2482
+ NULL = "NULL",
2483
+ UNDEFINED = "UNDEFINED",
2484
+ IDENTIFIER = "IDENTIFIER",
2485
+ PLUS = "PLUS",
2486
+ MINUS = "MINUS",
2487
+ MULTIPLY = "MULTIPLY",
2488
+ DIVIDE = "DIVIDE",
2489
+ MODULO = "MODULO",
2490
+ EQUAL = "EQUAL",
2491
+ NOT_EQUAL = "NOT_EQUAL",
2492
+ GREATER = "GREATER",
2493
+ LESS = "LESS",
2494
+ GREATER_EQUAL = "GREATER_EQUAL",
2495
+ LESS_EQUAL = "LESS_EQUAL",
2496
+ AND = "AND",
2497
+ OR = "OR",
2498
+ NOT = "NOT",
2499
+ DOT = "DOT",
2500
+ COMMA = "COMMA",
2501
+ COLON = "COLON",
2502
+ LPAREN = "LPAREN",
2503
+ RPAREN = "RPAREN",
2504
+ LBRACKET = "LBRACKET",
2505
+ RBRACKET = "RBRACKET",
2506
+ LBRACE = "LBRACE",
2507
+ RBRACE = "RBRACE",
2508
+ ARROW = "ARROW",
2509
+ QUESTION = "QUESTION",
2510
+ OPTIONAL_DOT = "OPTIONAL_DOT",
2511
+ EOF = "EOF"
2512
+ }
2513
+ /** Token with type, value, and position */
2514
+ interface Token {
2515
+ type: TokenType;
2516
+ value: string;
2517
+ position: number;
2518
+ }
2519
+ /** AST Node types */
2520
+ type ASTNode = LiteralNode | IdentifierNode | MemberAccessNode | ComputedMemberAccessNode | BinaryOpNode | UnaryOpNode | CallExpressionNode | ConditionalNode | ArrayLiteralNode | ObjectLiteralNode | ArrowFunctionNode;
2521
+ interface LiteralNode {
2522
+ type: 'Literal';
2523
+ value: string | number | boolean | null | undefined;
2524
+ }
2525
+ interface IdentifierNode {
2526
+ type: 'Identifier';
2527
+ name: string;
2528
+ }
2529
+ interface MemberAccessNode {
2530
+ type: 'MemberAccess';
2531
+ object: ASTNode;
2532
+ property: string;
2533
+ /** True when this access used `?.` (optional chaining). */
2534
+ optional?: boolean;
2535
+ }
2536
+ interface ComputedMemberAccessNode {
2537
+ type: 'ComputedMemberAccess';
2538
+ object: ASTNode;
2539
+ /** Expression evaluated at runtime to produce the property key. */
2540
+ property: ASTNode;
2541
+ /** True when this access used `?.[ ... ]` (optional chaining). */
2542
+ optional?: boolean;
2543
+ }
2544
+ interface ConditionalNode {
2545
+ type: 'Conditional';
2546
+ test: ASTNode;
2547
+ consequent: ASTNode;
2548
+ alternate: ASTNode;
2549
+ }
2550
+ interface BinaryOpNode {
2551
+ type: 'BinaryOp';
2552
+ operator: string;
2553
+ left: ASTNode;
2554
+ right: ASTNode;
2555
+ }
2556
+ interface UnaryOpNode {
2557
+ type: 'UnaryOp';
2558
+ operator: string;
2559
+ operand: ASTNode;
2560
+ }
2561
+ interface CallExpressionNode {
2562
+ type: 'CallExpression';
2563
+ callee: ASTNode;
2564
+ arguments: ASTNode[];
2565
+ /** True when this call used `?.( ... )` (optional chaining). */
2566
+ optional?: boolean;
2567
+ }
2568
+ interface ArrayLiteralNode {
2569
+ type: 'ArrayLiteral';
2570
+ elements: ASTNode[];
2571
+ }
2572
+ interface ObjectLiteralNode {
2573
+ type: 'ObjectLiteral';
2574
+ properties: Array<{
2575
+ key: string;
2576
+ value: ASTNode;
2577
+ }>;
2578
+ }
2579
+ interface ArrowFunctionNode {
2580
+ type: 'ArrowFunction';
2581
+ params: string[];
2582
+ body: ASTNode;
2583
+ }
2584
+ /** Parser error with position information */
2585
+ declare class ExpressionParserError extends DynamicFormError {
2586
+ position: number;
2587
+ expression: string;
2588
+ constructor(message: string, position: number, expression: string);
2589
+ }
2120
2590
 
2121
- /**
2122
- * Re-export Angular's ValidationError for consistency
2123
- * This replaces our custom ValidationError interface
2124
- */
2125
- type ValidationError = ValidationError$1;
2126
- interface ValidationMessages {
2127
- required?: DynamicText;
2128
- email?: DynamicText;
2129
- min?: DynamicText;
2130
- max?: DynamicText;
2131
- minLength?: DynamicText;
2132
- maxLength?: DynamicText;
2133
- pattern?: DynamicText;
2134
- [key: string]: DynamicText | undefined;
2591
+ /** Evaluation context for safe expression evaluation */
2592
+ interface EvaluationScope {
2593
+ [key: string]: unknown;
2594
+ }
2595
+ /** Safely evaluates an AST node with a given context */
2596
+ declare class Evaluator {
2597
+ private readonly scope;
2598
+ private readonly expression;
2599
+ constructor(scope: EvaluationScope, expression: string);
2600
+ /** Evaluate an AST node */
2601
+ evaluate(node: ASTNode): unknown;
2602
+ private evaluateIdentifier;
2603
+ private evaluateMemberAccess;
2604
+ private evaluateComputedMemberAccess;
2605
+ private evaluateBinaryOp;
2606
+ private evaluateUnaryOp;
2607
+ private evaluateCallExpression;
2608
+ private evaluateArrayLiteral;
2609
+ private evaluateObjectLiteral;
2610
+ private evaluateArrowFunction;
2611
+ private isMethodSafe;
2135
2612
  }
2136
2613
 
2137
- /**
2138
- * The result type for submission actions.
2139
- * Can be either a Promise or an Observable.
2140
- */
2141
- type SubmissionActionResult = Promise<TreeValidationResult> | Observable<TreeValidationResult | unknown>;
2142
- /**
2143
- * Configuration for form submission handling.
2144
- *
2145
- * @typeParam TValue - The form value type
2146
- */
2147
- interface SubmissionConfig<TValue = unknown> {
2614
+ /** Secure expression parser that uses AST-based evaluation */
2615
+ declare class ExpressionParser {
2148
2616
  /**
2149
- * Action called when the form is submitted.
2150
- *
2151
- * @param form - The form's FieldTree instance
2152
- * @returns Promise or Observable - for errors, return TreeValidationResult
2617
+ * Parse an expression string into an AST
2618
+ * Results are cached for performance using LRU eviction
2153
2619
  */
2154
- action: (form: FieldTree<TValue>) => SubmissionActionResult;
2620
+ static parse(expression: string): ASTNode;
2621
+ /** Evaluate an expression with a given scope */
2622
+ static evaluate(expression: string, scope: EvaluationScope): unknown;
2623
+ /** Clear the AST cache */
2624
+ static clearCache(): void;
2625
+ /** Get cache statistics */
2626
+ static getCacheStats(): {
2627
+ size: number;
2628
+ maxSize: number;
2629
+ };
2155
2630
  }
2156
2631
 
2157
2632
  /**
2158
- * Configuration interface for defining dynamic form structure and behavior.
2159
- *
2160
- * @typeParam TFields - Array of registered field types available for this form
2161
- * @typeParam TValue - The strongly-typed interface for form values
2162
- * @typeParam TProps - The type for form-level default props (library-specific)
2633
+ * Parses tokens into an Abstract Syntax Tree (AST)
2634
+ * Uses recursive descent parsing with operator precedence
2163
2635
  */
2164
- interface FormConfig<TFields extends NarrowFields | RegisteredFieldTypes[] = RegisteredFieldTypes[], TValue = InferFormValue<TFields extends readonly RegisteredFieldTypes[] ? TFields : RegisteredFieldTypes[]>, TProps extends object = Record<string, unknown>, TSchemaValue = unknown> {
2165
- /** Array of field definitions that define the form structure. */
2166
- fields: TFields;
2167
- /** Optional form-level validation schema using Standard Schema spec. */
2168
- schema?: FormSchema<TSchemaValue>;
2169
- /**
2170
- * Global form configuration options.
2171
- *
2172
- * @value {}
2173
- */
2174
- options?: FormOptions;
2175
- /** Global schemas available to all fields. */
2176
- schemas?: SchemaDefinition[];
2177
- /** Form-level validation messages that act as fallback for field-level messages. */
2178
- defaultValidationMessages?: ValidationMessages;
2179
- /** Signal forms adapter configuration. */
2180
- customFnConfig?: CustomFnConfig<TValue extends Record<string, unknown> ? TValue : Record<string, unknown>>;
2181
- /** Form submission configuration. */
2182
- submission?: SubmissionConfig<TValue>;
2183
- /** Default props applied to all fields in the form. */
2184
- defaultProps?: TProps;
2185
- /** External data signals available to conditional logic and derivations. */
2186
- externalData?: Record<string, Signal<unknown>>;
2187
- /** Form-wide default wrappers applied to every field that does not explicitly opt out. */
2188
- defaultWrappers?: readonly WrapperConfig[];
2189
- }
2190
- /** Signal forms adapter configuration for advanced form behavior. */
2191
- interface CustomFnConfig<TFormValue extends Record<string, unknown> = Record<string, unknown>> {
2192
- /** Custom evaluation functions for conditional expressions. */
2193
- customFunctions?: Record<string, CustomFunction<TFormValue>>;
2194
- /** Custom derivation functions for value derivation logic. */
2195
- derivations?: Record<string, CustomFunction<TFormValue>>;
2196
- /** Async derivation functions for asynchronous value derivation logic. */
2197
- asyncDerivations?: Record<string, AsyncDerivationFunction<TFormValue>>;
2198
- /** Async condition functions for asynchronous field state logic. */
2199
- asyncConditions?: Record<string, AsyncConditionFunction<TFormValue>>;
2200
- /** Custom validators using Angular's public FieldContext API */
2201
- validators?: Record<string, CustomValidator>;
2202
- /** Async custom validators using Angular's resource-based validateAsync() API */
2203
- asyncValidators?: Record<string, AsyncCustomValidator>;
2204
- /** HTTP validators using Angular's validateHttp() API. */
2205
- httpValidators?: Record<string, HttpCustomValidator>;
2206
- }
2207
- /** Global form configuration options. */
2208
- interface FormOptions {
2209
- /**
2210
- * Disable the entire form.
2211
- *
2212
- * @value false
2213
- */
2214
- disabled?: boolean;
2215
- /**
2216
- * Prefix scoping every field's DOM `id` (and matching `for` / `data-testid` /
2217
- * `aria-describedby`) to this form instance, as the outermost id segment:
2218
- * `{idPrefix}_{group}_{key}_{index}`. Use it when rendering multiple forms
2219
- * from the same config on one page so their ids don't collide.
2220
- *
2221
- * When omitted, a lone form stays unprefixed and a generated prefix (`df-1`,
2222
- * `df-2`, …) is applied automatically once a second form is mounted. Characters
2223
- * invalid in an id token (whitespace, punctuation) are replaced with `_`.
2224
- *
2225
- * @example
2226
- * ```typescript
2227
- * options: { idPrefix: 'billing' } // → id="billing_email-input"
2228
- * ```
2229
- *
2230
- * @default undefined (auto-prefix only when multiple forms are mounted)
2231
- */
2232
- idPrefix?: string;
2233
- /**
2234
- * Maximum number of iterations for derivation chain processing.
2235
- *
2236
- * @default 10
2237
- */
2238
- maxDerivationIterations?: number;
2239
- /** Default disabled behavior for submit buttons. */
2240
- submitButton?: SubmitButtonOptions;
2241
- /** Default disabled behavior for next page buttons. */
2242
- nextButton?: NextButtonOptions;
2243
- /**
2244
- * Whether to exclude values of hidden fields from submission output.
2245
- *
2246
- * @default undefined (uses global setting)
2247
- */
2248
- excludeValueIfHidden?: boolean;
2249
- /**
2250
- * Whether to exclude values of disabled fields from submission output.
2251
- *
2252
- * @default undefined (uses global setting)
2253
- */
2254
- excludeValueIfDisabled?: boolean;
2255
- /**
2256
- * Whether to exclude values of readonly fields from submission output.
2257
- *
2258
- * @default undefined (uses global setting)
2259
- */
2260
- excludeValueIfReadonly?: boolean;
2261
- /**
2262
- * Whether to run validation when a field is hidden.
2263
- *
2264
- * @default undefined (uses global setting, which defaults to `false`)
2265
- */
2266
- validateWhenHidden?: boolean;
2267
- /**
2268
- * Whether to attach the current form value to all events dispatched through the EventBus.
2269
- *
2270
- * @default undefined (uses global setting)
2271
- */
2272
- emitFormValueOnEvents?: boolean;
2273
- }
2274
- /** Options for controlling submit button disabled behavior. */
2275
- interface SubmitButtonOptions {
2276
- /**
2277
- * Disable submit button when the form is invalid.
2278
- *
2279
- * @default true
2280
- */
2281
- disableWhenInvalid?: boolean;
2282
- /**
2283
- * Disable submit button while the form is submitting.
2284
- *
2285
- * @default true
2286
- */
2287
- disableWhileSubmitting?: boolean;
2288
- }
2289
- /** Options for controlling next page button disabled behavior. */
2290
- interface NextButtonOptions {
2636
+ declare class Parser {
2637
+ private tokens;
2638
+ private current;
2639
+ private readonly expression;
2640
+ constructor(expression: string);
2641
+ /** Parse the expression into an AST */
2642
+ parse(): ASTNode;
2643
+ private parseExpression;
2291
2644
  /**
2292
- * Disable next button when the current page has invalid fields.
2293
- *
2294
- * @default true
2645
+ * Ternary `test ? consequent : alternate` — right-associative, sits between
2646
+ * the arrow-function check and logical-or in precedence.
2295
2647
  */
2296
- disableWhenPageInvalid?: boolean;
2648
+ private parseConditional;
2297
2649
  /**
2298
- * Disable next button while the form is submitting.
2299
- *
2300
- * @default true
2650
+ * Attempts to parse an arrow function. Returns null and leaves position
2651
+ * unchanged if the next tokens don't form an arrow function head.
2301
2652
  */
2302
- disableWhileSubmitting?: boolean;
2653
+ private tryParseArrowFunction;
2654
+ private checkAt;
2655
+ private parseLogicalOr;
2656
+ private parseLogicalAnd;
2657
+ private parseEquality;
2658
+ private parseComparison;
2659
+ private parseAddition;
2660
+ private parseMultiplication;
2661
+ private parseUnary;
2662
+ private parsePostfix;
2663
+ private parsePrimary;
2664
+ private parseArgumentList;
2665
+ private parseArrayElements;
2666
+ private parseObjectProperties;
2667
+ private match;
2668
+ private check;
2669
+ private advance;
2670
+ private isAtEnd;
2671
+ private peek;
2672
+ private previous;
2673
+ private consume;
2303
2674
  }
2304
2675
 
2305
- /** Context for resolving button disabled state. */
2306
- interface ButtonLogicContext {
2307
- /** The form's FieldTree instance (supports both string and number keys for array indices) */
2308
- form: FieldTree<unknown, string | number>;
2309
- /** Form-level options */
2310
- formOptions?: FormOptions;
2311
- /** Field-level logic array (if provided) */
2312
- fieldLogic?: LogicConfig[];
2313
- /** Explicit disabled state from field definition */
2314
- explicitlyDisabled?: boolean;
2315
- /** Current page validity signal (for paged forms) */
2316
- currentPageValid?: Signal<boolean>;
2317
- /** Current form value for evaluating conditional expressions */
2318
- formValue?: unknown;
2319
- /** Optional logger for diagnostic output. Falls back to no-op logger if not provided. */
2320
- logger?: Logger;
2676
+ /** Tokenizes an expression string into tokens */
2677
+ declare class Tokenizer {
2678
+ private position;
2679
+ private readonly expression;
2680
+ constructor(expression: string);
2681
+ /** Tokenize the entire expression */
2682
+ tokenize(): Token[];
2683
+ private skipWhitespace;
2684
+ private nextToken;
2685
+ private readString;
2686
+ private readNumber;
2687
+ private readIdentifierOrKeyword;
2688
+ private getKeywordType;
2689
+ private readOperatorOrPunctuation;
2321
2690
  }
2322
- /**
2323
- * Allowed logic types for non-form-bound elements (buttons, text fields, etc.).
2324
- * These elements only support hidden and disabled states - not readonly or required
2325
- * since they don't participate in form validation.
2326
- */
2327
- type NonFieldLogicType = 'hidden' | 'disabled';
2328
- /**
2329
- * Logic config restricted to types valid for non-form-bound elements.
2330
- * This is a subset of LogicConfig that only includes hidden and disabled types.
2331
- */
2332
- type NonFieldLogicConfig = LogicConfig & {
2333
- type: NonFieldLogicType;
2334
- };
2335
- /** Context for resolving state (hidden/disabled) for non-form-bound elements. */
2336
- interface NonFieldLogicContext {
2337
- /** The form's FieldTree instance (supports both string and number keys for array indices) */
2338
- form: FieldTree<unknown, string | number>;
2339
- /**
2340
- * Field-level logic array containing conditions.
2341
- * Accepts full LogicConfig[] for compatibility, but only hidden and disabled types are processed.
2342
- */
2343
- fieldLogic?: LogicConfig[];
2344
- /** Explicit state from field definition (e.g., `hidden: true` or `disabled: true`) */
2345
- explicitValue?: boolean;
2346
- /** Current form value for evaluating conditional expressions */
2347
- formValue?: unknown;
2348
- /** Optional logger for diagnostic output. Falls back to no-op logger if not provided. */
2349
- logger?: Logger;
2691
+
2692
+ /** TTL cache for HTTP condition responses with max entries eviction. */
2693
+ declare class HttpConditionCache {
2694
+ private readonly cache;
2695
+ private readonly maxEntries;
2696
+ constructor(maxEntries?: number);
2697
+ get(key: string): boolean | undefined;
2698
+ set(key: string, value: boolean, ttlMs: number): void;
2699
+ clear(): void;
2350
2700
  }
2701
+ /** @internal */
2702
+ declare const HTTP_CONDITION_CACHE: InjectionToken<HttpConditionCache>;
2703
+
2351
2704
  /**
2352
- * Resolves the disabled state for a submit button.
2353
- *
2354
- * @param ctx - The button logic context
2355
- * @returns A computed signal that returns true when the button should be disabled
2356
- */
2357
- declare function resolveSubmitButtonDisabled(ctx: ButtonLogicContext): Signal<boolean>;
2358
- /**
2359
- * Resolves the disabled state for a next page button.
2360
- *
2361
- * @param ctx - The button logic context
2362
- * @returns A computed signal that returns true when the button should be disabled
2363
- */
2364
- declare function resolveNextButtonDisabled(ctx: ButtonLogicContext): Signal<boolean>;
2365
- /**
2366
- * Evaluates the hidden state for non-form-bound elements synchronously.
2367
- *
2368
- * @param ctx - The context containing form, logic array, and explicit hidden state
2369
- * @returns true when the element should be hidden
2370
- */
2371
- declare function evaluateNonFieldHidden(ctx: NonFieldLogicContext): boolean;
2372
- /**
2373
- * Resolves the hidden state for non-form-bound elements as a reactive signal.
2374
- *
2375
- * @param ctx - The context containing form, logic array, and explicit hidden state
2376
- * @returns A computed signal that returns true when the element should be hidden
2377
- */
2378
- declare function resolveNonFieldHidden(ctx: NonFieldLogicContext): Signal<boolean>;
2379
- /**
2380
- * Evaluates the disabled state for non-form-bound elements synchronously.
2381
- *
2382
- * @param ctx - The context containing form, logic array, and explicit disabled state
2383
- * @returns true when the element should be disabled
2384
- */
2385
- declare function evaluateNonFieldDisabled(ctx: NonFieldLogicContext): boolean;
2386
- /**
2387
- * Resolves the disabled state for non-form-bound elements as a reactive signal.
2388
- *
2389
- * @param ctx - The context containing form, logic array, and explicit disabled state
2390
- * @returns A computed signal that returns true when the element should be disabled
2705
+ * Resolves an `HttpRequestConfig` into an `HttpResourceRequest` by evaluating
2706
+ * expression-based query params and (optionally) body values.
2391
2707
  */
2392
- declare function resolveNonFieldDisabled(ctx: NonFieldLogicContext): Signal<boolean>;
2708
+ declare function resolveHttpRequest(config: HttpRequestConfig, context: EvaluationContext): HttpResourceRequest | null;
2709
+
2710
+ /** Evaluates an HTTP response against a `HttpValidationResponseMapping` to produce a validation result. */
2711
+ declare function evaluateHttpValidationResponse(response: unknown, mapping: HttpValidationResponseMapping, logger: Logger): ValidationError$1 | null;
2393
2712
 
2394
2713
  /**
2395
2714
  * Service that provides field evaluation context by combining
@@ -2903,142 +3222,22 @@ declare function pageFieldMapper(fieldDef: PageField): Signal<Record<string, unk
2903
3222
  */
2904
3223
  declare function textFieldMapper(fieldDef: TextField): Signal<Record<string, unknown>>;
2905
3224
 
3225
+ /** Handler signature for user-registered addon actions. */
3226
+ type AddonActionHandler<TValue = unknown> = (ctx: AddonActionContext<TValue>) => void;
2906
3227
  /**
2907
- * Fields every addon-action context carries, regardless of whether the
2908
- * addon is bound to a host field or rendered orphaned.
2909
- */
2910
- interface AddonActionContextBase<TValue> {
2911
- /**
2912
- * Identity of the host field this addon is attached to. Empty strings
2913
- * indicate the addon is rendered outside an active field context (rare).
2914
- * Use {@link isFieldBoundContext} or the `form !== null` check to
2915
- * narrow before relying on field identity.
2916
- */
2917
- readonly field: {
2918
- readonly key: string;
2919
- readonly type: string;
2920
- };
2921
- /**
2922
- * Current value of the host field at the time the action fires.
2923
- * `undefined` when the host field has no value yet (initial render before
2924
- * defaultValue resolution) or when the addon is rendered outside a field.
2925
- */
2926
- readonly value: TValue | undefined;
2927
- }
2928
- /**
2929
- * Field-bound variant — the addon is attached to a real field and has a
2930
- * working value-writer. The common case for `pi-button` / `mat-button` /
2931
- * `bs-button` / `ion-button` inside an adapter input field.
2932
- */
2933
- interface FieldBoundAddonActionContext<TValue = unknown> extends AddonActionContextBase<TValue> {
2934
- /** Read-only view of the host field's tree — same view wrappers receive. */
2935
- readonly form: ReadonlyFieldTree<TValue>;
2936
- /** Push a new value into the host field. */
2937
- readonly setValue: (next: TValue) => void;
2938
- }
2939
- /**
2940
- * Orphan variant — the addon is rendered outside any field component (rare;
2941
- * happens when consumers compose `<df-addon-slot>` directly without a host
2942
- * field). No writer is reachable; reading `value` may also yield `undefined`.
2943
- */
2944
- interface OrphanAddonActionContext<TValue = unknown> extends AddonActionContextBase<TValue> {
2945
- readonly form: null;
2946
- /** Always absent in the orphan variant — distinguishes the union members. */
2947
- readonly setValue?: undefined;
2948
- }
2949
- /** Context handed to inline addon actions and registered handler functions. */
2950
- type AddonActionContext<TValue = unknown> = FieldBoundAddonActionContext<TValue> | OrphanAddonActionContext<TValue>;
2951
- /** Type guard narrowing {@link AddonActionContext} to its field-bound variant. */
2952
- declare function isFieldBoundContext<TValue>(ctx: AddonActionContext<TValue>): ctx is FieldBoundAddonActionContext<TValue>;
2953
- /** Built-in preset actions shared across adapters. */
2954
- type CommonAddonActionPreset = 'clear' | 'reset' | 'paste' | 'copy' | 'toggle-password-visibility';
2955
- /** Module-augmentable registry of adapter-specific preset names. */
2956
- interface DynamicFormAddonActionPresetRegistry {
2957
- }
2958
- /**
2959
- * Union of every preset name an addon may reference — universal presets
2960
- * plus any contributed via {@link DynamicFormAddonActionPresetRegistry}.
2961
- */
2962
- type AddonActionPreset = CommonAddonActionPreset | keyof DynamicFormAddonActionPresetRegistry | (string & {});
2963
- /** Module-augmentable registry of user-defined named action handlers. */
2964
- interface DynamicFormActionRegistry {
2965
- }
2966
- /**
2967
- * Typed string handle to a registered action handler. The empty registry
2968
- * resolves to `never`; augmenting `DynamicFormActionRegistry` populates the
2969
- * union and unlocks autocomplete.
2970
- */
2971
- type RegisteredActionRef = keyof DynamicFormActionRegistry;
2972
-
2973
- /**
2974
- * Minimal JSON Schema fragment used by the MCP server to surface an addon
2975
- * kind's shape to AI form generators. Covers the common subset
2976
- * (`type`/`properties`/`required`/`enum`/etc.) without pulling in a full JSON
2977
- * Schema dependency. Extra keys are allowed via the `[key: string]` index so
2978
- * vendor-specific annotations (`x-foo`, `markdownDescription`) still typecheck.
3228
+ * Multi-provider token populated by `withAddonActions({...})` calls.
3229
+ * `ADDON_ACTION_REGISTRY` aggregates these into a single name → handler map.
3230
+ *
3231
+ * @internal
2979
3232
  */
2980
- interface AddonKindSchema {
2981
- readonly $ref?: string;
2982
- readonly $schema?: string;
2983
- readonly title?: string;
2984
- readonly description?: string;
2985
- readonly type?: 'object' | 'array' | 'string' | 'number' | 'integer' | 'boolean' | 'null' | ReadonlyArray<'object' | 'array' | 'string' | 'number' | 'integer' | 'boolean' | 'null'>;
2986
- readonly enum?: ReadonlyArray<unknown>;
2987
- readonly const?: unknown;
2988
- readonly properties?: Readonly<Record<string, AddonKindSchema>>;
2989
- readonly required?: ReadonlyArray<string>;
2990
- readonly additionalProperties?: boolean | AddonKindSchema;
2991
- readonly items?: AddonKindSchema | ReadonlyArray<AddonKindSchema>;
2992
- readonly oneOf?: ReadonlyArray<AddonKindSchema>;
2993
- readonly anyOf?: ReadonlyArray<AddonKindSchema>;
2994
- readonly allOf?: ReadonlyArray<AddonKindSchema>;
2995
- readonly not?: AddonKindSchema;
2996
- readonly default?: unknown;
2997
- readonly examples?: ReadonlyArray<unknown>;
2998
- readonly minimum?: number;
2999
- readonly maximum?: number;
3000
- readonly minLength?: number;
3001
- readonly maxLength?: number;
3002
- readonly pattern?: string;
3003
- readonly format?: string;
3004
- /** Vendor extensions and unrecognised keywords pass through untyped. */
3005
- readonly [key: string]: unknown;
3006
- }
3233
+ declare const ADDON_ACTION_HANDLERS: InjectionToken<readonly Record<string, AddonActionHandler<unknown>>[]>;
3007
3234
  /**
3008
- * Optional shape validator a kind ships to enforce its required fields at
3009
- * runtime. Throws are caught by the validator and converted into lenient
3010
- * warnings; the offending addon is dropped and the form keeps rendering.
3235
+ * Form-scoped name → handler map. Read by adapter button types at click
3236
+ * time for `actionRef: 'name'` lookups. Provided at form scope (not root)
3237
+ * because `ADDON_ACTION_HANDLERS` is form-scoped via `withAddonActions`.
3011
3238
  */
3012
- type AddonShapeValidator<T extends BaseAddon = BaseAddon> = (addon: T, fieldKey: string) => void;
3013
- /** Per-kind registration metadata. */
3014
- interface AddonKindDefinition<T extends BaseAddon = BaseAddon> {
3015
- /** Discriminant matching `addon.kind`. */
3016
- readonly kind: string;
3017
- /** Lazy loader for the kind's renderer component. */
3018
- readonly loadComponent: LazyComponentLoader;
3019
- /** Optional shape validator — throw `DynamicFormError` to drop the addon with a warning. */
3020
- readonly validate?: AddonShapeValidator<T>;
3021
- /** Optional JSON Schema fragment for MCP / pre-flight tooling. */
3022
- readonly schema?: AddonKindSchema;
3023
- /**
3024
- * Whether the kind survives `JSON.stringify` / `JSON.parse`. Kinds whose
3025
- * shape includes a function payload (e.g., the built-in `'component'`
3026
- * loader, inline `prime-button` `action` handlers) declare `jsonSafe: false`
3027
- * so the validator drops them when the config was loaded from a JSON
3028
- * source (`sanitizeFormConfig(config, { source: 'json' })`). Defaults to
3029
- * `true` — kinds are JSON-safe unless explicitly opted out.
3030
- */
3031
- readonly jsonSafe?: boolean;
3032
- }
3033
- /** Per-field-type addon-support metadata declared at field registration. */
3034
- interface FieldAddonSupport {
3035
- /** Slots a field of this type accepts. */
3036
- readonly slots: readonly AddonSlot[];
3037
- /** Optional whitelist of allowed addon kinds. Omitted = any registered kind. */
3038
- readonly allowedKinds?: readonly string[];
3039
- }
3040
- /** Global registry of addon kinds. */
3041
- declare const ADDON_KIND_REGISTRY: InjectionToken<Map<string, AddonKindDefinition<BaseAddon<AddonSlot>>>>;
3239
+ declare const ADDON_ACTION_REGISTRY: InjectionToken<ReadonlyMap<string, AddonActionHandler<unknown>>>;
3240
+ declare function createAddonActionRegistry(): ReadonlyMap<string, AddonActionHandler>;
3042
3241
 
3043
3242
  /**
3044
3243
  * Map of named `TemplateRef`s collected by `<df-dynamic-form>` from
@@ -3483,26 +3682,5 @@ declare function safeReadPathKeys(fieldContext: FieldContext<unknown>): readonly
3483
3682
  */
3484
3683
  declare function stableStringify(value: unknown): string;
3485
3684
 
3486
- /** Input shape passed to a wrapper component via the `fieldInputs` input. */
3487
- interface WrapperFieldInputs {
3488
- readonly key: string;
3489
- /** Field-type discriminant (mirrors `FieldDef.type`) — useful for kind-aware addons. */
3490
- readonly type?: string;
3491
- readonly label?: string;
3492
- readonly placeholder?: string;
3493
- readonly className?: string;
3494
- readonly props?: Record<string, unknown>;
3495
- readonly validationMessages?: Record<string, string>;
3496
- readonly defaultValidationMessages?: Record<string, string>;
3497
- readonly field?: ReadonlyFieldTree;
3498
- /**
3499
- * Write a value into the wrapped field's tree. Provided by `buildFieldInputs`
3500
- * when a `FieldTree` is present. Addons (e.g., `prime-button` presets) use this
3501
- * to mutate the host field; wrappers should treat the field as read-only.
3502
- */
3503
- readonly setValue?: (next: unknown) => void;
3504
- readonly [key: string]: unknown;
3505
- }
3506
-
3507
- export { ADDON_KIND_REGISTRY, ARRAY_CONTEXT, AsyncConditionFunctionCacheService, ComponentInitializedEvent, DEFAULT_PROPS, DEFAULT_VALIDATION_MESSAGES, DEFAULT_WRAPPERS, DEPRECATION_WARNING_TRACKER, DF_FIELD_TEMPLATES, DynamicFormError, DynamicFormLogger, DynamicTextPipe, DynamicValueFunctionCacheService, EMIT_FORM_VALUE_ON_EVENTS, EXTERNAL_DATA, Evaluator, EventBus, ExpressionParser, ExpressionParserError, FIELD_REGISTRY, FIELD_SIGNAL_CONTEXT, FORM_ID_PREFIX, FORM_OPTIONS, FieldContextRegistryService, FunctionRegistryService, GROUP_CONTEXT, HTTP_CONDITION_CACHE, HttpConditionCache, HttpConditionFunctionCacheService, INITIALIZATION_TIMEOUT_MS, LogicFunctionCacheService, NoopLogger, Parser, READONLY_FIELD_TREE_CACHE, RootFormRegistryService, TokenType, Tokenizer, WRAPPER_AUTO_ASSOCIATIONS, WRAPPER_COMPONENT_CACHE, WRAPPER_REGISTRY, applyHiddenLogic, applyMetaToElement, applyValidator, applyValidators, arrayFieldMapper, assertNever, baseFieldMapper, buildBaseInputs, buildClassName, compareValues, containerFieldMapper, createAsyncConditionLogicFunction, createDebouncedLogicFunction, createDebouncedResourceLogicFn, createDefaultDerivationLogConfig, createDynamicValueFunction, createFormFieldStateMap, createHttpConditionLogicFunction, createInitializationTracker, createLogicFunction, createWarningTracker, deepMergeDefaults, derivedFromDeferred, detectFormMode, dynamicTextToObservable, evaluateCondition, evaluateHttpValidationResponse, evaluateNonFieldDisabled, evaluateNonFieldHidden, extractExpressionDependencies, extractStringDependencies, getArrayLength, getChangedKeys, getFieldValueHandling, getGridClassString, getNestedValue, groupFieldMapper, hasChildFields, hasCrossFieldWhenCondition, hasFormValue, hasNestedProperty, hasTargetProperty, injectFieldSignalContext, interpolateParams, isArrayField, isCheckedField, isContainerField, isContainerTypedField, isCrossFieldBuiltInValidator, isCrossFieldExpression, isCrossFieldSchema, isCrossFieldStateLogic, isCrossFieldValidator, isDerivationLogicConfig, isDisplayOnlyField, isEqual, isFieldBoundContext, isFormStateCondition, isFunctionHttpValidator, isGroupField, isHiddenField, isLeafField, isNonPagedForm, isPageField, isPagedForm, isResourceBasedValidator, isRowField, isSimplifiedArrayField, isStateLogicConfig, isValidNonPagedForm, isValidPagedForm, isValueBearingField, isValueField, isWrapperTypeDefinition, keyBy, mapValues, memoize, normalizeFieldsArray, omit, pageFieldMapper, readFieldStateInfo, resolveDynamicValue, resolveHttpRequest, resolveNextButtonDisabled, resolveNonFieldDisabled, resolveNonFieldHidden, resolveSubmitButtonDisabled, resolveTokens, rowFieldMapper, safeReadPathKeys, setupInitializationTracking, shouldLog, stableStringify, textFieldMapper, toReadonlyFieldTree, toReadonlyFieldTreeCached, validatePageNesting, withPreviousValue, writeToFieldValue };
3508
- export type { ASTNode, AddonActionContext, AddonActionPreset, AddonKindDefinition, AddonKindSchema, AddonShapeValidator, AddonSlot, AndCondition, AnyAddon, ArrayAllowedChildren, ArrayButtonConfig, ArrayComponent, ArrayContext, ArrayField, ArrayFieldTree, ArrayItemDefinition, ArrayItemTemplate, ArrayLiteralNode, ArrowFunctionNode, AsyncCondition, AsyncConditionFunction, AsyncCustomValidator, AsyncDerivationFunction, AsyncValidatorConfig, AvailableFieldTypes, BaseAddon, BaseCheckedField, BaseValidatorConfig, BaseValueField, BinaryOpNode, BuiltInValidatorConfig, ButtonLogicContext, CallExpressionNode, CheckedFieldComponent, CommonAddonActionPreset, CommonAddonSlot, ComparisonOperator, ComponentAddon, ComputedMemberAccessNode, ConditionalExpression, ConditionalNode, ContainerAllowedChildren, ContainerComponent, ContainerField, ContainerFieldTypes, ContainerLogicConfig, CrossFieldDetectionContext, CssWrapper, CustomCondition, CustomFnConfig, CustomFunction, CustomFunctionOptions, CustomFunctionScope, CustomValidator, CustomValidatorConfig, DebouncedResourceLogicFnConfig, DeclarativeHttpValidatorConfig, DerivationLogConfig, DerivationLogLevel, DerivationLogicConfig, DerivedFromDeferredOptions, DynamicFormActionRegistry, DynamicFormAddonActionPresetRegistry, DynamicFormAddonRegistry, DynamicFormAddonSlotRegistry, DynamicFormFieldRegistry, DynamicText, DynamicValue, EvaluationContext, EvaluationScope, ExtractField, FieldAddonSupport, FieldBoundAddonActionContext, FieldComponent, FieldDef, FieldMeta, FieldOption, FieldPathAccess, FieldRegistryContainers, FieldRegistryLeaves, FieldRegistryWrappers, FieldScope, FieldSignalContext, FieldStateContext, FieldStateInfo, FieldTreeRecord, FieldTypeDefinition, FieldValueCondition, FieldWithValidation, FieldWrapper, FormConfig, FormEvent, FormEventConstructor, FormFieldStateMap, FormMode, FormModeDetectionResult, FormOptions, FormStateCondition, FunctionHttpValidatorConfig, GroupAllowedChildren, GroupComponent, GroupContext, GroupField, HiddenField, HiddenScalar, HiddenValue, HttpCondition, HttpCustomValidator, HttpRequestConfig, HttpResourceRequest, HttpValidationResponseMapping, IdentifierNode, InferFormValue, InitializationTrackingOptions, JavascriptCondition, LazyComponentLoader, LeafFieldTypes, LiteralNode, Logger, LogicConfig, LogicTrigger, MapperFn, MemberAccessNode, MemoizeOptions, NarrowField, NarrowFields, NextButtonOptions, NonFieldLogicConfig, NonFieldLogicContext, NonFieldLogicType, ObjectLiteralNode, OrCondition, OrphanAddonActionContext, PageAllowedChildren, PageField, Prettify, ReadonlyFieldTree, RegisteredActionRef, RegisteredFieldTypes, RegisteredWrapperTypes, RenderReadyInput, ResolvedValidationExecutionConfig, ResolvedValueExclusionConfig, RowAllowedChildren, RowComponent, RowField, RowWrapper, SchemaApplicationConfig, SchemaDefinition, SimplifiedArrayField, StateLogicConfig, StateLogicType, SubmissionActionResult, SubmissionConfig, SubmitButtonOptions, TemplateAddon, TextAddon, TextElementType, TextField, TextProps, Token, TokenContext, Trigger, UnaryOpNode, ValidationError, ValidationExecutionConfig, ValidationMessages, ValidatorConfig, ValueExclusionConfig, ValueFieldComponent, ValueHandlingMode, ValueType, WarningTracker, WithInputSignals, WrapperAutoAssociations, WrapperConfig, WrapperFieldInputs, WrapperTypeDefinition };
3685
+ export { ADDON_ACTION_HANDLERS, ADDON_ACTION_REGISTRY, ADDON_TYPE_COMPONENT_CACHE, ADDON_TYPE_DEFINITIONS, ADDON_TYPE_REGISTRY, ARRAY_CONTEXT, AsyncConditionFunctionCacheService, ComponentInitializedEvent, DEFAULT_PROPS, DEFAULT_VALIDATION_MESSAGES, DEFAULT_WRAPPERS, DEPRECATION_WARNING_TRACKER, DF_FIELD_TEMPLATES, DfAddonSlot, DynamicFormError, DynamicFormLogger, DynamicTextPipe, DynamicValueFunctionCacheService, EMIT_FORM_VALUE_ON_EVENTS, EXTERNAL_DATA, Evaluator, EventBus, ExpressionParser, ExpressionParserError, FIELD_REGISTRY, FIELD_SIGNAL_CONTEXT, FORM_ID_PREFIX, FORM_OPTIONS, FieldContextRegistryService, FunctionRegistryService, GROUP_CONTEXT, HTTP_CONDITION_CACHE, HttpConditionCache, HttpConditionFunctionCacheService, INITIALIZATION_TIMEOUT_MS, LogicFunctionCacheService, NoopLogger, Parser, READONLY_FIELD_TREE_CACHE, RootFormRegistryService, TokenType, Tokenizer, WRAPPER_AUTO_ASSOCIATIONS, WRAPPER_COMPONENT_CACHE, WRAPPER_REGISTRY, applyHiddenLogic, applyMetaToElement, applyValidator, applyValidators, arrayFieldMapper, assertNever, baseFieldMapper, buildBaseInputs, buildClassName, compareValues, containerFieldMapper, createAddonActionRegistry, createAsyncConditionLogicFunction, createDebouncedLogicFunction, createDebouncedResourceLogicFn, createDefaultDerivationLogConfig, createDynamicValueFunction, createFormFieldStateMap, createHttpConditionLogicFunction, createInitializationTracker, createLogicFunction, createWarningTracker, deepMergeDefaults, derivedFromDeferred, detectFormMode, dynamicTextToObservable, evaluateCondition, evaluateHttpValidationResponse, evaluateNonFieldDisabled, evaluateNonFieldHidden, extractExpressionDependencies, extractStringDependencies, getArrayLength, getChangedKeys, getFieldValueHandling, getGridClassString, getNestedValue, groupFieldMapper, hasChildFields, hasCrossFieldWhenCondition, hasFormValue, hasNestedProperty, hasTargetProperty, injectAddonTypeRegistry, injectFieldSignalContext, injectFieldsSupportingAddons, interpolateParams, isArrayField, isCheckedField, isContainerField, isCrossFieldBuiltInValidator, isCrossFieldExpression, isCrossFieldSchema, isCrossFieldStateLogic, isCrossFieldValidator, isDerivationLogicConfig, isDisplayOnlyField, isEqual, isFieldBoundContext, isFormStateCondition, isFunctionHttpValidator, isGenericContainerField, isGroupField, isHiddenField, isLeafField, isNonPagedForm, isPageField, isPagedForm, isResourceBasedValidator, isRowField, isSimplifiedArrayField, isStateLogicConfig, isValidNonPagedForm, isValidPagedForm, isValueBearingField, isValueField, isWrapperTypeDefinition, keyBy, mapValues, memoize, normalizeFieldsArray, omit, pageFieldMapper, readFieldStateInfo, resolveDynamicValue, resolveHttpRequest, resolveNextButtonDisabled, resolveNonFieldDisabled, resolveNonFieldHidden, resolveSubmitButtonDisabled, resolveTokens, rowFieldMapper, runPresetAction, safeReadPathKeys, setupInitializationTracking, shouldLog, stableStringify, textFieldMapper, toReadonlyFieldTree, toReadonlyFieldTreeCached, validatePageNesting, withPreviousValue, writeToFieldValue };
3686
+ export type { ASTNode, AddonActionContext, AddonActionHandler, AddonActionPreset, AddonShapeValidator, AddonSlot, AddonTypeDefinition, AddonTypeRegistryRef, AddonTypeSchema, AndCondition, AnyAddon, ArrayAllowedChildren, ArrayButtonConfig, ArrayComponent, ArrayContext, ArrayField, ArrayFieldTree, ArrayItemDefinition, ArrayItemTemplate, ArrayLiteralNode, ArrowFunctionNode, AsyncCondition, AsyncConditionFunction, AsyncCustomValidator, AsyncDerivationFunction, AsyncValidatorConfig, AvailableFieldTypes, BaseAddon, BaseCheckedField, BaseValidatorConfig, BaseValueField, BinaryOpNode, BuiltInValidatorConfig, ButtonLogicContext, CallExpressionNode, CheckedFieldComponent, CommonAddonActionPreset, CommonAddonSlot, ComparisonOperator, ComponentAddon, ComputedMemberAccessNode, ConditionalExpression, ConditionalNode, ContainerAllowedChildren, ContainerComponent, ContainerField, ContainerFieldTypes, ContainerLogicConfig, CrossFieldDetectionContext, CssWrapper, CustomCondition, CustomFnConfig, CustomFunction, CustomFunctionOptions, CustomFunctionScope, CustomValidator, CustomValidatorConfig, DebouncedResourceLogicFnConfig, DeclarativeHttpValidatorConfig, DerivationLogConfig, DerivationLogLevel, DerivationLogicConfig, DerivedFromDeferredOptions, DynamicFormActionRegistry, DynamicFormAddonActionPresetRegistry, DynamicFormAddonRegistry, DynamicFormAddonSlotRegistry, DynamicFormFieldRegistry, DynamicText, DynamicValue, EvaluationContext, EvaluationScope, ExtractField, FieldAddonSupport, FieldAddonSupportEntry, FieldBoundAddonActionContext, FieldComponent, FieldDef, FieldMeta, FieldOption, FieldPathAccess, FieldRegistryContainers, FieldRegistryLeaves, FieldRegistryWrappers, FieldScope, FieldSignalContext, FieldStateContext, FieldStateInfo, FieldTreeRecord, FieldTypeDefinition, FieldValueCondition, FieldWithValidation, FieldWrapper, FormConfig, FormEvent, FormEventConstructor, FormFieldStateMap, FormMode, FormModeDetectionResult, FormOptions, FormStateCondition, FunctionHttpValidatorConfig, GroupAllowedChildren, GroupComponent, GroupContext, GroupField, HiddenField, HiddenScalar, HiddenValue, HttpCondition, HttpCustomValidator, HttpRequestConfig, HttpResourceRequest, HttpValidationResponseMapping, IdentifierNode, InferFormValue, InitializationTrackingOptions, JavascriptCondition, LazyComponentLoader, LeafFieldTypes, LiteralNode, Logger, LogicConfig, LogicTrigger, MapperFn, MemberAccessNode, MemoizeOptions, NarrowField, NarrowFields, NextButtonOptions, NonFieldLogicConfig, NonFieldLogicContext, NonFieldLogicType, ObjectLiteralNode, OrCondition, OrphanAddonActionContext, PageAllowedChildren, PageField, PresetCollaborators, Prettify, ReadonlyFieldTree, RegisteredActionRef, RegisteredFieldTypes, RegisteredWrapperTypes, RenderReadyInput, ResolvedValidationExecutionConfig, ResolvedValueExclusionConfig, RowAllowedChildren, RowComponent, RowField, RowWrapper, SchemaApplicationConfig, SchemaDefinition, SimplifiedArrayField, StateLogicConfig, StateLogicType, SubmissionActionResult, SubmissionConfig, SubmitButtonOptions, TemplateAddon, TextAddon, TextElementType, TextField, TextProps, Token, TokenContext, Trigger, UnaryOpNode, ValidationError, ValidationExecutionConfig, ValidationMessages, ValidatorConfig, ValueExclusionConfig, ValueFieldComponent, ValueHandlingMode, ValueType, WarningTracker, WithInputSignals, WrapperAutoAssociations, WrapperConfig, WrapperFieldInputs, WrapperTypeDefinition };