2024-01-27 00:35:02 +00:00
|
|
|
<script lang="ts">
|
2024-11-09 19:05:28 +00:00
|
|
|
import Checkbox from '$components/ui/checkbox/checkbox.svelte';
|
|
|
|
|
import * as Form from '$components/ui/form';
|
|
|
|
|
import Input from '$components/ui/input/input.svelte';
|
|
|
|
|
import { type SearchSchema, search_schema } from '$lib/zodValidation';
|
|
|
|
|
import { type Infer, type SuperValidated, superForm } from 'sveltekit-superforms';
|
|
|
|
|
import { zodClient } from 'sveltekit-superforms/adapters';
|
2024-01-27 00:35:02 +00:00
|
|
|
|
2024-11-09 19:05:28 +00:00
|
|
|
export let data: SuperValidated<Infer<SearchSchema>>;
|
2024-03-03 19:32:36 +00:00
|
|
|
|
2024-11-09 19:05:28 +00:00
|
|
|
const form = superForm(data, {
|
|
|
|
|
validators: zodClient(search_schema),
|
|
|
|
|
});
|
2024-03-03 19:32:36 +00:00
|
|
|
|
2024-11-09 19:05:28 +00:00
|
|
|
const { form: formData } = form;
|
2024-01-27 00:35:02 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<search>
|
2024-03-03 19:32:36 +00:00
|
|
|
<form id="search-form" action="/search" method="GET" data-sveltekit-reload>
|
2024-01-27 00:35:02 +00:00
|
|
|
<fieldset>
|
2024-03-03 19:32:36 +00:00
|
|
|
<Form.Field {form} name="q">
|
|
|
|
|
<Form.Control let:attrs>
|
|
|
|
|
<Form.Label>Search</Form.Label>
|
|
|
|
|
<Input {...attrs} bind:value={$formData.q} />
|
|
|
|
|
</Form.Control>
|
|
|
|
|
<Form.FieldErrors />
|
|
|
|
|
</Form.Field>
|
|
|
|
|
<Form.Field {form} name="skip">
|
|
|
|
|
<Form.Control let:attrs>
|
|
|
|
|
<Input type="hidden" />
|
|
|
|
|
</Form.Control>
|
|
|
|
|
</Form.Field>
|
|
|
|
|
<Form.Field {form} name="limit">
|
|
|
|
|
<Form.Control let:attrs>
|
|
|
|
|
<Input type="hidden" />
|
|
|
|
|
</Form.Control>
|
|
|
|
|
</Form.Field>
|
2024-01-27 00:35:02 +00:00
|
|
|
</fieldset>
|
|
|
|
|
<fieldset>
|
|
|
|
|
<div class="flex items-center space-x-2">
|
2024-03-03 19:32:36 +00:00
|
|
|
<Form.Field {form} name="exact">
|
|
|
|
|
<Form.Control let:attrs>
|
|
|
|
|
<Form.Label>Exact Search</Form.Label>
|
|
|
|
|
<Checkbox {...attrs} class="mt-0" bind:checked={$formData.exact} />
|
|
|
|
|
<input name={attrs.name} value={$formData.exact} hidden />
|
|
|
|
|
</Form.Control>
|
2024-01-27 00:35:02 +00:00
|
|
|
</Form.Field>
|
|
|
|
|
</div>
|
|
|
|
|
</fieldset>
|
|
|
|
|
<Form.Button>Submit</Form.Button>
|
2024-03-03 19:32:36 +00:00
|
|
|
</form>
|
2024-01-27 00:35:02 +00:00
|
|
|
</search>
|
|
|
|
|
|
|
|
|
|
<style lang="postcss">
|
|
|
|
|
</style>
|