@angular/forms 21.0.0 → 21.1.0-next.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,5 +1,5 @@
1
1
  /**
2
- * @license Angular v21.0.0
2
+ * @license Angular v21.1.0-next.0
3
3
  * (c) 2010-2025 Google LLC. https://angular.dev/
4
4
  * License: MIT
5
5
  */
@@ -61,53 +61,71 @@ class FieldValidationState {
61
61
  return [];
62
62
  }
63
63
  return [...this.node.logicNode.logic.syncTreeErrors.compute(this.node.context), ...(this.node.structure.parent?.validationState.rawSyncTreeErrors() ?? [])];
64
- }, ...(ngDevMode ? [{
65
- debugName: "rawSyncTreeErrors"
66
- }] : []));
64
+ }, {
65
+ ...(ngDevMode ? {
66
+ debugName: "rawSyncTreeErrors"
67
+ } : {})
68
+ });
67
69
  syncErrors = computed(() => {
68
70
  if (this.shouldSkipValidation()) {
69
71
  return [];
70
72
  }
71
73
  return [...this.node.logicNode.logic.syncErrors.compute(this.node.context), ...this.syncTreeErrors(), ...normalizeErrors(this.node.submitState.serverErrors())];
72
- }, ...(ngDevMode ? [{
73
- debugName: "syncErrors"
74
- }] : []));
74
+ }, {
75
+ ...(ngDevMode ? {
76
+ debugName: "syncErrors"
77
+ } : {})
78
+ });
75
79
  syncValid = computed(() => {
76
80
  if (this.shouldSkipValidation()) {
77
81
  return true;
78
82
  }
79
83
  return reduceChildren(this.node, this.syncErrors().length === 0, (child, value) => value && child.validationState.syncValid(), shortCircuitFalse);
80
- }, ...(ngDevMode ? [{
81
- debugName: "syncValid"
82
- }] : []));
83
- syncTreeErrors = computed(() => this.rawSyncTreeErrors().filter(err => err.field === this.node.fieldProxy), ...(ngDevMode ? [{
84
- debugName: "syncTreeErrors"
85
- }] : []));
84
+ }, {
85
+ ...(ngDevMode ? {
86
+ debugName: "syncValid"
87
+ } : {})
88
+ });
89
+ syncTreeErrors = computed(() => this.rawSyncTreeErrors().filter(err => err.field === this.node.fieldProxy), {
90
+ ...(ngDevMode ? {
91
+ debugName: "syncTreeErrors"
92
+ } : {})
93
+ });
86
94
  rawAsyncErrors = computed(() => {
87
95
  if (this.shouldSkipValidation()) {
88
96
  return [];
89
97
  }
90
98
  return [...this.node.logicNode.logic.asyncErrors.compute(this.node.context), ...(this.node.structure.parent?.validationState.rawAsyncErrors() ?? [])];
91
- }, ...(ngDevMode ? [{
92
- debugName: "rawAsyncErrors"
93
- }] : []));
99
+ }, {
100
+ ...(ngDevMode ? {
101
+ debugName: "rawAsyncErrors"
102
+ } : {})
103
+ });
94
104
  asyncErrors = computed(() => {
95
105
  if (this.shouldSkipValidation()) {
96
106
  return [];
97
107
  }
98
108
  return this.rawAsyncErrors().filter(err => err === 'pending' || err.field === this.node.fieldProxy);
99
- }, ...(ngDevMode ? [{
100
- debugName: "asyncErrors"
101
- }] : []));
102
- errors = computed(() => [...this.syncErrors(), ...this.asyncErrors().filter(err => err !== 'pending')], ...(ngDevMode ? [{
103
- debugName: "errors"
104
- }] : []));
105
- errorSummary = computed(() => reduceChildren(this.node, this.errors(), (child, result) => [...result, ...child.errorSummary()]), ...(ngDevMode ? [{
106
- debugName: "errorSummary"
107
- }] : []));
108
- pending = computed(() => reduceChildren(this.node, this.asyncErrors().includes('pending'), (child, value) => value || child.validationState.asyncErrors().includes('pending')), ...(ngDevMode ? [{
109
- debugName: "pending"
110
- }] : []));
109
+ }, {
110
+ ...(ngDevMode ? {
111
+ debugName: "asyncErrors"
112
+ } : {})
113
+ });
114
+ errors = computed(() => [...this.syncErrors(), ...this.asyncErrors().filter(err => err !== 'pending')], {
115
+ ...(ngDevMode ? {
116
+ debugName: "errors"
117
+ } : {})
118
+ });
119
+ errorSummary = computed(() => reduceChildren(this.node, this.errors(), (child, result) => [...result, ...child.errorSummary()]), {
120
+ ...(ngDevMode ? {
121
+ debugName: "errorSummary"
122
+ } : {})
123
+ });
124
+ pending = computed(() => reduceChildren(this.node, this.asyncErrors().includes('pending'), (child, value) => value || child.validationState.asyncErrors().includes('pending')), {
125
+ ...(ngDevMode ? {
126
+ debugName: "pending"
127
+ } : {})
128
+ });
111
129
  status = computed(() => {
112
130
  if (this.shouldSkipValidation()) {
113
131
  return 'valid';
@@ -121,18 +139,26 @@ class FieldValidationState {
121
139
  }
122
140
  return 'valid';
123
141
  }, v => v === 'invalid');
124
- }, ...(ngDevMode ? [{
125
- debugName: "status"
126
- }] : []));
127
- valid = computed(() => this.status() === 'valid', ...(ngDevMode ? [{
128
- debugName: "valid"
129
- }] : []));
130
- invalid = computed(() => this.status() === 'invalid', ...(ngDevMode ? [{
131
- debugName: "invalid"
132
- }] : []));
133
- shouldSkipValidation = computed(() => this.node.hidden() || this.node.disabled() || this.node.readonly(), ...(ngDevMode ? [{
134
- debugName: "shouldSkipValidation"
135
- }] : []));
142
+ }, {
143
+ ...(ngDevMode ? {
144
+ debugName: "status"
145
+ } : {})
146
+ });
147
+ valid = computed(() => this.status() === 'valid', {
148
+ ...(ngDevMode ? {
149
+ debugName: "valid"
150
+ } : {})
151
+ });
152
+ invalid = computed(() => this.status() === 'invalid', {
153
+ ...(ngDevMode ? {
154
+ debugName: "invalid"
155
+ } : {})
156
+ });
157
+ shouldSkipValidation = computed(() => this.node.hidden() || this.node.disabled() || this.node.readonly(), {
158
+ ...(ngDevMode ? {
159
+ debugName: "shouldSkipValidation"
160
+ } : {})
161
+ });
136
162
  }
