@sitecore-content-sdk/react 0.3.0-canary.3 → 0.3.0-canary.31

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.
Files changed (31) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/components/EditingScripts.js +6 -7
  3. package/dist/cjs/components/ErrorBoundary.js +4 -4
  4. package/dist/cjs/components/FEaaSComponent.js +2 -2
  5. package/dist/cjs/components/Form.js +2 -2
  6. package/dist/cjs/components/HiddenRendering.js +8 -3
  7. package/dist/cjs/components/Image.js +1 -1
  8. package/dist/cjs/components/MissingComponent.js +1 -1
  9. package/dist/cjs/components/Placeholder.js +1 -1
  10. package/dist/cjs/components/PlaceholderCommon.js +8 -3
  11. package/dist/cjs/enhancers/withPlaceholder.js +1 -1
  12. package/dist/cjs/enhancers/withSitecore.js +1 -1
  13. package/dist/esm/components/EditingScripts.js +7 -8
  14. package/dist/esm/components/ErrorBoundary.js +4 -4
  15. package/dist/esm/components/FEaaSComponent.js +2 -2
  16. package/dist/esm/components/Form.js +2 -2
  17. package/dist/esm/components/HiddenRendering.js +8 -3
  18. package/dist/esm/components/Image.js +1 -1
  19. package/dist/esm/components/MissingComponent.js +1 -1
  20. package/dist/esm/components/Placeholder.js +1 -1
  21. package/dist/esm/components/PlaceholderCommon.js +8 -3
  22. package/dist/esm/enhancers/withPlaceholder.js +1 -1
  23. package/dist/esm/enhancers/withSitecore.js +1 -1
  24. package/package.json +5 -5
  25. package/types/components/EditingScripts.d.ts +1 -12
  26. package/types/components/ErrorBoundary.d.ts +1 -0
  27. package/types/components/PlaceholderCommon.d.ts +5 -0
  28. package/types/components/sharedTypes/components.d.ts +2 -2
  29. package/types/enhancers/withPlaceholder.d.ts +1 -1
  30. package/types/enhancers/withSitecore.d.ts +1 -1
  31. package/types/index.d.ts +1 -1
package/README.md CHANGED
@@ -6,6 +6,6 @@ This module is provided as a part of Sitecore Content SDK. It contains React com
6
6
  @TODO: Update link with appropriate page when avaiable
7
7
  -->
8
8
 
