@angular/forms 21.2.0-next.2 → 21.2.0-next.3
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 → _validation_errors-chunk.mjs} +86 -81
- package/fesm2022/_validation_errors-chunk.mjs.map +1 -0
- package/fesm2022/forms.mjs +170 -189
- package/fesm2022/forms.mjs.map +1 -1
- package/fesm2022/signals-compat.mjs +7 -7
- package/fesm2022/signals-compat.mjs.map +1 -1
- package/fesm2022/signals.mjs +967 -856
- 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 +277 -255
- package/types/forms.d.ts +1 -1
- package/types/signals-compat.d.ts +1 -1
- package/types/signals.d.ts +106 -12
- package/fesm2022/_structure-chunk.mjs.map +0 -1
package/types/signals.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v21.2.0-next.
|
|
2
|
+
* @license Angular v21.2.0-next.3
|
|
3
3
|
* (c) 2010-2026 Google LLC. https://angular.dev/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
|
|
7
|
+
import * as i0 from '@angular/core';
|
|
8
|
+
import { Signal, ResourceRef, InputSignal, InputSignalWithTransform, ModelSignal, OutputRef, WritableSignal } from '@angular/core';
|
|
9
|
+
import { PathKind, SchemaPath, SchemaPathRules, LogicFn, OneOrMany, ValidationError, FieldValidator, FieldContext, TreeValidationResult, TreeValidator, WithOptionalFieldTree, DisabledReason, Debouncer, FieldTree } from './_structure-chunk.js';
|
|
10
|
+
export { AsyncValidationResult, BaseNgValidationError, ChildFieldContext, CompatFieldState, CompatSchemaPath, EmailValidationError, FORM_FIELD, FieldState, FormField, FormFieldBindingOptions, FormOptions, FormSubmitOptions, IgnoreUnknownProperties, ItemFieldContext, ItemType, MAX, MAX_LENGTH, MIN, MIN_LENGTH, MaxLengthValidationError, MaxValidationError, MaybeFieldTree, MaybeSchemaPathTree, MetadataKey, MetadataReducer, MetadataSetterType, MinLengthValidationError, MinValidationError, NgValidationError, PATTERN, PatternValidationError, REQUIRED, ReadonlyArrayLike, RemoveStringIndexUnknownKey, RequiredValidationError, RootFieldContext, Schema, SchemaFn, SchemaOrSchemaFn, SchemaPathTree, SignalFormsConfig, StandardSchemaValidationError, Subfields, ValidationErrorOptions, ValidationResult, ValidationSuccess, Validator, WithField, WithFieldTree, WithOptionalField, WithoutField, WithoutFieldTree, apply, applyEach, applyWhen, applyWhenValue, createManagedMetadataKey, createMetadataKey, emailError, form, maxError, maxLengthError, metadata, minError, minLengthError, patternError, provideSignalFormsConfig, requiredError, schema, standardSchemaError, submit, validateStandardSchema, ɵNgFieldDirective } from './_structure-chunk.js';
|
|
10
11
|
import { HttpResourceRequest, HttpResourceOptions } from '@angular/common/http';
|
|
11
12
|
import '@angular/forms';
|
|
12
13
|
import '@standard-schema/spec';
|
|
@@ -469,12 +470,6 @@ interface FormUiControl<TValue> {
|
|
|
469
470
|
* will automatically bind the value patterns from the bound field to this input.
|
|
470
471
|
*/
|
|
471
472
|
readonly pattern?: InputSignal<readonly RegExp[]> | InputSignalWithTransform<readonly RegExp[], unknown>;
|
|
472
|
-
/**
|
|
473
|
-
* A signal containing the current parse errors for the control.
|
|
474
|
-
* This allows the control to communicate to the form that there are additional validation errors
|
|
475
|
-
* beyond those produced by the schema, due to being unable to parse the user's input.
|
|
476
|
-
*/
|
|
477
|
-
readonly parseErrors?: Signal<ValidationError.WithoutFieldTree[]>;
|
|
478
473
|
/**
|
|
479
474
|
* Focuses the UI control.
|
|
480
475
|
*
|
|
@@ -548,5 +543,104 @@ interface FormCheckboxControl extends FormUiControl<boolean> {
|
|
|
548
543
|
*/
|
|
549
544
|
declare function debounce<TValue, TPathKind extends PathKind = PathKind.Root>(path: SchemaPath<TValue, SchemaPathRules.Supported, TPathKind>, durationOrDebouncer: number | Debouncer<TValue, TPathKind>): void;
|
|
550
545
|
|
|
551
|
-
|
|
552
|
-
|
|
546
|
+
/**
|
|
547
|
+
* Options for `transformedValue`.
|
|
548
|
+
*
|
|
549
|
+
* @experimental 21.2.0
|
|
550
|
+
*/
|
|
551
|
+
interface TransformedValueOptions<TValue, TRaw> {
|
|
552
|
+
/**
|
|
553
|
+
* Parse the raw value into the model value.
|
|
554
|
+
*
|
|
555
|
+
* Should return an object containing the parsed result, which may contain:
|
|
556
|
+
* - `value`: The parsed model value. If `undefined`, the model will not be updated.
|
|
557
|
+
* - `errors`: Any parse errors encountered. If `undefined`, no errors are reported.
|
|
558
|
+
*/
|
|
559
|
+
parse: (rawValue: TRaw) => {
|
|
560
|
+
value?: TValue;
|
|
561
|
+
errors?: readonly ValidationError.WithoutFieldTree[];
|
|
562
|
+
};
|
|
563
|
+
/**
|
|
564
|
+
* Format the model value into the raw value.
|
|
565
|
+
*/
|
|
566
|
+
format: (value: TValue) => TRaw;
|
|
567
|
+
}
|
|
568
|
+
/**
|
|
569
|
+
* A writable signal representing a "raw" UI value that is synchronized with a model signal
|
|
570
|
+
* via parse/format transformations.
|
|
571
|
+
*
|
|
572
|
+
* @category control
|
|
573
|
+
* @experimental 21.2.0
|
|
574
|
+
*/
|
|
575
|
+
interface TransformedValueSignal<TRaw> extends WritableSignal<TRaw> {
|
|
576
|
+
/**
|
|
577
|
+
* The current parse errors resulting from the last transformation.
|
|
578
|
+
*/
|
|
579
|
+
readonly parseErrors: Signal<readonly ValidationError.WithoutFieldTree[]>;
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* Creates a writable signal representing a "raw" UI value that is transformed to/from a model
|
|
583
|
+
* value via `parse` and `format` functions.
|
|
584
|
+
*
|
|
585
|
+
* This utility simplifies the creation of custom form controls that parse a user-facing value
|
|
586
|
+
* representation into an underlying model value. For example, a numeric input that displays and
|
|
587
|
+
* accepts string values but stores a number.
|
|
588
|
+
*
|
|
589
|
+
* @param value The model signal to synchronize with.
|
|
590
|
+
* @param options Configuration including `parse` and `format` functions.
|
|
591
|
+
* @returns A `TransformedValueSignal` representing the raw value with parse error tracking.
|
|
592
|
+
* @experimental 21.2.0
|
|
593
|
+
*
|
|
594
|
+
* @example
|
|
595
|
+
* ```ts
|
|
596
|
+
* @Component({
|
|
597
|
+
* selector: 'number-input',
|
|
598
|
+
* template: `<input [value]="rawValue()" (input)="rawValue.set($event.target.value)" />`,
|
|
599
|
+
* })
|
|
600
|
+
* export class NumberInput implements FormValueControl<number | null> {
|
|
601
|
+
* readonly value = model.required<number | null>();
|
|
602
|
+
*
|
|
603
|
+
* protected readonly rawValue = transformedValue(this.value, {
|
|
604
|
+
* parse: (val) => {
|
|
605
|
+
* if (val === '') return {value: null};
|
|
606
|
+
* const num = Number(val);
|
|
607
|
+
* if (Number.isNaN(num)) {
|
|
608
|
+
* return {errors: [{kind: 'parse', message: `${val} is not numeric`}]};
|
|
609
|
+
* }
|
|
610
|
+
* return {value: num};
|
|
611
|
+
* },
|
|
612
|
+
* format: (val) => val?.toString() ?? '',
|
|
613
|
+
* });
|
|
614
|
+
* }
|
|
615
|
+
* ```
|
|
616
|
+
*/
|
|
617
|
+
declare function transformedValue<TValue, TRaw>(value: ModelSignal<TValue>, options: TransformedValueOptions<TValue, TRaw>): TransformedValueSignal<TRaw>;
|
|
618
|
+
|
|
619
|
+
/**
|
|
620
|
+
* A directive that binds a `FieldTree` to a `<form>` element.
|
|
621
|
+
*
|
|
622
|
+
* It automatically:
|
|
623
|
+
* 1. Sets `novalidate` on the form element to disable browser validation.
|
|
624
|
+
* 2. Listens for the `submit` event, prevents the default behavior, and calls `submit()` on the
|
|
625
|
+
* `FieldTree`.
|
|
626
|
+
*
|
|
627
|
+
* @usageNotes
|
|
628
|
+
*
|
|
629
|
+
* ```html
|
|
630
|
+
* <form [formRoot]="myFieldTree">
|
|
631
|
+
* ...
|
|
632
|
+
* </form>
|
|
633
|
+
* ```
|
|
634
|
+
*
|
|
635
|
+
* @publicApi
|
|
636
|
+
* @experimental 21.0.0
|
|
637
|
+
*/
|
|
638
|
+
declare class FormRoot<T> {
|
|
639
|
+
readonly fieldTree: i0.InputSignal<FieldTree<T>>;
|
|
640
|
+
protected onSubmit(event: Event): void;
|
|
641
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<FormRoot<any>, never>;
|
|
642
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<FormRoot<any>, "form[formRoot]", never, { "fieldTree": { "alias": "formRoot"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
export { Debouncer, DisabledReason, FieldContext, FieldTree, FieldValidator, FormRoot, LogicFn, OneOrMany, PathKind, SchemaPath, SchemaPathRules, TreeValidationResult, TreeValidator, ValidationError, WithOptionalFieldTree, debounce, disabled, email, hidden, max, maxLength, min, minLength, pattern, readonly, required, transformedValue, validate, validateAsync, validateHttp, validateTree };
|
|
646
|
+
export type { AsyncValidatorOptions, FormCheckboxControl, FormUiControl, FormValueControl, HttpValidatorOptions, MapToErrorsFn, TransformedValueOptions, TransformedValueSignal };
|