@sitecore-content-sdk/react 2.1.0-canary.11 → 2.1.0-canary.13
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.
|
@@ -71,6 +71,7 @@ const Form = ({ params, rendering }) => {
|
|
|
71
71
|
const context = (0, SitecoreProvider_1.useSitecore)();
|
|
72
72
|
const formRef = (0, react_1.useRef)(null);
|
|
73
73
|
const isEditing = context.page.mode.isEditing;
|
|
74
|
+
// fetch form content
|
|
74
75
|
(0, react_1.useEffect)(() => {
|
|
75
76
|
var _a, _b, _c, _d;
|
|
76
77
|
if (!content) {
|
|
@@ -90,26 +91,27 @@ const Form = ({ params, rendering }) => {
|
|
|
90
91
|
setError(true);
|
|
91
92
|
});
|
|
92
93
|
}
|
|
93
|
-
else {
|
|
94
|
-
if (!formRef.current)
|
|
95
|
-
return;
|
|
96
|
-
// If we are in editing mode, we don't want to send any events
|
|
97
|
-
if (!isEditing && !isBotClientSide()) {
|
|
98
|
-
subscribeToFormSubmitEvent(formRef.current, rendering.uid);
|
|
99
|
-
}
|
|
100
|
-
executeScriptElements(formRef.current);
|
|
101
|
-
}
|
|
102
94
|
}, [
|
|
103
95
|
content,
|
|
104
96
|
isEditing,
|
|
105
97
|
params.FormId,
|
|
106
|
-
rendering.uid,
|
|
107
98
|
(_b = (_a = context.api) === null || _a === void 0 ? void 0 : _a.edge) === null || _b === void 0 ? void 0 : _b.clientContextId,
|
|
108
99
|
(_d = (_c = context.api) === null || _c === void 0 ? void 0 : _c.edge) === null || _d === void 0 ? void 0 : _d.edgeUrl,
|
|
109
100
|
]);
|
|
101
|
+
// Set innerHTML and execute scripts whenever form content changes
|
|
102
|
+
(0, react_1.useEffect)(() => {
|
|
103
|
+
if (!content || !formRef.current)
|
|
104
|
+
return;
|
|
105
|
+
formRef.current.innerHTML = content;
|
|
106
|
+
executeScriptElements(formRef.current);
|
|
107
|
+
// If we are in editing mode, we don't want to send any events
|
|
108
|
+
if (!isEditing && !isBotClientSide()) {
|
|
109
|
+
subscribeToFormSubmitEvent(formRef.current, rendering.uid);
|
|
110
|
+
}
|
|
111
|
+
}, [content, isEditing, rendering.uid]);
|
|
110
112
|
if (isEditing && error) {
|
|
111
113
|
return react_1.default.createElement(ErrorBoundary_1.ErrorComponent, { message: "There was a problem loading this section" });
|
|
112
114
|
}
|
|
113
|
-
return
|
|
115
|
+
return react_1.default.createElement("div", { ref: formRef, className: (_e = params.styles) === null || _e === void 0 ? void 0 : _e.trimEnd(), id: id ? id : undefined });
|
|
114
116
|
};
|
|
115
117
|
exports.Form = Form;
|
|
@@ -33,6 +33,7 @@ export const Form = ({ params, rendering }) => {
|
|
|
33
33
|
const context = useSitecore();
|
|
34
34
|
const formRef = useRef(null);
|
|
35
35
|
const isEditing = context.page.mode.isEditing;
|
|
36
|
+
// fetch form content
|
|
36
37
|
useEffect(() => {
|
|
37
38
|
var _a, _b, _c, _d;
|
|
38
39
|
if (!content) {
|
|
@@ -52,25 +53,26 @@ export const Form = ({ params, rendering }) => {
|
|
|
52
53
|
setError(true);
|
|
53
54
|
});
|
|
54
55
|
}
|
|
55
|
-
else {
|
|
56
|
-
if (!formRef.current)
|
|
57
|
-
return;
|
|
58
|
-
// If we are in editing mode, we don't want to send any events
|
|
59
|
-
if (!isEditing && !isBotClientSide()) {
|
|
60
|
-
subscribeToFormSubmitEvent(formRef.current, rendering.uid);
|
|
61
|
-
}
|
|
62
|
-
executeScriptElements(formRef.current);
|
|
63
|
-
}
|
|
64
56
|
}, [
|
|
65
57
|
content,
|
|
66
58
|
isEditing,
|
|
67
59
|
params.FormId,
|
|
68
|
-
rendering.uid,
|
|
69
60
|
(_b = (_a = context.api) === null || _a === void 0 ? void 0 : _a.edge) === null || _b === void 0 ? void 0 : _b.clientContextId,
|
|
70
61
|
(_d = (_c = context.api) === null || _c === void 0 ? void 0 : _c.edge) === null || _d === void 0 ? void 0 : _d.edgeUrl,
|
|
71
62
|
]);
|
|
63
|
+
// Set innerHTML and execute scripts whenever form content changes
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
if (!content || !formRef.current)
|
|
66
|
+
return;
|
|
67
|
+
formRef.current.innerHTML = content;
|
|
68
|
+
executeScriptElements(formRef.current);
|
|
69
|
+
// If we are in editing mode, we don't want to send any events
|
|
70
|
+
if (!isEditing && !isBotClientSide()) {
|
|
71
|
+
subscribeToFormSubmitEvent(formRef.current, rendering.uid);
|
|
72
|
+
}
|
|
73
|
+
}, [content, isEditing, rendering.uid]);
|
|
72
74
|
if (isEditing && error) {
|
|
73
75
|
return React.createElement(ErrorComponent, { message: "There was a problem loading this section" });
|
|
74
76
|
}
|
|
75
|
-
return
|
|
77
|
+
return React.createElement("div", { ref: formRef, className: (_e = params.styles) === null || _e === void 0 ? void 0 : _e.trimEnd(), id: id ? id : undefined });
|
|
76
78
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sitecore-content-sdk/react",
|
|
3
|
-
"version": "2.1.0-canary.
|
|
3
|
+
"version": "2.1.0-canary.13",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"url": "https://github.com/sitecore/content-sdk/issues"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@sitecore-content-sdk/analytics-core": "2.1.0-canary.
|
|
35
|
+
"@sitecore-content-sdk/analytics-core": "2.1.0-canary.13",
|
|
36
36
|
"@sitecore-feaas/clientside": "^0.6.0",
|
|
37
37
|
"@stylistic/eslint-plugin": "^5.2.2",
|
|
38
38
|
"@testing-library/dom": "^10.4.0",
|
|
@@ -78,14 +78,14 @@
|
|
|
78
78
|
"react-dom": "^19.2.1"
|
|
79
79
|
},
|
|
80
80
|
"dependencies": {
|
|
81
|
-
"@sitecore-content-sdk/content": "2.1.0-canary.
|
|
82
|
-
"@sitecore-content-sdk/core": "2.1.0-canary.
|
|
83
|
-
"@sitecore-content-sdk/search": "0.2.2-canary.
|
|
81
|
+
"@sitecore-content-sdk/content": "2.1.0-canary.13",
|
|
82
|
+
"@sitecore-content-sdk/core": "2.1.0-canary.13",
|
|
83
|
+
"@sitecore-content-sdk/search": "0.2.2-canary.22",
|
|
84
84
|
"fast-deep-equal": "^3.1.3"
|
|
85
85
|
},
|
|
86
86
|
"description": "",
|
|
87
87
|
"types": "types/index.d.ts",
|
|
88
|
-
"gitHead": "
|
|
88
|
+
"gitHead": "3bb3656cf04e432ead4005db696643c4b409b7a3",
|
|
89
89
|
"files": [
|
|
90
90
|
"dist",
|
|
91
91
|
"types",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../src/components/Form.tsx"],"names":[],"mappings":"AACA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAY1E;;;GAGG;AACH,eAAO,MAAM,cAAc,GAAI,YAAY,GAAG,SAI7C,CAAC;AAEF,eAAO,MAAM,2BAA2B,GAAI,6BAA6B,GAAG,SAE3E,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB,SAAS,EAAE,kBAAkB,CAAC;IAC9B,MAAM,EAAE;QACN;;WAEG;QACH,MAAM,EAAE,MAAM,CAAC;QACf;;WAEG;QACH,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB;;WAEG;QACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;KAC9B,CAAC;CACH,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,IAAI,GAAI,uBAAuB,SAAS,
|
|
1
|
+
{"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../src/components/Form.tsx"],"names":[],"mappings":"AACA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAY1E;;;GAGG;AACH,eAAO,MAAM,cAAc,GAAI,YAAY,GAAG,SAI7C,CAAC;AAEF,eAAO,MAAM,2BAA2B,GAAI,6BAA6B,GAAG,SAE3E,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB,SAAS,EAAE,kBAAkB,CAAC;IAC9B,MAAM,EAAE;QACN;;WAEG;QACH,MAAM,EAAE,MAAM,CAAC;QACf;;WAEG;QACH,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB;;WAEG;QACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;KAC9B,CAAC;CACH,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,IAAI,GAAI,uBAAuB,SAAS,sBA0DpD,CAAC"}
|