File Upload
Strefa upuszczania wokół natywnego pola pliku: kliknij lub upuść pliki, sprawdzane pod kątem akceptowanych typów, limitu rozmiaru i liczby, a potem wyświetlane z rozmiarem, podglądem obrazu i przyciskiem usuwania.
Angular: dostępny Vue: dostępny React: dostępny React Native: dostępny
Użycie
Up to four files, attached to the meeting notes.
<div class="demo-stack" style="max-width: 28rem">
<div soneField>
<label soneFieldLabel for="demo-attachments">Attachments</label>
<sone-file-upload
inputId="demo-attachments"
multiple
accept="image/*,.pdf"
[maxSize]="2000000"
[maxFiles]="4"
description="PNG, JPG or PDF, up to 2 MB each"
[(value)]="files"
/>
<p soneFieldDescription>Up to four files, attached to the meeting notes.</p>
</div>
</div>Import
import {
SoneFileUploadComponent,
} from "@surface-one/angular/file-upload";Dokumentacja API
SoneFileUploadComponentKomponent
`<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.
| Nazwa | Typ | Domyślnie |
|---|---|---|
valuedwukierunkoweThe files — `[(value)]`. | File[] | [] |
acceptThe native `accept` list: `image/*`, `.pdf,.docx`, `application/json`. | string | null | null |
multipleMore than one file; without it a new file replaces the current one. | boolean | false |
maxSizeThe largest file, in bytes. | number | null | null |
maxFilesThe most files (with `multiple`). | number | null | null |
previewShow image files as thumbnails in the list. | boolean | true |
disabled | boolean | false |
invalidA failed check: `aria-invalid` and the destructive dropzone border. | boolean | false |
inputIdThe input's id (a `soneFieldLabel for` points at it); generated when left out. | string | null | null |
name | string | null | null |
labelThe dropzone's text, which also names the input. | — | $localize`Drop files here or click to browse` |
descriptionA quieter line under it: the accepted types and the size limit. | string | null | null |
listLabelThe 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:` |
rejectionLabelWhat the alert says about a file that was turned away. | (rejection: FileRejection<File>) => string | (r) => this.defaultRejection(r) |
localeThe locale file sizes are written in. | string | "en" |
| Nazwa | Typ |
|---|---|
rejectedFiles that were turned away by the last pick or drop. | FileRejection<File>[] |