import type { FormItemProps } from 'antd';
import { isFunction } from 'lodash';
import { isValidElement } from 'react';

export const component = (c: any, v?: any, i?: number) => {
  return isFunction(c) && !isValidElement(c) ? c(v, i) : c;
};

export const withWarpFormItemProps = <T extends Record<string, any>>(Comp: any) => {
  return (
    props: T &
      FormItemProps & {
        changeCleans?: string[];
      },
  ) => {
    const { children, ...rest } = props;
    return <Comp {...rest}>{children}</Comp>;
  };
};
