mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-03-29 08:58:23 +08:00
Redux form onChange onBlur fix (#22989)
* Fix onChange and onBlur parameters * Add semicolon * Fix definition
This commit is contained in:
16
types/redux-form/lib/Field.d.ts
vendored
16
types/redux-form/lib/Field.d.ts
vendored
@@ -17,20 +17,24 @@ export type Parser = (value: any, name: string) => any;
|
||||
export type Validator = (value: any, allValues?: any, props?: any) => any;
|
||||
|
||||
export type EventHandler<Event> = (event: Event) => void;
|
||||
export type EventWithDataHandler<Event> = (event?: Event, newValue?: any, previousValue?: any) => void;
|
||||
|
||||
export interface EventOrValueHandler<Event> extends EventHandler<Event> {
|
||||
(value: any): void;
|
||||
}
|
||||
|
||||
export interface CommonFieldProps {
|
||||
export interface CommonFieldInputProps {
|
||||
name: string;
|
||||
onBlur: EventOrValueHandler<FocusEvent<any>>;
|
||||
onChange: EventOrValueHandler<ChangeEvent<any>>;
|
||||
onDragStart: EventHandler<DragEvent<any>>;
|
||||
onDrop: EventHandler<DragEvent<any>>;
|
||||
onFocus: EventHandler<FocusEvent<any>>;
|
||||
}
|
||||
|
||||
export interface CommonFieldProps extends CommonFieldInputProps {
|
||||
onBlur: EventWithDataHandler<FocusEvent<any>>;
|
||||
onChange: EventWithDataHandler<ChangeEvent<any>>;
|
||||
}
|
||||
|
||||
export interface BaseFieldProps<P = {}> extends Partial<CommonFieldProps> {
|
||||
name: string;
|
||||
label?: string;
|
||||
@@ -57,7 +61,7 @@ export type GenericFieldHTMLAttributes =
|
||||
SelectHTMLAttributes<HTMLSelectElement> |
|
||||
TextareaHTMLAttributes<HTMLTextAreaElement>;
|
||||
|
||||
export class Field<P = GenericFieldHTMLAttributes> extends Component<BaseFieldProps<P> & P> implements GenericField<P> {
|
||||
export class Field<P = GenericFieldHTMLAttributes | BaseFieldProps> extends Component<BaseFieldProps<P> & P> {
|
||||
dirty: boolean;
|
||||
name: string;
|
||||
pristine: boolean;
|
||||
@@ -70,9 +74,11 @@ export interface WrappedFieldProps {
|
||||
meta: WrappedFieldMetaProps;
|
||||
}
|
||||
|
||||
export interface WrappedFieldInputProps extends CommonFieldProps {
|
||||
export interface WrappedFieldInputProps extends CommonFieldInputProps {
|
||||
checked?: boolean;
|
||||
value: any;
|
||||
onBlur: EventOrValueHandler<FocusEvent<any>>;
|
||||
onChange: EventOrValueHandler<ChangeEvent<any>>;
|
||||
}
|
||||
|
||||
export interface WrappedFieldMetaProps {
|
||||
|
||||
@@ -265,6 +265,13 @@ const Test = reduxForm<TestFormData>({
|
||||
component="select"
|
||||
/>
|
||||
|
||||
<Field
|
||||
name="field4"
|
||||
component="input"
|
||||
onChange={(event, newValue, previousValue) => {}}
|
||||
onBlur={(event, newValue, previousValue) => {}}
|
||||
/>
|
||||
|
||||
<ImmutableField
|
||||
name="field3im"
|
||||
component="select"
|
||||
|
||||
Reference in New Issue
Block a user