Make dialog default to only show supported formats

This commit is contained in:
JovannMC 2024-11-13 17:49:57 +03:00
parent b724f066ba
commit 80602cadf6
No known key found for this signature in database
3 changed files with 4 additions and 1 deletions

BIN
bun.lockb

Binary file not shown.

View File

@ -10,6 +10,7 @@
files: File[] | undefined; files: File[] | undefined;
onupload?: () => void; onupload?: () => void;
isMobile: boolean; isMobile: boolean;
acceptedFormats?: string[];
} }
$effect(() => { $effect(() => {
@ -20,7 +21,7 @@
let fileInput = $state<HTMLInputElement>(); let fileInput = $state<HTMLInputElement>();
let dragOver = $state(false); let dragOver = $state(false);
let { files = $bindable(), onupload, isMobile }: Props = $props(); let { files = $bindable(), onupload, isMobile, acceptedFormats }: Props = $props();
function upload() { function upload() {
if (!fileInput) return; if (!fileInput) return;
@ -108,6 +109,7 @@
class="hidden" class="hidden"
bind:this={fileInput} bind:this={fileInput}
onchange={addFiles} onchange={addFiles}
accept={acceptedFormats?.join(",") ?? "*"}
multiple multiple
/> />

View File

@ -77,6 +77,7 @@
isMobile={data.isMobile} isMobile={data.isMobile}
bind:files={ourFiles} bind:files={ourFiles}
onupload={runUpload} onupload={runUpload}
acceptedFormats={converters.flatMap((c) => c.supportedFormats)}
/> />
</div> </div>