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