import React, {Key, ReactElement} from "react";
import {CUSTOM_FIELD_WRAPPER_SCHEMA} from "../schemes";
import {AdditionPropsType} from "../types";
import {InputFieldWrapper} from "../dependencies";
import {formBuilder} from "../lib";

const customFieldWrapperComponent = (schema: CUSTOM_FIELD_WRAPPER_SCHEMA, key: Key, additionProps: AdditionPropsType): ReactElement => {
    const {children, ...props} = schema.props || {}
    return (
        <InputFieldWrapper {...props} key={key}>
            {children && formBuilder(children, additionProps)}
        </InputFieldWrapper>
    )
}

export default customFieldWrapperComponent