mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-23 10:18:40 +00:00
* Add @uppy/remote-sources preset/plugin * yarn.lock * Update packages/@uppy/remote-sources/README.md Co-authored-by: Merlijn Vos <merlijn@soverin.net> * Use div.uppy-Root for all plugins mounted in DOM; set dir in UIPlugin * remote uppy-Root from all UI plugins, as it will be set in UIPlugin automatically * Remove uppy-Root from file-input * Revert "Update packages/@uppy/remote-sources/README.md" This reverts commit3fd00028f7. * Revert "yarn.lock" This reverts commit04dd8c73de. * Revert "Add @uppy/remote-sources preset/plugin" This reverts commitac1f5df6b3. * Update packages/@uppy/core/src/UIPlugin.js Co-authored-by: Merlijn Vos <merlijn@soverin.net> * Update packages/@uppy/drag-drop/src/DragDrop.jsx Co-authored-by: Merlijn Vos <merlijn@soverin.net> * Update packages/@uppy/core/src/UIPlugin.js Co-authored-by: Renée Kooi <renee@kooi.me> * Revert "Update packages/@uppy/core/src/UIPlugin.js" This reverts commitf91af00d6b. * @uppy/react: add .uppy-Contrainer class name to wrapper div * @uppy/svelte: add .uppy-Contrainer class name to wrapper div Co-authored-by: Merlijn Vos <merlijn@soverin.net> Co-authored-by: Renée Kooi <renee@kooi.me>
57 lines
1.1 KiB
JavaScript
57 lines
1.1 KiB
JavaScript
const React = require('react')
|
|
const PropTypes = require('prop-types')
|
|
const uppyPropType = require('./propTypes').uppy
|
|
|
|
const h = React.createElement
|
|
|
|
class UppyWrapper extends React.Component {
|
|
constructor (props) {
|
|
super(props)
|
|
|
|
this.refContainer = this.refContainer.bind(this)
|
|
}
|
|
|
|
componentDidMount () {
|
|
this.installPlugin()
|
|
}
|
|
|
|
componentDidUpdate (prevProps) {
|
|
if (prevProps.uppy !== this.props.uppy) {
|
|
this.uninstallPlugin(prevProps)
|
|
this.installPlugin()
|
|
}
|
|
}
|
|
|
|
componentWillUnmount () {
|
|
this.uninstallPlugin()
|
|
}
|
|
|
|
installPlugin () {
|
|
const plugin = this.props.uppy
|
|
.getPlugin(this.props.plugin)
|
|
|
|
plugin.mount(this.container, plugin)
|
|
}
|
|
|
|
uninstallPlugin (props = this.props) {
|
|
const plugin = props.uppy
|
|
.getPlugin(this.props.plugin)
|
|
|
|
plugin.unmount()
|
|
}
|
|
|
|
refContainer (container) {
|
|
this.container = container
|
|
}
|
|
|
|
render () {
|
|
return h('div', { className: 'uppy-Container', ref: this.refContainer })
|
|
}
|
|
}
|
|
|
|
UppyWrapper.propTypes = {
|
|
uppy: uppyPropType,
|
|
plugin: PropTypes.string.isRequired,
|
|
}
|
|
|
|
module.exports = UppyWrapper
|