@sitecore-jss/sitecore-jss-react 21.5.2-canary.3 → 21.5.2-canary.5

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.
@@ -67,7 +67,7 @@ class BYOCComponent extends react_1.default.Component {
67
67
  this.setState({ error });
68
68
  }
69
69
  render() {
70
- var _a, _b;
70
+ var _a, _b, _c;
71
71
  const props = this.props;
72
72
  if (this.state.error) {
73
73
  return this.props.errorComponent ? (react_1.default.createElement(this.props.errorComponent, { error: this.state.error })) : (react_1.default.createElement(DefaultErrorComponent, { error: this.state.error }));
@@ -87,7 +87,7 @@ class BYOCComponent extends react_1.default.Component {
87
87
  };
88
88
  const fallbackComponent = this.props.missingComponentComponent ? (react_1.default.createElement(this.props.missingComponentComponent, Object.assign({}, unRegisteredComponentProps))) : (react_1.default.createElement(MissingComponent_1.MissingComponent, Object.assign({}, unRegisteredComponentProps)));
89
89
  const ErrorComponent = this.props.errorComponent;
90
- let componentProps = null;
90
+ let componentProps = {};
91
91
  if ((_a = props.params) === null || _a === void 0 ? void 0 : _a.ComponentProps) {
92
92
  try {
93
93
  componentProps = (_b = JSON.parse(props.params.ComponentProps)) !== null && _b !== void 0 ? _b : {};
@@ -97,11 +97,10 @@ class BYOCComponent extends react_1.default.Component {
97
97
  return ErrorComponent ? (react_1.default.createElement(ErrorComponent, { error: e })) : (react_1.default.createElement(DefaultErrorComponent, { error: e }));
98
98
  }
99
99
  }
100
- else {
101
- componentProps = props.fields ? (0, utils_1.getDataFromFields)(props.fields) : {};
102
- }
100
+ // apply props from item datasource
101
+ const dataSourcesData = Object.assign(Object.assign({}, props.fetchedData), { _: (0, utils_1.getDataFromFields)((_c = props.fields) !== null && _c !== void 0 ? _c : {}) });
103
102
  // we render fallback on client to avoid problems with client-only components
104
- return (react_1.default.createElement(FEAAS.ExternalComponent, Object.assign({ componentName: componentName, clientFallback: fallbackComponent, datasources: props.fetchedData }, componentProps)));
103
+ return (react_1.default.createElement(FEAAS.ExternalComponent, Object.assign({ componentName: componentName, clientFallback: fallbackComponent, datasources: dataSourcesData }, componentProps)));
105
104
  }
106
105
  }
107
106
  exports.BYOCComponent = BYOCComponent;
@@ -57,26 +57,12 @@ const FEaaSComponent = (props) => {
57
57
  // Missing FEaaS component required props
58
58
  return null;
59
59
  }
60
- let data = null;
61
- if (props.fetchedData === null || props.fetchedData === undefined) {
62
- if ((_b = props.params) === null || _b === void 0 ? void 0 : _b.ComponentDataOverride) {
63
- // Use override data if provided
64
- try {
65
- data = JSON.parse(props.params.ComponentDataOverride);
66
- }
67
- catch (e) {
68
- data = null;
69
- }
70
- }
71
- else if (props.fields) {
72
- // Otherwise use datasource data (provided in fields)
73
- data = (0, utils_1.getDataFromFields)(props.fields);
74
- }
75
- }
60
+ // combine fetchedData from server with datasource data (if present)
61
+ const data = Object.assign(Object.assign({}, props.fetchedData), { _: (0, utils_1.getDataFromFields)((_b = props.fields) !== null && _b !== void 0 ? _b : {}) });
76
62
  // FEaaS control would still be hydrated by client
77
63
  // we pass all the props as a workaround to avoid hydration error, until we convert all JSS components to server side
78
64
  // this also allows component to fall back to full client-side rendering when template or src is empty
79
- return (react_1.default.createElement(FEAAS.Component, { data: props.fetchedData || 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 }));
65
+ 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 }));
80
66
  };
81
67
  exports.FEaaSComponent = FEaaSComponent;
