@angular/forms 21.1.0-next.3 → 21.1.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,11 @@
1
1
  /**
2
- * @license Angular v21.1.0-next.3
3
- * (c) 2010-2025 Google LLC. https://angular.dev/
2
+ * @license Angular v21.1.0-rc.0
3
+ * (c) 2010-2026 Google LLC. https://angular.dev/
4
4
  * License: MIT
5
5
  */
6
6
 
7
7
  import { FieldNode, getInjectorFromOptions, FieldNodeState, FieldNodeStructure, calculateValidationSelfStatus, BasicFieldAdapter, form, normalizeFormArgs } from './_structure-chunk.mjs';
8
- import { linkedSignal, untracked, runInInjectionContext, computed, signal } from '@angular/core';
8
+ import { linkedSignal, untracked, runInInjectionContext, computed, signal, ɵRuntimeError as _RuntimeError } from '@angular/core';
9
9
  import { FormGroup, FormArray, AbstractControl } from '@angular/forms';
10
10
  import { toSignal } from '@angular/core/rxjs-interop';
11
11
  import { ReplaySubject } from 'rxjs';
@@ -134,7 +134,7 @@ class CompatStructure extends FieldNodeStructure {
134
134
  fieldManager;
135
135
  constructor(node, options) {
136
136
  super(options.logic, node, () => {
137
- throw new Error(`Compat nodes don't have children.`);
137
+ throw new _RuntimeError(1911, ngDevMode && `Compat nodes don't have children.`);
138
138
  });
139
139
  this.value = getControlValueSignal(options);
140
140
  this.parent = getParentFromOptions(options);
@@ -155,7 +155,7 @@ class CompatStructure extends FieldNodeStructure {
155
155
  class CompatValidationError {
156
156
  kind = 'compat';
157
157
  control;
158
- field;
158
+ fieldTree;
159
159
  context;
160
160
  message;
161
161
  constructor({
@@ -292,13 +292,27 @@ function compatForm(...args) {
292
292
  }
293
293
 
294
294
  const NG_STATUS_CLASSES = {
295
- 'ng-touched': state => state.touched(),
296
- 'ng-untouched': state => !state.touched(),
297
- 'ng-dirty': state => state.dirty(),
298
- 'ng-pristine': state => !state.dirty(),
299
- 'ng-valid': state => state.valid(),
300
- 'ng-invalid': state => state.invalid(),
301
- 'ng-pending': state => state.pending()
295
+ 'ng-touched': ({
296
+ state
297
+ }) => state().touched(),
298
+ 'ng-untouched': ({
299
+ state
300
+ }) => !state().touched(),
301
+ 'ng-dirty': ({
302
+ state
303
+ }) => state().dirty(),
304
+ 'ng-pristine': ({
305
+ state
306
+ }) => !state().dirty(),
307
+ 'ng-valid': ({
308
+ state
309
+ }) => state().valid(),
310
+ 'ng-invalid': ({
311
+ state
312
+ }) => state().invalid(),
313
+ 'ng-pending': ({
314
+ state
315
+ }) => state().pending()
302
316
  };
303
317
 
304
318
  export { CompatValidationError, NG_STATUS_CLASSES, compatForm };
@@ -1 +1 @@
1
- {"version":3,"file":"signals-compat.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/forms/signals/compat/src/compat_field_node.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/forms/signals/compat/src/compat_node_state.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/forms/signals/compat/src/compat_structure.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/forms/signals/compat/src/api/compat_validation_error.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/forms/signals/compat/src/compat_validation_error.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/forms/signals/compat/src/compat_validation_state.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/forms/signals/compat/src/compat_field_adapter.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/forms/signals/compat/src/api/compat_form.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/forms/signals/compat/src/api/di.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {computed, linkedSignal, runInInjectionContext, Signal, untracked} from '@angular/core';\nimport {toSignal} from '@angular/core/rxjs-interop';\nimport {AbstractControl} from '@angular/forms';\nimport {Observable, ReplaySubject} from 'rxjs';\nimport {map, takeUntil} from 'rxjs/operators';\nimport {FieldNode} from '../../src/field/node';\nimport {getInjectorFromOptions} from '../../src/field/util';\nimport type {CompatFieldNodeOptions} from './compat_structure';\n\n/**\n * Field node with additional control property.\n *\n * Compat node has no children.\n */\nexport class CompatFieldNode extends FieldNode {\n readonly control: Signal<AbstractControl>;\n\n constructor(public readonly options: CompatFieldNodeOptions) {\n super(options);\n this.control = this.options.control;\n }\n}\n\n/**\n * Makes a function which creates a new subject (and unsubscribes/destroys the previous one).\n *\n * This allows us to automatically unsubscribe from status changes of the previous FormControl when we go to subscribe to a new one\n */\nfunction makeCreateDestroySubject() {\n let destroy$ = new ReplaySubject<void>(1);\n return () => {\n if (destroy$) {\n destroy$.next();\n destroy$.complete();\n }\n return (destroy$ = new ReplaySubject<void>(1));\n };\n}\n\n/**\n * Helper function taking options, and a callback which takes options, and a function\n * converting reactive control to appropriate property using toSignal from rxjs compat.\n *\n * This helper keeps all complexity in one place by doing the following things:\n * - Running the callback in injection context\n * - Not tracking the callback, as it creates a new signal.\n * - Reacting to control changes, allowing to swap control dynamically.\n *\n * @param options\n * @param makeSignal\n */\nexport function extractControlPropToSignal<T, R = T>(\n options: CompatFieldNodeOptions,\n makeSignal: (c: AbstractControl<unknown, T>, destroy$: Observable<void>) => Signal<R>,\n): Signal<R> {\n const injector = getInjectorFromOptions(options);\n\n // Creates a subject that could be used in takeUntil.\n const createDestroySubject = makeCreateDestroySubject();\n\n const signalOfControlSignal = linkedSignal({\n source: options.control,\n computation: (control) => {\n return untracked(() => {\n return runInInjectionContext(injector, () => makeSignal(control, createDestroySubject()));\n });\n },\n });\n\n // We have to have computed, because we need to react to both:\n // linked signal changes as well as the inner signal changes.\n return computed(() => signalOfControlSignal()());\n}\n\n/**\n * A helper function, simplifying getting reactive control properties after status changes.\n *\n * Used to extract errors and statuses such as valid, pending.\n *\n * @param options\n * @param getValue\n */\nexport const getControlStatusSignal = <T>(\n options: CompatFieldNodeOptions,\n getValue: (c: AbstractControl<unknown>) => T,\n) => {\n return extractControlPropToSignal<unknown, T>(options, (c, destroy$) =>\n toSignal(\n c.statusChanges.pipe(\n map(() => getValue(c)),\n takeUntil(destroy$),\n ),\n {\n initialValue: getValue(c),\n },\n ),\n );\n};\n\n/**\n * A helper function, simplifying converting convert events to signals.\n *\n * Used to get dirty and touched signals from control.\n *\n * @param options\n * @param getValue A function which takes control and returns required value.\n */\nexport const getControlEventsSignal = <T>(\n options: CompatFieldNodeOptions,\n getValue: (c: AbstractControl) => T,\n) => {\n return extractControlPropToSignal<unknown, T>(options, (c, destroy$) =>\n toSignal(\n c.events.pipe(\n map(() => {\n return getValue(c);\n }),\n takeUntil(destroy$),\n ),\n {\n initialValue: getValue(c),\n },\n ),\n );\n};\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {computed, Signal} from '@angular/core';\nimport {AbstractControl} from '@angular/forms';\nimport {FieldNodeState} from '../../src/field/state';\nimport {CompatFieldNode, getControlEventsSignal, getControlStatusSignal} from './compat_field_node';\nimport {CompatFieldNodeOptions} from './compat_structure';\n\n/**\n * A FieldNodeState class wrapping a FormControl and proxying it's state.\n */\nexport class CompatNodeState extends FieldNodeState {\n override readonly touched: Signal<boolean>;\n override readonly dirty: Signal<boolean>;\n override readonly disabled: Signal<boolean>;\n private readonly control: Signal<AbstractControl>;\n\n constructor(\n readonly compatNode: CompatFieldNode,\n options: CompatFieldNodeOptions,\n ) {\n super(compatNode);\n this.control = options.control;\n this.touched = getControlEventsSignal(options, (c) => c.touched);\n this.dirty = getControlEventsSignal(options, (c) => c.dirty);\n const controlDisabled = getControlStatusSignal(options, (c) => c.disabled);\n\n this.disabled = computed(() => {\n return controlDisabled() || this.disabledReasons().length > 0;\n });\n }\n\n override markAsDirty() {\n this.control().markAsDirty();\n }\n\n override markAsTouched() {\n this.control().markAsTouched();\n }\n\n override markAsPristine() {\n this.control().markAsPristine();\n }\n\n override markAsUntouched() {\n this.control().markAsUntouched();\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {computed, Signal, signal, WritableSignal} from '@angular/core';\nimport {FormFieldManager} from '../../src/field/manager';\nimport {FieldNode, ParentFieldNode} from '../../src/field/node';\nimport {\n ChildFieldNodeOptions,\n FieldNodeOptions,\n FieldNodeStructure,\n RootFieldNodeOptions,\n} from '../../src/field/structure';\n\nimport {toSignal} from '@angular/core/rxjs-interop';\nimport {AbstractControl} from '@angular/forms';\nimport {map, takeUntil} from 'rxjs/operators';\nimport {extractControlPropToSignal} from './compat_field_node';\n\n/**\n * Child Field Node options also exposing control property.\n */\nexport interface CompatChildFieldNodeOptions extends ChildFieldNodeOptions {\n control: Signal<AbstractControl>;\n}\n\n/**\n * Root Field Node options also exposing control property.\n */\nexport interface CompatRootFieldNodeOptions extends RootFieldNodeOptions {\n control: Signal<AbstractControl>;\n}\n\n/**\n * Field Node options also exposing control property.\n */\nexport type CompatFieldNodeOptions = CompatRootFieldNodeOptions | CompatChildFieldNodeOptions;\n\n/**\n * A helper function allowing to get parent if it exists.\n */\nfunction getParentFromOptions(options: FieldNodeOptions) {\n if (options.kind === 'root') {\n return undefined;\n }\n\n return options.parent;\n}\n\n/**\n * A helper function allowing to get fieldManager regardless of the option type.\n */\nfunction getFieldManagerFromOptions(options: FieldNodeOptions) {\n if (options.kind === 'root') {\n return options.fieldManager;\n }\n\n return options.parent.structure.root.structure.fieldManager;\n}\n\n/**\n * A helper function that takes CompatFieldNodeOptions, and produce a writable signal synced to the\n * value of contained AbstractControl.\n *\n * This uses toSignal, which requires an injector.\n *\n * @param options\n */\nfunction getControlValueSignal<T>(options: CompatFieldNodeOptions) {\n const value = extractControlPropToSignal<T>(options, (control, destroy$) => {\n return toSignal(\n control.valueChanges.pipe(\n map(() => control.getRawValue()),\n takeUntil(destroy$),\n ),\n {\n initialValue: control.getRawValue(),\n },\n );\n }) as WritableSignal<T>;\n\n value.set = (value: T) => {\n options.control().setValue(value);\n };\n\n value.update = (fn: (current: T) => T) => {\n value.set(fn(value()));\n };\n\n return value;\n}\n\n/**\n * Compat version of FieldNodeStructure,\n * - It has no children\n * - It wraps FormControl and proxies its value.\n */\nexport class CompatStructure extends FieldNodeStructure {\n override value: WritableSignal<unknown>;\n override keyInParent: Signal<string>;\n override root: FieldNode;\n override pathKeys: Signal<readonly string[]>;\n override readonly children = signal([]);\n override readonly childrenMap = computed(() => undefined);\n override readonly parent: ParentFieldNode | undefined;\n override readonly fieldManager: FormFieldManager;\n\n constructor(node: FieldNode, options: CompatFieldNodeOptions) {\n super(options.logic, node, () => {\n throw new Error(`Compat nodes don't have children.`);\n });\n this.value = getControlValueSignal(options);\n this.parent = getParentFromOptions(options);\n this.root = this.parent?.structure.root ?? node;\n this.fieldManager = getFieldManagerFromOptions(options);\n\n const identityInParent = options.kind === 'child' ? options.identityInParent : undefined;\n const initialKeyInParent = options.kind === 'child' ? options.initialKeyInParent : undefined;\n this.keyInParent = this.createKeyInParent(options, identityInParent, initialKeyInParent);\n\n this.pathKeys = computed(() =>\n this.parent ? [...this.parent.structure.pathKeys(), this.keyInParent()] : [],\n );\n }\n\n override getChild(): FieldNode | undefined {\n return undefined;\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {AbstractControl} from '@angular/forms';\nimport {ValidationError} from '../../../src/api/rules/validation/validation_errors';\nimport {FieldTree} from '../../../src/api/types';\n\n/**\n * An error used for compat errors.\n *\n * @experimental 21.0.0\n * @category interop\n */\nexport class CompatValidationError<T = unknown> implements ValidationError {\n readonly kind: string = 'compat';\n readonly control: AbstractControl;\n readonly field!: FieldTree<unknown>;\n readonly context: T;\n readonly message?: string;\n\n constructor({context, kind, control}: {context: T; kind: string; control: AbstractControl}) {\n this.context = context;\n this.kind = kind;\n this.control = control;\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {AbstractControl, FormArray, FormGroup, ValidationErrors} from '@angular/forms';\nimport {CompatValidationError} from './api/compat_validation_error';\n\n/**\n * Converts reactive form validation error to signal forms CompatValidationError.\n * @param errors\n * @param control\n * @return list of errors.\n */\nexport function reactiveErrorsToSignalErrors(\n errors: ValidationErrors | null,\n control: AbstractControl,\n): CompatValidationError[] {\n if (errors === null) {\n return [];\n }\n\n return Object.entries(errors).map(([kind, context]) => {\n return new CompatValidationError({context, kind, control});\n });\n}\n\nexport function extractNestedReactiveErrors(control: AbstractControl): CompatValidationError[] {\n const errors: CompatValidationError[] = [];\n\n if (control.errors) {\n errors.push(...reactiveErrorsToSignalErrors(control.errors, control));\n }\n\n if (control instanceof FormGroup || control instanceof FormArray) {\n for (const c of Object.values(control.controls)) {\n errors.push(...extractNestedReactiveErrors(c));\n }\n }\n\n return errors;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {computed, Signal} from '@angular/core';\nimport {AbstractControl} from '@angular/forms';\nimport {ValidationError} from '../../src/api/rules/validation/validation_errors';\nimport {calculateValidationSelfStatus, ValidationState} from '../../src/field/validation';\nimport type {CompatValidationError} from './api/compat_validation_error';\nimport {getControlStatusSignal} from './compat_field_node';\nimport {CompatFieldNodeOptions} from './compat_structure';\nimport {extractNestedReactiveErrors} from './compat_validation_error';\n\n// Readonly signal containing an empty array, used for optimization.\nconst EMPTY_ARRAY_SIGNAL = computed(() => []);\nconst TRUE_SIGNAL = computed(() => true);\n\n/**\n * Compat version of a validation state that wraps a FormControl, and proxies it's validation state.\n */\nexport class CompatValidationState implements ValidationState {\n readonly syncValid: Signal<boolean>;\n /**\n * All validation errors for this field.\n */\n readonly errors: Signal<CompatValidationError[]>;\n readonly pending: Signal<boolean>;\n readonly invalid: Signal<boolean>;\n readonly valid: Signal<boolean>;\n\n constructor(options: CompatFieldNodeOptions) {\n this.syncValid = getControlStatusSignal(options, (c: AbstractControl) => c.status === 'VALID');\n this.errors = getControlStatusSignal(options, extractNestedReactiveErrors);\n this.pending = getControlStatusSignal(options, (c) => c.pending);\n\n this.valid = getControlStatusSignal(options, (c) => {\n return c.valid;\n });\n\n this.invalid = getControlStatusSignal(options, (c) => {\n return c.invalid;\n });\n }\n\n asyncErrors: Signal<(ValidationError.WithField | 'pending')[]> = EMPTY_ARRAY_SIGNAL;\n errorSummary: Signal<ValidationError.WithField[]> = EMPTY_ARRAY_SIGNAL;\n\n // Those are irrelevant for compat mode, as it has no children\n rawSyncTreeErrors = EMPTY_ARRAY_SIGNAL;\n syncErrors = EMPTY_ARRAY_SIGNAL;\n rawAsyncErrors = EMPTY_ARRAY_SIGNAL;\n shouldSkipValidation = TRUE_SIGNAL;\n\n /**\n * Computes status based on whether the field is valid/invalid/pending.\n */\n readonly status: Signal<'valid' | 'invalid' | 'unknown'> = computed(() => {\n return calculateValidationSelfStatus(this);\n });\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {computed, Signal, WritableSignal} from '@angular/core';\nimport {AbstractControl} from '@angular/forms';\nimport {BasicFieldAdapter, FieldAdapter} from '../../src/field/field_adapter';\nimport {FormFieldManager} from '../../src/field/manager';\nimport {FieldNode} from '../../src/field/node';\nimport {FieldNodeState} from '../../src/field/state';\nimport {\n ChildFieldNodeOptions,\n FieldNodeOptions,\n FieldNodeStructure,\n} from '../../src/field/structure';\nimport {ValidationState} from '../../src/field/validation';\nimport {FieldPathNode} from '../../src/schema/path_node';\nimport {CompatFieldNode} from './compat_field_node';\nimport {CompatNodeState} from './compat_node_state';\nimport {CompatChildFieldNodeOptions, CompatStructure} from './compat_structure';\nimport {CompatValidationState} from './compat_validation_state';\n\n/**\n * This is a tree-shakable Field adapter that can create a compat node\n * that proxies FormControl state and value to a field.\n */\nexport class CompatFieldAdapter implements FieldAdapter {\n readonly basicAdapter = new BasicFieldAdapter();\n\n /**\n * Creates a regular or compat root node state based on whether the control is present.\n * @param fieldManager\n * @param value\n * @param pathNode\n * @param adapter\n */\n newRoot<TModel>(\n fieldManager: FormFieldManager,\n value: WritableSignal<TModel>,\n pathNode: FieldPathNode,\n adapter: FieldAdapter,\n ): FieldNode {\n if (value() instanceof AbstractControl) {\n return createCompatNode({\n kind: 'root',\n fieldManager,\n value,\n pathNode,\n logic: pathNode.builder.build(),\n fieldAdapter: adapter,\n });\n }\n\n return this.basicAdapter.newRoot<TModel>(fieldManager, value, pathNode, adapter);\n }\n\n /**\n * Creates a regular or compat node state based on whether the control is present.\n * @param node\n * @param options\n */\n createNodeState(node: CompatFieldNode, options: CompatChildFieldNodeOptions): FieldNodeState {\n if (!options.control) {\n return this.basicAdapter.createNodeState(node);\n }\n return new CompatNodeState(node, options);\n }\n\n /**\n * Creates a regular or compat structure based on whether the control is present.\n * @param node\n * @param options\n */\n createStructure(node: CompatFieldNode, options: CompatChildFieldNodeOptions): FieldNodeStructure {\n if (!options.control) {\n return this.basicAdapter.createStructure(node, options);\n }\n return new CompatStructure(node, options);\n }\n\n /**\n * Creates a regular or compat validation state based on whether the control is present.\n * @param node\n * @param options\n */\n createValidationState(\n node: CompatFieldNode,\n options: CompatChildFieldNodeOptions,\n ): ValidationState {\n if (!options.control) {\n return this.basicAdapter.createValidationState(node);\n }\n return new CompatValidationState(options);\n }\n\n /**\n * Creates a regular or compat node based on whether the control is present.\n * @param options\n */\n newChild(options: ChildFieldNodeOptions): FieldNode {\n const value = options.parent.value()[options.initialKeyInParent];\n\n if (value instanceof AbstractControl) {\n return createCompatNode(options);\n }\n\n return new FieldNode(options);\n }\n}\n\n/**\n * Creates a CompatFieldNode from options.\n * @param options\n */\nexport function createCompatNode(options: FieldNodeOptions) {\n const control = (\n options.kind === 'root'\n ? options.value\n : computed(() => {\n return options.parent.value()[options.initialKeyInParent];\n })\n ) as Signal<AbstractControl>;\n\n return new CompatFieldNode({\n ...options,\n control,\n });\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {WritableSignal} from '@angular/core';\nimport {form, FormOptions} from '../../../public_api';\nimport {FieldTree, PathKind, SchemaOrSchemaFn} from '../../../src/api/types';\nimport {normalizeFormArgs} from '../../../src/util/normalize_form_args';\nimport {CompatFieldAdapter} from '../compat_field_adapter';\n\n/**\n * Options that may be specified when creating a compat form.\n *\n * @category interop\n * @experimental 21.0.0\n */\nexport type CompatFormOptions = Omit<FormOptions, 'adapter'>;\n\n/**\n * Creates a compatibility form wrapped around the given model data.\n *\n * `compatForm` is a version of the `form` function that is designed for backwards\n * compatibility with Reactive forms by accepting Reactive controls as a part of the data.\n *\n * @example\n * ```ts\n * const lastName = new FormControl('lastName');\n *\n * const nameModel = signal({\n * first: '',\n * last: lastName\n * });\n *\n * const nameForm = compatForm(nameModel, (name) => {\n * required(name.first);\n * });\n *\n * nameForm.last().value(); // lastName, not FormControl\n * ```\n * \n * @param model A writable signal that contains the model data for the form. The resulting field\n * structure will match the shape of the model and any changes to the form data will be written to\n * the model.\n\n * @category interop\n * @experimental 21.0.0\n */\nexport function compatForm<TModel>(model: WritableSignal<TModel>): FieldTree<TModel>;\n\n/**\n * Creates a compatibility form wrapped around the given model data.\n *\n * `compatForm` is a version of the `form` function that is designed for backwards\n * compatibility with Reactive forms by accepting Reactive controls as a part of the data.\n *\n * @example\n * ```ts\n * const lastName = new FormControl('lastName');\n *\n * const nameModel = signal({\n * first: '',\n * last: lastName\n * });\n *\n * const nameForm = compatForm(nameModel, (name) => {\n * required(name.first);\n * });\n *\n * nameForm.last().value(); // lastName, not FormControl\n *\n * @param model A writable signal that contains the model data for the form. The resulting field\n * structure will match the shape of the model and any changes to the form data will be written to\n * the model.\n * @param schemaOrOptions The second argument can be either\n * 1. A schema or a function used to specify logic for the form (e.g. validation, disabled fields, etc.).\n * When passing a schema, the form options can be passed as a third argument if needed.\n * 2. The form options (excluding adapter, since it's provided).\n *\n * @category interop\n * @experimental 21.0.0\n */\nexport function compatForm<TModel>(\n model: WritableSignal<TModel>,\n schemaOrOptions: SchemaOrSchemaFn<TModel> | CompatFormOptions,\n): FieldTree<TModel>;\n\n/**\n * Creates a compatibility form wrapped around the given model data.\n *\n * `compatForm` is a version of the `form` function that is designed for backwards\n * compatibility with Reactive forms by accepting Reactive controls as a part of the data.\n *\n * @example\n * ```ts\n * const lastName = new FormControl('lastName');\n *\n * const nameModel = signal({\n * first: '',\n * last: lastName\n * });\n *\n * const nameForm = compatForm(nameModel, (name) => {\n * required(name.first);\n * });\n *\n * nameForm.last().value(); // lastName, not FormControl\n *\n * @param model A writable signal that contains the model data for the form. The resulting field\n * structure will match the shape of the model and any changes to the form data will be written to\n * the model.\n * @param schemaOrOptions A schema or a function used to specify logic for the form (e.g. validation, disabled fields, etc.).\n * When passing a schema, the form options can be passed as a third argument if needed.\n * @param options The form options (excluding adapter, since it's provided).\n *\n * @category interop\n * @experimental 21.0.0\n */\nexport function compatForm<TModel>(\n model: WritableSignal<TModel>,\n schema: SchemaOrSchemaFn<TModel>,\n options: CompatFormOptions,\n): FieldTree<TModel>;\n\nexport function compatForm<TModel>(...args: any[]): FieldTree<TModel> {\n const [model, maybeSchema, maybeOptions] = normalizeFormArgs<TModel>(args);\n\n const options = {...maybeOptions, adapter: new CompatFieldAdapter()};\n const schema = maybeSchema || ((() => {}) as SchemaOrSchemaFn<TModel, PathKind>);\n return form(model, schema, options) as FieldTree<TModel>;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport type {SignalFormsConfig} from '../../../src/api/di';\n\n/**\n * A value that can be used for `SignalFormsConfig.classes` to automatically add\n * the `ng-*` status classes from reactive forms.\n *\n * @experimental 21.0.1\n */\nexport const NG_STATUS_CLASSES: SignalFormsConfig['classes'] = {\n 'ng-touched': (state) => state.touched(),\n 'ng-untouched': (state) => !state.touched(),\n 'ng-dirty': (state) => state.dirty(),\n 'ng-pristine': (state) => !state.dirty(),\n 'ng-valid': (state) => state.valid(),\n 'ng-invalid': (state) => state.invalid(),\n 'ng-pending': (state) => state.pending(),\n};\n"],"names":["CompatFieldNode","FieldNode","options","control","constructor","makeCreateDestroySubject","destroy$","ReplaySubject","next","complete","extractControlPropToSignal","makeSignal","injector","getInjectorFromOptions","createDestroySubject","signalOfControlSignal","linkedSignal","ngDevMode","debugName","source","computation","untracked","runInInjectionContext","computed","getControlStatusSignal","getValue","c","toSignal","statusChanges","pipe","map","takeUntil","initialValue","getControlEventsSignal","events","CompatNodeState","FieldNodeState","compatNode","touched","dirty","disabled","controlDisabled","disabledReasons","length","markAsDirty","markAsTouched","markAsPristine","markAsUntouched","getParentFromOptions","kind","undefined","parent","getFieldManagerFromOptions","fieldManager","structure","root","getControlValueSignal","value","valueChanges","getRawValue","set","setValue","update","fn","CompatStructure","FieldNodeStructure","keyInParent","pathKeys","children","signal","childrenMap","node","logic","Error","identityInParent","initialKeyInParent","createKeyInParent","getChild","CompatValidationError","field","context","message","reactiveErrorsToSignalErrors","errors","Object","entries","extractNestedReactiveErrors","push","FormGroup","FormArray","values","controls","EMPTY_ARRAY_SIGNAL","TRUE_SIGNAL","CompatValidationState","syncValid","pending","invalid","valid","status","asyncErrors","errorSummary","rawSyncTreeErrors","syncErrors","rawAsyncErrors","shouldSkipValidation","calculateValidationSelfStatus","CompatFieldAdapter","basicAdapter","BasicFieldAdapter","newRoot","pathNode","adapter","AbstractControl","createCompatNode","builder","build","fieldAdapter","createNodeState","createStructure","createValidationState","newChild","compatForm","args","model","maybeSchema","maybeOptions","normalizeFormArgs","schema","form","NG_STATUS_CLASSES","state"],"mappings":";;;;;;;;;;;;;;AAsBM,MAAOA,eAAgB,SAAQC,SAAS,CAAA;EAGhBC,OAAA;EAFnBC,OAAO;EAEhBC,WAAAA,CAA4BF,OAA+B,EAAA;IACzD,KAAK,CAACA,OAAO,CAAC;IADY,IAAO,CAAAA,OAAA,GAAPA,OAAO;AAEjC,IAAA,IAAI,CAACC,OAAO,GAAG,IAAI,CAACD,OAAO,CAACC,OAAO;AACrC;AACD;AAOD,SAASE,wBAAwBA,GAAA;AAC/B,EAAA,IAAIC,QAAQ,GAAG,IAAIC,aAAa,CAAO,CAAC,CAAC;AACzC,EAAA,OAAO,MAAK;AACV,IAAA,IAAID,QAAQ,EAAE;MACZA,QAAQ,CAACE,IAAI,EAAE;MACfF,QAAQ,CAACG,QAAQ,EAAE;AACrB;AACA,IAAA,OAAQH,QAAQ,GAAG,IAAIC,aAAa,CAAO,CAAC,CAAC;GAC9C;AACH;AAcgB,SAAAG,0BAA0BA,CACxCR,OAA+B,EAC/BS,UAAqF,EAAA;AAErF,EAAA,MAAMC,QAAQ,GAAGC,sBAAsB,CAACX,OAAO,CAAC;AAGhD,EAAA,MAAMY,oBAAoB,GAAGT,wBAAwB,EAAE;EAEvD,MAAMU,qBAAqB,GAAGC,YAAY,CAAA;AAAA,IAAA,IAAAC,SAAA,GAAA;AAAAC,MAAAA,SAAA,EAAA;KAAA,GAAA,EAAA,CAAA;IACxCC,MAAM,EAAEjB,OAAO,CAACC,OAAO;IACvBiB,WAAW,EAAGjB,OAAO,IAAI;MACvB,OAAOkB,SAAS,CAAC,MAAK;AACpB,QAAA,OAAOC,qBAAqB,CAACV,QAAQ,EAAE,MAAMD,UAAU,CAACR,OAAO,EAAEW,oBAAoB,EAAE,CAAC,CAAC;AAC3F,OAAC,CAAC;AACJ;IACA;EAIF,OA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compat/src/compat_field_node.ts","../../../../../k8-fastbuild-ST-fdfa778d11ba/bin/packages/forms/signals/compat/src/compat_node_state.ts","../../../../../k8-fastbuild-ST-fdfa778d11ba/bin/packages/forms/signals/compat/src/compat_structure.ts","../../../../../k8-fastbuild-ST-fdfa778d11ba/bin/packages/forms/signals/compat/src/api/compat_validation_error.ts","../../../../../k8-fastbuild-ST-fdfa778d11ba/bin/packages/forms/signals/compat/src/compat_validation_error.ts","../../../../../k8-fastbuild-ST-fdfa778d11ba/bin/packages/forms/signals/compat/src/compat_validation_state.ts","../../../../../k8-fastbuild-ST-fdfa778d11ba/bin/packages/forms/signals/compat/src/compat_field_adapter.ts","../../../../../k8-fastbuild-ST-fdfa778d11ba/bin/packages/forms/signals/compat/src/api/compat_form.ts","../../../../../k8-fastbuild-ST-fdfa778d11ba/bin/packages/forms/signals/compat/src/api/di.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {computed, linkedSignal, runInInjectionContext, Signal, untracked} from '@angular/core';\nimport {toSignal} from '@angular/core/rxjs-interop';\nimport {AbstractControl} from '@angular/forms';\nimport {Observable, ReplaySubject} from 'rxjs';\nimport {map, takeUntil} from 'rxjs/operators';\nimport {FieldNode} from '../../src/field/node';\nimport {getInjectorFromOptions} from '../../src/field/util';\nimport type {CompatFieldNodeOptions} from './compat_structure';\n\n/**\n * Field node with additional control property.\n *\n * Compat node has no children.\n */\nexport class CompatFieldNode extends FieldNode {\n readonly control: Signal<AbstractControl>;\n\n constructor(public readonly options: CompatFieldNodeOptions) {\n super(options);\n this.control = this.options.control;\n }\n}\n\n/**\n * Makes a function which creates a new subject (and unsubscribes/destroys the previous one).\n *\n * This allows us to automatically unsubscribe from status changes of the previous FormControl when we go to subscribe to a new one\n */\nfunction makeCreateDestroySubject() {\n let destroy$ = new ReplaySubject<void>(1);\n return () => {\n if (destroy$) {\n destroy$.next();\n destroy$.complete();\n }\n return (destroy$ = new ReplaySubject<void>(1));\n };\n}\n\n/**\n * Helper function taking options, and a callback which takes options, and a function\n * converting reactive control to appropriate property using toSignal from rxjs compat.\n *\n * This helper keeps all complexity in one place by doing the following things:\n * - Running the callback in injection context\n * - Not tracking the callback, as it creates a new signal.\n * - Reacting to control changes, allowing to swap control dynamically.\n *\n * @param options\n * @param makeSignal\n */\nexport function extractControlPropToSignal<T, R = T>(\n options: CompatFieldNodeOptions,\n makeSignal: (c: AbstractControl<unknown, T>, destroy$: Observable<void>) => Signal<R>,\n): Signal<R> {\n const injector = getInjectorFromOptions(options);\n\n // Creates a subject that could be used in takeUntil.\n const createDestroySubject = makeCreateDestroySubject();\n\n const signalOfControlSignal = linkedSignal({\n source: options.control,\n computation: (control) => {\n return untracked(() => {\n return runInInjectionContext(injector, () => makeSignal(control, createDestroySubject()));\n });\n },\n });\n\n // We have to have computed, because we need to react to both:\n // linked signal changes as well as the inner signal changes.\n return computed(() => signalOfControlSignal()());\n}\n\n/**\n * A helper function, simplifying getting reactive control properties after status changes.\n *\n * Used to extract errors and statuses such as valid, pending.\n *\n * @param options\n * @param getValue\n */\nexport const getControlStatusSignal = <T>(\n options: CompatFieldNodeOptions,\n getValue: (c: AbstractControl<unknown>) => T,\n) => {\n return extractControlPropToSignal<unknown, T>(options, (c, destroy$) =>\n toSignal(\n c.statusChanges.pipe(\n map(() => getValue(c)),\n takeUntil(destroy$),\n ),\n {\n initialValue: getValue(c),\n },\n ),\n );\n};\n\n/**\n * A helper function, simplifying converting convert events to signals.\n *\n * Used to get dirty and touched signals from control.\n *\n * @param options\n * @param getValue A function which takes control and returns required value.\n */\nexport const getControlEventsSignal = <T>(\n options: CompatFieldNodeOptions,\n getValue: (c: AbstractControl) => T,\n) => {\n return extractControlPropToSignal<unknown, T>(options, (c, destroy$) =>\n toSignal(\n c.events.pipe(\n map(() => {\n return getValue(c);\n }),\n takeUntil(destroy$),\n ),\n {\n initialValue: getValue(c),\n },\n ),\n );\n};\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {computed, Signal} from '@angular/core';\nimport {AbstractControl} from '@angular/forms';\nimport {FieldNodeState} from '../../src/field/state';\nimport {CompatFieldNode, getControlEventsSignal, getControlStatusSignal} from './compat_field_node';\nimport {CompatFieldNodeOptions} from './compat_structure';\n\n/**\n * A FieldNodeState class wrapping a FormControl and proxying it's state.\n */\nexport class CompatNodeState extends FieldNodeState {\n override readonly touched: Signal<boolean>;\n override readonly dirty: Signal<boolean>;\n override readonly disabled: Signal<boolean>;\n private readonly control: Signal<AbstractControl>;\n\n constructor(\n readonly compatNode: CompatFieldNode,\n options: CompatFieldNodeOptions,\n ) {\n super(compatNode);\n this.control = options.control;\n this.touched = getControlEventsSignal(options, (c) => c.touched);\n this.dirty = getControlEventsSignal(options, (c) => c.dirty);\n const controlDisabled = getControlStatusSignal(options, (c) => c.disabled);\n\n this.disabled = computed(() => {\n return controlDisabled() || this.disabledReasons().length > 0;\n });\n }\n\n override markAsDirty() {\n this.control().markAsDirty();\n }\n\n override markAsTouched() {\n this.control().markAsTouched();\n }\n\n override markAsPristine() {\n this.control().markAsPristine();\n }\n\n override markAsUntouched() {\n this.control().markAsUntouched();\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {\n computed,\n Signal,\n signal,\n WritableSignal,\n ɵRuntimeError as RuntimeError,\n} from '@angular/core';\nimport {SignalFormsErrorCode} from '../../src/errors';\nimport {FormFieldManager} from '../../src/field/manager';\nimport {FieldNode, ParentFieldNode} from '../../src/field/node';\nimport {\n ChildFieldNodeOptions,\n FieldNodeOptions,\n FieldNodeStructure,\n RootFieldNodeOptions,\n} from '../../src/field/structure';\n\nimport {toSignal} from '@angular/core/rxjs-interop';\nimport {AbstractControl} from '@angular/forms';\nimport {map, takeUntil} from 'rxjs/operators';\nimport {extractControlPropToSignal} from './compat_field_node';\n\n/**\n * Child Field Node options also exposing control property.\n */\nexport interface CompatChildFieldNodeOptions extends ChildFieldNodeOptions {\n control: Signal<AbstractControl>;\n}\n\n/**\n * Root Field Node options also exposing control property.\n */\nexport interface CompatRootFieldNodeOptions extends RootFieldNodeOptions {\n control: Signal<AbstractControl>;\n}\n\n/**\n * Field Node options also exposing control property.\n */\nexport type CompatFieldNodeOptions = CompatRootFieldNodeOptions | CompatChildFieldNodeOptions;\n\n/**\n * A helper function allowing to get parent if it exists.\n */\nfunction getParentFromOptions(options: FieldNodeOptions) {\n if (options.kind === 'root') {\n return undefined;\n }\n\n return options.parent;\n}\n\n/**\n * A helper function allowing to get fieldManager regardless of the option type.\n */\nfunction getFieldManagerFromOptions(options: FieldNodeOptions) {\n if (options.kind === 'root') {\n return options.fieldManager;\n }\n\n return options.parent.structure.root.structure.fieldManager;\n}\n\n/**\n * A helper function that takes CompatFieldNodeOptions, and produce a writable signal synced to the\n * value of contained AbstractControl.\n *\n * This uses toSignal, which requires an injector.\n *\n * @param options\n */\nfunction getControlValueSignal<T>(options: CompatFieldNodeOptions) {\n const value = extractControlPropToSignal<T>(options, (control, destroy$) => {\n return toSignal(\n control.valueChanges.pipe(\n map(() => control.getRawValue()),\n takeUntil(destroy$),\n ),\n {\n initialValue: control.getRawValue(),\n },\n );\n }) as WritableSignal<T>;\n\n value.set = (value: T) => {\n options.control().setValue(value);\n };\n\n value.update = (fn: (current: T) => T) => {\n value.set(fn(value()));\n };\n\n return value;\n}\n\n/**\n * Compat version of FieldNodeStructure,\n * - It has no children\n * - It wraps FormControl and proxies its value.\n */\nexport class CompatStructure extends FieldNodeStructure {\n override value: WritableSignal<unknown>;\n override keyInParent: Signal<string>;\n override root: FieldNode;\n override pathKeys: Signal<readonly string[]>;\n override readonly children = signal([]);\n override readonly childrenMap = computed(() => undefined);\n override readonly parent: ParentFieldNode | undefined;\n override readonly fieldManager: FormFieldManager;\n\n constructor(node: FieldNode, options: CompatFieldNodeOptions) {\n super(options.logic, node, () => {\n throw new RuntimeError(\n SignalFormsErrorCode.COMPAT_NO_CHILDREN,\n ngDevMode && `Compat nodes don't have children.`,\n );\n });\n this.value = getControlValueSignal(options);\n this.parent = getParentFromOptions(options);\n this.root = this.parent?.structure.root ?? node;\n this.fieldManager = getFieldManagerFromOptions(options);\n\n const identityInParent = options.kind === 'child' ? options.identityInParent : undefined;\n const initialKeyInParent = options.kind === 'child' ? options.initialKeyInParent : undefined;\n this.keyInParent = this.createKeyInParent(options, identityInParent, initialKeyInParent);\n\n this.pathKeys = computed(() =>\n this.parent ? [...this.parent.structure.pathKeys(), this.keyInParent()] : [],\n );\n }\n\n override getChild(): FieldNode | undefined {\n return undefined;\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {AbstractControl} from '@angular/forms';\nimport {ValidationError} from '../../../src/api/rules/validation/validation_errors';\nimport {FieldTree} from '../../../src/api/types';\n\n/**\n * An error used for compat errors.\n *\n * @experimental 21.0.0\n * @category interop\n */\nexport class CompatValidationError<T = unknown> implements ValidationError {\n readonly kind: string = 'compat';\n readonly control: AbstractControl;\n readonly fieldTree!: FieldTree<unknown>;\n readonly context: T;\n readonly message?: string;\n\n constructor({context, kind, control}: {context: T; kind: string; control: AbstractControl}) {\n this.context = context;\n this.kind = kind;\n this.control = control;\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {AbstractControl, FormArray, FormGroup, ValidationErrors} from '@angular/forms';\nimport {CompatValidationError} from './api/compat_validation_error';\n\n/**\n * Converts reactive form validation error to signal forms CompatValidationError.\n * @param errors\n * @param control\n * @return list of errors.\n */\nexport function reactiveErrorsToSignalErrors(\n errors: ValidationErrors | null,\n control: AbstractControl,\n): CompatValidationError[] {\n if (errors === null) {\n return [];\n }\n\n return Object.entries(errors).map(([kind, context]) => {\n return new CompatValidationError({context, kind, control});\n });\n}\n\nexport function extractNestedReactiveErrors(control: AbstractControl): CompatValidationError[] {\n const errors: CompatValidationError[] = [];\n\n if (control.errors) {\n errors.push(...reactiveErrorsToSignalErrors(control.errors, control));\n }\n\n if (control instanceof FormGroup || control instanceof FormArray) {\n for (const c of Object.values(control.controls)) {\n errors.push(...extractNestedReactiveErrors(c));\n }\n }\n\n return errors;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {computed, Signal} from '@angular/core';\nimport {AbstractControl} from '@angular/forms';\nimport {ValidationError} from '../../src/api/rules/validation/validation_errors';\nimport {calculateValidationSelfStatus, ValidationState} from '../../src/field/validation';\nimport type {CompatValidationError} from './api/compat_validation_error';\nimport {getControlStatusSignal} from './compat_field_node';\nimport {CompatFieldNodeOptions} from './compat_structure';\nimport {extractNestedReactiveErrors} from './compat_validation_error';\n\n// Readonly signal containing an empty array, used for optimization.\nconst EMPTY_ARRAY_SIGNAL = computed(() => []);\nconst TRUE_SIGNAL = computed(() => true);\n\n/**\n * Compat version of a validation state that wraps a FormControl, and proxies it's validation state.\n */\nexport class CompatValidationState implements ValidationState {\n readonly syncValid: Signal<boolean>;\n /**\n * All validation errors for this field.\n */\n readonly errors: Signal<CompatValidationError[]>;\n readonly pending: Signal<boolean>;\n readonly invalid: Signal<boolean>;\n readonly valid: Signal<boolean>;\n\n constructor(options: CompatFieldNodeOptions) {\n this.syncValid = getControlStatusSignal(options, (c: AbstractControl) => c.status === 'VALID');\n this.errors = getControlStatusSignal(options, extractNestedReactiveErrors);\n this.pending = getControlStatusSignal(options, (c) => c.pending);\n\n this.valid = getControlStatusSignal(options, (c) => {\n return c.valid;\n });\n\n this.invalid = getControlStatusSignal(options, (c) => {\n return c.invalid;\n });\n }\n\n asyncErrors: Signal<(ValidationError.WithField | 'pending')[]> = EMPTY_ARRAY_SIGNAL;\n errorSummary: Signal<ValidationError.WithField[]> = EMPTY_ARRAY_SIGNAL;\n\n // Those are irrelevant for compat mode, as it has no children\n rawSyncTreeErrors = EMPTY_ARRAY_SIGNAL;\n syncErrors = EMPTY_ARRAY_SIGNAL;\n rawAsyncErrors = EMPTY_ARRAY_SIGNAL;\n shouldSkipValidation = TRUE_SIGNAL;\n\n /**\n * Computes status based on whether the field is valid/invalid/pending.\n */\n readonly status: Signal<'valid' | 'invalid' | 'unknown'> = computed(() => {\n return calculateValidationSelfStatus(this);\n });\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {computed, Signal, WritableSignal} from '@angular/core';\nimport {AbstractControl} from '@angular/forms';\nimport {BasicFieldAdapter, FieldAdapter} from '../../src/field/field_adapter';\nimport {FormFieldManager} from '../../src/field/manager';\nimport {FieldNode} from '../../src/field/node';\nimport {FieldNodeState} from '../../src/field/state';\nimport {\n ChildFieldNodeOptions,\n FieldNodeOptions,\n FieldNodeStructure,\n} from '../../src/field/structure';\nimport {ValidationState} from '../../src/field/validation';\nimport {FieldPathNode} from '../../src/schema/path_node';\nimport {CompatFieldNode} from './compat_field_node';\nimport {CompatNodeState} from './compat_node_state';\nimport {CompatChildFieldNodeOptions, CompatStructure} from './compat_structure';\nimport {CompatValidationState} from './compat_validation_state';\n\n/**\n * This is a tree-shakable Field adapter that can create a compat node\n * that proxies FormControl state and value to a field.\n */\nexport class CompatFieldAdapter implements FieldAdapter {\n readonly basicAdapter = new BasicFieldAdapter();\n\n /**\n * Creates a regular or compat root node state based on whether the control is present.\n * @param fieldManager\n * @param value\n * @param pathNode\n * @param adapter\n */\n newRoot<TModel>(\n fieldManager: FormFieldManager,\n value: WritableSignal<TModel>,\n pathNode: FieldPathNode,\n adapter: FieldAdapter,\n ): FieldNode {\n if (value() instanceof AbstractControl) {\n return createCompatNode({\n kind: 'root',\n fieldManager,\n value,\n pathNode,\n logic: pathNode.builder.build(),\n fieldAdapter: adapter,\n });\n }\n\n return this.basicAdapter.newRoot<TModel>(fieldManager, value, pathNode, adapter);\n }\n\n /**\n * Creates a regular or compat node state based on whether the control is present.\n * @param node\n * @param options\n */\n createNodeState(node: CompatFieldNode, options: CompatChildFieldNodeOptions): FieldNodeState {\n if (!options.control) {\n return this.basicAdapter.createNodeState(node);\n }\n return new CompatNodeState(node, options);\n }\n\n /**\n * Creates a regular or compat structure based on whether the control is present.\n * @param node\n * @param options\n */\n createStructure(node: CompatFieldNode, options: CompatChildFieldNodeOptions): FieldNodeStructure {\n if (!options.control) {\n return this.basicAdapter.createStructure(node, options);\n }\n return new CompatStructure(node, options);\n }\n\n /**\n * Creates a regular or compat validation state based on whether the control is present.\n * @param node\n * @param options\n */\n createValidationState(\n node: CompatFieldNode,\n options: CompatChildFieldNodeOptions,\n ): ValidationState {\n if (!options.control) {\n return this.basicAdapter.createValidationState(node);\n }\n return new CompatValidationState(options);\n }\n\n /**\n * Creates a regular or compat node based on whether the control is present.\n * @param options\n */\n newChild(options: ChildFieldNodeOptions): FieldNode {\n const value = options.parent.value()[options.initialKeyInParent];\n\n if (value instanceof AbstractControl) {\n return createCompatNode(options);\n }\n\n return new FieldNode(options);\n }\n}\n\n/**\n * Creates a CompatFieldNode from options.\n * @param options\n */\nexport function createCompatNode(options: FieldNodeOptions) {\n const control = (\n options.kind === 'root'\n ? options.value\n : computed(() => {\n return options.parent.value()[options.initialKeyInParent];\n })\n ) as Signal<AbstractControl>;\n\n return new CompatFieldNode({\n ...options,\n control,\n });\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {WritableSignal} from '@angular/core';\nimport {form, FormOptions} from '../../../public_api';\nimport {FieldTree, PathKind, SchemaOrSchemaFn} from '../../../src/api/types';\nimport {normalizeFormArgs} from '../../../src/util/normalize_form_args';\nimport {CompatFieldAdapter} from '../compat_field_adapter';\n\n/**\n * Options that may be specified when creating a compat form.\n *\n * @category interop\n * @experimental 21.0.0\n */\nexport type CompatFormOptions = Omit<FormOptions, 'adapter'>;\n\n/**\n * Creates a compatibility form wrapped around the given model data.\n *\n * `compatForm` is a version of the `form` function that is designed for backwards\n * compatibility with Reactive forms by accepting Reactive controls as a part of the data.\n *\n * @example\n * ```ts\n * const lastName = new FormControl('lastName');\n *\n * const nameModel = signal({\n * first: '',\n * last: lastName\n * });\n *\n * const nameForm = compatForm(nameModel, (name) => {\n * required(name.first);\n * });\n *\n * nameForm.last().value(); // lastName, not FormControl\n * ```\n * \n * @param model A writable signal that contains the model data for the form. The resulting field\n * structure will match the shape of the model and any changes to the form data will be written to\n * the model.\n\n * @category interop\n * @experimental 21.0.0\n */\nexport function compatForm<TModel>(model: WritableSignal<TModel>): FieldTree<TModel>;\n\n/**\n * Creates a compatibility form wrapped around the given model data.\n *\n * `compatForm` is a version of the `form` function that is designed for backwards\n * compatibility with Reactive forms by accepting Reactive controls as a part of the data.\n *\n * @example\n * ```ts\n * const lastName = new FormControl('lastName');\n *\n * const nameModel = signal({\n * first: '',\n * last: lastName\n * });\n *\n * const nameForm = compatForm(nameModel, (name) => {\n * required(name.first);\n * });\n *\n * nameForm.last().value(); // lastName, not FormControl\n *\n * @param model A writable signal that contains the model data for the form. The resulting field\n * structure will match the shape of the model and any changes to the form data will be written to\n * the model.\n * @param schemaOrOptions The second argument can be either\n * 1. A schema or a function used to specify logic for the form (e.g. validation, disabled fields, etc.).\n * When passing a schema, the form options can be passed as a third argument if needed.\n * 2. The form options (excluding adapter, since it's provided).\n *\n * @category interop\n * @experimental 21.0.0\n */\nexport function compatForm<TModel>(\n model: WritableSignal<TModel>,\n schemaOrOptions: SchemaOrSchemaFn<TModel> | CompatFormOptions,\n): FieldTree<TModel>;\n\n/**\n * Creates a compatibility form wrapped around the given model data.\n *\n * `compatForm` is a version of the `form` function that is designed for backwards\n * compatibility with Reactive forms by accepting Reactive controls as a part of the data.\n *\n * @example\n * ```ts\n * const lastName = new FormControl('lastName');\n *\n * const nameModel = signal({\n * first: '',\n * last: lastName\n * });\n *\n * const nameForm = compatForm(nameModel, (name) => {\n * required(name.first);\n * });\n *\n * nameForm.last().value(); // lastName, not FormControl\n *\n * @param model A writable signal that contains the model data for the form. The resulting field\n * structure will match the shape of the model and any changes to the form data will be written to\n * the model.\n * @param schemaOrOptions A schema or a function used to specify logic for the form (e.g. validation, disabled fields, etc.).\n * When passing a schema, the form options can be passed as a third argument if needed.\n * @param options The form options (excluding adapter, since it's provided).\n *\n * @category interop\n * @experimental 21.0.0\n */\nexport function compatForm<TModel>(\n model: WritableSignal<TModel>,\n schema: SchemaOrSchemaFn<TModel>,\n options: CompatFormOptions,\n): FieldTree<TModel>;\n\nexport function compatForm<TModel>(...args: any[]): FieldTree<TModel> {\n const [model, maybeSchema, maybeOptions] = normalizeFormArgs<TModel>(args);\n\n const options = {...maybeOptions, adapter: new CompatFieldAdapter()};\n const schema = maybeSchema || ((() => {}) as SchemaOrSchemaFn<TModel, PathKind>);\n return form(model, schema, options) as FieldTree<TModel>;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport type {SignalFormsConfig} from '../../../src/api/di';\n\n/**\n * A value that can be used for `SignalFormsConfig.classes` to automatically add\n * the `ng-*` status classes from reactive forms.\n *\n * @experimental 21.0.1\n */\nexport const NG_STATUS_CLASSES: SignalFormsConfig['classes'] = {\n 'ng-touched': ({state}) => state().touched(),\n 'ng-untouched': ({state}) => !state().touched(),\n 'ng-dirty': ({state}) => state().dirty(),\n 'ng-pristine': ({state}) => !state().dirty(),\n 'ng-valid': ({state}) => state().valid(),\n 'ng-invalid': ({state}) => state().invalid(),\n 'ng-pending': ({state}) => state().pending(),\n};\n"],"names":["CompatFieldNode","FieldNode","options","control","constructor","makeCreateDestroySubject","destroy$","ReplaySubject","next","complete","extractControlPropToSignal","makeSignal","injector","getInjectorFromOptions","createDestroySubject","signalOfControlSignal","linkedSignal","ngDevMode","debugName","source","computation","untracked","runInInjectionContext","computed","getControlStatusSignal","getValue","c","toSignal","statusChanges","pipe","map","takeUntil","initialValue","getControlEventsSignal","events","CompatNodeState","FieldNodeState","compatNode","touched","dirty","disabled","controlDisabled","disabledReasons","length","markAsDirty","markAsTouched","markAsPristine","markAsUntouched","getParentFromOptions","kind","undefined","parent","getFieldManagerFromOptions","fieldManager","structure","root","getControlValueSignal","value","valueChanges","getRawValue","set","setValue","update","fn","CompatStructure","FieldNodeStructure","keyInParent","pathKeys","children","signal","childrenMap","node","logic","RuntimeError","identityInParent","initialKeyInParent","createKeyInParent","getChild","CompatValidationError","fieldTree","context","message","reactiveErrorsToSignalErrors","errors","Object","entries","extractNestedReactiveErrors","push","FormGroup","FormArray","values","controls","EMPTY_ARRAY_SIGNAL","TRUE_SIGNAL","CompatValidationState","syncValid","pending","invalid","valid","status","asyncErrors","errorSummary","rawSyncTreeErrors","syncErrors","rawAsyncErrors","shouldSkipValidation","calculateValidationSelfStatus","CompatFieldAdapter","basicAdapter","BasicFieldAdapter","newRoot","pathNode","adapter","AbstractControl","createCompatNode","builder","build","fieldAdapter","createNodeState","createStructure","createValidationState","newChild","compatForm","args","model","maybeSchema","maybeOptions","normalizeFormArgs","schema","form","NG_STATUS_CLASSES","ng-touched","state","ng-untouched","ng-dirty","ng-pristine","ng-valid","ng-invalid","ng-pending"],"mappings":";;;;;;;;;;;;;;AAsBM,MAAOA,eAAgB,SAAQC,SAAS,CAAA;EAGhBC,OAAA;EAFnBC,OAAO;EAEhBC,WAAAA,CAA4BF,OAA+B,EAAA;IACzD,KAAK,CAACA,OAAO,CAAC;IADY,IAAO,CAAAA,OAAA,GAAPA,OAAO;AAEjC,IAAA,IA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C/C,MAAM,CAACC,KAAK,EAAEC,WAAW,EAAEC,YAAY,CAAC,GAAGC,iBAAiB,CAASJ,IAAI,CAAC;AAE1E,EAAA,MAAMzH,OAAO,GAAG;AAAC,IAAA,GAAG4H,YAAY;IAAEd,OAAO,EAAE,IAAIL,kBAAkB;GAAG;AACpE,EAAA,MAAMqB,MAAM,GAAGH,WAAW,KAAM,MAAK,EAAG,CAAwC;AAChF,EAAA,OAAOI,IAAI,CAACL,KAAK,EAAEI,MAAM,EAAE9H,OAAO,CAAsB;AAC1D;;ACrHO,MAAMgI,iBAAiB,GAAiC;AAC7D,EAAA,YAAY,EAAEC,CAAC;AAACC,IAAAA;AAAM,GAAA,KAAKA,KAAK,EAAE,CAAC9F,OAAO,EAAE;AAC5C,EAAA,cAAc,EAAE+F,CAAC;AAACD,IAAAA;GAAM,KAAK,CAACA,KAAK,EAAE,CAAC9F,OAAO,EAAE;AAC/C,EAAA,UAAU,EAAEgG,CAAC;AAACF,IAAAA;AAAM,GAAA,KAAKA,KAAK,EAAE,CAAC7F,KAAK,EAAE;AACxC,EAAA,aAAa,EAAEgG,CAAC;AAACH,IAAAA;GAAM,KAAK,CAACA,KAAK,EAAE,CAAC7F,KAAK,EAAE;AAC5C,EAAA,UAAU,EAAEiG,CAAC;AAACJ,IAAAA;AAAM,GAAA,KAAKA,KAAK,EAAE,CAAClC,KAAK,EAAE;AACxC,EAAA,YAAY,EAAEuC,CAAC;AAACL,IAAAA;AAAM,GAAA,KAAKA,KAAK,EAAE,CAACnC,OAAO,EAAE;AAC5C,EAAA,YAAY,EAAEyC,CAAC;AAACN,IAAAA;AAAM,GAAA,KAAKA,KAAK,EAAE,CAACpC,OAAO;;;;;"}
@@ -1,13 +1,13 @@
1
1
  /**
2
- * @license Angular v21.1.0-next.3
3
- * (c) 2010-2025 Google LLC. https://angular.dev/
2
+ * @license Angular v21.1.0-rc.0
3
+ * (c) 2010-2026 Google LLC. https://angular.dev/
4
4
  * License: MIT
5
5
  */
6
6
 
7
7
  import * as i0 from '@angular/core';
8
- import { InjectionToken, inject, ElementRef, Injector, input, computed, ɵCONTROL as _CONTROL, effect, Directive, ɵɵcontrolCreate as __controlCreate, ɵcontrolUpdate as _controlUpdate, ɵisPromise as _isPromise, resource } from '@angular/core';
8
+ import { InjectionToken, ɵRuntimeError as _RuntimeError, inject, ElementRef, Injector, input, computed, ɵCONTROL as _CONTROL, effect, Directive, ɵɵcontrolCreate as __controlCreate, ɵcontrolUpdate as _controlUpdate, ɵisPromise as _isPromise, resource } from '@angular/core';
9
9
  import { Validators, NG_VALUE_ACCESSOR, NgControl } from '@angular/forms';
10
- import { assertPathIsCurrent, FieldPathNode, isArray, addDefaultField, metadata, createMetadataKey, MAX, MAX_LENGTH, MIN, MIN_LENGTH, PATTERN, REQUIRED, createManagedMetadataKey, DEBOUNCER } from './_structure-chunk.mjs';
10
+ import { assertPathIsCurrent, FieldPathNode, addDefaultField, metadata, createMetadataKey, MAX, MAX_LENGTH, MIN, MIN_LENGTH, PATTERN, REQUIRED, createManagedMetadataKey, DEBOUNCER } from './_structure-chunk.mjs';
11
11
  export { MetadataKey, MetadataReducer, apply, applyEach, applyWhen, applyWhenValue, form, schema, submit } from './_structure-chunk.mjs';
12
12
  import { httpResource } from '@angular/common/http';
13
13
  import '@angular/core/primitives/signals';
@@ -81,7 +81,7 @@ class InteropNgControl {
81
81
  if (this.field().pending()) {
82
82
  return 'PENDING';
83
83
  }
84
- throw Error('AssertionError: unknown form control status');
84
+ throw new _RuntimeError(1910, ngDevMode && 'Unknown form control status');
85
85
  }
86
86
  valueAccessor = null;
87
87
  hasValidator(validator) {
@@ -94,7 +94,7 @@ class InteropNgControl {
94
94
  }
95
95
 
96
96
  const FIELD = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'FIELD' : '');
97
- const controlInstructions = {
97
+ const controlInstructions$1 = {
98
98
  create: __controlCreate,
99
99
  update: _controlUpdate
100
100
  };
@@ -107,11 +107,11 @@ class Field {
107
107
  state = computed(() => this.field()(), ...(ngDevMode ? [{
108
108
  debugName: "state"
109
109
  }] : []));
110
- [_CONTROL] = controlInstructions;
110
+ [_CONTROL] = controlInstructions$1;
111
111
  config = inject(SIGNAL_FORMS_CONFIG, {
112
112
  optional: true
113
113
  });
114
- classes = Object.entries(this.config?.classes ?? {}).map(([className, computation]) => [className, computed(() => computation(this.state()))]);
114
+ classes = Object.entries(this.config?.classes ?? {}).map(([className, computation]) => [className, computed(() => computation(this))]);
115
115
  controlValueAccessors = inject(NG_VALUE_ACCESSOR, {
116
116
  optional: true,
117
117
  self: true
@@ -126,9 +126,9 @@ class Field {
126
126
  ɵregister() {
127
127
  effect(onCleanup => {
128
128
  const fieldNode = this.state();
129
- fieldNode.nodeState.fieldBindings.update(controls => [...controls, this]);
129
+ fieldNode.nodeState.formFieldBindings.update(controls => [...controls, this]);
130
130
  onCleanup(() => {
131
- fieldNode.nodeState.fieldBindings.update(controls => controls.filter(c => c !== this));
131
+ fieldNode.nodeState.formFieldBindings.update(controls => controls.filter(c => c !== this));
132
132
  });
133
133
  }, {
134
134
  injector: this.injector
@@ -136,7 +136,7 @@ class Field {
136
136
  }
137
137
  static ɵfac = i0.ɵɵngDeclareFactory({
138
138
  minVersion: "12.0.0",
139
- version: "21.1.0-next.3",
139
+ version: "21.1.0-rc.0",
140
140
  ngImport: i0,
141
141
  type: Field,
142
142
  deps: [],
@@ -144,7 +144,7 @@ class Field {
144
144
  });
145
145
  static ɵdir = i0.ɵɵngDeclareDirective({
146
146
  minVersion: "17.1.0",
147
- version: "21.1.0-next.3",
147
+ version: "21.1.0-rc.0",
148
148
  type: Field,
149
149
  isStandalone: true,
150
150
  selector: "[field]",
@@ -169,7 +169,7 @@ class Field {
169
169
  }
170
170
  i0.ɵɵngDeclareClassMetadata({
171
171
  minVersion: "12.0.0",
172
- version: "21.1.0-next.3",
172
+ version: "21.1.0-rc.0",
173
173
  ngImport: i0,
174
174
  type: Field,
175
175
  decorators: [{
@@ -197,6 +197,110 @@ i0.ɵɵngDeclareClassMetadata({
197
197
  }
198
198
  });
199
199
 
200
+ const FORM_FIELD = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'FORM_FIELD' : '');
201
+ const controlInstructions = {
202
+ create: __controlCreate,
203
+ update: _controlUpdate
204
+ };
205
+ class FormField {
206
+ element = inject(ElementRef).nativeElement;
207
+ injector = inject(Injector);
208
+ formField = input.required(...(ngDevMode ? [{
209
+ debugName: "formField"
210
+ }] : []));
211
+ state = computed(() => this.formField()(), ...(ngDevMode ? [{
212
+ debugName: "state"
213
+ }] : []));
214
+ [_CONTROL] = controlInstructions;
215
+ config = inject(SIGNAL_FORMS_CONFIG, {
216
+ optional: true
217
+ });
218
+ classes = Object.entries(this.config?.classes ?? {}).map(([className, computation]) => [className, computed(() => computation(this))]);
219
+ controlValueAccessors = inject(NG_VALUE_ACCESSOR, {
220
+ optional: true,
221
+ self: true
222
+ });
223
+ interopNgControl;
224
+ get ɵinteropControl() {
225
+ return this.controlValueAccessors?.[0] ?? this.interopNgControl?.valueAccessor ?? undefined;
226
+ }
227
+ getOrCreateNgControl() {
228
+ return this.interopNgControl ??= new InteropNgControl(this.state);
229
+ }
230
+ ɵregister() {
231
+ effect(onCleanup => {
232
+ const fieldNode = this.state();
233
+ fieldNode.nodeState.formFieldBindings.update(controls => [...controls, this]);
234
+ onCleanup(() => {
235
+ fieldNode.nodeState.formFieldBindings.update(controls => controls.filter(c => c !== this));
236
+ });
237
+ }, {
238
+ injector: this.injector
239
+ });
240
+ }
241
+ static ɵfac = i0.ɵɵngDeclareFactory({
242
+ minVersion: "12.0.0",
243
+ version: "21.1.0-rc.0",
244
+ ngImport: i0,
245
+ type: FormField,
246
+ deps: [],
247
+ target: i0.ɵɵFactoryTarget.Directive
248
+ });
249
+ static ɵdir = i0.ɵɵngDeclareDirective({
250
+ minVersion: "17.1.0",
251
+ version: "21.1.0-rc.0",
252
+ type: FormField,
253
+ isStandalone: true,
254
+ selector: "[formField]",
255
+ inputs: {
256
+ formField: {
257
+ classPropertyName: "formField",
258
+ publicName: "formField",
259
+ isSignal: true,
260
+ isRequired: true,
261
+ transformFunction: null
262
+ }
263
+ },
264
+ providers: [{
265
+ provide: FORM_FIELD,
266
+ useExisting: FormField
267
+ }, {
268
+ provide: NgControl,
269
+ useFactory: () => inject(FormField).getOrCreateNgControl()
270
+ }],
271
+ ngImport: i0
272
+ });
273
+ }
274
+ i0.ɵɵngDeclareClassMetadata({
275
+ minVersion: "12.0.0",
276
+ version: "21.1.0-rc.0",
277
+ ngImport: i0,
278
+ type: FormField,
279
+ decorators: [{
280
+ type: Directive,
281
+ args: [{
282
+ selector: '[formField]',
283
+ providers: [{
284
+ provide: FORM_FIELD,
285
+ useExisting: FormField
286
+ }, {
287
+ provide: NgControl,
288
+ useFactory: () => inject(FormField).getOrCreateNgControl()
289
+ }]
290
+ }]
291
+ }],
292
+ propDecorators: {
293
+ formField: [{
294
+ type: i0.Input,
295
+ args: [{
296
+ isSignal: true,
297
+ alias: "formField",
298
+ required: true
299
+ }]
300
+ }]
301
+ }
302
+ });
303
+
200
304
  function disabled(path, logic) {
201
305
  assertPathIsCurrent(path);
202
306
  const pathNode = FieldPathNode.unwrapFieldPath(path);
@@ -209,12 +313,12 @@ function disabled(path, logic) {
209
313
  }
210
314
  if (typeof result === 'string') {
211
315
  return {
212
- field: ctx.field,
316
+ fieldTree: ctx.fieldTree,
213
317
  message: result
214
318
  };
215
319
  }
216
320
  return result ? {
217
- field: ctx.field
321
+ fieldTree: ctx.fieldTree
218
322
  } : undefined;
219
323
  });
220
324
  }
@@ -231,6 +335,28 @@ function readonly(path, logic = () => true) {
231
335
  pathNode.builder.addReadonlyRule(logic);
232
336
  }
233
337
 
338
+ function getLengthOrSize(value) {
339
+ const v = value;
340
+ return typeof v.length === 'number' ? v.length : v.size;
341
+ }
342
+ function getOption(opt, ctx) {
343
+ return opt instanceof Function ? opt(ctx) : opt;
344
+ }
345
+ function isEmpty(value) {
346
+ if (typeof value === 'number') {
347
+ return isNaN(value);
348
+ }
349
+ return value === '' || value === false || value == null;
350
+ }
351
+
352
+ function validate(path, logic) {
353
+ assertPathIsCurrent(path);
354
+ const pathNode = FieldPathNode.unwrapFieldPath(path);
355
+ pathNode.builder.addSyncErrorRule(ctx => {
356
+ return addDefaultField(logic(ctx), ctx.fieldTree);
357
+ });
358
+ }
359
+
234
360
  function requiredError(options) {
235
361
  return new RequiredValidationError(options);
236
362
  }
@@ -255,24 +381,10 @@ function emailError(options) {
255
381
  function standardSchemaError(issue, options) {
256
382
  return new StandardSchemaValidationError(issue, options);
257
383
  }
258
- function customError(obj) {
259
- return new CustomValidationError(obj);
260
- }
261
- class CustomValidationError {
262
- __brand = undefined;
263
- kind = '';
264
- field;
265
- message;
266
- constructor(options) {
267
- if (options) {
268
- Object.assign(this, options);
269
- }
270
- }
271
- }
272
384
  class _NgValidationError {
273
385
  __brand = undefined;
274
386
  kind = '';
275
- field;
387
+ fieldTree;
276
388
  message;
277
389
  constructor(options) {
278
390
  if (options) {
@@ -336,46 +448,6 @@ class StandardSchemaValidationError extends _NgValidationError {
336
448
  }
337
449
  const NgValidationError = _NgValidationError;
338
450
 
339
- function getLengthOrSize(value) {
340
- const v = value;
341
- return typeof v.length === 'number' ? v.length : v.size;
342
- }
343
- function getOption(opt, ctx) {
344
- return opt instanceof Function ? opt(ctx) : opt;
345
- }
346
- function isEmpty(value) {
347
- if (typeof value === 'number') {
348
- return isNaN(value);
349
- }
350
- return value === '' || value === false || value == null;
351
- }
352
- function isPlainError(error) {
353
- return typeof error === 'object' && (Object.getPrototypeOf(error) === Object.prototype || Object.getPrototypeOf(error) === null);
354
- }
355
- function ensureCustomValidationError(error) {
356
- if (isPlainError(error)) {
357
- return customError(error);
358
- }
359
- return error;
360
- }
361
- function ensureCustomValidationResult(result) {
362
- if (result === null || result === undefined) {
363
- return result;
364
- }
365
- if (isArray(result)) {
366
- return result.map(ensureCustomValidationError);
367
- }
368
- return ensureCustomValidationError(result);
369
- }
370
-
371
- function validate(path, logic) {
372
- assertPathIsCurrent(path);
373
- const pathNode = FieldPathNode.unwrapFieldPath(path);
374
- pathNode.builder.addSyncErrorRule(ctx => {
375
- return ensureCustomValidationResult(addDefaultField(logic(ctx), ctx.field));
376
- });
377
- }
378
-
379
451
  const EMAIL_REGEXP = /^(?=.{1,254}$)(?=.{1,64}@)[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
380
452
  function email(path, config) {
381
453
  validate(path, ctx => {
@@ -575,10 +647,10 @@ function validateAsync(path, opts) {
575
647
  return undefined;
576
648
  }
577
649
  errors = opts.onSuccess(res.value(), ctx);
578
- return addDefaultField(errors, ctx.field);
650
+ return addDefaultField(errors, ctx.fieldTree);
579
651
  case 'error':
580
652
  errors = opts.onError(res.error(), ctx);
581
- return addDefaultField(errors, ctx.field);
653
+ return addDefaultField(errors, ctx.fieldTree);
582
654
  }
583
655
  });
584
656
  }
@@ -586,7 +658,7 @@ function validateAsync(path, opts) {
586
658
  function validateTree(path, logic) {
587
659
  assertPathIsCurrent(path);
588
660
  const pathNode = FieldPathNode.unwrapFieldPath(path);
589
- pathNode.builder.addSyncTreeErrorRule(ctx => addDefaultField(logic(ctx), ctx.field));
661
+ pathNode.builder.addSyncTreeErrorRule(ctx => addDefaultField(logic(ctx), ctx.fieldTree));
590
662
  }
591
663
 
592
664
  function validateStandardSchema(path, schema) {
@@ -628,8 +700,8 @@ function validateStandardSchema(path, schema) {
628
700
  onError: () => {}
629
701
  });
630
702
  }
631
- function standardIssueToFormTreeError(field, issue) {
632
- let target = field;
703
+ function standardIssueToFormTreeError(fieldTree, issue) {
704
+ let target = fieldTree;
633
705
  for (const pathPart of issue.path ?? []) {
634
706
  const pathKey = typeof pathPart === 'object' ? pathPart.key : pathPart;
635
707
  target = target[pathKey];
@@ -657,12 +729,21 @@ function debounce(path, durationOrDebouncer) {
657
729
  function debounceForDuration(durationInMilliseconds) {
658
730
  return (_context, abortSignal) => {
659
731
  return new Promise(resolve => {
660
- const timeoutId = setTimeout(resolve, durationInMilliseconds);
661
- abortSignal.addEventListener('abort', () => clearTimeout(timeoutId));
732
+ let timeoutId;
733
+ const onAbort = () => {
734
+ clearTimeout(timeoutId);
735
+ };
736
+ timeoutId = setTimeout(() => {
737
+ abortSignal.removeEventListener('abort', onAbort);
738
+ resolve();
739
+ }, durationInMilliseconds);
740
+ abortSignal.addEventListener('abort', onAbort, {
741
+ once: true
742
+ });
662
743
  });
663
744
  };
664
745
  }
665
746
  function immediate() {}
666
747
 
667
- export { CustomValidationError, EmailValidationError, FIELD, Field, MAX, MAX_LENGTH, MIN, MIN_LENGTH, MaxLengthValidationError, MaxValidationError, MinLengthValidationError, MinValidationError, NgValidationError, PATTERN, PatternValidationError, REQUIRED, RequiredValidationError, StandardSchemaValidationError, createManagedMetadataKey, createMetadataKey, customError, debounce, disabled, email, emailError, hidden, max, maxError, maxLength, maxLengthError, metadata, min, minError, minLength, minLengthError, pattern, patternError, provideSignalFormsConfig, readonly, required, requiredError, standardSchemaError, validate, validateAsync, validateHttp, validateStandardSchema, validateTree };
748
+ export { EmailValidationError, FIELD, FORM_FIELD, Field, FormField, MAX, MAX_LENGTH, MIN, MIN_LENGTH, MaxLengthValidationError, MaxValidationError, MinLengthValidationError, MinValidationError, NgValidationError, PATTERN, PatternValidationError, REQUIRED, RequiredValidationError, StandardSchemaValidationError, createManagedMetadataKey, createMetadataKey, debounce, disabled, email, emailError, hidden, max, maxError, maxLength, maxLengthError, metadata, min, minError, minLength, minLengthError, pattern, patternError, provideSignalFormsConfig, readonly, required, requiredError, standardSchemaError, validate, validateAsync, validateHttp, validateStandardSchema, validateTree };
668
749
  //# sourceMappingURL=signals.mjs.map