<script setup lang="ts">
import {reactive, toRefs} from 'vue'
import * as ElIcons from '@element-plus/icons-vue'

const prop = defineProps({
  visible: {
    type: Boolean,
    default: false
  }
})

const emits = defineEmits(['onIcon'])
const handleClose = (val: any) => {
  // 触发自定义事件来通知父组件关闭弹窗
  emits('onIcon',val)
}
let { visible } = toRefs(prop)
const state = reactive({
  iconList: ElIcons,
})
const {iconList} = toRefs(state)
</script>
<template>
  <el-dialog v-model="visible" title="图标"
             @close="handleClose"
             width="70%">
    <el-icon v-for="icon in iconList" @click="$emit('onIcon', icon)" :size="30" color="#242e42"
             style="border: 1px solid #e4e7ed;padding: 1rem;cursor: pointer;">
      <component :is="icon"></component>
    </el-icon>
  </el-dialog>
</template>
<style lang="scss">
.el-dialog__header {
  margin: 0 !important;
}
</style>