React component to handle file uploads with drag and drop support.
This is an in-progress project that will grow with my needs, but if you have any sugestions or requests I'm listening.:wink:
import React, { Component } from 'react';
import InputFile from 'ds-react-input-file';
class App extends Component {
render() {
return (
<InputFile onComplete={result => console.log(result)} />
);
}
}
Attribute | Type | Behavior | Default | Mandatory |
---|---|---|---|---|
children | React Element |
Gets drawn instead of the default button view | undefined |
false |
onComplete | Function |
Called with Any when upload completes |
- | true |
onProgress | Function |
Called with Object when upload status changes (Shape == { porcentage:Integer , bits:Integer }) |
- | false |
onError | Function |
Called with Error when fail |
(err) => { // hande error } |
false |
multiple | Boolean |
Allows multi-selection and forces onComplete to return an Array |
false |
false |
noDrop | Boolean |
Disables drag and drop support | false |
false |
noClick | Boolean |
Disables click support | false |
false |
readAs | Enum['TEXT', 'DATA_URL', 'BINARY_STRING', 'ARRAY_BUFFER', 'NO_READ'] |
Sets the read mode of FileReader. NO_READ returns raw input. |
'TEXT' | false |
output | Enum['JSON'] |
Formats the result | - | false |
accept | ACCEPT helpers, extension name or mime-type |
Limits input types. For ACCEPT helpers see Live demo with samples | - | false |
- Added accessibility support
- Added support for custom label
- Improved examples
- Fixed a typo in docs
- Fixed samples page title
- Fixed docs
- Added accept support to limit input types
- Changed output default and options
- Removed default error handling function
- Fixed a bug that was preventing some children from being clicked
- Added option to disable file read
- Added option to disable click support
- Added progress handler
- Added drag and drop support
- Removed dependencies
- Basic functionality