File upload
FileUpload. It is copied into your app’s ui/ by qatjs add upload: the code is yours to edit.
Example
Invoices
Drop files here or PDF or images up to 10 MB each
- invoice-10482.pdf184 KB
import FileUpload from './ui/upload/upload.qx'
export default function Example() {
let uploads = state([{ id: 'u1', name: 'invoice-10482.pdf', size: 188416, progress: 70 }])
return (
<FileUpload
label="Invoices"
accept=".pdf,image/*"
maxSize={10 * 1048576}
multiple
hint="PDF or images up to 10 MB each"
items={uploads}
on:add={(files) =>
(uploads = [
...uploads,
...files.map((f, i) => ({ id: f.name + i, name: f.name, size: f.size, progress: 100 })),
])
}
on:remove={(id) => (uploads = uploads.filter((u) => u.id !== id))}
/>
)
}uploads stateAdd it
npx qatjs add uploadFileUpload
As a custom element: <ui-file-upload>.
| Prop | Type | Attribute |
|---|---|---|
label | string | yes |
accept | string | yes |
maxSize | number | yes |
multiple | boolean | yes |
hint | QatNode | property only |
items | UploadItem[] | property only |
disabled | boolean | yes |
| Event | Detail |
|---|---|
on:add | CustomEvent<File[]> |
on:remove | CustomEvent<string> |
on:retry | CustomEvent<string> |
Keys
| Key | Does |
|---|---|
| Enter, Space | on “choose files”: the system’s file dialog |