<template>
  <div class="ModalFrameClose">
    <n-button text @click="clickBtn">
      <Button :w="w" :h="h" :dataStyle="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({
    dataStyle: props.chartConfig.option.dataStyle,
  });

  // 单击交互
  const clickElementItem = ref([]);

  const list = props.chartConfig.events.interactConfigEvents;
  for (let i = 0; i < list.length; i++) {
    if (list[i].type == 'click') {
      for (let j = 0; j < list[i].movementList.length; j++) {
        clickElementItem.value.push(list[i].movementList[j]);
      }
    }
  }

  const clickBtn = () => {
    eventHandlerHook(chartEditStore.getComponentList, clickElementItem.value);
  };
</script>

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