@angular/forms 21.0.6 → 21.0.8
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 +14 -14
- package/fesm2022/_structure-chunk.mjs.map +1 -1
- package/fesm2022/forms.mjs +132 -131
- package/fesm2022/forms.mjs.map +1 -1
- package/fesm2022/signals-compat.mjs +1 -1
- package/fesm2022/signals.mjs +147 -66
- package/fesm2022/signals.mjs.map +1 -1
- package/package.json +4 -4
- package/types/_structure-chunk.d.ts +69 -58
- package/types/forms.d.ts +25 -8
- package/types/signals-compat.d.ts +1 -1
- package/types/signals.d.ts +154 -144
package/fesm2022/signals.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v21.0.
|
|
2
|
+
* @license Angular v21.0.8
|
|
3
3
|
* (c) 2010-2025 Google LLC. https://angular.dev/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import * as i0 from '@angular/core';
|
|
8
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';
|
|
9
9
|
import { Validators, NG_VALUE_ACCESSOR, NgControl } from '@angular/forms';
|
|
10
|
-
import { assertPathIsCurrent, FieldPathNode,
|
|
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';
|
|
12
12
|
import { httpResource } from '@angular/common/http';
|
|
13
13
|
import '@angular/core/primitives/signals';
|
|
@@ -94,7 +94,7 @@ class InteropNgControl {
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
const FIELD = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'FIELD' : '');
|
|
97
|
-
const controlInstructions = {
|
|
97
|
+
const controlInstructions$1 = {
|
|
98
98
|
create: __controlCreate,
|
|
99
99
|
update: _controlUpdate
|
|
100
100
|
};
|
|
@@ -107,7 +107,7 @@ class Field {
|
|
|
107
107
|
state = computed(() => this.field()(), ...(ngDevMode ? [{
|
|
108
108
|
debugName: "state"
|
|
109
109
|
}] : []));
|
|
110
|
-
[_CONTROL] = controlInstructions;
|
|
110
|
+
[_CONTROL] = controlInstructions$1;
|
|
111
111
|
config = inject(SIGNAL_FORMS_CONFIG, {
|
|
112
112
|
optional: true
|
|
113
113
|
});
|
|
@@ -126,9 +126,9 @@ class Field {
|
|
|
126
126
|
ɵregister() {
|
|
127
127
|
effect(onCleanup => {
|
|
128
128
|
const fieldNode = this.state();
|
|
129
|
-
fieldNode.nodeState.
|
|
129
|
+
fieldNode.nodeState.formFieldBindings.update(controls => [...controls, this]);
|
|
130
130
|
onCleanup(() => {
|
|
131
|
-
fieldNode.nodeState.
|
|
131
|
+
fieldNode.nodeState.formFieldBindings.update(controls => controls.filter(c => c !== this));
|
|
132
132
|
});
|
|
133
133
|
}, {
|
|
134
134
|
injector: this.injector
|
|
@@ -136,7 +136,7 @@ class Field {
|
|
|
136
136
|
}
|
|
137
137
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
138
138
|
minVersion: "12.0.0",
|
|
139
|
-
version: "21.0.
|
|
139
|
+
version: "21.0.8",
|
|
140
140
|
ngImport: i0,
|
|
141
141
|
type: Field,
|
|
142
142
|
deps: [],
|
|
@@ -144,7 +144,7 @@ class Field {
|
|
|
144
144
|
});
|
|
145
145
|
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
146
146
|
minVersion: "17.1.0",
|
|
147
|
-
version: "21.0.
|
|
147
|
+
version: "21.0.8",
|
|
148
148
|
type: Field,
|
|
149
149
|
isStandalone: true,
|
|
150
150
|
selector: "[field]",
|
|
@@ -169,7 +169,7 @@ class Field {
|
|
|
169
169
|
}
|
|
170
170
|
i0.ɵɵngDeclareClassMetadata({
|
|
171
171
|
minVersion: "12.0.0",
|
|
172
|
-
version: "21.0.
|
|
172
|
+
version: "21.0.8",
|
|
173
173
|
ngImport: i0,
|
|
174
174
|
type: Field,
|
|
175
175
|
decorators: [{
|
|
@@ -197,6 +197,110 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
197
197
|
}
|
|
198
198
|
});
|
|
199
199
|
|
|
200
|
+
const FORM_FIELD = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'FORM_FIELD' : '');
|
|
201
|
+
const controlInstructions = {
|
|
202
|
+
create: __controlCreate,
|
|
203
|
+
update: _controlUpdate
|
|
204
|
+
};
|
|
205
|
+
class FormField {
|
|
206
|
+
element = inject(ElementRef).nativeElement;
|
|
207
|
+
injector = inject(Injector);
|
|
208
|
+
formField = input.required(...(ngDevMode ? [{
|
|
209
|
+
debugName: "formField"
|
|
210
|
+
}] : []));
|
|
211
|
+
state = computed(() => this.formField()(), ...(ngDevMode ? [{
|
|
212
|
+
debugName: "state"
|
|
213
|
+
}] : []));
|
|
214
|
+
[_CONTROL] = controlInstructions;
|
|
215
|
+
config = inject(SIGNAL_FORMS_CONFIG, {
|
|
216
|
+
optional: true
|
|
217
|
+
});
|
|
218
|
+
classes = Object.entries(this.config?.classes ?? {}).map(([className, computation]) => [className, computed(() => computation(this))]);
|
|
219
|
+
controlValueAccessors = inject(NG_VALUE_ACCESSOR, {
|
|
220
|
+
optional: true,
|
|
221
|
+
self: true
|
|
222
|
+
});
|
|
223
|
+
interopNgControl;
|
|
224
|
+
get ɵinteropControl() {
|
|
225
|
+
return this.controlValueAccessors?.[0] ?? this.interopNgControl?.valueAccessor ?? undefined;
|
|
226
|
+
}
|
|
227
|
+
getOrCreateNgControl() {
|
|
228
|
+
return this.interopNgControl ??= new InteropNgControl(this.state);
|
|
229
|
+
}
|
|
230
|
+
ɵregister() {
|
|
231
|
+
effect(onCleanup => {
|
|
232
|
+
const fieldNode = this.state();
|
|
233
|
+
fieldNode.nodeState.formFieldBindings.update(controls => [...controls, this]);
|
|
234
|
+
onCleanup(() => {
|
|
235
|
+
fieldNode.nodeState.formFieldBindings.update(controls => controls.filter(c => c !== this));
|
|
236
|
+
});
|
|
237
|
+
}, {
|
|
238
|
+
injector: this.injector
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
242
|
+
minVersion: "12.0.0",
|
|
243
|
+
version: "21.0.8",
|
|
244
|
+
ngImport: i0,
|
|
245
|
+
type: FormField,
|
|
246
|
+
deps: [],
|
|
247
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
248
|
+
});
|
|
249
|
+
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
250
|
+
minVersion: "17.1.0",
|
|
251
|
+
version: "21.0.8",
|
|
252
|
+
type: FormField,
|
|
253
|
+
isStandalone: true,
|
|
254
|
+
selector: "[formField]",
|
|
255
|
+
inputs: {
|
|
256
|
+
formField: {
|
|
257
|
+
classPropertyName: "formField",
|
|
258
|
+
publicName: "formField",
|
|
259
|
+
isSignal: true,
|
|
260
|
+
isRequired: true,
|
|
261
|
+
transformFunction: null
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
providers: [{
|
|
265
|
+
provide: FORM_FIELD,
|
|
266
|
+
useExisting: FormField
|
|
267
|
+
}, {
|
|
268
|
+
provide: NgControl,
|
|
269
|
+
useFactory: () => inject(FormField).getOrCreateNgControl()
|
|
270
|
+
}],
|
|
271
|
+
ngImport: i0
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
275
|
+
minVersion: "12.0.0",
|
|
276
|
+
version: "21.0.8",
|
|
277
|
+
ngImport: i0,
|
|
278
|
+
type: FormField,
|
|
279
|
+
decorators: [{
|
|
280
|
+
type: Directive,
|
|
281
|
+
args: [{
|
|
282
|
+
selector: '[formField]',
|
|
283
|
+
providers: [{
|
|
284
|
+
provide: FORM_FIELD,
|
|
285
|
+
useExisting: FormField
|
|
286
|
+
}, {
|
|
287
|
+
provide: NgControl,
|
|
288
|
+
useFactory: () => inject(FormField).getOrCreateNgControl()
|
|
289
|
+
}]
|
|
290
|
+
}]
|
|
291
|
+
}],
|
|
292
|
+
propDecorators: {
|
|
293
|
+
formField: [{
|
|
294
|
+
type: i0.Input,
|
|
295
|
+
args: [{
|
|
296
|
+
isSignal: true,
|
|
297
|
+
alias: "formField",
|
|
298
|
+
required: true
|
|
299
|
+
}]
|
|
300
|
+
}]
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
|
|
200
304
|
function disabled(path, logic) {
|
|
201
305
|
assertPathIsCurrent(path);
|
|
202
306
|
const pathNode = FieldPathNode.unwrapFieldPath(path);
|
|
@@ -231,6 +335,28 @@ function readonly(path, logic = () => true) {
|
|
|
231
335
|
pathNode.builder.addReadonlyRule(logic);
|
|
232
336
|
}
|
|
233
337
|
|
|
338
|
+
function getLengthOrSize(value) {
|
|
339
|
+
const v = value;
|
|
340
|
+
return typeof v.length === 'number' ? v.length : v.size;
|
|
341
|
+
}
|
|
342
|
+
function getOption(opt, ctx) {
|
|
343
|
+
return opt instanceof Function ? opt(ctx) : opt;
|
|
344
|
+
}
|
|
345
|
+
function isEmpty(value) {
|
|
346
|
+
if (typeof value === 'number') {
|
|
347
|
+
return isNaN(value);
|
|
348
|
+
}
|
|
349
|
+
return value === '' || value === false || value == null;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
function validate(path, logic) {
|
|
353
|
+
assertPathIsCurrent(path);
|
|
354
|
+
const pathNode = FieldPathNode.unwrapFieldPath(path);
|
|
355
|
+
pathNode.builder.addSyncErrorRule(ctx => {
|
|
356
|
+
return addDefaultField(logic(ctx), ctx.fieldTree);
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
|
|
234
360
|
function requiredError(options) {
|
|
235
361
|
return new RequiredValidationError(options);
|
|
236
362
|
}
|
|
@@ -255,20 +381,6 @@ function emailError(options) {
|
|
|
255
381
|
function standardSchemaError(issue, options) {
|
|
256
382
|
return new StandardSchemaValidationError(issue, options);
|
|
257
383
|
}
|
|
258
|
-
function customError(obj) {
|
|
259
|
-
return new CustomValidationError(obj);
|
|
260
|
-
}
|
|
261
|
-
class CustomValidationError {
|
|
262
|
-
__brand = undefined;
|
|
263
|
-
kind = '';
|
|
264
|
-
fieldTree;
|
|
265
|
-
message;
|
|
266
|
-
constructor(options) {
|
|
267
|
-
if (options) {
|
|
268
|
-
Object.assign(this, options);
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
384
|
class _NgValidationError {
|
|
273
385
|
__brand = undefined;
|
|
274
386
|
kind = '';
|
|
@@ -336,46 +448,6 @@ class StandardSchemaValidationError extends _NgValidationError {
|
|
|
336
448
|
}
|
|
337
449
|
const NgValidationError = _NgValidationError;
|
|
338
450
|
|
|
339
|
-
function getLengthOrSize(value) {
|
|
340
|
-
const v = value;
|
|
341
|
-
return typeof v.length === 'number' ? v.length : v.size;
|
|
342
|
-
}
|
|
343
|
-
function getOption(opt, ctx) {
|
|
344
|
-
return opt instanceof Function ? opt(ctx) : opt;
|
|
345
|
-
}
|
|
346
|
-
function isEmpty(value) {
|
|
347
|
-
if (typeof value === 'number') {
|
|
348
|
-
return isNaN(value);
|
|
349
|
-
}
|
|
350
|
-
return value === '' || value === false || value == null;
|
|
351
|
-
}
|
|
352
|
-
function isPlainError(error) {
|
|
353
|
-
return typeof error === 'object' && (Object.getPrototypeOf(error) === Object.prototype || Object.getPrototypeOf(error) === null);
|
|
354
|
-
}
|
|
355
|
-
function ensureCustomValidationError(error) {
|
|
356
|
-
if (isPlainError(error)) {
|
|
357
|
-
return customError(error);
|
|
358
|
-
}
|
|
359
|
-
return error;
|
|
360
|
-
}
|
|
361
|
-
function ensureCustomValidationResult(result) {
|
|
362
|
-
if (result === null || result === undefined) {
|
|
363
|
-
return result;
|
|
364
|
-
}
|
|
365
|
-
if (isArray(result)) {
|
|
366
|
-
return result.map(ensureCustomValidationError);
|
|
367
|
-
}
|
|
368
|
-
return ensureCustomValidationError(result);
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
function validate(path, logic) {
|
|
372
|
-
assertPathIsCurrent(path);
|
|
373
|
-
const pathNode = FieldPathNode.unwrapFieldPath(path);
|
|
374
|
-
pathNode.builder.addSyncErrorRule(ctx => {
|
|
375
|
-
return ensureCustomValidationResult(addDefaultField(logic(ctx), ctx.fieldTree));
|
|
376
|
-
});
|
|
377
|
-
}
|
|
378
|
-
|
|
379
451
|
const EMAIL_REGEXP = /^(?=.{1,254}$)(?=.{1,64}@)[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
|
|
380
452
|
function email(path, config) {
|
|
381
453
|
validate(path, ctx => {
|
|
@@ -657,12 +729,21 @@ function debounce(path, durationOrDebouncer) {
|
|
|
657
729
|
function debounceForDuration(durationInMilliseconds) {
|
|
658
730
|
return (_context, abortSignal) => {
|
|
659
731
|
return new Promise(resolve => {
|
|
660
|
-
|
|
661
|
-
|
|
732
|
+
let timeoutId;
|
|
733
|
+
const onAbort = () => {
|
|
734
|
+
clearTimeout(timeoutId);
|
|
735
|
+
};
|
|
736
|
+
timeoutId = setTimeout(() => {
|
|
737
|
+
abortSignal.removeEventListener('abort', onAbort);
|
|
738
|
+
resolve();
|
|
739
|
+
}, durationInMilliseconds);
|
|
740
|
+
abortSignal.addEventListener('abort', onAbort, {
|
|
741
|
+
once: true
|
|
742
|
+
});
|
|
662
743
|
});
|
|
663
744
|
};
|
|
664
745
|
}
|
|
665
746
|
function immediate() {}
|
|
666
747
|
|
|
667
|
-
export {
|
|
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 };
|
|
668
749
|
//# sourceMappingURL=signals.mjs.map
|