1
1
import React from 'react' ;
2
2
import PropTypes from 'prop-types' ;
3
- import { Validations , RequiredValidation , Value } from './interfaces' ;
3
+ import { RequiredValidation , Validations } from './interfaces' ;
4
4
declare const propTypes : {
5
5
innerRef : PropTypes . Requireable < ( ...args : any [ ] ) => any > ;
6
6
name : PropTypes . Validator < string > ;
7
7
required : PropTypes . Requireable < string | boolean | object > ;
8
8
validations : PropTypes . Requireable < string | object > ;
9
9
value : PropTypes . Requireable < any > ;
10
10
} ;
11
- export interface WrapperProps {
11
+ export interface WrapperProps < V > {
12
12
innerRef ?: ( ref : any ) => void ;
13
13
name : string ;
14
- required ?: RequiredValidation ;
14
+ required ?: RequiredValidation < V > ;
15
15
validationError ?: any ;
16
16
validationErrors ?: any ;
17
- validations ?: Validations | string ;
18
- value ?: Value ;
17
+ validations ?: Validations < V > ;
18
+ value ?: V ;
19
19
}
20
- export interface WrapperState {
20
+ export interface WrapperState < V > {
21
21
[ key : string ] : unknown ;
22
22
externalError : null ;
23
23
formSubmitted : boolean ;
@@ -26,9 +26,9 @@ export interface WrapperState {
26
26
isValid : boolean ;
27
27
pristineValue : any ;
28
28
validationError : any [ ] ;
29
- value : any ;
29
+ value : V ;
30
30
}
31
- export interface PassDownProps extends WrapperProps {
31
+ export interface InjectedProps < V > {
32
32
errorMessage : any ;
33
33
errorMessages : any ;
34
34
hasValue : boolean ;
@@ -37,13 +37,14 @@ export interface PassDownProps extends WrapperProps {
37
37
isPristine : boolean ;
38
38
isRequired : boolean ;
39
39
isValid : boolean ;
40
- isValidValue : ( value : Value ) => boolean ;
40
+ isValidValue : ( value : V ) => boolean ;
41
41
ref ?: any ;
42
42
resetValue : any ;
43
43
setValidations : any ;
44
- setValue : ( value : Value ) => void ;
44
+ setValue : ( value : V ) => void ;
45
45
showError : boolean ;
46
46
showRequired : boolean ;
47
47
}
48
+ export declare type PassDownProps < V > = WrapperProps < V > & InjectedProps < V > ;
48
49
export { propTypes } ;
49
- export default function < T > ( WrappedComponent : React . ComponentType < T & PassDownProps > ) : React . ComponentType < T & WrapperProps > ;
50
+ export default function < T , V > ( WrappedComponent : React . ComponentType < T & PassDownProps < V > > ) : React . ComponentType < Omit < T & WrapperProps < V > , keyof InjectedProps < V > > > ;
0 commit comments