blob: 3631d84ba6145d560f577baada05598af80675b9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
<script lang="ts">
import type { AddNamespaceInput, Namespace } from '$gql/graphql';
import SubmitButton from '$lib/components/SubmitButton.svelte';
import { namespacePending, type FormProps } from '$lib/Form';
let { initial, submit, children }: FormProps<Namespace, AddNamespaceInput> = $props();
let input = $state(initial);
let pending = $derived(input.name.length > 0 && namespacePending(initial, input));
function onsubmit(event: SubmitEvent) {
event.preventDefault();
submit({ ...input });
}
</script>
<form {onsubmit}>
<div class="grid-labels">
<label class="self-center" for="name">Name</label>
<!-- svelte-ignore a11y_autofocus -->
<input autofocus required id="name" bind:value={input.name} />
<label class="self-center" for="sort-name">Sort name</label>
<input id="name" bind:value={input.sortName} />
</div>
<div class="flex gap-4">
{@render children?.()}
<div class="grow"></div>
<SubmitButton {pending} />
</div>
</form>
|