-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1372 from stijnvanhulle/master
fix: better generic types for field, FormRenderer and hooks
- Loading branch information
Showing
4 changed files
with
47 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 18 additions & 10 deletions
28
packages/react-form-renderer/src/form-renderer/form-renderer.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,39 @@ | ||
import { ComponentType, FunctionComponent, ReactNode } from 'react'; | ||
import { ComponentType, ReactElement, FunctionComponent, ReactNode } from 'react'; | ||
import { FormProps } from 'react-final-form'; | ||
import Schema from '../common-types/schema'; | ||
import ComponentMapper from '../common-types/component-mapper'; | ||
import { ValidatorMapper} from '../validator-mapper'; | ||
import { ValidatorMapper } from '../validator-mapper'; | ||
import { ActionMapper } from './action-mapper'; | ||
import SchemaValidatorMapper from '../common-types/schema-validator-mapper'; | ||
import { FormTemplateRenderProps } from '../common-types/form-template-render-props'; | ||
import { AnyObject } from '../common-types/any-object'; | ||
|
||
export interface FormRendererProps extends Omit<FormProps, 'onSubmit'> { | ||
initialValues?: object; | ||
onCancel?: (values: AnyObject, ...args: any[]) => void; | ||
export interface FormRendererProps< | ||
FormValues = Record<string, any>, | ||
InitialFormValues = Partial<FormValues>, | ||
FormTemplateProps extends FormTemplateRenderProps = FormTemplateRenderProps | ||
> extends Omit<FormProps<FormValues, InitialFormValues>, 'onSubmit'> { | ||
initialValues?: InitialFormValues; | ||
onCancel?: (values: FormValues, ...args: any[]) => void; | ||
onReset?: () => void; | ||
onError?: (...args: any[]) => void; | ||
onSubmit?: FormProps['onSubmit'] | ||
onSubmit?: FormProps<FormValues, InitialFormValues>['onSubmit']; | ||
schema: Schema; | ||
clearOnUnmount?: boolean; | ||
clearedValue?: any; | ||
componentMapper: ComponentMapper; | ||
FormTemplate?: ComponentType<FormTemplateRenderProps> | FunctionComponent<FormTemplateRenderProps>; | ||
FormTemplate?: ComponentType<FormTemplateProps> | FunctionComponent<FormTemplateProps>; | ||
validatorMapper?: ValidatorMapper; | ||
actionMapper?: ActionMapper; | ||
schemaValidatorMapper?: SchemaValidatorMapper; | ||
FormTemplateProps?: AnyObject; | ||
children?: ReactNode | ((props: FormTemplateRenderProps) => ReactNode) | ||
FormTemplateProps?: Partial<FormTemplateProps>; | ||
children?: ReactNode | ((props: FormTemplateRenderProps) => ReactNode); | ||
} | ||
|
||
declare const FormRenderer: React.ComponentType<FormRendererProps>; | ||
declare function FormRenderer< | ||
FormValues = Record<string, any>, | ||
InitialFormValues = Partial<FormValues>, | ||
FormTemplateProps extends FormTemplateRenderProps = FormTemplateRenderProps | ||
>(props: FormRendererProps<FormValues, InitialFormValues, FormTemplateProps>): ReactElement<any, any>; | ||
|
||
export default FormRenderer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 4 additions & 1 deletion
5
packages/react-form-renderer/src/use-form-api/use-form-api.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
import { FormOptions } from '../renderer-context'; | ||
|
||
export default function(): FormOptions; | ||
export default function useFormApi<FormValues = Record<string, any>, InitialFormValues = Partial<FormValues>>(): FormOptions< | ||
FormValues, | ||
InitialFormValues | ||
>; |
7aa9bb8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
react-forms – ./
www.data-driven-forms.org
react-forms-git-master-data-driven-forms.vercel.app
react-forms-wine.vercel.app
react-forms-data-driven-forms.vercel.app
data-driven-forms.org