Files
Stackq/node_modules/bits-ui/dist/bits/collapsible/components/collapsible-content.svelte
T
eewing cf73cd3b4c INIT
2026-02-17 14:10:16 -06:00

42 lines
954 B
Svelte

<script lang="ts">
import { boxWith, mergeProps } from "svelte-toolbelt";
import { CollapsibleContentState } from "../collapsible.svelte.js";
import type { CollapsibleContentProps } from "../types.js";
import { createId } from "../../../internal/create-id.js";
const uid = $props.id();
let {
child,
ref = $bindable(null),
forceMount = false,
hiddenUntilFound = false,
children,
id = createId(uid),
...restProps
}: CollapsibleContentProps = $props();
const contentState = CollapsibleContentState.create({
id: boxWith(() => id),
forceMount: boxWith(() => forceMount),
hiddenUntilFound: boxWith(() => hiddenUntilFound),
ref: boxWith(
() => ref,
(v) => (ref = v)
),
});
const mergedProps = $derived(mergeProps(restProps, contentState.props));
</script>
{#if child}
{@render child({
...contentState.snippetProps,
props: mergedProps,
})}
{:else}
<div {...mergedProps}>
{@render children?.()}
</div>
{/if}