@angular/forms 21.1.0-rc.0 → 21.1.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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v21.1.0-rc.0
2
+ * @license Angular v21.1.1
3
3
  * (c) 2010-2026 Google LLC. https://angular.dev/
4
4
  * License: MIT
5
5
  */
@@ -1,11 +1,11 @@
1
1
  /**
2
- * @license Angular v21.1.0-rc.0
2
+ * @license Angular v21.1.1
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, ɵRuntimeError as _RuntimeError, inject, ElementRef, Injector, input, computed, ɵCONTROL as _CONTROL, effect, Directive, ɵɵcontrolCreate as __controlCreate, ɵcontrolUpdate as _controlUpdate, ɵisPromise as _isPromise, resource } from '@angular/core';
8
+ import { InjectionToken, ɵRuntimeError as _RuntimeError, inject, ElementRef, Injector, input, computed, signal, ɵCONTROL as _CONTROL, untracked, effect, Directive, ɵɵcontrolCreate as __controlCreate, ɵcontrolUpdate as _controlUpdate, ɵisPromise as _isPromise, resource } from '@angular/core';
9
9
  import { Validators, NG_VALUE_ACCESSOR, NgControl } from '@angular/forms';
10
10
  import { assertPathIsCurrent, FieldPathNode, addDefaultField, metadata, createMetadataKey, MAX, MAX_LENGTH, MIN, MIN_LENGTH, PATTERN, REQUIRED, createManagedMetadataKey, DEBOUNCER } from './_structure-chunk.mjs';
11
11
  export { MetadataKey, MetadataReducer, apply, applyEach, applyWhen, applyWhenValue, form, schema, submit } from './_structure-chunk.mjs';
@@ -93,110 +93,6 @@ class InteropNgControl {
93
93
  updateValueAndValidity() {}
94
94
  }
95
95
 
96
- const FIELD = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'FIELD' : '');
97
- const controlInstructions$1 = {
98
- create: __controlCreate,
99
- update: _controlUpdate
100
- };
101
- class Field {
102
- element = inject(ElementRef).nativeElement;
103
- injector = inject(Injector);
104
- field = input.required(...(ngDevMode ? [{
105
- debugName: "field"
106
- }] : []));
107
- state = computed(() => this.field()(), ...(ngDevMode ? [{
108
- debugName: "state"
109
- }] : []));
110
- [_CONTROL] = controlInstructions$1;
111
- config = inject(SIGNAL_FORMS_CONFIG, {
112
- optional: true
113
- });
114
- classes = Object.entries(this.config?.classes ?? {}).map(([className, computation]) => [className, computed(() => computation(this))]);
115
- controlValueAccessors = inject(NG_VALUE_ACCESSOR, {
116
- optional: true,
117
- self: true
118
- });
119
- interopNgControl;
120
- get ɵinteropControl() {
121
- return this.controlValueAccessors?.[0] ?? this.interopNgControl?.valueAccessor ?? undefined;
122
- }
123
- getOrCreateNgControl() {
124
- return this.interopNgControl ??= new InteropNgControl(this.state);
125
- }
126
- ɵregister() {
127
- effect(onCleanup => {
128
- const fieldNode = this.state();
129
- fieldNode.nodeState.formFieldBindings.update(controls => [...controls, this]);
130
- onCleanup(() => {
131
- fieldNode.nodeState.formFieldBindings.update(controls => controls.filter(c => c !== this));
132
- });
133
- }, {
134
- injector: this.injector
135
- });
136
- }
137
- static ɵfac = i0.ɵɵngDeclareFactory({
138
- minVersion: "12.0.0",
139
- version: "21.1.0-rc.0",
140
- ngImport: i0,
141
- type: Field,
142
- deps: [],
143
- target: i0.ɵɵFactoryTarget.Directive
144
- });
145
- static ɵdir = i0.ɵɵngDeclareDirective({
146
- minVersion: "17.1.0",
147
- version: "21.1.0-rc.0",
148
- type: Field,
149
- isStandalone: true,
150
- selector: "[field]",
151
- inputs: {
152
- field: {
153
- classPropertyName: "field",
154
- publicName: "field",
155
- isSignal: true,
156
- isRequired: true,
157
- transformFunction: null
158
- }
159
- },
160
- providers: [{
161
- provide: FIELD,
162
- useExisting: Field
163
- }, {
164
- provide: NgControl,
165
- useFactory: () => inject(Field).getOrCreateNgControl()
166
- }],
167
- ngImport: i0
168
- });
169
- }
170
- i0.ɵɵngDeclareClassMetadata({
171
- minVersion: "12.0.0",
172
- version: "21.1.0-rc.0",
173
- ngImport: i0,
174
- type: Field,
175
- decorators: [{
176
- type: Directive,
177
- args: [{
178
- selector: '[field]',
179
- providers: [{
180
- provide: FIELD,
181
- useExisting: Field
182
- }, {
183
- provide: NgControl,
184
- useFactory: () => inject(Field).getOrCreateNgControl()
185
- }]
186
- }]
187
- }],
188
- propDecorators: {
189
- field: [{
190
- type: i0.Input,
191
- args: [{
192
- isSignal: true,
193
- alias: "field",
194
- required: true
195
- }]
196
- }]
197
- }
198
- });
199
-
200
96
  const FORM_FIELD = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'FORM_FIELD' : '');
201
97
  const controlInstructions = {
202
98
  create: __controlCreate,
@@ -211,6 +107,9 @@ class FormField {
211
107
  state = computed(() => this.formField()(), ...(ngDevMode ? [{
212
108
  debugName: "state"
213
109
  }] : []));
110
+ bindingOptions = signal(undefined, ...(ngDevMode ? [{
111
+ debugName: "bindingOptions"
112
+ }] : []));
214
113
  [_CONTROL] = controlInstructions;
215
114
  config = inject(SIGNAL_FORMS_CONFIG, {
216
115
  optional: true
@@ -227,7 +126,11 @@ class FormField {
227
126
  getOrCreateNgControl() {
228
127
  return this.interopNgControl ??= new InteropNgControl(this.state);
229
128
  }
230
- ɵregister() {
129
+ registerAsBinding(bindingOptions) {
130
+ if (untracked(this.bindingOptions)) {
131
+ throw new _RuntimeError(1913, ngDevMode && 'FormField already registered as a binding');
132
+ }
133
+ this.bindingOptions.set(bindingOptions);
231
134
  effect(onCleanup => {
232
135
  const fieldNode = this.state();
233
136
  fieldNode.nodeState.formFieldBindings.update(controls => [...controls, this]);
@@ -238,9 +141,17 @@ class FormField {
238
141
  injector: this.injector
239
142
  });
240
143
  }
144
+ focus() {
145
+ const bindingOptions = untracked(this.bindingOptions);
146
+ if (bindingOptions?.focus) {
147
+ bindingOptions.focus();
148
+ } else {
149
+ this.element.focus();
150
+ }
151
+ }
241
152
  static ɵfac = i0.ɵɵngDeclareFactory({
242
153
  minVersion: "12.0.0",
243
- version: "21.1.0-rc.0",
154
+ version: "21.1.1",
244
155
  ngImport: i0,
245
156
  type: FormField,
246
157
  deps: [],
@@ -248,7 +159,7 @@ class FormField {
248
159
  });
249
160
  static ɵdir = i0.ɵɵngDeclareDirective({
250
161
  minVersion: "17.1.0",
251
- version: "21.1.0-rc.0",
162
+ version: "21.1.1",
252
163
  type: FormField,
253
164
  isStandalone: true,
254
165
  selector: "[formField]",
@@ -273,7 +184,7 @@ class FormField {
273
184
  }
274
185
  i0.ɵɵngDeclareClassMetadata({
275
186
  minVersion: "12.0.0",
276
- version: "21.1.0-rc.0",
187
+ version: "21.1.1",
277
188
  ngImport: i0,
278
189
  type: FormField,
279
190
  decorators: [{
@@ -745,5 +656,5 @@ function debounceForDuration(durationInMilliseconds) {
745
656
  }
746
657
  function immediate() {}
747
658
 
748
- export { EmailValidationError, FIELD, FORM_FIELD, Field, FormField, MAX, MAX_LENGTH, MIN, MIN_LENGTH, MaxLengthValidationError, MaxValidationError, MinLengthValidationError, MinValidationError, NgValidationError, PATTERN, PatternValidationError, REQUIRED, RequiredValidationError, StandardSchemaValidationError, createManagedMetadataKey, createMetadataKey, debounce, disabled, email, emailError, hidden, max, maxError, maxLength, maxLengthError, metadata, min, minError, minLength, minLengthError, pattern, patternError, provideSignalFormsConfig, readonly, required, requiredError, standardSchemaError, validate, validateAsync, validateHttp, validateStandardSchema, validateTree };
659
+ export { EmailValidationError, FORM_FIELD, FormField, MAX, MAX_LENGTH, MIN, MIN_LENGTH, MaxLengthValidationError, MaxValidationError, MinLengthValidationError, MinValidationError, NgValidationError, PATTERN, PatternValidationError, REQUIRED, RequiredValidationError, StandardSchemaValidationError, createManagedMetadataKey, createMetadataKey, debounce, disabled, email, emailError, hidden, max, maxError, maxLength, maxLengthError, metadata, min, minError, minLength, minLengthError, pattern, patternError, provideSignalFormsConfig, readonly, required, requiredError, standardSchemaError, validate, validateAsync, validateHttp, validateStandardSchema, validateTree };
749
660
  //# sourceMappingURL=signals.mjs.map