@@ -5,6 +5,7 @@ import { AnyObject } from './any-object';
55import { FieldInputProps } from 'react-final-form' ;
66import { FormOptions } from '../renderer-context' ;
77import { Meta } from '../use-field-api' ;
8+ import ComponentMapper , { ComponentPropsMap } from './component-mapper' ;
89
910export type FieldAction = [ string , ...any [ ] ] ;
1011
@@ -23,7 +24,46 @@ export type ResolvePropsFunction<FormValues = Record<string, any>, FieldValue =
2324 formOptions : FormOptions < FormValues >
2425) => AnyObject ;
2526
26- interface Field < FormValues = Record < string , any > , FieldValue = FormValues [ keyof FormValues ] > extends AnyObject {
27+ // Re-export BaseFieldProps from use-field-api for consistency
28+ export { BaseFieldProps } from '../use-field-api' ;
29+
30+ // Strict base field properties for generic type inference (without AnyObject)
31+ export interface StrictBaseFieldProps < FormValues = Record < string , any > , FieldValue = FormValues [ keyof FormValues ] > {
32+ name : string ;
33+ label ?: string ;
34+ helperText ?: string ;
35+ description ?: string ;
36+ isRequired ?: boolean ;
37+ isDisabled ?: boolean ;
38+ isReadOnly ?: boolean ;
39+ isVisible ?: boolean ;
40+ hideField ?: boolean ;
41+ validate ?: Validator [ ] ;
42+ condition ?: ConditionDefinition | ConditionDefinition [ ] ;
43+ initializeOnMount ?: boolean ;
44+ dataType ?: DataType ;
45+ initialValue ?: FieldValue ;
46+ clearedValue ?: FieldValue ;
47+ clearOnUnmount ?: boolean ;
48+ actions ?: FieldActions ;
49+ resolveProps ?: ResolvePropsFunction < FormValues , FieldValue > ;
50+ }
51+
52+ // Utility type for users to create typed field component props without AnyObject
53+ export type TypedFieldProps < P = { } > = StrictBaseFieldProps & P ;
54+
55+ // Generic field type that infers component-specific props from any ComponentMapper
56+ export type Field <
57+ T extends ComponentMapper = ComponentMapper ,
58+ C extends keyof T = keyof T ,
59+ FormValues = Record < string , any > ,
60+ FieldValue = FormValues [ keyof FormValues ]
61+ > = StrictBaseFieldProps < FormValues , FieldValue > & {
62+ component : C ;
63+ } & ComponentPropsMap < T > [ C ] ;
64+
65+ // For backward compatibility - preserve the original interface
66+ interface LegacyField < FormValues = Record < string , any > , FieldValue = FormValues [ keyof FormValues ] > extends AnyObject {
2767 name : string ;
2868 component : string ;
2969 validate ?: Validator [ ] ;
@@ -37,4 +77,5 @@ interface Field<FormValues = Record<string, any>, FieldValue = FormValues[keyof
3777 resolveProps ?: ResolvePropsFunction < FormValues , FieldValue > ;
3878}
3979
40- export default Field ;
80+ // Export the backward-compatible version as default for existing code
81+ export default LegacyField ;
0 commit comments