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

47 lines
1.0 KiB
Svelte

<script lang="ts">
import { boxWith, mergeProps } from "svelte-toolbelt";
import type { NavigationMenuSubProps } from "../types.js";
import { NavigationMenuSubState } from "../navigation-menu.svelte.js";
import { createId } from "../../../internal/create-id.js";
import { noop } from "../../../internal/noop.js";
const uid = $props.id();
let {
child,
children,
id = createId(uid),
ref = $bindable(null),
value = $bindable(""),
onValueChange = noop,
orientation = "horizontal",
...restProps
}: NavigationMenuSubProps = $props();
const rootState = NavigationMenuSubState.create({
id: boxWith(() => id),
value: boxWith(
() => value,
(v) => {
value = v;
onValueChange(v);
}
),
orientation: boxWith(() => orientation),
ref: boxWith(
() => ref,
(v) => (ref = v)
),
});
const mergedProps = $derived(mergeProps(restProps, rootState.props));
</script>
{#if child}
{@render child({ props: mergedProps })}
{:else}
<div {...mergedProps}>
{@render children?.()}
</div>
{/if}