mirror of
https://github.com/LukeHagar/form.git
synced 2025-12-06 12:27:45 +00:00
fix: UserChange/InputProps
This commit is contained in:
@@ -10,19 +10,19 @@
|
|||||||
"children": [
|
"children": [
|
||||||
{
|
{
|
||||||
"label": "Overview",
|
"label": "Overview",
|
||||||
"to": "core/overview"
|
"to": "overview"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Installation",
|
"label": "Installation",
|
||||||
"to": "core/installation"
|
"to": "installation"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Comparison",
|
"label": "Comparison",
|
||||||
"to": "core/comparison"
|
"to": "comparison"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "TypeScript",
|
"label": "TypeScript",
|
||||||
"to": "core/typescript"
|
"to": "typescript"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
"children": [
|
"children": [
|
||||||
{
|
{
|
||||||
"label": "Important Defaults",
|
"label": "Important Defaults",
|
||||||
"to": "core/guides/important-defaults"
|
"to": "guides/important-defaults"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -40,11 +40,11 @@
|
|||||||
"children": [
|
"children": [
|
||||||
{
|
{
|
||||||
"label": "FormApi",
|
"label": "FormApi",
|
||||||
"to": "core/reference/formApi"
|
"to": "reference/formApi"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "FieldApi",
|
"label": "FieldApi",
|
||||||
"to": "core/reference/fieldApi"
|
"to": "reference/fieldApi"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,9 +110,9 @@ A class representing the API for managing a form field.
|
|||||||
- Gets a subfield instance.
|
- Gets a subfield instance.
|
||||||
- `validate(): Promise<any>`
|
- `validate(): Promise<any>`
|
||||||
- Validates the field value.
|
- Validates the field value.
|
||||||
- `getChangeProps<T extends ChangeProps<any>>(props: T = {} as T): ChangeProps<TData> & Omit<T, keyof ChangeProps<TData>>`
|
- `getChangeProps<T extends UserChangeProps<any>>(props: T = {} as T): ChangeProps<TData> & Omit<T, keyof ChangeProps<TData>>`
|
||||||
- Gets the change and blur event handlers.
|
- Gets the change and blur event handlers.
|
||||||
- `getInputProps<T extends InputProps>(props: T = {} as T): InputProps & Omit<T, keyof InputProps>`
|
- `getInputProps<T extends UserInputProps>(props: T = {} as T): InputProps & Omit<T, keyof InputProps>`
|
||||||
- Gets the input event handlers.
|
- Gets the input event handlers.
|
||||||
|
|
||||||
### `FieldState<TData>`
|
### `FieldState<TData>`
|
||||||
@@ -124,6 +124,24 @@ An object type representing the state of a field.
|
|||||||
- `meta: FieldMeta`
|
- `meta: FieldMeta`
|
||||||
- The current metadata of the field.
|
- The current metadata of the field.
|
||||||
|
|
||||||
|
### `UserChangeProps<TData>`
|
||||||
|
|
||||||
|
An object type representing the change and blur event handlers for a field.
|
||||||
|
|
||||||
|
- `onChange?: (updater: Updater<TData>) => void`
|
||||||
|
- An optional function to further handle the change event.
|
||||||
|
- `onBlur?: (event: any) => void`
|
||||||
|
- An optional function to further handle the blur event.
|
||||||
|
|
||||||
|
### `UserInputProps`
|
||||||
|
|
||||||
|
An object type representing the input event handlers for a field.
|
||||||
|
|
||||||
|
- `onChange?: (event: any) => void`
|
||||||
|
- An optional function to further handle the change event.
|
||||||
|
- `onBlur?: (event: any) => void`
|
||||||
|
- An optional function to further handle the blur event.
|
||||||
|
|
||||||
### `ChangeProps<TData>`
|
### `ChangeProps<TData>`
|
||||||
|
|
||||||
An object type representing the change and blur event handlers for a field.
|
An object type representing the change and blur event handlers for a field.
|
||||||
@@ -31,16 +31,28 @@ export type FieldMeta = {
|
|||||||
isValidating: boolean
|
isValidating: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ChangeProps<TData> = {
|
export type UserChangeProps<TData> = {
|
||||||
onChange?: (updater: Updater<TData>) => void
|
onChange?: (updater: Updater<TData>) => void
|
||||||
onBlur?: (event: any) => void
|
onBlur?: (event: any) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
export type InputProps = {
|
export type UserInputProps = {
|
||||||
onChange?: (event: any) => void
|
onChange?: (event: any) => void
|
||||||
onBlur?: (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<
|
export type FieldApiOptions<TData, TFormData> = RequiredByKey<
|
||||||
FieldOptions<TData, TFormData>,
|
FieldOptions<TData, TFormData>,
|
||||||
'form'
|
'form'
|
||||||
@@ -332,7 +344,7 @@ export class FieldApi<TData, TFormData> {
|
|||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
getChangeProps = <T extends ChangeProps<any>>(
|
getChangeProps = <T extends UserChangeProps<any>>(
|
||||||
props: T = {} as T,
|
props: T = {} as T,
|
||||||
): ChangeProps<TData> & Omit<T, keyof ChangeProps<TData>> => {
|
): ChangeProps<TData> & Omit<T, keyof ChangeProps<TData>> => {
|
||||||
return {
|
return {
|
||||||
@@ -350,7 +362,7 @@ export class FieldApi<TData, TFormData> {
|
|||||||
} as ChangeProps<TData> & Omit<T, keyof ChangeProps<TData>>
|
} as ChangeProps<TData> & Omit<T, keyof ChangeProps<TData>>
|
||||||
}
|
}
|
||||||
|
|
||||||
getInputProps = <T extends InputProps>(
|
getInputProps = <T extends UserInputProps>(
|
||||||
props: T = {} as T,
|
props: T = {} as T,
|
||||||
): InputProps & Omit<T, keyof InputProps> => {
|
): InputProps & Omit<T, keyof InputProps> => {
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user