137
163
  function normalizeErrors(error) {
138
164
  if (error === undefined) {
@@ -742,9 +768,11 @@ class FieldNodeContext {
742
768
  }
743
769
  }
744
770
  return field.fieldProxy;
745
- }, ...(ngDevMode ? [{
746
- debugName: "resolver"
747
- }] : []));
771
+ }, {
772
+ ...(ngDevMode ? {
773
+ debugName: "resolver"
774
+ } : {})
775
+ });
748
776
  this.cache.set(target, resolver);
749
777
  }
750
778
  return this.cache.get(target)();
@@ -770,9 +798,11 @@ class FieldNodeContext {
770
798
  throw new Error(`RuntimeError: cannot access index, parent field is not an array`);
771
799
  }
772
800
  return Number(key);
773
- }, ...(ngDevMode ? [{
774
- debugName: "index"
775
- }] : []));
801
+ }, {
802
+ ...(ngDevMode ? {
803
+ debugName: "index"
804
+ } : {})
805
+ });
776
806
  fieldTreeOf = p => this.resolve(p);
777
807
  stateOf = p => this.resolve(p)();
778
808
  valueOf = p => {
@@ -801,9 +831,11 @@ class FieldMetadataState {
801
831
  }
802
832
  if (!this.metadata.has(key)) {
803
833
  const logic = this.node.logicNode.logic.getAggregateMetadata(key);
804
- const result = computed(() => logic.compute(this.node.context), ...(ngDevMode ? [{
805
- debugName: "result"
806
- }] : []));
834
+ const result = computed(() => logic.compute(this.node.context), {
835
+ ...(ngDevMode ? {
836
+ debugName: "result"
837
+ } : {})
838
+ });
807
839
  this.metadata.set(key, result);
808
840
  }
809
841
  return this.metadata.get(key);
@@ -957,9 +989,11 @@ class ChildFieldNodeStructure extends FieldNodeStructure {
957
989
  super(logic);
958
990
  this.parent = parent;
959
991
  this.root = this.parent.structure.root;
960
- this.pathKeys = computed(() => [...parent.structure.pathKeys(), this.keyInParent()], ...(ngDevMode ? [{
961
- debugName: "pathKeys"
962
- }] : []));
992
+ this.pathKeys = computed(() => [...parent.structure.pathKeys(), this.keyInParent()], {
993
+ ...(ngDevMode ? {
994
+ debugName: "pathKeys"
995
+ } : {})
996
+ });
963
997
  if (identityInParent === undefined) {
964
998
  const key = initialKeyInParent;
965
999
  this.keyInParent = computed(() => {
@@ -967,9 +1001,11 @@ class ChildFieldNodeStructure extends FieldNodeStructure {
967
1001
  throw new Error(`RuntimeError: orphan field, looking for property '${key}' of ${getDebugName(parent)}`);
968
1002
  }
969
1003
  return key;
970
- }, ...(ngDevMode ? [{
971
- debugName: "keyInParent"
972
- }] : []));
1004
+ }, {
1005
+ ...(ngDevMode ? {
1006
+ debugName: "keyInParent"
1007
+ } : {})
1008
+ });
973
1009
  } else {
974
1010
  let lastKnownKey = initialKeyInParent;
975
1011
  this.keyInParent = computed(() => {
@@ -988,9 +1024,11 @@ class ChildFieldNodeStructure extends FieldNodeStructure {
988
1024
  }
989
1025
  }
990
1026
  throw new Error(`RuntimeError: orphan field, can't find element in array ${getDebugName(parent)}`);
991
- }, ...(ngDevMode ? [{
992
- debugName: "keyInParent"
993
- }] : []));
1027
+ }, {
1028
+ ...(ngDevMode ? {
1029
+ debugName: "keyInParent"
1030
+ } : {})
1031
+ });
994
1032
  }
