1<script lang="ts">
2 import { cn, type WithElementRef } from '$lib/components/ui/utils.js';
3 import type { Snippet } from 'svelte';
4 import type { HTMLAttributes } from 'svelte/elements';
5
6 let {
7 ref = $bindable(null),
8 children,
9 child,
10 class: className,
11 ...restProps
12 }: WithElementRef<HTMLAttributes<HTMLElement>> & {
13 child?: Snippet<[{ props: Record<string, unknown> }]>;
14 } = $props();
15
16 const mergedProps = $derived({
17 class: cn(
18 'text-sidebar-foreground/70 ring-sidebar-ring outline-hidden flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium transition-[margin,opacity] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0',
19 'group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0',
20 className
21 ),
22 'data-slot': 'sidebar-group-label',
23 'data-sidebar': 'group-label',
24 ...restProps
25 });
26</script>
27
28{#if child}
29 {@render child({ props: mergedProps })}
30{:else}
31 <div bind:this={ref} {...mergedProps}>
32 {@render children?.()}
33 </div>
34{/if}