qat

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
Example.qx22 lines, 1 reactive nameOpen in the playground
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 state

Add it

shell1 line
npx qatjs add upload

FileUpload

As a custom element: <ui-file-upload>.

FileUpload: props
PropTypeAttribute
labelstringyes
acceptstringyes
maxSizenumberyes
multiplebooleanyes
hintQatNodeproperty only
itemsUploadItem[]property only
disabledbooleanyes
FileUpload: events
EventDetail
on:addCustomEvent<File[]>
on:removeCustomEvent<string>
on:retryCustomEvent<string>

Keys

KeyDoes
Enter, Spaceon “choose files”: the system’s file dialog