<script setup>
import { ref } from "vue";

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

const focused = ref(false);

// 注册回调
const onFocus = () => {
  console.log("item onfocus", props.data.id)
  focused.value = true;
};
const onBlur = () => {
  console.log("item onblur", props.data.id)
  focused.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,
      backgroundColor: focused ? '#aa0000aa' : '#007788aa',
    }"
  >
    {{ data.id }}
  </div>
</template>
