@angular/forms 21.0.0-next.3 → 21.0.0-next.5

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.0.0-next.3
2
+ * @license Angular v21.0.0-next.5
3
3
  * (c) 2010-2025 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -1072,6 +1072,7 @@ function assertPathIsCurrent(path) {
1072
1072
  * Represents a property that may be defined on a field when it is created using a `property` rule
1073
1073
  * in the schema. A particular `Property` can only be defined on a particular field **once**.
1074
1074
  *
1075
+ * @category logic
1075
1076
  * @experimental 21.0.0
1076
1077
  */
1077
1078
  class Property {
@@ -1175,36 +1176,42 @@ function andProperty() {
1175
1176
  /**
1176
1177
  * An aggregate property representing whether the field is required.
1177
1178
  *
1179
+ * @category validation
1178
1180
  * @experimental 21.0.0
1179
1181
  */
1180
1182
  const REQUIRED = orProperty();
1181
1183
  /**
1182
1184
  * An aggregate property representing the min value of the field.
1183
1185
  *
1186
+ * @category validation
1184
1187
  * @experimental 21.0.0
1185
1188
  */
1186
1189
  const MIN = maxProperty();
1187
1190
  /**
1188
1191
  * An aggregate property representing the max value of the field.
1189
1192
  *
1193
+ * @category validation
1190
1194
  * @experimental 21.0.0
1191
1195
  */
1192
1196
  const MAX = minProperty();
1193
1197
  /**
1194
1198
  * An aggregate property representing the min length of the field.
1195
1199
  *
1200
+ * @category validation
1196
1201
  * @experimental 21.0.0
1197
1202
  */
1198
1203
  const MIN_LENGTH = maxProperty();
1199
1204
  /**
1200
1205
  * An aggregate property representing the max length of the field.
1201
1206
  *
1207
+ * @category validation
1202
1208
  * @experimental 21.0.0
1203
1209
  */
1204
1210
  const MAX_LENGTH = minProperty();
1205
1211
  /**
1206
1212
  * An aggregate property representing the patterns the field must match.
1207
1213
  *
1214
+ * @category validation
1208
1215
  * @experimental 21.0.0
1209
1216
  */
1210
1217
  const PATTERN = listProperty();
@@ -1219,6 +1226,7 @@ const PATTERN = listProperty();
1219
1226
  * @template TValue The type of value stored in the field the logic is bound to.
1220
1227
  * @template TPathKind The kind of path the logic is bound to (a root path, child path, or item of an array)
1221
1228
  *
1229
+ * @category logic
1222
1230
  * @experimental 21.0.0
1223
1231
  */
1224
1232
  function disabled(path, logic) {
@@ -1247,6 +1255,7 @@ function disabled(path, logic) {
1247
1255
  * @template TValue The type of value stored in the field the logic is bound to.
1248
1256
  * @template TPathKind The kind of path the logic is bound to (a root path, child path, or item of an array)
1249
1257
  *
1258
+ * @category logic
1250
1259
  * @experimental 21.0.0
1251
1260
  */
1252
1261
  function readonly(path, logic = () => true) {
@@ -1271,6 +1280,7 @@ function readonly(path, logic = () => true) {
1271
1280
  * @template TValue The type of value stored in the field the logic is bound to.
1272
1281
  * @template TPathKind The kind of path the logic is bound to (a root path, child path, or item of an array)
1273
1282
  *
1283
+ * @category logic
1274
1284
  * @experimental 21.0.0
1275
1285
  */
1276
1286
  function hidden(path, logic) {
@@ -1286,6 +1296,7 @@ function hidden(path, logic) {
1286
1296
  * @template TValue The type of value stored in the field the logic is bound to.
1287
1297
  * @template TPathKind The kind of path the logic is bound to (a root path, child path, or item of an array)
1288
1298
  *
1299
+ * @category logic
1289
1300
  * @experimental 21.0.0
1290
1301
  */
1291
1302
  function validate(path, logic) {
@@ -1302,6 +1313,7 @@ function validate(path, logic) {
1302
1313
  * @template TValue The type of value stored in the field the logic is bound to.
1303
1314
  * @template TPathKind The kind of path the logic is bound to (a root path, child path, or item of an array)
1304
1315
  *
1316
+ * @category logic
1305
1317
  * @experimental 21.0.0
1306
1318
  */
1307
1319
  function validateTree(path, logic) {
@@ -1319,6 +1331,7 @@ function validateTree(path, logic) {
1319
1331
  * @template TPropItem The type of value the property aggregates over.
1320
1332
  * @template TPathKind The kind of path the logic is bound to (a root path, child path, or item of an array)
1321
1333
  *
1334
+ * @category logic
1322
1335
  * @experimental 21.0.0
1323
1336
  */
1324
1337
  function aggregateProperty(path, prop, logic) {
@@ -1353,6 +1366,7 @@ function property(path, ...rest) {
1353
1366
  * @template TResult The type of result returned by the resource
1354
1367
  * @template TPathKind The kind of path being validated (a root path, child path, or item of an array)
1355
1368
  *
1369
+ * @category validation
1356
1370
  * @experimental 21.0.0
1357
1371
  */
1358
1372
  function validateAsync(path, opts) {
@@ -1400,6 +1414,7 @@ function validateAsync(path, opts) {
1400
1414
  * @template TResult The type of result returned by the httpResource
1401
1415
  * @template TPathKind The kind of path being validated (a root path, child path, or item of an array)
1402
1416
  *
1417
+ * @category validation
1403
1418
  * @experimental 21.0.0
1404
1419
  */
1405
1420
  function validateHttp(path, opts) {
@@ -1542,6 +1557,7 @@ function isInputSignal(value) {
1542
1557
  * forms `NgControl`. This is provided to improve interoperability with controls designed to work
1543
1558
  * with reactive forms. It should not be used by controls written for signal forms.
1544
1559
  *
1560
+ * @category control
1545
1561
  * @experimental 21.0.0
1546
1562
  */
1547
1563
  class Control {
@@ -1857,15 +1873,15 @@ class Control {
1857
1873
  }
1858
1874
  };
1859
1875
  }
1860
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.0-next.3", ngImport: i0, type: Control, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1861
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.0.0-next.3", type: Control, isStandalone: true, selector: "[control]", inputs: { _field: ["control", "_field"] }, providers: [
1876
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.0-next.5", ngImport: i0, type: Control, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1877
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.0.0-next.5", type: Control, isStandalone: true, selector: "[control]", inputs: { _field: ["control", "_field"] }, providers: [
1862
1878
  {
1863
1879
  provide: NgControl,
1864
1880
  useFactory: () => inject(Control).ngControl,
1865
1881
  },
1866
1882
  ], ngImport: i0 });
1867
1883
  }
1868
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.0-next.3", ngImport: i0, type: Control, decorators: [{
1884
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.0-next.5", ngImport: i0, type: Control, decorators: [{
1869
1885
  type: Directive,
1870
1886
  args: [{
1871
1887
  selector: '[control]',
@@ -2619,14 +2635,12 @@ class FieldNodeState {
2619
2635
  * Marks this specific field as touched.
2620
2636
  */
2621
2637
  markAsTouched() {
2622
- // TODO: should this be noop for fields that are hidden/disabled/readonly
2623
2638
  this.selfTouched.set(true);
2624
2639
  }
2625
2640
  /**
2626
2641
  * Marks this specific field as dirty.
2627
2642
  */
2628
2643
  markAsDirty() {
2629
- // TODO: should this be noop for fields that are hidden/disabled/readonly
2630
2644
  this.selfDirty.set(true);
2631
2645
  }
2632
2646
  /**
@@ -2650,20 +2664,24 @@ class FieldNodeState {
2650
2664
  * Whether this field is considered dirty.
2651
2665
  *
2652
2666
  * A field is considered dirty if one of the following is true:
2653
- * - It was directly dirtied
2667
+ * - It was directly dirtied and is interactive
2654
2668
  * - One of its children is considered dirty
2655
2669
  */
2656
2670
  dirty = computed(() => {
2657
- return reduceChildren(this.node, this.selfDirty(), (child, value) => value || child.nodeState.dirty(), shortCircuitTrue);
2671
+ const selfDirtyValue = this.selfDirty() && !this.isNonInteractive();
2672
+ return reduceChildren(this.node, selfDirtyValue, (child, value) => value || child.nodeState.dirty(), shortCircuitTrue);
2658
2673
  }, ...(ngDevMode ? [{ debugName: "dirty" }] : []));
2659
2674
  /**
2660
2675
  * Whether this field is considered touched.
2661
2676
  *
2662
2677
  * A field is considered touched if one of the following is true:
2663
- * - It was directly touched
2678
+ * - It was directly touched and is interactive
2664
2679
  * - One of its children is considered touched
2665
2680
  */
2666
- touched = computed(() => reduceChildren(this.node, this.selfTouched(), (child, value) => value || child.nodeState.touched(), shortCircuitTrue), ...(ngDevMode ? [{ debugName: "touched" }] : []));
2681
+ touched = computed(() => {
2682
+ const selfTouchedValue = this.selfTouched() && !this.isNonInteractive();
2683
+ return reduceChildren(this.node, selfTouchedValue, (child, value) => value || child.nodeState.touched(), shortCircuitTrue);
2684
+ }, ...(ngDevMode ? [{ debugName: "touched" }] : []));
2667
2685
  /**
2668
2686
  * The reasons for this field's disablement. This includes disabled reasons for any parent field
2669
2687
  * that may have been disabled, indirectly causing this field to be disabled as well.
@@ -2709,6 +2727,14 @@ class FieldNodeState {
2709
2727
  }
2710
2728
  return `${parent.name()}.${this.node.structure.keyInParent()}`;
2711
2729
  }, ...(ngDevMode ? [{ debugName: "name" }] : []));
2730
+ /** Whether this field is considered non-interactive.
2731
+ *
2732
+ * A field is considered non-interactive if one of the following is true:
2733
+ * - It is hidden
2734
+ * - It is disabled
2735
+ * - It is readonly
2736
+ */
2737
+ isNonInteractive = computed(() => this.hidden() || this.disabled() || this.readonly(), ...(ngDevMode ? [{ debugName: "isNonInteractive" }] : []));
2712
2738
  }
2713
2739
 
2714
2740
  /**
@@ -2890,6 +2916,7 @@ function form(...args) {
2890
2916
  * element of the array.
2891
2917
  * @template TValue The data type of the item field to apply the schema to.
2892
2918
  *
2919
+ * @category structure
2893
2920
  * @experimental 21.0.0
2894
2921
  */
2895
2922
  function applyEach(path, schema) {
@@ -2915,6 +2942,7 @@ function applyEach(path, schema) {
2915
2942
  * @param schema The schema to apply to the property
2916
2943
  * @template TValue The data type of the field to apply the schema to.
2917
2944
  *
2945
+ * @category structure
2918
2946
  * @experimental 21.0.0
2919
2947
  */
2920
2948
  function apply(path, schema) {
@@ -2930,6 +2958,7 @@ function apply(path, schema) {
2930
2958
  * @param schema The schema to apply to the field when the `logic` function returns `true`.
2931
2959
  * @template TValue The data type of the field to apply the schema to.
2932
2960
  *
2961
+ * @category structure
2933
2962
  * @experimental 21.0.0
2934
2963
  */
2935
2964
  function applyWhen(path, logic, schema) {
@@ -2971,6 +3000,7 @@ function applyWhenValue(path, predicate, schema) {
2971
3000
  * errors.
2972
3001
  * @template TValue The data type of the field being submitted.
2973
3002
  *
3003
+ * @category submission
2974
3004
  * @experimental 21.0.0
2975
3005
  */
2976
3006
  async function submit(form, action) {
@@ -3020,6 +3050,7 @@ function setServerErrors(submittedField, errors) {
3020
3050
  * @returns A schema object that implements the given logic.
3021
3051
  * @template TValue The value type of a `Field` that this schema binds to.
3022
3052
  *
3053
+ * @category structure
3023
3054
  * @experimental 21.0.0
3024
3055
  */
3025
3056
  function schema(fn) {
@@ -3063,6 +3094,7 @@ function customError(obj) {
3063
3094
  /**
3064
3095
  * A custom error that may contain additional properties
3065
3096
  *
3097
+ * @category validation
3066
3098
  * @experimental 21.0.0
3067
3099
  */
3068
3100
  class CustomValidationError {
@@ -3104,6 +3136,7 @@ class _NgValidationError {
3104
3136
  /**
3105
3137
  * An error used to indicate that a required field is empty.
3106
3138
  *
3139
+ * @category validation
3107
3140
  * @experimental 21.0.0
3108
3141
  */
3109
3142
  class RequiredValidationError extends _NgValidationError {
@@ -3112,6 +3145,7 @@ class RequiredValidationError extends _NgValidationError {
3112
3145
  /**
3113
3146
  * An error used to indicate that a value is lower than the minimum allowed.
3114
3147
  *
3148
+ * @category validation
3115
3149
  * @experimental 21.0.0
3116
3150
  */
3117
3151
  class MinValidationError extends _NgValidationError {
@@ -3125,6 +3159,7 @@ class MinValidationError extends _NgValidationError {
3125
3159
  /**
3126
3160
  * An error used to indicate that a value is higher than the maximum allowed.
3127
3161
  *
3162
+ * @category validation
3128
3163
  * @experimental 21.0.0
3129
3164
  */
3130
3165
  class MaxValidationError extends _NgValidationError {
@@ -3138,6 +3173,7 @@ class MaxValidationError extends _NgValidationError {
3138
3173
  /**
3139
3174
  * An error used to indicate that a value is shorter than the minimum allowed length.
3140
3175
  *
3176
+ * @category validation
3141
3177
  * @experimental 21.0.0
3142
3178
  */
3143
3179
  class MinLengthValidationError extends _NgValidationError {
@@ -3151,6 +3187,7 @@ class MinLengthValidationError extends _NgValidationError {
3151
3187
  /**
3152
3188
  * An error used to indicate that a value is longer than the maximum allowed length.
3153
3189
  *
3190
+ * @category validation
3154
3191
  * @experimental 21.0.0
3155
3192
  */
3156
3193
  class MaxLengthValidationError extends _NgValidationError {
@@ -3164,6 +3201,7 @@ class MaxLengthValidationError extends _NgValidationError {
3164
3201
  /**
3165
3202
  * An error used to indicate that a value does not match the required pattern.
3166
3203
  *
3204
+ * @category validation
3167
3205
  * @experimental 21.0.0
3168
3206
  */
3169
3207
  class PatternValidationError extends _NgValidationError {
@@ -3177,6 +3215,7 @@ class PatternValidationError extends _NgValidationError {
3177
3215
  /**
3178
3216
  * An error used to indicate that a value is not a valid email.
3179
3217
  *
3218
+ * @category validation
3180
3219
  * @experimental 21.0.0
3181
3220
  */
3182
3221
  class EmailValidationError extends _NgValidationError {
@@ -3185,6 +3224,7 @@ class EmailValidationError extends _NgValidationError {
3185
3224
  /**
3186
3225
  * An error used to indicate an issue validating against a standard schema.
3187
3226
  *
3227
+ * @category validation
3188
3228
  * @experimental 21.0.0
3189
3229
  */
3190
3230
  class StandardSchemaValidationError extends _NgValidationError {
@@ -3217,6 +3257,7 @@ class StandardSchemaValidationError extends _NgValidationError {
3217
3257
  * }
3218
3258
  * ```
3219
3259
  *
3260
+ * @category validation
3220
3261
  * @experimental 21.0.0
3221
3262
  */
3222
3263
  const NgValidationError = _NgValidationError;
@@ -3288,6 +3329,7 @@ const EMAIL_REGEXP = /^(?=.{1,254}$)(?=.{1,64}@)[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(
3288
3329
  * or a function that receives the `FieldContext` and returns custom validation error(s).
3289
3330
  * @template TPathKind The kind of path the logic is bound to (a root path, child path, or item of an array)
3290
3331
  *
3332
+ * @category validation
3291
3333
  * @experimental 21.0.0
3292
3334
  */
3293
3335
  function email(path, config) {
@@ -3320,6 +3362,7 @@ function email(path, config) {
3320
3362
  * or a function that receives the `FieldContext` and returns custom validation error(s).
3321
3363
  * @template TPathKind The kind of path the logic is bound to (a root path, child path, or item of an array)
3322
3364
  *
3365
+ * @category validation
3323
3366
  * @experimental 21.0.0
3324
3367
  */
3325
3368
  function max(path, maxValue, config) {
@@ -3359,6 +3402,7 @@ function max(path, maxValue, config) {
3359
3402
  * @template TValue The type of value stored in the field the logic is bound to.
3360
3403
  * @template TPathKind The kind of path the logic is bound to (a root path, child path, or item of an array)
3361
3404
  *
3405
+ * @category validation
3362
3406
  * @experimental 21.0.0
3363
3407
  */
3364
3408
  function maxLength(path, maxLength, config) {
@@ -3397,6 +3441,7 @@ function maxLength(path, maxLength, config) {
3397
3441
  * or a function that receives the `FieldContext` and returns custom validation error(s).
3398
3442
  * @template TPathKind The kind of path the logic is bound to (a root path, child path, or item of an array)
3399
3443
  *
3444
+ * @category validation
3400
3445
  * @experimental 21.0.0
3401
3446
  */
3402
3447
  function min(path, minValue, config) {
@@ -3436,6 +3481,7 @@ function min(path, minValue, config) {
3436
3481
  * @template TValue The type of value stored in the field the logic is bound to.
3437
3482
  * @template TPathKind The kind of path the logic is bound to (a root path, child path, or item of an array)
3438
3483
  *
3484
+ * @category validation
3439
3485
  * @experimental 21.0.0
3440
3486
  */
3441
3487
  function minLength(path, minLength, config) {
@@ -3473,6 +3519,7 @@ function minLength(path, minLength, config) {
3473
3519
  * or a function that receives the `FieldContext` and returns custom validation error(s).
3474
3520
  * @template TPathKind The kind of path the logic is bound to (a root path, child path, or item of an array)
3475
3521
  *
3522
+ * @category validation
3476
3523
  * @experimental 21.0.0
3477
3524
  */
3478
3525
  function pattern(path, pattern, config) {
@@ -3512,6 +3559,7 @@ function pattern(path, pattern, config) {
3512
3559
  * @template TValue The type of value stored in the field the logic is bound to.
3513
3560
  * @template TPathKind The kind of path the logic is bound to (a root path, child path, or item of an array)
3514
3561
  *
3562
+ * @category validation
3515
3563
  * @experimental 21.0.0
3516
3564
  */
3517
3565
  function required(path, config) {
@@ -3541,6 +3589,7 @@ function required(path, config) {
3541
3589
  * or a partial of it.
3542
3590
  * @template TValue The type of value stored in the field being validated.
3543
3591
  *
3592
+ * @category validation
3544
3593
  * @experimental 21.0.0
3545
3594
  */
3546
3595
  function validateStandardSchema(path, schema) {