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

39 lines
912 B
Svelte

<script lang="ts">
import { boxWith, mergeProps } from "svelte-toolbelt";
import type { RatingGroupItemProps } from "../types.js";
import { RatingGroupItemState } from "../rating-group.svelte.js";
import { createId } from "../../../internal/create-id.js";
const uid = $props.id();
let {
disabled = false,
index,
children,
child,
ref = $bindable(null),
id = createId(uid),
...restProps
}: RatingGroupItemProps = $props();
const itemState = RatingGroupItemState.create({
disabled: boxWith(() => Boolean(disabled)),
index: boxWith(() => index),
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}
<div {...mergedProps}>
{@render children?.(itemState.snippetProps)}
</div>
{/if}