chayns-api 2.2.5 → 2.2.7
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/cjs/components/ChaynsProvider.js +3 -5
- package/dist/cjs/components/withCompatMode.js +5 -8
- package/dist/cjs/host/module/ModuleHost.js +22 -19
- package/dist/esm/components/ChaynsProvider.js +3 -5
- package/dist/esm/components/withCompatMode.js +5 -8
- package/dist/esm/host/module/ModuleHost.js +22 -19
- package/package.json +1 -1
|
@@ -83,11 +83,9 @@ const ChaynsProvider = ({
|
|
|
83
83
|
})();
|
|
84
84
|
}, []);
|
|
85
85
|
(0, _react.useEffect)(() => {
|
|
86
|
-
if (isModule) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
customWrapper.current.emitChange();
|
|
90
|
-
}
|
|
86
|
+
if (isModule && data) {
|
|
87
|
+
customWrapper.current.values = data;
|
|
88
|
+
customWrapper.current.emitChange();
|
|
91
89
|
}
|
|
92
90
|
}, [data, isModule]);
|
|
93
91
|
(0, _react.useEffect)(() => {
|
|
@@ -7,14 +7,11 @@ exports.withCompatMode = void 0;
|
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
9
9
|
var _ErrorBoundary = _interopRequireDefault(require("./ErrorBoundary"));
|
|
10
|
+
var _client = require("react-dom/client");
|
|
10
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
12
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
12
13
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
13
14
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
14
|
-
let ReactDOMClient;
|
|
15
|
-
try {
|
|
16
|
-
ReactDOMClient = require('react-dom/client');
|
|
17
|
-
} catch (e) {}
|
|
18
15
|
const withCompatMode = Component => {
|
|
19
16
|
class CompatComponent extends _react.PureComponent {
|
|
20
17
|
constructor(props) {
|
|
@@ -22,16 +19,16 @@ const withCompatMode = Component => {
|
|
|
22
19
|
this.ref = _react.default.createRef();
|
|
23
20
|
}
|
|
24
21
|
componentDidMount() {
|
|
25
|
-
var _ReactDOMClient;
|
|
26
22
|
const {
|
|
27
23
|
innerRef
|
|
28
24
|
} = this.props;
|
|
29
25
|
const component = _react.default.createElement(_ErrorBoundary.default, null, _react.default.createElement(Component, _extends({}, this.props, {
|
|
30
26
|
ref: innerRef
|
|
31
27
|
})));
|
|
32
|
-
if (typeof
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
if (typeof _client.createRoot === 'function') {
|
|
29
|
+
const identifierPrefix = Math.floor(Math.random() * 2 ** 64).toString(16);
|
|
30
|
+
this.root = (0, _client.createRoot)(this.ref.current, {
|
|
31
|
+
identifierPrefix
|
|
35
32
|
});
|
|
36
33
|
this.root.render(component);
|
|
37
34
|
} else {
|
|
@@ -39,24 +39,27 @@ const ModuleHost = ({
|
|
|
39
39
|
preventStagingReplacement,
|
|
40
40
|
styleSettings
|
|
41
41
|
}) => {
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
42
|
+
const data = (0, _react.useMemo)(() => {
|
|
43
|
+
const result = {
|
|
44
|
+
site,
|
|
45
|
+
isAdminModeActive,
|
|
46
|
+
pages,
|
|
47
|
+
currentPage,
|
|
48
|
+
device,
|
|
49
|
+
language,
|
|
50
|
+
parameters,
|
|
51
|
+
customData,
|
|
52
|
+
environment,
|
|
53
|
+
styleSettings
|
|
54
|
+
};
|
|
55
|
+
if (user) {
|
|
56
|
+
result.user = user;
|
|
57
|
+
}
|
|
58
|
+
if (dialog) {
|
|
59
|
+
result.dialog = dialog;
|
|
60
|
+
}
|
|
61
|
+
return result;
|
|
62
|
+
}, [site, isAdminModeActive, pages, currentPage, device, language, parameters, customData, environment, styleSettings, user, dialog]);
|
|
60
63
|
return _react.default.createElement(_react.default.Fragment, null, _react.default.createElement("div", {
|
|
61
64
|
className: "module-css"
|
|
62
65
|
}), _react.default.createElement(System, {
|
|
@@ -67,7 +70,7 @@ const ModuleHost = ({
|
|
|
67
70
|
module: system.module,
|
|
68
71
|
preventSingleton: system.preventSingleton
|
|
69
72
|
},
|
|
70
|
-
data:
|
|
73
|
+
data: data,
|
|
71
74
|
functions: functions,
|
|
72
75
|
customFunctions: customFunctions,
|
|
73
76
|
fallback: children,
|
|
@@ -77,11 +77,9 @@ const ChaynsProvider = _ref2 => {
|
|
|
77
77
|
})();
|
|
78
78
|
}, []);
|
|
79
79
|
useEffect(() => {
|
|
80
|
-
if (isModule) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
customWrapper.current.emitChange();
|
|
84
|
-
}
|
|
80
|
+
if (isModule && data) {
|
|
81
|
+
customWrapper.current.values = data;
|
|
82
|
+
customWrapper.current.emitChange();
|
|
85
83
|
}
|
|
86
84
|
}, [data, isModule]);
|
|
87
85
|
useEffect(() => {
|
|
@@ -2,10 +2,7 @@ function _extends() { return _extends = Object.assign ? Object.assign.bind() : f
|
|
|
2
2
|
import React, { PureComponent } from 'react';
|
|
3
3
|
import ReactDOM from 'react-dom';
|
|
4
4
|
import ErrorBoundary from './ErrorBoundary';
|
|
5
|
-
|
|
6
|
-
try {
|
|
7
|
-
ReactDOMClient = require('react-dom/client');
|
|
8
|
-
} catch (e) {}
|
|
5
|
+
import { createRoot } from 'react-dom/client';
|
|
9
6
|
export const withCompatMode = Component => {
|
|
10
7
|
class CompatComponent extends PureComponent {
|
|
11
8
|
constructor(props) {
|
|
@@ -13,16 +10,16 @@ export const withCompatMode = Component => {
|
|
|
13
10
|
this.ref = React.createRef();
|
|
14
11
|
}
|
|
15
12
|
componentDidMount() {
|
|
16
|
-
var _ReactDOMClient;
|
|
17
13
|
const {
|
|
18
14
|
innerRef
|
|
19
15
|
} = this.props;
|
|
20
16
|
const component = React.createElement(ErrorBoundary, null, React.createElement(Component, _extends({}, this.props, {
|
|
21
17
|
ref: innerRef
|
|
22
18
|
})));
|
|
23
|
-
if (typeof
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
if (typeof createRoot === 'function') {
|
|
20
|
+
const identifierPrefix = Math.floor(Math.random() * 2 ** 64).toString(16);
|
|
21
|
+
this.root = createRoot(this.ref.current, {
|
|
22
|
+
identifierPrefix
|
|
26
23
|
});
|
|
27
24
|
this.root.render(component);
|
|
28
25
|
} else {
|
|
@@ -32,24 +32,27 @@ const ModuleHost = _ref2 => {
|
|
|
32
32
|
preventStagingReplacement,
|
|
33
33
|
styleSettings
|
|
34
34
|
} = _ref2;
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
35
|
+
const data = useMemo(() => {
|
|
36
|
+
const result = {
|
|
37
|
+
site,
|
|
38
|
+
isAdminModeActive,
|
|
39
|
+
pages,
|
|
40
|
+
currentPage,
|
|
41
|
+
device,
|
|
42
|
+
language,
|
|
43
|
+
parameters,
|
|
44
|
+
customData,
|
|
45
|
+
environment,
|
|
46
|
+
styleSettings
|
|
47
|
+
};
|
|
48
|
+
if (user) {
|
|
49
|
+
result.user = user;
|
|
50
|
+
}
|
|
51
|
+
if (dialog) {
|
|
52
|
+
result.dialog = dialog;
|
|
53
|
+
}
|
|
54
|
+
return result;
|
|
55
|
+
}, [site, isAdminModeActive, pages, currentPage, device, language, parameters, customData, environment, styleSettings, user, dialog]);
|
|
53
56
|
return React.createElement(React.Fragment, null, React.createElement("div", {
|
|
54
57
|
className: "module-css"
|
|
55
58
|
}), React.createElement(System, {
|
|
@@ -60,7 +63,7 @@ const ModuleHost = _ref2 => {
|
|
|
60
63
|
module: system.module,
|
|
61
64
|
preventSingleton: system.preventSingleton
|
|
62
65
|
},
|
|
63
|
-
data:
|
|
66
|
+
data: data,
|
|
64
67
|
functions: functions,
|
|
65
68
|
customFunctions: customFunctions,
|
|
66
69
|
fallback: children,
|