import { App } from 'vue';
import config from './config';

import Form from './Form';
import { formProps } from 'ant-design-vue/es/form';
import FormItem, { formItemProps } from 'ant-design-vue/es/form/FormItem';
import useForm from 'ant-design-vue/es/form/useForm';
import FormItemRest, {
  useInjectFormItemContext
} from 'ant-design-vue/es/form/FormItemContext';
Form.useInjectFormItemContext = useInjectFormItemContext;
Form.ItemRest = FormItemRest;

Form.install = (app: App, options: any = {}) => {
  // 覆盖默认配置
  Object.assign(config.props, options.props);

  app.component(Form.name, Form);
  app.component(FormItem.name, FormItem);
  app.component(FormItemRest.name, FormItemRest);
  return app;
};

export {
  FormItem,
  formItemProps,
  formProps,
  FormItemRest,
  useForm,
  useInjectFormItemContext
};
export default Form;
