@jspreadsheet/react 11.0.0-beta.8 → 11.0.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.
- package/dist/index.d.ts +7 -1
- package/dist/index.js +32 -3
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -14,9 +14,15 @@ interface Worksheet {
|
|
|
14
14
|
[key: string]: any
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
interface Picker {
|
|
18
|
+
(): any
|
|
19
|
+
[key: string]: any
|
|
20
|
+
}
|
|
21
|
+
|
|
17
22
|
declare function Spreadsheet<Spreadsheet>(props: Spreadsheet): any;
|
|
18
23
|
declare function Worksheet<Worksheet>(props: Worksheet): any;
|
|
24
|
+
declare function Picker<Picker>(props: Picker): any;
|
|
19
25
|
|
|
20
26
|
import jspreadsheet from "jspreadsheet";
|
|
21
27
|
|
|
22
|
-
export { Spreadsheet, Worksheet, jspreadsheet };
|
|
28
|
+
export { Spreadsheet, Worksheet, Picker, jspreadsheet };
|
package/dist/index.js
CHANGED
|
@@ -39,7 +39,7 @@ const Spreadsheet = React.forwardRef((props, mainReference) => {
|
|
|
39
39
|
// Extract worksheet options
|
|
40
40
|
extractWorksheetProperties.call(options, v.props);
|
|
41
41
|
});
|
|
42
|
-
} else {
|
|
42
|
+
} else if (props.children) {
|
|
43
43
|
// Extract worksheet options
|
|
44
44
|
extractWorksheetProperties.call(options, props.children.props);
|
|
45
45
|
}
|
|
@@ -55,7 +55,7 @@ const Spreadsheet = React.forwardRef((props, mainReference) => {
|
|
|
55
55
|
|
|
56
56
|
useEffect(() => {
|
|
57
57
|
// @ts-ignore
|
|
58
|
-
if (! jssDom.current.
|
|
58
|
+
if (! jssDom.current.textContent && ! mainReference.current) {
|
|
59
59
|
mainReference.current = jspreadsheet(jssDom.current, options);
|
|
60
60
|
}
|
|
61
61
|
}, []);
|
|
@@ -75,4 +75,33 @@ function Worksheet () {
|
|
|
75
75
|
return (null);
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
|
|
78
|
+
// @ts-ignore
|
|
79
|
+
const Picker = React.forwardRef((props, mainReference) => {
|
|
80
|
+
|
|
81
|
+
// Dom element
|
|
82
|
+
const jssDom = useRef(null);
|
|
83
|
+
|
|
84
|
+
// Get the properties for the spreadsheet
|
|
85
|
+
let options = { ...props };
|
|
86
|
+
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
if (! jssDom.current.textContent) {
|
|
89
|
+
let ret = jspreadsheet.picker(jssDom.current, options);
|
|
90
|
+
if (mainReference && ! mainReference.current) {
|
|
91
|
+
mainReference.current = ret;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}, []);
|
|
95
|
+
|
|
96
|
+
let prop = {
|
|
97
|
+
ref: jssDom
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
if (typeof(options.id) !== 'undefined') {
|
|
101
|
+
prop.id = options.id;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return React.createElement("div", prop);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
export { Spreadsheet, Worksheet, Picker, jspreadsheet };
|
package/package.json
CHANGED