dromo-uploader-react
Advanced tools
Comparing version 2.1.7 to 2.1.8
@@ -33,2 +33,3 @@ import * as React from 'react'; | ||
open?: boolean; | ||
inline?: boolean; | ||
}; | ||
@@ -38,3 +39,7 @@ declare type Props = (VerboseRequiredProps | SavedSchemaProps) & CommonProps; | ||
dromo: any; | ||
inlineRef: React.RefObject<HTMLDivElement> | null; | ||
constructor(props: Props); | ||
init: () => void; | ||
open: () => void; | ||
initInline: () => void; | ||
componentDidMount(): void; | ||
@@ -41,0 +46,0 @@ componentDidUpdate(prevProps: Props): void; |
@@ -15,8 +15,9 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
function DromoReactUploader() { | ||
function DromoReactUploader(props) { | ||
var _this; | ||
_this = _React$Component.apply(this, arguments) || this; | ||
_this = _React$Component.call(this, props) || this; | ||
_this.inlineRef = null; | ||
_this.open = function () { | ||
_this.init = function () { | ||
if ('fields' in _this.props && 'settings' in _this.props) { | ||
@@ -88,6 +89,22 @@ _this.dromo = new DromoUploader(_this.props.licenseKey, _this.props.fields, _this.props.settings, _this.props.user); | ||
} | ||
}; | ||
_this.open = function () { | ||
_this.init(); | ||
_this.dromo.open(); | ||
}; | ||
_this.initInline = function () { | ||
if (!_this.inlineRef) return; | ||
_this.init(); | ||
_this.dromo.initInline(_this.inlineRef.current); | ||
}; | ||
if (props.inline) { | ||
_this.inlineRef = React.createRef(); | ||
} | ||
return _this; | ||
@@ -99,2 +116,7 @@ } | ||
_proto.componentDidMount = function componentDidMount() { | ||
if (this.props.inline && this.inlineRef) { | ||
this.initInline(); | ||
return; | ||
} | ||
if (this.props.open) this.open(); | ||
@@ -104,2 +126,7 @@ }; | ||
_proto.componentDidUpdate = function componentDidUpdate(prevProps) { | ||
if (this.props.inline) { | ||
this.initInline(); | ||
return; | ||
} | ||
if (!prevProps.open && this.props.open) { | ||
@@ -115,3 +142,3 @@ this.open(); | ||
_proto.componentWillUnmount = function componentWillUnmount() { | ||
if (this.props.open) { | ||
if (this.props.open && !this.props.inline) { | ||
this.dromo.close(); | ||
@@ -122,2 +149,10 @@ } | ||
_proto.render = function render() { | ||
if (this.props.inline) { | ||
return React.createElement("div", { | ||
ref: this.inlineRef, | ||
className: this.props.className, | ||
style: this.props.style | ||
}); | ||
} | ||
if (this.props.children === undefined) return React.createElement(React.Fragment, null); | ||
@@ -124,0 +159,0 @@ return React.createElement("button", { |
@@ -1,2 +0,2 @@ | ||
import { createElement, Fragment, Component } from 'react'; | ||
import { createElement, Fragment, createRef, Component } from 'react'; | ||
import DromoUploader from 'dromo-uploader-js'; | ||
@@ -13,8 +13,9 @@ | ||
function DromoReactUploader() { | ||
function DromoReactUploader(props) { | ||
var _this; | ||
_this = _React$Component.apply(this, arguments) || this; | ||
_this = _React$Component.call(this, props) || this; | ||
_this.inlineRef = null; | ||
_this.open = function () { | ||
_this.init = function () { | ||
if ('fields' in _this.props && 'settings' in _this.props) { | ||
@@ -86,6 +87,22 @@ _this.dromo = new DromoUploader(_this.props.licenseKey, _this.props.fields, _this.props.settings, _this.props.user); | ||
} | ||
}; | ||
_this.open = function () { | ||
_this.init(); | ||
_this.dromo.open(); | ||
}; | ||
_this.initInline = function () { | ||
if (!_this.inlineRef) return; | ||
_this.init(); | ||
_this.dromo.initInline(_this.inlineRef.current); | ||
}; | ||
if (props.inline) { | ||
_this.inlineRef = createRef(); | ||
} | ||
return _this; | ||
@@ -97,2 +114,7 @@ } | ||
_proto.componentDidMount = function componentDidMount() { | ||
if (this.props.inline && this.inlineRef) { | ||
this.initInline(); | ||
return; | ||
} | ||
if (this.props.open) this.open(); | ||
@@ -102,2 +124,7 @@ }; | ||
_proto.componentDidUpdate = function componentDidUpdate(prevProps) { | ||
if (this.props.inline) { | ||
this.initInline(); | ||
return; | ||
} | ||
if (!prevProps.open && this.props.open) { | ||
@@ -113,3 +140,3 @@ this.open(); | ||
_proto.componentWillUnmount = function componentWillUnmount() { | ||
if (this.props.open) { | ||
if (this.props.open && !this.props.inline) { | ||
this.dromo.close(); | ||
@@ -120,2 +147,10 @@ } | ||
_proto.render = function render() { | ||
if (this.props.inline) { | ||
return createElement("div", { | ||
ref: this.inlineRef, | ||
className: this.props.className, | ||
style: this.props.style | ||
}); | ||
} | ||
if (this.props.children === undefined) return createElement(Fragment, null); | ||
@@ -122,0 +157,0 @@ return createElement("button", { |
{ | ||
"name": "dromo-uploader-react", | ||
"version": "2.1.7", | ||
"version": "2.1.8", | ||
"description": "Easy to use data (CSV, TSV, Excel) importer", | ||
@@ -64,4 +64,4 @@ "author": "ankitgoyal100", | ||
"dependencies": { | ||
"dromo-uploader-js": "^2.1.7" | ||
"dromo-uploader-js": "^2.1.8" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
36588
306
Updateddromo-uploader-js@^2.1.8