UNPKG

60.3 kBMarkdownView Raw
1:rocket: [Spanish README](./README_ES.md)
2
3# Dropzone UI
4
5The `best`, most complete and `easy to use`, [React](https://reactjs.org/) file upload library.
6
7:zap: Live demo and code generator : [dropzone-ui.com](http://www.dropzone-ui.com)
8
9:heart: it ?, support us by giving a :star: on :octocat: [Github](https://github.com/dropzone-ui/dropzone-ui) :D
10
11[![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/dropzone-ui/react/blob/HEAD/LICENSE)
12[![npm latest package](https://img.shields.io/npm/v/@dropzone-ui/react.svg?logo=npm&logoColor=fff&label=NPM+package&color=limegreen)](https://www.npmjs.com/package/@dropzone-ui/react)
13[![Rate on Openbase](https://badges.openbase.com/js/rating/@dropzone-ui/react.svg)](https://openbase.com/js/@dropzone-ui/react?utm_source=embedded&utm_medium=badge&utm_campaign=rate-badge)
14[![Node.js CI](https://github.com/dropzone-ui/react-dropzone/actions/workflows/node.js.yml/badge.svg)](https://github.com/dropzone-ui/dropzone-ui-react)
15[![Build Status](https://app.travis-ci.com/dropzone-ui/dropzone-ui-react.svg?branch=master)](https://app.travis-ci.com/dropzone-ui/dropzone-ui-react)
16[![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/dropzone-ui/dropzone-ui.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/dropzone-ui/dropzone-ui/context:javascript)
17[![Total alerts](https://img.shields.io/lgtm/alerts/g/dropzone-ui/dropzone-ui.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/dropzone-ui/dropzone-ui/alerts/)
18[![Known Vulnerabilities](https://snyk.io/test/github/dropzone-ui/react/badge.svg)](https://snyk.io/test/github/dropzone-ui/react)
19[![Package Quality](https://packagequality.com/shield/dropzone-ui.svg)](https://packagequality.com/#?package=dropzone-ui)
20[![install size](https://packagephobia.com/badge?p=@dropzone-ui/react)](https://packagephobia.com/result?p=@dropzone-ui/react)
21[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/dropzone-ui/react.svg)](http://isitmaintained.com/project/dropzone-ui/react)
22[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
23[![GitHub Repo stars](https://img.shields.io/github/stars/dropzone-ui/react?label=Star%20me%20please%20:D&style=social)](https://github.com/dropzone-ui/react)
24[![Twitter URL](https://img.shields.io/twitter/url?style=social&url=https%3A%2F%2Fgithub.com%2Fwellyshen%2Freact-cool-img)](https://twitter.com/intent/tweet?text=With%20@dropzone_ui,%20my%20@reactjs%20%20web%20app%20becomes%20more%20powerful.%20Thanks,%20@JinJoseManuel%20%F0%9F%A4%A9)
25
26<p align="center">
27 <img src="https://user-images.githubusercontent.com/43678736/148801752-954fa819-023d-4596-b557-56f7a38f4745.png" align="center">
28</p>
29
30## Key Features
31
32- :white_check_mark: File validation: Validate files before uploading.
33- :art: File Image previews: See a thumbnail preview
34- :framed_picture: [Full screen image previews](#image-full-screen-preview): Add more interacion with a full screen preview of images
35- :movie_camera: [Full screen video previews](#video-full-screen-preview). Play the video before uploading. [![new-feature](https://img.shields.io/badge/new-feature-green.svg)](https://github.com/dropzone-ui/react-dropzone/releases/tag/v6.4.0)
36- :eyes: status visualization: validation and upload status is shown on a [Tooltip](https://codesandbox.io/s/dropzone-ui-fileitem-resultontooltip-h6hu7) or on [Info Layer](https://codesandbox.io/s/dropzone-ui-fileitem-resultontooltip-h6hu7).
37- :airplane: File upload: Upload valid files to a server.
38- :performing_arts: Out of the box design and style.
39- :cake: Easy to use. Probably, this is the killer feature you are looking for in a package.
40
41## Main Content
42
43Ordered by use:
44
45- :books: [\<Full Documentation\>](#dropzone-ui-react-components-api)
46
47- :performing_arts: [\<Examples and use cases\>](#Usage-and-examples)
48
49- :computer: [\<Server side implementation/>](#uploading)
50
51- :earth_americas: [\<Localization\>](#localization)
52
53- [Code generator](#code-generator)
54
55- [Supporters](#supporters)
56
57## Sample result:
58
59On `Drag`, `Drop`, `Upload` and full screen `preview`. (also changing view mode from `grid` to `list`).
60
61<p align="center">
62<a href="https://github.com/dropzone-ui/react#readme">
63<img align="center" width="100%" src="https://user-images.githubusercontent.com/43678736/139614260-602b512c-cf78-48fe-ae57-1057e7ec8135.gif" alt="dropone-ui-preview">
64</a>
65
66</p>
67
68- More previews [here](#more-previews).
69
70- Did you like the project? Please don't forget to give us a :star: star on :octocat: [GitHub](https://github.com/dropzone-ui/dropzone-ui) :D
71
72## Code generator
73
74Want to generate the code that fits your needs? Just interact with the code generator [here](http://www.dropzone-ui.com/).
75
76## Requirement
77
78`@dropzone-ui/react` is based on [React Hooks](https://reactjs.org/docs/hooks-intro.html). It requires `react v16.8+`.
79
80`@dropzone-ui/react` uses [axios](https://www.npmjs.com/package/axios) for uploading files. It requires `axios v0.24.0+`.
81
82## Installation
83
84@dropzone-ui/react is available as an [npm package](https://www.npmjs.com/package/@dropzone-ui/react).
85
86For uploading files, peer dependency [axios](https://www.npmjs.com/package/axios) must be also installed together with `dropzone-ui`.
87
88```sh
89// with npm
90npm i @dropzone-ui/react axios
91```
92
93```sh
94// with yarn
95yarn add @dropzone-ui/react axios
96```
97
98## Usage and examples
99
100Here is a quick example to get you started, **it's all you need**:
101
102```jsx
103import * as React from "react";
104import ReactDOM from "react-dom";
105import { Dropzone, FileItem } from "@dropzone-ui/react";
106Function App() {
107 const [files, setFiles] = React.useState([]);
108 const updateFiles = (incommingFiles) => {
109 setFiles(incommingFiles);
110 };
111 return (
112 <Dropzone onChange={updateFiles} value={files}>
113 {files.map((file) => (
114 <FileItem {...file} preview />
115 ))}
116 </Dropzone>
117 );
118}
119
120ReactDOM.render(<App />, document.querySelector("#app"));
121```
122
123Yes, it's really all you need to get started as you can see in these live and interactive demos:
124
125| Name | Codesandbox link |
126| -------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
127| Dropzone Basic example | [![Edit Button](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/basic-3j01v?file=/src/index.js) |
128| Dropzone Complete example | [![Edit Button](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/complete-946hz?file=/src/index.js) |
129| File item props | [![Edit Button](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/fileitem-props-o0w5x) |
130| VideoPreview [![new-feature](https://img.shields.io/badge/new-feature-green.svg)](http://www.dropzone-ui.com) | [![Edit Button](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/dropzone-ui-videopreview-6m6he?file=/src/App.js) |
131| FileItem `alwaysActive` Prop [![new-feature](https://img.shields.io/badge/new-feature-green.svg)](http://www.dropzone-ui.com) | [![Edit Button](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/alwaysactive-w15h3) |
132| FileItem `resultOnTooltip` Prop [![new-feature](https://img.shields.io/badge/new-feature-green.svg)](http://www.dropzone-ui.com) | [![Edit Button](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/dropzone-ui-fileitem-resultontooltip-h6hu7?file=/src/App.js) |
133| FileItem with no image preview | [![Edit Button](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/dropzone-ui-file-item-with-no-image-preview-14i2m) |
134| InputFileButton & FileItemContainer | [![Edit Button](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/inputbutton-example-poqsn?file=/src/App.js) |
135| `localización`: multilanguage example | [![Edit Button](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/localization-6ew1i?file=/src/App.js) |
136| File Item `imageUrl` and synthetic files | [![Edit Button](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/imageurl-to-fileitem-m4801?file=/src/App.js) |
137| Default previews extensive list | [![Edit Button](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/defautl-preview-extensive-list-hrwm5?file=/src/App.js) |
138
139# Uploading
140
141Dropzone-ui provides a way to upload files to a server. However, in case you want to make your own upload function, you can take the files that Dropzone `onChange` event returns.
142
143For uploading files through dropzone-ui, you should follow at least this guidelines:
144
145- Server Endpoint should get the file from `req.files.file`.
146- Server Response should follow the [`DropzoneUIResponse`](#dropzoneuiresponse) structure for returning a response.
147
148## Server example
149
150Bellow, there is an example built in [Express.js](https://www.npmjs.com/package/express) wich you can use to create your own server side implementation. Other languages implementations are in construction.
151
152The complete code can be found [here](https://github.com/dropzone-ui/file-upload-server-side#readme).
153
154<a href="https://github.com/dropzone-ui/file-upload-server-side#readme">
155<img src="https://i.cloudup.com/zfY6lL7eFa-300x300.png" width="120px" height="35px" alt="server"/>
156</a>
157
158```js
159const express = require("express");
160const fileUpload = require("express-fileupload");
161// ... some code
162app.post("/upload-my-file", async (req, res) => {
163 try {
164 if (!req.files) {
165 res.send({
166 status: false,
167 message: "There was no file found in request",
168 payload: {},
169 });
170 } else {
171 //Use the name of the input field (i.e. "file") to retrieve the uploaded file
172 let file = req.files.file;
173 //Use the mv() method to place the file in upload directory (i.e. "uploads")
174 file.mv("./uploads/" + file.name);
175 //send response
176 res.send({
177 status: true,
178 message: "File was uploaded successfuly",
179 payload: {
180 name: file.name,
181 mimetype: file.mimetype,
182 size: file.size,
183 path: "/files/uploads/",
184 url: "https://my-ftp-server.com/bjYJGFYgjfVGHVb",
185 },
186 });
187 }
188 } catch (err) {
189 res.status(500).send({
190 status: false,
191 message: "Unexpected problem",
192 payload: {},
193 });
194 }
195});
196```
197
198# Localization
199
200Dropzone-ui is available in different languages. So far, we only support `English`, `Spanish`, `French` and `Portuguese`. In next releases this list will be increased.
201
202| Language | Code | Example |
203| ---------------------------------------- | ------- | ---------------------- |
204| English :us: :uk: | `EN-en` | localization="`EN-en`" |
205| Spanish :peru: :mexico: :argentina: :es: | `ES-es` | localization="`ES-es`" |
206| Fench :fr: | `FR-fr` | localization="`FR-fr`" |
207| Italian :it: | `IT-it` | localization="`IT-it`" |
208| Portuguese :brazil: :portugal: | `PT-pt` | localization="`PT-pt`" |
209| Russian :ru: | `RU-ru` | localization="`RU-ru`" |
210| Chinese(simplified) :cn: | `ZH-cn` | localization="`ZH-cn`" |
211| Chinese(traditional) :cn: | `ZH-hk` | localization="`ZH-hk`" |
212
213# Dropzone UI react Components API
214
215- [< Dropzone />](#dropzone-api)
216- [< FileItem />](#fileitem-api)
217- [< FullScreenPreview />](#fullscreenpreview-api)
218- [< VideoPreview />](#videopreview-api)
219 [![new-component](https://img.shields.io/badge/new-component-green.svg)](http://www.dropzone-ui.com)
220- [< FileItemContainer />](#fileitemcontainer-api)
221- [< InputButton />](#inputbutton-api)
222- [Special Types](#special-types-api)
223
224## Dropzone API
225
226### Props
227
228| Name | Type | Default | Description |
229| -------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ | --------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
230| accept | `string` | `undefined` | The accept attribute value is a string that defines the file types the `Dropzone` should accept. This string is a comma-separated list of unique file type specifiers, wich is compared with the file attributes in order to determine whether that file is valid or not: `"image/*, application/pdf, .psd"`. More info on [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept) . |
231| behaviour | `"add"` \| `"replace"` | `"add"` | The behaviour on drop files. `"add"` option will make `Dropzone` to add files to the current file list. `"replace"` option will make `Dropzone` to replace the current list of files |
232| children | `node` | `true` | The content of the component. Normally a list of `FileItem` components or a label |
233| clickable | `boolean` | `true` | If true, the dropzone component itself will be clickable |
234| config | Object | { headers: { "content-type": "multipart/form-data;", }, } | Extra configuration for uploading, normally an object with headers or bearer token- |
235| disableScroll [![new-feature](https://img.shields.io/badge/new-feature-green.svg)](http://www.dropzone-ui.com) | `boolean` | `undefined` | if present or `true`, removes scrolls and sets the `Dropzone` content (FileItemContainer) in a `grid` view. It also disables `maxHeight` prop. Only `minHeight` prop will work. This feature was added to work together with `resultOnTooltip` prop of `FileItem`. If not present or `false` , FileItemContainer will set csss property `"overflow"` as `"auto"`. |
236| fakeUploading | `boolean` | `undefined` | If true, this flag will make dropzone to simulate a server upload. Use only in development. |
237| footer | `boolean` | `true` | if true, shows the dropzone footer |
238| header | `boolean` | `true` | if true, shows the dropzone header |
239| label | `string` | "Drop your files here" | Label to place when no files selected |
240| localization | `"EN-en"` \| `"ES-es"` \| `"FR-fr"` \| `"PT-pt"`\| `"RU-ru"`\| `"ZH-cn"`\| `"ZH-hk"` | `"EN-en"` | The language to present labels. So far, only `English`, `Portuguese`, `French`,`Russian`, `Chinese` (simplifyed and traditional) and `Spanish` are suported. |
241| method | `"POST"` \| `"PUT"` \| `"PATCH"` | `"POST"` | The method for uploading. |
242| maxFiles | `number` | `undefined` | Max `number` of files to be accepted. If the value is 1, click event dialog will allow just a select a single file. (`multiple` prop on input tag will be false). If not set, vlidation will not consider a max amount of files and user will be allowed to drop or select `Infinity` files. |
243| maxFileSize | `number` | `undefined` | max file size allowed in bytes. if not preent, will not be considered on validating the file |
244| minHeight | `string` | "280px" | The min height of the container in string format. e.g. '50vh' , '20%', '40em', '1rem' . This not consider the space for Footer and Header. |
245| maxHeight | `string` | "450px" | The max height of the container in string format. e.g. '50vh' , '20%', '40em', '1rem'. This not consider the space for Footer and Header. |
246| onChange | (files: `FileValidated[]` ) => `void` | `undefined` | Probably one of the most important methods. The `onChange` event occurs when the value of the file list is changed. Returns as first paramater a list of [FileValidated](#filevalidated) . This event is also triggered when upload starts and when upload finishes for each file in order to update the props on very FIleItem |
247| onChangeView | `Function` | `undefined` | Event that ocurs when view mode has changed. First parameter is the current view mode. |
248| onDrop | (filesDropped: `FileValidated[]`)=> `void` | `undefined` | The onDrop event occurs when files are dropped indide the Dropzone or selected from file dialog. Normally used for retrieving the new files dropped as a list of [FileValidated](#filevalidated) |
249| onUploadStart | (files: `FileValidated[]`) => `void` | `undefined` | This event is triggered when upload process starts. Returns as first parameter the list of [FileValidated](#filevalidated) that will be uploaded. Unlike Onchange, onUploadStart will only return a list of files thta are candidates to be uploaded, in case they are valid or upload status is "error" |
250| onUploadFinish | onUploadFinish?: ( responses: `FileDuiResponse[]` ) => `void`; | `undefined` | This event returns as first aparameter the list of responses for each file after upload process. Responses are instances of [`FileDuiResponse`](#fileduiresponse). |
251| uploadOnDrop | `boolean` | `false` | If true, onDrop event will return the list of files, but also will upload the files if url was set, and also config |
252| url | `string` | `undefined` | The url endpoint to upload the files. Server response must match [DropzoneUIResponse](#dropzoneuiresponse) structure |
253| validator | (f: `File`) => `CustomValidateFileResponse` | `undefined` | Must be a function that recieves as first parameter a File Object instance and must return a [CustomValidateFileResponse](#customvalidatefileresponse) object with 2 fields: valid (boolean value) and `errors` a string array of errors. This function will be used instead of the default validator. |
254| view | `"grid"` \| `"list"` | `"grid"` | `grid` will display files in a grid layout. `list` will display files in a horizontal list. Convenient for saving space in page. If not given, `Dropzone` component will show "change view" button. If `view` is given, it´ll be hidden. |
255| value | `FIleValidated[]` | [ ] | The current list of Files |
256
257## FileItem API
258
259### Props
260
261| Name | Type | Default | Description |
262| ---------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
263| alwaysActive [![new-feature](https://img.shields.io/badge/new-feature-green.svg)](http://www.dropzone-ui.com) | `boolean` | `false` | Flag that makes all buttons visible. If false, the buttons and info will be visible on hover |
264| file | `File` | `undefined` | The actual `File` object instance |
265| errors | `string[]` | `undefined` | The list of errors according to the validation criteria or custom validation function given. |
266| elevation [![new-feature](https://img.shields.io/badge/new-feature-green.svg)](http://www.dropzone-ui.com) | `"1"` \| `"2"` \| `"3"` \| `"4"` \| `1` \| `2` \| `3` \| `4` \| `false` | `undefined` | Shadow depth for the FileItem container. |
267| hd | `boolean` | `undefined` | If present, preview on full screen will be presented in the real image resolution |
268| id | `string` \| `number` | `undefined` | identifier for the file |
269| info | `boolean` | `false` | If present, the info layer and the info button will ve visible |
270| imageUrl | `string` | `undefined` | A string base64 representation or web url of the image that will be set to the `"src"` prop of an `<img/>` tag `<img src={imageUrl} />`. If given, FileItem componnet will use this image instead of reading the image file. |
271| localization | `"EN-en"` \| `"ES-es"` \| `"FR-fr"` \| `"PT-pt"`\| `"RU-ru"`\| `"ZH-cn"`\| `"ZH-hk"` | `"EN-en"` | The language to present labels. So far, only `English`, `Portuguese`, `French`,`Russian`, `Chinese` (simplifyed and traditional) and `Spanish` are suported. |
272| onDelete | (id: `number` \| `string` \| `undefined`) => `void` | `undefined` | This event is triggered when close button is pressed or clicked. Returns as first parameter the if of the corresponding `FileItem` . If not given, `"delete"` button will not be visible. |
273| onSee | `Function` | `undefined` | This event is triggered when "see" button is pressed or clicked. Returns as first parameter the image url in string format. Normally used in `FullScreenPeview` component. If `hd` present, will return the image url in the real quality. Otherwise, will return a minimized image with less resolution in order to save memory. |
274| onWatch [![new-feature](https://img.shields.io/badge/new-feature-green.svg)](http://www.dropzone-ui.com) | `Function` | `undefined` | This event is triggered when "play" button is pressed or clicked. Returns as first parameter the video file object. Normally used in `VideoPreview` component. |
275| preview | `boolean` | `false` | If present, and if `onSee` present, "see" button will be visible and on click will trigger `onSee` function |
276| resultOnTooltip [![new-feature](https://img.shields.io/badge/new-feature-green.svg)](http://www.dropzone-ui.com) | `boolean` | `undefined` | Where to display result of validation: on InfoLayer or in Tooltip when user hovers the FileItem. |
277| uploadMessage | `string` | `undefined` | The message to display when server responds. The server response should follow the structure of an instance of [DropzoneUIResponse](#dropzoneuiresponse) |
278| uploadStatus | `undefined` \| `"uploading"` \| `"success"` \| `"error"` | `undefined` | The status of the upload process |
279| valid | `boolean` | `false` | whether to show a "valid" or "rejected" message ("valid", "denied"). By default valid is `false` (if not present, it's `false` too)This value will affect preview behaviour. If not valid, the preview will not be shown, nor the view button even when `onSee` and `preview` props are present. The functionality to allow to show preview despite of a not valid image file, is a feature that will be added in future releases. |
280
281## FullScreenPreview API
282
283### Props
284
285| Name | Type | Default | Description |
286| --------- | ---------- | ----------- | ----------------------------------------------------------------- |
287| imgSource | `string` | `undefined` | The url string representation of the image |
288| onClose | `Function` | `undefined` | A function that describes the close behaviour |
289| openImage | `boolean` | `false` | Flag that indicates whether to open the image preview or close it |
290
291## VideoPreview API
292
293### Props
294
295| Name | Type | Default | Description |
296| ----------- | ---------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
297| videoSource | `string` | `undefined` | The video source in `string` format or `File` object. When a File object is given `VideoPreview` component will check if video type is included in the supported formats. (`video/mp4`, `video/ogg`, `video/webm`). Normally used with `FileItem` component when returns this value in `onWatch` handler. |
298| onClose | `Function` | `undefined` | A function that describes the close behaviour |
299| openVideo | `boolean` | `undefined` | Flag that indicates whether to open the video preview or close it |
300| autoplay | `boolean` | `undefined` | Flag that indicates whether to play automatically the video or not. |
301| controls | `boolean` | `undefined` | Flag that indicates whether to display the controls in the video player or not. |
302
303## FileItemContainer API
304
305### Props
306
307| Name | Type | Default | Description |
308| -------------------------------------------------------------------------------------------------------------- | -------------------- | ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
309| children | `node` | `true` | The content of he component. Normally a list of `FileItem`. By default `Dropzone` component already uses this component for containing the `FileItem` list children. |
310| view | `"grid"` \| `"list"` | `"grid"` | `grid` will display files in a grid layout. `list` will display files in a horizontal list. Convenient for saving space in page. |
311| disableScroll [![new-feature](https://img.shields.io/badge/new-feature-green.svg)](http://www.dropzone-ui.com) | `boolean` | `undefined` | if present or `true`, removes scrolls and sets the `FileItemContainer` in a `grid` view. It also disables `maxHeight` prop. Only `minHeight` prop will work. This feature was added to work together with `resultOnTooltip` prop of `FileItem`. |
312
313## InputButton API
314
315### Props
316
317| Name | Type | Default | Description |
318| ----------- | ------------------------------------------------------------ | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
319| accept | `string` | `undefined` | The accept attribute value is a string that defines the file types the `InputButton` should accept. This string is a comma-separated list of unique file type specifiers, wich is compared with the file attributes in order to determine whether that file is valid or not: `"image/*, application/pdf, .psd"`. More info on [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept) . |
320| color | `string` | `"#071e25"` | The main color for the button. (e.g. "#FFFFFF", "rgb(255,12,45)") |
321| disabled | `boolean` | `false` | whether the button will be disabled or not |
322| id | `string` | `undefined` | the id of the component |
323| label | `string` | "Browse ..." | If given, this label will be showed inside the button |
324| maxFileSize | `number` | `undefined` | max file size allowed in bytes |
325| multiple | `boolean` | `false` | whether to accept multiple files or not |
326| onChange | `Function` | `undefined` | What to do after selecting the files. Returns the File[] as first parameter |
327| style | `React.CSSProperties` | {} | the in-line style object |
328| text | `"uppercase"` \| `"capitalize"` \| `"lowercase"` \| `"none"` | `"capitalize"` | The text transform for the text inside the button label |
329| textColor | `string` | "white" | The font color in case variant is `"contained"` |
330| validator | (f: `File`) => `CustomValidateFileResponse` | `undefined` | Must be a function that recieves as first parameter a File Object instance and must return a [CustomValidateFileResponse](#customvalidatefileresponse) object with 2 fields: valid (boolean value) and `errors` a string array of errors. This function will be used instead of the default validator. |
331| variant | `"text"` \| `"outlined"` \| `"contained"` | `"contained"` | The variant of the button |
332
333# Special Types Api
334
335## FileValidated
336
337This is the file structure that is used in `onChange` event from Dropzone. This object contains all the required props to work dynamically with `FileItem` component.
338
339```jsx
340export enum UPLOADSTATUS {
341 uploading = "uploading",
342 success = "success",
343 error = "error"
344}
345export interface FileValidated {
346 file: File;
347 valid: boolean;
348 id: number| string | undefined;
349 errors?: string[];
350 uploadMessage?: string;
351 uploadStatus?: undefined | UPLOADSTATUS;
352}
353```
354
355## FileDuiResponse
356
357This is the object structure for responses thatcomes from server when Dropzone `onUploadFinish` event is triggeed. This event returns an array of `FileDuiResponse` objects
358
359```jsx
360export interface FileDuiResponse {
361 id: number | string | undefined;
362 serverResponse: DropzoneUIResponse | {};
363}
364```
365
366## DropzoneUIResponse
367
368This is the response structure for each file that server must send when Dropzone perfoms the upload process.
369
370```jsx
371export interface DropzoneUIResponse {
372 status: boolean;
373 message: string;
374 payload: any;
375}
376```
377
378## UploadPromiseAxiosResponse
379
380This is the response object after uploading each file.
381
382```jsx
383export interface UploadPromiseAxiosResponse {
384 serverResponse: FileDuiResponse;
385 uploadedFile: FileValidated;
386}
387```
388
389## CustomValidateFileResponse
390
391This is the response structure for each file that server must send when Dropzone performs the upload process.
392
393```jsx
394export interface CustomValidateFileResponse {
395 valid: boolean;
396 errors?: string[];
397}
398```
399
400## Supporters
401
402Special thanks to these amazing people :star: :
403### :clap: Stargazers
404
405[![Stargazers repo roster for @dropzone-ui/dropzone-ui-react](https://reporoster.com/stars/dropzone-ui/dropzone-ui-react)](https://github.com/dropzone-ui/dropzone-ui-react/stargazers)
406
407### :clap: Forkers
408
409[![Forkers repo roster for @dropzone-ui/dropzone-ui-react](https://reporoster.com/forks/dropzone-ui/dropzone-ui-react)](https://github.com/dropzone-ui/dropzone-ui-react/network/members)
410
411## More Previews
412
413### Image full screen preview
414
415<p align="center"><img src="https://camo.githubusercontent.com/58e1d2e245bdd8a4eb7302bc0749ce9fd39bfade9838c4ed7fe9272d94e54eb4/68747470733a2f2f6465762d746f2d75706c6f6164732e73332e616d617a6f6e6177732e636f6d2f75706c6f6164732f61727469636c65732f3577786b31346f367a686c6f7a327a337a7970792e706e67" alt="Image full screen preview" width="100%"/></p>
416
417### Video full screen preview
418
419<p align="center"><img src="https://user-images.githubusercontent.com/43678736/148802895-9a5349a7-224d-44df-854b-19d6a1f2d30e.png" alt="Video full screen preview" width="100%"/></p>
420
421## License
422
423This project is licensed under the terms of the
424[MIT license](/LICENSE).
425
426<p align="center"><a href="https://github.com/dropzone-ui/react-dropzone#"><img src="http://randojs.com/images/barsSmallTransparentBackground.gif" alt="Animated footer bars" width="100%"/></a></p>
427
428<br/>
429<p align="center"><a href="https://github.com/dropzone-ui/react-dropzone#readme"><img src="http://randojs.com/images/backToTopButtonTransparentBackground.png" alt="Back to top" height="28"/></a></p>