@sumit_yewale/react 1.1.14
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/@types/csvbox__react.d.ts +37 -0
- package/README.md +48 -0
- package/dist/index.js +210 -0
- package/dist/index.js.map +1 -0
- package/dist/index.modern.js +207 -0
- package/dist/index.modern.js.map +1 -0
- package/package.json +88 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React, { PropsWithChildren } from 'react';
|
|
2
|
+
declare module '@csvbox/react' {
|
|
3
|
+
interface CSVBoxImporterProps {
|
|
4
|
+
lazy?: boolean;
|
|
5
|
+
loadStarted?:() => void;
|
|
6
|
+
user: any;
|
|
7
|
+
dynamicColumns?: any;
|
|
8
|
+
options?: any;
|
|
9
|
+
onReady?:() => void;
|
|
10
|
+
onImport:(type:boolean, metadata?:any) => void;
|
|
11
|
+
onSubmit?:(metadata:any) => void;
|
|
12
|
+
onClose?:() => void;
|
|
13
|
+
licenseKey: string;
|
|
14
|
+
dataLocation?: string;
|
|
15
|
+
customDomain?: string;
|
|
16
|
+
language?: string;
|
|
17
|
+
environment?: any;
|
|
18
|
+
theme?: string;
|
|
19
|
+
render?:(launch:any, isLoading:boolean) => void
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export class CSVBoxButton extends React.Component<PropsWithChildren<CSVBoxImporterProps>>{
|
|
23
|
+
constructor(props: CSVBoxImporterProps);
|
|
24
|
+
|
|
25
|
+
holder: React.RefObject<HTMLDivElement>;
|
|
26
|
+
uuid: string;
|
|
27
|
+
iframe: HTMLIFrameElement | null;
|
|
28
|
+
|
|
29
|
+
openModal(): void;
|
|
30
|
+
|
|
31
|
+
componentDidMount(): void;
|
|
32
|
+
|
|
33
|
+
initImporter(): void;
|
|
34
|
+
|
|
35
|
+
enableInitator(): void;
|
|
36
|
+
}
|
|
37
|
+
}
|
package/README.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# @csvbox/react
|
|
2
|
+
|
|
3
|
+
> React adapter for csvbox.io
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@csvbox/react) [](https://standardjs.com)
|
|
6
|
+
|
|
7
|
+
## Shell
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @csvbox/react
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Import
|
|
14
|
+
```js
|
|
15
|
+
import { CSVBoxButton } from '@csvbox/react'
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
```jsx
|
|
21
|
+
<CSVBoxButton
|
|
22
|
+
licenseKey="Sheet license key"
|
|
23
|
+
user={{
|
|
24
|
+
user_id: "default123"
|
|
25
|
+
}}
|
|
26
|
+
onImport={(result, data) => {
|
|
27
|
+
if(result){
|
|
28
|
+
console.log("success");
|
|
29
|
+
console.log(data.row_success + " rows uploaded");
|
|
30
|
+
//custom code
|
|
31
|
+
}else{
|
|
32
|
+
console.log("fail");
|
|
33
|
+
//custom code
|
|
34
|
+
}
|
|
35
|
+
}}
|
|
36
|
+
>
|
|
37
|
+
Import
|
|
38
|
+
</CSVBoxButton>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Readme
|
|
42
|
+
|
|
43
|
+
For usage see the guide here - https://help.csvbox.io/getting-started#2-install-code
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
## License
|
|
47
|
+
|
|
48
|
+
MIT © [csvbox-io](https://github.com/csvbox-io)
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var React__default = _interopDefault(React);
|
|
5
|
+
var adapterCore = require('@sumit_yewale/adapter-core');
|
|
6
|
+
|
|
7
|
+
function _inheritsLoose(subClass, superClass) {
|
|
8
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
9
|
+
subClass.prototype.constructor = subClass;
|
|
10
|
+
|
|
11
|
+
_setPrototypeOf(subClass, superClass);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function _setPrototypeOf(o, p) {
|
|
15
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
16
|
+
o.__proto__ = p;
|
|
17
|
+
return o;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
return _setPrototypeOf(o, p);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function _assertThisInitialized(self) {
|
|
24
|
+
if (self === void 0) {
|
|
25
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return self;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
var version = "1.1.14";
|
|
32
|
+
|
|
33
|
+
var CSVBoxButton = /*#__PURE__*/function (_Component) {
|
|
34
|
+
_inheritsLoose(CSVBoxButton, _Component);
|
|
35
|
+
|
|
36
|
+
function CSVBoxButton(props) {
|
|
37
|
+
var _this;
|
|
38
|
+
|
|
39
|
+
_this = _Component.call(this, props) || this;
|
|
40
|
+
_this.holder = React__default.createRef();
|
|
41
|
+
_this.openModal = _this.openModal.bind(_assertThisInitialized(_this));
|
|
42
|
+
_this.lifecycle = adapterCore.createModalLifecycle();
|
|
43
|
+
_this.uuid = adapterCore.generateUuid();
|
|
44
|
+
_this.state = {
|
|
45
|
+
isLoading: true
|
|
46
|
+
};
|
|
47
|
+
_this.iframe = null;
|
|
48
|
+
return _this;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
var _proto = CSVBoxButton.prototype;
|
|
52
|
+
|
|
53
|
+
_proto.componentDidMount = function componentDidMount() {
|
|
54
|
+
var lazy = this.props.lazy;
|
|
55
|
+
|
|
56
|
+
if (!lazy && !this.iframe) {
|
|
57
|
+
this.initImporter();
|
|
58
|
+
} else if (lazy) {
|
|
59
|
+
this.enableInitator();
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
_proto.initImporter = function initImporter() {
|
|
64
|
+
var _this2 = this;
|
|
65
|
+
|
|
66
|
+
var loadStarted = this.props.loadStarted;
|
|
67
|
+
loadStarted === null || loadStarted === void 0 ? void 0 : loadStarted();
|
|
68
|
+
var user = this.props.user;
|
|
69
|
+
var dynamicColumns = this.props.dynamicColumns;
|
|
70
|
+
var options = this.props.options;
|
|
71
|
+
var onReady = this.props.onReady;
|
|
72
|
+
var onImport = this.props.onImport;
|
|
73
|
+
var onSubmit = this.props.onSubmit;
|
|
74
|
+
var onClose = this.props.onClose;
|
|
75
|
+
var licenseKey = this.props.licenseKey;
|
|
76
|
+
var dataLocation = this.props.dataLocation;
|
|
77
|
+
var customDomain = this.props.customDomain;
|
|
78
|
+
var language = this.props.language;
|
|
79
|
+
var environment = this.props.environment;
|
|
80
|
+
var theme = this.props.theme;
|
|
81
|
+
var iframeUrl = adapterCore.buildImportUrl({
|
|
82
|
+
licenseKey: licenseKey,
|
|
83
|
+
customDomain: customDomain,
|
|
84
|
+
dataLocation: dataLocation,
|
|
85
|
+
language: language,
|
|
86
|
+
theme: theme,
|
|
87
|
+
environment: environment
|
|
88
|
+
}, "react", version);
|
|
89
|
+
|
|
90
|
+
var handleModalClosed = function handleModalClosed() {
|
|
91
|
+
if (_this2.holder && _this2.holder.current) {
|
|
92
|
+
_this2.holder.current.style.display = 'none';
|
|
93
|
+
_this2.holder.current.innerHTML = '';
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
_this2.lifecycle.markClosed();
|
|
97
|
+
|
|
98
|
+
_this2.iframe = null;
|
|
99
|
+
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
if (this.messageListener) {
|
|
103
|
+
window.removeEventListener("message", this.messageListener, false);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
this.messageListener = function (event) {
|
|
107
|
+
var legacy = adapterCore.classifyLegacyMessage(event.data);
|
|
108
|
+
|
|
109
|
+
if (legacy) {
|
|
110
|
+
if (legacy.type === "mainModalHidden") {
|
|
111
|
+
handleModalClosed();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (legacy.type === "uploadSuccessful") {
|
|
115
|
+
onImport(true);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (legacy.type === "uploadFailed") {
|
|
119
|
+
onImport(false);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
var message = adapterCore.classifyStructuredMessage(event.data, _this2.uuid);
|
|
126
|
+
|
|
127
|
+
if (!message) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (message.type === "data-on-submit") {
|
|
132
|
+
onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(message.metadata);
|
|
133
|
+
} else if (message.type === "data-push-status") {
|
|
134
|
+
onImport(message.success, message.metadata);
|
|
135
|
+
} else if (message.type === "csvbox-modal-hidden") {
|
|
136
|
+
handleModalClosed();
|
|
137
|
+
} else if (message.type === "csvbox-upload-successful") {
|
|
138
|
+
onImport(true);
|
|
139
|
+
} else if (message.type === "csvbox-upload-failed") {
|
|
140
|
+
onImport(false);
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
window.addEventListener("message", this.messageListener, false);
|
|
145
|
+
this.uuid = adapterCore.generateUuid();
|
|
146
|
+
var self = this;
|
|
147
|
+
var iframe = document.createElement("iframe");
|
|
148
|
+
this.iframe = iframe;
|
|
149
|
+
iframe.setAttribute("src", iframeUrl);
|
|
150
|
+
iframe.frameBorder = 0;
|
|
151
|
+
iframe.classList.add('csvbox-iframe');
|
|
152
|
+
Object.assign(iframe.style, adapterCore.IFRAME_STYLE);
|
|
153
|
+
|
|
154
|
+
iframe.onload = function () {
|
|
155
|
+
self.enableInitator();
|
|
156
|
+
iframe.contentWindow.postMessage(adapterCore.buildInitPayload(user, dynamicColumns, options, self.uuid), "*");
|
|
157
|
+
onReady === null || onReady === void 0 ? void 0 : onReady();
|
|
158
|
+
|
|
159
|
+
if (self.lifecycle.markReady()) {
|
|
160
|
+
self.openModal();
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
this.holder.current.appendChild(iframe);
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
_proto.openModal = function openModal() {
|
|
168
|
+
if (!this.iframe) {
|
|
169
|
+
this.lifecycle.requestOpen();
|
|
170
|
+
this.initImporter();
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if (this.lifecycle.requestOpen()) {
|
|
175
|
+
this.iframe.contentWindow.postMessage('openModal', '*');
|
|
176
|
+
this.holder.current.style.display = 'block';
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
_proto.enableInitator = function enableInitator() {
|
|
181
|
+
this.setState({
|
|
182
|
+
isLoading: false
|
|
183
|
+
});
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
_proto.render = function render() {
|
|
187
|
+
if (this.props.render) {
|
|
188
|
+
return /*#__PURE__*/React__default.createElement("div", null, this.props.render(this.openModal, this.state.isLoading), /*#__PURE__*/React__default.createElement("div", {
|
|
189
|
+
ref: this.holder,
|
|
190
|
+
style: adapterCore.HOLDER_STYLE
|
|
191
|
+
}));
|
|
192
|
+
} else {
|
|
193
|
+
return /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement("button", {
|
|
194
|
+
disabled: this.state.isLoading,
|
|
195
|
+
onClick: this.openModal,
|
|
196
|
+
"data-csvbox-initator": true,
|
|
197
|
+
"data-csvbox-token": this.uuid
|
|
198
|
+
}, this.props.children), /*#__PURE__*/React__default.createElement("div", {
|
|
199
|
+
ref: this.holder,
|
|
200
|
+
style: adapterCore.HOLDER_STYLE
|
|
201
|
+
}));
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
return CSVBoxButton;
|
|
206
|
+
}(React.Component);
|
|
207
|
+
|
|
208
|
+
exports.CSVBoxButton = CSVBoxButton;
|
|
209
|
+
exports.default = CSVBoxButton;
|
|
210
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.js"],"sourcesContent":["import React, { Component } from 'react';\nimport { version } from '../package.json';\nimport {\n\tHOLDER_STYLE,\n\tIFRAME_STYLE,\n\tbuildImportUrl,\n\tgenerateUuid,\n\tbuildInitPayload,\n\tcreateModalLifecycle,\n\tclassifyStructuredMessage,\n\tclassifyLegacyMessage\n} from '@sumit_yewale/adapter-core';\n\nexport class CSVBoxButton extends Component {\n\n\tconstructor(props) {\n\t\tsuper(props)\n\t\tthis.holder = React.createRef();\n\t\tthis.openModal = this.openModal.bind(this)\n\t\tthis.lifecycle = createModalLifecycle();\n\t\tthis.uuid = generateUuid();\n\t\tthis.state = {\n\t\t\tisLoading: true\n\t\t};\n\t\tthis.iframe = null;\n\t}\n\n\tcomponentDidMount() {\n\t\tconst { lazy } = this.props;\n\t\tif (!lazy && !this.iframe) {\n\t\t\tthis.initImporter();\n\t\t} else if (lazy) {\n\t\t\tthis.enableInitator();\n\t\t}\n\t}\n\n\tinitImporter() {\n\n\t\tconst { loadStarted } = this.props;\n\n\t\tloadStarted?.();\n\n\t\tconst { user } = this.props;\n\t\tconst { dynamicColumns } = this.props;\n\t\tconst { options } = this.props;\n\t\tconst { onReady } = this.props;\n\t\tconst { onImport } = this.props;\n\t\tconst { onSubmit } = this.props;\n\t\tconst { onClose } = this.props;\n\t\tconst { licenseKey } = this.props;\n\t\tconst { dataLocation } = this.props;\n\t\tconst { customDomain } = this.props;\n\t\tconst { language } = this.props;\n\t\tconst { environment } = this.props;\n\t\tconst { theme } = this.props;\n\n\t\tlet iframeUrl = buildImportUrl(\n\t\t\t{ licenseKey, customDomain, dataLocation, language, theme, environment },\n\t\t\t\"react\",\n\t\t\tversion\n\t\t);\n\n\t\tlet handleModalClosed = () => {\n\t\t\tif (this.holder && this.holder.current) {\n\t\t\t\tthis.holder.current.style.display = 'none';\n\t\t\t\tthis.holder.current.innerHTML = '';\n\t\t\t}\n\t\t\tthis.lifecycle.markClosed();\n\t\t\tthis.iframe = null;\n\t\t\tonClose?.();\n\t\t};\n\n\t\tif (this.messageListener) {\n\t\t\twindow.removeEventListener(\"message\", this.messageListener, false);\n\t\t}\n\n\t\tthis.messageListener = (event) => {\n\n\t\t\tlet legacy = classifyLegacyMessage(event.data);\n\t\t\tif (legacy) {\n\t\t\t\tif (legacy.type === \"mainModalHidden\") {\n\t\t\t\t\thandleModalClosed();\n\t\t\t\t}\n\t\t\t\tif (legacy.type === \"uploadSuccessful\") {\n\t\t\t\t\tonImport(true);\n\t\t\t\t}\n\t\t\t\tif (legacy.type === \"uploadFailed\") {\n\t\t\t\t\tonImport(false);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tlet message = classifyStructuredMessage(event.data, this.uuid);\n\t\t\tif (!message) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (message.type === \"data-on-submit\") {\n\t\t\t\tonSubmit?.(message.metadata);\n\t\t\t} else if (message.type === \"data-push-status\") {\n\t\t\t\tonImport(message.success, message.metadata);\n\t\t\t} else if (message.type === \"csvbox-modal-hidden\") {\n\t\t\t\thandleModalClosed();\n\t\t\t} else if (message.type === \"csvbox-upload-successful\") {\n\t\t\t\tonImport(true);\n\t\t\t} else if (message.type === \"csvbox-upload-failed\") {\n\t\t\t\tonImport(false);\n\t\t\t}\n\n\t\t};\n\n\t\twindow.addEventListener(\"message\", this.messageListener, false);\n\n\t\tthis.uuid = generateUuid();\n\n\t\tlet self = this;\n\n\t\tlet iframe = document.createElement(\"iframe\");\n\t\tthis.iframe = iframe;\n\t\tiframe.setAttribute(\"src\", iframeUrl);\n\t\tiframe.frameBorder = 0;\n\t\tiframe.classList.add('csvbox-iframe');\n\n\t\tObject.assign(iframe.style, IFRAME_STYLE);\n\n\t\tiframe.onload = function () {\n\t\t\tself.enableInitator();\n\t\t\tiframe.contentWindow.postMessage(buildInitPayload(user, dynamicColumns, options, self.uuid), \"*\");\n\t\t\tonReady?.();\n\t\t\tif (self.lifecycle.markReady()) {\n\t\t\t\tself.openModal();\n\t\t\t}\n\t\t}\n\t\tthis.holder.current.appendChild(iframe);\n\t}\n\n\topenModal() {\n\n\t\tif (!this.iframe) {\n\t\t\tthis.lifecycle.requestOpen();\n\t\t\tthis.initImporter();\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.lifecycle.requestOpen()) {\n\t\t\tthis.iframe.contentWindow.postMessage('openModal', '*');\n\t\t\tthis.holder.current.style.display = 'block';\n\t\t}\n\n\t}\n\n\tenableInitator() {\n\t\tthis.setState({\n\t\t\tisLoading: false\n\t\t})\n\t}\n\n\trender() {\n\n\t\tif (this.props.render) {\n\t\t\treturn (\n\t\t\t\t<div>\n\t\t\t\t\t{this.props.render(this.openModal, this.state.isLoading)}\n\t\t\t\t\t<div ref={this.holder} style={HOLDER_STYLE}></div>\n\t\t\t\t</div>\n\t\t\t)\n\t\t} else {\n\t\t\treturn (\n\t\t\t\t<div>\n\t\t\t\t\t<button disabled={this.state.isLoading} onClick={this.openModal} data-csvbox-initator data-csvbox-token={this.uuid}>{this.props.children}</button>\n\t\t\t\t\t<div ref={this.holder} style={HOLDER_STYLE}></div>\n\t\t\t\t</div>\n\t\t\t)\n\t\t}\n\n\n\t}\n}\n\nexport default CSVBoxButton;\n"],"names":["CSVBoxButton","props","holder","React","createRef","openModal","bind","lifecycle","createModalLifecycle","uuid","generateUuid","state","isLoading","iframe","componentDidMount","lazy","initImporter","enableInitator","loadStarted","user","dynamicColumns","options","onReady","onImport","onSubmit","onClose","licenseKey","dataLocation","customDomain","language","environment","theme","iframeUrl","buildImportUrl","version","handleModalClosed","current","style","display","innerHTML","markClosed","messageListener","window","removeEventListener","event","legacy","classifyLegacyMessage","data","type","message","classifyStructuredMessage","metadata","success","addEventListener","self","document","createElement","setAttribute","frameBorder","classList","add","Object","assign","IFRAME_STYLE","onload","contentWindow","postMessage","buildInitPayload","markReady","appendChild","requestOpen","setState","render","HOLDER_STYLE","children","Component"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAaaA,YAAb;AAAA;;AAEC,wBAAYC,KAAZ,EAAmB;AAAA;;AAClB,kCAAMA,KAAN;AACA,UAAKC,MAAL,GAAcC,cAAK,CAACC,SAAN,EAAd;AACA,UAAKC,SAAL,GAAiB,MAAKA,SAAL,CAAeC,IAAf,+BAAjB;AACA,UAAKC,SAAL,GAAiBC,gCAAoB,EAArC;AACA,UAAKC,IAAL,GAAYC,wBAAY,EAAxB;AACA,UAAKC,KAAL,GAAa;AACZC,MAAAA,SAAS,EAAE;AADC,KAAb;AAGA,UAAKC,MAAL,GAAc,IAAd;AATkB;AAUlB;;AAZF;;AAAA,SAcCC,iBAdD,GAcC,6BAAoB;AACnB,QAAQC,IAAR,GAAiB,KAAKd,KAAtB,CAAQc,IAAR;;AACA,QAAI,CAACA,IAAD,IAAS,CAAC,KAAKF,MAAnB,EAA2B;AAC1B,WAAKG,YAAL;AACA,KAFD,MAEO,IAAID,IAAJ,EAAU;AAChB,WAAKE,cAAL;AACA;AACD,GArBF;;AAAA,SAuBCD,YAvBD,GAuBC,wBAAe;AAAA;;AAEd,QAAQE,WAAR,GAAwB,KAAKjB,KAA7B,CAAQiB,WAAR;AAEAA,IAAAA,WAAW,SAAX,IAAAA,WAAW,WAAX,YAAAA,WAAW;AAEX,QAAQC,IAAR,GAAiB,KAAKlB,KAAtB,CAAQkB,IAAR;AACA,QAAQC,cAAR,GAA2B,KAAKnB,KAAhC,CAAQmB,cAAR;AACA,QAAQC,OAAR,GAAoB,KAAKpB,KAAzB,CAAQoB,OAAR;AACA,QAAQC,OAAR,GAAoB,KAAKrB,KAAzB,CAAQqB,OAAR;AACA,QAAQC,QAAR,GAAqB,KAAKtB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SAAL,CAAe+D,WAAf,EAAJ,EAAkC;AACjC,WAAKzD,MAAL,CAAYoD,aAAZ,CAA0BC,WAA1B,CAAsC,WAAtC,EAAmD,GAAnD;AACA,WAAKhE,MAAL,CAAYkC,OAAZ,CAAoBC,KAApB,CAA0BC,OAA1B,GAAoC,OAApC;AACA;AAED,GAxIF;;AAAA,SA0ICrB,cA1ID,GA0IC,0BAAiB;AAChB,SAAKsD,QAAL,CAAc;AACb3D,MAAAA,SAAS,EAAE;AADE,KAAd;AAGA,GA9IF;;AAAA,SAgJC4D,MAhJD,GAgJC,kBAAS;AAER,QAAI,KAAKvE,KAAL,CAAWuE,MAAf,EAAuB;AACtB,0BACCrE,0CACE,KAAKF,KAAL,CAAWuE,MAAX,CAAkB,KAAKnE,SAAvB,EAAkC,KAAKM,KAAL,CAAWC,SAA7C,CADF,eAECT;AAAK,QAAA,GAAG,EAAE,KAAKD,MAAf;AAAuB,QAAA,KAAK,EAAEuE;AAA9B,QAFD,CADD;AAMA,KAPD,MAOO;AACN,0BACCtE,uDACCA;AAAQ,QAAA,QAAQ,EAAE,KAAKQ,KAAL,CAAWC,SAA7B;AAAwC,QAAA,OAAO,EAAE,KAAKP,SAAtD;AAAiE,oCAAjE;AAAsF,6BAAmB,KAAKI;AAA9G,SAAqH,KAAKR,KAAL,CAAWyE,QAAhI,CADD,eAECvE;AAAK,QAAA,GAAG,EAAE,KAAKD,MAAf;AAAuB,QAAA,KAAK,EAAEuE;AAA9B,QAFD,CADD;AAMA;AAGD,GAnKF;;AAAA;AAAA,EAAkCE,eAAlC;;;;;"}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import { buildImportUrl, classifyLegacyMessage, classifyStructuredMessage, generateUuid, IFRAME_STYLE, buildInitPayload, HOLDER_STYLE, createModalLifecycle } from '@sumit_yewale/adapter-core';
|
|
3
|
+
|
|
4
|
+
function _inheritsLoose(subClass, superClass) {
|
|
5
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
6
|
+
subClass.prototype.constructor = subClass;
|
|
7
|
+
|
|
8
|
+
_setPrototypeOf(subClass, superClass);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function _setPrototypeOf(o, p) {
|
|
12
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
13
|
+
o.__proto__ = p;
|
|
14
|
+
return o;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
return _setPrototypeOf(o, p);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function _assertThisInitialized(self) {
|
|
21
|
+
if (self === void 0) {
|
|
22
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return self;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
var version = "1.1.14";
|
|
29
|
+
|
|
30
|
+
var CSVBoxButton = /*#__PURE__*/function (_Component) {
|
|
31
|
+
_inheritsLoose(CSVBoxButton, _Component);
|
|
32
|
+
|
|
33
|
+
function CSVBoxButton(props) {
|
|
34
|
+
var _this;
|
|
35
|
+
|
|
36
|
+
_this = _Component.call(this, props) || this;
|
|
37
|
+
_this.holder = React.createRef();
|
|
38
|
+
_this.openModal = _this.openModal.bind(_assertThisInitialized(_this));
|
|
39
|
+
_this.lifecycle = createModalLifecycle();
|
|
40
|
+
_this.uuid = generateUuid();
|
|
41
|
+
_this.state = {
|
|
42
|
+
isLoading: true
|
|
43
|
+
};
|
|
44
|
+
_this.iframe = null;
|
|
45
|
+
return _this;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
var _proto = CSVBoxButton.prototype;
|
|
49
|
+
|
|
50
|
+
_proto.componentDidMount = function componentDidMount() {
|
|
51
|
+
var lazy = this.props.lazy;
|
|
52
|
+
|
|
53
|
+
if (!lazy && !this.iframe) {
|
|
54
|
+
this.initImporter();
|
|
55
|
+
} else if (lazy) {
|
|
56
|
+
this.enableInitator();
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
_proto.initImporter = function initImporter() {
|
|
61
|
+
var _this2 = this;
|
|
62
|
+
|
|
63
|
+
var loadStarted = this.props.loadStarted;
|
|
64
|
+
loadStarted === null || loadStarted === void 0 ? void 0 : loadStarted();
|
|
65
|
+
var user = this.props.user;
|
|
66
|
+
var dynamicColumns = this.props.dynamicColumns;
|
|
67
|
+
var options = this.props.options;
|
|
68
|
+
var onReady = this.props.onReady;
|
|
69
|
+
var onImport = this.props.onImport;
|
|
70
|
+
var onSubmit = this.props.onSubmit;
|
|
71
|
+
var onClose = this.props.onClose;
|
|
72
|
+
var licenseKey = this.props.licenseKey;
|
|
73
|
+
var dataLocation = this.props.dataLocation;
|
|
74
|
+
var customDomain = this.props.customDomain;
|
|
75
|
+
var language = this.props.language;
|
|
76
|
+
var environment = this.props.environment;
|
|
77
|
+
var theme = this.props.theme;
|
|
78
|
+
var iframeUrl = buildImportUrl({
|
|
79
|
+
licenseKey: licenseKey,
|
|
80
|
+
customDomain: customDomain,
|
|
81
|
+
dataLocation: dataLocation,
|
|
82
|
+
language: language,
|
|
83
|
+
theme: theme,
|
|
84
|
+
environment: environment
|
|
85
|
+
}, "react", version);
|
|
86
|
+
|
|
87
|
+
var handleModalClosed = function handleModalClosed() {
|
|
88
|
+
if (_this2.holder && _this2.holder.current) {
|
|
89
|
+
_this2.holder.current.style.display = 'none';
|
|
90
|
+
_this2.holder.current.innerHTML = '';
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
_this2.lifecycle.markClosed();
|
|
94
|
+
|
|
95
|
+
_this2.iframe = null;
|
|
96
|
+
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
if (this.messageListener) {
|
|
100
|
+
window.removeEventListener("message", this.messageListener, false);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
this.messageListener = function (event) {
|
|
104
|
+
var legacy = classifyLegacyMessage(event.data);
|
|
105
|
+
|
|
106
|
+
if (legacy) {
|
|
107
|
+
if (legacy.type === "mainModalHidden") {
|
|
108
|
+
handleModalClosed();
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (legacy.type === "uploadSuccessful") {
|
|
112
|
+
onImport(true);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (legacy.type === "uploadFailed") {
|
|
116
|
+
onImport(false);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
var message = classifyStructuredMessage(event.data, _this2.uuid);
|
|
123
|
+
|
|
124
|
+
if (!message) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (message.type === "data-on-submit") {
|
|
129
|
+
onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(message.metadata);
|
|
130
|
+
} else if (message.type === "data-push-status") {
|
|
131
|
+
onImport(message.success, message.metadata);
|
|
132
|
+
} else if (message.type === "csvbox-modal-hidden") {
|
|
133
|
+
handleModalClosed();
|
|
134
|
+
} else if (message.type === "csvbox-upload-successful") {
|
|
135
|
+
onImport(true);
|
|
136
|
+
} else if (message.type === "csvbox-upload-failed") {
|
|
137
|
+
onImport(false);
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
window.addEventListener("message", this.messageListener, false);
|
|
142
|
+
this.uuid = generateUuid();
|
|
143
|
+
var self = this;
|
|
144
|
+
var iframe = document.createElement("iframe");
|
|
145
|
+
this.iframe = iframe;
|
|
146
|
+
iframe.setAttribute("src", iframeUrl);
|
|
147
|
+
iframe.frameBorder = 0;
|
|
148
|
+
iframe.classList.add('csvbox-iframe');
|
|
149
|
+
Object.assign(iframe.style, IFRAME_STYLE);
|
|
150
|
+
|
|
151
|
+
iframe.onload = function () {
|
|
152
|
+
self.enableInitator();
|
|
153
|
+
iframe.contentWindow.postMessage(buildInitPayload(user, dynamicColumns, options, self.uuid), "*");
|
|
154
|
+
onReady === null || onReady === void 0 ? void 0 : onReady();
|
|
155
|
+
|
|
156
|
+
if (self.lifecycle.markReady()) {
|
|
157
|
+
self.openModal();
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
this.holder.current.appendChild(iframe);
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
_proto.openModal = function openModal() {
|
|
165
|
+
if (!this.iframe) {
|
|
166
|
+
this.lifecycle.requestOpen();
|
|
167
|
+
this.initImporter();
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (this.lifecycle.requestOpen()) {
|
|
172
|
+
this.iframe.contentWindow.postMessage('openModal', '*');
|
|
173
|
+
this.holder.current.style.display = 'block';
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
_proto.enableInitator = function enableInitator() {
|
|
178
|
+
this.setState({
|
|
179
|
+
isLoading: false
|
|
180
|
+
});
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
_proto.render = function render() {
|
|
184
|
+
if (this.props.render) {
|
|
185
|
+
return /*#__PURE__*/React.createElement("div", null, this.props.render(this.openModal, this.state.isLoading), /*#__PURE__*/React.createElement("div", {
|
|
186
|
+
ref: this.holder,
|
|
187
|
+
style: HOLDER_STYLE
|
|
188
|
+
}));
|
|
189
|
+
} else {
|
|
190
|
+
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("button", {
|
|
191
|
+
disabled: this.state.isLoading,
|
|
192
|
+
onClick: this.openModal,
|
|
193
|
+
"data-csvbox-initator": true,
|
|
194
|
+
"data-csvbox-token": this.uuid
|
|
195
|
+
}, this.props.children), /*#__PURE__*/React.createElement("div", {
|
|
196
|
+
ref: this.holder,
|
|
197
|
+
style: HOLDER_STYLE
|
|
198
|
+
}));
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
return CSVBoxButton;
|
|
203
|
+
}(Component);
|
|
204
|
+
|
|
205
|
+
export default CSVBoxButton;
|
|
206
|
+
export { CSVBoxButton };
|
|
207
|
+
//# sourceMappingURL=index.modern.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.modern.js","sources":["../src/index.js"],"sourcesContent":["import React, { Component } from 'react';\nimport { version } from '../package.json';\nimport {\n\tHOLDER_STYLE,\n\tIFRAME_STYLE,\n\tbuildImportUrl,\n\tgenerateUuid,\n\tbuildInitPayload,\n\tcreateModalLifecycle,\n\tclassifyStructuredMessage,\n\tclassifyLegacyMessage\n} from '@sumit_yewale/adapter-core';\n\nexport class CSVBoxButton extends Component {\n\n\tconstructor(props) {\n\t\tsuper(props)\n\t\tthis.holder = React.createRef();\n\t\tthis.openModal = this.openModal.bind(this)\n\t\tthis.lifecycle = createModalLifecycle();\n\t\tthis.uuid = generateUuid();\n\t\tthis.state = {\n\t\t\tisLoading: true\n\t\t};\n\t\tthis.iframe = null;\n\t}\n\n\tcomponentDidMount() {\n\t\tconst { lazy } = this.props;\n\t\tif (!lazy && !this.iframe) {\n\t\t\tthis.initImporter();\n\t\t} else if (lazy) {\n\t\t\tthis.enableInitator();\n\t\t}\n\t}\n\n\tinitImporter() {\n\n\t\tconst { loadStarted } = this.props;\n\n\t\tloadStarted?.();\n\n\t\tconst { user } = this.props;\n\t\tconst { dynamicColumns } = this.props;\n\t\tconst { options } = this.props;\n\t\tconst { onReady } = this.props;\n\t\tconst { onImport } = this.props;\n\t\tconst { onSubmit } = this.props;\n\t\tconst { onClose } = this.props;\n\t\tconst { licenseKey } = this.props;\n\t\tconst { dataLocation } = this.props;\n\t\tconst { customDomain } = this.props;\n\t\tconst { language } = this.props;\n\t\tconst { environment } = this.props;\n\t\tconst { theme } = this.props;\n\n\t\tlet iframeUrl = buildImportUrl(\n\t\t\t{ licenseKey, customDomain, dataLocation, language, theme, environment },\n\t\t\t\"react\",\n\t\t\tversion\n\t\t);\n\n\t\tlet handleModalClosed = () => {\n\t\t\tif (this.holder && this.holder.current) {\n\t\t\t\tthis.holder.current.style.display = 'none';\n\t\t\t\tthis.holder.current.innerHTML = '';\n\t\t\t}\n\t\t\tthis.lifecycle.markClosed();\n\t\t\tthis.iframe = null;\n\t\t\tonClose?.();\n\t\t};\n\n\t\tif (this.messageListener) {\n\t\t\twindow.removeEventListener(\"message\", this.messageListener, false);\n\t\t}\n\n\t\tthis.messageListener = (event) => {\n\n\t\t\tlet legacy = classifyLegacyMessage(event.data);\n\t\t\tif (legacy) {\n\t\t\t\tif (legacy.type === \"mainModalHidden\") {\n\t\t\t\t\thandleModalClosed();\n\t\t\t\t}\n\t\t\t\tif (legacy.type === \"uploadSuccessful\") {\n\t\t\t\t\tonImport(true);\n\t\t\t\t}\n\t\t\t\tif (legacy.type === \"uploadFailed\") {\n\t\t\t\t\tonImport(false);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tlet message = classifyStructuredMessage(event.data, this.uuid);\n\t\t\tif (!message) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (message.type === \"data-on-submit\") {\n\t\t\t\tonSubmit?.(message.metadata);\n\t\t\t} else if (message.type === \"data-push-status\") {\n\t\t\t\tonImport(message.success, message.metadata);\n\t\t\t} else if (message.type === \"csvbox-modal-hidden\") {\n\t\t\t\thandleModalClosed();\n\t\t\t} else if (message.type === \"csvbox-upload-successful\") {\n\t\t\t\tonImport(true);\n\t\t\t} else if (message.type === \"csvbox-upload-failed\") {\n\t\t\t\tonImport(false);\n\t\t\t}\n\n\t\t};\n\n\t\twindow.addEventListener(\"message\", this.messageListener, false);\n\n\t\tthis.uuid = generateUuid();\n\n\t\tlet self = this;\n\n\t\tlet iframe = document.createElement(\"iframe\");\n\t\tthis.iframe = iframe;\n\t\tiframe.setAttribute(\"src\", iframeUrl);\n\t\tiframe.frameBorder = 0;\n\t\tiframe.classList.add('csvbox-iframe');\n\n\t\tObject.assign(iframe.style, IFRAME_STYLE);\n\n\t\tiframe.onload = function () {\n\t\t\tself.enableInitator();\n\t\t\tiframe.contentWindow.postMessage(buildInitPayload(user, dynamicColumns, options, self.uuid), \"*\");\n\t\t\tonReady?.();\n\t\t\tif (self.lifecycle.markReady()) {\n\t\t\t\tself.openModal();\n\t\t\t}\n\t\t}\n\t\tthis.holder.current.appendChild(iframe);\n\t}\n\n\topenModal() {\n\n\t\tif (!this.iframe) {\n\t\t\tthis.lifecycle.requestOpen();\n\t\t\tthis.initImporter();\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.lifecycle.requestOpen()) {\n\t\t\tthis.iframe.contentWindow.postMessage('openModal', '*');\n\t\t\tthis.holder.current.style.display = 'block';\n\t\t}\n\n\t}\n\n\tenableInitator() {\n\t\tthis.setState({\n\t\t\tisLoading: false\n\t\t})\n\t}\n\n\trender() {\n\n\t\tif (this.props.render) {\n\t\t\treturn (\n\t\t\t\t<div>\n\t\t\t\t\t{this.props.render(this.openModal, this.state.isLoading)}\n\t\t\t\t\t<div ref={this.holder} style={HOLDER_STYLE}></div>\n\t\t\t\t</div>\n\t\t\t)\n\t\t} else {\n\t\t\treturn (\n\t\t\t\t<div>\n\t\t\t\t\t<button disabled={this.state.isLoading} onClick={this.openModal} data-csvbox-initator data-csvbox-token={this.uuid}>{this.props.children}</button>\n\t\t\t\t\t<div ref={this.holder} style={HOLDER_STYLE}></div>\n\t\t\t\t</div>\n\t\t\t)\n\t\t}\n\n\n\t}\n}\n\nexport default CSVBoxButton;\n"],"names":["CSVBoxButton","props","holder","React","createRef","openModal","bind","lifecycle","createModalLifecycle","uuid","generateUuid","state","isLoading","iframe","componentDidMount","lazy","initImporter","enableInitator","loadStarted","user","dynamicColumns","options","onReady","onImport","onSubmit","onClose","licenseKey","dataLocation","customDomain","language","environment","theme","iframeUrl","buildImportUrl","version","handleModalClosed","current","style","display","innerHTML","markClosed","messageListener","window","removeEventListener","event","legacy","classifyLegacyMessage","data","type","message","classifyStructuredMessage","metadata","success","addEventListener","self","document","createElement","setAttribute","frameBorder","classList","add","Object","assign","IFRAME_STYLE","onload","contentWindow","postMessage","buildInitPayload","markReady","appendChild","requestOpen","setState","render","HOLDER_STYLE","children","Component"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAaaA,YAAb;AAAA;;AAEC,wBAAYC,KAAZ,EAAmB;AAAA;;AAClB,kCAAMA,KAAN;AACA,UAAKC,MAAL,GAAcC,KAAK,CAACC,SAAN,EAAd;AACA,UAAKC,SAAL,GAAiB,MAAKA,SAAL,CAAeC,IAAf,+BAAjB;AACA,UAAKC,SAAL,GAAiBC,oBAAoB,EAArC;AACA,UAAKC,IAAL,GAAYC,YAAY,EAAxB;AACA,UAAKC,KAAL,GAAa;AACZC,MAAAA,SAAS,EAAE;AADC,KAAb;AAGA,UAAKC,MAAL,GAAc,IAAd;AATkB;AAUlB;;AAZF;;AAAA,SAcCC,iBAdD,GAcC,6BAAoB;AACnB,QAAQC,IAAR,GAAiB,KAAKd,KAAtB,CAAQc,IAAR;;AACA,QAAI,CAACA,IAAD,IAAS,CAAC,KAAKF,MAAnB,EAA2B;AAC1B,WAAKG,YAAL;AACA,KAFD,MAEO,IAAID,IAAJ,EAAU;AAChB,WAAKE,cAAL;AACA;AACD,GArBF;;AAAA,SAuBCD,YAvBD,GAuBC,wBAAe;AAAA;;AAEd,QAAQE,WAAR,GAAwB,KAAKjB,KAA7B,CAAQiB,WAAR;AAEAA,IAAAA,WAAW,SAAX,IAAAA,WAAW,WAAX,YAAAA,WAAW;AAEX,QAAQC,IAAR,GAAiB,KAAKlB,KAAtB,CAAQkB,IAAR;AACA,QAAQC,cAAR,GAA2B,KAAKnB,KAAhC,CAAQmB,cAAR;AACA,QAAQC,OAAR,GAAoB,KAAKpB,KAAzB,CAAQoB,OAAR;AACA,QAAQC,OAAR,GAAoB,KAAKrB,KAAzB,CAAQqB,OAAR;AACA,QAAQC,QAAR,GAAqB,KAAKtB,KAA1B,CAAQsB,QAAR;AACA,QAAQC,QAAR,GAAqB,KAAKvB,KAA1B,CAAQuB,QAAR;AACA,QAAQ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C,WAAtC,EAAmD,GAAnD;AACA,WAAKhE,MAAL,CAAYkC,OAAZ,CAAoBC,KAApB,CAA0BC,OAA1B,GAAoC,OAApC;AACA;AAED,GAxIF;;AAAA,SA0ICrB,cA1ID,GA0IC,0BAAiB;AAChB,SAAKsD,QAAL,CAAc;AACb3D,MAAAA,SAAS,EAAE;AADE,KAAd;AAGA,GA9IF;;AAAA,SAgJC4D,MAhJD,GAgJC,kBAAS;AAER,QAAI,KAAKvE,KAAL,CAAWuE,MAAf,EAAuB;AACtB,0BACC,iCACE,KAAKvE,KAAL,CAAWuE,MAAX,CAAkB,KAAKnE,SAAvB,EAAkC,KAAKM,KAAL,CAAWC,SAA7C,CADF,eAEC;AAAK,QAAA,GAAG,EAAE,KAAKV,MAAf;AAAuB,QAAA,KAAK,EAAEuE;AAA9B,QAFD,CADD;AAMA,KAPD,MAOO;AACN,0BACC,8CACC;AAAQ,QAAA,QAAQ,EAAE,KAAK9D,KAAL,CAAWC,SAA7B;AAAwC,QAAA,OAAO,EAAE,KAAKP,SAAtD;AAAiE,oCAAjE;AAAsF,6BAAmB,KAAKI;AAA9G,SAAqH,KAAKR,KAAL,CAAWyE,QAAhI,CADD,eAEC;AAAK,QAAA,GAAG,EAAE,KAAKxE,MAAf;AAAuB,QAAA,KAAK,EAAEuE;AAA9B,QAFD,CADD;AAMA;AAGD,GAnKF;;AAAA;AAAA,EAAkCE,SAAlC;;;;;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sumit_yewale/react",
|
|
3
|
+
"version": "1.1.14",
|
|
4
|
+
"description": "React adapter for csvbox.io",
|
|
5
|
+
"types": "@types/csvbox__react.d.ts",
|
|
6
|
+
"author": "csvbox-io",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/csvbox-io/react.git"
|
|
11
|
+
},
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public"
|
|
14
|
+
},
|
|
15
|
+
"main": "dist/index.js",
|
|
16
|
+
"module": "dist/index.modern.js",
|
|
17
|
+
"source": "src/index.js",
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=10"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "microbundle-crl --no-compress --format modern,cjs",
|
|
23
|
+
"start": "microbundle-crl watch --no-compress --format modern,cjs",
|
|
24
|
+
"prepare": "run-s build",
|
|
25
|
+
"test": "run-s test:unit test:lint test:build",
|
|
26
|
+
"test:build": "run-s build",
|
|
27
|
+
"test:lint": "eslint .",
|
|
28
|
+
"test:unit": "cross-env CI=1 react-scripts test --env=jsdom",
|
|
29
|
+
"test:watch": "react-scripts test --env=jsdom",
|
|
30
|
+
"predeploy": "cd example && npm install && npm run build",
|
|
31
|
+
"deploy": "gh-pages -d example/build"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"react": "^16.13.1 || ^17.0.2 || ^18.0.0 || ^19.0.0",
|
|
35
|
+
"react-dom": "^16.13.1 || ^17.0.2 || ^18.0.0 || ^19.0.0"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@sumit_yewale/adapter-core": "^0.0.1"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"babel-eslint": "^10.0.3",
|
|
42
|
+
"cross-env": "^7.0.2",
|
|
43
|
+
"eslint": "^6.8.0",
|
|
44
|
+
"eslint-config-prettier": "^6.7.0",
|
|
45
|
+
"eslint-config-standard": "^14.1.0",
|
|
46
|
+
"eslint-config-standard-react": "^9.2.0",
|
|
47
|
+
"eslint-plugin-import": "^2.18.2",
|
|
48
|
+
"eslint-plugin-node": "^11.0.0",
|
|
49
|
+
"eslint-plugin-prettier": "^3.1.1",
|
|
50
|
+
"eslint-plugin-promise": "^4.2.1",
|
|
51
|
+
"eslint-plugin-react": "^7.17.0",
|
|
52
|
+
"eslint-plugin-standard": "^4.0.1",
|
|
53
|
+
"gh-pages": "^2.2.0",
|
|
54
|
+
"microbundle-crl": "^0.13.10",
|
|
55
|
+
"npm-run-all": "^4.1.5",
|
|
56
|
+
"prettier": "^2.0.4",
|
|
57
|
+
"react": "^16.13.1",
|
|
58
|
+
"react-dom": "^16.13.1",
|
|
59
|
+
"react-scripts": "^3.4.1"
|
|
60
|
+
},
|
|
61
|
+
"files": [
|
|
62
|
+
"dist",
|
|
63
|
+
"@types/csvbox__react.d.ts"
|
|
64
|
+
],
|
|
65
|
+
"keywords": [
|
|
66
|
+
"csv",
|
|
67
|
+
"importer",
|
|
68
|
+
"uploader",
|
|
69
|
+
"csvbox",
|
|
70
|
+
"parser",
|
|
71
|
+
"csv-parse",
|
|
72
|
+
"excel",
|
|
73
|
+
"xls",
|
|
74
|
+
"csv import",
|
|
75
|
+
"csv upload",
|
|
76
|
+
"spreadsheet import",
|
|
77
|
+
"react csv",
|
|
78
|
+
"csv parse",
|
|
79
|
+
"csv to json"
|
|
80
|
+
],
|
|
81
|
+
"bugs": {
|
|
82
|
+
"url": "https://github.com/csvbox-io/react/issues"
|
|
83
|
+
},
|
|
84
|
+
"homepage": "https://github.com/csvbox-io/react#readme",
|
|
85
|
+
"directories": {
|
|
86
|
+
"example": "example"
|
|
87
|
+
}
|
|
88
|
+
}
|