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.
svelte-kit-vice/src/uix/terra/command/components/command-group-heading.svelte

59 lines
1.3 KiB

<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}

Powered by TurnKey Linux.