1 | function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
2 |
|
3 | function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
|
4 |
|
5 | function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
6 |
|
7 | var React = require('react');
|
8 |
|
9 | var PropTypes = require('prop-types');
|
10 |
|
11 | var StatusBarPlugin = require('@uppy/status-bar');
|
12 |
|
13 | var uppyPropType = require('./propTypes').uppy;
|
14 |
|
15 | var h = React.createElement;
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 | var StatusBar = function (_React$Component) {
|
22 | _inheritsLoose(StatusBar, _React$Component);
|
23 |
|
24 | function StatusBar() {
|
25 | return _React$Component.apply(this, arguments) || this;
|
26 | }
|
27 |
|
28 | var _proto = StatusBar.prototype;
|
29 |
|
30 | _proto.componentDidMount = function componentDidMount() {
|
31 | this.installPlugin();
|
32 | };
|
33 |
|
34 | _proto.componentDidUpdate = function componentDidUpdate(prevProps) {
|
35 | if (prevProps.uppy !== this.props.uppy) {
|
36 | this.uninstallPlugin(prevProps);
|
37 | this.installPlugin();
|
38 | }
|
39 | };
|
40 |
|
41 | _proto.componentWillUnmount = function componentWillUnmount() {
|
42 | this.uninstallPlugin();
|
43 | };
|
44 |
|
45 | _proto.installPlugin = function installPlugin() {
|
46 | var uppy = this.props.uppy;
|
47 |
|
48 | var options = _extends({
|
49 | id: 'react:StatusBar'
|
50 | }, this.props, {
|
51 | target: this.container
|
52 | });
|
53 |
|
54 | delete options.uppy;
|
55 | uppy.use(StatusBarPlugin, options);
|
56 | this.plugin = uppy.getPlugin(options.id);
|
57 | };
|
58 |
|
59 | _proto.uninstallPlugin = function uninstallPlugin(props) {
|
60 | if (props === void 0) {
|
61 | props = this.props;
|
62 | }
|
63 |
|
64 | var uppy = props.uppy;
|
65 | uppy.removePlugin(this.plugin);
|
66 | };
|
67 |
|
68 | _proto.render = function render() {
|
69 | var _this = this;
|
70 |
|
71 | return h('div', {
|
72 | ref: function ref(container) {
|
73 | _this.container = container;
|
74 | }
|
75 | });
|
76 | };
|
77 |
|
78 | return StatusBar;
|
79 | }(React.Component);
|
80 |
|
81 | StatusBar.propTypes = {
|
82 | uppy: uppyPropType,
|
83 | hideAfterFinish: PropTypes.bool,
|
84 | showProgressDetails: PropTypes.bool
|
85 | };
|
86 | StatusBar.defaultProps = {};
|
87 | module.exports = StatusBar; |
\ | No newline at end of file |