/*
 * @Date: 2021-12-22 16:38:18
 * @LastEditors: huangliping
 * @LastEditTime: 2022-01-04 14:46:53
 */
export enum ReactVisualEditorPropsType {
  text = 'text',
  select = 'select',
  color = 'color',
  table = 'table',
  textarea = 'textarea',
}

export type ReactVisualEditorProps =
  | ReactVisualEditorTextProp
  | ReactVisualEditorColorProp
  | ReactVisualEditorSelectProp
  | ReactVisualEditorTextareaProp
  | ReactVisualEditorTableProp
  | {};

/*---------------------------------------text-------------------------------------------*/

interface ReactVisualEditorTextProp {
  name: string;
  type: ReactVisualEditorPropsType.text;
}
interface ReactVisualEditorTextareaProp {
  name: string;
  type: ReactVisualEditorPropsType.textarea;
}
export function createTextareaProp(name: string): ReactVisualEditorTextareaProp {
  return {
    name,
    type: ReactVisualEditorPropsType.textarea,
  };
}
export function createTextProp(name: string): ReactVisualEditorTextProp {
  return {
    name,
    type: ReactVisualEditorPropsType.text,
  };
}

/*---------------------------------------color-------------------------------------------*/

interface ReactVisualEditorColorProp {
  name: string;
  type: ReactVisualEditorPropsType.color;
}

export function createColorProp(name: string): ReactVisualEditorColorProp {
  return {
    name,
    type: ReactVisualEditorPropsType.color,
  };
}

/*---------------------------------------select-------------------------------------------*/

interface ReactVisualEditorSelectProp {
  name: string;
  type: ReactVisualEditorPropsType.select;
  options: { label: string; value: string }[];
}

export function createSelectProp(
  name: string,
  options: { label: string; value: string }[],
): ReactVisualEditorSelectProp {
  return {
    name,
    type: ReactVisualEditorPropsType.select,
    options,
  };
}

/*---------------------------------------table-------------------------------------------*/

export interface ReactVisualEditorTableProp {
  name: string;
  type: ReactVisualEditorPropsType.table;
  showField: string; // 数组中，需要显示字段
  columns: {
    name: string; // 字段提示名称
    field: string; // 绑定字段
  }[];
}

export function createTableProp(
  name: string,
  showField: string,
  columns: {
    name: string;
    field: string;
  }[],
): ReactVisualEditorTableProp {
  return {
    name,
    showField,
    type: ReactVisualEditorPropsType.table,
    columns,
  };
}
/**
 * 配置参数
 */
export interface ParameterType{
  title?:string//标题
  dataUrl?:string//数据路径
  titleColor?:string//标题颜色
  titleFontSize?:number//字体大小
}
export enum EchartType{
   line='line',
   pie='pie',
   radar='radar',
   bar='bar',
   gauge='gauge'
}