<template>
  <CollapseItem name="标题设置" :expanded="true">
    <n-tag type="primary">若配置无响应，请在预览页面查看效果</n-tag>
    <SettingItemBox :alone="true" name="标题名称">
      <SettingItem :alone="true">
        <n-input v-model:value="optionData.data" type="text" size="small" />
      </SettingItem>
    </SettingItemBox>
    <SettingItemBox name="标题设置">
      <SettingItem name="标题横坐标位置">
        <n-input-number
          v-model:value="optionData.dataStyle.x"
          :min="0"
          size="small"
          placeholder="宽度"
        ></n-input-number>
      </SettingItem>
      <SettingItem name="标题纵坐标位置">
        <n-input-number
          v-model:value="optionData.dataStyle.y"
          :min="0"
          size="small"
          placeholder="高度"
        ></n-input-number>
      </SettingItem>
      <SettingItem name="标题字体颜色">
        <n-color-picker
          size="small"
          :modes="['hex']"
          v-model:value="optionData.dataStyle.fontColor"
        ></n-color-picker>
      </SettingItem>
      <SettingItem name="标题字体大小">
        <n-input-number
          v-model:value="optionData.dataStyle.fontSize"
          :min="0"
          size="small"
        ></n-input-number>
      </SettingItem>
      <SettingItem name="标题矩形左侧颜色">
        <n-color-picker
          size="small"
          :modes="['hex']"
          v-model:value="optionData.dataStyle.leftColor"
        ></n-color-picker>
      </SettingItem>
      <SettingItem>
        <n-button
          size="small"
          @click="optionData.dataStyle.leftColor = option.dataStyleClone.leftColor"
        >
          恢复默认
        </n-button>
      </SettingItem>
      <SettingItem name="标题渐变颜色(始)">
        <n-color-picker
          size="small"
          :modes="['hex']"
          v-model:value="optionData.dataStyle.startColor"
        ></n-color-picker>
      </SettingItem>
      <SettingItem>
        <n-button
          size="small"
          @click="optionData.dataStyle.startColor = option.dataStyleClone.startColor"
        >
          恢复默认
        </n-button>
      </SettingItem>
      <SettingItem name="标题渐变颜色(终)">
        <n-color-picker
          size="small"
          :modes="['hex']"
          v-model:value="optionData.dataStyle.endColor"
        ></n-color-picker>
      </SettingItem>
      <SettingItem>
        <n-button
          size="small"
          @click="optionData.dataStyle.endColor = option.dataStyleClone.endColor"
        >
          恢复默认
        </n-button>
      </SettingItem>
    </SettingItemBox>
  </CollapseItem>
</template>

<script setup lang="ts">
  import { PropType, watch, ref } from 'vue';
  import { option } from './config';
  import { cloneDeep } from 'lodash-es';
  import { CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting';

  const props = defineProps({
    optionData: {
      type: Object as PropType<typeof option>,
      required: true,
    },
  });
</script>
