<script lang="ts">
	// eslint-disable-next-line no-undef
	type T = $$Generic;

	export let id: string | null = null;
	export let name: string | null = null;
	export let value: T | null = null;
	export let label: string | null = null;
	export let notice: string | null = null;
	export let required = false;
	export let disabled = false;
	export let size: 'xs' | 'sm' | 'md' | 'lg' = 'md';
</script>

<div>
	{#if label}
		<label class="label" for={id}>
			<span class="label-text">
				{label}
				{#if required}
					<span class="text-red-700">*</span>
				{/if}
			</span>
		</label>
	{/if}
	<select
		class="select select-bordered w-[100%] sm:max-w-[16rem]"
		class:select-xs={size === 'xs'}
		class:select-sm={size === 'sm'}
		class:select-md={size === 'md'}
		class:select-lg={size === 'lg'}
		{id}
		{name}
		{required}
		{disabled}
		bind:value
	>
		<slot />
	</select>
	{#if notice}
		<label class="label" for={id}>
			<span class="label-text-alt">{notice}</span>
		</label>
	{/if}
</div>
