@sitecore-content-sdk/react 1.3.0-canary.9 → 1.4.0-canary.2
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/README.md +11 -11
- package/dist/cjs/components/ClientEditingChromesUpdate.js +53 -52
- package/dist/cjs/components/Date.js +49 -45
- package/dist/cjs/components/DefaultEmptyFieldEditingComponents.js +32 -22
- package/dist/cjs/components/{DesignLibrary.js → DesignLibrary/DesignLibrary.js} +161 -202
- package/dist/cjs/components/DesignLibrary/DesignLibraryApp.js +31 -0
- package/dist/cjs/components/DesignLibrary/DesignLibraryClientEvents.js +123 -0
- package/dist/cjs/components/DesignLibrary/DesignLibraryErrorBoundary.js +65 -0
- package/dist/cjs/components/DesignLibrary/DesignLibraryServer.js +193 -0
- package/dist/cjs/components/DesignLibrary/index.js +7 -0
- package/dist/cjs/components/DesignLibrary/models.js +2 -0
- package/dist/cjs/components/EditingScripts.js +44 -43
- package/dist/cjs/components/ErrorBoundary.js +101 -92
- package/dist/cjs/components/FEaaS/BYOCServerWrapper.js +25 -28
- package/dist/cjs/components/FEaaS/BYOCWrapper.js +133 -122
- package/dist/cjs/components/FEaaS/FEaaSSeverWrapper.js +26 -34
- package/dist/cjs/components/FEaaS/FEaaSWrapper.js +84 -78
- package/dist/cjs/components/FEaaS/feaas-utils.js +130 -144
- package/dist/cjs/components/FEaaS/index.js +21 -21
- package/dist/cjs/components/FEaaS/models.js +7 -7
- package/dist/cjs/components/FieldMetadata.js +29 -29
- package/dist/cjs/components/File.js +43 -38
- package/dist/cjs/components/Form.js +100 -92
- package/dist/cjs/components/HiddenRendering.js +23 -23
- package/dist/cjs/components/Image.js +71 -66
- package/dist/cjs/components/Link.js +91 -86
- package/dist/cjs/components/MissingComponent.js +28 -28
- package/dist/cjs/components/Placeholder/AppPlaceholder.js +79 -76
- package/dist/cjs/components/Placeholder/ClientComponentWrapper.js +21 -21
- package/dist/cjs/components/Placeholder/Placeholder.js +144 -110
- package/dist/cjs/components/Placeholder/PlaceholderMetadata.js +68 -63
- package/dist/cjs/components/Placeholder/index.js +25 -25
- package/dist/cjs/components/Placeholder/models.js +18 -18
- package/dist/cjs/components/Placeholder/placeholder-utils.js +226 -226
- package/dist/cjs/components/RichText.js +75 -70
- package/dist/cjs/components/SitecoreProvider.js +62 -52
- package/dist/cjs/components/Text.js +69 -65
- package/dist/cjs/components/sharedTypes/components.js +7 -7
- package/dist/cjs/components/sharedTypes/index.js +18 -18
- package/dist/cjs/components/sharedTypes/props.js +2 -2
- package/dist/cjs/enhancers/withAppPlaceholder.js +21 -21
- package/dist/cjs/enhancers/withComponentMap.js +24 -24
- package/dist/cjs/enhancers/withDatasourceCheck.js +31 -30
- package/dist/cjs/enhancers/withEditorChromes.js +29 -24
- package/dist/cjs/enhancers/withEmptyFieldEditingComponent.js +71 -70
- package/dist/cjs/enhancers/withFieldMetadata.js +68 -67
- package/dist/cjs/enhancers/withLoadImportMap.js +53 -0
- package/dist/cjs/enhancers/withPlaceholder.js +64 -65
- package/dist/cjs/enhancers/withSitecore.js +47 -45
- package/dist/cjs/index.js +86 -85
- package/dist/cjs/rsc-utils/no-rsc.js +5 -5
- package/dist/cjs/rsc-utils/rsc.js +5 -5
- package/dist/cjs/search/index.js +7 -0
- package/dist/cjs/search/useInfiniteSearch.js +136 -0
- package/dist/cjs/search/useSearch.js +107 -0
- package/dist/cjs/search/utils.js +35 -0
- package/dist/cjs/server-actions/update-server-component-action.js +18 -0
- package/dist/cjs/utils.js +38 -38
- package/dist/esm/components/ClientEditingChromesUpdate.js +16 -15
- package/dist/esm/components/Date.js +43 -39
- package/dist/esm/components/DefaultEmptyFieldEditingComponents.js +24 -14
- package/dist/esm/components/{DesignLibrary.js → DesignLibrary/DesignLibrary.js} +124 -164
- package/dist/esm/components/DesignLibrary/DesignLibraryApp.js +24 -0
- package/dist/esm/components/DesignLibrary/DesignLibraryClientEvents.js +84 -0
- package/dist/esm/components/DesignLibrary/DesignLibraryErrorBoundary.js +28 -0
- package/dist/esm/components/DesignLibrary/DesignLibraryServer.js +150 -0
- package/dist/esm/components/DesignLibrary/index.js +2 -0
- package/dist/esm/components/DesignLibrary/models.js +1 -0
- package/dist/esm/components/EditingScripts.js +37 -36
- package/dist/esm/components/ErrorBoundary.js +64 -57
- package/dist/esm/components/FEaaS/BYOCServerWrapper.js +18 -21
- package/dist/esm/components/FEaaS/BYOCWrapper.js +91 -81
- package/dist/esm/components/FEaaS/FEaaSSeverWrapper.js +19 -27
- package/dist/esm/components/FEaaS/FEaaSWrapper.js +43 -37
- package/dist/esm/components/FEaaS/feaas-utils.js +91 -105
- package/dist/esm/components/FEaaS/index.js +6 -6
- package/dist/esm/components/FEaaS/models.js +4 -4
- package/dist/esm/components/FieldMetadata.js +22 -22
- package/dist/esm/components/File.js +36 -31
- package/dist/esm/components/Form.js +62 -54
- package/dist/esm/components/HiddenRendering.js +16 -16
- package/dist/esm/components/Image.js +65 -60
- package/dist/esm/components/Link.js +55 -50
- package/dist/esm/components/MissingComponent.js +21 -21
- package/dist/esm/components/Placeholder/AppPlaceholder.js +72 -69
- package/dist/esm/components/Placeholder/ClientComponentWrapper.js +14 -14
- package/dist/esm/components/Placeholder/Placeholder.js +104 -103
- package/dist/esm/components/Placeholder/PlaceholderMetadata.js +61 -56
- package/dist/esm/components/Placeholder/index.js +4 -4
- package/dist/esm/components/Placeholder/models.js +15 -15
- package/dist/esm/components/Placeholder/placeholder-utils.js +214 -214
- package/dist/esm/components/RichText.js +39 -34
- package/dist/esm/components/SitecoreProvider.js +55 -45
- package/dist/esm/components/Text.js +63 -59
- package/dist/esm/components/sharedTypes/components.js +4 -4
- package/dist/esm/components/sharedTypes/index.js +2 -2
- package/dist/esm/components/sharedTypes/props.js +1 -1
- package/dist/esm/enhancers/withAppPlaceholder.js +14 -14
- package/dist/esm/enhancers/withComponentMap.js +18 -18
- package/dist/esm/enhancers/withDatasourceCheck.js +23 -22
- package/dist/esm/enhancers/withEditorChromes.js +22 -17
- package/dist/esm/enhancers/withEmptyFieldEditingComponent.js +35 -34
- package/dist/esm/enhancers/withFieldMetadata.js +32 -31
- package/dist/esm/enhancers/withLoadImportMap.js +17 -0
- package/dist/esm/enhancers/withPlaceholder.js +58 -59
- package/dist/esm/enhancers/withSitecore.js +40 -38
- package/dist/esm/index.js +29 -29
- package/dist/esm/rsc-utils/no-rsc.js +2 -2
- package/dist/esm/rsc-utils/rsc.js +2 -2
- package/dist/esm/search/index.js +2 -0
- package/dist/esm/search/useInfiniteSearch.js +132 -0
- package/dist/esm/search/useSearch.js +103 -0
- package/dist/esm/search/utils.js +30 -0
- package/dist/esm/server-actions/update-server-component-action.js +15 -0
- package/dist/esm/utils.js +33 -33
- package/global.d.ts +17 -0
- package/package.json +27 -11
- package/search.d.ts +1 -0
- package/types/components/ClientEditingChromesUpdate.d.ts +8 -6
- package/types/components/ClientEditingChromesUpdate.d.ts.map +1 -0
- package/types/components/Date.d.ts +25 -16
- package/types/components/Date.d.ts.map +1 -0
- package/types/components/DefaultEmptyFieldEditingComponents.d.ts +20 -9
- package/types/components/DefaultEmptyFieldEditingComponents.d.ts.map +1 -0
- package/types/components/DesignLibrary/DesignLibrary.d.ts +20 -0
- package/types/components/DesignLibrary/DesignLibrary.d.ts.map +1 -0
- package/types/components/DesignLibrary/DesignLibraryApp.d.ts +14 -0
- package/types/components/DesignLibrary/DesignLibraryApp.d.ts.map +1 -0
- package/types/components/DesignLibrary/DesignLibraryClientEvents.d.ts +21 -0
- package/types/components/DesignLibrary/DesignLibraryClientEvents.d.ts.map +1 -0
- package/types/components/DesignLibrary/DesignLibraryErrorBoundary.d.ts +19 -0
- package/types/components/DesignLibrary/DesignLibraryErrorBoundary.d.ts.map +1 -0
- package/types/components/DesignLibrary/DesignLibraryServer.d.ts +38 -0
- package/types/components/DesignLibrary/DesignLibraryServer.d.ts.map +1 -0
- package/types/components/DesignLibrary/index.d.ts +3 -0
- package/types/components/DesignLibrary/index.d.ts.map +1 -0
- package/types/components/DesignLibrary/models.d.ts +67 -0
- package/types/components/DesignLibrary/models.d.ts.map +1 -0
- package/types/components/EditingScripts.d.ts +9 -7
- package/types/components/EditingScripts.d.ts.map +1 -0
- package/types/components/ErrorBoundary.d.ts +29 -17
- package/types/components/ErrorBoundary.d.ts.map +1 -0
- package/types/components/FEaaS/BYOCServerWrapper.d.ts +10 -3
- package/types/components/FEaaS/BYOCServerWrapper.d.ts.map +1 -0
- package/types/components/FEaaS/BYOCWrapper.d.ts +29 -25
- package/types/components/FEaaS/BYOCWrapper.d.ts.map +1 -0
- package/types/components/FEaaS/FEaaSSeverWrapper.d.ts +10 -8
- package/types/components/FEaaS/FEaaSSeverWrapper.d.ts.map +1 -0
- package/types/components/FEaaS/FEaaSWrapper.d.ts +14 -7
- package/types/components/FEaaS/FEaaSWrapper.d.ts.map +1 -0
- package/types/components/FEaaS/feaas-utils.d.ts +24 -21
- package/types/components/FEaaS/feaas-utils.d.ts.map +1 -0
- package/types/components/FEaaS/index.d.ts +7 -6
- package/types/components/FEaaS/index.d.ts.map +1 -0
- package/types/components/FEaaS/models.d.ts +136 -125
- package/types/components/FEaaS/models.d.ts.map +1 -0
- package/types/components/FieldMetadata.d.ts +18 -17
- package/types/components/FieldMetadata.d.ts.map +1 -0
- package/types/components/File.d.ts +28 -18
- package/types/components/File.d.ts.map +1 -0
- package/types/components/Form.d.ts +35 -29
- package/types/components/Form.d.ts.map +1 -0
- package/types/components/HiddenRendering.d.ts +3 -2
- package/types/components/HiddenRendering.d.ts.map +1 -0
- package/types/components/Image.d.ts +70 -48
- package/types/components/Image.d.ts.map +1 -0
- package/types/components/Link.d.ts +45 -27
- package/types/components/Link.d.ts.map +1 -0
- package/types/components/MissingComponent.d.ts +9 -8
- package/types/components/MissingComponent.d.ts.map +1 -0
- package/types/components/Placeholder/AppPlaceholder.d.ts +12 -10
- package/types/components/Placeholder/AppPlaceholder.d.ts.map +1 -0
- package/types/components/Placeholder/ClientComponentWrapper.d.ts +10 -9
- package/types/components/Placeholder/ClientComponentWrapper.d.ts.map +1 -0
- package/types/components/Placeholder/Placeholder.d.ts +33 -28
- package/types/components/Placeholder/Placeholder.d.ts.map +1 -0
- package/types/components/Placeholder/PlaceholderMetadata.d.ts +35 -28
- package/types/components/Placeholder/PlaceholderMetadata.d.ts.map +1 -0
- package/types/components/Placeholder/index.d.ts +6 -5
- package/types/components/Placeholder/index.d.ts.map +1 -0
- package/types/components/Placeholder/models.d.ts +149 -140
- package/types/components/Placeholder/models.d.ts.map +1 -0
- package/types/components/Placeholder/placeholder-utils.d.ts +52 -53
- package/types/components/Placeholder/placeholder-utils.d.ts.map +1 -0
- package/types/components/RichText.d.ts +31 -17
- package/types/components/RichText.d.ts.map +1 -0
- package/types/components/SitecoreProvider.d.ts +68 -48
- package/types/components/SitecoreProvider.d.ts.map +1 -0
- package/types/components/Text.d.ts +29 -20
- package/types/components/Text.d.ts.map +1 -0
- package/types/components/sharedTypes/components.d.ts +50 -38
- package/types/components/sharedTypes/components.d.ts.map +1 -0
- package/types/components/sharedTypes/index.d.ts +3 -2
- package/types/components/sharedTypes/index.d.ts.map +1 -0
- package/types/components/sharedTypes/props.d.ts +15 -14
- package/types/components/sharedTypes/props.d.ts.map +1 -0
- package/types/enhancers/withAppPlaceholder.d.ts +16 -15
- package/types/enhancers/withAppPlaceholder.d.ts.map +1 -0
- package/types/enhancers/withComponentMap.d.ts +13 -12
- package/types/enhancers/withComponentMap.d.ts.map +1 -0
- package/types/enhancers/withDatasourceCheck.d.ts +23 -21
- package/types/enhancers/withDatasourceCheck.d.ts.map +1 -0
- package/types/enhancers/withEditorChromes.d.ts +8 -2
- package/types/enhancers/withEditorChromes.d.ts.map +1 -0
- package/types/enhancers/withEmptyFieldEditingComponent.d.ts +29 -27
- package/types/enhancers/withEmptyFieldEditingComponent.d.ts.map +1 -0
- package/types/enhancers/withFieldMetadata.d.ts +18 -16
- package/types/enhancers/withFieldMetadata.d.ts.map +1 -0
- package/types/enhancers/withLoadImportMap.d.ts +22 -0
- package/types/enhancers/withLoadImportMap.d.ts.map +1 -0
- package/types/enhancers/withPlaceholder.d.ts +37 -35
- package/types/enhancers/withPlaceholder.d.ts.map +1 -0
- package/types/enhancers/withSitecore.d.ts +63 -48
- package/types/enhancers/withSitecore.d.ts.map +1 -0
- package/types/index.d.ts +31 -30
- package/types/index.d.ts.map +1 -0
- package/types/rsc-utils/no-rsc.d.ts +2 -1
- package/types/rsc-utils/no-rsc.d.ts.map +1 -0
- package/types/rsc-utils/rsc.d.ts +2 -1
- package/types/rsc-utils/rsc.d.ts.map +1 -0
- package/types/search/index.d.ts +4 -0
- package/types/search/index.d.ts.map +1 -0
- package/types/search/useInfiniteSearch.d.ts +116 -0
- package/types/search/useInfiniteSearch.d.ts.map +1 -0
- package/types/search/useSearch.d.ts +107 -0
- package/types/search/useSearch.d.ts.map +1 -0
- package/types/search/utils.d.ts +19 -0
- package/types/search/utils.d.ts.map +1 -0
- package/types/server-actions/update-server-component-action.d.ts +25 -0
- package/types/server-actions/update-server-component-action.d.ts.map +1 -0
- package/types/utils.d.ts +18 -17
- package/types/utils.d.ts.map +1 -0
- package/types/components/DesignLibrary.d.ts +0 -26
|
@@ -1,202 +1,161 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
'use client';
|
|
3
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
-
if (k2 === undefined) k2 = k;
|
|
5
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
-
}
|
|
9
|
-
Object.defineProperty(o, k2, desc);
|
|
10
|
-
}) : (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
o[k2] = m[k];
|
|
13
|
-
}));
|
|
14
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
-
}) : function(o, v) {
|
|
17
|
-
o["default"] = v;
|
|
18
|
-
});
|
|
19
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
-
var ownKeys = function(o) {
|
|
21
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
-
var ar = [];
|
|
23
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
-
return ar;
|
|
25
|
-
};
|
|
26
|
-
return ownKeys(o);
|
|
27
|
-
};
|
|
28
|
-
return function (mod) {
|
|
29
|
-
if (mod && mod.__esModule) return mod;
|
|
30
|
-
var result = {};
|
|
31
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
-
__setModuleDefault(result, mod);
|
|
33
|
-
return result;
|
|
34
|
-
};
|
|
35
|
-
})();
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
let unsubscribe;
|
|
163
|
-
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
164
|
-
if (!loadImportMap) {
|
|
165
|
-
sendErrorEvent(rendering.uid, 'No loadImportMap provided', codegen.DesignLibraryPreviewError.RenderInit);
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
let importMap;
|
|
169
|
-
try {
|
|
170
|
-
const mod = yield loadImportMap();
|
|
171
|
-
importMap = mod.default;
|
|
172
|
-
}
|
|
173
|
-
catch (e) {
|
|
174
|
-
sendErrorEvent(rendering.uid, `Error loading import map: ${e}`, codegen.DesignLibraryPreviewError.RenderInit);
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
// account for component being unmounted while resolving async import map
|
|
178
|
-
if (cancelled)
|
|
179
|
-
return;
|
|
180
|
-
unsubscribe = addComponentPreviewHandler(importMap, (error, Component) => {
|
|
181
|
-
// Error event is already sent in the addComponentPreviewHandler
|
|
182
|
-
if (error)
|
|
183
|
-
return;
|
|
184
|
-
setComponent(() => Component);
|
|
185
|
-
setRenderKey((k) => k + 1);
|
|
186
|
-
});
|
|
187
|
-
const importMapEvent = getDesignLibraryImportMapEvent(rendering.uid, importMap);
|
|
188
|
-
postToDL(importMapEvent);
|
|
189
|
-
const propsEvent = getDesignLibraryComponentPropsEvent(rendering.uid, propsState.fields, propsState.params);
|
|
190
|
-
postToDL(propsEvent);
|
|
191
|
-
}))();
|
|
192
|
-
// return function that calls unsubscribe - if the component was mounted correctly
|
|
193
|
-
return () => {
|
|
194
|
-
cancelled = true;
|
|
195
|
-
unsubscribe && unsubscribe();
|
|
196
|
-
};
|
|
197
|
-
}, [isVariantGeneration, rendering]);
|
|
198
|
-
return (react_1.default.createElement("main", null, isGeneratedComponentActive ? (react_1.default.createElement(ErrorBoundary, { uid: rendering.uid, renderKey: renderKey },
|
|
199
|
-
react_1.default.createElement(Placeholder_2.PlaceholderMetadata, { rendering: rendering },
|
|
200
|
-
react_1.default.createElement(Component, { fields: propsState.fields, params: propsState.params, key: renderKey })))) : (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 }))))));
|
|
201
|
-
};
|
|
202
|
-
exports.DesignLibrary = DesignLibrary;
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.DesignLibrary = exports.__mockDependencies = void 0;
|
|
38
|
+
/* eslint-disable jsdoc/require-param */
|
|
39
|
+
/* eslint-disable prefer-const */
|
|
40
|
+
const react_1 = __importStar(require("react"));
|
|
41
|
+
const layout_1 = require("@sitecore-content-sdk/core/layout");
|
|
42
|
+
const editing_1 = require("@sitecore-content-sdk/core/editing");
|
|
43
|
+
const codegen = __importStar(require("@sitecore-content-sdk/core/codegen"));
|
|
44
|
+
const editing = __importStar(require("@sitecore-content-sdk/core/editing"));
|
|
45
|
+
const withSitecore_1 = require("../../enhancers/withSitecore");
|
|
46
|
+
const Placeholder_1 = require("../Placeholder");
|
|
47
|
+
const DesignLibraryErrorBoundary_1 = require("./DesignLibraryErrorBoundary");
|
|
48
|
+
const withLoadImportMap_1 = require("../../enhancers/withLoadImportMap");
|
|
49
|
+
const ErrorBoundary_1 = require("../ErrorBoundary");
|
|
50
|
+
let { getDesignLibraryImportMapEvent, getDesignLibraryComponentPropsEvent, addComponentPreviewHandler, sendErrorEvent, } = codegen;
|
|
51
|
+
let { postToDesignLibrary } = editing;
|
|
52
|
+
const __mockDependencies = (mocks) => {
|
|
53
|
+
addComponentPreviewHandler = mocks.addComponentPreviewHandler;
|
|
54
|
+
if (mocks.postToDesignLibrary) {
|
|
55
|
+
postToDesignLibrary = mocks.postToDesignLibrary;
|
|
56
|
+
}
|
|
57
|
+
if (mocks.sendErrorEvent) {
|
|
58
|
+
sendErrorEvent = mocks.sendErrorEvent;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
exports.__mockDependencies = __mockDependencies;
|
|
62
|
+
/**
|
|
63
|
+
* Design Library component.
|
|
64
|
+
*
|
|
65
|
+
* Renders the **real** Sitecore component for `library` / `library-metadata` modes and,
|
|
66
|
+
* when generation is enabled (`page.mode.designLibrary.isVariantGeneration === true`),
|
|
67
|
+
* wires the **variant generation** handshake so the parent (DL Studio) can send
|
|
68
|
+
* generated code to preview and iterate on.
|
|
69
|
+
* @param {DesignLibraryProps} props
|
|
70
|
+
* @param {() => Promise} [props.loadImportMap] Optional async loader that resolves to the import-map used to resolve the generated component’s imports. Required when `isVariantGeneration` is true.
|
|
71
|
+
* @returns {JSX.Element} The preview surface, or `null` when not in Design Library mode.
|
|
72
|
+
* @public
|
|
73
|
+
*/
|
|
74
|
+
exports.DesignLibrary = (0, withLoadImportMap_1.withLoadImportMap)(({ loadImportMap }) => {
|
|
75
|
+
var _a, _b;
|
|
76
|
+
const { page } = (0, withSitecore_1.useSitecore)();
|
|
77
|
+
const route = page.layout.sitecore.route;
|
|
78
|
+
const rendering = (_a = route === null || route === void 0 ? void 0 : route.placeholders[layout_1.EDITING_COMPONENT_PLACEHOLDER]) === null || _a === void 0 ? void 0 : _a[0];
|
|
79
|
+
const uid = rendering === null || rendering === void 0 ? void 0 : rendering.uid;
|
|
80
|
+
const { isDesignLibrary } = page.mode;
|
|
81
|
+
const isVariantGeneration = (_b = page.mode.designLibrary) === null || _b === void 0 ? void 0 : _b.isVariantGeneration;
|
|
82
|
+
const [propsState, setPropsState] = (0, react_1.useState)({
|
|
83
|
+
fields: rendering === null || rendering === void 0 ? void 0 : rendering.fields,
|
|
84
|
+
params: rendering === null || rendering === void 0 ? void 0 : rendering.params,
|
|
85
|
+
});
|
|
86
|
+
const [renderKey, setRenderKey] = (0, react_1.useState)(0);
|
|
87
|
+
const [Component, setComponent] = (0, react_1.useState)(null);
|
|
88
|
+
const isGeneratedComponentActive = !!Component;
|
|
89
|
+
if (!isDesignLibrary)
|
|
90
|
+
return null;
|
|
91
|
+
if (!uid)
|
|
92
|
+
return react_1.default.createElement(ErrorBoundary_1.ErrorComponent, { message: "Rendering UID is missing in the rendering data" });
|
|
93
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
94
|
+
(0, react_1.useEffect)(() => {
|
|
95
|
+
postToDesignLibrary((0, editing_1.getDesignLibraryStatusEvent)(editing_1.DesignLibraryStatus.READY, uid));
|
|
96
|
+
if (!isVariantGeneration) {
|
|
97
|
+
requestAnimationFrame(() => {
|
|
98
|
+
setRenderKey((k) => (k === 0 ? k + 1 : k));
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
const unsubUpdate = (0, editing_1.addComponentUpdateHandler)(rendering, (updated) => {
|
|
102
|
+
setPropsState({ fields: updated.fields, params: updated.params });
|
|
103
|
+
setRenderKey((k) => k + 1);
|
|
104
|
+
});
|
|
105
|
+
// useEffect will cleanup event handler on re-render
|
|
106
|
+
return () => unsubUpdate && unsubUpdate();
|
|
107
|
+
}, [isVariantGeneration, rendering, uid]);
|
|
108
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
109
|
+
(0, react_1.useEffect)(() => {
|
|
110
|
+
// Send a rendered event only as effect of a component update command
|
|
111
|
+
if (renderKey === 0)
|
|
112
|
+
return;
|
|
113
|
+
postToDesignLibrary((0, editing_1.getDesignLibraryStatusEvent)(editing_1.DesignLibraryStatus.RENDERED, uid));
|
|
114
|
+
}, [renderKey, uid]);
|
|
115
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
116
|
+
(0, react_1.useEffect)(() => {
|
|
117
|
+
if (!isDesignLibrary || !isVariantGeneration)
|
|
118
|
+
return;
|
|
119
|
+
let cancelled = false;
|
|
120
|
+
// since import map is loaded lazily, we only need to add preview event handler once the import map is loaded
|
|
121
|
+
// unsubscribe function for useEffect cleanup will also be returned once importMap promise has been resolved or rejected
|
|
122
|
+
let unsubscribe;
|
|
123
|
+
(async () => {
|
|
124
|
+
if (!loadImportMap) {
|
|
125
|
+
sendErrorEvent(uid, 'No loadImportMap provided', codegen.DesignLibraryPreviewError.RenderInit);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
let importMap;
|
|
129
|
+
try {
|
|
130
|
+
const mod = await loadImportMap();
|
|
131
|
+
importMap = mod.default;
|
|
132
|
+
}
|
|
133
|
+
catch (e) {
|
|
134
|
+
sendErrorEvent(uid, `Error loading import map: ${e}`, codegen.DesignLibraryPreviewError.RenderInit);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
// account for component being unmounted while resolving async import map
|
|
138
|
+
if (cancelled)
|
|
139
|
+
return;
|
|
140
|
+
unsubscribe = addComponentPreviewHandler(importMap, (error, Component) => {
|
|
141
|
+
// Error event is already sent in the addComponentPreviewHandler
|
|
142
|
+
if (error)
|
|
143
|
+
return;
|
|
144
|
+
setComponent(() => Component);
|
|
145
|
+
setRenderKey((k) => k + 1);
|
|
146
|
+
});
|
|
147
|
+
const importMapEvent = getDesignLibraryImportMapEvent(uid, importMap);
|
|
148
|
+
postToDesignLibrary(importMapEvent);
|
|
149
|
+
const propsEvent = getDesignLibraryComponentPropsEvent(uid, propsState.fields, propsState.params);
|
|
150
|
+
postToDesignLibrary(propsEvent);
|
|
151
|
+
})();
|
|
152
|
+
// return function that calls unsubscribe - if the component was mounted correctly
|
|
153
|
+
return () => {
|
|
154
|
+
cancelled = true;
|
|
155
|
+
unsubscribe && unsubscribe();
|
|
156
|
+
};
|
|
157
|
+
}, [isVariantGeneration, uid]);
|
|
158
|
+
return (react_1.default.createElement("main", null, isGeneratedComponentActive ? (react_1.default.createElement(DesignLibraryErrorBoundary_1.DesignLibraryErrorBoundary, { uid: uid, renderKey: renderKey },
|
|
159
|
+
react_1.default.createElement(Placeholder_1.PlaceholderMetadata, { rendering: rendering },
|
|
160
|
+
react_1.default.createElement(Component, { fields: propsState.fields, params: propsState.params, key: renderKey })))) : (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 }))))));
|
|
161
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.DesignLibraryApp = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const layout_1 = require("@sitecore-content-sdk/core/layout");
|
|
9
|
+
const DesignLibraryServer_1 = require("./DesignLibraryServer");
|
|
10
|
+
const DesignLibrary_1 = require("./DesignLibrary");
|
|
11
|
+
/**
|
|
12
|
+
* Design Library component intended to be used by the NextJs app router application
|
|
13
|
+
* This component serves as a router between client and server component rendering modes for the Design Library.
|
|
14
|
+
* It inspects the component type from the component map and
|
|
15
|
+
* delegates to the appropriate rendering implementation:
|
|
16
|
+
* - Client components are rendered using the `DesignLibrary` component
|
|
17
|
+
* - Server components are rendered using the `DesignLibraryServer` component
|
|
18
|
+
* @param {DesingLibraryAppProps} props - The properties for the Design Library App.
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
const DesignLibraryApp = ({ page, componentMap, loadServerImportMap, }) => {
|
|
22
|
+
var _a;
|
|
23
|
+
const { route } = page.layout.sitecore;
|
|
24
|
+
if (!route)
|
|
25
|
+
return null;
|
|
26
|
+
const rendering = (_a = route === null || route === void 0 ? void 0 : route.placeholders[layout_1.EDITING_COMPONENT_PLACEHOLDER]) === null || _a === void 0 ? void 0 : _a[0];
|
|
27
|
+
const component = componentMap.get((rendering === null || rendering === void 0 ? void 0 : rendering.componentName) || '');
|
|
28
|
+
const isClient = component && component.componentType === 'client';
|
|
29
|
+
return (react_1.default.createElement(react_1.default.Fragment, null, isClient ? (react_1.default.createElement(DesignLibrary_1.DesignLibrary, null)) : (react_1.default.createElement(DesignLibraryServer_1.DesignLibraryServer, { page: page, componentMap: componentMap, loadServerImportMap: loadServerImportMap, rendering: route }))));
|
|
30
|
+
};
|
|
31
|
+
exports.DesignLibraryApp = DesignLibraryApp;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.DesignLibraryVariantGenerationEvents = exports.DesignLibraryPreviewEvents = exports.__mockDependencies = void 0;
|
|
38
|
+
const react_1 = __importStar(require("react"));
|
|
39
|
+
const dlHelpers = __importStar(require("@sitecore-content-sdk/core/editing"));
|
|
40
|
+
const codegen = __importStar(require("@sitecore-content-sdk/core/codegen"));
|
|
41
|
+
const update_server_component_action_1 = require("../../server-actions/update-server-component-action");
|
|
42
|
+
let { getDesignLibraryComponentPropsEvent, addServerComponentPreviewHandler, getDesignLibraryImportMapEvent, addStyleElement, sendErrorEvent, } = codegen;
|
|
43
|
+
let { getDesignLibraryStatusEvent, addComponentUpdateHandler, postToDesignLibrary } = dlHelpers;
|
|
44
|
+
let _updateServerComponentAction = update_server_component_action_1.updateServerComponentAction;
|
|
45
|
+
const __mockDependencies = (mocks) => {
|
|
46
|
+
postToDesignLibrary = mocks.postToDesignLibrary;
|
|
47
|
+
addComponentUpdateHandler = mocks.addComponentUpdateHandler;
|
|
48
|
+
_updateServerComponentAction = mocks.updateServerComponentAction;
|
|
49
|
+
addServerComponentPreviewHandler = mocks.addServerComponentPreviewHandler;
|
|
50
|
+
getDesignLibraryImportMapEvent = mocks.getDesignLibraryImportMapEvent;
|
|
51
|
+
getDesignLibraryComponentPropsEvent = mocks.getDesignLibraryComponentPropsEvent;
|
|
52
|
+
addStyleElement = mocks.addStyleElement;
|
|
53
|
+
sendErrorEvent = mocks.sendErrorEvent;
|
|
54
|
+
};
|
|
55
|
+
exports.__mockDependencies = __mockDependencies;
|
|
56
|
+
/**
|
|
57
|
+
* Design Library component for rendering server components in app router application.
|
|
58
|
+
* DesignLibraryPreviewEvents component serves as a communication bridge between DesignLibraryServer and the Design Studio on the client side.
|
|
59
|
+
* It posts messages to Design Library Studio and sets up handlers to receive updates and previews which are then passed to the server component via server function updateServerComponentAction.
|
|
60
|
+
* @param {DesignLibraryPreviewEventsProps} props The props. {@link DesignLibraryPreviewEventsProps}
|
|
61
|
+
* @returns {JSX.Element} empty JSX element.
|
|
62
|
+
*/
|
|
63
|
+
const DesignLibraryPreviewEvents = ({ designLibraryStatus, component, }) => {
|
|
64
|
+
(0, react_1.useEffect)(() => {
|
|
65
|
+
if (!(component === null || component === void 0 ? void 0 : component.uid))
|
|
66
|
+
return;
|
|
67
|
+
postToDesignLibrary(getDesignLibraryStatusEvent(designLibraryStatus, component.uid));
|
|
68
|
+
const unsubUpdate = addComponentUpdateHandler(component, (updated) => {
|
|
69
|
+
_updateServerComponentAction({ uid: updated.uid, updatedComponent: updated });
|
|
70
|
+
});
|
|
71
|
+
return () => {
|
|
72
|
+
unsubUpdate && unsubUpdate();
|
|
73
|
+
};
|
|
74
|
+
}, [component, designLibraryStatus]);
|
|
75
|
+
return react_1.default.createElement(react_1.default.Fragment, null);
|
|
76
|
+
};
|
|
77
|
+
exports.DesignLibraryPreviewEvents = DesignLibraryPreviewEvents;
|
|
78
|
+
/**
|
|
79
|
+
* Design Library component for rendering server components in app router application.
|
|
80
|
+
* DesignLibraryVariantGenerationEvents component serves as a communication bridge between DesignLibraryServer and the Design Studio on the client side in variant generation mode.
|
|
81
|
+
* It posts messages to Design Library Studio and sets up handlers to receive updates and previews which are then passed to the server component via server function updateServerComponentAction.
|
|
82
|
+
* If the import map is not present then the import map error will be sent to Design Studio.
|
|
83
|
+
* @param {DesignLibraryVariantGenerationEventsProps} props The props. {@link DesignLibraryVariantGenerationEventsProps}
|
|
84
|
+
* @returns {JSX.Element} empty JSX element.
|
|
85
|
+
*/
|
|
86
|
+
const DesignLibraryVariantGenerationEvents = ({ designLibraryStatus, component, importMap, importMapError, previewComponentData, }) => {
|
|
87
|
+
(0, react_1.useEffect)(() => {
|
|
88
|
+
var _a, _b;
|
|
89
|
+
if (!(component === null || component === void 0 ? void 0 : component.uid))
|
|
90
|
+
return;
|
|
91
|
+
postToDesignLibrary(getDesignLibraryStatusEvent(designLibraryStatus, component.uid));
|
|
92
|
+
const unsubUpdate = addComponentUpdateHandler(component, (updated) => {
|
|
93
|
+
_updateServerComponentAction({
|
|
94
|
+
uid: updated.uid,
|
|
95
|
+
updatedComponent: updated,
|
|
96
|
+
previewComponent: previewComponentData,
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
const unsubPreview = addServerComponentPreviewHandler((eventArgs) => {
|
|
100
|
+
_updateServerComponentAction({ uid: component.uid, previewComponent: eventArgs });
|
|
101
|
+
});
|
|
102
|
+
if (importMapError) {
|
|
103
|
+
// an import map error occurred on the server side in DesignLibraryServer, post error event to Design Studio
|
|
104
|
+
sendErrorEvent(component.uid, importMapError, codegen.DesignLibraryPreviewError.RenderInit);
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
const importMapEvent = getDesignLibraryImportMapEvent(component.uid, importMap);
|
|
108
|
+
postToDesignLibrary(importMapEvent);
|
|
109
|
+
const propsEvent = getDesignLibraryComponentPropsEvent(component.uid, component.fields, component.params);
|
|
110
|
+
postToDesignLibrary(propsEvent);
|
|
111
|
+
if ((_b = (_a = previewComponentData === null || previewComponentData === void 0 ? void 0 : previewComponentData.message) === null || _a === void 0 ? void 0 : _a.styles) === null || _b === void 0 ? void 0 : _b.content) {
|
|
112
|
+
// the generated component has custom styles, so add the css in style element and add it to document head
|
|
113
|
+
addStyleElement(previewComponentData.message.styles.content);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return () => {
|
|
117
|
+
unsubUpdate && unsubUpdate();
|
|
118
|
+
unsubPreview && unsubPreview();
|
|
119
|
+
};
|
|
120
|
+
}, [component, designLibraryStatus, importMap, importMapError, previewComponentData]);
|
|
121
|
+
return react_1.default.createElement(react_1.default.Fragment, null);
|
|
122
|
+
};
|
|
123
|
+
exports.DesignLibraryVariantGenerationEvents = DesignLibraryVariantGenerationEvents;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.DesignLibraryErrorBoundary = void 0;
|
|
38
|
+
const react_1 = __importStar(require("react"));
|
|
39
|
+
const codegen_1 = require("@sitecore-content-sdk/core/codegen");
|
|
40
|
+
class DesignLibraryErrorBoundary extends react_1.default.Component {
|
|
41
|
+
constructor() {
|
|
42
|
+
super(...arguments);
|
|
43
|
+
this.state = {
|
|
44
|
+
hasError: false,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
static getDerivedStateFromError() {
|
|
48
|
+
return { hasError: true };
|
|
49
|
+
}
|
|
50
|
+
componentDidUpdate(prevProps) {
|
|
51
|
+
if (prevProps.renderKey !== this.props.renderKey) {
|
|
52
|
+
this.setState({ hasError: false });
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
componentDidCatch(error) {
|
|
56
|
+
(0, codegen_1.sendErrorEvent)(this.props.uid, error, codegen_1.DesignLibraryPreviewError.Render);
|
|
57
|
+
}
|
|
58
|
+
render() {
|
|
59
|
+
if (this.state.hasError) {
|
|
60
|
+
return react_1.default.createElement("div", null, "Error during component rendering");
|
|
61
|
+
}
|
|
62
|
+
return react_1.default.createElement(react_1.Suspense, null, this.props.children);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.DesignLibraryErrorBoundary = DesignLibraryErrorBoundary;
|