@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.
- package/fesm2022/_validation_errors-chunk.mjs +35 -24
- package/fesm2022/_validation_errors-chunk.mjs.map +1 -1
- package/fesm2022/forms.mjs +3633 -3301
- package/fesm2022/forms.mjs.map +1 -1
- package/fesm2022/signals-compat.mjs +83 -9
- package/fesm2022/signals-compat.mjs.map +1 -1
- package/fesm2022/signals.mjs +18 -59
- 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 +31 -17
- package/types/forms.d.ts +123 -17
- package/types/signals-compat.d.ts +60 -2
- package/types/signals.d.ts +2 -2
package/fesm2022/signals.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v22.0.0-next.
|
|
2
|
+
* @license Angular v22.0.0-next.4
|
|
3
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, ɵisPromise as _isPromise,
|
|
8
|
+
import { InjectionToken, resource, ɵisPromise as _isPromise, linkedSignal, inject, ɵRuntimeError as _RuntimeError, untracked, input, computed, Renderer2, DestroyRef, Injector, ElementRef, signal, afterRenderEffect, effect, ɵformatRuntimeError as _formatRuntimeError, Directive } from '@angular/core';
|
|
9
|
+
import { ɵFORM_FIELD_PARSE_ERRORS as _FORM_FIELD_PARSE_ERRORS, Validators, ɵsetNativeDomProperty as _setNativeDomProperty, ɵisNativeFormElement as _isNativeFormElement, ɵisNumericFormElement as _isNumericFormElement, ɵisTextualFormElement as _isTextualFormElement, NG_VALUE_ACCESSOR, NgControl } from '@angular/forms';
|
|
9
10
|
import { assertPathIsCurrent, FieldPathNode, addDefaultField, metadata, createMetadataKey, MAX, MAX_LENGTH, MIN, MIN_LENGTH, PATTERN, REQUIRED, createManagedMetadataKey, DEBOUNCER, signalErrorsToValidationErrors, submit } from './_validation_errors-chunk.mjs';
|
|
10
11
|
export { MetadataKey, MetadataReducer, apply, applyEach, applyWhen, applyWhenValue, form, schema } from './_validation_errors-chunk.mjs';
|
|
11
12
|
import { httpResource } from '@angular/common/http';
|
|
12
|
-
import { Validators, NG_VALUE_ACCESSOR, NgControl } from '@angular/forms';
|
|
13
13
|
import '@angular/core/primitives/signals';
|
|
14
14
|
|
|
15
15
|
const SIGNAL_FORMS_CONFIG = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'SIGNAL_FORMS_CONFIG' : '');
|
|
@@ -498,8 +498,6 @@ function debounceUntilBlur() {
|
|
|
498
498
|
}
|
|
499
499
|
function immediate() {}
|
|
500
500
|
|
|
501
|
-
const FORM_FIELD_PARSE_ERRORS = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'FORM_FIELD_PARSE_ERRORS' : '');
|
|
502
|
-
|
|
503
501
|
function createParser(getValue, setValue, parse) {
|
|
504
502
|
const errors = linkedSignal({
|
|
505
503
|
...(ngDevMode ? {
|
|
@@ -528,7 +526,7 @@ function transformedValue(value, options) {
|
|
|
528
526
|
format
|
|
529
527
|
} = options;
|
|
530
528
|
const parser = createParser(value, value.set, parse);
|
|
531
|
-
const formFieldParseErrors = inject(
|
|
529
|
+
const formFieldParseErrors = inject(_FORM_FIELD_PARSE_ERRORS, {
|
|
532
530
|
self: true,
|
|
533
531
|
optional: true
|
|
534
532
|
});
|
|
@@ -656,19 +654,6 @@ function bindingUpdated(bindings, key, value) {
|
|
|
656
654
|
return false;
|
|
657
655
|
}
|
|
658
656
|
|
|
659
|
-
function isNativeFormElement(element) {
|
|
660
|
-
return element.tagName === 'INPUT' || element.tagName === 'SELECT' || element.tagName === 'TEXTAREA';
|
|
661
|
-
}
|
|
662
|
-
function isNumericFormElement(element) {
|
|
663
|
-
if (element.tagName !== 'INPUT') {
|
|
664
|
-
return false;
|
|
665
|
-
}
|
|
666
|
-
const type = element.type;
|
|
667
|
-
return type === 'date' || type === 'datetime-local' || type === 'month' || type === 'number' || type === 'range' || type === 'time' || type === 'week';
|
|
668
|
-
}
|
|
669
|
-
function isTextualFormElement(element) {
|
|
670
|
-
return element.tagName === 'INPUT' || element.tagName === 'TEXTAREA';
|
|
671
|
-
}
|
|
672
657
|
function getNativeControlValue(element, currentValue) {
|
|
673
658
|
let modelValue;
|
|
674
659
|
if (element.validity.badInput) {
|
|
@@ -751,32 +736,6 @@ function setNativeNumberControlValue(element, value) {
|
|
|
751
736
|
element.valueAsNumber = value;
|
|
752
737
|
}
|
|
753
738
|
}
|
|
754
|
-
function setNativeDomProperty(renderer, element, name, value) {
|
|
755
|
-
switch (name) {
|
|
756
|
-
case 'name':
|
|
757
|
-
renderer.setAttribute(element, name, value);
|
|
758
|
-
break;
|
|
759
|
-
case 'disabled':
|
|
760
|
-
case 'readonly':
|
|
761
|
-
case 'required':
|
|
762
|
-
if (value) {
|
|
763
|
-
renderer.setAttribute(element, name, '');
|
|
764
|
-
} else {
|
|
765
|
-
renderer.removeAttribute(element, name);
|
|
766
|
-
}
|
|
767
|
-
break;
|
|
768
|
-
case 'max':
|
|
769
|
-
case 'min':
|
|
770
|
-
case 'minLength':
|
|
771
|
-
case 'maxLength':
|
|
772
|
-
if (value !== undefined) {
|
|
773
|
-
renderer.setAttribute(element, name, value.toString());
|
|
774
|
-
} else {
|
|
775
|
-
renderer.removeAttribute(element, name);
|
|
776
|
-
}
|
|
777
|
-
break;
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
739
|
|
|
781
740
|
function customControlCreate(host, parent) {
|
|
782
741
|
host.listenToCustomControlModel(value => parent.state().controlValue.set(value));
|
|
@@ -799,7 +758,7 @@ function customControlCreate(host, parent) {
|
|
|
799
758
|
if (bindingUpdated(bindings, name, value)) {
|
|
800
759
|
host.setInputOnDirectives(name, value);
|
|
801
760
|
if (parent.elementAcceptsNativeProperty(name) && !host.customControlHasInput(name)) {
|
|
802
|
-
|
|
761
|
+
_setNativeDomProperty(parent.renderer, parent.nativeFormElement, name, value);
|
|
803
762
|
}
|
|
804
763
|
}
|
|
805
764
|
}
|
|
@@ -824,7 +783,7 @@ function cvaControlCreate(host, parent) {
|
|
|
824
783
|
if (name === 'disabled' && parent.controlValueAccessor.setDisabledState) {
|
|
825
784
|
untracked(() => parent.controlValueAccessor.setDisabledState(value));
|
|
826
785
|
} else if (!propertyWasSet && parent.elementAcceptsNativeProperty(name)) {
|
|
827
|
-
|
|
786
|
+
_setNativeDomProperty(parent.renderer, parent.nativeFormElement, name, value);
|
|
828
787
|
}
|
|
829
788
|
}
|
|
830
789
|
}
|
|
@@ -900,7 +859,7 @@ function nativeControlCreate(host, parent, parseErrorsSource) {
|
|
|
900
859
|
if (bindingUpdated(bindings, name, value)) {
|
|
901
860
|
host.setInputOnDirectives(name, value);
|
|
902
861
|
if (parent.elementAcceptsNativeProperty(name)) {
|
|
903
|
-
|
|
862
|
+
_setNativeDomProperty(parent.renderer, input, name, value);
|
|
904
863
|
}
|
|
905
864
|
}
|
|
906
865
|
}
|
|
@@ -924,9 +883,9 @@ class FormField {
|
|
|
924
883
|
destroyRef = inject(DestroyRef);
|
|
925
884
|
injector = inject(Injector);
|
|
926
885
|
element = inject(ElementRef).nativeElement;
|
|
927
|
-
elementIsNativeFormElement =
|
|
928
|
-
elementAcceptsNumericValues =
|
|
929
|
-
elementAcceptsTextualValues =
|
|
886
|
+
elementIsNativeFormElement = _isNativeFormElement(this.element);
|
|
887
|
+
elementAcceptsNumericValues = _isNumericFormElement(this.element);
|
|
888
|
+
elementAcceptsTextualValues = _isTextualFormElement(this.element);
|
|
930
889
|
nativeFormElement = this.elementIsNativeFormElement ? this.element : undefined;
|
|
931
890
|
focuser = options => this.element.focus(options);
|
|
932
891
|
controlValueAccessors = inject(NG_VALUE_ACCESSOR, {
|
|
@@ -1051,7 +1010,7 @@ class FormField {
|
|
|
1051
1010
|
}
|
|
1052
1011
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
1053
1012
|
minVersion: "12.0.0",
|
|
1054
|
-
version: "22.0.0-next.
|
|
1013
|
+
version: "22.0.0-next.4",
|
|
1055
1014
|
ngImport: i0,
|
|
1056
1015
|
type: FormField,
|
|
1057
1016
|
deps: [],
|
|
@@ -1059,7 +1018,7 @@ class FormField {
|
|
|
1059
1018
|
});
|
|
1060
1019
|
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
1061
1020
|
minVersion: "17.1.0",
|
|
1062
|
-
version: "22.0.0-next.
|
|
1021
|
+
version: "22.0.0-next.4",
|
|
1063
1022
|
type: FormField,
|
|
1064
1023
|
isStandalone: true,
|
|
1065
1024
|
selector: "[formField]",
|
|
@@ -1079,7 +1038,7 @@ class FormField {
|
|
|
1079
1038
|
provide: NgControl,
|
|
1080
1039
|
useFactory: () => inject(FormField).interopNgControl
|
|
1081
1040
|
}, {
|
|
1082
|
-
provide:
|
|
1041
|
+
provide: _FORM_FIELD_PARSE_ERRORS,
|
|
1083
1042
|
useFactory: () => inject(FormField).parseErrorsSource
|
|
1084
1043
|
}],
|
|
1085
1044
|
exportAs: ["formField"],
|
|
@@ -1091,7 +1050,7 @@ class FormField {
|
|
|
1091
1050
|
}
|
|
1092
1051
|
i0.ɵɵngDeclareClassMetadata({
|
|
1093
1052
|
minVersion: "12.0.0",
|
|
1094
|
-
version: "22.0.0-next.
|
|
1053
|
+
version: "22.0.0-next.4",
|
|
1095
1054
|
ngImport: i0,
|
|
1096
1055
|
type: FormField,
|
|
1097
1056
|
decorators: [{
|
|
@@ -1106,7 +1065,7 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
1106
1065
|
provide: NgControl,
|
|
1107
1066
|
useFactory: () => inject(FormField).interopNgControl
|
|
1108
1067
|
}, {
|
|
1109
|
-
provide:
|
|
1068
|
+
provide: _FORM_FIELD_PARSE_ERRORS,
|
|
1110
1069
|
useFactory: () => inject(FormField).parseErrorsSource
|
|
1111
1070
|
}]
|
|
1112
1071
|
}]
|
|
@@ -1136,7 +1095,7 @@ class FormRoot {
|
|
|
1136
1095
|
}
|
|
1137
1096
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
1138
1097
|
minVersion: "12.0.0",
|
|
1139
|
-
version: "22.0.0-next.
|
|
1098
|
+
version: "22.0.0-next.4",
|
|
1140
1099
|
ngImport: i0,
|
|
1141
1100
|
type: FormRoot,
|
|
1142
1101
|
deps: [],
|
|
@@ -1144,7 +1103,7 @@ class FormRoot {
|
|
|
1144
1103
|
});
|
|
1145
1104
|
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
1146
1105
|
minVersion: "17.1.0",
|
|
1147
|
-
version: "22.0.0-next.
|
|
1106
|
+
version: "22.0.0-next.4",
|
|
1148
1107
|
type: FormRoot,
|
|
1149
1108
|
isStandalone: true,
|
|
1150
1109
|
selector: "form[formRoot]",
|
|
@@ -1170,7 +1129,7 @@ class FormRoot {
|
|
|
1170
1129
|
}
|
|
1171
1130
|
i0.ɵɵngDeclareClassMetadata({
|
|
1172
1131
|
minVersion: "12.0.0",
|
|
1173
|
-
version: "22.0.0-next.
|
|
1132
|
+
version: "22.0.0-next.4",
|
|
1174
1133
|
ngImport: i0,
|
|
1175
1134
|
type: FormRoot,
|
|
1176
1135
|
decorators: [{
|