@sitecore-jss/sitecore-jss-react 22.13.0-canary.6 → 23.0.0-canary.2

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.
@@ -40,7 +40,7 @@ const mockFormModule = (formModule) => {
40
40
  };
41
41
  exports.mockFormModule = mockFormModule;
42
42
  const Form = ({ params, rendering }) => {
43
- var _a;
43
+ var _a, _b, _c, _d, _e;
44
44
  const id = params === null || params === void 0 ? void 0 : params.RenderingIdentifier;
45
45
  const [error, setError] = (0, react_1.useState)(false);
46
46
  const [content, setContent] = (0, react_1.useState)('');
@@ -59,19 +59,22 @@ const Form = ({ params, rendering }) => {
59
59
  setError(true);
60
60
  });
61
61
  }
62
- else {
63
- // If we are in editing mode, we don't want to send any events
64
- if (!isEditing) {
65
- subscribeToFormSubmitEvent(formRef.current, rendering.uid);
66
- }
67
- executeScriptElements(formRef.current);
62
+ }, [content, params.FormId, (_b = (_a = context.api) === null || _a === void 0 ? void 0 : _a.edge) === null || _b === void 0 ? void 0 : _b.contextId, (_d = (_c = context.api) === null || _c === void 0 ? void 0 : _c.edge) === null || _d === void 0 ? void 0 : _d.edgeUrl, isEditing]);
63
+ (0, react_1.useEffect)(() => {
64
+ if (!content || !formRef.current)
65
+ return;
66
+ formRef.current.innerHTML = content;
67
+ executeScriptElements(formRef.current);
68
+ // If we are in editing mode, we don't want to send any events
69
+ if (!isEditing) {
70
+ subscribeToFormSubmitEvent(formRef.current, rendering.uid);
68
71
  }
69
- }, [content]);
72
+ }, [content, isEditing, rendering.uid]);
70
73
  if (isEditing) {
71
74
  if (error) {
72
75
  return (react_1.default.createElement("div", { className: "sc-jss-placeholder-error" }, "There was a problem loading this section"));
73
76
  }
74
77
  }
75
- 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 }));
78
+ return react_1.default.createElement("div", { ref: formRef, className: (_e = params.styles) === null || _e === void 0 ? void 0 : _e.trimEnd(), id: id ? id : undefined });
76
79
  };
77
80
  exports.Form = Form;
@@ -13,7 +13,7 @@ export const mockFormModule = (formModule) => {
13
13
  subscribeToFormSubmitEvent = formModule.subscribeToFormSubmitEvent;
14
14
  };
15
15
  export const Form = ({ params, rendering }) => {
16
- var _a;
16
+ var _a, _b, _c, _d, _e;
17
17
  const id = params === null || params === void 0 ? void 0 : params.RenderingIdentifier;
18
18
  const [error, setError] = useState(false);
19
19
  const [content, setContent] = useState('');
@@ -32,18 +32,21 @@ export const Form = ({ params, rendering }) => {
32
32
  setError(true);
33
33
  });
34
34
  }
35
- else {
36
- // If we are in editing mode, we don't want to send any events
37
- if (!isEditing) {
38
- subscribeToFormSubmitEvent(formRef.current, rendering.uid);
39
- }
40
- executeScriptElements(formRef.current);
35
+ }, [content, params.FormId, (_b = (_a = context.api) === null || _a === void 0 ? void 0 : _a.edge) === null || _b === void 0 ? void 0 : _b.contextId, (_d = (_c = context.api) === null || _c === void 0 ? void 0 : _c.edge) === null || _d === void 0 ? void 0 : _d.edgeUrl, isEditing]);
36
+ useEffect(() => {
37
+ if (!content || !formRef.current)
38
+ return;
39
+ formRef.current.innerHTML = content;
40
+ executeScriptElements(formRef.current);
41
+ // If we are in editing mode, we don't want to send any events
42
+ if (!isEditing) {
43
+ subscribeToFormSubmitEvent(formRef.current, rendering.uid);
41
44
  }
42
- }, [content]);
45
+ }, [content, isEditing, rendering.uid]);
43
46
  if (isEditing) {
44
47
  if (error) {
45
48
  return (React.createElement("div", { className: "sc-jss-placeholder-error" }, "There was a problem loading this section"));
46
49
  }
47
50
  }
48
- 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 }));
51
+ return React.createElement("div", { ref: formRef, className: (_e = params.styles) === null || _e === void 0 ? void 0 : _e.trimEnd(), id: id ? id : undefined });
49
52
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sitecore-jss/sitecore-jss-react",
3
- "version": "22.13.0-canary.6",
3
+ "version": "23.0.0-canary.2",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "sideEffects": false,
@@ -61,13 +61,13 @@
61
61
  "react-dom": "^19.1.0"
62
62
  },
63
63
  "dependencies": {
64
- "@sitecore-jss/sitecore-jss": "22.13.0-canary.6",
64
+ "@sitecore-jss/sitecore-jss": "23.0.0-canary.2",
65
65
  "fast-deep-equal": "^3.1.3",
66
66
  "style-attr": "^1.3.0"
67
67
  },
68
68
  "description": "",
69
69
  "types": "types/index.d.ts",
70
- "gitHead": "29a1e8fccff17a09cb3067228c59bc7d4eed32ae",
70
+ "gitHead": "885e9ceff27b4215bf41087b88069888e84e43a5",
71
71
  "files": [
72
72
  "dist",
73
73
  "types"