<script lang="ts">
	import { idFromLabel } from '$lib/Utils';
	import type { Snippet } from 'svelte';

	interface Props {
		label: string;
		side?: Snippet;
		children?: Snippet<[{ id: string }]>;
	}

	let { label, side, children }: Props = $props();

	const id = idFromLabel(label);
</script>

<div class="flex flex-col">
	<div class="flex">
		<label for={id}>{label}</label>
		{#if side}
			<div class="grow"></div>
			{@render side?.()}
		{/if}
	</div>
	{@render children?.({ id })}
</div>