82
68
  /**
@@ -91,7 +77,7 @@ function fetchFEaaSComponentServerProps(params, pageState, endpointOverride) {
91
77
  const revisionFallback = pageState && pageState !== layout_1.LayoutServicePageState.Normal ? 'staged' : 'published';
92
78
  const src = endpointOverride || (0, exports.composeComponentEndpoint)(params, revisionFallback);
93
79
  let template = '';
94
- let fetchedData = null;
80
+ let fetchedData = {};
95
81
  const fetchDataOptions = params.ComponentDataOverride
96
82
  ? JSON.parse(params.ComponentDataOverride)
97
83
  : {};
@@ -38,7 +38,7 @@ export class BYOCComponent extends React.Component {
38
38
  this.setState({ error });
39
39
  }
40
40
  render() {
41
- var _a, _b;
41
+ var _a, _b, _c;
42
42
  const props = this.props;
43
43
  if (this.state.error) {
44
44
  return this.props.errorComponent ? (React.createElement(this.props.errorComponent, { error: this.state.error })) : (React.createElement(DefaultErrorComponent, { error: this.state.error }));
@@ -58,7 +58,7 @@ export class BYOCComponent extends React.Component {
58
58
  };
59
59
  const fallbackComponent = this.props.missingComponentComponent ? (React.createElement(this.props.missingComponentComponent, Object.assign({}, unRegisteredComponentProps))) : (React.createElement(MissingComponent, Object.assign({}, unRegisteredComponentProps)));
60
60
  const ErrorComponent = this.props.errorComponent;
61
- let componentProps = null;
61
+ let componentProps = {};
62
62
  if ((_a = props.params) === null || _a === void 0 ? void 0 : _a.ComponentProps) {
63
63
  try {
64
64
  componentProps = (_b = JSON.parse(props.params.ComponentProps)) !== null && _b !== void 0 ? _b : {};
@@ -68,11 +68,10 @@ export class BYOCComponent extends React.Component {
68
68
  return ErrorComponent ? (React.createElement(ErrorComponent, { error: e })) : (React.createElement(DefaultErrorComponent, { error: e }));
69
69
  }
70
70
  }
71
- else {
72
- componentProps = props.fields ? getDataFromFields(props.fields) : {};
73
- }
71
+ // apply props from item datasource
72
+ const dataSourcesData = Object.assign(Object.assign({}, props.fetchedData), { _: getDataFromFields((_c = props.fields) !== null && _c !== void 0 ? _c : {}) });
74
73
  // we render fallback on client to avoid problems with client-only components
75
- return (React.createElement(FEAAS.ExternalComponent, Object.assign({ componentName: componentName, clientFallback: fallbackComponent, datasources: props.fetchedData }, componentProps)));
74
+ return (React.createElement(FEAAS.ExternalComponent, Object.assign({ componentName: componentName, clientFallback: fallbackComponent, datasources: dataSourcesData }, componentProps)));
76
75
  }
77
76
  }
78
77
  /**
@@ -28,26 +28,12 @@ export const FEaaSComponent = (props) => {
28
28
  // Missing FEaaS component required props
29
29
  return null;
30
30
  }
31
- let data = null;
32
- if (props.fetchedData === null || props.fetchedData === undefined) {
33
- if ((_b = props.params) === null || _b === void 0 ? void 0 : _b.ComponentDataOverride) {
34
- // Use override data if provided
35
- try {
36
- data = JSON.parse(props.params.ComponentDataOverride);
37
- }
38
- catch (e) {
39
- data = null;
40
- }
41
- }
42
- else if (props.fields) {
43
- // Otherwise use datasource data (provided in fields)
44
- data = getDataFromFields(props.fields);
45
- }
46
- }
31
+ // combine fetchedData from server with datasource data (if present)
32
+ const data = Object.assign(Object.assign({}, props.fetchedData), { _: getDataFromFields((_b = props.fields) !== null && _b !== void 0 ? _b : {}) });
47
33
  // FEaaS control would still be hydrated by client
48
34
  // we pass all the props as a workaround to avoid hydration error, until we convert all JSS components to server side
49
35
  // this also allows component to fall back to full client-side rendering when template or src is empty
50
- return (React.createElement(FEAAS.Component, { data: props.fetchedData || 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 }));
36
+ 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 }));
51
37
  };
52
38
  /**
53
39
  * Fetches server component props required for server rendering, based on rendering params.
@@ -61,7 +47,7 @@ export function fetchFEaaSComponentServerProps(params, pageState, endpointOverri
61
47
  const revisionFallback = pageState && pageState !== LayoutServicePageState.Normal ? 'staged' : 'published';
62
48
  const src = endpointOverride || composeComponentEndpoint(params, revisionFallback);
63
49
  let template = '';
64
- let fetchedData = null;
50
+ let fetchedData = {};
65
51
  const fetchDataOptions = params.ComponentDataOverride
66
52
  ? JSON.parse(params.ComponentDataOverride)
67
53
  : {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sitecore-jss/sitecore-jss-react",
3
- "version": "21.5.2-canary.3",
3
+ "version": "21.5.2-canary.5",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "sideEffects": false,
@@ -27,7 +27,7 @@
27
27
  "url": "https://github.com/sitecore/jss/issues"
28
28
  },
29
29
  "devDependencies": {
30
- "@sitecore-feaas/clientside": "^0.5.4",
30
+ "@sitecore-feaas/clientside": "^0.5.6",
31
31
  "@types/chai": "^4.3.4",
32
32
  "@types/chai-string": "^1.4.2",
33
33
  "@types/deep-equal": "^1.0.1",
@@ -58,19 +58,19 @@
58
58
  "typescript": "~4.9.3"
59
59
  },
60
60
  "peerDependencies": {
61
- "@sitecore-feaas/clientside": "^0.5.4",
61
+ "@sitecore-feaas/clientside": "^0.5.6",
62
62
  "react": "^18.2.0",
63
63
  "react-dom": "^18.2.0"
64
64
  },
65
65
  "dependencies": {
66
- "@sitecore-jss/sitecore-jss": "^21.5.2-canary.3",
66
+ "@sitecore-jss/sitecore-jss": "^21.5.2-canary.5",
67
67
  "deep-equal": "^2.1.0",
68
68
  "prop-types": "^15.8.1",
69
69
  "style-attr": "^1.3.0"
70
70
  },
71
71
  "description": "",
72
72
  "types": "types/index.d.ts",
73
- "gitHead": "901eaa31fb2cfdc84cbe2070ae849fd97090ce07",
73
+ "gitHead": "1de72998e175fe3c115ef322dbe739866910ce85",
74
74
  "files": [
75
75
  "dist",
76
76
  "types"