@sitecore-content-sdk/react 1.1.0-canary.9 → 1.2.0-canary.10
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/BYOCComponent.js +1 -0
- package/dist/cjs/components/BYOCWrapper.js +1 -0
- package/dist/cjs/components/Date.js +3 -1
- package/dist/cjs/components/DesignLibrary.js +77 -32
- package/dist/cjs/components/EditingScripts.js +8 -2
- package/dist/cjs/components/FEaaSComponent.js +2 -2
- package/dist/cjs/components/FEaaSWrapper.js +1 -0
- package/dist/cjs/components/File.js +1 -3
- package/dist/cjs/components/Form.js +1 -0
- package/dist/cjs/components/Image.js +1 -0
- package/dist/cjs/components/Link.js +4 -3
- package/dist/cjs/components/RichText.js +8 -4
- package/dist/cjs/components/SitecoreProvider.js +1 -0
- package/dist/cjs/components/Text.js +1 -1
- package/dist/cjs/enhancers/withComponentMap.js +1 -3
- package/dist/cjs/enhancers/withEmptyFieldEditingComponent.js +0 -2
- package/dist/cjs/enhancers/withFieldMetadata.js +0 -2
- package/dist/cjs/enhancers/withPlaceholder.js +2 -1
- package/dist/cjs/enhancers/withSitecore.js +1 -0
- package/dist/esm/components/BYOCComponent.js +1 -0
- package/dist/esm/components/BYOCWrapper.js +1 -0
- package/dist/esm/components/Date.js +3 -1
- package/dist/esm/components/DesignLibrary.js +77 -32
- package/dist/esm/components/EditingScripts.js +8 -2
- package/dist/esm/components/FEaaSComponent.js +2 -2
- package/dist/esm/components/FEaaSWrapper.js +1 -0
- package/dist/esm/components/File.js +1 -3
- package/dist/esm/components/Form.js +1 -0
- package/dist/esm/components/Image.js +1 -0
- package/dist/esm/components/Link.js +4 -3
- package/dist/esm/components/RichText.js +8 -4
- package/dist/esm/components/SitecoreProvider.js +1 -0
- package/dist/esm/components/Text.js +1 -1
- package/dist/esm/enhancers/withComponentMap.js +1 -3
- package/dist/esm/enhancers/withEmptyFieldEditingComponent.js +0 -2
- package/dist/esm/enhancers/withFieldMetadata.js +0 -2
- package/dist/esm/enhancers/withPlaceholder.js +2 -1
- package/dist/esm/enhancers/withSitecore.js +1 -0
- package/package.json +14 -5
- package/types/components/DesignLibrary.d.ts +7 -4
|
@@ -20,7 +20,9 @@ const withFieldMetadata_1 = require("../enhancers/withFieldMetadata");
|
|
|
20
20
|
const withEmptyFieldEditingComponent_1 = require("../enhancers/withEmptyFieldEditingComponent");
|
|
21
21
|
const DefaultEmptyFieldEditingComponents_1 = require("./DefaultEmptyFieldEditingComponents");
|
|
22
22
|
const layout_1 = require("@sitecore-content-sdk/core/layout");
|
|
23
|
-
exports.DateField = (0, withFieldMetadata_1.withFieldMetadata)((0, withEmptyFieldEditingComponent_1.withEmptyFieldEditingComponent)(
|
|
23
|
+
exports.DateField = (0, withFieldMetadata_1.withFieldMetadata)((0, withEmptyFieldEditingComponent_1.withEmptyFieldEditingComponent)(
|
|
24
|
+
// eslint-disable-next-line no-unused-vars
|
|
25
|
+
(_a) => {
|
|
24
26
|
var { field, tag, editable = true, render } = _a, otherProps = __rest(_a, ["field", "tag", "editable", "render"]);
|
|
25
27
|
if ((0, layout_1.isFieldValueEmpty)(field)) {
|
|
26
28
|
return null;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
'use client';
|
|
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);
|
|
@@ -32,6 +33,15 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
33
|
return result;
|
|
33
34
|
};
|
|
34
35
|
})();
|
|
36
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
37
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
38
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
39
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
40
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
41
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
42
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
43
|
+
});
|
|
44
|
+
};
|
|
35
45
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
46
|
exports.DesignLibrary = exports.VariantGeneration = exports.__mockDependencies = void 0;
|
|
37
47
|
/* eslint-disable jsdoc/require-param */
|
|
@@ -61,10 +71,7 @@ const Preview = () => {
|
|
|
61
71
|
// useEffect may execute multiple times on single render (i.e. in dev) - but we only want to fire ready event once
|
|
62
72
|
let componentReady = false;
|
|
63
73
|
// have an up-to-date layout state between re-renders (SSR re-render excluded)
|
|
64
|
-
const persistedRoot = (0, react_1.useMemo)(() => (Object.assign(Object.assign({}, (rootComponent || {})), rootUpdate)), [
|
|
65
|
-
rootComponent,
|
|
66
|
-
rootUpdate,
|
|
67
|
-
]);
|
|
74
|
+
const persistedRoot = (0, react_1.useMemo)(() => (Object.assign(Object.assign({}, (rootComponent || {})), rootUpdate)), [rootComponent, rootUpdate]);
|
|
68
75
|
route.placeholders[layout_1.EDITING_COMPONENT_PLACEHOLDER][0] = persistedRoot;
|
|
69
76
|
(0, react_1.useEffect)(() => {
|
|
70
77
|
// useEffect will fire when components are ready - and we inform the whole wide world of it too
|
|
@@ -90,6 +97,11 @@ const Preview = () => {
|
|
|
90
97
|
react_1.default.createElement("main", null,
|
|
91
98
|
react_1.default.createElement("div", { id: layout_1.EDITING_COMPONENT_ID }, route && (react_1.default.createElement(Placeholder_1.Placeholder, { name: layout_1.EDITING_COMPONENT_PLACEHOLDER, rendering: route, key: renderKey }))))));
|
|
92
99
|
};
|
|
100
|
+
const sendErrorEvent = (uid, error, type) => {
|
|
101
|
+
const errorEvent = codegen.getDesignLibraryComponentPreviewErrorEvent(uid, error, type);
|
|
102
|
+
console.error('Component Library: sending error event', errorEvent);
|
|
103
|
+
window.top.postMessage(errorEvent, '*');
|
|
104
|
+
};
|
|
93
105
|
class ErrorBoundary extends react_1.default.Component {
|
|
94
106
|
constructor() {
|
|
95
107
|
super(...arguments);
|
|
@@ -106,9 +118,7 @@ class ErrorBoundary extends react_1.default.Component {
|
|
|
106
118
|
}
|
|
107
119
|
}
|
|
108
120
|
componentDidCatch(error) {
|
|
109
|
-
|
|
110
|
-
console.debug('Component Library: sending error event', errorEvent);
|
|
111
|
-
window.top.postMessage(errorEvent, '*');
|
|
121
|
+
sendErrorEvent(this.props.uid, error, codegen.DesignLibraryPreviewError.Render);
|
|
112
122
|
}
|
|
113
123
|
render() {
|
|
114
124
|
if (this.state.hasError) {
|
|
@@ -126,40 +136,75 @@ const VariantGeneration = (props) => {
|
|
|
126
136
|
const { layout: { sitecore: { route }, }, } = page;
|
|
127
137
|
const rendering = route === null || route === void 0 ? void 0 : route.placeholders[layout_1.EDITING_COMPONENT_PLACEHOLDER][0];
|
|
128
138
|
const [renderKey, setRenderKey] = (0, react_1.useState)(0);
|
|
129
|
-
const [initError, setInitError] = (0, react_1.useState)(false);
|
|
130
139
|
const [Component, setComponent] = (0, react_1.useState)(null);
|
|
131
|
-
|
|
132
|
-
return react_1.default.createElement("div", null, "No import map found. Please check your import map.");
|
|
133
|
-
}
|
|
134
|
-
if (!rendering) {
|
|
135
|
-
return react_1.default.createElement("div", null, "No component found in layout data. Please check your layout data.");
|
|
136
|
-
}
|
|
140
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
137
141
|
(0, react_1.useEffect)(() => {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
+
let cancelled = false;
|
|
143
|
+
// since import map is loaded lazily, we only need to add preview event handler once the import map is loaded
|
|
144
|
+
// unsubscribe function for useEffect cleanup will also be returned once importMap promise has been resolved or rejected
|
|
145
|
+
let unsubscribe = undefined;
|
|
146
|
+
const init = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
147
|
+
var _a;
|
|
148
|
+
let importMap = undefined;
|
|
149
|
+
if (!props.loadImportMap) {
|
|
150
|
+
const errorMessage = 'No loadImportMap prop provided. Please provide a dynamic import map function for DesignLibrary.';
|
|
151
|
+
sendErrorEvent(rendering.uid, errorMessage, codegen.DesignLibraryPreviewError.RenderInit);
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
try {
|
|
155
|
+
const importMapImport = yield props.loadImportMap();
|
|
156
|
+
importMap = importMapImport.default;
|
|
157
|
+
}
|
|
158
|
+
catch (error) {
|
|
159
|
+
const errorMessage = `Error loading import map: ${error}`;
|
|
160
|
+
sendErrorEvent(rendering.uid, errorMessage, codegen.DesignLibraryPreviewError.RenderInit);
|
|
142
161
|
return;
|
|
143
162
|
}
|
|
144
|
-
|
|
145
|
-
|
|
163
|
+
// account for component being unmounted while resolving async import map
|
|
164
|
+
if (cancelled)
|
|
165
|
+
return;
|
|
166
|
+
unsubscribe = addComponentPreviewHandler(importMap, (error, Component) => {
|
|
167
|
+
// Error event is already sent in the addComponentPreviewHandler
|
|
168
|
+
if (error) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
setRenderKey((key) => key + 1);
|
|
172
|
+
setComponent(() => Component);
|
|
173
|
+
});
|
|
174
|
+
const importMapEvent = getDesignLibraryImportMapEvent(rendering.uid, importMap);
|
|
175
|
+
console.debug('Component Library: sending event', importMapEvent);
|
|
176
|
+
window.parent.postMessage(importMapEvent, '*');
|
|
177
|
+
const componentPropsEvent = getDesignLibraryComponentPropsEvent(rendering.uid, rendering.fields, rendering.params);
|
|
178
|
+
console.debug('Component Library: sending event', componentPropsEvent);
|
|
179
|
+
window.top.postMessage(componentPropsEvent, '*');
|
|
180
|
+
const readyEvent = (0, editing_1.getDesignLibraryStatusEvent)(editing_1.DesignLibraryStatus.READY, rendering.uid);
|
|
181
|
+
console.debug('Component Library: sending event', readyEvent);
|
|
182
|
+
(_a = window.top) === null || _a === void 0 ? void 0 : _a.postMessage(readyEvent, '*');
|
|
146
183
|
});
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
184
|
+
init();
|
|
185
|
+
// return function that calls unsubsubribe - if the component was mounted correctly
|
|
186
|
+
return () => {
|
|
187
|
+
cancelled = true;
|
|
188
|
+
if (unsubscribe) {
|
|
189
|
+
unsubscribe();
|
|
190
|
+
}
|
|
191
|
+
};
|
|
154
192
|
}, []);
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
193
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
194
|
+
(0, react_1.useEffect)(() => {
|
|
195
|
+
var _a;
|
|
196
|
+
// Send a rendered event only as effect of a component update command
|
|
197
|
+
if (renderKey === 0)
|
|
198
|
+
return undefined;
|
|
199
|
+
const renderedEvent = (0, editing_1.getDesignLibraryStatusEvent)(editing_1.DesignLibraryStatus.RENDERED, rendering.uid);
|
|
200
|
+
console.debug('Component Library: sending event', renderedEvent);
|
|
201
|
+
(_a = window.top) === null || _a === void 0 ? void 0 : _a.postMessage(renderedEvent, '*');
|
|
202
|
+
}, [renderKey, rendering === null || rendering === void 0 ? void 0 : rendering.uid]);
|
|
158
203
|
return (react_1.default.createElement("main", null, Component ? (react_1.default.createElement(ErrorBoundary, { uid: rendering.uid, renderKey: renderKey },
|
|
159
204
|
react_1.default.createElement(Component, { fields: rendering.fields, params: rendering.params, key: renderKey }))) : (react_1.default.createElement("div", null, "Loading preview..."))));
|
|
160
205
|
};
|
|
161
206
|
exports.VariantGeneration = VariantGeneration;
|
|
162
|
-
const DesignLibrary = ({
|
|
207
|
+
const DesignLibrary = ({ loadImportMap }) => {
|
|
163
208
|
var _a;
|
|
164
209
|
const { page } = (0, withSitecore_1.useSitecore)();
|
|
165
210
|
const { isDesignLibrary } = page.mode;
|
|
@@ -168,7 +213,7 @@ const DesignLibrary = ({ importMap }) => {
|
|
|
168
213
|
return null;
|
|
169
214
|
}
|
|
170
215
|
if (isVariantGeneration) {
|
|
171
|
-
return react_1.default.createElement(exports.VariantGeneration, {
|
|
216
|
+
return react_1.default.createElement(exports.VariantGeneration, { loadImportMap: loadImportMap });
|
|
172
217
|
}
|
|
173
218
|
return react_1.default.createElement(Preview, null);
|
|
174
219
|
};
|
|
@@ -23,8 +23,14 @@ const EditingScripts = () => {
|
|
|
23
23
|
}
|
|
24
24
|
// In case of Design Library - render only the script for Design Library
|
|
25
25
|
if (mode.isDesignLibrary) {
|
|
26
|
-
// Add cache buster to the script URL
|
|
27
|
-
const
|
|
26
|
+
// Add cache buster to the script URL (format hh-dd-mm-yyyy, UTC)
|
|
27
|
+
const now = new Date();
|
|
28
|
+
const hour = String(now.getUTCHours()).padStart(2, '0');
|
|
29
|
+
const day = String(now.getUTCDate()).padStart(2, '0');
|
|
30
|
+
const month = String(now.getUTCMonth() + 1).padStart(2, '0');
|
|
31
|
+
const year = String(now.getUTCFullYear());
|
|
32
|
+
const cacheTimestamp = `${hour}-${day}-${month}-${year}`;
|
|
33
|
+
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=${cacheTimestamp}`;
|
|
28
34
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
29
35
|
react_1.default.createElement("script", { src: scriptUrl, suppressHydrationWarning: true })));
|
|
30
36
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
'use client';
|
|
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);
|
|
@@ -119,8 +120,7 @@ function fetchComponentTemplate(src, params, revisionFallback) {
|
|
|
119
120
|
return template;
|
|
120
121
|
}
|
|
121
122
|
catch (error) {
|
|
122
|
-
console.error(`Fetch FEAAS component from ${src} failed. Ensure the component revision "${params.ComponentRevision ||
|
|
123
|
-
revisionFallback}" is present`);
|
|
123
|
+
console.error(`Fetch FEAAS component from ${src} failed. Ensure the component revision "${params.ComponentRevision || revisionFallback}" is present`);
|
|
124
124
|
throw error;
|
|
125
125
|
}
|
|
126
126
|
});
|
|
@@ -24,9 +24,7 @@ const File = (_a) => {
|
|
|
24
24
|
return null;
|
|
25
25
|
}
|
|
26
26
|
// handle link directly on field for forgetful devs
|
|
27
|
-
const file = (dynamicField.src
|
|
28
|
-
? field
|
|
29
|
-
: dynamicField.value);
|
|
27
|
+
const file = (dynamicField.src ? field : dynamicField.value);
|
|
30
28
|
if (!file) {
|
|
31
29
|
return null;
|
|
32
30
|
}
|
|
@@ -15,6 +15,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.Image = void 0;
|
|
18
|
+
/* eslint-disable no-unused-vars */
|
|
18
19
|
const media_1 = require("@sitecore-content-sdk/core/media");
|
|
19
20
|
const react_1 = __importDefault(require("react"));
|
|
20
21
|
const utils_1 = require("../utils");
|
|
@@ -45,14 +45,15 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
45
45
|
};
|
|
46
46
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47
47
|
exports.Link = void 0;
|
|
48
|
+
/* eslint-disable no-unused-expressions, @typescript-eslint/no-unused-expressions */
|
|
48
49
|
const react_1 = __importStar(require("react"));
|
|
49
50
|
const layout_1 = require("@sitecore-content-sdk/core/layout");
|
|
50
51
|
const withFieldMetadata_1 = require("../enhancers/withFieldMetadata");
|
|
51
52
|
const withEmptyFieldEditingComponent_1 = require("../enhancers/withEmptyFieldEditingComponent");
|
|
52
53
|
const DefaultEmptyFieldEditingComponents_1 = require("./DefaultEmptyFieldEditingComponents");
|
|
53
|
-
exports.Link = (0, withFieldMetadata_1.withFieldMetadata)((0, withEmptyFieldEditingComponent_1.withEmptyFieldEditingComponent)(
|
|
54
|
-
// eslint-disable-next-line
|
|
55
|
-
(
|
|
54
|
+
exports.Link = (0, withFieldMetadata_1.withFieldMetadata)((0, withEmptyFieldEditingComponent_1.withEmptyFieldEditingComponent)((0, react_1.forwardRef)(
|
|
55
|
+
// eslint-disable-next-line no-unused-vars
|
|
56
|
+
(_a, ref) => {
|
|
56
57
|
var { field, editable = true, showLinkTextWithChildrenPresent } = _a, otherProps = __rest(_a, ["field", "editable", "showLinkTextWithChildrenPresent"]);
|
|
57
58
|
const children = otherProps.children;
|
|
58
59
|
const dynamicField = field;
|
|
@@ -50,10 +50,14 @@ const withFieldMetadata_1 = require("../enhancers/withFieldMetadata");
|
|
|
50
50
|
const withEmptyFieldEditingComponent_1 = require("../enhancers/withEmptyFieldEditingComponent");
|
|
51
51
|
const DefaultEmptyFieldEditingComponents_1 = require("./DefaultEmptyFieldEditingComponents");
|
|
52
52
|
const layout_1 = require("@sitecore-content-sdk/core/layout");
|
|
53
|
-
exports.RichText = (0, withFieldMetadata_1.withFieldMetadata)((0, withEmptyFieldEditingComponent_1.withEmptyFieldEditingComponent)(
|
|
54
|
-
// eslint-disable-next-line
|
|
55
|
-
|
|
56
|
-
var
|
|
53
|
+
exports.RichText = (0, withFieldMetadata_1.withFieldMetadata)((0, withEmptyFieldEditingComponent_1.withEmptyFieldEditingComponent)((0, react_1.forwardRef)((
|
|
54
|
+
// eslint-disable-next-line no-unused-vars
|
|
55
|
+
_a, ref) => {
|
|
56
|
+
var
|
|
57
|
+
// eslint-disable-next-line no-unused-vars
|
|
58
|
+
{ field, tag = 'div', editable = true } = _a, otherProps = __rest(_a,
|
|
59
|
+
// eslint-disable-next-line no-unused-vars
|
|
60
|
+
["field", "tag", "editable"]);
|
|
57
61
|
if ((0, layout_1.isFieldValueEmpty)(field)) {
|
|
58
62
|
return null;
|
|
59
63
|
}
|
|
@@ -27,7 +27,7 @@ exports.Text = (0, withFieldMetadata_1.withFieldMetadata)((0, withEmptyFieldEdit
|
|
|
27
27
|
}
|
|
28
28
|
// can't use editable value if we want to output unencoded
|
|
29
29
|
if (!encode) {
|
|
30
|
-
// eslint-disable-next-line no-param-reassign
|
|
30
|
+
// eslint-disable-next-line no-param-reassign, no-unused-vars
|
|
31
31
|
editable = false;
|
|
32
32
|
}
|
|
33
33
|
let output = field.value === undefined ? '' : field.value;
|
|
@@ -19,8 +19,6 @@ function withComponentMap(Component) {
|
|
|
19
19
|
const context = (0, react_2.useContext)(SitecoreProvider_1.ComponentMapReactContext);
|
|
20
20
|
return react_1.default.createElement(Component, Object.assign({}, props, { componentMap: props.componentMap || context }));
|
|
21
21
|
}
|
|
22
|
-
WithComponentMap.displayName = `withComponentMap(${Component.displayName ||
|
|
23
|
-
Component.name ||
|
|
24
|
-
'Anonymous'})`;
|
|
22
|
+
WithComponentMap.displayName = `withComponentMap(${Component.displayName || Component.name || 'Anonymous'})`;
|
|
25
23
|
return WithComponentMap;
|
|
26
24
|
}
|
|
@@ -51,13 +51,11 @@ function withEmptyFieldEditingComponent(FieldComponent, options) {
|
|
|
51
51
|
return null;
|
|
52
52
|
};
|
|
53
53
|
if (options.isForwardRef) {
|
|
54
|
-
// eslint-disable-next-line react/display-name
|
|
55
54
|
return (0, react_1.forwardRef)((props, ref) => {
|
|
56
55
|
const EmptyFieldEditingComponent = getEmptyFieldEditingComponent(props);
|
|
57
56
|
return (react_1.default.createElement(react_1.default.Fragment, null, (EmptyFieldEditingComponent && react_1.default.createElement(EmptyFieldEditingComponent, null)) || (react_1.default.createElement(FieldComponent, Object.assign({}, props, { ref: ref })))));
|
|
58
57
|
});
|
|
59
58
|
}
|
|
60
|
-
// eslint-disable-next-line react/display-name
|
|
61
59
|
return (props) => {
|
|
62
60
|
const EmptyFieldEditingComponent = getEmptyFieldEditingComponent(props);
|
|
63
61
|
return (react_1.default.createElement(react_1.default.Fragment, null, (EmptyFieldEditingComponent && react_1.default.createElement(EmptyFieldEditingComponent, null)) || (react_1.default.createElement(FieldComponent, Object.assign({}, props)))));
|
|
@@ -43,7 +43,6 @@ const FieldMetadata_1 = require("../components/FieldMetadata");
|
|
|
43
43
|
*/
|
|
44
44
|
function withFieldMetadata(FieldComponent, isForwardRef = false) {
|
|
45
45
|
if (isForwardRef) {
|
|
46
|
-
// eslint-disable-next-line react/display-name
|
|
47
46
|
return (0, react_1.forwardRef)((props, ref) => {
|
|
48
47
|
var _a;
|
|
49
48
|
const { editable = true } = props;
|
|
@@ -55,7 +54,6 @@ function withFieldMetadata(FieldComponent, isForwardRef = false) {
|
|
|
55
54
|
react_1.default.createElement(FieldComponent, Object.assign({}, props, { ref: ref }))));
|
|
56
55
|
});
|
|
57
56
|
}
|
|
58
|
-
// eslint-disable-next-line react/display-name
|
|
59
57
|
return (props) => {
|
|
60
58
|
var _a;
|
|
61
59
|
const { editable = true } = props;
|
|
@@ -50,7 +50,8 @@ function withPlaceholder(placeholders, options) {
|
|
|
50
50
|
else {
|
|
51
51
|
placeholderData = PlaceholderCommon_1.PlaceholderCommon.getPlaceholderDataFromRenderingData(renderingData, placeholder, childProps.page.mode.isEditing);
|
|
52
52
|
if (placeholderData) {
|
|
53
|
-
childProps[placeholder] =
|
|
53
|
+
childProps[placeholder] =
|
|
54
|
+
this.getComponentsForRenderingData(placeholderData);
|
|
54
55
|
}
|
|
55
56
|
}
|
|
56
57
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
'use client';
|
|
1
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -14,7 +14,9 @@ import { withFieldMetadata } from '../enhancers/withFieldMetadata';
|
|
|
14
14
|
import { withEmptyFieldEditingComponent } from '../enhancers/withEmptyFieldEditingComponent';
|
|
15
15
|
import { DefaultEmptyFieldEditingComponentText } from './DefaultEmptyFieldEditingComponents';
|
|
16
16
|
import { isFieldValueEmpty } from '@sitecore-content-sdk/core/layout';
|
|
17
|
-
export const DateField = withFieldMetadata(withEmptyFieldEditingComponent(
|
|
17
|
+
export const DateField = withFieldMetadata(withEmptyFieldEditingComponent(
|
|
18
|
+
// eslint-disable-next-line no-unused-vars
|
|
19
|
+
(_a) => {
|
|
18
20
|
var { field, tag, editable = true, render } = _a, otherProps = __rest(_a, ["field", "tag", "editable", "render"]);
|
|
19
21
|
if (isFieldValueEmpty(field)) {
|
|
20
22
|
return null;
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
1
11
|
/* eslint-disable jsdoc/require-param */
|
|
2
12
|
/* eslint-disable prefer-const */
|
|
3
13
|
import React, { useEffect, useMemo, useState } from 'react';
|
|
@@ -24,10 +34,7 @@ const Preview = () => {
|
|
|
24
34
|
// useEffect may execute multiple times on single render (i.e. in dev) - but we only want to fire ready event once
|
|
25
35
|
let componentReady = false;
|
|
26
36
|
// have an up-to-date layout state between re-renders (SSR re-render excluded)
|
|
27
|
-
const persistedRoot = useMemo(() => (Object.assign(Object.assign({}, (rootComponent || {})), rootUpdate)), [
|
|
28
|
-
rootComponent,
|
|
29
|
-
rootUpdate,
|
|
30
|
-
]);
|
|
37
|
+
const persistedRoot = useMemo(() => (Object.assign(Object.assign({}, (rootComponent || {})), rootUpdate)), [rootComponent, rootUpdate]);
|
|
31
38
|
route.placeholders[EDITING_COMPONENT_PLACEHOLDER][0] = persistedRoot;
|
|
32
39
|
useEffect(() => {
|
|
33
40
|
// useEffect will fire when components are ready - and we inform the whole wide world of it too
|
|
@@ -53,6 +60,11 @@ const Preview = () => {
|
|
|
53
60
|
React.createElement("main", null,
|
|
54
61
|
React.createElement("div", { id: EDITING_COMPONENT_ID }, route && (React.createElement(Placeholder, { name: EDITING_COMPONENT_PLACEHOLDER, rendering: route, key: renderKey }))))));
|
|
55
62
|
};
|
|
63
|
+
const sendErrorEvent = (uid, error, type) => {
|
|
64
|
+
const errorEvent = codegen.getDesignLibraryComponentPreviewErrorEvent(uid, error, type);
|
|
65
|
+
console.error('Component Library: sending error event', errorEvent);
|
|
66
|
+
window.top.postMessage(errorEvent, '*');
|
|
67
|
+
};
|
|
56
68
|
class ErrorBoundary extends React.Component {
|
|
57
69
|
constructor() {
|
|
58
70
|
super(...arguments);
|
|
@@ -69,9 +81,7 @@ class ErrorBoundary extends React.Component {
|
|
|
69
81
|
}
|
|
70
82
|
}
|
|
71
83
|
componentDidCatch(error) {
|
|
72
|
-
|
|
73
|
-
console.debug('Component Library: sending error event', errorEvent);
|
|
74
|
-
window.top.postMessage(errorEvent, '*');
|
|
84
|
+
sendErrorEvent(this.props.uid, error, codegen.DesignLibraryPreviewError.Render);
|
|
75
85
|
}
|
|
76
86
|
render() {
|
|
77
87
|
if (this.state.hasError) {
|
|
@@ -89,39 +99,74 @@ export const VariantGeneration = (props) => {
|
|
|
89
99
|
const { layout: { sitecore: { route }, }, } = page;
|
|
90
100
|
const rendering = route === null || route === void 0 ? void 0 : route.placeholders[EDITING_COMPONENT_PLACEHOLDER][0];
|
|
91
101
|
const [renderKey, setRenderKey] = useState(0);
|
|
92
|
-
const [initError, setInitError] = useState(false);
|
|
93
102
|
const [Component, setComponent] = useState(null);
|
|
94
|
-
|
|
95
|
-
return React.createElement("div", null, "No import map found. Please check your import map.");
|
|
96
|
-
}
|
|
97
|
-
if (!rendering) {
|
|
98
|
-
return React.createElement("div", null, "No component found in layout data. Please check your layout data.");
|
|
99
|
-
}
|
|
103
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
100
104
|
useEffect(() => {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
+
let cancelled = false;
|
|
106
|
+
// since import map is loaded lazily, we only need to add preview event handler once the import map is loaded
|
|
107
|
+
// unsubscribe function for useEffect cleanup will also be returned once importMap promise has been resolved or rejected
|
|
108
|
+
let unsubscribe = undefined;
|
|
109
|
+
const init = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
110
|
+
var _a;
|
|
111
|
+
let importMap = undefined;
|
|
112
|
+
if (!props.loadImportMap) {
|
|
113
|
+
const errorMessage = 'No loadImportMap prop provided. Please provide a dynamic import map function for DesignLibrary.';
|
|
114
|
+
sendErrorEvent(rendering.uid, errorMessage, codegen.DesignLibraryPreviewError.RenderInit);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
try {
|
|
118
|
+
const importMapImport = yield props.loadImportMap();
|
|
119
|
+
importMap = importMapImport.default;
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
const errorMessage = `Error loading import map: ${error}`;
|
|
123
|
+
sendErrorEvent(rendering.uid, errorMessage, codegen.DesignLibraryPreviewError.RenderInit);
|
|
105
124
|
return;
|
|
106
125
|
}
|
|
107
|
-
|
|
108
|
-
|
|
126
|
+
// account for component being unmounted while resolving async import map
|
|
127
|
+
if (cancelled)
|
|
128
|
+
return;
|
|
129
|
+
unsubscribe = addComponentPreviewHandler(importMap, (error, Component) => {
|
|
130
|
+
// Error event is already sent in the addComponentPreviewHandler
|
|
131
|
+
if (error) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
setRenderKey((key) => key + 1);
|
|
135
|
+
setComponent(() => Component);
|
|
136
|
+
});
|
|
137
|
+
const importMapEvent = getDesignLibraryImportMapEvent(rendering.uid, importMap);
|
|
138
|
+
console.debug('Component Library: sending event', importMapEvent);
|
|
139
|
+
window.parent.postMessage(importMapEvent, '*');
|
|
140
|
+
const componentPropsEvent = getDesignLibraryComponentPropsEvent(rendering.uid, rendering.fields, rendering.params);
|
|
141
|
+
console.debug('Component Library: sending event', componentPropsEvent);
|
|
142
|
+
window.top.postMessage(componentPropsEvent, '*');
|
|
143
|
+
const readyEvent = getDesignLibraryStatusEvent(DesignLibraryStatus.READY, rendering.uid);
|
|
144
|
+
console.debug('Component Library: sending event', readyEvent);
|
|
145
|
+
(_a = window.top) === null || _a === void 0 ? void 0 : _a.postMessage(readyEvent, '*');
|
|
109
146
|
});
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
147
|
+
init();
|
|
148
|
+
// return function that calls unsubsubribe - if the component was mounted correctly
|
|
149
|
+
return () => {
|
|
150
|
+
cancelled = true;
|
|
151
|
+
if (unsubscribe) {
|
|
152
|
+
unsubscribe();
|
|
153
|
+
}
|
|
154
|
+
};
|
|
117
155
|
}, []);
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
156
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
157
|
+
useEffect(() => {
|
|
158
|
+
var _a;
|
|
159
|
+
// Send a rendered event only as effect of a component update command
|
|
160
|
+
if (renderKey === 0)
|
|
161
|
+
return undefined;
|
|
162
|
+
const renderedEvent = getDesignLibraryStatusEvent(DesignLibraryStatus.RENDERED, rendering.uid);
|
|
163
|
+
console.debug('Component Library: sending event', renderedEvent);
|
|
164
|
+
(_a = window.top) === null || _a === void 0 ? void 0 : _a.postMessage(renderedEvent, '*');
|
|
165
|
+
}, [renderKey, rendering === null || rendering === void 0 ? void 0 : rendering.uid]);
|
|
121
166
|
return (React.createElement("main", null, Component ? (React.createElement(ErrorBoundary, { uid: rendering.uid, renderKey: renderKey },
|
|
122
167
|
React.createElement(Component, { fields: rendering.fields, params: rendering.params, key: renderKey }))) : (React.createElement("div", null, "Loading preview..."))));
|
|
123
168
|
};
|
|
124
|
-
export const DesignLibrary = ({
|
|
169
|
+
export const DesignLibrary = ({ loadImportMap }) => {
|
|
125
170
|
var _a;
|
|
126
171
|
const { page } = useSitecore();
|
|
127
172
|
const { isDesignLibrary } = page.mode;
|
|
@@ -130,7 +175,7 @@ export const DesignLibrary = ({ importMap }) => {
|
|
|
130
175
|
return null;
|
|
131
176
|
}
|
|
132
177
|
if (isVariantGeneration) {
|
|
133
|
-
return React.createElement(VariantGeneration, {
|
|
178
|
+
return React.createElement(VariantGeneration, { loadImportMap: loadImportMap });
|
|
134
179
|
}
|
|
135
180
|
return React.createElement(Preview, null);
|
|
136
181
|
};
|
|
@@ -17,8 +17,14 @@ export const EditingScripts = () => {
|
|
|
17
17
|
}
|
|
18
18
|
// In case of Design Library - render only the script for Design Library
|
|
19
19
|
if (mode.isDesignLibrary) {
|
|
20
|
-
// Add cache buster to the script URL
|
|
21
|
-
const
|
|
20
|
+
// Add cache buster to the script URL (format hh-dd-mm-yyyy, UTC)
|
|
21
|
+
const now = new Date();
|
|
22
|
+
const hour = String(now.getUTCHours()).padStart(2, '0');
|
|
23
|
+
const day = String(now.getUTCDate()).padStart(2, '0');
|
|
24
|
+
const month = String(now.getUTCMonth() + 1).padStart(2, '0');
|
|
25
|
+
const year = String(now.getUTCFullYear());
|
|
26
|
+
const cacheTimestamp = `${hour}-${day}-${month}-${year}`;
|
|
27
|
+
const scriptUrl = `${getDesignLibraryScriptLink((_a = api === null || api === void 0 ? void 0 : api.edge) === null || _a === void 0 ? void 0 : _a.edgeUrl)}?cb=${cacheTimestamp}`;
|
|
22
28
|
return (React.createElement(React.Fragment, null,
|
|
23
29
|
React.createElement("script", { src: scriptUrl, suppressHydrationWarning: true })));
|
|
24
30
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
'use client';
|
|
1
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -78,8 +79,7 @@ function fetchComponentTemplate(src, params, revisionFallback) {
|
|
|
78
79
|
return template;
|
|
79
80
|
}
|
|
80
81
|
catch (error) {
|
|
81
|
-
console.error(`Fetch FEAAS component from ${src} failed. Ensure the component revision "${params.ComponentRevision ||
|
|
82
|
-
revisionFallback}" is present`);
|
|
82
|
+
console.error(`Fetch FEAAS component from ${src} failed. Ensure the component revision "${params.ComponentRevision || revisionFallback}" is present`);
|
|
83
83
|
throw error;
|
|
84
84
|
}
|
|
85
85
|
});
|
|
@@ -18,9 +18,7 @@ export const File = (_a) => {
|
|
|
18
18
|
return null;
|
|
19
19
|
}
|
|
20
20
|
// handle link directly on field for forgetful devs
|
|
21
|
-
const file = (dynamicField.src
|
|
22
|
-
? field
|
|
23
|
-
: dynamicField.value);
|
|
21
|
+
const file = (dynamicField.src ? field : dynamicField.value);
|
|
24
22
|
if (!file) {
|
|
25
23
|
return null;
|
|
26
24
|
}
|
|
@@ -9,14 +9,15 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
+
/* eslint-disable no-unused-expressions, @typescript-eslint/no-unused-expressions */
|
|
12
13
|
import React, { forwardRef } from 'react';
|
|
13
14
|
import { isFieldValueEmpty } from '@sitecore-content-sdk/core/layout';
|
|
14
15
|
import { withFieldMetadata } from '../enhancers/withFieldMetadata';
|
|
15
16
|
import { withEmptyFieldEditingComponent } from '../enhancers/withEmptyFieldEditingComponent';
|
|
16
17
|
import { DefaultEmptyFieldEditingComponentText } from './DefaultEmptyFieldEditingComponents';
|
|
17
|
-
export const Link = withFieldMetadata(withEmptyFieldEditingComponent(
|
|
18
|
-
// eslint-disable-next-line
|
|
19
|
-
|
|
18
|
+
export const Link = withFieldMetadata(withEmptyFieldEditingComponent(forwardRef(
|
|
19
|
+
// eslint-disable-next-line no-unused-vars
|
|
20
|
+
(_a, ref) => {
|
|
20
21
|
var { field, editable = true, showLinkTextWithChildrenPresent } = _a, otherProps = __rest(_a, ["field", "editable", "showLinkTextWithChildrenPresent"]);
|
|
21
22
|
const children = otherProps.children;
|
|
22
23
|
const dynamicField = field;
|
|
@@ -14,10 +14,14 @@ import { withFieldMetadata } from '../enhancers/withFieldMetadata';
|
|
|
14
14
|
import { withEmptyFieldEditingComponent } from '../enhancers/withEmptyFieldEditingComponent';
|
|
15
15
|
import { DefaultEmptyFieldEditingComponentText } from './DefaultEmptyFieldEditingComponents';
|
|
16
16
|
import { isFieldValueEmpty } from '@sitecore-content-sdk/core/layout';
|
|
17
|
-
export const RichText = withFieldMetadata(withEmptyFieldEditingComponent(
|
|
18
|
-
// eslint-disable-next-line
|
|
19
|
-
|
|
20
|
-
var
|
|
17
|
+
export const RichText = withFieldMetadata(withEmptyFieldEditingComponent(forwardRef((
|
|
18
|
+
// eslint-disable-next-line no-unused-vars
|
|
19
|
+
_a, ref) => {
|
|
20
|
+
var
|
|
21
|
+
// eslint-disable-next-line no-unused-vars
|
|
22
|
+
{ field, tag = 'div', editable = true } = _a, otherProps = __rest(_a,
|
|
23
|
+
// eslint-disable-next-line no-unused-vars
|
|
24
|
+
["field", "tag", "editable"]);
|
|
21
25
|
if (isFieldValueEmpty(field)) {
|
|
22
26
|
return null;
|
|
23
27
|
}
|
|
@@ -21,7 +21,7 @@ export const Text = withFieldMetadata(withEmptyFieldEditingComponent((_a) => {
|
|
|
21
21
|
}
|
|
22
22
|
// can't use editable value if we want to output unencoded
|
|
23
23
|
if (!encode) {
|
|
24
|
-
// eslint-disable-next-line no-param-reassign
|
|
24
|
+
// eslint-disable-next-line no-param-reassign, no-unused-vars
|
|
25
25
|
editable = false;
|
|
26
26
|
}
|
|
27
27
|
let output = field.value === undefined ? '' : field.value;
|
|
@@ -13,8 +13,6 @@ export function withComponentMap(Component) {
|
|
|
13
13
|
const context = useContext(ComponentMapReactContext);
|
|
14
14
|
return React.createElement(Component, Object.assign({}, props, { componentMap: props.componentMap || context }));
|
|
15
15
|
}
|
|
16
|
-
WithComponentMap.displayName = `withComponentMap(${Component.displayName ||
|
|
17
|
-
Component.name ||
|
|
18
|
-
'Anonymous'})`;
|
|
16
|
+
WithComponentMap.displayName = `withComponentMap(${Component.displayName || Component.name || 'Anonymous'})`;
|
|
19
17
|
return WithComponentMap;
|
|
20
18
|
}
|
|
@@ -15,13 +15,11 @@ export function withEmptyFieldEditingComponent(FieldComponent, options) {
|
|
|
15
15
|
return null;
|
|
16
16
|
};
|
|
17
17
|
if (options.isForwardRef) {
|
|
18
|
-
// eslint-disable-next-line react/display-name
|
|
19
18
|
return forwardRef((props, ref) => {
|
|
20
19
|
const EmptyFieldEditingComponent = getEmptyFieldEditingComponent(props);
|
|
21
20
|
return (React.createElement(React.Fragment, null, (EmptyFieldEditingComponent && React.createElement(EmptyFieldEditingComponent, null)) || (React.createElement(FieldComponent, Object.assign({}, props, { ref: ref })))));
|
|
22
21
|
});
|
|
23
22
|
}
|
|
24
|
-
// eslint-disable-next-line react/display-name
|
|
25
23
|
return (props) => {
|
|
26
24
|
const EmptyFieldEditingComponent = getEmptyFieldEditingComponent(props);
|
|
27
25
|
return (React.createElement(React.Fragment, null, (EmptyFieldEditingComponent && React.createElement(EmptyFieldEditingComponent, null)) || (React.createElement(FieldComponent, Object.assign({}, props)))));
|
|
@@ -7,7 +7,6 @@ import { FieldMetadata } from '../components/FieldMetadata';
|
|
|
7
7
|
*/
|
|
8
8
|
export function withFieldMetadata(FieldComponent, isForwardRef = false) {
|
|
9
9
|
if (isForwardRef) {
|
|
10
|
-
// eslint-disable-next-line react/display-name
|
|
11
10
|
return forwardRef((props, ref) => {
|
|
12
11
|
var _a;
|
|
13
12
|
const { editable = true } = props;
|
|
@@ -19,7 +18,6 @@ export function withFieldMetadata(FieldComponent, isForwardRef = false) {
|
|
|
19
18
|
React.createElement(FieldComponent, Object.assign({}, props, { ref: ref }))));
|
|
20
19
|
});
|
|
21
20
|
}
|
|
22
|
-
// eslint-disable-next-line react/display-name
|
|
23
21
|
return (props) => {
|
|
24
22
|
var _a;
|
|
25
23
|
const { editable = true } = props;
|
|
@@ -44,7 +44,8 @@ export function withPlaceholder(placeholders, options) {
|
|
|
44
44
|
else {
|
|
45
45
|
placeholderData = PlaceholderCommon.getPlaceholderDataFromRenderingData(renderingData, placeholder, childProps.page.mode.isEditing);
|
|
46
46
|
if (placeholderData) {
|
|
47
|
-
childProps[placeholder] =
|
|
47
|
+
childProps[placeholder] =
|
|
48
|
+
this.getComponentsForRenderingData(placeholderData);
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
51
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sitecore-content-sdk/react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0-canary.10",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@sitecore-feaas/clientside": "^0.6.0",
|
|
34
|
+
"@stylistic/eslint-plugin": "^5.2.2",
|
|
34
35
|
"@testing-library/dom": "^10.4.0",
|
|
35
36
|
"@testing-library/react": "^16.3.0",
|
|
36
37
|
"@types/chai": "^5.2.2",
|
|
@@ -41,14 +42,22 @@
|
|
|
41
42
|
"@types/react-dom": "^19.1.3",
|
|
42
43
|
"@types/sinon": "^17.0.4",
|
|
43
44
|
"@types/sinon-chai": "^4.0.0",
|
|
45
|
+
"@typescript-eslint/eslint-plugin": "8.39.0",
|
|
46
|
+
"@typescript-eslint/parser": "8.39.0",
|
|
44
47
|
"chai": "^4.3.7",
|
|
45
48
|
"chai-string": "^1.6.0",
|
|
46
49
|
"del-cli": "^6.0.0",
|
|
47
|
-
"eslint": "^
|
|
48
|
-
"eslint-
|
|
50
|
+
"eslint": "^9.32.0",
|
|
51
|
+
"eslint-config-prettier": "^10.1.8",
|
|
52
|
+
"eslint-plugin-import": "2.32.0",
|
|
53
|
+
"eslint-plugin-jsdoc": "52.0.3",
|
|
54
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
55
|
+
"eslint-plugin-react": "7.37.5",
|
|
56
|
+
"eslint-plugin-react-hooks": "5.2.0",
|
|
49
57
|
"jsdom": "^26.1.0",
|
|
50
58
|
"mocha": "^11.2.2",
|
|
51
59
|
"nyc": "^17.1.0",
|
|
60
|
+
"prettier": "^2.8.0",
|
|
52
61
|
"react": "^19.1.0",
|
|
53
62
|
"react-dom": "^19.1.0",
|
|
54
63
|
"sinon": "^20.0.0",
|
|
@@ -63,12 +72,12 @@
|
|
|
63
72
|
"react-dom": "^19.1.0"
|
|
64
73
|
},
|
|
65
74
|
"dependencies": {
|
|
66
|
-
"@sitecore-content-sdk/core": "1.
|
|
75
|
+
"@sitecore-content-sdk/core": "1.2.0-canary.10",
|
|
67
76
|
"fast-deep-equal": "^3.1.3"
|
|
68
77
|
},
|
|
69
78
|
"description": "",
|
|
70
79
|
"types": "types/index.d.ts",
|
|
71
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "c02a3a5233fb6864d1ff3d48ad676a5bb4722ae4",
|
|
72
81
|
"files": [
|
|
73
82
|
"dist",
|
|
74
83
|
"types"
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { JSX } from 'react';
|
|
2
2
|
import * as codegen from '@sitecore-content-sdk/core/codegen';
|
|
3
3
|
export declare const __mockDependencies: (mocks: any) => void;
|
|
4
|
+
export type ImportMapImport = {
|
|
5
|
+
default: codegen.ImportEntry[];
|
|
6
|
+
};
|
|
4
7
|
type VariantGenerationProps = {
|
|
5
8
|
/**
|
|
6
9
|
* The import map to be used in variant generation mode.
|
|
7
10
|
*/
|
|
8
|
-
|
|
11
|
+
loadImportMap?: () => Promise<ImportMapImport>;
|
|
9
12
|
};
|
|
10
13
|
/**
|
|
11
14
|
* This component is used to render the component in variant generation mode.
|
|
@@ -14,10 +17,10 @@ type VariantGenerationProps = {
|
|
|
14
17
|
export declare const VariantGeneration: (props: VariantGenerationProps) => JSX.Element;
|
|
15
18
|
type DesignLibraryProps = {
|
|
16
19
|
/**
|
|
17
|
-
* The import map to be used in variant generation mode.
|
|
20
|
+
* The dynamic import for import map to be used in variant generation mode.
|
|
18
21
|
* Currently it's optional but it will be required in the next major version.
|
|
19
22
|
*/
|
|
20
|
-
|
|
23
|
+
loadImportMap?: () => Promise<ImportMapImport>;
|
|
21
24
|
};
|
|
22
|
-
export declare const DesignLibrary: ({
|
|
25
|
+
export declare const DesignLibrary: ({ loadImportMap }: DesignLibraryProps) => JSX.Element;
|
|
23
26
|
export {};
|