import { App } from 'vue'
import SvgIcon from '@/components/SvgIcon/index.vue'
//全局引用icon图标
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import DialogForm from './FormConfigDialog.vue'
import InputNumber from './InputNumber.vue'
import InputNumberRange from './InputNumberRange.vue'
import FormConfig from './FormConfig/index.vue'
import SearchForm from './SearchForm.vue'
import LeTableColumnsPopover from '@/components/Table/components/TableColumnsPopover.vue'
import DraggableNest from '@/components/DraggableNest.vue'
import LeTable from '@/components/Table/index.vue'
import NoData from '@/components/NoData.vue'
import Icon from '@/components/Icon.vue'
import Select from '@/components/Select/index.vue'
import Chart from '@/components/Chart.vue'

// 表单设计器
import DragTool from '@/components/FormCreateDesigner/DragTool.vue'
import Struct from '@/components/FormCreateDesigner/Struct.vue'
import Fetch from '@/components/FormCreateDesigner/Fetch.vue'
import Validate from '@/components/FormCreateDesigner/Validate.vue'
import DragBox from '@/components/FormCreateDesigner/DragBox.vue'
import Required from '@/components/FormCreateDesigner/Required.vue'
import TableOptions from '@/components/FormCreateDesigner/TableOptions.vue'
import FcEditor from '@form-create/component-wangeditor'
import draggable from 'vuedraggable/src/vuedraggable'

// you want register components
const compList = [
	SvgIcon,
	InputNumber,
	InputNumberRange,
	DialogForm,
	FormConfig,
	SearchForm,
	LeTableColumnsPopover,
	DraggableNest,
	LeTable,
	NoData,
	Icon,
	Select,
	Chart,
	DragTool,
	Struct,
	Fetch,
	Validate,
	DragBox,
	Required,
	TableOptions,
	FcEditor,
	draggable
]

export function registerGlobComp(app: App) {
	Object.entries(ElementPlusIconsVue).map(([key, component]) => {
		app.component(key, component)
	})
	compList.forEach(comp => {
		// eslint-disable-next-line
		// @ts-ignore
		app.component(comp.name || comp.displayName, comp)
	})
}
