1
- // Type definitions for react-use-form-state 0.1
1
+ // Type definitions for react-use-form-state 0.2
2
2
// Project: https://github.com/wsmd/react-use-form-state
3
3
// Definitions by: Waseem Dahman <https://github.com/wsmd>
4
4
@@ -7,47 +7,43 @@ export function useFormState<
7
7
> ( initialState ?: T ) : [ FormState < T > , Inputs ] ;
8
8
9
9
interface FormState < T > {
10
- values : FormStateValues < T > ;
11
- validity : FormStateValidations < T > ;
12
- touched : FormStateValidations < T > ;
10
+ values : InputValues < T > ;
11
+ validity : InputValuesValidity < T > ;
12
+ touched : InputValuesValidity < T > ;
13
13
}
14
14
15
15
interface Inputs {
16
- select ( name : string ) : Omit < SharedInputProps , 'type' > ;
17
- email ( name : string ) : SharedInputProps ;
18
- color ( name : string ) : SharedInputProps ;
19
- password ( name : string ) : SharedInputProps ;
20
- text ( name : string ) : SharedInputProps ;
21
- url ( name : string ) : SharedInputProps ;
22
- search ( name : string ) : SharedInputProps ;
23
- number ( name : string ) : SharedInputProps ;
24
- range ( name : string ) : SharedInputProps ;
25
- tel ( name : string ) : SharedInputProps ;
26
- radio ( name : string , value : string ) : SharedInputProps & CheckedProp ;
27
- checkbox ( name : string , value : string ) : SharedInputProps & CheckedProp ;
28
- date ( name : string ) : SharedInputProps ;
29
- month ( name : string ) : SharedInputProps ;
30
- week ( name : string ) : SharedInputProps ;
31
- time ( name : string ) : SharedInputProps ;
16
+ select ( name : string ) : Omit < InputProps , 'type' > ;
17
+ email ( name : string ) : InputProps ;
18
+ color ( name : string ) : InputProps ;
19
+ password ( name : string ) : InputProps ;
20
+ text ( name : string ) : InputProps ;
21
+ url ( name : string ) : InputProps ;
22
+ search ( name : string ) : InputProps ;
23
+ number ( name : string ) : InputProps ;
24
+ range ( name : string ) : InputProps ;
25
+ tel ( name : string ) : InputProps ;
26
+ radio ( name : string , value : string ) : InputProps & CheckedProp ;
27
+ checkbox ( name : string , value : string ) : InputProps & CheckedProp ;
28
+ date ( name : string ) : InputProps ;
29
+ month ( name : string ) : InputProps ;
30
+ week ( name : string ) : InputProps ;
31
+ time ( name : string ) : InputProps ;
32
32
}
33
33
34
34
type Maybe < T > = T | void ;
35
35
36
36
type Omit < T , K extends keyof T > = Pick < T , Exclude < keyof T , K > > ;
37
37
38
- type FormStateValues < T > = { readonly [ A in keyof T ] : T [ A ] } & {
38
+ type InputValues < T > = { readonly [ A in keyof T ] : T [ A ] } & {
39
39
readonly [ key : string ] : Maybe < string | string [ ] > ;
40
40
} ;
41
41
42
- type FormStateValidations < T > = { readonly [ A in keyof T ] : Maybe < boolean > } & {
42
+ type InputValuesValidity < T > = { readonly [ A in keyof T ] : Maybe < boolean > } & {
43
43
readonly [ key : string ] : Maybe < boolean > ;
44
44
} ;
45
45
46
- interface TypeProp {
47
- type : string ;
48
- }
49
-
50
- interface SharedInputProps {
46
+ interface InputProps {
51
47
onChange ( e : any ) : void ;
52
48
onBlur ( e : any ) : void ;
53
49
value : string ;
0 commit comments