fix: UserChange/InputProps

This commit is contained in:
Tanner Linsley
2023-04-27 13:27:20 -06:00
parent 4e7ff05abe
commit 5b7c6ce55d
14 changed files with 43 additions and 13 deletions

View File

@@ -31,16 +31,28 @@ export type FieldMeta = {
isValidating: boolean
}
export type ChangeProps<TData> = {
export type UserChangeProps<TData> = {
onChange?: (updater: Updater<TData>) => void
onBlur?: (event: any) => void
}
export type InputProps = {
export type UserInputProps = {
onChange?: (event: any) => void
onBlur?: (event: any) => void
}
export type ChangeProps<TData> = {
value: TData
onChange: (updater: Updater<TData>) => void
onBlur: (event: any) => void
}
export type InputProps = {
value: string
onChange: (event: any) => void
onBlur: (event: any) => void
}
export type FieldApiOptions<TData, TFormData> = RequiredByKey<
FieldOptions<TData, TFormData>,
'form'
@@ -332,7 +344,7 @@ export class FieldApi<TData, TFormData> {
return undefined
}
getChangeProps = <T extends ChangeProps<any>>(
getChangeProps = <T extends UserChangeProps<any>>(
props: T = {} as T,
): ChangeProps<TData> & Omit<T, keyof ChangeProps<TData>> => {
return {
@@ -350,7 +362,7 @@ export class FieldApi<TData, TFormData> {
} as ChangeProps<TData> & Omit<T, keyof ChangeProps<TData>>
}
getInputProps = <T extends InputProps>(
getInputProps = <T extends UserInputProps>(
props: T = {} as T,
): InputProps & Omit<T, keyof InputProps> => {
return {