@tanstack/form-core
Advanced tools
Comparing version 0.30.0 to 0.32.0
@@ -145,2 +145,6 @@ import { Store } from '@tanstack/store'; | ||
/** | ||
* A flag indicating whether the field has been blurred. | ||
*/ | ||
isBlurred: boolean; | ||
/** | ||
* A flag that is `true` if the field's value has not been modified by the user. Opposite of `isDirty`. | ||
@@ -147,0 +151,0 @@ */ |
@@ -76,2 +76,3 @@ import { Store } from "@tanstack/store"; | ||
isTouched: false, | ||
isBlurred: false, | ||
isDirty: false, | ||
@@ -306,2 +307,5 @@ isPristine: true, | ||
} | ||
if (!this.state.meta.isBlurred) { | ||
this.setMeta((prev) => ({ ...prev, isBlurred: true })); | ||
} | ||
this.validate("blur"); | ||
@@ -322,2 +326,3 @@ }; | ||
isTouched: false, | ||
isBlurred: false, | ||
isDirty: false, | ||
@@ -324,0 +329,0 @@ isPristine: true, |
@@ -189,2 +189,6 @@ import { Store } from '@tanstack/store'; | ||
/** | ||
* A boolean indicating if any of the form fields have been blurred. | ||
*/ | ||
isBlurred: boolean; | ||
/** | ||
* A boolean indicating if any of the form's fields' values have been modified by the user. `True` if the user have modified at least one of the fields. Opposite of `isPristine`. | ||
@@ -191,0 +195,0 @@ */ |
@@ -17,2 +17,3 @@ import { Store } from "@tanstack/store"; | ||
isTouched: defaultState.isTouched ?? false, | ||
isBlurred: defaultState.isBlurred ?? false, | ||
isPristine: defaultState.isPristine ?? true, | ||
@@ -106,2 +107,5 @@ isDirty: defaultState.isDirty ?? false, | ||
} | ||
if (!field.instance.state.meta.isBlurred) { | ||
field.instance.setMeta((prev) => ({ ...prev, isBlurred: true })); | ||
} | ||
}); | ||
@@ -140,2 +144,5 @@ }); | ||
} | ||
if (!fieldInstance.state.meta.isBlurred) { | ||
fieldInstance.setMeta((prev) => ({ ...prev, isBlurred: true })); | ||
} | ||
return fieldInstance.validate(cause); | ||
@@ -390,2 +397,3 @@ }; | ||
isTouched: false, | ||
isBlurred: false, | ||
isDirty: false, | ||
@@ -408,2 +416,3 @@ isPristine: true, | ||
isTouched: true, | ||
isBlurred: true, | ||
isDirty: true | ||
@@ -531,2 +540,3 @@ })); | ||
const isTouched = fieldMetaValues.some((field) => field == null ? void 0 : field.isTouched); | ||
const isBlurred = fieldMetaValues.some((field) => field == null ? void 0 : field.isBlurred); | ||
const isDirty = fieldMetaValues.some((field) => field == null ? void 0 : field.isDirty); | ||
@@ -549,2 +559,3 @@ const isPristine = !isDirty; | ||
isTouched, | ||
isBlurred, | ||
isPristine, | ||
@@ -551,0 +562,0 @@ isDirty |
{ | ||
"name": "@tanstack/form-core", | ||
"version": "0.30.0", | ||
"version": "0.32.0", | ||
"description": "Powerful, type-safe, framework agnostic forms.", | ||
@@ -5,0 +5,0 @@ "author": "tannerlinsley", |
@@ -339,2 +339,6 @@ import { Store } from '@tanstack/store' | ||
/** | ||
* A flag indicating whether the field has been blurred. | ||
*/ | ||
isBlurred: boolean | ||
/** | ||
* A flag that is `true` if the field's value has not been modified by the user. Opposite of `isDirty`. | ||
@@ -460,2 +464,3 @@ */ | ||
isTouched: false, | ||
isBlurred: false, | ||
isDirty: false, | ||
@@ -630,2 +635,3 @@ isPristine: true, | ||
isTouched: false, | ||
isBlurred: false, | ||
isDirty: false, | ||
@@ -1007,2 +1013,5 @@ isPristine: true, | ||
} | ||
if (!this.state.meta.isBlurred) { | ||
this.setMeta((prev) => ({ ...prev, isBlurred: true })) | ||
} | ||
this.validate('blur') | ||
@@ -1009,0 +1018,0 @@ } |
@@ -263,2 +263,6 @@ import { Store } from '@tanstack/store' | ||
/** | ||
* A boolean indicating if any of the form fields have been blurred. | ||
*/ | ||
isBlurred: boolean | ||
/** | ||
* A boolean indicating if any of the form's fields' values have been modified by the user. `True` if the user have modified at least one of the fields. Opposite of `isPristine`. | ||
@@ -309,2 +313,3 @@ */ | ||
isTouched: defaultState.isTouched ?? false, | ||
isBlurred: defaultState.isBlurred ?? false, | ||
isPristine: defaultState.isPristine ?? true, | ||
@@ -393,2 +398,3 @@ isDirty: defaultState.isDirty ?? false, | ||
const isTouched = fieldMetaValues.some((field) => field?.isTouched) | ||
const isBlurred = fieldMetaValues.some((field) => field?.isBlurred) | ||
@@ -416,2 +422,3 @@ const isDirty = fieldMetaValues.some((field) => field?.isDirty) | ||
isTouched, | ||
isBlurred, | ||
isPristine, | ||
@@ -560,2 +567,8 @@ isDirty, | ||
} | ||
// If any fields are not blurred | ||
if (!field.instance.state.meta.isBlurred) { | ||
// Mark them as blurred | ||
field.instance.setMeta((prev) => ({ ...prev, isBlurred: true })) | ||
} | ||
}) | ||
@@ -624,2 +637,8 @@ }) | ||
// If the field is not blurred (same logic as in validateAllFields) | ||
if (!fieldInstance.state.meta.isBlurred) { | ||
// Mark it as blurred | ||
fieldInstance.setMeta((prev) => ({ ...prev, isBlurred: true })) | ||
} | ||
return fieldInstance.validate(cause) | ||
@@ -992,2 +1011,3 @@ } | ||
isTouched: false, | ||
isBlurred: false, | ||
isDirty: false, | ||
@@ -1019,2 +1039,3 @@ isPristine: true, | ||
isTouched: true, | ||
isBlurred: true, | ||
isDirty: true, | ||
@@ -1021,0 +1042,0 @@ })) |
@@ -1,2 +0,2 @@ | ||
import { type DeepKeys } from './util-types' | ||
import type { DeepKeys } from './util-types' | ||
@@ -3,0 +3,0 @@ export type ValidationError = undefined | false | null | string |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
456774
6080