~ knotless Search/
↑↓ move↵ open⇧↵ all results
0
0
66 lines · 1.4 KB Raw History
<script lang="ts">
	import Checkbox from '#lib/atoms/Checkbox.svelte';
	import Field from '#lib/molecules/Field.svelte';
	import { words } from '#lib/words';

	// The sign-in form: the identifier, the password and whether to remember
	// the account. Its submit button, in the view's actions, names it by `id`.
	// The identifier is read-only when the client named the account (`hinted`).
	let {
		id,
		identifier = $bindable(''),
		password = $bindable(''),
		remember = $bindable(false),
		passwordField = $bindable(),
		hinted = false,
		describedby,
		onsubmit
	}: {
		id: string;
		identifier?: string;
		password?: string;
		remember?: boolean;
		passwordField?: HTMLInputElement;
		hinted?: boolean;
		describedby?: string;
		onsubmit: () => void;
	} = $props();
</script>

<form
	class="form"
	{id}
	onsubmit={(e) => {
		e.preventDefault();
		onsubmit();
	}}
>
	<Field
		id="identifier"
		label={words.identifier}
		autocomplete="username webauthn"
		readonly={hinted}
		{describedby}
		invalid={!!describedby}
		bind:value={identifier}
	/>
	<Field
		id="password"
		type="password"
		label={words.password}
		autocomplete="current-password"
		{describedby}
		invalid={!!describedby}
		bind:value={password}
		bind:element={passwordField}
	/>
	<Checkbox label={words.remember} bind:checked={remember} />
</form>

<style>
	.form {
		display: flex;
		flex-direction: column;
		gap: var(--space-4);
	}
</style>