import type { Component } from 'vue';
import {
  ElInput,
  ElSelect,
  ElCheckbox,
  ElInputNumber,
  ElSwitch,
  ElDatePicker,
  ElTimePicker,
  ElCascader,
} from 'element-plus';
import type { ComponentType } from './types/componentType';

export enum EventEnum {
  Input = 'onInput',
  InputNumber = 'onChange',
  Select = 'onChange',
  Switch = 'onChange',
  Checkbox = 'onChange',
  DatePicker = 'onUpdate:modelValue',
  TimePicker = 'onUpdate:modelValue',
  Cascader = 'onUpdate:modelValue',
}

const componentMap = new Map<ComponentType, Component>();

componentMap.set('Input', ElInput);
componentMap.set('InputNumber', ElInputNumber);
componentMap.set('Select', ElSelect);
componentMap.set('Switch', ElSwitch);
componentMap.set('Checkbox', ElCheckbox);
componentMap.set('DatePicker', ElDatePicker);
componentMap.set('TimePicker', ElTimePicker);
componentMap.set('Cascader', ElCascader);

export function add(compName: ComponentType, component: Component) {
  componentMap.set(compName, component);
}

export function del(compName: ComponentType) {
  componentMap.delete(compName);
}

export { componentMap };
