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

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

export default blockComponent