<template>
  <div class="HuoQingButton" @click="clickBtn">
    <n-button text>
      <Button
        :w="w"
        :h="h"
        :dataset="chartConfig.option.dataset"
        :dataStyle="chartConfig.option.dataStyle"
      />
    </n-button>
  </div>
</template>

<script setup lang="ts">
  import { computed, PropType, toRefs, watch, reactive, ref } from 'vue';
  import { CreateComponentType } from '@/packages/index.d';
  import { icon } from '@/plugins';
  import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore';
  import { useChartDataFetch } from '@/hooks';
  import { eventHandlerHook } from '@/hooks/eventHandler.hook';
  import Button from './svg/button.vue';

  const chartEditStore = useChartEditStore();
  const props = defineProps({
    chartConfig: {
      type: Object as PropType<CreateComponentType>,
      required: true,
    },
  });

  const { w, h } = toRefs(props.chartConfig.attr);

  const option = reactive({
    dataset: props.chartConfig.option.dataset,
    dataStyle: props.chartConfig.option.dataStyle,
  });

  // 单击交互
  const clickBtn = (val) => {
    eventHandlerHook(
      chartEditStore.getComponentList,
      props.chartConfig.events.interactConfigEvents,
      'click',
      val,
    );
  };
</script>

<style lang="scss" scoped>
  .HuoQingButton {
    display: flex;
    justify-content: center;
    text-align: center;
    width: v-bind('`${w}px`');
    height: v-bind('`${h}px`');
  }
</style>
