chayns-api 1.0.10 → 1.0.11
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/README.md
CHANGED
|
@@ -43,5 +43,12 @@ const FirstName = () => {
|
|
|
43
43
|
|
|
44
44
|
More information to setup chayns-api can be found in the [documentation](https://tobitsoftware.github.io/chayns-api/docs).
|
|
45
45
|
|
|
46
|
+
## Troubleshooting
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
Can't resolve 'react-dom/client'
|
|
50
|
+
```
|
|
51
|
+
A warning like above can be shown when you are still using react 17.
|
|
52
|
+
This can be ignored because the react 17 api is used as fallback instead.
|
|
46
53
|
|
|
47
54
|
## License
|
|
@@ -10,6 +10,12 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
10
10
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
11
11
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
12
12
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
13
|
+
let ReactDOMClient;
|
|
14
|
+
try {
|
|
15
|
+
ReactDOMClient = require('react-dom/client');
|
|
16
|
+
} catch (e) {
|
|
17
|
+
// do nothing
|
|
18
|
+
}
|
|
13
19
|
const withCompatMode = Component => {
|
|
14
20
|
class CompatComponent extends _react.PureComponent {
|
|
15
21
|
constructor(props) {
|
|
@@ -17,23 +23,39 @@ const withCompatMode = Component => {
|
|
|
17
23
|
this.ref = /*#__PURE__*/_react.default.createRef();
|
|
18
24
|
}
|
|
19
25
|
componentDidMount() {
|
|
26
|
+
var _ReactDOMClient;
|
|
20
27
|
const {
|
|
21
28
|
innerRef
|
|
22
29
|
} = this.props;
|
|
23
|
-
|
|
30
|
+
const component = /*#__PURE__*/_react.default.createElement(Component, _extends({}, this.props, {
|
|
24
31
|
ref: innerRef
|
|
25
|
-
}))
|
|
32
|
+
}));
|
|
33
|
+
if (typeof ((_ReactDOMClient = ReactDOMClient) === null || _ReactDOMClient === void 0 ? void 0 : _ReactDOMClient.createRoot) === 'function') {
|
|
34
|
+
this.root = ReactDOMClient.createRoot(this.ref.current);
|
|
35
|
+
this.root.render(component);
|
|
36
|
+
} else {
|
|
37
|
+
_reactDom.default.render(component, this.ref.current);
|
|
38
|
+
}
|
|
26
39
|
}
|
|
27
40
|
componentDidUpdate() {
|
|
28
41
|
const {
|
|
29
42
|
innerRef
|
|
30
43
|
} = this.props;
|
|
31
|
-
|
|
44
|
+
const component = /*#__PURE__*/_react.default.createElement(Component, _extends({}, this.props, {
|
|
32
45
|
ref: innerRef
|
|
33
|
-
}))
|
|
46
|
+
}));
|
|
47
|
+
if (this.root) {
|
|
48
|
+
this.root.render(component);
|
|
49
|
+
} else {
|
|
50
|
+
_reactDom.default.render(component, this.ref.current);
|
|
51
|
+
}
|
|
34
52
|
}
|
|
35
53
|
componentWillUnmount() {
|
|
36
|
-
|
|
54
|
+
if (this.root) {
|
|
55
|
+
this.root.render( /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null));
|
|
56
|
+
} else {
|
|
57
|
+
_reactDom.default.render( /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null), this.ref.current);
|
|
58
|
+
}
|
|
37
59
|
}
|
|
38
60
|
render() {
|
|
39
61
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -3,6 +3,12 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
|
|
|
3
3
|
|
|
4
4
|
import React, { PureComponent } from 'react';
|
|
5
5
|
import ReactDOM from 'react-dom';
|
|
6
|
+
let ReactDOMClient;
|
|
7
|
+
try {
|
|
8
|
+
ReactDOMClient = require('react-dom/client');
|
|
9
|
+
} catch (e) {
|
|
10
|
+
// do nothing
|
|
11
|
+
}
|
|
6
12
|
export const withCompatMode = Component => {
|
|
7
13
|
class CompatComponent extends PureComponent {
|
|
8
14
|
constructor(props) {
|
|
@@ -10,23 +16,39 @@ export const withCompatMode = Component => {
|
|
|
10
16
|
this.ref = /*#__PURE__*/React.createRef();
|
|
11
17
|
}
|
|
12
18
|
componentDidMount() {
|
|
19
|
+
var _ReactDOMClient;
|
|
13
20
|
const {
|
|
14
21
|
innerRef
|
|
15
22
|
} = this.props;
|
|
16
|
-
|
|
23
|
+
const component = /*#__PURE__*/React.createElement(Component, _extends({}, this.props, {
|
|
17
24
|
ref: innerRef
|
|
18
|
-
}))
|
|
25
|
+
}));
|
|
26
|
+
if (typeof ((_ReactDOMClient = ReactDOMClient) === null || _ReactDOMClient === void 0 ? void 0 : _ReactDOMClient.createRoot) === 'function') {
|
|
27
|
+
this.root = ReactDOMClient.createRoot(this.ref.current);
|
|
28
|
+
this.root.render(component);
|
|
29
|
+
} else {
|
|
30
|
+
ReactDOM.render(component, this.ref.current);
|
|
31
|
+
}
|
|
19
32
|
}
|
|
20
33
|
componentDidUpdate() {
|
|
21
34
|
const {
|
|
22
35
|
innerRef
|
|
23
36
|
} = this.props;
|
|
24
|
-
|
|
37
|
+
const component = /*#__PURE__*/React.createElement(Component, _extends({}, this.props, {
|
|
25
38
|
ref: innerRef
|
|
26
|
-
}))
|
|
39
|
+
}));
|
|
40
|
+
if (this.root) {
|
|
41
|
+
this.root.render(component);
|
|
42
|
+
} else {
|
|
43
|
+
ReactDOM.render(component, this.ref.current);
|
|
44
|
+
}
|
|
27
45
|
}
|
|
28
46
|
componentWillUnmount() {
|
|
29
|
-
|
|
47
|
+
if (this.root) {
|
|
48
|
+
this.root.render( /*#__PURE__*/React.createElement(React.Fragment, null));
|
|
49
|
+
} else {
|
|
50
|
+
ReactDOM.render( /*#__PURE__*/React.createElement(React.Fragment, null), this.ref.current);
|
|
51
|
+
}
|
|
30
52
|
}
|
|
31
53
|
render() {
|
|
32
54
|
return /*#__PURE__*/React.createElement("div", {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chayns-api",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.11",
|
|
4
4
|
"description": "new chayns api",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -56,16 +56,16 @@
|
|
|
56
56
|
"@types/htmlescape": "^1.1.1",
|
|
57
57
|
"@types/lodash.throttle": "^4.1.6",
|
|
58
58
|
"@types/prop-types": "^15.7.3",
|
|
59
|
-
"@types/react": "^
|
|
60
|
-
"@types/react-dom": "^
|
|
59
|
+
"@types/react": "^18.0.28",
|
|
60
|
+
"@types/react-dom": "^18.0.10",
|
|
61
61
|
"@typescript-eslint/parser": "^5.50.0",
|
|
62
62
|
"concurrently": "^7.6.0",
|
|
63
63
|
"cross-env": "^7.0.3",
|
|
64
64
|
"postcss-prefix-selector": "^1.13.0",
|
|
65
65
|
"prettier": "^2.5.0",
|
|
66
66
|
"prettier-plugin-packagejson": "^2.2.15",
|
|
67
|
-
"react": "^
|
|
68
|
-
"react-dom": "^
|
|
67
|
+
"react": "^18.2.0",
|
|
68
|
+
"react-dom": "^18.2.0",
|
|
69
69
|
"typescript": "^4.9.5"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|