刘光辉
10 小时以前 0dfe84494048ce27ba8449831782128412d3eb13
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<script setup lang="ts">
import type { HoverCardContentProps, HoverCardRootEmits, HoverCardRootProps } from 'radix-vue';
 
import type { ClassType } from '@vben-core/typings';
 
import { computed } from 'vue';
 
import { useForwardPropsEmits } from 'radix-vue';
 
import { HoverCard, HoverCardContent, HoverCardTrigger } from '../../ui';
 
interface Props extends HoverCardRootProps {
  class?: ClassType;
  contentClass?: ClassType;
  contentProps?: HoverCardContentProps;
}
 
const props = defineProps<Props>();
 
const emits = defineEmits<HoverCardRootEmits>();
 
const delegatedProps = computed(() => {
  const { class: _cls, contentClass: _, contentProps: _cProps, ...delegated } = props;
 
  return delegated;
});
 
const forwarded = useForwardPropsEmits(delegatedProps, emits);
</script>
 
<template>
  <HoverCard v-bind="forwarded">
    <HoverCardTrigger as-child class="h-full">
      <div class="h-full cursor-pointer">
        <slot name="trigger"></slot>
      </div>
    </HoverCardTrigger>
    <HoverCardContent :class="contentClass" v-bind="contentProps" class="side-content z-popup">
      <slot></slot>
    </HoverCardContent>
  </HoverCard>
</template>