@sitecore-jss/sitecore-jss-react 22.6.0-canary.30 → 22.6.0-canary.33
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.
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/* eslint-disable prefer-const */
|
|
2
3
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
4
|
if (k2 === undefined) k2 = k;
|
|
4
5
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -23,10 +24,21 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
24
|
return result;
|
|
24
25
|
};
|
|
25
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.Form = void 0;
|
|
27
|
+
exports.Form = exports.mockFormModule = void 0;
|
|
27
28
|
const react_1 = __importStar(require("react"));
|
|
28
|
-
const
|
|
29
|
+
const sitecore_jss_1 = require("@sitecore-jss/sitecore-jss");
|
|
29
30
|
const withSitecoreContext_1 = require("../enhancers/withSitecoreContext");
|
|
31
|
+
let { executeScriptElements, loadForm, subscribeToFormSubmitEvent } = sitecore_jss_1.form;
|
|
32
|
+
/**
|
|
33
|
+
* Mock function to replace the form module functions for `testing` purposes.
|
|
34
|
+
* @param {any} formModule - The form module to mock
|
|
35
|
+
*/
|
|
36
|
+
const mockFormModule = (formModule) => {
|
|
37
|
+
executeScriptElements = formModule.executeScriptElements;
|
|
38
|
+
loadForm = formModule.loadForm;
|
|
39
|
+
subscribeToFormSubmitEvent = formModule.subscribeToFormSubmitEvent;
|
|
40
|
+
};
|
|
41
|
+
exports.mockFormModule = mockFormModule;
|
|
30
42
|
const Form = ({ params, rendering }) => {
|
|
31
43
|
var _a;
|
|
32
44
|
const id = params === null || params === void 0 ? void 0 : params.RenderingIdentifier;
|
|
@@ -38,7 +50,7 @@ const Form = ({ params, rendering }) => {
|
|
|
38
50
|
(0, react_1.useEffect)(() => {
|
|
39
51
|
var _a, _b, _c, _d;
|
|
40
52
|
if (!content) {
|
|
41
|
-
|
|
53
|
+
loadForm((_b = (_a = context.api) === null || _a === void 0 ? void 0 : _a.edge) === null || _b === void 0 ? void 0 : _b.contextId, params.FormId, (_d = (_c = context.api) === null || _c === void 0 ? void 0 : _c.edge) === null || _d === void 0 ? void 0 : _d.edgeUrl)
|
|
42
54
|
.then(setContent)
|
|
43
55
|
.catch(() => {
|
|
44
56
|
if (isEditing) {
|
|
@@ -50,9 +62,9 @@ const Form = ({ params, rendering }) => {
|
|
|
50
62
|
else {
|
|
51
63
|
// If we are in editing mode, we don't want to send any events
|
|
52
64
|
if (!isEditing) {
|
|
53
|
-
|
|
65
|
+
subscribeToFormSubmitEvent(formRef.current, rendering.uid);
|
|
54
66
|
}
|
|
55
|
-
|
|
67
|
+
executeScriptElements(formRef.current);
|
|
56
68
|
}
|
|
57
69
|
}, [content]);
|
|
58
70
|
if (isEditing) {
|
|
@@ -1,6 +1,17 @@
|
|
|
1
|
+
/* eslint-disable prefer-const */
|
|
1
2
|
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
-
import {
|
|
3
|
+
import { form } from '@sitecore-jss/sitecore-jss';
|
|
3
4
|
import { useSitecoreContext } from '../enhancers/withSitecoreContext';
|
|
5
|
+
let { executeScriptElements, loadForm, subscribeToFormSubmitEvent } = form;
|
|
6
|
+
/**
|
|
7
|
+
* Mock function to replace the form module functions for `testing` purposes.
|
|
8
|
+
* @param {any} formModule - The form module to mock
|
|
9
|
+
*/
|
|
10
|
+
export const mockFormModule = (formModule) => {
|
|
11
|
+
executeScriptElements = formModule.executeScriptElements;
|
|
12
|
+
loadForm = formModule.loadForm;
|
|
13
|
+
subscribeToFormSubmitEvent = formModule.subscribeToFormSubmitEvent;
|
|
14
|
+
};
|
|
4
15
|
export const Form = ({ params, rendering }) => {
|
|
5
16
|
var _a;
|
|
6
17
|
const id = params === null || params === void 0 ? void 0 : params.RenderingIdentifier;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sitecore-jss/sitecore-jss-react",
|
|
3
|
-
"version": "22.6.0-canary.
|
|
3
|
+
"version": "22.6.0-canary.33",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -33,7 +33,6 @@
|
|
|
33
33
|
"@types/mocha": "^10.0.1",
|
|
34
34
|
"@types/node": "20.14.2",
|
|
35
35
|
"@types/prop-types": "^15.7.5",
|
|
36
|
-
"@types/proxyquire": "^1.3.31",
|
|
37
36
|
"@types/react": "^18.2.45",
|
|
38
37
|
"@types/react-dom": "^18.0.10",
|
|
39
38
|
"@types/sinon": "^10.0.13",
|
|
@@ -49,7 +48,6 @@
|
|
|
49
48
|
"jsdom": "^25.0.1",
|
|
50
49
|
"mocha": "^10.2.0",
|
|
51
50
|
"nyc": "^15.1.0",
|
|
52
|
-
"proxyquire": "^2.1.3",
|
|
53
51
|
"react": "^18.2.0",
|
|
54
52
|
"react-dom": "^18.2.0",
|
|
55
53
|
"sinon": "^15.0.0",
|
|
@@ -64,14 +62,14 @@
|
|
|
64
62
|
"react-dom": "^18.2.0"
|
|
65
63
|
},
|
|
66
64
|
"dependencies": {
|
|
67
|
-
"@sitecore-jss/sitecore-jss": "22.6.0-canary.
|
|
65
|
+
"@sitecore-jss/sitecore-jss": "22.6.0-canary.33",
|
|
68
66
|
"fast-deep-equal": "^3.1.3",
|
|
69
67
|
"prop-types": "^15.8.1",
|
|
70
68
|
"style-attr": "^1.3.0"
|
|
71
69
|
},
|
|
72
70
|
"description": "",
|
|
73
71
|
"types": "types/index.d.ts",
|
|
74
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "cabd4087d274145306befdb29f56fbdebc1f6aa5",
|
|
75
73
|
"files": [
|
|
76
74
|
"dist",
|
|
77
75
|
"types"
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
/// <reference types="@types/react" />
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { ComponentRendering } from '@sitecore-jss/sitecore-jss/layout';
|
|
4
|
+
/**
|
|
5
|
+
* Mock function to replace the form module functions for `testing` purposes.
|
|
6
|
+
* @param {any} formModule - The form module to mock
|
|
7
|
+
*/
|
|
8
|
+
export declare const mockFormModule: (formModule: any) => void;
|
|
4
9
|
/**
|
|
5
10
|
* Shape of the Form component rendering data.
|
|
6
11
|
* FormId is the rendering parameter that specifies the ID of the Sitecore Form to render.
|