11import arrayMutators from 'final-form-arrays' ;
2- import createFocusDecorator from 'final-form- focus' ;
2+ import createFocusDecorator from './ focus-decorator ' ;
33import React , { useCallback , useMemo , useRef , useState , cloneElement , ReactNode , ComponentType , FunctionComponent , ReactElement } from 'react' ;
44import { FormProps } from 'react-final-form' ;
55import { FormApi } from 'final-form' ;
66
77import defaultSchemaValidator from '../default-schema-validator' ;
88import defaultValidatorMapper from '../validator-mapper' ;
99import Form from '../form' ;
10- import RendererContext from '../renderer-context' ;
10+ import RendererContext , { FormOptions } from '../renderer-context' ;
1111import renderForm from './render-form' ;
1212import SchemaErrorComponent from './schema-error-component' ;
1313import Schema from '../common-types/schema' ;
@@ -21,14 +21,14 @@ import { ConditionMapper } from './condition-mapper';
2121
2222export interface FormRendererProps <
2323 FormValues = Record < string , any > ,
24- InitialFormValues = Partial < FormValues > ,
24+ InitialFormValues extends Partial < FormValues > = Partial < FormValues > ,
2525 FormTemplateProps extends FormTemplateRenderProps = FormTemplateRenderProps
26- > extends Omit < NoIndex < FormProps < FormValues , InitialFormValues > > , 'onSubmit' | 'children' > {
26+ > extends Omit < NoIndex < FormProps < FormValues > > , 'onSubmit' | 'children' > {
2727 initialValues ?: InitialFormValues ;
2828 onCancel ?: ( values : FormValues , ...args : any [ ] ) => void ;
2929 onReset ?: ( ) => void ;
3030 onError ?: ( ...args : any [ ] ) => void ;
31- onSubmit ?: FormProps < FormValues , InitialFormValues > [ 'onSubmit' ] ;
31+ onSubmit ?: FormProps < FormValues > [ 'onSubmit' ] ;
3232 schema : Schema | ( Record < string , any > & { fields : Array < Record < string , any > > } ) ;
3333 clearOnUnmount ?: boolean ;
3434 clearedValue ?: any ;
@@ -82,7 +82,7 @@ const renderChildren = (children: ReactNode | ((props: Record<string, any>) => R
8282
8383function FormRenderer <
8484 FormValues = Record < string , any > ,
85- InitialFormValues = Partial < FormValues > ,
85+ InitialFormValues extends Partial < FormValues > = Partial < FormValues > ,
8686 FTP extends FormTemplateRenderProps = FormTemplateRenderProps
8787> ( {
8888 actionMapper,
@@ -214,7 +214,7 @@ function FormRenderer<
214214 onCancel : isFunc ( onCancel ) ? handleCancelCallback ( getState ) : undefined ,
215215 onReset : handleResetCallback ( reset ) ,
216216 onError : handleErrorCallback ,
217- getState,
217+ getState : getState as FormOptions [ 'getState' ] ,
218218 valid,
219219 clearedValue,
220220 submit,
@@ -240,7 +240,7 @@ function FormRenderer<
240240 </ RendererContext . Provider >
241241 ) }
242242 { ...props }
243- initialValues = { initialValues }
243+ initialValues = { initialValues as Partial < FormValues > }
244244 />
245245 ) ;
246246}
0 commit comments