<template>
  <el-scrollbar>
    <ul>
      <li class="selector-item" v-for="item in dataList" :key="item.fullPathName" @click="onClick(item)">
        <span class="selector-item-name">{{ item.oguName }}</span>
        <el-icon class="selector-item-close" @click="onDelete(item.fullPathName)" :size="16">
          <Close />
        </el-icon>
      </li>
    </ul>
  </el-scrollbar>
</template>
<script lang="ts" setup>
import type { BaseCacpOgu } from '@cacp/ui'

defineProps<{
  dataList: Array<BaseCacpOgu>
}>()
const emits = defineEmits<{
  (e: 'on-click', value: BaseCacpOgu): void
  (e: 'on-delete', value: string): void
}>()
function onClick(value: BaseCacpOgu) {
  emits('on-click', value)
}
function onDelete(value: string) {
  emits('on-delete', value)
}
</script>
<style lang="less" scoped>
.selector-item {
  height: 32px;
  line-height: 32px;
  padding: 0 var(--cacp-padding-space-s);
  font-size: var(--font-size-s);
  display: flex;
  align-items: center;
  cursor: pointer;
  margin-bottom: 1px;
  overflow: hidden;
  &-name {
    flex: 1;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
  }
  &-close {
    cursor: pointer;
    opacity: 0.8;
    &:hover {
      opacity: 1;
    }
  }
  &:hover {
    background-color: var(--el-fill-color-light);
  }
}
</style>
