/*
 * @Author: kennthKun c_kunx@163.com
 * @Date: 2022-08-31 11:20:14
 * @LastEditors: kennthKun c_kunx@163.com
 * @LastEditTime: 2022-11-04 11:00:04
 * @FilePath: /kx_component/src/components/input/input.tsx
 */
import { Input } from 'antd';
import React from 'react';
import FormItem from '../FormItem/FormItem'
import { getItemProps } from "../../utils"
import schema from "./schema"

const InputWapper = (item: any) => {
  const data: any = getItemProps(schema, item)
  const { componentType, ControlProps = null, FormItemProps } = data
  const { placeholder } = ControlProps
  const { label } = FormItemProps
  const InputBoxFun = () => {
    return <Input className="kx_antd_input"
      {...ControlProps}
      placeholder={placeholder || `请输入${label}`}
    />
  }
  return <>
    {
      componentType === 'FormItem' ? <FormItem FormItemProps={...FormItemProps} >
        {InputBoxFun()}
      </FormItem> : InputBoxFun()
    }
  </>
};

export default InputWapper;
