Skip to content

Commit

Permalink
cleanup presence
Browse files Browse the repository at this point in the history
  • Loading branch information
zernonia committed Jul 24, 2023
1 parent 95480b6 commit 36b0df4
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions packages/radix-vue/src/Presence/Presence.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
type VNode,
} from "vue";
import { usePresence } from "./usePresence";
import { syncRef } from "@vueuse/core";
interface PresenceProps {
present: boolean;
Expand All @@ -19,27 +18,22 @@ const props = defineProps<PresenceProps>();
const { present, forceMount } = toRefs(props);
const slots = useSlots();
const isLocalPresence = ref(props.forceMount || props.present);
const node = ref<HTMLElement>();
const { isPresent } = usePresence(present, node);
const vPresence: Directive = {
created(el) {
syncRef(isLocalPresence, isPresent, { direction: "rtl" });
node.value = el;
},
};
const render = () =>
forceMount.value || present.value || isLocalPresence.value
? withDirectives(
slots.default?.({ present: isLocalPresence })?.[0] as VNode,
[[vPresence]]
)
forceMount.value || present.value || isPresent.value
? withDirectives(slots.default?.()?.[0] as VNode, [[vPresence]])
: null;
defineExpose({
present: isLocalPresence,
present: isPresent,
});
</script>

Expand Down

0 comments on commit 36b0df4

Please sign in to comment.