@sitecore-content-sdk/react 1.0.0-canary.5 → 1.0.0-canary.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.
|
@@ -59,7 +59,14 @@ const Form = ({ params, rendering }) => {
|
|
|
59
59
|
(0, react_1.useEffect)(() => {
|
|
60
60
|
var _a, _b, _c, _d;
|
|
61
61
|
if (!content) {
|
|
62
|
-
|
|
62
|
+
// Forms must use clientContextId since they are rendered client-side
|
|
63
|
+
const edgeId = (_b = (_a = context.api) === null || _a === void 0 ? void 0 : _a.edge) === null || _b === void 0 ? void 0 : _b.clientContextId;
|
|
64
|
+
if (!edgeId) {
|
|
65
|
+
/* eslint-disable no-console */
|
|
66
|
+
console.warn('Warning: clientContextId is missing – form cannot be loaded properly on the client');
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
loadForm(edgeId, params.FormId, (_d = (_c = context.api) === null || _c === void 0 ? void 0 : _c.edge) === null || _d === void 0 ? void 0 : _d.edgeUrl)
|
|
63
70
|
.then(setContent)
|
|
64
71
|
.catch(() => {
|
|
65
72
|
if (isEditing) {
|
|
@@ -76,10 +83,8 @@ const Form = ({ params, rendering }) => {
|
|
|
76
83
|
executeScriptElements(formRef.current);
|
|
77
84
|
}
|
|
78
85
|
}, [content]);
|
|
79
|
-
if (isEditing) {
|
|
80
|
-
|
|
81
|
-
return (react_1.default.createElement("div", { className: "sc-content-sdk-placeholder-error" }, "There was a problem loading this section"));
|
|
82
|
-
}
|
|
86
|
+
if (isEditing && error) {
|
|
87
|
+
return (react_1.default.createElement("div", { className: "sc-content-sdk-placeholder-error" }, "There was a problem loading this section"));
|
|
83
88
|
}
|
|
84
89
|
return (react_1.default.createElement("div", { ref: formRef, dangerouslySetInnerHTML: { __html: content }, className: (_a = params.styles) === null || _a === void 0 ? void 0 : _a.trimEnd(), id: id ? id : undefined }));
|
|
85
90
|
};
|
|
@@ -12,7 +12,7 @@ exports.SitecoreProviderReactContext = react_1.default.createContext({});
|
|
|
12
12
|
exports.ComponentMapReactContext = react_1.default.createContext(new Map());
|
|
13
13
|
class SitecoreProvider extends react_1.default.Component {
|
|
14
14
|
constructor(props) {
|
|
15
|
-
var _a, _b, _c, _d;
|
|
15
|
+
var _a, _b, _c, _d, _e, _f;
|
|
16
16
|
super(props);
|
|
17
17
|
/**
|
|
18
18
|
* Update context state. Value can be @type {LayoutServiceData} which will be automatically transformed
|
|
@@ -27,8 +27,10 @@ class SitecoreProvider extends react_1.default.Component {
|
|
|
27
27
|
});
|
|
28
28
|
};
|
|
29
29
|
const pageContext = this.constructContext(props.layoutData);
|
|
30
|
+
// If any Edge ID is present but no edgeUrl, apply the default
|
|
30
31
|
let api = props.api;
|
|
31
|
-
if (((_b = (_a = props.api) === null || _a === void 0 ? void 0 : _a.edge) === null || _b === void 0 ? void 0 : _b.contextId)
|
|
32
|
+
if ((((_b = (_a = props.api) === null || _a === void 0 ? void 0 : _a.edge) === null || _b === void 0 ? void 0 : _b.contextId) || ((_d = (_c = props.api) === null || _c === void 0 ? void 0 : _c.edge) === null || _d === void 0 ? void 0 : _d.clientContextId)) &&
|
|
33
|
+
!((_f = (_e = props.api) === null || _e === void 0 ? void 0 : _e.edge) === null || _f === void 0 ? void 0 : _f.edgeUrl)) {
|
|
32
34
|
api = Object.assign(Object.assign({}, props.api), { edge: Object.assign(Object.assign({}, props.api.edge), { edgeUrl: core_1.constants.SITECORE_EDGE_URL_DEFAULT }) });
|
|
33
35
|
}
|
|
34
36
|
this.state = {
|
|
@@ -40,9 +42,7 @@ class SitecoreProvider extends react_1.default.Component {
|
|
|
40
42
|
constructContext(layoutData) {
|
|
41
43
|
var _a;
|
|
42
44
|
if (!layoutData) {
|
|
43
|
-
return {
|
|
44
|
-
pageEditing: false,
|
|
45
|
-
};
|
|
45
|
+
return { pageEditing: false };
|
|
46
46
|
}
|
|
47
47
|
return Object.assign({ route: layoutData.sitecore.route, itemId: (_a = layoutData.sitecore.route) === null || _a === void 0 ? void 0 : _a.itemId }, layoutData.sitecore.context);
|
|
48
48
|
}
|
|
@@ -22,7 +22,14 @@ export const Form = ({ params, rendering }) => {
|
|
|
22
22
|
useEffect(() => {
|
|
23
23
|
var _a, _b, _c, _d;
|
|
24
24
|
if (!content) {
|
|
25
|
-
|
|
25
|
+
// Forms must use clientContextId since they are rendered client-side
|
|
26
|
+
const edgeId = (_b = (_a = context.api) === null || _a === void 0 ? void 0 : _a.edge) === null || _b === void 0 ? void 0 : _b.clientContextId;
|
|
27
|
+
if (!edgeId) {
|
|
28
|
+
/* eslint-disable no-console */
|
|
29
|
+
console.warn('Warning: clientContextId is missing – form cannot be loaded properly on the client');
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
loadForm(edgeId, params.FormId, (_d = (_c = context.api) === null || _c === void 0 ? void 0 : _c.edge) === null || _d === void 0 ? void 0 : _d.edgeUrl)
|
|
26
33
|
.then(setContent)
|
|
27
34
|
.catch(() => {
|
|
28
35
|
if (isEditing) {
|
|
@@ -39,10 +46,8 @@ export const Form = ({ params, rendering }) => {
|
|
|
39
46
|
executeScriptElements(formRef.current);
|
|
40
47
|
}
|
|
41
48
|
}, [content]);
|
|
42
|
-
if (isEditing) {
|
|
43
|
-
|
|
44
|
-
return (React.createElement("div", { className: "sc-content-sdk-placeholder-error" }, "There was a problem loading this section"));
|
|
45
|
-
}
|
|
49
|
+
if (isEditing && error) {
|
|
50
|
+
return (React.createElement("div", { className: "sc-content-sdk-placeholder-error" }, "There was a problem loading this section"));
|
|
46
51
|
}
|
|
47
52
|
return (React.createElement("div", { ref: formRef, dangerouslySetInnerHTML: { __html: content }, className: (_a = params.styles) === null || _a === void 0 ? void 0 : _a.trimEnd(), id: id ? id : undefined }));
|
|
48
53
|
};
|
|
@@ -6,7 +6,7 @@ export const SitecoreProviderReactContext = React.createContext({});
|
|
|
6
6
|
export const ComponentMapReactContext = React.createContext(new Map());
|
|
7
7
|
export class SitecoreProvider extends React.Component {
|
|
8
8
|
constructor(props) {
|
|
9
|
-
var _a, _b, _c, _d;
|
|
9
|
+
var _a, _b, _c, _d, _e, _f;
|
|
10
10
|
super(props);
|
|
11
11
|
/**
|
|
12
12
|
* Update context state. Value can be @type {LayoutServiceData} which will be automatically transformed
|
|
@@ -21,8 +21,10 @@ export class SitecoreProvider extends React.Component {
|
|
|
21
21
|
});
|
|
22
22
|
};
|
|
23
23
|
const pageContext = this.constructContext(props.layoutData);
|
|
24
|
+
// If any Edge ID is present but no edgeUrl, apply the default
|
|
24
25
|
let api = props.api;
|
|
25
|
-
if (((_b = (_a = props.api) === null || _a === void 0 ? void 0 : _a.edge) === null || _b === void 0 ? void 0 : _b.contextId)
|
|
26
|
+
if ((((_b = (_a = props.api) === null || _a === void 0 ? void 0 : _a.edge) === null || _b === void 0 ? void 0 : _b.contextId) || ((_d = (_c = props.api) === null || _c === void 0 ? void 0 : _c.edge) === null || _d === void 0 ? void 0 : _d.clientContextId)) &&
|
|
27
|
+
!((_f = (_e = props.api) === null || _e === void 0 ? void 0 : _e.edge) === null || _f === void 0 ? void 0 : _f.edgeUrl)) {
|
|
26
28
|
api = Object.assign(Object.assign({}, props.api), { edge: Object.assign(Object.assign({}, props.api.edge), { edgeUrl: constants.SITECORE_EDGE_URL_DEFAULT }) });
|
|
27
29
|
}
|
|
28
30
|
this.state = {
|
|
@@ -34,9 +36,7 @@ export class SitecoreProvider extends React.Component {
|
|
|
34
36
|
constructContext(layoutData) {
|
|
35
37
|
var _a;
|
|
36
38
|
if (!layoutData) {
|
|
37
|
-
return {
|
|
38
|
-
pageEditing: false,
|
|
39
|
-
};
|
|
39
|
+
return { pageEditing: false };
|
|
40
40
|
}
|
|
41
41
|
return Object.assign({ route: layoutData.sitecore.route, itemId: (_a = layoutData.sitecore.route) === null || _a === void 0 ? void 0 : _a.itemId }, layoutData.sitecore.context);
|
|
42
42
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sitecore-content-sdk/react",
|
|
3
|
-
"version": "1.0.0-canary.
|
|
3
|
+
"version": "1.0.0-canary.7",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"url": "https://github.com/sitecore/content-sdk/issues"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@sitecore-feaas/clientside": "0.
|
|
33
|
+
"@sitecore-feaas/clientside": "^0.6.0",
|
|
34
34
|
"@testing-library/dom": "^10.4.0",
|
|
35
35
|
"@testing-library/react": "^16.3.0",
|
|
36
36
|
"@types/chai": "^5.2.2",
|
|
@@ -58,17 +58,17 @@
|
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"@sitecore-cloudsdk/events": "^0.5.1",
|
|
61
|
-
"@sitecore-feaas/clientside": "0.
|
|
61
|
+
"@sitecore-feaas/clientside": "^0.6.0",
|
|
62
62
|
"react": "^19.1.0",
|
|
63
63
|
"react-dom": "^19.1.0"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@sitecore-content-sdk/core": "1.0.0-canary.
|
|
66
|
+
"@sitecore-content-sdk/core": "1.0.0-canary.7",
|
|
67
67
|
"fast-deep-equal": "^3.1.3"
|
|
68
68
|
},
|
|
69
69
|
"description": "",
|
|
70
70
|
"types": "types/index.d.ts",
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "6a2feebb65713c2c210b934c7ab1b872db59c360",
|
|
72
72
|
"files": [
|
|
73
73
|
"dist",
|
|
74
74
|
"types"
|