mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-06 06:19:58 +08:00
Modify injected Field input prop change function arguments
Add tests for input prop
This commit is contained in:
19
types/redux-form/lib/Field.d.ts
vendored
19
types/redux-form/lib/Field.d.ts
vendored
@@ -16,13 +16,21 @@ export type Formatter = (value: any, name: string) => any;
|
||||
export type Parser = (value: any, name: string) => any;
|
||||
export type Validator = (value: any, allValues?: any, props?: any) => any;
|
||||
|
||||
interface EventHandler<Event> {
|
||||
(event: Event): void;
|
||||
}
|
||||
|
||||
interface EventOrValueHandler<Event> extends EventHandler<Event> {
|
||||
(value: any): void;
|
||||
}
|
||||
|
||||
interface CommonFieldProps {
|
||||
name: string;
|
||||
onBlur: EventOrValueHandler<FocusEvent<any>>;
|
||||
onChange: EventOrValueHandler<ChangeEvent<any>>;
|
||||
onDragStart: EventOrValueHandler<DragEvent<any>>;
|
||||
onDrop: EventOrValueHandler<DragEvent<any>>;
|
||||
onFocus: EventOrValueHandler<FocusEvent<any>>;
|
||||
onDragStart: EventHandler<DragEvent<any>>;
|
||||
onDrop: EventHandler<DragEvent<any>>;
|
||||
onFocus: EventHandler<FocusEvent<any>>;
|
||||
}
|
||||
|
||||
interface BaseFieldProps<P = {}> extends Partial<CommonFieldProps> {
|
||||
@@ -60,11 +68,6 @@ interface WrappedFieldProps {
|
||||
meta: WrappedFieldMetaProps;
|
||||
}
|
||||
|
||||
interface EventOrValueHandler<Event> {
|
||||
(event: Event): void;
|
||||
(value: any, newValue: any, previousValue: any): void;
|
||||
}
|
||||
|
||||
interface WrappedFieldInputProps extends CommonFieldProps {
|
||||
checked?: boolean;
|
||||
value: any;
|
||||
|
||||
@@ -96,7 +96,20 @@ const MyField: StatelessComponent<MyFieldProps> = ({
|
||||
children,
|
||||
input,
|
||||
meta
|
||||
}) => null;
|
||||
}) => {
|
||||
input.onBlur("value");
|
||||
input.onBlur({} as React.SyntheticEvent<HTMLDivElement>);
|
||||
|
||||
input.onChange("value");
|
||||
input.onChange({} as React.SyntheticEvent<HTMLDivElement>);
|
||||
|
||||
input.onDragStart({} as React.DragEvent<HTMLDivElement>);
|
||||
|
||||
input.onDrop({} as React.DragEvent<HTMLDivElement>);
|
||||
|
||||
input.onFocus({} as React.FocusEvent<HTMLDivElement>);
|
||||
return null;
|
||||
};
|
||||
const FieldCustom = Field as new () => GenericField<MyFieldCustomProps>;
|
||||
|
||||
const MyFieldImm: StatelessComponent<MyFieldProps> = ({
|
||||
|
||||
Reference in New Issue
Block a user