File Upload

Eine Ablagezone um das native Dateifeld: Dateien anklicken oder ablegen, gegen erlaubte Typen sowie Größen- und Anzahlgrenzen geprüft und mit Größe, Bildvorschau und Entfernen-Schaltfläche aufgelistet.

Verfügbar für
  • Angular: verfügbar
  • Vue: verfügbar
  • React: verfügbar
  • React Native: verfügbar

Verwendung

PNG, JPG or PDF, up to 2 MB each

Up to four files, attached to the meeting notes.

Import

ts
import {
  SoneFileUploadComponent,
} from "@surface-one/angular/file-upload";

API-Referenz

SoneFileUploadComponentKomponente

`<sone-file-upload>` — a dropzone around the native `<input type="file">` (Nuxt UI FileUpload): click, Enter / Space or a drop add files, checked against `accept`, `maxSize` and `maxFiles` (a polite alert names what was turned away), listed with their size, an image preview and a remove button. `[(value)]` is a `File[]` (also `ngModel` / `formControl`), mirrored into the input so a native form submits it too. Inside a `[soneField]` the field names and describes the input.

Selektor
sone-file-upload
Inputs
NameTyp Standard
valuebidirektional

The files — `[(value)]`.

File[][]
accept

The native `accept` list: `image/*`, `.pdf,.docx`, `application/json`.

string | nullnull
multiple

More than one file; without it a new file replaces the current one.

booleanfalse
maxSize

The largest file, in bytes.

number | nullnull
maxFiles

The most files (with `multiple`).

number | nullnull
preview

Show image files as thumbnails in the list.

booleantrue
disabledbooleanfalse
invalid

A failed check: `aria-invalid` and the destructive dropzone border.

booleanfalse
inputId

The input's id (a `soneFieldLabel for` points at it); generated when left out.

string | nullnull
namestring | nullnull
label

The dropzone's text, which also names the input.

—$localize`Drop files here or click to browse`
description

A quieter line under it: the accepted types and the size limit.

string | nullnull
listLabel

The file list's accessible name.

—$localize`:A file upload's list of files:Selected files`
removeLabel(name: string) => string(name) => $localize`:Remove a file from an upload:Remove ${name}:name:`
rejectionLabel

What the alert says about a file that was turned away.

(rejection: FileRejection<File>) => string(r) => this.defaultRejection(r)
locale

The locale file sizes are written in.

string"en"
Outputs
NameTyp
rejected

Files that were turned away by the last pick or drop.

FileRejection<File>[]