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

46 lines
1.0 KiB
Svelte

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