From da27ae5541ff41d655fec18010383e5a721147a0 Mon Sep 17 00:00:00 2001 From: grabowski Date: Fri, 24 Apr 2026 16:11:06 +0700 Subject: [PATCH] Add device autocomplete to todo forms: type name or paste ID Co-Authored-By: Claude Opus 4.7 (1M context) --- .../components/ui/DeviceAutocomplete.svelte | 138 ++++++++++++++++++ src/routes/(app)/todos/+page.svelte | 28 ++-- 2 files changed, 149 insertions(+), 17 deletions(-) create mode 100644 src/lib/components/ui/DeviceAutocomplete.svelte 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} +
    + {#each suggestions as d, i} +
  • + +
  • + {/each} +
+ {/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} -