@angular/forms 22.0.0-next.2 → 22.0.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,5 +1,5 @@
1
1
  /**
2
- * @license Angular v22.0.0-next.2
2
+ * @license Angular v22.0.0-next.4
3
3
  * (c) 2010-2026 Google LLC. https://angular.dev/
4
4
  * License: MIT
5
5
  */
@@ -732,6 +732,8 @@ class FieldNodeContext {
732
732
  cache = new WeakMap();
733
733
  constructor(node) {
734
734
  this.node = node;
735
+ this.fieldTreeOf = this.fieldTreeOf.bind(this);
736
+ this.stateOf = this.stateOf.bind(this);
735
737
  }
736
738
  resolve(target) {
737
739
  if (!this.cache.has(target)) {
@@ -784,8 +786,12 @@ class FieldNodeContext {
784
786
  }, ...(ngDevMode ? [{
785
787
  debugName: "index"
786
788
  }] : []));
787
- fieldTreeOf = p => this.resolve(p);
788
- stateOf = p => this.resolve(p)();
789
+ fieldTreeOf(p) {
790
+ return this.resolve(p);
791
+ }
792
+ stateOf(p) {
793
+ return this.resolve(p)();
794
+ }
789
795
  valueOf = p => {
790
796
  const result = this.resolve(p)().value();
791
797
  if (result instanceof AbstractControl) {
@@ -1302,12 +1308,24 @@ class FieldNode {
1302
1308
  hasMetadata(key) {
1303
1309
  return this.metadataState.has(key);
1304
1310
  }
1305
- markAsTouched() {
1311
+ markAsTouched(options) {
1306
1312
  untracked(() => {
1307
- this.nodeState.markAsTouched();
1313
+ this.markAsTouchedInternal(options);
1308
1314
  this.flushSync();
1309
1315
  });
1310
1316
  }
1317
+ markAsTouchedInternal(options) {
1318
+ if (this.validationState.shouldSkipValidation()) {
1319
+ return;
1320
+ }
1321
+ this.nodeState.markAsTouched();
1322
+ if (options?.skipDescendants) {
1323
+ return;
1324
+ }
1325
+ for (const child of this.structure.children()) {
1326
+ child.markAsTouchedInternal();
1327
+ }
1328
+ }
1311
1329
  markAsDirty() {
1312
1330
  this.nodeState.markAsDirty();
1313
1331
  }
@@ -1617,19 +1635,11 @@ async function submit(form, options) {
1617
1635
  if (!action) {
1618
1636
  throw new _RuntimeError(1915, (typeof ngDevMode === 'undefined' || ngDevMode) && 'Cannot submit form with no submit action. Specify the action when creating the form, or as an additional argument to `submit()`.');
1619
1637
  }
1638
+ node.markAsTouched();
1620
1639
  const onInvalid = options?.onInvalid;
1621
- const ignoreValidators = options?.ignoreValidators ?? 'pending';
1622
- let shouldRunAction = true;
1623
- untracked(() => {
1624
- markAllAsTouched(node);
1625
- if (ignoreValidators === 'none') {
1626
- shouldRunAction = node.valid();
1627
- } else if (ignoreValidators === 'pending') {
1628
- shouldRunAction = !node.invalid();
1629
- }
1630
- });
1640
+ const shouldRun = shouldRunAction(node, options?.ignoreValidators);
1631
1641
  try {
1632
- if (shouldRunAction) {
1642
+ if (shouldRun) {
1633
1643
  node.submitState.selfSubmitting.set(true);
1634
1644
  const errors = await untracked(() => action?.(field, detail));
1635
1645
  errors && setSubmissionErrors(node, errors);
@@ -1645,13 +1655,14 @@ async function submit(form, options) {
1645
1655
  function schema(fn) {
1646
1656
  return SchemaImpl.create(fn);
1647
1657
  }
1648
- function markAllAsTouched(node) {
1649
- if (node.validationState.shouldSkipValidation()) {
1650
- return;
1651
- }
1652
- node.markAsTouched();
1653
- for (const child of node.structure.children()) {
1654
- markAllAsTouched(child);
1658
+ function shouldRunAction(node, ignoreValidators) {
1659
+ switch (ignoreValidators) {
1660
+ case 'all':
1661
+ return true;
1662
+ case 'none':
1663
+ return untracked(node.valid);
1664
+ default:
1665
+ return !untracked(node.invalid);
1655
1666
  }
1656
1667
  }
1657
1668
  function setSubmissionErrors(submittedField, errors) {
@@ -1725,5 +1736,5 @@ function extractNestedReactiveErrors(control) {
1725
1736
  return errors;
1726
1737
  }
1727
1738
 
1728
- export { BasicFieldAdapter, CompatValidationError, DEBOUNCER, FieldNode, FieldNodeState, FieldNodeStructure, FieldPathNode, MAX, MAX_LENGTH, MIN, MIN_LENGTH, MetadataKey, MetadataReducer, PATTERN, REQUIRED, addDefaultField, apply, applyEach, applyWhen, applyWhenValue, assertPathIsCurrent, calculateValidationSelfStatus, createManagedMetadataKey, createMetadataKey, extractNestedReactiveErrors, form, getInjectorFromOptions, metadata, normalizeFormArgs, schema, signalErrorsToValidationErrors, submit };
1739
+ export { BasicFieldAdapter, CompatValidationError, DEBOUNCER, FieldNode, FieldNodeState, FieldNodeStructure, FieldPathNode, MAX, MAX_LENGTH, MIN, MIN_LENGTH, MetadataKey, MetadataReducer, PATTERN, REQUIRED, addDefaultField, apply, applyEach, applyWhen, applyWhenValue, assertPathIsCurrent, calculateValidationSelfStatus, createManagedMetadataKey, createMetadataKey, extractNestedReactiveErrors, form, getInjectorFromOptions, isArray, isObject, metadata, normalizeFormArgs, schema, signalErrorsToValidationErrors, submit };
1729
1740
  //# sourceMappingURL=_validation_errors-chunk.mjs.map