Files
risuai/src/lib/UI/GUI/Portal.svelte
2025-02-15 21:29:37 +09:00

24 lines
509 B
Svelte

<script lang="ts">
import { getAllContexts, mount, unmount } from "svelte";
//@ts-ignore
import PortalConsumer from "./PortalConsumer.svelte";
interface Props {
target?: HTMLElement;
children: any;
}
const { target: target = document.body, children }:Props = $props();
const context = getAllContexts();
let instance;
$effect(() => {
instance = mount(PortalConsumer, { target, props: { children }, context })
return () => {
unmount(instance);
}
});
</script>