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.
|
|
|
|
<script lang="ts">
|
|
|
|
|
import { readableActive, writableActive, mergeProps } from "$terra/utils";
|
|
|
|
|
import { CommandGroupHeadingState } from "../command.svelte";
|
|
|
|
|
import type { CommandGroupHeadingProps } from "../types";
|
|
|
|
|
import { useId } from '$terra/utils';
|
|
|
|
|
|
|
|
|
|
let {
|
|
|
|
|
id = useId(),
|
|
|
|
|
ref = $bindable(null),
|
|
|
|
|
children,
|
|
|
|
|
child,
|
|
|
|
|
...restProps
|
|
|
|
|
}: CommandGroupHeadingProps = $props();
|
|
|
|
|
|
|
|
|
|
const headingState = CommandGroupHeadingState.create({
|
|
|
|
|
id: readableActive(() => id),
|
|
|
|
|
ref: writableActive(
|
|
|
|
|
() => 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}
|
|
|
|
|
|