refactor(presence): enhance slot handling and attribute forwarding

This commit is contained in:
2026-03-26 17:19:31 +07:00
parent fe527daad1
commit 333a18cbaf
3 changed files with 70 additions and 3 deletions
+8 -2
View File
@@ -3,9 +3,14 @@ export interface PresenceProps {
present: boolean;
forceMount?: boolean;
}
export default {
inheritAttrs: false,
};
</script>
<script setup lang="ts">
import { Slot } from '../primitive/Slot';
import { usePresence } from './usePresence';
const {
@@ -23,6 +28,7 @@ defineExpose({ present: isPresent });
</script>
<template>
<!-- @vue-expect-error ref is forwarded to slot -->
<slot v-if="forceMount || present || isPresent" :ref="setRef" :present="isPresent" />
<Slot v-if="forceMount || isPresent" :ref="setRef" v-bind="$attrs">
<slot :present="isPresent" />
</Slot>
</template>