infinity-forge
Version:
82 lines (81 loc) • 2.9 kB
TypeScript
import { FormikErrors } from 'formik';
import { ButtonProps, Language, MessageProviderProps } from '../../../../ui/index.js';
import { ICustomSubmitProps } from './custom-submit/index.js';
import { IDefaultSchemas } from './form-handler/generate-schemas.js';
export type StateFormFormHandler = {
state: "loading" | "default" | "error" | "send" | "";
message: string;
};
export type OnSubmitConfiguration = {
schema?: {
verifyOnly?: string[];
};
extraData?: {
[key in string]: any;
};
};
export interface IFormHandler {
ref?: any;
schema?: Record<string, any>;
onSubmitConfiguration?: OnSubmitConfiguration;
modifySchema?: ({ schema, data }: {
schema: IFormHandler["schema"];
data?: Record<string, any>;
}) => IFormHandler["schema"];
onValidateSchema?: (erors: any) => void;
recaptcha?: boolean | string;
decimalFields?: string[];
formHandlerContextProps?: any;
messageProvider?: MessageProviderProps;
modifyInitialData?: (initialData: IFormHandler["initialData"]) => any;
onFinish?: (data: any, initialValues: any) => void;
fileFields?: {
ref: string;
unique?: boolean;
keyRef?: string;
uniqueFields?: string[];
fields: string[];
onUpload?: (values: any, response: any, handlers?: {
setFieldError: (field: string, message: string) => void;
setFieldValue: (field: string, value: any, shouldValidate?: boolean) => Promise<void | FormikErrors<unknown>>;
}) => Promise<void>;
};
i18n?: {
languages?: Language[];
schema?: IFormHandler['schema'];
RenderFields: ({ symbol }: {
symbol: string;
}) => React.ReactNode;
};
defaultSchemas?: IDefaultSchemas;
isStickyButtons?: boolean;
autoComplete?: 'on' | 'off';
onSucess?: (data: any, handlers?: {
setFieldError: (field: string, message: string) => void;
setFieldValue: (field: string, value: any, shouldValidate?: boolean) => Promise<void | FormikErrors<unknown>>;
}, initialValues?: any) => Promise<unknown>;
button?: ButtonProps;
children?: React.ReactNode;
onChangeForm?: {
callbackResult: (dataForm: any) => void;
additionalDependencies?: any[];
};
customAction?: {
props?: {
[key: string]: any;
};
Component: (props: {
values?: any;
stateForm: StateFormFormHandler;
handleSubmit?(action?: any): Promise<void>;
setFieldValue: (field: string, value: any, shouldValidate?: boolean) => Promise<void | FormikErrors<unknown>>;
}) => React.ReactNode;
};
initialData?: {
[key: string]: any;
};
customSubmit?: ICustomSubmitProps[];
cleanFieldsOnSubmit?: boolean;
debugMode?: boolean;
disableEnterKeySubmitForm?: boolean;
}