1.3.0 • Published 5 months ago

@illa-design/upload v1.3.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
5 months ago

Upload

The Upload component is used to upload files.

Installation

yarn add @illa-design/upload

Import Component

import { Upload } from "@illa-design/upload"

API

Upload Basic Properties

PropsDescTypeDefault
defaultFileListThe default uploaded file listUploadItem[]-
fileListThe uploaded file listUploadItem[]-
pictureUploadIf true, the file type is imageboolean-
directoryIf true, the file type is directoryboolean-
acceptThe file types are acceptedstring-
customRequestCustom the request option(options: RequestOptions) => UploadRequestReturn-
listTypeTwo types of the list: the text list and picture list"text" | "picture-list""text"
showUploadListIf true, show the upload listboolean | CustomIconTypetrue
autoUploadIf true, auto upload the filebooleantrue
actionURL of the uploadstring-
limitThe limit of max number of the uploaded filesnumber-
disabledIf true, the status is diabledboolean-
dragIf true, users can drag files to uploadboolean-
multipleSelect multiple filesboolean-
tipThe text tipsstring| React.ReactNode-
headersThe headers while uploadingobject-
dataThe data of the bodyobject| ((any:any)=> obeject)-
nameThe file namestring|((any:any)=> string)-
withCredentialsIf true, upload request with cookiesboolean-
renderUploadListCustom the uploaded file list(fileList: UploadItem[], uploadListProps: UploadListProps) => ReactNode-
beforeUploadCall back before upload(file: File, filesList: File[]) => boolean | Promise<any>()=>true

Upload Events

PropsDescTypeDefault
onChangeCallback when change(fileList: UploadItem[], file: UploadItem) => void-
onRemoveCallback when remove(file: UploadItem, fileList: UploadItem[]) => void-
onProgressCallback when on progress(file: UploadItem, e?: ProgressEvent) => void-
onReuploadCall back when reupload(file: UploadItem) => void-
onExceedLimitCall back when exceed limit of files(files: File[], fileList: UploadItem[]) => void-

uploadList Basic Properties

PropsDescTypeDefault
disabledIf true, the list is disabledboolean-

uploadList Events

PropsDescTypeDefault
onAbortCallback when uploading file abort(file: UploadItem) => void-
onRemoveCallback when click delete file button(file: UploadItem) => void-
onReuploadCallback when reupload(file: UploadItem) => void-

uploadItem Basic Properties

PropsDescTypeDefault
percentUpload progress percentagenumber-
responseThe response returned by the current file upload requestobject-
urlFile's urlstring-
nameFile namestring-
uidThe unique identifier of the currently uploaded filestring-
statusThe status of file uploadingUploadStatus-
originFileFile objectFile-

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

5 months ago

1.3.0

5 months ago

1.1.0

8 months ago

1.0.29

10 months ago

1.0.28

10 months ago

1.0.27

11 months ago

1.0.31

9 months ago

1.0.30

10 months ago

1.0.22

1 year ago

1.0.21

1 year ago

1.0.26

12 months ago

1.0.25

12 months ago

1.0.24

1 year ago

1.0.23

1 year ago

1.0.19

1 year ago

1.0.18

1 year ago

1.0.17

1 year ago

1.0.20

1 year ago

1.0.16

1 year ago

0.0.10

2 years ago

0.0.11

2 years ago

0.0.12

2 years ago

0.0.13

2 years ago

0.0.14

2 years ago

0.0.15

2 years ago

0.0.9

2 years ago

0.0.16

2 years ago

0.0.17

2 years ago

0.0.8

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago