@angular/forms 21.1.0-next.3 → 21.1.0-next.4

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,10 +1,10 @@
1
1
  /**
2
- * @license Angular v21.1.0-next.3
2
+ * @license Angular v21.1.0-next.4
3
3
  * (c) 2010-2025 Google LLC. https://angular.dev/
4
4
  * License: MIT
5
5
  */
6
6
 
7
- import { untracked, computed, runInInjectionContext, Injector, linkedSignal, signal, APP_ID, effect, inject } from '@angular/core';
7
+ import { untracked, ɵRuntimeError as _RuntimeError, computed, runInInjectionContext, Injector, linkedSignal, signal, APP_ID, effect, inject } from '@angular/core';
8
8
  import { AbstractControl } from '@angular/forms';
9
9
  import { SIGNAL } from '@angular/core/primitives/signals';
10
10
 
@@ -384,7 +384,7 @@ function getAllChildBuilders(builder, key) {
384
384
  predicates: []
385
385
  }] : [])];
386
386
  } else {
387
- throw new Error('Unknown LogicNodeBuilder type');
387
+ throw new _RuntimeError(1909, ngDevMode && 'Unknown LogicNodeBuilder type');
388
388
  }
389
389
  }
390
390
  function createLogic(builder, predicates, depth) {
@@ -400,7 +400,7 @@ function createLogic(builder, predicates, depth) {
400
400
  } else if (builder instanceof NonMergeableLogicNodeBuilder) {
401
401
  logic.mergeIn(builder.logic);
402
402
  } else {
403
- throw new Error('Unknown LogicNodeBuilder type');
403
+ throw new _RuntimeError(1909, ngDevMode && 'Unknown LogicNodeBuilder type');
404
404
  }
405
405
  return logic;
406
406
  }
@@ -509,7 +509,7 @@ function isSchemaOrSchemaFn(value) {
509
509
  }
510
510
  function assertPathIsCurrent(path) {
511
511
  if (currentCompilingNode !== FieldPathNode.unwrapFieldPath(path).root) {
512
- throw new Error(`A FieldPath can only be used directly within the Schema that owns it,` + ` **not** outside of it or within a sub-schema.`);
512
+ throw new _RuntimeError(1908, ngDevMode && `A FieldPath can only be used directly within the Schema that owns it, **not** outside of it or within a sub-schema.`);
513
513
  }
514
514
  }
515
515
 
@@ -628,7 +628,7 @@ class FieldValidationState {
628
628
  }, ...(ngDevMode ? [{
629
629
  debugName: "syncValid"
630
630
  }] : []));
631
- syncTreeErrors = computed(() => this.rawSyncTreeErrors().filter(err => err.field === this.node.fieldProxy), ...(ngDevMode ? [{
631
+ syncTreeErrors = computed(() => this.rawSyncTreeErrors().filter(err => err.fieldTree === this.node.fieldProxy), ...(ngDevMode ? [{
632
632
  debugName: "syncTreeErrors"
633
633
  }] : []));
634
634
  rawAsyncErrors = computed(() => {
@@ -643,7 +643,7 @@ class FieldValidationState {
643
643
  if (this.shouldSkipValidation()) {
644
644
  return [];
645
645
  }
646
- return this.rawAsyncErrors().filter(err => err === 'pending' || err.field === this.node.fieldProxy);
646
+ return this.rawAsyncErrors().filter(err => err === 'pending' || err.fieldTree === this.node.fieldProxy);
647
647
  }, ...(ngDevMode ? [{
648
648
  debugName: "asyncErrors"
649
649
  }] : []));
@@ -691,13 +691,13 @@ function normalizeErrors(error) {
691
691
  }
692
692
  return [error];
693
693
  }
694
- function addDefaultField(errors, field) {
694
+ function addDefaultField(errors, fieldTree) {
695
695
  if (isArray(errors)) {
696
696
  for (const error of errors) {
697
- error.field ??= field;
697
+ error.fieldTree ??= fieldTree;
698
698
  }
699
699
  } else if (errors) {
700
- errors.field ??= field;
700
+ errors.fieldTree ??= fieldTree;
701
701
  }
702
702
  return errors;
703
703
  }
@@ -720,13 +720,13 @@ class FieldNodeContext {
720
720
  stepsRemaining--;
721
721
  field = field.structure.parent;
722
722
  if (field === undefined) {
723
- throw new Error('Path is not part of this field tree.');
723
+ throw new _RuntimeError(1900, ngDevMode && 'Path is not part of this field tree.');
724
724
  }
725
725
  }
726
726
  for (let key of targetPathNode.keys) {
727
727
  field = field.structure.getChild(key);
728
728
  if (field === undefined) {
729
- throw new Error(`Cannot resolve path .${targetPathNode.keys.join('.')} relative to field ${['<root>', ...this.node.structure.pathKeys()].join('.')}.`);
729
+ throw new _RuntimeError(1901, ngDevMode && `Cannot resolve path .${targetPathNode.keys.join('.')} relative to field ${['<root>', ...this.node.structure.pathKeys()].join('.')}.`);
730
730
  }
731
731
  }
732
732
  return field.fieldProxy;
@@ -737,7 +737,7 @@ class FieldNodeContext {
737
737
  }
738
738
  return this.cache.get(target)();
739
739
  }
740
- get field() {
740
+ get fieldTree() {
741
741
  return this.node.fieldProxy;
742
742
  }
743
743
  get state() {
@@ -755,7 +755,7 @@ class FieldNodeContext {
755
755
  index = computed(() => {
756
756
  const key = this.key();
757
757
  if (!isArray(untracked(this.node.structure.parent.value))) {
758
- throw new Error(`RuntimeError: cannot access index, parent field is not an array`);
758
+ throw new _RuntimeError(1906, ngDevMode && 'Cannot access index, parent field is not an array.');
759
759
  }
760
760
  return Number(key);
761
761
  }, ...(ngDevMode ? [{
@@ -766,7 +766,7 @@ class FieldNodeContext {
766
766
  valueOf = p => {
767
767
  const result = this.resolve(p)().value();
768
768
  if (result instanceof AbstractControl) {
769
- throw new Error(`Tried to read an 'AbstractControl' value form a 'form()'. Did you mean to use 'compatForm()' instead?`);
769
+ throw new _RuntimeError(1907, ngDevMode && `Tried to read an 'AbstractControl' value from a 'form()'. Did you mean to use 'compatForm()' instead?`);
770
770
  }
771
771
  return result;
772
772
  };
@@ -929,7 +929,7 @@ class FieldNodeStructure {
929
929
  const key = initialKeyInParent;
930
930
  return computed(() => {
931
931
  if (this.parent.structure.getChild(key) !== this.node) {
932
- throw new Error(`RuntimeError: orphan field, looking for property '${key}' of ${getDebugName(this.parent)}`);
932
+ throw new _RuntimeError(1902, ngDevMode && `Orphan field, looking for property '${key}' of ${getDebugName(this.parent)}`);
933
933
  }
934
934
  return key;
935
935
  });
@@ -938,7 +938,7 @@ class FieldNodeStructure {
938
938
  return computed(() => {
939
939
  const parentValue = this.parent.structure.value();
940
940
  if (!isArray(parentValue)) {
941
- throw new Error(`RuntimeError: orphan field, expected ${getDebugName(this.parent)} to be an array`);
941
+ throw new _RuntimeError(1903, ngDevMode && `Orphan field, expected ${getDebugName(this.parent)} to be an array`);
942
942
  }
943
943
  const data = parentValue[lastKnownKey];
944
944
  if (isObject(data) && data.hasOwnProperty(this.parent.structure.identitySymbol) && data[this.parent.structure.identitySymbol] === identityInParent) {
@@ -950,7 +950,7 @@ class FieldNodeStructure {
950
950
  return lastKnownKey = i.toString();
951
951
  }
952
952
  }
953
- throw new Error(`RuntimeError: orphan field, can't find element in array ${getDebugName(this.parent)}`);
953
+ throw new _RuntimeError(1904, ngDevMode && `Orphan field, can't find element in array ${getDebugName(this.parent)}`);
954
954
  });
955
955
  }
956
956
  }
@@ -1084,7 +1084,7 @@ const ROOT_PATH_KEYS = computed(() => [], ...(ngDevMode ? [{
1084
1084
  debugName: "ROOT_PATH_KEYS"
1085
1085
  }] : []));
1086
1086
  const ROOT_KEY_IN_PARENT = computed(() => {
1087
- throw new Error(`RuntimeError: the top-level field in the form has no parent`);
1087
+ throw new _RuntimeError(1905, ngDevMode && 'The top-level field in the form has no parent.');
1088
1088
  }, ...(ngDevMode ? [{
1089
1089
  debugName: "ROOT_KEY_IN_PARENT"
1090
1090
  }] : []));
@@ -1552,7 +1552,7 @@ function setServerErrors(submittedField, errors) {
1552
1552
  const errorsByField = new Map();
1553
1553
  for (const error of errors) {
1554
1554
  const errorWithField = addDefaultField(error, submittedField.fieldProxy);
1555
- const field = errorWithField.field();
1555
+ const field = errorWithField.fieldTree();
1556
1556
  let fieldErrors = errorsByField.get(field);
1557
1557
  if (!fieldErrors) {
1558
1558
  fieldErrors = [];