diff --git a/src/lib/components/ui/DeviceAutocomplete.svelte b/src/lib/components/ui/DeviceAutocomplete.svelte new file mode 100644 index 0000000..1fa77f7 --- /dev/null +++ b/src/lib/components/ui/DeviceAutocomplete.svelte @@ -0,0 +1,138 @@ + + +
+ (showDropdown = true)} + onblur={handleBlur} + autocomplete="off" + class="w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:ring-1 focus:ring-blue-500 focus:outline-none dark:border-gray-600 dark:bg-gray-700 dark:text-white dark:placeholder-gray-400" + /> + + + {#if showDropdown && suggestions.length > 0} + + {/if} +
diff --git a/src/routes/(app)/todos/+page.svelte b/src/routes/(app)/todos/+page.svelte index 8f03c96..11d665d 100644 --- a/src/routes/(app)/todos/+page.svelte +++ b/src/routes/(app)/todos/+page.svelte @@ -4,11 +4,14 @@ import { page } from '$app/stores'; import { TODO_STATUSES, TODO_STATUS_LABELS, TODO_PRIORITIES } from '$lib/constants.js'; import { formatDate } from '$lib/utils/date.js'; + import DeviceAutocomplete from '$lib/components/ui/DeviceAutocomplete.svelte'; let { data } = $props(); let showNewForm = $state(false); let editingId = $state(null); + let newDeviceId = $state(''); + let editDeviceId = $state(''); const view = $derived(data.view); function setView(v: string) { @@ -83,7 +86,10 @@
{ return async ({ update, result }) => { await update(); - if (result.type === 'success') showNewForm = false; + if (result.type === 'success') { + showNewForm = false; + newDeviceId = ''; + } }; }} class="space-y-3">
@@ -128,13 +134,7 @@
- +
@@ -184,13 +184,7 @@
- +
@@ -256,7 +250,7 @@ {/if} -