From cb0c87a4ca575ce1dacfab9f52e5147a8600131b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20T=C3=A4kker?= Date: Tue, 16 Dec 2025 16:46:14 +0100 Subject: [PATCH] Enhance Input component: add file input handling and improve label rendering logic --- app/ui/Input.vue | 44 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/app/ui/Input.vue b/app/ui/Input.vue index 48b43a7..d6884e3 100644 --- a/app/ui/Input.vue +++ b/app/ui/Input.vue @@ -10,22 +10,47 @@ interface InputProps { name?: string required?: boolean autocomplete?: AutocompleteType + label?: string } -const value = defineModel("value") +const value = defineModel("value") const emit = defineEmits<{ (e: "input", value: string): void + (e: "file", value: File | File[] | null | undefined): void (e: "focus"): void + (e: "blur"): void }>() const props = defineProps() + +const onFileChange = (e: Event) => { + const input = e.target as HTMLInputElement + const files = input.files + + if (!files || files.length == 0) { + value.value = null + emit("file", null) + return + } + + const result = files.length == 1 ? files[0] : Array.from(files) + + value.value = result + emit("file", result) +}