<script lang="ts" setup>
  import { ComponentConfigFieldEnum } from '../../../enum';
  import { option } from './config';
  import { useForm, BasicForm } from '/@/components/Form';
  import { PublicFormInstaceType } from '/@/views/visual/dataSourceBindPanel/index.type';

  const [register, { getFieldsValue, setFieldsValue, resetFields }] = useForm({
    schemas: [
      {
        field: ComponentConfigFieldEnum.FONT_COLOR,
        label: '数值字体颜色',
        component: 'ColorPicker',
        changeEvent: 'update:value',
        defaultValue: option.fontColor,
      },
      {
        field: ComponentConfigFieldEnum.UNIT,
        label: '数值单位',
        component: 'Input',
        defaultValue: option.unit,
      },
      {
        field: ComponentConfigFieldEnum.SHOW_DEVICE_NAME,
        label: '显示设备名称',
        component: 'Checkbox',
        defaultValue: option.showDeviceName,
      },
    ],
    showActionButtonGroup: false,
    labelWidth: 120,
    baseColProps: {
      span: 12,
    },
  });

  const getFormValues = () => {
    return getFieldsValue();
  };

  const setFormValues = (data: Recordable) => {
    return setFieldsValue(data);
  };

  defineExpose({
    getFormValues,
    setFormValues,
    resetFormValues: resetFields,
  } as PublicFormInstaceType);
</script>

<template>
  <BasicForm @register="register" />
</template>
