mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-29 21:13:21 +00:00
* relocate .vscode
* Switch to transloadit linter
* Update .eslintrc.json
* autofix code
* unlink and install eslint-config-transloadit@1.1.1
* Change 0 to "off"
* Don't change 'use strict'
* Do not vertically align
* disable key-spacing
* add import/no-extraneous-dependencies per package
* add more react/a11y warnings
* Revert "autofix code"
This reverts commit 14c8a8cde8.
* add import/no-extraneous-dependencies per example and main package
* autofix code (2)
* Allow devDependencies in ./bin
* Change import/no-extraneous-dependencies to warn again
* upgrade linter
* Set import/no-extraneous-dependencies to warn
64 lines
1.2 KiB
JavaScript
64 lines
1.2 KiB
JavaScript
const React = require('react')
|
|
const DragDropPlugin = require('@uppy/drag-drop')
|
|
const propTypes = require('./propTypes')
|
|
|
|
const h = React.createElement
|
|
|
|
/**
|
|
* React component that renders an area in which files can be dropped to be
|
|
* uploaded.
|
|
*/
|
|
|
|
class DragDrop extends React.Component {
|
|
componentDidMount () {
|
|
this.installPlugin()
|
|
}
|
|
|
|
componentDidUpdate (prevProps) {
|
|
if (prevProps.uppy !== this.props.uppy) {
|
|
this.uninstallPlugin(prevProps)
|
|
this.installPlugin()
|
|
}
|
|
}
|
|
|
|
componentWillUnmount () {
|
|
this.uninstallPlugin()
|
|
}
|
|
|
|
installPlugin () {
|
|
const uppy = this.props.uppy
|
|
const options = {
|
|
id: 'react:DragDrop',
|
|
...this.props,
|
|
target: this.container,
|
|
}
|
|
delete options.uppy
|
|
|
|
uppy.use(DragDropPlugin, options)
|
|
|
|
this.plugin = uppy.getPlugin(options.id)
|
|
}
|
|
|
|
uninstallPlugin (props = this.props) {
|
|
const uppy = props.uppy
|
|
|
|
uppy.removePlugin(this.plugin)
|
|
}
|
|
|
|
render () {
|
|
return h('div', {
|
|
ref: (container) => {
|
|
this.container = container
|
|
},
|
|
})
|
|
}
|
|
}
|
|
|
|
DragDrop.propTypes = {
|
|
uppy: propTypes.uppy,
|
|
locale: propTypes.locale,
|
|
}
|
|
DragDrop.defaultProps = {
|
|
}
|
|
|
|
module.exports = DragDrop
|