mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-26 11:44:53 +00:00
react: revert UppyWrapper version of <ProgressBar />
This commit is contained in:
parent
ce5d19bb35
commit
aaae797a0f
1 changed files with 34 additions and 8 deletions
|
|
@ -1,23 +1,49 @@
|
|||
const React = require('react')
|
||||
const PropTypes = require('prop-types')
|
||||
const UppyCore = require('../core/Core')
|
||||
const UppyWrapper = require('./Wrapper')
|
||||
const UppyCore = require('../core')
|
||||
const DragDropPlugin = require('../plugins/ProgressBar')
|
||||
|
||||
const h = React.createElement
|
||||
|
||||
/**
|
||||
* React component that renders an area in which files can be dropped to be
|
||||
* uploaded.
|
||||
* React component that renders a progress bar at the top of the page.
|
||||
*/
|
||||
|
||||
const ProgressBar = (props) =>
|
||||
h(UppyWrapper, props)
|
||||
class ProgressBar extends React.Component {
|
||||
componentDidMount () {
|
||||
const uppy = this.props.uppy
|
||||
const options = Object.assign(
|
||||
{},
|
||||
this.props,
|
||||
{ target: this.container }
|
||||
)
|
||||
delete options.uppy
|
||||
|
||||
uppy.use(DragDropPlugin, options)
|
||||
|
||||
this.plugin = uppy.getPlugin('ProgressBar')
|
||||
}
|
||||
|
||||
componentWillUnmount () {
|
||||
const uppy = this.props.uppy
|
||||
|
||||
uppy.removePlugin(this.plugin)
|
||||
}
|
||||
|
||||
render () {
|
||||
return h('div', {
|
||||
ref: (container) => {
|
||||
this.container = container
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
ProgressBar.propTypes = {
|
||||
uppy: PropTypes.instanceOf(UppyCore).isRequired
|
||||
uppy: PropTypes.instanceOf(UppyCore).isRequired,
|
||||
fixed: PropTypes.bool
|
||||
}
|
||||
ProgressBar.defaultProps = {
|
||||
plugin: 'ProgressBar'
|
||||
}
|
||||
|
||||
module.exports = ProgressBar
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue