checkpoint

This commit is contained in:
Tanner Linsley
2023-04-25 16:16:54 -06:00
parent 63c400737a
commit 4fc3e7ce6c
4 changed files with 26 additions and 17 deletions

View File

@@ -1,5 +1,6 @@
{
"name": "form",
"private": true,
"repository": "https://github.com/tanstack/form.git",
"scripts": {
"nx-reset": "nx reset",

View File

@@ -1,7 +1,7 @@
{
"name": "@tanstack/form-core",
"version": "4.29.5",
"description": "The framework agnostic core that powers TanStack Form",
"version": "0.0.1",
"description": "Powerful, type-safe, framework agnostic forms.",
"author": "tannerlinsley",
"license": "MIT",
"repository": "tanstack/form",
@@ -15,8 +15,7 @@
"module": "build/esm/index.js",
"sideEffects": false,
"files": [
"build/lib/*",
"build/umd/*",
"build/**",
"src"
],
"scripts": {

View File

@@ -12,16 +12,20 @@ export type FieldOptions<TData, TFormData> = {
validate?: (
value: TData,
fieldApi: FieldApi<TData, TFormData>,
) => ValidationError
validateAsync?: (
value: TData,
fieldApi: FieldApi<TData, TFormData>,
) => ValidationError | Promise<ValidationError>
validatePristine?: boolean
validatePristine?: boolean // Default: false
validateOn?: ValidateOn // Default: 'change'
validateAsyncOn?: ValidateOn // Default: 'blur'
validateAsyncDebounceMs?: number
filterValue?: (value: TData) => TData
defaultMeta?: Partial<FieldMeta>
change?: boolean
blur?: boolean
submit?: boolean
validateUntouched?: boolean // Default: false
validateOn?: ValidateOn // Default: 'change'
validateAsyncOn?: ValidateOn // Default: 'blur'
}
export type FieldMeta = {
@@ -148,7 +152,12 @@ export class FieldApi<TData, TFormData> {
}
update = (opts: FieldApiOptions<TData, TFormData>) => {
this.options = { validateOn: 'change', validateAsyncOn: 'blur', ...opts }
this.options = {
validateOn: 'change',
validateAsyncOn: 'blur',
validateAsyncDebounceMs: 0,
...opts,
}
// Default Value
if (
@@ -191,7 +200,7 @@ export class FieldApi<TData, TFormData> {
form: this.form,
})
validate = async () => {
#validate = async (isAsync: boolean) => {
if (!this.options.validate) {
return
}
@@ -251,6 +260,9 @@ export class FieldApi<TData, TFormData> {
return this.getInfo().validationPromise
}
validate = () => this.#validate(false)
validateAsync = () => this.#validate(true)
getChangeProps = <T extends ChangeProps<any>>(
props: T = {} as T,
): ChangeProps<TData> & Omit<T, keyof ChangeProps<TData>> => {

View File

@@ -1,7 +1,7 @@
{
"name": "@tanstack/react-form",
"version": "4.29.5",
"description": "Hooks for managing form state in React",
"version": "0.0.1",
"description": "Powerful, type-safe forms for React.",
"author": "tannerlinsley",
"license": "MIT",
"repository": "tanstack/form",
@@ -13,9 +13,7 @@
"types": "build/types/index.d.ts",
"main": "build/cjs/index.js",
"module": "build/esm/index.js",
"sideEffects": [
"./src/setBatchUpdatesFn.ts"
],
"sideEffects": false,
"scripts": {
"clean": "rimraf ./build",
"test:eslint": "eslint --ext .ts,.tsx ./src",
@@ -25,8 +23,7 @@
"build:types": "tsc --build"
},
"files": [
"build/lib/*",
"build/umd/*",
"build/**",
"src"
],
"devDependencies": {