diff --git a/.eslintrc.js b/.eslintrc.js index 8e4d0624de..6d5bb7ff5e 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -202,6 +202,7 @@ module.exports = { 'packages/@uppy/box/src/**/*.js', 'packages/@uppy/drag-drop/src/**/*.js', 'packages/@uppy/drop-target/src/**/*.js', + 'packages/@uppy/dropbox/src/**/*.js', 'packages/@uppy/compressor/src/**/*.js', 'packages/@uppy/vue/src/**/*.js', ], diff --git a/packages/@uppy/dropbox/package.json b/packages/@uppy/dropbox/package.json index 757396dd5c..d9fd55b5f1 100644 --- a/packages/@uppy/dropbox/package.json +++ b/packages/@uppy/dropbox/package.json @@ -4,6 +4,7 @@ "version": "2.0.5", "license": "MIT", "main": "lib/index.js", + "type": "module", "types": "types/index.d.ts", "keywords": [ "file uploader", diff --git a/packages/@uppy/dropbox/src/Dropbox.jsx b/packages/@uppy/dropbox/src/Dropbox.jsx new file mode 100644 index 0000000000..4d30598f1d --- /dev/null +++ b/packages/@uppy/dropbox/src/Dropbox.jsx @@ -0,0 +1,70 @@ +import { UIPlugin } from '@uppy/core' +import { Provider } from '@uppy/companion-client' +import { ProviderViews } from '@uppy/provider-views' +import { h } from 'preact' + +import packageJson from '../package.json' +import locale from './locale.js' + +export default class Dropbox extends UIPlugin { + static VERSION = packageJson.version + + constructor (uppy, opts) { + super(uppy, opts) + this.id = this.opts.id || 'Dropbox' + Provider.initPlugin(this, opts) + this.title = this.opts.title || 'Dropbox' + this.icon = () => ( + + ) + + this.provider = new Provider(uppy, { + companionUrl: this.opts.companionUrl, + companionHeaders: this.opts.companionHeaders, + companionKeysParams: this.opts.companionKeysParams, + companionCookiesRule: this.opts.companionCookiesRule, + provider: 'dropbox', + pluginId: this.id, + }) + + this.defaultLocale = locale + + this.i18nInit() + this.title = this.i18n('pluginNameDropbox') + + this.onFirstRender = this.onFirstRender.bind(this) + this.render = this.render.bind(this) + } + + install () { + this.view = new ProviderViews(this, { + provider: this.provider, + }) + + const { target } = this.opts + if (target) { + this.mount(target, this) + } + } + + uninstall () { + this.view.tearDown() + this.unmount() + } + + onFirstRender () { + return Promise.all([ + this.provider.fetchPreAuthToken(), + this.view.getFolder(), + ]) + } + + render (state) { + return this.view.render(state) + } +} diff --git a/packages/@uppy/dropbox/src/index.js b/packages/@uppy/dropbox/src/index.js index a10187b7a6..477d56d48b 100644 --- a/packages/@uppy/dropbox/src/index.js +++ b/packages/@uppy/dropbox/src/index.js @@ -1,69 +1 @@ -const { UIPlugin } = require('@uppy/core') -const { Provider } = require('@uppy/companion-client') -const { ProviderViews } = require('@uppy/provider-views') -const { h } = require('preact') - -const locale = require('./locale') - -module.exports = class Dropbox extends UIPlugin { - static VERSION = require('../package.json').version - - constructor (uppy, opts) { - super(uppy, opts) - this.id = this.opts.id || 'Dropbox' - Provider.initPlugin(this, opts) - this.title = this.opts.title || 'Dropbox' - this.icon = () => ( - - ) - - this.provider = new Provider(uppy, { - companionUrl: this.opts.companionUrl, - companionHeaders: this.opts.companionHeaders, - companionKeysParams: this.opts.companionKeysParams, - companionCookiesRule: this.opts.companionCookiesRule, - provider: 'dropbox', - pluginId: this.id, - }) - - this.defaultLocale = locale - - this.i18nInit() - this.title = this.i18n('pluginNameDropbox') - - this.onFirstRender = this.onFirstRender.bind(this) - this.render = this.render.bind(this) - } - - install () { - this.view = new ProviderViews(this, { - provider: this.provider, - }) - - const { target } = this.opts - if (target) { - this.mount(target, this) - } - } - - uninstall () { - this.view.tearDown() - this.unmount() - } - - onFirstRender () { - return Promise.all([ - this.provider.fetchPreAuthToken(), - this.view.getFolder(), - ]) - } - - render (state) { - return this.view.render(state) - } -} +export { default } from './Dropbox.jsx' diff --git a/packages/@uppy/dropbox/src/locale.js b/packages/@uppy/dropbox/src/locale.js index 2c86a87245..872861452d 100644 --- a/packages/@uppy/dropbox/src/locale.js +++ b/packages/@uppy/dropbox/src/locale.js @@ -1,4 +1,4 @@ -module.exports = { +export default { strings: { pluginNameDropbox: 'Dropbox', }, diff --git a/website/src/docs/dropbox.md b/website/src/docs/dropbox.md index f898684ff0..5ec0d9f7da 100644 --- a/website/src/docs/dropbox.md +++ b/website/src/docs/dropbox.md @@ -130,7 +130,7 @@ This option correlates to the [RequestCredentials value](https://developer.mozil ```js -module.exports = { +export default { strings: { pluginNameDropbox: 'Dropbox', },