@sitecore-jss/sitecore-jss-react 22.5.0-beta.6 → 22.5.0-beta.8
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.
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.withDatasourceCheck = exports.DefaultEditingError = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const layout_1 = require("@sitecore-jss/sitecore-jss/layout");
|
|
8
9
|
const withSitecoreContext_1 = require("./withSitecoreContext");
|
|
9
10
|
const DefaultEditingError = () => (react_1.default.createElement("div", { className: "sc-jss-editing-error", role: "alert" }, "Datasource is required. Please choose a content item for this component."));
|
|
10
11
|
exports.DefaultEditingError = DefaultEditingError;
|
|
@@ -21,7 +22,9 @@ function withDatasourceCheck(options) {
|
|
|
21
22
|
var _a, _b;
|
|
22
23
|
const { sitecoreContext } = (0, withSitecoreContext_1.useSitecoreContext)();
|
|
23
24
|
const EditingError = (_a = options === null || options === void 0 ? void 0 : options.editingErrorComponent) !== null && _a !== void 0 ? _a : exports.DefaultEditingError;
|
|
24
|
-
|
|
25
|
+
// If the component is rendered in DesignLibrary, we don't need to check for datasource
|
|
26
|
+
const isDesignLibrary = (sitecoreContext === null || sitecoreContext === void 0 ? void 0 : sitecoreContext.renderingType) === layout_1.RenderingType.Component;
|
|
27
|
+
return isDesignLibrary || ((_b = props.rendering) === null || _b === void 0 ? void 0 : _b.dataSource) ? (react_1.default.createElement(Component, Object.assign({}, props))) : sitecoreContext.pageEditing ? (react_1.default.createElement(EditingError, null)) : null;
|
|
25
28
|
};
|
|
26
29
|
};
|
|
27
30
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { RenderingType } from '@sitecore-jss/sitecore-jss/layout';
|
|
2
3
|
import { useSitecoreContext } from './withSitecoreContext';
|
|
3
4
|
export const DefaultEditingError = () => (React.createElement("div", { className: "sc-jss-editing-error", role: "alert" }, "Datasource is required. Please choose a content item for this component."));
|
|
4
5
|
/**
|
|
@@ -14,7 +15,9 @@ export function withDatasourceCheck(options) {
|
|
|
14
15
|
var _a, _b;
|
|
15
16
|
const { sitecoreContext } = useSitecoreContext();
|
|
16
17
|
const EditingError = (_a = options === null || options === void 0 ? void 0 : options.editingErrorComponent) !== null && _a !== void 0 ? _a : DefaultEditingError;
|
|
17
|
-
|
|
18
|
+
// If the component is rendered in DesignLibrary, we don't need to check for datasource
|
|
19
|
+
const isDesignLibrary = (sitecoreContext === null || sitecoreContext === void 0 ? void 0 : sitecoreContext.renderingType) === RenderingType.Component;
|
|
20
|
+
return isDesignLibrary || ((_b = props.rendering) === null || _b === void 0 ? void 0 : _b.dataSource) ? (React.createElement(Component, Object.assign({}, props))) : sitecoreContext.pageEditing ? (React.createElement(EditingError, null)) : null;
|
|
18
21
|
};
|
|
19
22
|
};
|
|
20
23
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sitecore-jss/sitecore-jss-react",
|
|
3
|
-
"version": "22.5.0-beta.
|
|
3
|
+
"version": "22.5.0-beta.8",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -61,14 +61,14 @@
|
|
|
61
61
|
"react-dom": "^18.2.0"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@sitecore-jss/sitecore-jss": "22.5.0-beta.
|
|
64
|
+
"@sitecore-jss/sitecore-jss": "22.5.0-beta.8",
|
|
65
65
|
"fast-deep-equal": "^3.1.3",
|
|
66
66
|
"prop-types": "^15.8.1",
|
|
67
67
|
"style-attr": "^1.3.0"
|
|
68
68
|
},
|
|
69
69
|
"description": "",
|
|
70
70
|
"types": "types/index.d.ts",
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "c523545dd18997548b73dfa4be372f278a2e288f",
|
|
72
72
|
"files": [
|
|
73
73
|
"dist",
|
|
74
74
|
"types"
|