You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
723 B
34 lines
723 B
|
6 months ago
|
<script lang="ts">
|
||
|
|
import { boxWith, mergeProps } from "../../utils/index";
|
||
|
|
import { CommandGroupHeadingState } from "../command.svelte";
|
||
|
|
import type { CommandGroupHeadingProps } from "../types";
|
||
|
|
import { useId } from "../../utils/use-id";
|
||
|
|
|
||
|
|
let {
|
||
|
|
id = useId(),
|
||
|
|
ref = $bindable(null),
|
||
|
|
children,
|
||
|
|
child,
|
||
|
|
...restProps
|
||
|
|
}: CommandGroupHeadingProps = $props();
|
||
|
|
|
||
|
|
const headingState = CommandGroupHeadingState.create({
|
||
|
|
id: boxWith(() => id),
|
||
|
|
ref: boxWith(
|
||
|
|
() => ref,
|
||
|
|
(v) => (ref = v)
|
||
|
|
),
|
||
|
|
});
|
||
|
|
|
||
|
|
const mergedProps = $derived(mergeProps(restProps, headingState.props));
|
||
|
|
</script>
|
||
|
|
|
||
|
|
{#if child}
|
||
|
|
{@render child({ props: mergedProps })}
|
||
|
|
{:else}
|
||
|
|
<div {...mergedProps}>
|
||
|
|
{@render children?.()}
|
||
|
|
</div>
|
||
|
|
{/if}
|
||
|
|
|