@tanstack/form-core
Advanced tools
Comparing version 0.14.0 to 0.16.0
@@ -45,2 +45,4 @@ import { Store } from '@tanstack/store'; | ||
isTouched: boolean; | ||
isPristine: boolean; | ||
isDirty: boolean; | ||
touchedErrors: ValidationError[]; | ||
@@ -47,0 +49,0 @@ errors: ValidationError[]; |
@@ -74,2 +74,4 @@ import { Store } from "@tanstack/store"; | ||
isTouched: false, | ||
isDirty: false, | ||
isPristine: true, | ||
touchedErrors: [], | ||
@@ -228,2 +230,4 @@ errors: [], | ||
isTouched: false, | ||
isDirty: false, | ||
isPristine: true, | ||
touchedErrors: [], | ||
@@ -242,2 +246,3 @@ errors: [], | ||
state.meta.touchedErrors = state.meta.isTouched ? state.meta.errors : []; | ||
state.meta.isPristine = !state.meta.isDirty; | ||
this.prevState = state; | ||
@@ -244,0 +249,0 @@ this.state = state; |
@@ -69,2 +69,4 @@ import { Store } from '@tanstack/store'; | ||
isTouched: boolean; | ||
isDirty: boolean; | ||
isPristine: boolean; | ||
isSubmitted: boolean; | ||
@@ -71,0 +73,0 @@ isValidating: boolean; |
@@ -17,2 +17,4 @@ import { Store } from "@tanstack/store"; | ||
isTouched: defaultState.isTouched ?? false, | ||
isPristine: defaultState.isPristine ?? true, | ||
isDirty: defaultState.isDirty ?? false, | ||
isValid: defaultState.isValid ?? false, | ||
@@ -299,3 +301,4 @@ isValidating: defaultState.isValidating ?? false, | ||
...prev, | ||
isTouched: true | ||
isTouched: true, | ||
isDirty: true | ||
})); | ||
@@ -374,2 +377,4 @@ } | ||
const isTouched = fieldMetaValues.some((field) => field == null ? void 0 : field.isTouched); | ||
const isDirty = fieldMetaValues.some((field) => field == null ? void 0 : field.isDirty); | ||
const isPristine = !isDirty; | ||
const isValidating = isFieldsValidating || state.isFormValidating; | ||
@@ -389,3 +394,5 @@ state.errors = Object.values(state.errorMap).filter( | ||
canSubmit, | ||
isTouched | ||
isTouched, | ||
isPristine, | ||
isDirty | ||
}; | ||
@@ -392,0 +399,0 @@ this.state = state; |
{ | ||
"name": "@tanstack/form-core", | ||
"version": "0.14.0", | ||
"version": "0.16.0", | ||
"description": "Powerful, type-safe, framework agnostic forms.", | ||
@@ -5,0 +5,0 @@ "author": "tannerlinsley", |
@@ -235,2 +235,4 @@ import { Store } from '@tanstack/store' | ||
isTouched: boolean | ||
isPristine: boolean | ||
isDirty: boolean | ||
touchedErrors: ValidationError[] | ||
@@ -304,2 +306,4 @@ errors: ValidationError[] | ||
isTouched: false, | ||
isDirty: false, | ||
isPristine: true, | ||
touchedErrors: [], | ||
@@ -323,2 +327,4 @@ errors: [], | ||
state.meta.isPristine = !state.meta.isDirty | ||
this.prevState = state | ||
@@ -454,2 +460,4 @@ this.state = state | ||
isTouched: false, | ||
isDirty: false, | ||
isPristine: true, | ||
touchedErrors: [], | ||
@@ -456,0 +464,0 @@ errors: [], |
@@ -132,2 +132,4 @@ import { Store } from '@tanstack/store' | ||
isTouched: boolean | ||
isDirty: boolean | ||
isPristine: boolean | ||
isSubmitted: boolean | ||
@@ -156,2 +158,4 @@ isValidating: boolean | ||
isTouched: defaultState.isTouched ?? false, | ||
isPristine: defaultState.isPristine ?? true, | ||
isDirty: defaultState.isDirty ?? false, | ||
isValid: defaultState.isValid ?? false, | ||
@@ -213,2 +217,5 @@ isValidating: defaultState.isValidating ?? false, | ||
const isDirty = fieldMetaValues.some((field) => field?.isDirty) | ||
const isPristine = !isDirty | ||
const isValidating = isFieldsValidating || state.isFormValidating | ||
@@ -232,2 +239,4 @@ state.errors = Object.values(state.errorMap).filter( | ||
isTouched, | ||
isPristine, | ||
isDirty, | ||
} | ||
@@ -632,2 +641,3 @@ | ||
isTouched: true, | ||
isDirty: true, | ||
})) | ||
@@ -634,0 +644,0 @@ } |
@@ -49,2 +49,4 @@ import { describe, expect, it, vi } from 'vitest' | ||
isValidating: false, | ||
isPristine: true, | ||
isDirty: false, | ||
touchedErrors: [], | ||
@@ -61,3 +63,3 @@ errors: [], | ||
name: 'name', | ||
defaultMeta: { isTouched: true }, | ||
defaultMeta: { isTouched: true, isDirty: true, isPristine: false }, | ||
}) | ||
@@ -68,2 +70,4 @@ | ||
isValidating: false, | ||
isDirty: true, | ||
isPristine: false, | ||
touchedErrors: [], | ||
@@ -70,0 +74,0 @@ errors: [], |
@@ -24,2 +24,4 @@ import { describe, expect, it, vi } from 'vitest' | ||
isTouched: false, | ||
isPristine: true, | ||
isDirty: false, | ||
isValid: true, | ||
@@ -59,2 +61,4 @@ isValidating: false, | ||
isTouched: false, | ||
isPristine: true, | ||
isDirty: false, | ||
isValid: true, | ||
@@ -92,2 +96,4 @@ isValidating: false, | ||
isTouched: false, | ||
isPristine: true, | ||
isDirty: false, | ||
isValid: true, | ||
@@ -136,2 +142,4 @@ isValidating: false, | ||
isTouched: false, | ||
isPristine: true, | ||
isDirty: false, | ||
isValid: true, | ||
@@ -177,2 +185,4 @@ isValidating: false, | ||
isTouched: false, | ||
isPristine: true, | ||
isDirty: false, | ||
isValid: true, | ||
@@ -212,2 +222,36 @@ isValidating: false, | ||
it("should be dirty after a field's value has been set", () => { | ||
const form = new FormApi({ | ||
defaultValues: { | ||
name: 'test', | ||
}, | ||
}) | ||
form.mount() | ||
form.setFieldValue('name', 'other', { touch: true }) | ||
expect(form.state.isDirty).toBe(true) | ||
expect(form.state.isPristine).toBe(false) | ||
}) | ||
it('should be clean again after being reset from a dirty state', () => { | ||
const form = new FormApi({ | ||
defaultValues: { | ||
name: 'test', | ||
}, | ||
}) | ||
form.mount() | ||
form.setFieldMeta('name', (meta) => ({ | ||
...meta, | ||
isDirty: true, | ||
isPristine: false, | ||
})) | ||
form.reset() | ||
expect(form.state.isDirty).toBe(false) | ||
expect(form.state.isPristine).toBe(true) | ||
}) | ||
it("should push an array field's value", () => { | ||
@@ -214,0 +258,0 @@ const form = new FormApi({ |
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
342660
5654