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

39 lines
913 B
Svelte

<script lang="ts">
import { boxWith, mergeProps } from "svelte-toolbelt";
import type { RadioGroupItemProps } from "../types.js";
import { RadioGroupItemState } from "../radio-group.svelte.js";
import { createId } from "../../../internal/create-id.js";
const uid = $props.id();
let {
id = createId(uid),
children,
child,
value,
disabled = false,
ref = $bindable(null),
...restProps
}: RadioGroupItemProps = $props();
const itemState = RadioGroupItemState.create({
value: boxWith(() => value),
disabled: boxWith(() => disabled ?? false),
id: boxWith(() => id),
ref: boxWith(
() => ref,
(v) => (ref = v)
),
});
const mergedProps = $derived(mergeProps(restProps, itemState.props));
</script>
{#if child}
{@render child({ props: mergedProps, ...itemState.snippetProps })}
{:else}
<button {...mergedProps}>
{@render children?.(itemState.snippetProps)}
</button>
{/if}