UNPKG

@cmk/fe_utils

Version:
37 lines (35 loc) 1.3 kB
import { FC } from 'react'; import { GenericFormProps } from '../types'; /** the properties/params to define a custom field in the generic form's -> fields property */ export type CustomFieldDefinition<F, P> = { type: 'inject'; name: string; component: FC<CustomFieldComponentProps<F, P>>; params: P; key?: string; }; /** the properties which are passed to the react component, partly from the generic form */ export type CustomFieldComponentProps<F, P> = { formData: F; onChangeFormData: (newFormData: F, changedPropertyName: keyof F & string, changedPropertyValue: unknown, prevFormData: F) => void; onBeforeChange?: NonNullable<GenericFormProps['injections']>['onBeforeChange']; params: P; rootFormData?: any; onChangeFormDataRoot?: (newFormData: any) => void; _path?: (string | number)[]; field: CustomFieldDefinition<F, P>; onFileChange?: (name: string, files: File[]) => void; files?: { [key: string]: { file: File; filename: string; }[]; }; fields: any; subforms: any; }; export declare const CustomField: <F extends { [key: string]: any; }, Params extends { [key: string]: any; }>(props: CustomFieldComponentProps<F, Params>) => import("react/jsx-runtime").JSX.Element;