@jspreadsheet/react 9.4.1 → 9.4.3

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.
Files changed (2) hide show
  1. package/dist/index.js +27 -18
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -5,8 +5,6 @@ import jspreadsheet from 'jspreadsheet';
5
5
  import "/node_modules/jspreadsheet/dist/jspreadsheet.css";
6
6
  import "/node_modules/jsuites/dist/jsuites.css";
7
7
 
8
- window.jspreadsheet = jspreadsheet;
9
-
10
8
  const extractWorksheetProperties = function(props) {
11
9
  this.worksheets.push({
12
10
  minDimensions: [10, 10],
@@ -14,7 +12,10 @@ const extractWorksheetProperties = function(props) {
14
12
  });
15
13
  }
16
14
 
17
- export const Spreadsheet = React.forwardRef((props, mainReference) => {
15
+ window.jspreadsheet = jspreadsheet;
16
+
17
+ // @ts-ignore
18
+ const Spreadsheet = React.forwardRef((props, mainReference) => {
18
19
  // Set the license
19
20
  if (props.license) {
20
21
  jspreadsheet.setLicense(props.license);
@@ -27,36 +28,44 @@ export const Spreadsheet = React.forwardRef((props, mainReference) => {
27
28
  const jssDom = useRef(null);
28
29
 
29
30
  // Get the properties for the spreadsheet
30
- let options = { ...props, worksheets: [] };
31
+ let options = { ...props };
31
32
 
32
- // Get all the properties from the worksheets
33
- if (Array.isArray(props.children)) {
34
- // Multiple worksheets
35
- props.children.map(function (v) {
33
+ if (! options.worksheets) {
34
+ // Create the worksheets
35
+ options.worksheets = [];
36
+ // Get all the properties from the worksheets
37
+ if (Array.isArray(props.children)) {
38
+ // Multiple worksheets
39
+ props.children.map(function (v) {
40
+ // Extract worksheet options
41
+ extractWorksheetProperties.call(options, v.props);
42
+ });
43
+ } else {
36
44
  // Extract worksheet options
37
- extractWorksheetProperties.call(options, v.props);
38
- });
39
- } else {
40
- // Extract worksheet options
41
- extractWorksheetProperties.call(options, props.children.props);
45
+ extractWorksheetProperties.call(options, props.children.props);
46
+ }
42
47
  }
43
48
 
44
- /*useEffect(() => {
49
+ /*useEffect(function() {
50
+ // Track changes in the data
45
51
  if (jssDom.current.innerText) {
46
- mainReference.current[0].setData(JSON.parse(JSON.stringify(options.worksheets[1].data)))
52
+ mainReference.current[0].setData(JSON.parse(JSON.stringify(options.worksheets[0].data)))
47
53
  }
48
54
  }, [options.worksheets[0].data]);*/
49
55
 
56
+
50
57
  useEffect(() => {
58
+ // @ts-ignore
51
59
  if (! jssDom.current.innerText) {
52
60
  mainReference.current = jspreadsheet(jssDom.current, options);
53
61
  }
54
62
  }, []);
55
63
 
56
- return (<div ref={jssDom}></div>);
57
-
64
+ return React.createElement("div", { ref: jssDom });
58
65
  })
59
66
 
60
- export function Worksheet () {
67
+ function Worksheet () {
61
68
  return (null);
62
69
  }
70
+
71
+ export { Spreadsheet, Worksheet, jspreadsheet };
package/package.json CHANGED
@@ -24,5 +24,5 @@
24
24
  },
25
25
  "main": "dist/index.js",
26
26
  "types": "dist/index.d.ts",
27
- "version": "9.4.1"
27
+ "version": "9.4.3"
28
28
  }