mirror of
https://github.com/open-webui/computer.git
synced 2026-11-23 06:00:43 -05:00
48 lines
1.1 KiB
Svelte
48 lines
1.1 KiB
Svelte
<script lang="ts">
|
|
interface Props {
|
|
onfiles: (files: FileList) => void;
|
|
}
|
|
let { onfiles }: Props = $props();
|
|
|
|
let inputEl: HTMLInputElement | undefined = $state();
|
|
|
|
function trigger() {
|
|
inputEl?.click();
|
|
}
|
|
|
|
function handleChange() {
|
|
if (inputEl?.files && inputEl.files.length > 0) {
|
|
onfiles(inputEl.files);
|
|
inputEl.value = '';
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<input
|
|
bind:this={inputEl}
|
|
type="file"
|
|
multiple
|
|
accept="image/*,.pdf,.txt,.md,.csv,.json,.xml,.yaml,.yml,.html,.css,.js,.ts,.py,.go,.rs,.java,.c,.cpp,.h,.rb,.sh"
|
|
class="hidden"
|
|
onchange={handleChange}
|
|
/>
|
|
|
|
<button
|
|
type="button"
|
|
class="flex items-center justify-center w-6 h-6 rounded-full text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-400 hover:bg-gray-50 dark:hover:bg-white/5 transition-colors duration-100"
|
|
onclick={trigger}
|
|
>
|
|
<svg
|
|
class="size-3.5"
|
|
viewBox="0 0 24 24"
|
|
fill="none"
|
|
stroke="currentColor"
|
|
stroke-width="2"
|
|
stroke-linecap="round"
|
|
stroke-linejoin="round"
|
|
>
|
|
<line x1="12" y1="5" x2="12" y2="19" />
|
|
<line x1="5" y1="12" x2="19" y2="12" />
|
|
</svg>
|
|
</button>
|