You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
781 B
34 lines
781 B
n<script lang="ts">
|
|
import { readableActive, writableActive } from '$soma/reactive';
|
|
import { createId } from '$soma/id';
|
|
import { PopoverProvider } from '../popover-provider.svelte';
|
|
import type { PopoverProps } from '../types';
|
|
import { noop } from '$lib/util/funcs';
|
|
|
|
const uid = $props.id();
|
|
|
|
let {
|
|
id = createId(uid, 'popover'),
|
|
open = $bindable(false),
|
|
onOpenChange = noop,
|
|
onOpenChangeComplete = noop,
|
|
modal = false,
|
|
children,
|
|
}: PopoverProps = $props();
|
|
|
|
PopoverProvider.from({
|
|
id: readableActive(() => id),
|
|
open: writableActive(
|
|
() => open,
|
|
(v) => {
|
|
open = v;
|
|
onOpenChange(v);
|
|
},
|
|
),
|
|
onOpenChangeComplete: readableActive(() => onOpenChangeComplete),
|
|
modal: readableActive(() => modal),
|
|
});
|
|
</script>
|
|
|
|
{@render children?.()}
|