import type { App, Plugin } from 'vue'

import Form, { formProps } from './Form'
import FormItem, { formItemProps } from './FormItem'
import FormItemRest, { useInjectFormItemContext } from './FormItemContext'
import useForm from './useForm'

export type { Rule, RuleObject } from './interface'

export type { FormInstance, FormProps } from './Form'
export type { FormItemInstance, FormItemProps } from './FormItem'

Form.useInjectFormItemContext = useInjectFormItemContext
Form.ItemRest = FormItemRest
/* istanbul ignore next */
Form.install = function (app: App) {
  app.component(Form.name, Form)
  app.component(Form.Item.name, Form.Item)
  app.component(FormItemRest.name, FormItemRest)
  return app
}

export { FormItem, formItemProps, FormItemRest, formProps, useForm, useInjectFormItemContext }

export default Form as typeof Form &
  Plugin & {
    readonly Item: typeof Form.Item
    readonly ItemRest: typeof FormItemRest
    readonly useForm: typeof useForm
    readonly useInjectFormItemContext: typeof useInjectFormItemContext
  }
