@sitecore-jss/sitecore-jss-react 22.6.0-canary.9 → 22.7.0-canary.1
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/Form.js +77 -0
- package/dist/cjs/components/PlaceholderCommon.js +5 -1
- package/dist/cjs/components/SitecoreContext.js +7 -0
- package/dist/cjs/enhancers/withSitecoreContext.js +2 -1
- package/dist/cjs/index.js +4 -2
- package/dist/esm/components/Form.js +49 -0
- package/dist/esm/components/PlaceholderCommon.js +5 -1
- package/dist/esm/components/SitecoreContext.js +7 -0
- package/dist/esm/enhancers/withSitecoreContext.js +3 -2
- package/dist/esm/index.js +1 -0
- package/package.json +4 -3
- package/types/components/Form.d.ts +30 -0
- package/types/components/PlaceholderCommon.d.ts +1 -1
- package/types/components/SitecoreContext.d.ts +20 -0
- package/types/enhancers/withSitecoreContext.d.ts +3 -5
- package/types/index.d.ts +1 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable prefer-const */
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
+
if (mod && mod.__esModule) return mod;
|
|
21
|
+
var result = {};
|
|
22
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
+
__setModuleDefault(result, mod);
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.Form = exports.mockFormModule = void 0;
|
|
28
|
+
const react_1 = __importStar(require("react"));
|
|
29
|
+
const sitecore_jss_1 = require("@sitecore-jss/sitecore-jss");
|
|
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;
|
|
42
|
+
const Form = ({ params, rendering }) => {
|
|
43
|
+
var _a;
|
|
44
|
+
const id = params === null || params === void 0 ? void 0 : params.RenderingIdentifier;
|
|
45
|
+
const [error, setError] = (0, react_1.useState)(false);
|
|
46
|
+
const [content, setContent] = (0, react_1.useState)('');
|
|
47
|
+
const context = (0, withSitecoreContext_1.useSitecoreContext)();
|
|
48
|
+
const formRef = (0, react_1.useRef)(null);
|
|
49
|
+
const isEditing = context.sitecoreContext.pageEditing;
|
|
50
|
+
(0, react_1.useEffect)(() => {
|
|
51
|
+
var _a, _b, _c, _d;
|
|
52
|
+
if (!content) {
|
|
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)
|
|
54
|
+
.then(setContent)
|
|
55
|
+
.catch(() => {
|
|
56
|
+
if (isEditing) {
|
|
57
|
+
console.error(`Failed to load form with id ${params.FormId}. Check debug logs for sitecore-jss:form for more details.`);
|
|
58
|
+
}
|
|
59
|
+
setError(true);
|
|
60
|
+
});
|
|
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);
|
|
68
|
+
}
|
|
69
|
+
}, [content]);
|
|
70
|
+
if (isEditing) {
|
|
71
|
+
if (error) {
|
|
72
|
+
return (react_1.default.createElement("div", { className: "sc-jss-placeholder-error" }, "There was a problem loading this section"));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
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 }));
|
|
76
|
+
};
|
|
77
|
+
exports.Form = Form;
|
|
@@ -147,9 +147,13 @@ class PlaceholderCommon extends react_1.default.Component {
|
|
|
147
147
|
if (!isEmpty) {
|
|
148
148
|
// assign type based on passed element - type='text/sitecore' should be ignored when renderEach Placeholder prop function is being used
|
|
149
149
|
const type = rendered.props.type === 'text/sitecore' ? rendered.props.type : '';
|
|
150
|
+
// the registered BYOC components are imported using dynamic(), so we need to account for that when passing the isDynamic prop to ErrorBoundary
|
|
151
|
+
const isByocWrapper = componentRendering.componentName === BYOCWrapper_1.BYOC_WRAPPER_RENDERING_NAME;
|
|
152
|
+
// all dynamic elements will have a separate render prop
|
|
153
|
+
const isDynamicComponent = !!((_a = component.render) === null || _a === void 0 ? void 0 : _a.preload);
|
|
150
154
|
// wrapping with error boundary could cause problems in case where parent component uses withPlaceholder HOC and tries to access its children props
|
|
151
155
|
// that's why we need to expose element's props here
|
|
152
|
-
rendered = (react_1.default.createElement(ErrorBoundary_1.default, Object.assign({ key: rendered.type + '-' + index, errorComponent: this.props.errorComponent, componentLoadingMessage: this.props.componentLoadingMessage, type: type, isDynamic:
|
|
156
|
+
rendered = (react_1.default.createElement(ErrorBoundary_1.default, Object.assign({ key: rendered.type + '-' + index, errorComponent: this.props.errorComponent, componentLoadingMessage: this.props.componentLoadingMessage, type: type, isDynamic: isDynamicComponent || isByocWrapper }, rendered.props), rendered));
|
|
153
157
|
}
|
|
154
158
|
// if editMode is equal to 'metadata' then emit shallow chromes for hydration in Pages
|
|
155
159
|
if (((_b = this.props.sitecoreContext) === null || _b === void 0 ? void 0 : _b.editMode) === layout_1.EditMode.Metadata) {
|
|
@@ -8,10 +8,12 @@ exports.SitecoreContext = exports.ComponentFactoryReactContext = exports.Sitecor
|
|
|
8
8
|
const react_1 = __importDefault(require("react"));
|
|
9
9
|
const prop_types_1 = __importDefault(require("prop-types"));
|
|
10
10
|
const react_2 = __importDefault(require("fast-deep-equal/es6/react"));
|
|
11
|
+
const sitecore_jss_1 = require("@sitecore-jss/sitecore-jss");
|
|
11
12
|
exports.SitecoreContextReactContext = react_1.default.createContext({});
|
|
12
13
|
exports.ComponentFactoryReactContext = react_1.default.createContext({});
|
|
13
14
|
class SitecoreContext extends react_1.default.Component {
|
|
14
15
|
constructor(props) {
|
|
16
|
+
var _a, _b, _c, _d;
|
|
15
17
|
super(props);
|
|
16
18
|
/**
|
|
17
19
|
* Update context state. Value can be @type {LayoutServiceData} which will be automatically transformed
|
|
@@ -26,9 +28,14 @@ class SitecoreContext extends react_1.default.Component {
|
|
|
26
28
|
});
|
|
27
29
|
};
|
|
28
30
|
const context = this.constructContext(props.layoutData);
|
|
31
|
+
let api = props.api;
|
|
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.edgeUrl)) {
|
|
33
|
+
api = Object.assign(Object.assign({}, props.api), { edge: Object.assign(Object.assign({}, props.api.edge), { edgeUrl: sitecore_jss_1.constants.SITECORE_EDGE_URL_DEFAULT }) });
|
|
34
|
+
}
|
|
29
35
|
this.state = {
|
|
30
36
|
context,
|
|
31
37
|
setContext: this.setContext,
|
|
38
|
+
api,
|
|
32
39
|
};
|
|
33
40
|
}
|
|
34
41
|
constructContext(layoutData) {
|
|
@@ -12,7 +12,7 @@ const SitecoreContext_1 = require("../components/SitecoreContext");
|
|
|
12
12
|
function withSitecoreContext(options) {
|
|
13
13
|
return function withSitecoreContextHoc(Component) {
|
|
14
14
|
return function WithSitecoreContext(props) {
|
|
15
|
-
return (react_1.default.createElement(SitecoreContext_1.SitecoreContextReactContext.Consumer, null, (context) => (react_1.default.createElement(Component, Object.assign({}, props, { sitecoreContext: context.context, updateSitecoreContext: options && options.updatable && context.setContext })))));
|
|
15
|
+
return (react_1.default.createElement(SitecoreContext_1.SitecoreContextReactContext.Consumer, null, (context) => (react_1.default.createElement(Component, Object.assign({}, props, { sitecoreContext: context.context, api: context.api, updateSitecoreContext: options && options.updatable && context.setContext })))));
|
|
16
16
|
};
|
|
17
17
|
};
|
|
18
18
|
}
|
|
@@ -42,6 +42,7 @@ function useSitecoreContext(options) {
|
|
|
42
42
|
const reactContext = react_1.default.useContext(SitecoreContext_1.SitecoreContextReactContext);
|
|
43
43
|
const updatable = options === null || options === void 0 ? void 0 : options.updatable;
|
|
44
44
|
return {
|
|
45
|
+
api: reactContext.api,
|
|
45
46
|
sitecoreContext: reactContext.context,
|
|
46
47
|
updateSitecoreContext: updatable ? reactContext.setContext : undefined,
|
|
47
48
|
};
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.DefaultEmptyFieldEditingComponentImage = exports.DefaultEmptyFieldEditingComponentText = exports.EditingScripts = exports.withEmptyFieldEditingComponent = void 0;
|
|
3
|
+
exports.ComponentBuilder = exports.EditFrame = exports.withDatasourceCheck = exports.withPlaceholder = exports.withEditorChromes = exports.useSitecoreContext = exports.withSitecoreContext = exports.SitecoreContextReactContext = exports.SitecoreContext = exports.VisitorIdentification = exports.File = exports.LinkPropTypes = exports.Link = exports.BYOCWrapper = exports.fetchBYOCComponentServerProps = exports.BYOCComponent = exports.FEaaSWrapper = exports.fetchFEaaSComponentServerProps = exports.FEaaSComponent = exports.DateField = exports.Text = exports.RichTextPropTypes = exports.RichText = exports.getEEMarkup = exports.Image = exports.Form = exports.Placeholder = exports.mediaApi = exports.GraphQLRequestClient = exports.DefaultRetryStrategy = exports.RestDictionaryService = exports.GraphQLDictionaryService = exports.trackingApi = exports.EditMode = exports.getFieldValue = exports.getChildPlaceholder = exports.RestLayoutService = exports.GraphQLLayoutService = exports.LayoutServicePageState = exports.getComponentLibraryStylesheetLinks = exports.getContentStylesheetLink = exports.DefaultEditFrameButtons = exports.DefaultEditFrameButton = exports.resetEditorChromes = exports.isEditorActive = exports.NativeDataFetcher = exports.MemoryCacheClient = exports.ClientError = exports.enableDebug = exports.constants = void 0;
|
|
4
|
+
exports.DefaultEmptyFieldEditingComponentImage = exports.DefaultEmptyFieldEditingComponentText = exports.EditingScripts = exports.withEmptyFieldEditingComponent = exports.withFieldMetadata = void 0;
|
|
5
5
|
var sitecore_jss_1 = require("@sitecore-jss/sitecore-jss");
|
|
6
6
|
Object.defineProperty(exports, "constants", { enumerable: true, get: function () { return sitecore_jss_1.constants; } });
|
|
7
7
|
Object.defineProperty(exports, "enableDebug", { enumerable: true, get: function () { return sitecore_jss_1.enableDebug; } });
|
|
@@ -34,6 +34,8 @@ var media_1 = require("@sitecore-jss/sitecore-jss/media");
|
|
|
34
34
|
Object.defineProperty(exports, "mediaApi", { enumerable: true, get: function () { return media_1.mediaApi; } });
|
|
35
35
|
var Placeholder_1 = require("./components/Placeholder");
|
|
36
36
|
Object.defineProperty(exports, "Placeholder", { enumerable: true, get: function () { return Placeholder_1.Placeholder; } });
|
|
37
|
+
var Form_1 = require("./components/Form");
|
|
38
|
+
Object.defineProperty(exports, "Form", { enumerable: true, get: function () { return Form_1.Form; } });
|
|
37
39
|
var Image_1 = require("./components/Image");
|
|
38
40
|
Object.defineProperty(exports, "Image", { enumerable: true, get: function () { return Image_1.Image; } });
|
|
39
41
|
Object.defineProperty(exports, "getEEMarkup", { enumerable: true, get: function () { return Image_1.getEEMarkup; } });
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/* eslint-disable prefer-const */
|
|
2
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { form } from '@sitecore-jss/sitecore-jss';
|
|
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
|
+
};
|
|
15
|
+
export const Form = ({ params, rendering }) => {
|
|
16
|
+
var _a;
|
|
17
|
+
const id = params === null || params === void 0 ? void 0 : params.RenderingIdentifier;
|
|
18
|
+
const [error, setError] = useState(false);
|
|
19
|
+
const [content, setContent] = useState('');
|
|
20
|
+
const context = useSitecoreContext();
|
|
21
|
+
const formRef = useRef(null);
|
|
22
|
+
const isEditing = context.sitecoreContext.pageEditing;
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
var _a, _b, _c, _d;
|
|
25
|
+
if (!content) {
|
|
26
|
+
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)
|
|
27
|
+
.then(setContent)
|
|
28
|
+
.catch(() => {
|
|
29
|
+
if (isEditing) {
|
|
30
|
+
console.error(`Failed to load form with id ${params.FormId}. Check debug logs for sitecore-jss:form for more details.`);
|
|
31
|
+
}
|
|
32
|
+
setError(true);
|
|
33
|
+
});
|
|
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);
|
|
41
|
+
}
|
|
42
|
+
}, [content]);
|
|
43
|
+
if (isEditing) {
|
|
44
|
+
if (error) {
|
|
45
|
+
return (React.createElement("div", { className: "sc-jss-placeholder-error" }, "There was a problem loading this section"));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
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 }));
|
|
49
|
+
};
|
|
@@ -141,9 +141,13 @@ export class PlaceholderCommon extends React.Component {
|
|
|
141
141
|
if (!isEmpty) {
|
|
142
142
|
// assign type based on passed element - type='text/sitecore' should be ignored when renderEach Placeholder prop function is being used
|
|
143
143
|
const type = rendered.props.type === 'text/sitecore' ? rendered.props.type : '';
|
|
144
|
+
// the registered BYOC components are imported using dynamic(), so we need to account for that when passing the isDynamic prop to ErrorBoundary
|
|
145
|
+
const isByocWrapper = componentRendering.componentName === BYOC_WRAPPER_RENDERING_NAME;
|
|
146
|
+
// all dynamic elements will have a separate render prop
|
|
147
|
+
const isDynamicComponent = !!((_a = component.render) === null || _a === void 0 ? void 0 : _a.preload);
|
|
144
148
|
// wrapping with error boundary could cause problems in case where parent component uses withPlaceholder HOC and tries to access its children props
|
|
145
149
|
// that's why we need to expose element's props here
|
|
146
|
-
rendered = (React.createElement(ErrorBoundary, Object.assign({ key: rendered.type + '-' + index, errorComponent: this.props.errorComponent, componentLoadingMessage: this.props.componentLoadingMessage, type: type, isDynamic:
|
|
150
|
+
rendered = (React.createElement(ErrorBoundary, Object.assign({ key: rendered.type + '-' + index, errorComponent: this.props.errorComponent, componentLoadingMessage: this.props.componentLoadingMessage, type: type, isDynamic: isDynamicComponent || isByocWrapper }, rendered.props), rendered));
|
|
147
151
|
}
|
|
148
152
|
// if editMode is equal to 'metadata' then emit shallow chromes for hydration in Pages
|
|
149
153
|
if (((_b = this.props.sitecoreContext) === null || _b === void 0 ? void 0 : _b.editMode) === EditMode.Metadata) {
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import fastDeepEqual from 'fast-deep-equal/es6/react';
|
|
5
|
+
import { constants } from '@sitecore-jss/sitecore-jss';
|
|
5
6
|
export const SitecoreContextReactContext = React.createContext({});
|
|
6
7
|
export const ComponentFactoryReactContext = React.createContext({});
|
|
7
8
|
export class SitecoreContext extends React.Component {
|
|
8
9
|
constructor(props) {
|
|
10
|
+
var _a, _b, _c, _d;
|
|
9
11
|
super(props);
|
|
10
12
|
/**
|
|
11
13
|
* Update context state. Value can be @type {LayoutServiceData} which will be automatically transformed
|
|
@@ -20,9 +22,14 @@ export class SitecoreContext extends React.Component {
|
|
|
20
22
|
});
|
|
21
23
|
};
|
|
22
24
|
const context = this.constructContext(props.layoutData);
|
|
25
|
+
let api = props.api;
|
|
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.edgeUrl)) {
|
|
27
|
+
api = Object.assign(Object.assign({}, props.api), { edge: Object.assign(Object.assign({}, props.api.edge), { edgeUrl: constants.SITECORE_EDGE_URL_DEFAULT }) });
|
|
28
|
+
}
|
|
23
29
|
this.state = {
|
|
24
30
|
context,
|
|
25
31
|
setContext: this.setContext,
|
|
32
|
+
api,
|
|
26
33
|
};
|
|
27
34
|
}
|
|
28
35
|
constructContext(layoutData) {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { SitecoreContextReactContext } from '../components/SitecoreContext';
|
|
2
|
+
import { SitecoreContextReactContext, } from '../components/SitecoreContext';
|
|
3
3
|
/**
|
|
4
4
|
* @param {WithSitecoreContextOptions} [options]
|
|
5
5
|
*/
|
|
6
6
|
export function withSitecoreContext(options) {
|
|
7
7
|
return function withSitecoreContextHoc(Component) {
|
|
8
8
|
return function WithSitecoreContext(props) {
|
|
9
|
-
return (React.createElement(SitecoreContextReactContext.Consumer, null, (context) => (React.createElement(Component, Object.assign({}, props, { sitecoreContext: context.context, updateSitecoreContext: options && options.updatable && context.setContext })))));
|
|
9
|
+
return (React.createElement(SitecoreContextReactContext.Consumer, null, (context) => (React.createElement(Component, Object.assign({}, props, { sitecoreContext: context.context, api: context.api, updateSitecoreContext: options && options.updatable && context.setContext })))));
|
|
10
10
|
};
|
|
11
11
|
};
|
|
12
12
|
}
|
|
@@ -35,6 +35,7 @@ export function useSitecoreContext(options) {
|
|
|
35
35
|
const reactContext = React.useContext(SitecoreContextReactContext);
|
|
36
36
|
const updatable = options === null || options === void 0 ? void 0 : options.updatable;
|
|
37
37
|
return {
|
|
38
|
+
api: reactContext.api,
|
|
38
39
|
sitecoreContext: reactContext.context,
|
|
39
40
|
updateSitecoreContext: updatable ? reactContext.setContext : undefined,
|
|
40
41
|
};
|
package/dist/esm/index.js
CHANGED
|
@@ -6,6 +6,7 @@ export { GraphQLDictionaryService, RestDictionaryService, } from '@sitecore-jss/
|
|
|
6
6
|
export { DefaultRetryStrategy, GraphQLRequestClient, } from '@sitecore-jss/sitecore-jss/graphql';
|
|
7
7
|
export { mediaApi } from '@sitecore-jss/sitecore-jss/media';
|
|
8
8
|
export { Placeholder } from './components/Placeholder';
|
|
9
|
+
export { Form } from './components/Form';
|
|
9
10
|
export { Image, getEEMarkup, } from './components/Image';
|
|
10
11
|
export { RichText, RichTextPropTypes } from './components/RichText';
|
|
11
12
|
export { Text } from './components/Text';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sitecore-jss/sitecore-jss-react",
|
|
3
|
-
"version": "22.
|
|
3
|
+
"version": "22.7.0-canary.1",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -56,19 +56,20 @@
|
|
|
56
56
|
"typescript": "~4.9.3"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
|
+
"@sitecore-cloudsdk/events": "^0.5.0",
|
|
59
60
|
"@sitecore-feaas/clientside": "^0.5.19",
|
|
60
61
|
"react": "^18.2.0",
|
|
61
62
|
"react-dom": "^18.2.0"
|
|
62
63
|
},
|
|
63
64
|
"dependencies": {
|
|
64
|
-
"@sitecore-jss/sitecore-jss": "
|
|
65
|
+
"@sitecore-jss/sitecore-jss": "22.7.0-canary.1",
|
|
65
66
|
"fast-deep-equal": "^3.1.3",
|
|
66
67
|
"prop-types": "^15.8.1",
|
|
67
68
|
"style-attr": "^1.3.0"
|
|
68
69
|
},
|
|
69
70
|
"description": "",
|
|
70
71
|
"types": "types/index.d.ts",
|
|
71
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "31b27434eca1cdfcc402ad567b7ecff70670f675",
|
|
72
73
|
"files": [
|
|
73
74
|
"dist",
|
|
74
75
|
"types"
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/// <reference types="@types/react" />
|
|
2
|
+
import React from 'react';
|
|
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;
|
|
9
|
+
/**
|
|
10
|
+
* Shape of the Form component rendering data.
|
|
11
|
+
* FormId is the rendering parameter that specifies the ID of the Sitecore Form to render.
|
|
12
|
+
*/
|
|
13
|
+
export type FormProps = {
|
|
14
|
+
rendering: ComponentRendering;
|
|
15
|
+
params: {
|
|
16
|
+
/**
|
|
17
|
+
* The ID of the Sitecore Form to render.
|
|
18
|
+
*/
|
|
19
|
+
FormId: string;
|
|
20
|
+
/**
|
|
21
|
+
* The CSS class to apply to the form.
|
|
22
|
+
*/
|
|
23
|
+
styles?: string;
|
|
24
|
+
/**
|
|
25
|
+
* The unique identifier of the rendering.
|
|
26
|
+
*/
|
|
27
|
+
RenderingIdentifier?: string;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export declare const Form: ({ params, rendering }: FormProps) => React.JSX.Element;
|
|
@@ -28,7 +28,7 @@ export interface PlaceholderProps {
|
|
|
28
28
|
* Any component or placeholder rendered by a placeholder will have access to this data via `props.fields`.
|
|
29
29
|
*/
|
|
30
30
|
fields?: {
|
|
31
|
-
[name: string]: Field | Item[];
|
|
31
|
+
[name: string]: Field | Item | Item[];
|
|
32
32
|
};
|
|
33
33
|
/**
|
|
34
34
|
* An object of rendering parameter names/values that are aggregated and propagated through the component tree created by a placeholder.
|
|
@@ -6,11 +6,31 @@ import { LayoutServiceContext, LayoutServiceData, RouteData } from '../index';
|
|
|
6
6
|
export interface SitecoreContextProps {
|
|
7
7
|
componentFactory: ComponentFactory;
|
|
8
8
|
layoutData?: LayoutServiceData;
|
|
9
|
+
/**
|
|
10
|
+
* API settings to connect to Sitecore.
|
|
11
|
+
*/
|
|
12
|
+
api?: {
|
|
13
|
+
/**
|
|
14
|
+
* Sitecore XM Cloud Edge endpoint credentials for Sitecore connection.
|
|
15
|
+
*/
|
|
16
|
+
edge?: {
|
|
17
|
+
/**
|
|
18
|
+
* A unified identifier used to connect and retrieve data from XM Cloud instance
|
|
19
|
+
*/
|
|
20
|
+
contextId: string;
|
|
21
|
+
/**
|
|
22
|
+
* XM Cloud endpoint that the app will communicate and retrieve data from
|
|
23
|
+
* @default https://edge-platform.sitecorecloud.io
|
|
24
|
+
*/
|
|
25
|
+
edgeUrl?: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
9
28
|
children: React.ReactNode;
|
|
10
29
|
}
|
|
11
30
|
export interface SitecoreContextState {
|
|
12
31
|
setContext: (value: SitecoreContextValue | LayoutServiceData) => void;
|
|
13
32
|
context: SitecoreContextValue;
|
|
33
|
+
api?: SitecoreContextProps['api'];
|
|
14
34
|
}
|
|
15
35
|
export declare const SitecoreContextReactContext: React.Context<SitecoreContextState>;
|
|
16
36
|
export declare const ComponentFactoryReactContext: React.Context<ComponentFactory>;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/// <reference types="@types/react" />
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { EnhancedOmit } from '@sitecore-jss/sitecore-jss/utils';
|
|
4
|
-
import { SitecoreContextValue } from '../components/SitecoreContext';
|
|
4
|
+
import { SitecoreContextState, SitecoreContextValue } from '../components/SitecoreContext';
|
|
5
5
|
export interface WithSitecoreContextOptions {
|
|
6
6
|
updatable?: boolean;
|
|
7
7
|
}
|
|
8
8
|
export interface WithSitecoreContextProps {
|
|
9
9
|
sitecoreContext: SitecoreContextValue;
|
|
10
|
+
api?: SitecoreContextState['api'];
|
|
10
11
|
updateSitecoreContext?: ((value: SitecoreContextValue) => void) | false;
|
|
11
12
|
}
|
|
12
13
|
export type WithSitecoreContextHocProps<ComponentProps> = EnhancedOmit<ComponentProps, keyof WithSitecoreContextProps>;
|
|
@@ -35,7 +36,4 @@ export declare function withSitecoreContext(options?: WithSitecoreContextOptions
|
|
|
35
36
|
* }
|
|
36
37
|
* @returns {object} { sitecoreContext, updateSitecoreContext }
|
|
37
38
|
*/
|
|
38
|
-
export declare function useSitecoreContext(options?: WithSitecoreContextOptions):
|
|
39
|
-
sitecoreContext: SitecoreContextValue;
|
|
40
|
-
updateSitecoreContext: (value: import("@sitecore-jss/sitecore-jss/layout").LayoutServiceData | SitecoreContextValue) => void;
|
|
41
|
-
};
|
|
39
|
+
export declare function useSitecoreContext(options?: WithSitecoreContextOptions): WithSitecoreContextProps;
|
package/types/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export { GraphQLClientError, RetryStrategy, DefaultRetryStrategy, GraphQLRequest
|
|
|
8
8
|
export { mediaApi } from '@sitecore-jss/sitecore-jss/media';
|
|
9
9
|
export { ComponentFactory, JssComponentType } from './components/sharedTypes';
|
|
10
10
|
export { Placeholder, PlaceholderComponentProps } from './components/Placeholder';
|
|
11
|
+
export { Form } from './components/Form';
|
|
11
12
|
export { Image, ImageProps, ImageField, getEEMarkup, ImageFieldValue, ImageSizeParameters, } from './components/Image';
|
|
12
13
|
export { RichText, RichTextProps, RichTextPropTypes, RichTextField } from './components/RichText';
|
|
13
14
|
export { Text, TextField } from './components/Text';
|