import React, {ReactElement, ReactNode} from "react"; import {InputFieldWrapperPropsType, InputFieldPropsType, Overwrite} from "../dependencies"; export type BLOCK_SCHEMA = { type: 'block', props?: Overwrite, { children?: FORM_BUILDER_SCHEMA, }> } export type ADDITION_PROPS = { type: 'addition_props', props: { className?: { [key: string]: string }, } } export type CUSTOM_FIELD_WRAPPER_SCHEMA = { type: 'custom_field_wrapper', props: Overwrite } export type InputFieldValidationFunObjectReturnType = { status: boolean, message: string } export type InputFieldValidationFunReturnType = string | boolean | InputFieldValidationFunObjectReturnType export type InputFieldValidationFunType = (data: any) => InputFieldValidationFunReturnType // export type InputFieldValidationType = { required?: boolean, fun?: InputFieldValidationFunType } export type InputFieldOnBlurValidationType = { required?: boolean, fun?: InputFieldValidationFunType } export type INPUT_FIELD_SCHEMA = { type: 'input_field', props: Overwrite any, deserializeValue?: (data: any) => any, }> & { [key: string]: any }, } export type REACT_NODE_SCHEMA = { type: 'react_node_component', react_node_comp?: ReactNode, } export type FORM_WRAPPER_SCHEMA = { type: 'form_wrapper', form_wrapper?: ReactElement, props: Overwrite, { name?: string, children?: FORM_BUILDER_SCHEMA, }>, } export type ARRAY_FIELDS_SCHEMA = { type: 'array_fields', array_comp?: ReactElement, props: Overwrite, { name: string, children?: FORM_BUILDER_SCHEMA, }> } export type BLOCK_WRAPPER_SCHEMA = { type: 'block_wrapper', block_wrapper?: ReactElement, props?: Overwrite, { children?: FORM_BUILDER_SCHEMA, }> } export type FORM_BUILDER_SCHEMA = ( FORM_WRAPPER_SCHEMA | REACT_NODE_SCHEMA | INPUT_FIELD_SCHEMA | BLOCK_SCHEMA | ADDITION_PROPS | CUSTOM_FIELD_WRAPPER_SCHEMA | ARRAY_FIELDS_SCHEMA | BLOCK_WRAPPER_SCHEMA )[]