1.3.0 • Published 2 years ago
@illa-design/upload v1.3.0
Upload
The Upload component is used to upload files.
Installation
yarn add @illa-design/uploadImport Component
import { Upload } from "@illa-design/upload"API
Upload Basic Properties
| Props | Desc | Type | Default |
|---|---|---|---|
| defaultFileList | The default uploaded file list | UploadItem[] | - |
| fileList | The uploaded file list | UploadItem[] | - |
| pictureUpload | If true, the file type is image | boolean | - |
| directory | If true, the file type is directory | boolean | - |
| accept | The file types are accepted | string | - |
| customRequest | Custom the request option | (options: RequestOptions) => UploadRequestReturn | - |
| listType | Two types of the list: the text list and picture list | "text" | "picture-list" | "text" |
| showUploadList | If true, show the upload list | boolean | CustomIconType | true |
| autoUpload | If true, auto upload the file | boolean | true |
| action | URL of the upload | string | - |
| limit | The limit of max number of the uploaded files | number | - |
| disabled | If true, the status is diabled | boolean | - |
| drag | If true, users can drag files to upload | boolean | - |
| multiple | Select multiple files | boolean | - |
| tip | The text tips | string| React.ReactNode | - |
| headers | The headers while uploading | object | - |
| data | The data of the body | object| ((any:any)=> obeject) | - |
| name | The file name | string|((any:any)=> string) | - |
| withCredentials | If true, upload request with cookies | boolean | - |
| renderUploadList | Custom the uploaded file list | (fileList: UploadItem[], uploadListProps: UploadListProps) => ReactNode | - |
| beforeUpload | Call back before upload | (file: File, filesList: File[]) => boolean | Promise<any> | ()=>true |
Upload Events
| Props | Desc | Type | Default |
|---|---|---|---|
| onChange | Callback when change | (fileList: UploadItem[], file: UploadItem) => void | - |
| onRemove | Callback when remove | (file: UploadItem, fileList: UploadItem[]) => void | - |
| onProgress | Callback when on progress | (file: UploadItem, e?: ProgressEvent) => void | - |
| onReupload | Call back when reupload | (file: UploadItem) => void | - |
| onExceedLimit | Call back when exceed limit of files | (files: File[], fileList: UploadItem[]) => void | - |
uploadList Basic Properties
| Props | Desc | Type | Default |
|---|---|---|---|
| disabled | If true, the list is disabled | boolean | - |
uploadList Events
| Props | Desc | Type | Default |
|---|---|---|---|
| onAbort | Callback when uploading file abort | (file: UploadItem) => void | - |
| onRemove | Callback when click delete file button | (file: UploadItem) => void | - |
| onReupload | Callback when reupload | (file: UploadItem) => void | - |
uploadItem Basic Properties
| Props | Desc | Type | Default |
|---|---|---|---|
| percent | Upload progress percentage | number | - |
| response | The response returned by the current file upload request | object | - |
| url | File's url | string | - |
| name | File name | string | - |
| uid | The unique identifier of the currently uploaded file | string | - |
| status | The status of file uploading | UploadStatus | - |
| originFile | File object | File | - |
Examples
Basic usage
<Upload placeholder={"upload"} />Set upload with request success
<Upload
action={"/"}
withCredentials={true}
beforeUpload={() => true}
headers={{ secChUaArch: "arm" }}
onChange={(fileList, file) => {
files = fileList
curFile = file
}}
name={() => "test"}
data={{ test: "test" }}
placeholder={"upload"}
/>Set upload with drag mode
<Upload drag={true} placeholder={"upload"} />Set upload without autoUpload
<Upload autoUpload={false} placeholder={"upload"} />Set upload with file type
<Upload
action={"/"}
placeholder={"upload"}
accept={".jpg, .jpeg, .png"}
/>1.2.0
2 years ago
1.3.0
2 years ago
1.1.0
2 years ago
1.0.29
2 years ago
1.0.28
2 years ago
1.0.27
2 years ago
1.0.31
2 years ago
1.0.30
2 years ago
1.0.22
3 years ago
1.0.21
3 years ago
1.0.26
3 years ago
1.0.25
3 years ago
1.0.24
3 years ago
1.0.23
3 years ago
1.0.19
3 years ago
1.0.18
3 years ago
1.0.17
3 years ago
1.0.20
3 years ago
1.0.16
3 years ago
0.0.10
3 years ago
0.0.11
3 years ago
0.0.12
3 years ago
0.0.13
3 years ago
0.0.14
3 years ago
0.0.15
3 years ago
0.0.9
3 years ago
0.0.16
3 years ago
0.0.17
3 years ago
0.0.8
3 years ago
0.0.5
4 years ago
0.0.4
4 years ago
0.0.7
4 years ago
0.0.6
4 years ago
0.0.3
4 years ago
0.0.2
4 years ago
0.0.1
4 years ago