import { Signal, useComputed } from "@preact/signals"; import Button, { button_class } from "@/components/Button.tsx"; import FileInfo from "@/components/FileInfo.tsx"; import { CloseIcon, PlusIcon } from "@/components/Icons.tsx"; import { format_bytes } from "@/src/files.ts"; import { twMerge } from "@/src/tw.ts"; interface FilePickerProps { on_add: (files: File[]) => void; } // Visually hidden, wrap it in a label to open the picker function FilePicker(props: FilePickerProps) { function change(event: Event) { const input = event.currentTarget as HTMLInputElement; const files = Array.from(input.files ?? []); input.value = ""; if (files.length) { props.on_add(files); } } return ; } export interface UploadState { file: File; index: number; count: number; // null while the file is being encrypted progress: number | null; controller: AbortController; } interface UploadingProps { state: UploadState; } function Uploading({ state }: UploadingProps) { const percent = Math.round((state.progress ?? 0) * 100); return (
{state.progress === null ? "Encrypting..." : `Uploading ${percent}%`}
{props.error}
; if (props.pending.value.length === 0) { return ( ); } return (Total size: {format_bytes(total_size.value)}