995
1033
  this.value = deepSignal(this.parent.structure.value, this.keyInParent);
996
1034
  this.childrenMap = makeChildrenMapSignal(node, this.value, this.identitySymbol, pathNode, logic, adapter, createChildNode);
@@ -998,14 +1036,18 @@ class ChildFieldNodeStructure extends FieldNodeStructure {
998
1036
  }
999
1037
  }
1000
1038
  let globalId = 0;
1001
- const ROOT_PATH_KEYS = computed(() => [], ...(ngDevMode ? [{
1002
- debugName: "ROOT_PATH_KEYS"
1003
- }] : []));
1039
+ const ROOT_PATH_KEYS = computed(() => [], {
1040
+ ...(ngDevMode ? {
1041
+ debugName: "ROOT_PATH_KEYS"
1042
+ } : {})
1043
+ });
1004
1044
  const ROOT_KEY_IN_PARENT = computed(() => {
1005
1045
  throw new Error(`RuntimeError: the top-level field in the form has no parent`);
1006
- }, ...(ngDevMode ? [{
1007
- debugName: "ROOT_KEY_IN_PARENT"
1008
- }] : []));
1046
+ }, {
1047
+ ...(ngDevMode ? {
1048
+ debugName: "ROOT_KEY_IN_PARENT"
1049
+ } : {})
1050
+ });
1009
1051
  function makeChildrenMapSignal(node, valueSignal, identitySymbol, pathNode, logic, adapter, createChildNode) {
1010
1052
  return linkedSignal({
1011
1053
  source: valueSignal,
@@ -1083,26 +1125,29 @@ function getDebugName(node) {
1083
1125
 
1084
1126
  class FieldSubmitState {
1085
1127
  node;
1086
- selfSubmitting = signal(false, ...(ngDevMode ? [{
1087
- debugName: "selfSubmitting"
1088
- }] : []));
1128
+ selfSubmitting = signal(false, {
1129
+ ...(ngDevMode ? {
1130
+ debugName: "selfSubmitting"
1131
+ } : {})
1132
+ });
1089
1133
  serverErrors;
1090
1134
  constructor(node) {
1091
1135
  this.node = node;
1092
- this.serverErrors = linkedSignal(...(ngDevMode ? [{
1093
- debugName: "serverErrors",
1136
+ this.serverErrors = linkedSignal({
1137
+ ...(ngDevMode ? {
1138
+ debugName: "serverErrors"
1139
+ } : {}),
1094
1140
  source: this.node.structure.value,
1095
1141
  computation: () => []
1096
- }] : [{
1097
- source: this.node.structure.value,
1098
- computation: () => []
1099
- }]));
1142
+ });
1100
1143
  }
1101
1144
  submitting = computed(() => {
1102
1145
  return this.selfSubmitting() || (this.node.structure.parent?.submitting() ?? false);
1103
- }, ...(ngDevMode ? [{
1104
- debugName: "submitting"
1105
- }] : []));
1146
+ }, {
1147
+ ...(ngDevMode ? {
1148
+ debugName: "submitting"
1149
+ } : {})
1150
+ });
1106
1151
  }
1107
1152
 
1108
1153
  class FieldNode {
@@ -1125,29 +1170,27 @@ class FieldNode {
1125
1170
  this.metadataState = new FieldMetadataState(this);
1126
1171
  this.submitState = new FieldSubmitState(this);
1127
1172
  }
1128
- pendingSync = linkedSignal(...(ngDevMode ? [{
1129
- debugName: "pendingSync",
1130
- source: () => this.value(),
1131
- computation: (_source, previous) => {
1132
- previous?.value?.abort();
1133
- return undefined;
1134
- }
1135
- }] : [{
1173
+ pendingSync = linkedSignal({
1174
+ ...(ngDevMode ? {
1175
+ debugName: "pendingSync"
1176
+ } : {}),
1136
1177
  source: () => this.value(),
1137
1178
  computation: (_source, previous) => {
1138
1179
  previous?.value?.abort();
1139
1180
  return undefined;
1140
1181
  }
1141
- }]));
1182
+ });
1142
1183
  get logicNode() {
1143
1184
  return this.structure.logic;
1144
1185
  }
1145
1186
  get value() {
1146
1187
  return this.structure.value;
1147
1188
  }
1148
- _controlValue = linkedSignal(() => this.value(), ...(ngDevMode ? [{
1149
- debugName: "_controlValue"
1150
- }] : []));
1189
+ _controlValue = linkedSignal(() => this.value(), {
1190
+ ...(ngDevMode ? {
1191
+ debugName: "_controlValue"
1192
+ } : {})
1193
+ });
1151
1194
  get controlValue() {
1152
1195
  return this._controlValue.asReadonly();
1153
1196
  }
@@ -1231,11 +1274,17 @@ class FieldNode {
1231
1274
  markAsDirty() {
1232
1275
  this.nodeState.markAsDirty();
1233
1276
  }
1234
- reset() {
1277
+ reset(value) {
1278
+ untracked(() => this._reset(value));
1279
+ }
1280
+ _reset(value) {
1281
+ if (value) {
1282
+ this.value.set(value);
1283
+ }
1235
1284
  this.nodeState.markAsUntouched();
1236
1285
  this.nodeState.markAsPristine();
1237
1286
  for (const child of this.structure.children()) {
1238
- child.reset();
1287
+ child._reset();
1239
1288
  }
1240
1289
  }
1241
1290
  setControlValue(newValue) {
@@ -1272,21 +1321,29 @@ class FieldNode {
1272
1321
  return options.kind === 'root' ? new RootFieldNodeStructure(this, options.pathNode, options.logic, options.fieldManager, options.value, options.fieldAdapter, FieldNode.newChild) : new ChildFieldNodeStructure(this, options.pathNode, options.logic, options.parent, options.identityInParent, options.initialKeyInParent, options.fieldAdapter, FieldNode.newChild);
1273
1322
  }
1274
1323
  }
1275
- const EMPTY = computed(() => [], ...(ngDevMode ? [{
1276
- debugName: "EMPTY"
1277
- }] : []));
1278
- const FALSE = computed(() => false, ...(ngDevMode ? [{
1279
- debugName: "FALSE"
1280
- }] : []));
1324
+ const EMPTY = computed(() => [], {
1325
+ ...(ngDevMode ? {
1326
+ debugName: "EMPTY"
1327
+ } : {})
1328
+ });
1329
+ const FALSE = computed(() => false, {
1330
+ ...(ngDevMode ? {
1331
+ debugName: "FALSE"
1332
+ } : {})
1333
+ });
1281
1334
 
1282
1335
  class FieldNodeState {
1283
1336
  node;
1284
- selfTouched = signal(false, ...(ngDevMode ? [{
1285
- debugName: "selfTouched"
1286
- }] : []));
1287
- selfDirty = signal(false, ...(ngDevMode ? [{
1288
- debugName: "selfDirty"
1289
- }] : []));
1337
+ selfTouched = signal(false, {
1338
+ ...(ngDevMode ? {
1339
+ debugName: "selfTouched"
1340
+ } : {})
1341
+ });
1342
+ selfDirty = signal(false, {
1343
+ ...(ngDevMode ? {
1344
+ debugName: "selfDirty"
1345
+ } : {})
1346
+ });
1290
1347
  markAsTouched() {
1291
1348
  this.selfTouched.set(true);
1292
1349
  }
@@ -1299,45 +1356,61 @@ class FieldNodeState {
1299
1356
  markAsUntouched() {
1300
1357
  this.selfTouched.set(false);
1301
1358
  }
1302
- fieldBindings = signal([], ...(ngDevMode ? [{
1303
- debugName: "fieldBindings"
1304
- }] : []));
1359
+ fieldBindings = signal([], {
1360
+ ...(ngDevMode ? {
1361
+ debugName: "fieldBindings"
1362
+ } : {})
1363
+ });
1305
1364
  constructor(node) {
1306
1365
  this.node = node;
1307
1366
  }
1308
1367
  dirty = computed(() => {
1309
1368
  const selfDirtyValue = this.selfDirty() && !this.isNonInteractive();
1310
1369
  return reduceChildren(this.node, selfDirtyValue, (child, value) => value || child.nodeState.dirty(), shortCircuitTrue);
1311
- }, ...(ngDevMode ? [{
1312
- debugName: "dirty"
1313
- }] : []));
1370
+ }, {
1371
+ ...(ngDevMode ? {
1372
+ debugName: "dirty"
1373
+ } : {})
1374
+ });
1314
1375
  touched = computed(() => {
1315
1376
  const selfTouchedValue = this.selfTouched() && !this.isNonInteractive();
1316
1377
  return reduceChildren(this.node, selfTouchedValue, (child, value) => value || child.nodeState.touched(), shortCircuitTrue);
1317
- }, ...(ngDevMode ? [{
1318
- debugName: "touched"
1319
- }] : []));
1320
- disabledReasons = computed(() => [...(this.node.structure.parent?.nodeState.disabledReasons() ?? []), ...this.node.logicNode.logic.disabledReasons.compute(this.node.context)], ...(ngDevMode ? [{
1321
- debugName: "disabledReasons"
1322
- }] : []));
1323
- disabled = computed(() => !!this.disabledReasons().length, ...(ngDevMode ? [{
1324
- debugName: "disabled"
1325
- }] : []));
1326
- readonly = computed(() => (this.node.structure.parent?.nodeState.readonly() || this.node.logicNode.logic.readonly.compute(this.node.context)) ?? false, ...(ngDevMode ? [{
1327
- debugName: "readonly"
1328
- }] : []));
1329
- hidden = computed(() => (this.node.structure.parent?.nodeState.hidden() || this.node.logicNode.logic.hidden.compute(this.node.context)) ?? false, ...(ngDevMode ? [{
1330
- debugName: "hidden"
1331
- }] : []));
1378
+ }, {
1379
+ ...(ngDevMode ? {
1380
+ debugName: "touched"
1381
+ } : {})
1382
+ });
1383
+ disabledReasons = computed(() => [...(this.node.structure.parent?.nodeState.disabledReasons() ?? []), ...this.node.logicNode.logic.disabledReasons.compute(this.node.context)], {
1384
+ ...(ngDevMode ? {
1385
+ debugName: "disabledReasons"
1386
+ } : {})
1387
+ });
1388
+ disabled = computed(() => !!this.disabledReasons().length, {
1389
+ ...(ngDevMode ? {
1390
+ debugName: "disabled"
1391
+ } : {})
1392
+ });
1393
+ readonly = computed(() => (this.node.structure.parent?.nodeState.readonly() || this.node.logicNode.logic.readonly.compute(this.node.context)) ?? false, {
1394
+ ...(ngDevMode ? {
1395
+ debugName: "readonly"
1396
+ } : {})
1397
+ });
1398
+ hidden = computed(() => (this.node.structure.parent?.nodeState.hidden() || this.node.logicNode.logic.hidden.compute(this.node.context)) ?? false, {
1399
+ ...(ngDevMode ? {
1400
+ debugName: "hidden"
1401
+ } : {})
1402
+ });
1332
1403
  name = computed(() => {
1333
1404
  const parent = this.node.structure.parent;
1334
1405
  if (!parent) {
1335
1406
  return this.node.structure.fieldManager.rootName;
1336
1407
  }
1337
1408
  return `${parent.name()}.${this.node.structure.keyInParent()}`;
1338
- }, ...(ngDevMode ? [{
1339
- debugName: "name"
1340
- }] : []));
1409
+ }, {
1410
+ ...(ngDevMode ? {
1411
+ debugName: "name"
1412
+ } : {})
1413
+ });
1341
1414
  debouncer = computed(() => {
1342
1415
  if (this.node.logicNode.logic.hasAggregateMetadata(DEBOUNCER)) {
1343
1416
  const debouncerLogic = this.node.logicNode.logic.getAggregateMetadata(DEBOUNCER);
@@ -1347,12 +1420,16 @@ class FieldNodeState {
1347
1420
  }
1348
1421
  }
1349
1422
  return this.node.structure.parent?.nodeState.debouncer?.();
1350
- }, ...(ngDevMode ? [{
1351
- debugName: "debouncer"
1352
- }] : []));
1353
- isNonInteractive = computed(() => this.hidden() || this.disabled() || this.readonly(), ...(ngDevMode ? [{
1354
- debugName: "isNonInteractive"
1355
- }] : []));
1423
+ }, {
1424
+ ...(ngDevMode ? {
1425
+ debugName: "debouncer"
1426
+ } : {})
1427
+ });
1428
+ isNonInteractive = computed(() => this.hidden() || this.disabled() || this.readonly(), {
1429
+ ...(ngDevMode ? {
1430
+ debugName: "isNonInteractive"
1431
+ } : {})
1432
+ });
1356
1433
  }
1357
1434
 
1358
1435
  class BasicFieldAdapter {