<!--
 * @Author: ChenChanghua
 * @Date: 2023-03-08 14:52:17
 * @Description: file content
-->
<script setup>
import { inject, ref } from "vue";

const props = defineProps({
  data: Object,
  onAction: Object,
});

const focused = ref(false);
const fullScreenVisibility = inject("fullScreenVisibility");

// 注册回调
const onFocus = () => {
  focused.value = true;
  if (props.data.showFull) {
    fullScreenVisibility.value = true;
  }
};
const onBlur = () => {
  focused.value = false;
  if (props.data.showFull) {
    fullScreenVisibility.value = false;
  }
};
const onClick = () => {
  console.log("item onclick ", props.data);
};
props.onAction.register("onFocus", onFocus);
props.onAction.register("onBlur", onBlur);
props.onAction.register("onClick", onClick);
</script>

<template>
  <div
    :style="{
      width: data.width,
      height: data.height,
      fontSize: 30,
      color: focused ? '#FF0000' : '#FFFFFF',
      backgroundColor: data.color,
    }"
  >
    {{ data.content }}
  </div>
</template>