|
|
|
|
<script lang="ts">
|
|
|
|
|
/**
|
|
|
|
|
* # Command Group Heading
|
|
|
|
|
*
|
|
|
|
|
* Encabezado opcional para un grupo de comandos.
|
|
|
|
|
*
|
|
|
|
|
* ## Uso
|
|
|
|
|
* ```svelte
|
|
|
|
|
* <CommandGroup>
|
|
|
|
|
* <CommandGroupHeading>Archivos</CommandGroupHeading>
|
|
|
|
|
* <CommandItem value="new-file">Nuevo archivo</CommandItem>
|
|
|
|
|
* <CommandItem value="open">Abrir archivo</CommandItem>
|
|
|
|
|
* </CommandGroup>
|
|
|
|
|
* ```
|
|
|
|
|
*
|
|
|
|
|
* ## Propiedades
|
|
|
|
|
* - `id`: string - ID del elemento
|
|
|
|
|
*
|
|
|
|
|
* ## Selectores CSS
|
|
|
|
|
* ```
|
|
|
|
|
* [data-command-group-heading] → Encabezado de un grupo de comandos
|
|
|
|
|
* ```
|
|
|
|
|
*
|
|
|
|
|
* ## Estilos
|
|
|
|
|
* Renderiza un elemento `<div>`.
|
|
|
|
|
*/
|
|
|
|
|
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}
|
|
|
|
|
|