UNPKG

60.4 kBMarkdownView Raw
1:rocket: [Spanish README](./README_ES.md)
2
3# Dropzone UI
4
5
6
7The `best`, most complete and `easy to use`, [React](https://reactjs.org/) file upload library.
8
9:zap: Live demo and code generator : [dropzone-ui.com](https://dropzone-ui.herokuapp.com/)
10
11:heart: it ?, support us by giving a :star: on :octocat: [Github](https://github.com/dropzone-ui/dropzone-ui) :D
12
13Very soon: :eyes: Dropzone-ui v7 with suuport for React 17 and 18
14
15[![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/dropzone-ui/react/blob/HEAD/LICENSE)
16[![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)
17[![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)
18[![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)
19[![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)
20[![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)
21[![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/)
22[![Known Vulnerabilities](https://snyk.io/test/github/dropzone-ui/react/badge.svg)](https://snyk.io/test/github/dropzone-ui/react)
23[![Package Quality](https://packagequality.com/shield/dropzone-ui.svg)](https://packagequality.com/#?package=dropzone-ui)
24[![install size](https://packagephobia.com/badge?p=@dropzone-ui/react)](https://packagephobia.com/result?p=@dropzone-ui/react)
25[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/dropzone-ui/react.svg)](http://isitmaintained.com/project/dropzone-ui/react)
26[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
27[![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)
28[![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)
29
30<p align="center">
31 <img src="https://user-images.githubusercontent.com/43678736/148801752-954fa819-023d-4596-b557-56f7a38f4745.png" align="center">
32</p>
33
34## Key Features
35
36- :white_check_mark: File validation: Validate files before uploading.
37- :art: File Image previews: See a thumbnail preview
38- :framed_picture: [Full screen image previews](#image-full-screen-preview): Add more interacion with a full screen preview of images
39- :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)
40- :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).
41- :airplane: File upload: Upload valid files to a server.
42- :performing_arts: Out of the box design and style.
43- :cake: Easy to use. Probably, this is the killer feature you are looking for in a package.
44
45## Main Content
46
47Ordered by use:
48
49- :books: [\<Full Documentation\>](#dropzone-ui-react-components-api)
50
51- :performing_arts: [\<Examples and use cases\>](#Usage-and-examples)
52
53- :computer: [\<Server side implementation/>](#uploading)
54
55- :earth_americas: [\<Localization\>](#localization)
56
57- [Code generator](#code-generator)
58
59- [Supporters](#supporters)
60
61## Sample result:
62
63On `Drag`, `Drop`, `Upload` and full screen `preview`. (also changing view mode from `grid` to `list`).
64
65<p align="center">
66<a href="https://github.com/dropzone-ui/react#readme">
67<img align="center" width="100%" src="https://user-images.githubusercontent.com/43678736/139614260-602b512c-cf78-48fe-ae57-1057e7ec8135.gif" alt="dropone-ui-preview">
68</a>
69
70</p>
71
72- More previews [here](#more-previews).
73
74- 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
75
76## Code generator
77
78Want to generate the code that fits your needs? Just interact with the code generator [here](http://www.dropzone-ui.com/).
79
80## Requirement
81
82`@dropzone-ui/react` is based on [React Hooks](https://reactjs.org/docs/hooks-intro.html). It requires `react v16.8+`.
83
84`@dropzone-ui/react` uses [axios](https://www.npmjs.com/package/axios) for uploading files. It requires `axios v0.24.0+`.
85
86## Installation
87
88@dropzone-ui/react is available as an [npm package](https://www.npmjs.com/package/@dropzone-ui/react).
89
90For uploading files, peer dependency [axios](https://www.npmjs.com/package/axios) must be also installed together with `dropzone-ui`.
91
92```sh
93// with npm
94npm i @dropzone-ui/react axios
95```
96
97```sh
98// with yarn
99yarn add @dropzone-ui/react axios
100```
101
102## Usage and examples
103
104Here is a quick example to get you started, **it's all you need**:
105
106```jsx
107import * as React from "react";
108import ReactDOM from "react-dom";
109import { Dropzone, FileItem } from "@dropzone-ui/react";
110Function App() {
111 const [files, setFiles] = React.useState([]);
112 const updateFiles = (incommingFiles) => {
113 setFiles(incommingFiles);
114 };
115 return (
116 <Dropzone onChange={updateFiles} value={files}>
117 {files.map((file) => (
118 <FileItem {...file} preview />
119 ))}
120 </Dropzone>
121 );
122}
123
124ReactDOM.render(<App />, document.querySelector("#app"));
125```
126
127Yes, it's really all you need to get started as you can see in these live and interactive demos:
128
129| Name | Codesandbox link |
130| -------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
131| Dropzone Basic example | [![Edit Button](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/basic-3j01v?file=/src/index.js) |
132| Dropzone Complete example | [![Edit Button](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/complete-946hz?file=/src/index.js) |
133| File item props | [![Edit Button](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/fileitem-props-o0w5x) |
134| 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) |
135| 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) |
136| 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) |
137| 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) |
138| InputFileButton & FileItemContainer | [![Edit Button](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/inputbutton-example-poqsn?file=/src/App.js) |
139| `localización`: multilanguage example | [![Edit Button](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/localization-6ew1i?file=/src/App.js) |
140| 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) |
141| 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) |
142
143# Uploading
144
145Dropzone-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.
146
147For uploading files through dropzone-ui, you should follow at least this guidelines:
148
149- Server Endpoint should get the file from `req.files.file`.
150- Server Response should follow the [`DropzoneUIResponse`](#dropzoneuiresponse) structure for returning a response.
151
152## Server example
153
154Bellow, 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.
155
156The complete code can be found [here](https://github.com/dropzone-ui/file-upload-server-side#readme).
157
158<a href="https://github.com/dropzone-ui/file-upload-server-side#readme">
159<img src="https://i.cloudup.com/zfY6lL7eFa-300x300.png" width="120px" height="35px" alt="server"/>
160</a>
161
162```js
163const express = require("express");
164const fileUpload = require("express-fileupload");
165// ... some code
166app.post("/upload-my-file", async (req, res) => {
167 try {
168 if (!req.files) {
169 res.send({
170 status: false,
171 message: "There was no file found in request",
172 payload: {},
173 });
174 } else {
175 //Use the name of the input field (i.e. "file") to retrieve the uploaded file
176 let file = req.files.file;
177 //Use the mv() method to place the file in upload directory (i.e. "uploads")
178 file.mv("./uploads/" + file.name);
179 //send response
180 res.send({
181 status: true,
182 message: "File was uploaded successfuly",
183 payload: {
184 name: file.name,
185 mimetype: file.mimetype,
186 size: file.size,
187 path: "/files/uploads/",
188 url: "https://my-ftp-server.com/bjYJGFYgjfVGHVb",
189 },
190 });
191 }
192 } catch (err) {
193 res.status(500).send({
194 status: false,
195 message: "Unexpected problem",
196 payload: {},
197 });
198 }
199});
200```
201
202# Localization
203
204Dropzone-ui is available in different languages. So far, we only support `English`, `Spanish`, `French` and `Portuguese`. In next releases this list will be increased.
205
206| Language | Code | Example |
207| ---------------------------------------- | ------- | ---------------------- |
208| English :us: :uk: | `EN-en` | localization="`EN-en`" |
209| Spanish :peru: :mexico: :argentina: :es: | `ES-es` | localization="`ES-es`" |
210| Fench :fr: | `FR-fr` | localization="`FR-fr`" |
211| Italian :it: | `IT-it` | localization="`IT-it`" |
212| Portuguese :brazil: :portugal: | `PT-pt` | localization="`PT-pt`" |
213| Russian :ru: | `RU-ru` | localization="`RU-ru`" |
214| Chinese(simplified) :cn: | `ZH-cn` | localization="`ZH-cn`" |
215| Chinese(traditional) :cn: | `ZH-hk` | localization="`ZH-hk`" |
216
217# Dropzone UI react Components API
218
219- [< Dropzone />](#dropzone-api)
220- [< FileItem />](#fileitem-api)
221- [< FullScreenPreview />](#fullscreenpreview-api)
222- [< VideoPreview />](#videopreview-api)
223 [![new-component](https://img.shields.io/badge/new-component-green.svg)](http://www.dropzone-ui.com)
224- [< FileItemContainer />](#fileitemcontainer-api)
225- [< InputButton />](#inputbutton-api)
226- [Special Types](#special-types-api)
227
228## Dropzone API
229
230### Props
231
232| Name | Type | Default | Description |
233| -------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ | --------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
234| 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) . |
235| 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 |
236| children | `node` | `true` | The content of the component. Normally a list of `FileItem` components or a label |
237| clickable | `boolean` | `true` | If true, the dropzone component itself will be clickable |
238| config | Object | { headers: { "content-type": "multipart/form-data;", }, } | Extra configuration for uploading, normally an object with headers or bearer token- |
239| 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"`. |
240| fakeUploading | `boolean` | `undefined` | If true, this flag will make dropzone to simulate a server upload. Use only in development. |
241| footer | `boolean` | `true` | if true, shows the dropzone footer |
242| header | `boolean` | `true` | if true, shows the dropzone header |
243| label | `string` | "Drop your files here" | Label to place when no files selected |
244| 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. |
245| method | `"POST"` \| `"PUT"` \| `"PATCH"` | `"POST"` | The method for uploading. |
246| 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. |
247| maxFileSize | `number` | `undefined` | max file size allowed in bytes. if not preent, will not be considered on validating the file |
248| 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. |
249| 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. |
250| 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 |
251| onChangeView | `Function` | `undefined` | Event that ocurs when view mode has changed. First parameter is the current view mode. |
252| 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) |
253| 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" |
254| 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). |
255| 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 |
256| url | `string` | `undefined` | The url endpoint to upload the files. Server response must match [DropzoneUIResponse](#dropzoneuiresponse) structure |
257| 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. |
258| 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. |
259| value | `FIleValidated[]` | [ ] | The current list of Files |
260
261## FileItem API
262
263### Props
264
265| Name | Type | Default | Description |
266| ---------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
267| 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 |
268| file | `File` | `undefined` | The actual `File` object instance |
269| errors | `string[]` | `undefined` | The list of errors according to the validation criteria or custom validation function given. |
270| 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. |
271| hd | `boolean` | `undefined` | If present, preview on full screen will be presented in the real image resolution |
272| id | `string` \| `number` | `undefined` | identifier for the file |
273| info | `boolean` | `false` | If present, the info layer and the info button will ve visible |
274| 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. |
275| 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. |
276| 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. |
277| 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. |
278| 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. |
279| preview | `boolean` | `false` | If present, and if `onSee` present, "see" button will be visible and on click will trigger `onSee` function |
280| 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. |
281| uploadMessage | `string` | `undefined` | The message to display when server responds. The server response should follow the structure of an instance of [DropzoneUIResponse](#dropzoneuiresponse) |
282| uploadStatus | `undefined` \| `"uploading"` \| `"success"` \| `"error"` | `undefined` | The status of the upload process |
283| 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. |
284
285## FullScreenPreview API
286
287### Props
288
289| Name | Type | Default | Description |
290| --------- | ---------- | ----------- | ----------------------------------------------------------------- |
291| imgSource | `string` | `undefined` | The url string representation of the image |
292| onClose | `Function` | `undefined` | A function that describes the close behaviour |
293| openImage | `boolean` | `false` | Flag that indicates whether to open the image preview or close it |
294
295## VideoPreview API
296
297### Props
298
299| Name | Type | Default | Description |
300| ----------- | ---------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
301| 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. |
302| onClose | `Function` | `undefined` | A function that describes the close behaviour |
303| openVideo | `boolean` | `undefined` | Flag that indicates whether to open the video preview or close it |
304| autoplay | `boolean` | `undefined` | Flag that indicates whether to play automatically the video or not. |
305| controls | `boolean` | `undefined` | Flag that indicates whether to display the controls in the video player or not. |
306
307## FileItemContainer API
308
309### Props
310
311| Name | Type | Default | Description |
312| -------------------------------------------------------------------------------------------------------------- | -------------------- | ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
313| 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. |
314| 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. |
315| 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`. |
316
317## InputButton API
318
319### Props
320
321| Name | Type | Default | Description |
322| ----------- | ------------------------------------------------------------ | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
323| 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) . |
324| color | `string` | `"#071e25"` | The main color for the button. (e.g. "#FFFFFF", "rgb(255,12,45)") |
325| disabled | `boolean` | `false` | whether the button will be disabled or not |
326| id | `string` | `undefined` | the id of the component |
327| label | `string` | "Browse ..." | If given, this label will be showed inside the button |
328| maxFileSize | `number` | `undefined` | max file size allowed in bytes |
329| multiple | `boolean` | `false` | whether to accept multiple files or not |
330| onChange | `Function` | `undefined` | What to do after selecting the files. Returns the File[] as first parameter |
331| style | `React.CSSProperties` | {} | the in-line style object |
332| text | `"uppercase"` \| `"capitalize"` \| `"lowercase"` \| `"none"` | `"capitalize"` | The text transform for the text inside the button label |
333| textColor | `string` | "white" | The font color in case variant is `"contained"` |
334| 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. |
335| variant | `"text"` \| `"outlined"` \| `"contained"` | `"contained"` | The variant of the button |
336
337# Special Types Api
338
339## FileValidated
340
341This 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.
342
343```jsx
344export enum UPLOADSTATUS {
345 uploading = "uploading",
346 success = "success",
347 error = "error"
348}
349export interface FileValidated {
350 file: File;
351 valid: boolean;
352 id: number| string | undefined;
353 errors?: string[];
354 uploadMessage?: string;
355 uploadStatus?: undefined | UPLOADSTATUS;
356}
357```
358
359## FileDuiResponse
360
361This is the object structure for responses thatcomes from server when Dropzone `onUploadFinish` event is triggeed. This event returns an array of `FileDuiResponse` objects
362
363```jsx
364export interface FileDuiResponse {
365 id: number | string | undefined;
366 serverResponse: DropzoneUIResponse | {};
367}
368```
369
370## DropzoneUIResponse
371
372This is the response structure for each file that server must send when Dropzone perfoms the upload process.
373
374```jsx
375export interface DropzoneUIResponse {
376 status: boolean;
377 message: string;
378 payload: any;
379}
380```
381
382## UploadPromiseAxiosResponse
383
384This is the response object after uploading each file.
385
386```jsx
387export interface UploadPromiseAxiosResponse {
388 serverResponse: FileDuiResponse;
389 uploadedFile: FileValidated;
390}
391```
392
393## CustomValidateFileResponse
394
395This is the response structure for each file that server must send when Dropzone performs the upload process.
396
397```jsx
398export interface CustomValidateFileResponse {
399 valid: boolean;
400 errors?: string[];
401}
402```
403
404## Supporters
405
406Special thanks to these amazing people :star: :
407### :clap: Stargazers
408
409[![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)
410
411### :clap: Forkers
412
413[![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)
414
415## More Previews
416
417### Image full screen preview
418
419<p align="center"><img src="https://camo.githubusercontent.com/58e1d2e245bdd8a4eb7302bc0749ce9fd39bfade9838c4ed7fe9272d94e54eb4/68747470733a2f2f6465762d746f2d75706c6f6164732e73332e616d617a6f6e6177732e636f6d2f75706c6f6164732f61727469636c65732f3577786b31346f367a686c6f7a327a337a7970792e706e67" alt="Image full screen preview" width="100%"/></p>
420
421### Video full screen preview
422
423<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>
424
425## License
426
427This project is licensed under the terms of the
428[MIT license](/LICENSE).
429
430<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>
431
432<br/>
433<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>