<script module lang="ts">
	import { defineMeta } from "@storybook/addon-svelte-csf";
	import Search from "$icon/search";
	import Mail from "$icon/mail";
	import Input from "./Input.svelte";

	const { Story } = defineMeta({
		title: "UI/Input",
		component: Input,
		tags: ["autodocs"],
		argTypes: {
			error: { control: "boolean" },
			disabled: { control: "boolean" },
			loading: { control: "boolean" },
			placeholder: { control: "text" }
		},
		args: {
			error: false,
			disabled: false,
			loading: false,
			placeholder: "Placeholder"
		}
	});
</script>

<Story name="Default" />
<Story name="Focus" args={{ autofocus: true }} />
<Story name="Filled" args={{ value: "Filled value" }} />
<Story name="Error" args={{ error: true, value: "Invalid value" }} />
<Story name="Disabled" args={{ disabled: true, value: "Can't edit this" }} />
<Story name="Loading" args={{ loading: true, value: "Checking..." }} />

<Story name="With left icon" args={{ iconLeft: Search, placeholder: "Search" }} />
<Story name="With right icon" args={{ iconRight: Mail, placeholder: "you@example.com" }} />

<Story name="States">
	<div class="flex w-64 flex-col gap-3">
		<Input placeholder="Default" />
		<Input placeholder="Filled" value="Filled value" />
		<Input placeholder="Error" error value="Invalid value" />
		<Input placeholder="Disabled" disabled value="Can't edit this" />
		<Input placeholder="Loading" loading value="Checking..." />
		<Input placeholder="Search" iconLeft={Search} />
	</div>
</Story>