9
- [Documentation](https://doc.sitecore.com/xmc/en/developers/xm-cloud/sitecore-javascript-rendering-sdk--jss--for-next-js.html)
9
+ [Documentation](https://doc.sitecore.com/xmc/en/developers/content-sdk/creating-a-content-sdk-app.html)
10
10
 
11
11
  [API reference documentation](/ref-docs/react/)
@@ -12,12 +12,11 @@ const editing_2 = require("@sitecore-content-sdk/core/editing");
12
12
  /**
13
13
  * Renders client scripts and data for editing/preview mode for Pages.
14
14
  * Renders script required for the Design Library (when RenderingType is `component`).
15
- * @param {EditingScriptsProps} props - The props for the EditingScripts component.
16
- * @param {string} props.sitecoreEdgeUrl - Sitecore Edge Platform URL.
17
15
  * @returns A JSX element containing the editing scripts or an empty fragment if not in editing/preview mode.
18
16
  */
19
- const EditingScripts = (props) => {
20
- const { pageContext: { pageState, clientData, clientScripts, renderingType }, } = (0, withSitecore_1.useSitecore)();
17
+ const EditingScripts = () => {
18
+ var _a;
19
+ const { pageContext: { pageState, clientData, clientScripts, renderingType }, api, } = (0, withSitecore_1.useSitecore)();
21
20
  // Don't render anything if not in editing/preview mode and rendering type is not component
22
21
  if (renderingType !== layout_1.RenderingType.Component &&
23
22
  (pageState === layout_1.LayoutServicePageState.Normal ||
@@ -28,13 +27,13 @@ const EditingScripts = (props) => {
28
27
  // In case of RenderingType.Component - render only the script for Design Libnrary
29
28
  if (renderingType === layout_1.RenderingType.Component) {
30
29
  // Add cache buster to the script URL
31
- const scriptUrl = `${(0, editing_2.getDesignLibraryScriptLink)(props.sitecoreEdgeUrl)}?cb=${Date.now()}`;
30
+ const scriptUrl = `${(0, editing_2.getDesignLibraryScriptLink)((_a = api === null || api === void 0 ? void 0 : api.edge) === null || _a === void 0 ? void 0 : _a.edgeUrl)}?cb=${Date.now()}`;
32
31
  return (react_1.default.createElement(react_1.default.Fragment, null,
33
32
  react_1.default.createElement("script", { src: scriptUrl, suppressHydrationWarning: true })));
34
33
  }
35
- const jssClientData = Object.assign(Object.assign({}, clientData), (0, editing_1.getJssPagesClientData)());
34
+ const contentSdkClientData = Object.assign(Object.assign({}, clientData), (0, editing_1.getContentSdkPagesClientData)());
36
35
  return (react_1.default.createElement(react_1.default.Fragment, null, clientScripts === null || clientScripts === void 0 ? void 0 :
37
36
  clientScripts.map((src, index) => (react_1.default.createElement("script", { src: src, key: index }))),
38
- Object.keys(jssClientData).map((id) => (react_1.default.createElement("script", { key: id, id: id, type: "application/json", dangerouslySetInnerHTML: { __html: JSON.stringify(jssClientData[id]) } })))));
37
+ Object.keys(contentSdkClientData).map((id) => (react_1.default.createElement("script", { key: id, id: id, type: "application/json", dangerouslySetInnerHTML: { __html: JSON.stringify(contentSdkClientData[id]) } })))));
39
38
  };
40
39
  exports.EditingScripts = EditingScripts;
@@ -71,7 +71,7 @@ class ErrorBoundary extends react_1.default.Component {
71
71
  else {
72
72
  if (this.showErrorDetails()) {
73
73
  return (react_1.default.createElement("div", null,
74
- react_1.default.createElement("div", { className: "sc-jss-placeholder-error" },
74
+ react_1.default.createElement("div", { className: "sc-content-sdk-placeholder-error" },
75
75
  "A rendering error occurred in component",
76
76
  ' ',
77
77
  react_1.default.createElement("em", null, (_a = this.props.rendering) === null || _a === void 0 ? void 0 : _a.componentName),
@@ -81,12 +81,12 @@ class ErrorBoundary extends react_1.default.Component {
81
81
  }
82
82
  else {
83
83
  return (react_1.default.createElement("div", null,
84
- react_1.default.createElement("div", { className: "sc-jss-placeholder-error" }, this.defaultErrorMessage)));
84
+ react_1.default.createElement("div", { className: "sc-content-sdk-placeholder-error" }, this.defaultErrorMessage)));
85
85
  }
86
86
  }
87
87
  }
88
- // do not apply suspense on already dynamic components
89
- if (this.props.isDynamic) {
88
+ // do not apply suspense when suspense is disabled or when on already dynamic components
89
+ if (this.props.disableSuspense || this.props.isDynamic) {
90
90
  return this.props.children;
91
91
  }
92
92
  return (react_1.default.createElement(react_1.Suspense, { fallback: react_1.default.createElement("h4", null, this.props.componentLoadingMessage || this.defaultLoadingMessage) }, this.props.children));
@@ -71,9 +71,9 @@ const FEaaSComponent = (props) => {
71
71
  // combine fetchedData from server with datasource data (if present)
72
72
  const data = Object.assign(Object.assign({}, props.fetchedData), { _: (0, utils_1.getDataFromFields)((_b = props.fields) !== null && _b !== void 0 ? _b : {}) });
73
73
  // FEaaS control would still be hydrated by client
74
- // we pass all the props as a workaround to avoid hydration error, until we convert all JSS components to server side
74
+ // we pass all the props as a workaround to avoid hydration error, until we convert all Content SDK components to server side
75
75
  // this also allows component to fall back to full client-side rendering when template or src is empty
76
- // FEAAS should not fetch anything, since JSS does the fetching - so we pass empty array into fetch param
76
+ // FEAAS should not fetch anything, since Content SDK does the fetching - so we pass empty array into fetch param
77
77
  return (react_1.default.createElement(FEAAS.Component, { data: data, template: props.template, cdn: (_c = props.params) === null || _c === void 0 ? void 0 : _c.ComponentHostName, library: (_d = props.params) === null || _d === void 0 ? void 0 : _d.LibraryId, version: (_e = props.params) === null || _e === void 0 ? void 0 : _e.ComponentVersion, component: (_f = props.params) === null || _f === void 0 ? void 0 : _f.ComponentId, instance: (_g = props.params) === null || _g === void 0 ? void 0 : _g.ComponentInstanceId, revision: computedRevision, fetch: [] }));
78
78
  };
79
79
  exports.FEaaSComponent = FEaaSComponent;
@@ -63,7 +63,7 @@ const Form = ({ params, rendering }) => {
63
63
  .then(setContent)
64
64
  .catch(() => {
65
65
  if (isEditing) {
66
- console.error(`Failed to load form with id ${params.FormId}. Check debug logs for sitecore-jss:form for more details.`);
66
+ console.error(`Failed to load form with id ${params.FormId}. Check debug logs for content-sdk:form for more details.`);
67
67
  }
68
68
  setError(true);
69
69
  });
@@ -78,7 +78,7 @@ const Form = ({ params, rendering }) => {
78
78
  }, [content]);
79
79
  if (isEditing) {
80
80
  if (error) {
81
- return (react_1.default.createElement("div", { className: "sc-jss-placeholder-error" }, "There was a problem loading this section"));
81
+ return (react_1.default.createElement("div", { className: "sc-content-sdk-placeholder-error" }, "There was a problem loading this section"));
82
82
  }
83
83
  }
84
84
  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 }));
@@ -5,8 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.HiddenRendering = void 0;
7
7
  const react_1 = __importDefault(require("react"));
8
- const styles = {
9
- backgroundImage: 'linear-gradient(45deg, #ffffff 25%, #dcdcdc 25%, #dcdcdc 50%, #ffffff 50%, #ffffff 75%, #dcdcdc 75%, #dcdcdc 100%)',
8
+ const baseStyles = {
10
9
  backgroundSize: '3px 3px',
11
10
  display: 'flex',
12
11
  justifyContent: 'center',
@@ -14,5 +13,11 @@ const styles = {
14
13
  padding: '30px',
15
14
  color: '#aaa',
16
15
  };
17
- const HiddenRendering = () => react_1.default.createElement("div", { style: styles }, "The component is hidden");
16
+ const backgroundImageStyle = {
17
+ backgroundImage: 'linear-gradient(45deg, #ffffff 25%, #dcdcdc 25%, #dcdcdc 50%, #ffffff 50%, #ffffff 75%, #dcdcdc 75%, #dcdcdc 100%)',
18
+ };
19
+ const HiddenRendering = () => {
20
+ const styles = process.env.NODE_ENV === 'test' ? baseStyles : Object.assign(Object.assign({}, baseStyles), backgroundImageStyle);
21
+ return react_1.default.createElement("div", { style: styles }, "The component is hidden");
22
+ };
18
23
  exports.HiddenRendering = HiddenRendering;
@@ -29,7 +29,7 @@ const getImageAttrs = (_a, imageParams, mediaUrlPrefix) => {
29
29
  }
30
30
  (0, utils_1.addClassName)(otherAttrs);
31
31
  const newAttrs = Object.assign({}, otherAttrs);
32
- // update image URL for jss handler and image rendering params
32
+ // update image URL for content sdk handler and image rendering params
33
33
  const resolvedSrc = media_1.mediaApi.updateImageUrl(src, imageParams, mediaUrlPrefix);
34
34
  if (srcSet) {
35
35
  // replace with HTML-formatted srcset, including updated image URLs
@@ -13,7 +13,7 @@ const MissingComponent = (props) => {
13
13
  !props.errorOverride &&
14
14
  console.log(`Component props for unimplemented '${componentName}' component`, props);
15
15
  const errorMessage = props.errorOverride ||
16
- 'JSS component is missing React implementation. See the developer console for more information.';
16
+ 'Content SDK component is missing React implementation. See the developer console for more information.';
17
17
  return (react_1.default.createElement("div", { style: {
18
18
  background: 'darkorange',
19
19
  outline: '5px solid orange',
@@ -35,7 +35,7 @@ class PlaceholderComponent extends PlaceholderCommon_1.PlaceholderCommon {
35
35
  if (childProps.errorComponent) {
36
36
  return react_1.default.createElement(childProps.errorComponent, { error: this.state.error });
37
37
  }
38
- return (react_1.default.createElement("div", { className: "sc-jss-placeholder-error" },
38
+ return (react_1.default.createElement("div", { className: "sc-content-sdk-placeholder-error" },
39
39
  "A rendering error occurred: ",
40
40
  this.state.error.message,
41
41
  "."));
@@ -74,8 +74,9 @@ class PlaceholderCommon extends react_1.default.Component {
74
74
  getSXAParams(rendering) {
75
75
  if (!rendering.params)
76
76
  return {};
77
- return (rendering.params.FieldNames && {
78
- styles: `${rendering.params.GridParameters || ''} ${rendering.params.Styles || ''}`,
77
+ const { GridParameters, Styles } = rendering.params;
78
+ return ((GridParameters || Styles) && {
79
+ styles: `${GridParameters || ''} ${Styles || ''}`,
79
80
  });
80
81
  }
81
82
  getComponentsForRenderingData(placeholderData) {
@@ -131,9 +132,13 @@ class PlaceholderCommon extends react_1.default.Component {
131
132
  if (!isEmpty) {
132
133
  // assign type based on passed element - type='text/sitecore' should be ignored when renderEach Placeholder prop function is being used
133
134
  const type = rendered.props.type === 'text/sitecore' ? rendered.props.type : '';
135
+ const disableSuspense = this.props.disableSuspense || false;
134
136
  // wrapping with error boundary could cause problems in case where parent component uses withPlaceholder HOC and tries to access its children props
135
137
  // that's why we need to expose element's props here
136
- 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: ((_a = component.render) === null || _a === void 0 ? void 0 : _a.preload) ? true : false }, rendered.props), rendered));
138
+ const isByocWrapper = componentRendering.componentName === BYOCWrapper_1.BYOC_WRAPPER_RENDERING_NAME;
139
+ // all dynamic elements will have a separate render prop
140
+ const isDynamicComponent = !!((_a = component.render) === null || _a === void 0 ? void 0 : _a.preload);
141
+ rendered = (react_1.default.createElement(ErrorBoundary_1.default, Object.assign({ "data-testid": "error-boundary", key: rendered.type + '-' + index, errorComponent: this.props.errorComponent, componentLoadingMessage: this.props.componentLoadingMessage, type: type, isDynamic: isDynamicComponent || isByocWrapper, disableSuspense: disableSuspense }, rendered.props), rendered));
137
142
  }
138
143
  // if in edit mode then emit shallow chromes for hydration in Pages
139
144
  if ((_b = this.props.pageContext) === null || _b === void 0 ? void 0 : _b.pageEditing) {
@@ -28,7 +28,7 @@ function withPlaceholder(placeholders, options) {
28
28
  if (childProps.errorComponent) {
29
29
  return react_1.default.createElement(childProps.errorComponent, { error: this.state.error });
30
30
  }
31
- return (react_1.default.createElement("div", { className: "sc-jss-placeholder-error" },
31
+ return (react_1.default.createElement("div", { className: "sc-content-sdk-placeholder-error" },
32
32
  "A rendering error occurred: ",
33
33
  this.state.error.message,
34
34
  "."));
@@ -19,7 +19,7 @@ function withSitecore(options) {
19
19
  }
20
20
  /**
21
21
  * This hook grants acсess to the current Sitecore page context and api.
22
- * by default JSS includes the following properties in this context:
22
+ * by default Content SDK includes the following properties in this context:
23
23
  * - pageEditing - Provided by Layout Service, a boolean indicating whether the route is being accessed via the Sitecore Editor.
24
24
  * - pageState - Like pageEditing, but a string: normal, preview or edit.
25
25
  * - site - Provided by Layout Service, an object containing the name of the current Sitecore site context.
@@ -1,17 +1,16 @@
1
1
  import React from 'react';
2
2
  import { LayoutServicePageState, RenderingType } from '@sitecore-content-sdk/core/layout';
3
3
  import { useSitecore } from '../enhancers/withSitecore';
4
- import { getJssPagesClientData } from '@sitecore-content-sdk/core/editing';
4
+ import { getContentSdkPagesClientData } from '@sitecore-content-sdk/core/editing';
5
5
  import { getDesignLibraryScriptLink } from '@sitecore-content-sdk/core/editing';
6
6
  /**
7
7
  * Renders client scripts and data for editing/preview mode for Pages.
8
8
  * Renders script required for the Design Library (when RenderingType is `component`).
9
- * @param {EditingScriptsProps} props - The props for the EditingScripts component.
10
- * @param {string} props.sitecoreEdgeUrl - Sitecore Edge Platform URL.
11
9
  * @returns A JSX element containing the editing scripts or an empty fragment if not in editing/preview mode.
12
10
  */
13
- export const EditingScripts = (props) => {
14
- const { pageContext: { pageState, clientData, clientScripts, renderingType }, } = useSitecore();
11
+ export const EditingScripts = () => {
12
+ var _a;
13
+ const { pageContext: { pageState, clientData, clientScripts, renderingType }, api, } = useSitecore();
15
14
  // Don't render anything if not in editing/preview mode and rendering type is not component
16
15
  if (renderingType !== RenderingType.Component &&
17
16
  (pageState === LayoutServicePageState.Normal ||
@@ -22,12 +21,12 @@ export const EditingScripts = (props) => {
22
21
  // In case of RenderingType.Component - render only the script for Design Libnrary
23
22
  if (renderingType === RenderingType.Component) {
24
23
  // Add cache buster to the script URL
25
- const scriptUrl = `${getDesignLibraryScriptLink(props.sitecoreEdgeUrl)}?cb=${Date.now()}`;
24
+ const scriptUrl = `${getDesignLibraryScriptLink((_a = api === null || api === void 0 ? void 0 : api.edge) === null || _a === void 0 ? void 0 : _a.edgeUrl)}?cb=${Date.now()}`;
26
25
  return (React.createElement(React.Fragment, null,
27
26
  React.createElement("script", { src: scriptUrl, suppressHydrationWarning: true })));
28
27
  }
29
- const jssClientData = Object.assign(Object.assign({}, clientData), getJssPagesClientData());
28
+ const contentSdkClientData = Object.assign(Object.assign({}, clientData), getContentSdkPagesClientData());
30
29
  return (React.createElement(React.Fragment, null, clientScripts === null || clientScripts === void 0 ? void 0 :
31
30
  clientScripts.map((src, index) => (React.createElement("script", { src: src, key: index }))),
32
- Object.keys(jssClientData).map((id) => (React.createElement("script", { key: id, id: id, type: "application/json", dangerouslySetInnerHTML: { __html: JSON.stringify(jssClientData[id]) } })))));
31
+ Object.keys(contentSdkClientData).map((id) => (React.createElement("script", { key: id, id: id, type: "application/json", dangerouslySetInnerHTML: { __html: JSON.stringify(contentSdkClientData[id]) } })))));
33
32
  };
@@ -36,7 +36,7 @@ class ErrorBoundary extends React.Component {
36
36
  else {
37
37
  if (this.showErrorDetails()) {
38
38
  return (React.createElement("div", null,
39
- React.createElement("div", { className: "sc-jss-placeholder-error" },
39
+ React.createElement("div", { className: "sc-content-sdk-placeholder-error" },
40
40
  "A rendering error occurred in component",
41
41
  ' ',
42
42
  React.createElement("em", null, (_a = this.props.rendering) === null || _a === void 0 ? void 0 : _a.componentName),
@@ -46,12 +46,12 @@ class ErrorBoundary extends React.Component {
46
46
  }
47
47
  else {
48
48
  return (React.createElement("div", null,
49
- React.createElement("div", { className: "sc-jss-placeholder-error" }, this.defaultErrorMessage)));
49
+ React.createElement("div", { className: "sc-content-sdk-placeholder-error" }, this.defaultErrorMessage)));
50
50
  }
51
51
  }
52
52
  }
53
- // do not apply suspense on already dynamic components
54
- if (this.props.isDynamic) {
53
+ // do not apply suspense when suspense is disabled or when on already dynamic components
54
+ if (this.props.disableSuspense || this.props.isDynamic) {
55
55
  return this.props.children;
56
56
  }
57
57
  return (React.createElement(Suspense, { fallback: React.createElement("h4", null, this.props.componentLoadingMessage || this.defaultLoadingMessage) }, this.props.children));
@@ -31,9 +31,9 @@ export const FEaaSComponent = (props) => {
31
31
  // combine fetchedData from server with datasource data (if present)
32
32
  const data = Object.assign(Object.assign({}, props.fetchedData), { _: getDataFromFields((_b = props.fields) !== null && _b !== void 0 ? _b : {}) });
33
33
  // FEaaS control would still be hydrated by client
34
- // we pass all the props as a workaround to avoid hydration error, until we convert all JSS components to server side
34
+ // we pass all the props as a workaround to avoid hydration error, until we convert all Content SDK components to server side
35
35
  // this also allows component to fall back to full client-side rendering when template or src is empty
36
- // FEAAS should not fetch anything, since JSS does the fetching - so we pass empty array into fetch param
36
+ // FEAAS should not fetch anything, since Content SDK does the fetching - so we pass empty array into fetch param
37
37
  return (React.createElement(FEAAS.Component, { data: data, template: props.template, cdn: (_c = props.params) === null || _c === void 0 ? void 0 : _c.ComponentHostName, library: (_d = props.params) === null || _d === void 0 ? void 0 : _d.LibraryId, version: (_e = props.params) === null || _e === void 0 ? void 0 : _e.ComponentVersion, component: (_f = props.params) === null || _f === void 0 ? void 0 : _f.ComponentId, instance: (_g = props.params) === null || _g === void 0 ? void 0 : _g.ComponentInstanceId, revision: computedRevision, fetch: [] }));
38
38
  };
39
39
  /**
@@ -26,7 +26,7 @@ export const Form = ({ params, rendering }) => {
26
26
  .then(setContent)
27
27
  .catch(() => {
28
28
  if (isEditing) {
29
- console.error(`Failed to load form with id ${params.FormId}. Check debug logs for sitecore-jss:form for more details.`);
29
+ console.error(`Failed to load form with id ${params.FormId}. Check debug logs for content-sdk:form for more details.`);
30
30
  }
31
31
  setError(true);
32
32
  });
@@ -41,7 +41,7 @@ export const Form = ({ params, rendering }) => {
41
41
  }, [content]);
42
42
  if (isEditing) {
43
43
  if (error) {
44
- return (React.createElement("div", { className: "sc-jss-placeholder-error" }, "There was a problem loading this section"));
44
+ return (React.createElement("div", { className: "sc-content-sdk-placeholder-error" }, "There was a problem loading this section"));
45
45
  }
46
46
  }
47
47
  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 }));
@@ -1,6 +1,5 @@
1
1
  import React from 'react';
2
- const styles = {
3
- backgroundImage: 'linear-gradient(45deg, #ffffff 25%, #dcdcdc 25%, #dcdcdc 50%, #ffffff 50%, #ffffff 75%, #dcdcdc 75%, #dcdcdc 100%)',
2
+ const baseStyles = {
4
3
  backgroundSize: '3px 3px',
5
4
  display: 'flex',
6
5
  justifyContent: 'center',
@@ -8,4 +7,10 @@ const styles = {
8
7
  padding: '30px',
9
8
  color: '#aaa',
10
9
  };
11
- export const HiddenRendering = () => React.createElement("div", { style: styles }, "The component is hidden");
10
+ const backgroundImageStyle = {
11
+ backgroundImage: 'linear-gradient(45deg, #ffffff 25%, #dcdcdc 25%, #dcdcdc 50%, #ffffff 50%, #ffffff 75%, #dcdcdc 75%, #dcdcdc 100%)',
12
+ };
13
+ export const HiddenRendering = () => {
14
+ const styles = process.env.NODE_ENV === 'test' ? baseStyles : Object.assign(Object.assign({}, baseStyles), backgroundImageStyle);
15
+ return React.createElement("div", { style: styles }, "The component is hidden");
16
+ };
@@ -23,7 +23,7 @@ const getImageAttrs = (_a, imageParams, mediaUrlPrefix) => {
23
23
  }
24
24
  addClassName(otherAttrs);
25
25
  const newAttrs = Object.assign({}, otherAttrs);
26
- // update image URL for jss handler and image rendering params
26
+ // update image URL for content sdk handler and image rendering params
27
27
  const resolvedSrc = mediaApi.updateImageUrl(src, imageParams, mediaUrlPrefix);
28
28
  if (srcSet) {
29
29
  // replace with HTML-formatted srcset, including updated image URLs
@@ -7,7 +7,7 @@ export const MissingComponent = (props) => {
7
7
  !props.errorOverride &&
8
8
  console.log(`Component props for unimplemented '${componentName}' component`, props);
9
9
  const errorMessage = props.errorOverride ||
10
- 'JSS component is missing React implementation. See the developer console for more information.';
10
+ 'Content SDK component is missing React implementation. See the developer console for more information.';
11
11
  return (React.createElement("div", { style: {
12
12
  background: 'darkorange',
13
13
  outline: '5px solid orange',
@@ -29,7 +29,7 @@ class PlaceholderComponent extends PlaceholderCommon {
29
29
  if (childProps.errorComponent) {
30
30
  return React.createElement(childProps.errorComponent, { error: this.state.error });
31
31
  }
32
- return (React.createElement("div", { className: "sc-jss-placeholder-error" },
32
+ return (React.createElement("div", { className: "sc-content-sdk-placeholder-error" },
33
33
  "A rendering error occurred: ",
34
34
  this.state.error.message,
35
35
  "."));
@@ -68,8 +68,9 @@ export class PlaceholderCommon extends React.Component {
68
68
  getSXAParams(rendering) {
69
69
  if (!rendering.params)
70
70
  return {};
71
- return (rendering.params.FieldNames && {
72
- styles: `${rendering.params.GridParameters || ''} ${rendering.params.Styles || ''}`,
71
+ const { GridParameters, Styles } = rendering.params;
72
+ return ((GridParameters || Styles) && {
73
+ styles: `${GridParameters || ''} ${Styles || ''}`,
73
74
  });
74
75
  }
75
76
  getComponentsForRenderingData(placeholderData) {
@@ -125,9 +126,13 @@ export class PlaceholderCommon extends React.Component {
125
126
  if (!isEmpty) {
126
127
  // assign type based on passed element - type='text/sitecore' should be ignored when renderEach Placeholder prop function is being used
127
128
  const type = rendered.props.type === 'text/sitecore' ? rendered.props.type : '';
129
+ const disableSuspense = this.props.disableSuspense || false;
128
130
  // wrapping with error boundary could cause problems in case where parent component uses withPlaceholder HOC and tries to access its children props
129
131
  // that's why we need to expose element's props here
130
- rendered = (React.createElement(ErrorBoundary, Object.assign({ key: rendered.type + '-' + index, errorComponent: this.props.errorComponent, componentLoadingMessage: this.props.componentLoadingMessage, type: type, isDynamic: ((_a = component.render) === null || _a === void 0 ? void 0 : _a.preload) ? true : false }, rendered.props), rendered));
132
+ const isByocWrapper = componentRendering.componentName === BYOC_WRAPPER_RENDERING_NAME;
133
+ // all dynamic elements will have a separate render prop
134
+ const isDynamicComponent = !!((_a = component.render) === null || _a === void 0 ? void 0 : _a.preload);
135
+ rendered = (React.createElement(ErrorBoundary, Object.assign({ "data-testid": "error-boundary", key: rendered.type + '-' + index, errorComponent: this.props.errorComponent, componentLoadingMessage: this.props.componentLoadingMessage, type: type, isDynamic: isDynamicComponent || isByocWrapper, disableSuspense: disableSuspense }, rendered.props), rendered));
131
136
  }
132
137
  // if in edit mode then emit shallow chromes for hydration in Pages
133
138
  if ((_b = this.props.pageContext) === null || _b === void 0 ? void 0 : _b.pageEditing) {
@@ -22,7 +22,7 @@ export function withPlaceholder(placeholders, options) {
22
22
  if (childProps.errorComponent) {
23
23
  return React.createElement(childProps.errorComponent, { error: this.state.error });
24
24
  }
25
- return (React.createElement("div", { className: "sc-jss-placeholder-error" },
25
+ return (React.createElement("div", { className: "sc-content-sdk-placeholder-error" },
26
26
  "A rendering error occurred: ",
27
27
  this.state.error.message,
28
28
  "."));
@@ -12,7 +12,7 @@ export function withSitecore(options) {
12
12
  }
13
13
  /**
14
14
  * This hook grants acсess to the current Sitecore page context and api.
15
- * by default JSS includes the following properties in this context:
15
+ * by default Content SDK includes the following properties in this context:
16
16
  * - pageEditing - Provided by Layout Service, a boolean indicating whether the route is being accessed via the Sitecore Editor.
17
17
  * - pageState - Like pageEditing, but a string: normal, preview or edit.
18
18
  * - site - Provided by Layout Service, an object containing the name of the current Sitecore site context.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sitecore-content-sdk/react",
3
- "version": "0.3.0-canary.3",
3
+ "version": "0.3.0-canary.31",
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.5.19",
33
+ "@sitecore-feaas/clientside": "0.5.20-alpha.1",
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.5.19",
61
+ "@sitecore-feaas/clientside": "0.5.20-alpha.1",
62
62
  "react": "^19.1.0",
63
63
  "react-dom": "^19.1.0"
64
64
  },
65
65
  "dependencies": {
66
- "@sitecore-content-sdk/core": "0.3.0-canary.3",
66
+ "@sitecore-content-sdk/core": "0.3.0-canary.31",
67
67
  "fast-deep-equal": "^3.1.3"
68
68
  },
69
69
  "description": "",
70
70
  "types": "types/index.d.ts",
71
- "gitHead": "73dc7a362f27a612b3fd6acc3ab2e65ce55eb75e",
71
+ "gitHead": "b6874d2a0be0e7b42a8cf33b43565e924e5901ec",
72
72
  "files": [
73
73
  "dist",
74
74
  "types"
@@ -1,18 +1,7 @@
1
1
  import { JSX } from 'react';
2
- /**
3
- * Props for the EditingScripts component.
4
- */
5
- export type EditingScriptsProps = {
6
- /**
7
- * Sitecore Edge Platform URL.
8
- */
9
- sitecoreEdgeUrl?: string;
10
- };
11
2
  /**
12
3
  * Renders client scripts and data for editing/preview mode for Pages.
13
4
  * Renders script required for the Design Library (when RenderingType is `component`).
14
- * @param {EditingScriptsProps} props - The props for the EditingScripts component.
15
- * @param {string} props.sitecoreEdgeUrl - Sitecore Edge Platform URL.
16
5
  * @returns A JSX element containing the editing scripts or an empty fragment if not in editing/preview mode.
17
6
  */
18
- export declare const EditingScripts: (props: EditingScriptsProps) => JSX.Element;
7
+ export declare const EditingScripts: () => JSX.Element;
@@ -12,6 +12,7 @@ export type ErrorBoundaryProps = {
12
12
  errorComponent?: React.ComponentClass<ErrorComponentProps> | React.FC<ErrorComponentProps>;
13
13
  rendering?: ComponentRendering;
14
14
  componentLoadingMessage?: string;
15
+ disableSuspense?: boolean;
15
16
  };
16
17
  declare const _default: (props: import("@sitecore-content-sdk/core/utils").EnhancedOmit<ErrorBoundaryProps, keyof import("../enhancers/withSitecore").WithSitecoreProps>) => React.JSX.Element;
17
18
  export default _default;
@@ -65,6 +65,11 @@ export interface PlaceholderProps {
65
65
  * The message that gets displayed while component is loading
66
66
  */
67
67
  componentLoadingMessage?: string;
68
+ /**
69
+ * If true, disables Suspense in ErrorBoundary for the placeholder.
70
+ * @default false
71
+ */
72
+ disableSuspense?: boolean;
68
73
  }
69
74
  export declare class PlaceholderCommon<T extends PlaceholderProps> extends React.Component<T> {
70
75
  state: Readonly<{
@@ -6,7 +6,7 @@ export declare const DEFAULT_EXPORT_NAME = "Default";
6
6
  /**
7
7
  * React component import with account for custom exports
8
8
  */
9
- export type ReactJssComponent = ComponentType | ReactModule;
9
+ export type ReactContentSdkComponent = ComponentType | ReactModule;
10
10
  export type ReactModule = {
11
11
  /**
12
12
  * Custom exports
@@ -29,4 +29,4 @@ export type LazyComponentType = ComponentType & {
29
29
  [key: string]: unknown;
30
30
  };
31
31
  };
32
- export type ComponentMap<TComponent extends ReactJssComponent = ReactJssComponent> = Map<string, TComponent>;
32
+ export type ComponentMap<TComponent extends ReactContentSdkComponent = ReactContentSdkComponent> = Map<string, TComponent>;
@@ -4,7 +4,7 @@ import { PlaceholderProps } from '../components/PlaceholderCommon';
4
4
  export interface WithPlaceholderOptions {
5
5
  /**
6
6
  * Function to map incoming placeholder props into rendering data to use for the placeholder data.
7
- * Normally in a JSS component, props.rendering is passed the component data, and that is the default.
7
+ * Normally in a Content SDK component, props.rendering is passed the component data, and that is the default.
8
8
  * However, if your component data is in a different prop, like say 'route' in a sample app,
9
9
  * this lets you map that.
10
10
  */
@@ -30,7 +30,7 @@ export type WithSitecoreHocProps<ComponentProps> = EnhancedOmit<ComponentProps,
30
30
  export declare function withSitecore(options?: WithSitecoreOptions): <ComponentProps extends WithSitecoreProps>(Component: React.ComponentType<ComponentProps>) => (props: WithSitecoreHocProps<ComponentProps>) => React.JSX.Element;
31
31
  /**
32
32
  * This hook grants acсess to the current Sitecore page context and api.
33
- * by default JSS includes the following properties in this context:
33
+ * by default Content SDK includes the following properties in this context:
34
34
  * - pageEditing - Provided by Layout Service, a boolean indicating whether the route is being accessed via the Sitecore Editor.
35
35
  * - pageState - Like pageEditing, but a string: normal, preview or edit.
36
36
  * - site - Provided by Layout Service, an object containing the name of the current Sitecore site context.
package/types/index.d.ts CHANGED
@@ -6,7 +6,7 @@ export { DictionaryPhrases, DictionaryService, GraphQLDictionaryService, } from
6
6
  export { GraphQLClientError, RetryStrategy, DefaultRetryStrategy, GraphQLRequestClientFactoryConfig, GraphQLRequestClient, } from '@sitecore-content-sdk/core/client';
7
7
  export { mediaApi } from '@sitecore-content-sdk/core/media';
8
8
  export { Form } from './components/Form';
9
- export { ReactJssComponent, ComponentMap, ReactModule } from './components/sharedTypes';
9
+ export { ReactContentSdkComponent, ComponentMap, ReactModule } from './components/sharedTypes';
10
10
  export { Placeholder, PlaceholderComponentProps } from './components/Placeholder';
11
11
  export { Image, ImageProps, ImageField, ImageFieldValue, ImageSizeParameters, } from './components/Image';
12
12
  export { RichText, RichTextProps, RichTextField } from './components/RichText';