@@ -22,19 +22,19 @@ export interface FieldConfig<V = any> {
22
22
* Field component to render. Can either be a string like 'select' or a component.
23
23
*/
24
24
component ?:
25
- | string
26
- | React . ComponentType < FieldProps < V > >
27
- | React . ComponentType
28
- | React . ForwardRefExoticComponent < any > ;
25
+ | string
26
+ | React . ComponentType < FieldProps < V > >
27
+ | React . ComponentType
28
+ | React . ForwardRefExoticComponent < any > ;
29
29
30
30
/**
31
31
* Component to render. Can either be a string e.g. 'select', 'input', or 'textarea', or a component.
32
32
*/
33
33
as ?:
34
- | React . ComponentType < FieldProps < V > [ 'field' ] >
35
- | string
36
- | React . ComponentType
37
- | React . ForwardRefExoticComponent < any > ;
34
+ | React . ComponentType < FieldProps < V > [ 'field' ] >
35
+ | string
36
+ | React . ComponentType
37
+ | React . ForwardRefExoticComponent < any > ;
38
38
39
39
/**
40
40
* Render prop (works like React router's <Route render={props =>} />)
@@ -72,9 +72,11 @@ export interface FieldConfig<V = any> {
72
72
innerRef ?: ( instance : any ) => void ;
73
73
}
74
74
75
- export type FieldAttributes < T > = GenericFieldHTMLAttributes &
75
+ export type FieldAttributes < T > = { className ?: string ; } & GenericFieldHTMLAttributes &
76
76
FieldConfig < T > &
77
- T & { name : string } ;
77
+ T & {
78
+ name : string ,
79
+ } ;
78
80
79
81
export type FieldHookConfig < T > = GenericFieldHTMLAttributes & FieldConfig < T > ;
80
82
@@ -139,6 +141,7 @@ export function Field({
139
141
children,
140
142
as : is , // `as` is reserved in typescript lol
141
143
component,
144
+ className,
142
145
...props
143
146
} : FieldAttributes < any > ) {
144
147
const {
@@ -202,14 +205,14 @@ export function Field({
202
205
const { innerRef, ...rest } = props ;
203
206
return React . createElement (
204
207
component ,
205
- { ref : innerRef , ...field , ...rest } ,
208
+ { ref : innerRef , ...field , ...rest , className } ,
206
209
children
207
210
) ;
208
211
}
209
212
// We don't pass `meta` for backwards compat
210
213
return React . createElement (
211
214
component ,
212
- { field, form : formik , ...props } ,
215
+ { field, form : formik , ...props , className } ,
213
216
children
214
217
) ;
215
218
}
@@ -221,10 +224,10 @@ export function Field({
221
224
const { innerRef, ...rest } = props ;
222
225
return React . createElement (
223
226
asElement ,
224
- { ref : innerRef , ...field , ...rest } ,
227
+ { ref : innerRef , ...field , ...rest , className } ,
225
228
children
226
229
) ;
227
230
}
228
231
229
- return React . createElement ( asElement , { ...field , ...props } , children ) ;
232
+ return React . createElement ( asElement , { ...field , ...props , className } , children ) ;
230
233
}
0 commit comments