@angular/forms 21.1.3 → 21.2.0-next.1
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.
- package/fesm2022/_structure-chunk.mjs +31 -5
- package/fesm2022/_structure-chunk.mjs.map +1 -1
- package/fesm2022/forms.mjs +128 -128
- package/fesm2022/forms.mjs.map +1 -1
- package/fesm2022/signals-compat.mjs +4 -1
- package/fesm2022/signals-compat.mjs.map +1 -1
- package/fesm2022/signals.mjs +29 -15
- package/fesm2022/signals.mjs.map +1 -1
- package/package.json +4 -4
- package/resources/code-examples.db +0 -0
- package/types/_structure-chunk.d.ts +171 -165
- package/types/forms.d.ts +1 -1
- package/types/signals-compat.d.ts +1 -1
- package/types/signals.d.ts +16 -10
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v21.1
|
|
2
|
+
* @license Angular v21.2.0-next.1
|
|
3
3
|
* (c) 2010-2026 Google LLC. https://angular.dev/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -647,10 +647,19 @@ class FieldValidationState {
|
|
|
647
647
|
}, ...(ngDevMode ? [{
|
|
648
648
|
debugName: "asyncErrors"
|
|
649
649
|
}] : []));
|
|
650
|
-
|
|
650
|
+
parseErrors = computed(() => this.node.formFieldBindings().flatMap(field => field.parseErrors()), ...(ngDevMode ? [{
|
|
651
|
+
debugName: "parseErrors"
|
|
652
|
+
}] : []));
|
|
653
|
+
errors = computed(() => [...this.parseErrors(), ...this.syncErrors(), ...this.asyncErrors().filter(err => err !== 'pending')], ...(ngDevMode ? [{
|
|
651
654
|
debugName: "errors"
|
|
652
655
|
}] : []));
|
|
653
|
-
errorSummary = computed(() =>
|
|
656
|
+
errorSummary = computed(() => {
|
|
657
|
+
const errors = this.node.structure.reduceChildren(this.errors(), (child, result) => [...result, ...child.errorSummary()]);
|
|
658
|
+
if (typeof ngServerMode === 'undefined' || !ngServerMode) {
|
|
659
|
+
untracked(() => errors.sort(compareErrorPosition));
|
|
660
|
+
}
|
|
661
|
+
return errors;
|
|
662
|
+
}, ...(ngDevMode ? [{
|
|
654
663
|
debugName: "errorSummary"
|
|
655
664
|
}] : []));
|
|
656
665
|
pending = computed(() => this.node.structure.reduceChildren(this.asyncErrors().includes('pending'), (child, value) => value || child.validationState.asyncErrors().includes('pending')), ...(ngDevMode ? [{
|
|
@@ -701,6 +710,20 @@ function addDefaultField(errors, fieldTree) {
|
|
|
701
710
|
}
|
|
702
711
|
return errors;
|
|
703
712
|
}
|
|
713
|
+
function getFirstBoundElement(error) {
|
|
714
|
+
if (error.formField) return error.formField.element;
|
|
715
|
+
return error.fieldTree().formFieldBindings().reduce((el, binding) => {
|
|
716
|
+
if (!el || !binding.element) return el ?? binding.element;
|
|
717
|
+
return el.compareDocumentPosition(binding.element) & Node.DOCUMENT_POSITION_PRECEDING ? binding.element : el;
|
|
718
|
+
}, undefined);
|
|
719
|
+
}
|
|
720
|
+
function compareErrorPosition(a, b) {
|
|
721
|
+
const aEl = getFirstBoundElement(a);
|
|
722
|
+
const bEl = getFirstBoundElement(b);
|
|
723
|
+
if (aEl === bEl) return 0;
|
|
724
|
+
if (aEl === undefined || bEl === undefined) return aEl === undefined ? 1 : -1;
|
|
725
|
+
return aEl.compareDocumentPosition(bEl) & Node.DOCUMENT_POSITION_PRECEDING ? 1 : -1;
|
|
726
|
+
}
|
|
704
727
|
|
|
705
728
|
const DEBOUNCER = createMetadataKey();
|
|
706
729
|
|
|
@@ -1178,8 +1201,8 @@ class FieldNode {
|
|
|
1178
1201
|
this.metadataState = new FieldMetadataState(this);
|
|
1179
1202
|
this.submitState = new FieldSubmitState(this);
|
|
1180
1203
|
}
|
|
1181
|
-
focusBoundControl() {
|
|
1182
|
-
this.getBindingForFocus()?.focus();
|
|
1204
|
+
focusBoundControl(options) {
|
|
1205
|
+
this.getBindingForFocus()?.focus(options);
|
|
1183
1206
|
}
|
|
1184
1207
|
getBindingForFocus() {
|
|
1185
1208
|
const own = this.formFieldBindings().filter(b => b.focus !== undefined).reduce(firstInDom, undefined);
|
|
@@ -1214,6 +1237,9 @@ class FieldNode {
|
|
|
1214
1237
|
get errors() {
|
|
1215
1238
|
return this.validationState.errors;
|
|
1216
1239
|
}
|
|
1240
|
+
get parseErrors() {
|
|
1241
|
+
return this.validationState.parseErrors;
|
|
1242
|
+
}
|
|
1217
1243
|
get errorSummary() {
|
|
1218
1244
|
return this.validationState.errorSummary;
|
|
1219
1245
|
}
|