dromo-uploader-react 2.1.6 → 2.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +11 -2
- package/dist/index.js +45 -4
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +46 -5
- package/dist/index.modern.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { IColumnHookInput, IColumnHookOutput, IColumnHook, IDeveloperField, IValidatorField, IDeveloperSettings, IRowHookInput, IRowHookOutput, IRowHook, IDeveloperStyleOverrides, IUser, IResultMetadata, IStepHook, IRowDeleteHook, IBeforeFinishCallback, IBulkRowHook, IImporterOptions } from 'dromo-uploader-js';
|
|
2
|
+
import { IColumnHookInput, IColumnHookOutput, IColumnHook, IDeveloperField, IValidatorField, IDeveloperSettings, IRowHookInput, IRowHookOutput, IRowHook, IDeveloperStyleOverrides, IUser, IResultMetadata, IStepHook, IRowDeleteHook, IBeforeFinishCallback, IBulkRowHook, IImporterOptions, IParseFileCallback } from 'dromo-uploader-js';
|
|
3
3
|
declare type VerboseRequiredProps = {
|
|
4
4
|
user: IUser;
|
|
5
5
|
fields: IDeveloperField[];
|
|
@@ -21,19 +21,28 @@ declare type CommonProps = {
|
|
|
21
21
|
rowDeleteHooks?: IRowDeleteHook[];
|
|
22
22
|
columnHooks?: IColumnHook[];
|
|
23
23
|
stepHooks?: IStepHook[];
|
|
24
|
+
fileParsers?: {
|
|
25
|
+
extensions: string[];
|
|
26
|
+
parseFile: IParseFileCallback;
|
|
27
|
+
}[];
|
|
24
28
|
beforeFinish?: IBeforeFinishCallback;
|
|
25
29
|
onResults?: (data: any, metadata: IResultMetadata) => void;
|
|
26
30
|
onCancel?: () => void;
|
|
27
31
|
children?: React.ReactNode;
|
|
28
32
|
open?: boolean;
|
|
33
|
+
inline?: boolean;
|
|
29
34
|
};
|
|
30
35
|
declare type Props = (VerboseRequiredProps | SavedSchemaProps) & CommonProps;
|
|
31
36
|
export default class DromoReactUploader extends React.Component<Props> {
|
|
32
37
|
dromo: any;
|
|
38
|
+
inlineRef: React.RefObject<HTMLDivElement> | null;
|
|
39
|
+
constructor(props: Props);
|
|
40
|
+
init: () => void;
|
|
33
41
|
open: () => void;
|
|
42
|
+
initInline: () => void;
|
|
34
43
|
componentDidMount(): void;
|
|
35
44
|
componentDidUpdate(prevProps: Props): void;
|
|
36
45
|
componentWillUnmount(): void;
|
|
37
46
|
render(): JSX.Element;
|
|
38
47
|
}
|
|
39
|
-
export { IDeveloperField, IDeveloperSettings, IUser, IColumnHookInput, IColumnHookOutput, IColumnHook, IRowHookInput, IRowHookOutput, IRowHook, IValidatorField, IDeveloperStyleOverrides, IResultMetadata, IStepHook, IRowDeleteHook, IBeforeFinishCallback, IBulkRowHook, IImporterOptions };
|
|
48
|
+
export { IDeveloperField, IDeveloperSettings, IUser, IColumnHookInput, IColumnHookOutput, IColumnHook, IRowHookInput, IRowHookOutput, IRowHook, IValidatorField, IDeveloperStyleOverrides, IResultMetadata, IStepHook, IRowDeleteHook, IBeforeFinishCallback, IBulkRowHook, IImporterOptions, IParseFileCallback };
|
package/dist/index.js
CHANGED
|
@@ -12,12 +12,13 @@ function _inheritsLoose(subClass, superClass) {
|
|
|
12
12
|
var DromoReactUploader = /*#__PURE__*/function (_React$Component) {
|
|
13
13
|
_inheritsLoose(DromoReactUploader, _React$Component);
|
|
14
14
|
|
|
15
|
-
function DromoReactUploader() {
|
|
15
|
+
function DromoReactUploader(props) {
|
|
16
16
|
var _this;
|
|
17
17
|
|
|
18
|
-
_this = _React$Component.
|
|
18
|
+
_this = _React$Component.call(this, props) || this;
|
|
19
|
+
_this.inlineRef = null;
|
|
19
20
|
|
|
20
|
-
_this.
|
|
21
|
+
_this.init = function () {
|
|
21
22
|
if ('fields' in _this.props && 'settings' in _this.props) {
|
|
22
23
|
_this.dromo = new DromoUploader(_this.props.licenseKey, _this.props.fields, _this.props.settings, _this.props.user);
|
|
23
24
|
} else if ('schemaId' in _this.props || 'schemaName' in _this.props) {
|
|
@@ -79,19 +80,51 @@ var DromoReactUploader = /*#__PURE__*/function (_React$Component) {
|
|
|
79
80
|
});
|
|
80
81
|
}
|
|
81
82
|
|
|
83
|
+
if (_this.props.fileParsers) {
|
|
84
|
+
_this.props.fileParsers.forEach(function (parser) {
|
|
85
|
+
_this.dromo.registerFileParser(parser);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
_this.open = function () {
|
|
91
|
+
_this.init();
|
|
92
|
+
|
|
82
93
|
_this.dromo.open();
|
|
83
94
|
};
|
|
84
95
|
|
|
96
|
+
_this.initInline = function () {
|
|
97
|
+
if (!_this.inlineRef) return;
|
|
98
|
+
|
|
99
|
+
_this.init();
|
|
100
|
+
|
|
101
|
+
_this.dromo.initInline(_this.inlineRef.current);
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
if (props.inline) {
|
|
105
|
+
_this.inlineRef = React.createRef();
|
|
106
|
+
}
|
|
107
|
+
|
|
85
108
|
return _this;
|
|
86
109
|
}
|
|
87
110
|
|
|
88
111
|
var _proto = DromoReactUploader.prototype;
|
|
89
112
|
|
|
90
113
|
_proto.componentDidMount = function componentDidMount() {
|
|
114
|
+
if (this.props.inline && this.inlineRef) {
|
|
115
|
+
this.initInline();
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
|
|
91
119
|
if (this.props.open) this.open();
|
|
92
120
|
};
|
|
93
121
|
|
|
94
122
|
_proto.componentDidUpdate = function componentDidUpdate(prevProps) {
|
|
123
|
+
if (this.props.inline) {
|
|
124
|
+
this.initInline();
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
|
|
95
128
|
if (!prevProps.open && this.props.open) {
|
|
96
129
|
this.open();
|
|
97
130
|
}
|
|
@@ -102,12 +135,20 @@ var DromoReactUploader = /*#__PURE__*/function (_React$Component) {
|
|
|
102
135
|
};
|
|
103
136
|
|
|
104
137
|
_proto.componentWillUnmount = function componentWillUnmount() {
|
|
105
|
-
if (this.props.open) {
|
|
138
|
+
if (this.props.open && !this.props.inline) {
|
|
106
139
|
this.dromo.close();
|
|
107
140
|
}
|
|
108
141
|
};
|
|
109
142
|
|
|
110
143
|
_proto.render = function render() {
|
|
144
|
+
if (this.props.inline) {
|
|
145
|
+
return React.createElement("div", {
|
|
146
|
+
ref: this.inlineRef,
|
|
147
|
+
className: this.props.className,
|
|
148
|
+
style: this.props.style
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
|
|
111
152
|
if (this.props.children === undefined) return React.createElement(React.Fragment, null);
|
|
112
153
|
return React.createElement("button", {
|
|
113
154
|
style: this.props.style,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/index.tsx"],"sourcesContent":["import * as React from 'react'\nimport DromoUploader, {\n IColumnHookInput,\n IColumnHookOutput,\n IColumnHook,\n IDeveloperField,\n IValidatorField,\n IDeveloperSettings,\n IRowHookInput,\n IRowHookOutput,\n IRowHook,\n IDeveloperStyleOverrides,\n IUser,\n IResultMetadata,\n IStepHook,\n IRowDeleteHook,\n IBeforeFinishCallback,\n IBulkRowHook,\n IImporterOptions\n} from 'dromo-uploader-js'\n\ntype VerboseRequiredProps = {\n user: IUser\n fields: IDeveloperField[]\n licenseKey: string\n settings: IDeveloperSettings\n}\n\ntype SavedSchemaProps = {\n licenseKey: string\n} & ({ schemaName: string } | { schemaId: string }) &\n IImporterOptions\n\ntype CommonProps = {\n style?: React.CSSProperties\n className?: string\n rowHooks?: IRowHook[]\n bulkRowHooks?: IBulkRowHook[]\n rowDeleteHooks?: IRowDeleteHook[]\n columnHooks?: IColumnHook[]\n stepHooks?: IStepHook[]\n beforeFinish?: IBeforeFinishCallback\n onResults?: (data: any, metadata: IResultMetadata) => void\n onCancel?: () => void\n children?: React.ReactNode\n open?: boolean\n}\n\ntype Props = (VerboseRequiredProps | SavedSchemaProps) & CommonProps\n\nexport default class DromoReactUploader extends React.Component<Props> {\n dromo: any\n\n
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.tsx"],"sourcesContent":["import * as React from 'react'\nimport DromoUploader, {\n IColumnHookInput,\n IColumnHookOutput,\n IColumnHook,\n IDeveloperField,\n IValidatorField,\n IDeveloperSettings,\n IRowHookInput,\n IRowHookOutput,\n IRowHook,\n IDeveloperStyleOverrides,\n IUser,\n IResultMetadata,\n IStepHook,\n IRowDeleteHook,\n IBeforeFinishCallback,\n IBulkRowHook,\n IImporterOptions,\n IParseFileCallback\n} from 'dromo-uploader-js'\n\ntype VerboseRequiredProps = {\n user: IUser\n fields: IDeveloperField[]\n licenseKey: string\n settings: IDeveloperSettings\n}\n\ntype SavedSchemaProps = {\n licenseKey: string\n} & ({ schemaName: string } | { schemaId: string }) &\n IImporterOptions\n\ntype CommonProps = {\n style?: React.CSSProperties\n className?: string\n rowHooks?: IRowHook[]\n bulkRowHooks?: IBulkRowHook[]\n rowDeleteHooks?: IRowDeleteHook[]\n columnHooks?: IColumnHook[]\n stepHooks?: IStepHook[]\n fileParsers?: { extensions: string[]; parseFile: IParseFileCallback }[]\n beforeFinish?: IBeforeFinishCallback\n onResults?: (data: any, metadata: IResultMetadata) => void\n onCancel?: () => void\n children?: React.ReactNode\n open?: boolean\n inline?: boolean\n}\n\ntype Props = (VerboseRequiredProps | SavedSchemaProps) & CommonProps\n\nexport default class DromoReactUploader extends React.Component<Props> {\n dromo: any\n inlineRef: React.RefObject<HTMLDivElement> | null = null\n\n constructor(props: Props) {\n super(props)\n\n if (props.inline) {\n this.inlineRef = React.createRef()\n }\n }\n\n init = () => {\n if ('fields' in this.props && 'settings' in this.props) {\n this.dromo = new DromoUploader(\n this.props.licenseKey,\n this.props.fields,\n this.props.settings,\n this.props.user\n )\n } else if ('schemaId' in this.props || 'schemaName' in this.props) {\n const idOrName =\n 'schemaId' in this.props ? this.props.schemaId : this.props.schemaName\n\n this.dromo = new DromoUploader(this.props.licenseKey, idOrName)\n\n if ('developmentMode' in this.props) {\n this.dromo.setDevelopmentMode(this.props.developmentMode)\n }\n if ('user' in this.props) {\n this.dromo.setUser(this.props.user)\n }\n if ('headerRowOverride' in this.props) {\n this.dromo.setHeaderRowOverride(this.props.headerRowOverride)\n }\n }\n\n if (this.props.rowHooks) {\n this.props.rowHooks.forEach((hook) => this.dromo.registerRowHook(hook))\n }\n\n if (this.props.bulkRowHooks) {\n this.props.bulkRowHooks.forEach((hook) =>\n this.dromo.registerBulkRowHook(hook)\n )\n }\n\n if (this.props.columnHooks) {\n this.props.columnHooks.forEach((hook) => {\n this.dromo.registerColumnHook(hook.fieldName, hook.callback)\n })\n }\n\n if (this.props.rowDeleteHooks) {\n this.props.rowDeleteHooks.forEach((hook) => {\n return this.dromo.registerRowDeleteHook(hook)\n })\n }\n\n if (this.props.beforeFinish) {\n this.dromo.beforeFinish(this.props.beforeFinish)\n }\n\n if (this.props.onResults) {\n this.dromo.onResults(this.props.onResults)\n }\n\n if (this.props.onCancel) {\n this.dromo.onCancel(this.props.onCancel)\n }\n\n if (this.props.stepHooks) {\n this.props.stepHooks.forEach((hook) => {\n this.dromo.registerStepHook(hook.type, hook.callback)\n })\n }\n\n if (this.props.fileParsers) {\n this.props.fileParsers.forEach((parser) => {\n this.dromo.registerFileParser(parser)\n })\n }\n }\n\n open = () => {\n this.init()\n this.dromo.open()\n }\n\n initInline = () => {\n if (!this.inlineRef) return\n\n this.init()\n this.dromo.initInline(this.inlineRef.current)\n }\n\n componentDidMount() {\n if (this.props.inline && this.inlineRef) {\n this.initInline()\n return\n }\n\n if (this.props.open) this.open()\n }\n\n componentDidUpdate(prevProps: Props) {\n if (this.props.inline) {\n this.initInline()\n return\n }\n\n if (!prevProps.open && this.props.open) {\n this.open()\n }\n\n if (prevProps.open && !this.props.open) {\n this.dromo.close()\n }\n }\n\n componentWillUnmount() {\n if (this.props.open && !this.props.inline) {\n this.dromo.close()\n }\n }\n\n render() {\n if (this.props.inline) {\n return (\n <div\n ref={this.inlineRef}\n className={this.props.className}\n style={this.props.style}\n />\n )\n }\n\n if (this.props.children === undefined) return <React.Fragment />\n\n return (\n <button\n style={this.props.style}\n className={this.props.className}\n onClick={this.open}\n >\n {this.props.children}\n </button>\n )\n }\n}\n\nexport {\n IDeveloperField,\n IDeveloperSettings,\n IUser,\n IColumnHookInput,\n IColumnHookOutput,\n IColumnHook,\n IRowHookInput,\n IRowHookOutput,\n IRowHook,\n IValidatorField,\n IDeveloperStyleOverrides,\n IResultMetadata,\n IStepHook,\n IRowDeleteHook,\n IBeforeFinishCallback,\n IBulkRowHook,\n IImporterOptions,\n IParseFileCallback\n}\n"],"names":["DromoReactUploader","props","dromo","DromoUploader","licenseKey","fields","settings","user","idOrName","schemaId","schemaName","setDevelopmentMode","developmentMode","setUser","setHeaderRowOverride","headerRowOverride","rowHooks","forEach","hook","registerRowHook","bulkRowHooks","registerBulkRowHook","columnHooks","registerColumnHook","fieldName","callback","rowDeleteHooks","registerRowDeleteHook","beforeFinish","onResults","onCancel","stepHooks","registerStepHook","type","fileParsers","parser","registerFileParser","init","open","inlineRef","initInline","current","inline","React","componentDidMount","componentDidUpdate","prevProps","close","componentWillUnmount","render","ref","className","style","children","undefined","onClick"],"mappings":";;;;;;;;;;;IAqDqBA;;;AAInB,8BAAYC,KAAZ;;;AACE,wCAAMA,KAAN;AAHF,mBAAA,GAAoD,IAApD;;AAUA,cAAA,GAAO;AACL,UAAI,YAAY,MAAKA,KAAjB,IAA0B,cAAc,MAAKA,KAAjD,EAAwD;AACtD,cAAKC,KAAL,GAAa,IAAIC,aAAJ,CACX,MAAKF,KAAL,CAAWG,UADA,EAEX,MAAKH,KAAL,CAAWI,MAFA,EAGX,MAAKJ,KAAL,CAAWK,QAHA,EAIX,MAAKL,KAAL,CAAWM,IAJA,CAAb;AAMD,OAPD,MAOO,IAAI,cAAc,MAAKN,KAAnB,IAA4B,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AL,CAAWkD;AACtBI,MAAAA,OAAO,EAAE,KAAKjB;KAHhB,EAKG,KAAKrC,KAAL,CAAWoD,QALd,CADF;AASD;;;EApJ6CV;;;;"}
|
package/dist/index.modern.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createElement, Fragment, Component } from 'react';
|
|
1
|
+
import { createElement, Fragment, createRef, Component } from 'react';
|
|
2
2
|
import DromoUploader from 'dromo-uploader-js';
|
|
3
3
|
|
|
4
4
|
function _inheritsLoose(subClass, superClass) {
|
|
@@ -10,12 +10,13 @@ function _inheritsLoose(subClass, superClass) {
|
|
|
10
10
|
var DromoReactUploader = /*#__PURE__*/function (_React$Component) {
|
|
11
11
|
_inheritsLoose(DromoReactUploader, _React$Component);
|
|
12
12
|
|
|
13
|
-
function DromoReactUploader() {
|
|
13
|
+
function DromoReactUploader(props) {
|
|
14
14
|
var _this;
|
|
15
15
|
|
|
16
|
-
_this = _React$Component.
|
|
16
|
+
_this = _React$Component.call(this, props) || this;
|
|
17
|
+
_this.inlineRef = null;
|
|
17
18
|
|
|
18
|
-
_this.
|
|
19
|
+
_this.init = function () {
|
|
19
20
|
if ('fields' in _this.props && 'settings' in _this.props) {
|
|
20
21
|
_this.dromo = new DromoUploader(_this.props.licenseKey, _this.props.fields, _this.props.settings, _this.props.user);
|
|
21
22
|
} else if ('schemaId' in _this.props || 'schemaName' in _this.props) {
|
|
@@ -77,19 +78,51 @@ var DromoReactUploader = /*#__PURE__*/function (_React$Component) {
|
|
|
77
78
|
});
|
|
78
79
|
}
|
|
79
80
|
|
|
81
|
+
if (_this.props.fileParsers) {
|
|
82
|
+
_this.props.fileParsers.forEach(function (parser) {
|
|
83
|
+
_this.dromo.registerFileParser(parser);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
_this.open = function () {
|
|
89
|
+
_this.init();
|
|
90
|
+
|
|
80
91
|
_this.dromo.open();
|
|
81
92
|
};
|
|
82
93
|
|
|
94
|
+
_this.initInline = function () {
|
|
95
|
+
if (!_this.inlineRef) return;
|
|
96
|
+
|
|
97
|
+
_this.init();
|
|
98
|
+
|
|
99
|
+
_this.dromo.initInline(_this.inlineRef.current);
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
if (props.inline) {
|
|
103
|
+
_this.inlineRef = createRef();
|
|
104
|
+
}
|
|
105
|
+
|
|
83
106
|
return _this;
|
|
84
107
|
}
|
|
85
108
|
|
|
86
109
|
var _proto = DromoReactUploader.prototype;
|
|
87
110
|
|
|
88
111
|
_proto.componentDidMount = function componentDidMount() {
|
|
112
|
+
if (this.props.inline && this.inlineRef) {
|
|
113
|
+
this.initInline();
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
|
|
89
117
|
if (this.props.open) this.open();
|
|
90
118
|
};
|
|
91
119
|
|
|
92
120
|
_proto.componentDidUpdate = function componentDidUpdate(prevProps) {
|
|
121
|
+
if (this.props.inline) {
|
|
122
|
+
this.initInline();
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
|
|
93
126
|
if (!prevProps.open && this.props.open) {
|
|
94
127
|
this.open();
|
|
95
128
|
}
|
|
@@ -100,12 +133,20 @@ var DromoReactUploader = /*#__PURE__*/function (_React$Component) {
|
|
|
100
133
|
};
|
|
101
134
|
|
|
102
135
|
_proto.componentWillUnmount = function componentWillUnmount() {
|
|
103
|
-
if (this.props.open) {
|
|
136
|
+
if (this.props.open && !this.props.inline) {
|
|
104
137
|
this.dromo.close();
|
|
105
138
|
}
|
|
106
139
|
};
|
|
107
140
|
|
|
108
141
|
_proto.render = function render() {
|
|
142
|
+
if (this.props.inline) {
|
|
143
|
+
return createElement("div", {
|
|
144
|
+
ref: this.inlineRef,
|
|
145
|
+
className: this.props.className,
|
|
146
|
+
style: this.props.style
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
|
|
109
150
|
if (this.props.children === undefined) return createElement(Fragment, null);
|
|
110
151
|
return createElement("button", {
|
|
111
152
|
style: this.props.style,
|
package/dist/index.modern.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.modern.js","sources":["../src/index.tsx"],"sourcesContent":["import * as React from 'react'\nimport DromoUploader, {\n IColumnHookInput,\n IColumnHookOutput,\n IColumnHook,\n IDeveloperField,\n IValidatorField,\n IDeveloperSettings,\n IRowHookInput,\n IRowHookOutput,\n IRowHook,\n IDeveloperStyleOverrides,\n IUser,\n IResultMetadata,\n IStepHook,\n IRowDeleteHook,\n IBeforeFinishCallback,\n IBulkRowHook,\n IImporterOptions\n} from 'dromo-uploader-js'\n\ntype VerboseRequiredProps = {\n user: IUser\n fields: IDeveloperField[]\n licenseKey: string\n settings: IDeveloperSettings\n}\n\ntype SavedSchemaProps = {\n licenseKey: string\n} & ({ schemaName: string } | { schemaId: string }) &\n IImporterOptions\n\ntype CommonProps = {\n style?: React.CSSProperties\n className?: string\n rowHooks?: IRowHook[]\n bulkRowHooks?: IBulkRowHook[]\n rowDeleteHooks?: IRowDeleteHook[]\n columnHooks?: IColumnHook[]\n stepHooks?: IStepHook[]\n beforeFinish?: IBeforeFinishCallback\n onResults?: (data: any, metadata: IResultMetadata) => void\n onCancel?: () => void\n children?: React.ReactNode\n open?: boolean\n}\n\ntype Props = (VerboseRequiredProps | SavedSchemaProps) & CommonProps\n\nexport default class DromoReactUploader extends React.Component<Props> {\n dromo: any\n\n
|
|
1
|
+
{"version":3,"file":"index.modern.js","sources":["../src/index.tsx"],"sourcesContent":["import * as React from 'react'\nimport DromoUploader, {\n IColumnHookInput,\n IColumnHookOutput,\n IColumnHook,\n IDeveloperField,\n IValidatorField,\n IDeveloperSettings,\n IRowHookInput,\n IRowHookOutput,\n IRowHook,\n IDeveloperStyleOverrides,\n IUser,\n IResultMetadata,\n IStepHook,\n IRowDeleteHook,\n IBeforeFinishCallback,\n IBulkRowHook,\n IImporterOptions,\n IParseFileCallback\n} from 'dromo-uploader-js'\n\ntype VerboseRequiredProps = {\n user: IUser\n fields: IDeveloperField[]\n licenseKey: string\n settings: IDeveloperSettings\n}\n\ntype SavedSchemaProps = {\n licenseKey: string\n} & ({ schemaName: string } | { schemaId: string }) &\n IImporterOptions\n\ntype CommonProps = {\n style?: React.CSSProperties\n className?: string\n rowHooks?: IRowHook[]\n bulkRowHooks?: IBulkRowHook[]\n rowDeleteHooks?: IRowDeleteHook[]\n columnHooks?: IColumnHook[]\n stepHooks?: IStepHook[]\n fileParsers?: { extensions: string[]; parseFile: IParseFileCallback }[]\n beforeFinish?: IBeforeFinishCallback\n onResults?: (data: any, metadata: IResultMetadata) => void\n onCancel?: () => void\n children?: React.ReactNode\n open?: boolean\n inline?: boolean\n}\n\ntype Props = (VerboseRequiredProps | SavedSchemaProps) & CommonProps\n\nexport default class DromoReactUploader extends React.Component<Props> {\n dromo: any\n inlineRef: React.RefObject<HTMLDivElement> | null = null\n\n constructor(props: Props) {\n super(props)\n\n if (props.inline) {\n this.inlineRef = React.createRef()\n }\n }\n\n init = () => {\n if ('fields' in this.props && 'settings' in this.props) {\n this.dromo = new DromoUploader(\n this.props.licenseKey,\n this.props.fields,\n this.props.settings,\n this.props.user\n )\n } else if ('schemaId' in this.props || 'schemaName' in this.props) {\n const idOrName =\n 'schemaId' in this.props ? this.props.schemaId : this.props.schemaName\n\n this.dromo = new DromoUploader(this.props.licenseKey, idOrName)\n\n if ('developmentMode' in this.props) {\n this.dromo.setDevelopmentMode(this.props.developmentMode)\n }\n if ('user' in this.props) {\n this.dromo.setUser(this.props.user)\n }\n if ('headerRowOverride' in this.props) {\n this.dromo.setHeaderRowOverride(this.props.headerRowOverride)\n }\n }\n\n if (this.props.rowHooks) {\n this.props.rowHooks.forEach((hook) => this.dromo.registerRowHook(hook))\n }\n\n if (this.props.bulkRowHooks) {\n this.props.bulkRowHooks.forEach((hook) =>\n this.dromo.registerBulkRowHook(hook)\n )\n }\n\n if (this.props.columnHooks) {\n this.props.columnHooks.forEach((hook) => {\n this.dromo.registerColumnHook(hook.fieldName, hook.callback)\n })\n }\n\n if (this.props.rowDeleteHooks) {\n this.props.rowDeleteHooks.forEach((hook) => {\n return this.dromo.registerRowDeleteHook(hook)\n })\n }\n\n if (this.props.beforeFinish) {\n this.dromo.beforeFinish(this.props.beforeFinish)\n }\n\n if (this.props.onResults) {\n this.dromo.onResults(this.props.onResults)\n }\n\n if (this.props.onCancel) {\n this.dromo.onCancel(this.props.onCancel)\n }\n\n if (this.props.stepHooks) {\n this.props.stepHooks.forEach((hook) => {\n this.dromo.registerStepHook(hook.type, hook.callback)\n })\n }\n\n if (this.props.fileParsers) {\n this.props.fileParsers.forEach((parser) => {\n this.dromo.registerFileParser(parser)\n })\n }\n }\n\n open = () => {\n this.init()\n this.dromo.open()\n }\n\n initInline = () => {\n if (!this.inlineRef) return\n\n this.init()\n this.dromo.initInline(this.inlineRef.current)\n }\n\n componentDidMount() {\n if (this.props.inline && this.inlineRef) {\n this.initInline()\n return\n }\n\n if (this.props.open) this.open()\n }\n\n componentDidUpdate(prevProps: Props) {\n if (this.props.inline) {\n this.initInline()\n return\n }\n\n if (!prevProps.open && this.props.open) {\n this.open()\n }\n\n if (prevProps.open && !this.props.open) {\n this.dromo.close()\n }\n }\n\n componentWillUnmount() {\n if (this.props.open && !this.props.inline) {\n this.dromo.close()\n }\n }\n\n render() {\n if (this.props.inline) {\n return (\n <div\n ref={this.inlineRef}\n className={this.props.className}\n style={this.props.style}\n />\n )\n }\n\n if (this.props.children === undefined) return <React.Fragment />\n\n return (\n <button\n style={this.props.style}\n className={this.props.className}\n onClick={this.open}\n >\n {this.props.children}\n </button>\n )\n }\n}\n\nexport {\n IDeveloperField,\n IDeveloperSettings,\n IUser,\n IColumnHookInput,\n IColumnHookOutput,\n IColumnHook,\n IRowHookInput,\n IRowHookOutput,\n IRowHook,\n IValidatorField,\n IDeveloperStyleOverrides,\n IResultMetadata,\n IStepHook,\n IRowDeleteHook,\n IBeforeFinishCallback,\n IBulkRowHook,\n IImporterOptions,\n IParseFileCallback\n}\n"],"names":["DromoReactUploader","props","dromo","DromoUploader","licenseKey","fields","settings","user","idOrName","schemaId","schemaName","setDevelopmentMode","developmentMode","setUser","setHeaderRowOverride","headerRowOverride","rowHooks","forEach","hook","registerRowHook","bulkRowHooks","registerBulkRowHook","columnHooks","registerColumnHook","fieldName","callback","rowDeleteHooks","registerRowDeleteHook","beforeFinish","onResults","onCancel","stepHooks","registerStepHook","type","fileParsers","parser","registerFileParser","init","open","inlineRef","initInline","current","inline","React","componentDidMount","componentDidUpdate","prevProps","close","componentWillUnmount","render","ref","className","style","children","undefined","onClick"],"mappings":";;;;;;;;;IAqDqBA;;;AAInB,8BAAYC,KAAZ;;;AACE,wCAAMA,KAAN;AAHF,mBAAA,GAAoD,IAApD;;AAUA,cAAA,GAAO;AACL,UAAI,YAAY,MAAKA,KAAjB,IAA0B,cAAc,MAAKA,KAAjD,EAAwD;AACtD,cAAKC,KAAL,GAAa,IAAIC,aAAJ,CACX,MAAKF,KAAL,CAAWG,UADA,EAEX,MAAKH,KAAL,CAAWI,MAFA,EAGX,MAAKJ,KAAL,CAAWK,QAHA,EAIX,MAAKL,KAAL,CAAWM,IAJA,CAAb;AAMD,OAPD,MAOO,IAAI,cAAc,MAAKN,KAAnB,IAA4B,gBAAgB,MAAKA,KAArD,EAA4D;AACjE,YAAMO,QAAQ,GACZ,cAAc,MAAKP,KAAnB,GAA2B,MAAKA,KAAL,CAAWQ,QAAtC,GAAiD,MAAKR,KAAL,CAAWS,UAD9D;AAGA,cAAKR,KAAL,GAAa,IAAIC,aAAJ,CAAkB,MAAKF,KAAL,CAAWG,UAA7B,EAAyCI,QAAzC,CAAb;;AAEA,YAAI,qBAAqB,MAAKP,KAA9B,EAAqC;AACnC,gBAAKC,KAAL,CAAWS,kBAAX,CAA8B,MAAKV,KAAL,CAAWW,eAAzC;AACD;;AACD,YAAI,UAAU,MAAKX,KAAnB,EAA0B;AACxB,gBAAKC,KAAL,CAAWW,OAAX,CAAmB,MAAKZ,KAAL,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AL,CAAWqC,IAAlC,EAAwC;AACtC,WAAKA,IAAL;AACD;;AAED,QAAIQ,SAAS,CAACR,IAAV,IAAkB,CAAC,KAAKrC,KAAL,CAAWqC,IAAlC,EAAwC;AACtC,WAAKpC,KAAL,CAAW6C,KAAX;AACD;AACF;;SAEDC,uBAAA;AACE,QAAI,KAAK/C,KAAL,CAAWqC,IAAX,IAAmB,CAAC,KAAKrC,KAAL,CAAWyC,MAAnC,EAA2C;AACzC,WAAKxC,KAAL,CAAW6C,KAAX;AACD;AACF;;SAEDE,SAAA;AACE,QAAI,KAAKhD,KAAL,CAAWyC,MAAf,EAAuB;AACrB,aACEC,aAAA,MAAA;AACEO,QAAAA,GAAG,EAAE,KAAKX;AACVY,QAAAA,SAAS,EAAE,KAAKlD,KAAL,CAAWkD;AACtBC,QAAAA,KAAK,EAAE,KAAKnD,KAAL,CAAWmD;OAHpB,CADF;AAOD;;AAED,QAAI,KAAKnD,KAAL,CAAWoD,QAAX,KAAwBC,SAA5B,EAAuC,OAAOX,aAAA,CAACA,QAAD,MAAA,CAAP;AAEvC,WACEA,aAAA,SAAA;AACES,MAAAA,KAAK,EAAE,KAAKnD,KAAL,CAAWmD;AAClBD,MAAAA,SAAS,EAAE,KAAKlD,KAAL,CAAWkD;AACtBI,MAAAA,OAAO,EAAE,KAAKjB;KAHhB,EAKG,KAAKrC,KAAL,CAAWoD,QALd,CADF;AASD;;;EApJ6CV;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dromo-uploader-react",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.8",
|
|
4
4
|
"description": "Easy to use data (CSV, TSV, Excel) importer",
|
|
5
5
|
"author": "ankitgoyal100",
|
|
6
6
|
"license": "MIT",
|
|
@@ -61,6 +61,6 @@
|
|
|
61
61
|
"dist"
|
|
62
62
|
],
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"dromo-uploader-js": "^2.1.
|
|
64
|
+
"dromo-uploader-js": "^2.1.8"
|
|
65
65
|
}
|
|
66
66
|
}
|