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

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

const focused = ref(false);

// 注册回调
const onFocus = () => {
  focused.value = true;
  props.onItemFocus(props.query.index);
};
const onBlur = () => {
  focused.value = false;
};
const onClick = () => {};
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: '#000000',
      backgroundColor: focused ? '#009900' : '#ff000033',
      lineHeight: data.height,
      textAlign: 'center',
    }"
  >
    {{ data.content }}
  </div>
</template>
