@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,27 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var _a, _b;
|
|
21
|
-
const params = ((_a = props.rendering) === null || _a === void 0 ? void 0 : _a.params) || {};
|
|
22
|
-
const isPageStateNormal = (_b = props.page) === null || _b === void 0 ? void 0 : _b.mode.isNormal;
|
|
23
|
-
// only pass serializable props to the client FEaaS component
|
|
24
|
-
const serializableProps = Object.fromEntries(Object.entries(props).filter(([key]) => !nonSerializedPlaceholderProps.includes(key)));
|
|
25
|
-
const finalProps = Object.assign(Object.assign({}, (yield fetchFEaaSComponentServerProps(params, isPageStateNormal))), serializableProps);
|
|
26
|
-
return React.createElement(FEaaSWrapper, Object.assign({}, finalProps));
|
|
27
|
-
});
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { fetchFEaaSComponentServerProps } from './feaas-utils';
|
|
3
|
+
import { FEaaSWrapper } from './FEaaSWrapper';
|
|
4
|
+
import { nonSerializedPlaceholderProps } from '../Placeholder/models';
|
|
5
|
+
/**
|
|
6
|
+
* Server component for FEaaS. Retrieves server props and renders client FEaaSWrapper.
|
|
7
|
+
* @param {FEaaSComponentProps} props incoming props
|
|
8
|
+
* @returns rendered FEaaSWrapper component
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export const FEaaSServerWrapper = async (props) => {
|
|
12
|
+
var _a, _b;
|
|
13
|
+
const params = ((_a = props.rendering) === null || _a === void 0 ? void 0 : _a.params) || {};
|
|
14
|
+
const isPageStateNormal = (_b = props.page) === null || _b === void 0 ? void 0 : _b.mode.isNormal;
|
|
15
|
+
// only pass serializable props to the client FEaaS component
|
|
16
|
+
const serializableProps = Object.fromEntries(Object.entries(props).filter(([key]) => !nonSerializedPlaceholderProps.includes(key)));
|
|
17
|
+
const finalProps = Object.assign(Object.assign({}, (await fetchFEaaSComponentServerProps(params, isPageStateNormal))), serializableProps);
|
|
18
|
+
return React.createElement(FEaaSWrapper, Object.assign({}, finalProps));
|
|
19
|
+
};
|
|
@@ -1,37 +1,43 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import * as FEAAS from '@sitecore-feaas/clientside/react';
|
|
4
|
-
import { getDataFromFields } from '../../utils';
|
|
5
|
-
// FEaaSComponent remains for backward compatibility and testing purposes
|
|
6
|
-
/**
|
|
7
|
-
* @param {FEaaSComponentProps} props component props
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
!props.params.
|
|
16
|
-
!props.params.
|
|
17
|
-
!props.params.
|
|
18
|
-
!
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
//
|
|
26
|
-
//
|
|
27
|
-
//
|
|
28
|
-
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
1
|
+
'use client';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import * as FEAAS from '@sitecore-feaas/clientside/react';
|
|
4
|
+
import { getDataFromFields } from '../../utils';
|
|
5
|
+
// FEaaSComponent remains for backward compatibility and testing purposes
|
|
6
|
+
/**
|
|
7
|
+
* @param {FEaaSComponentProps} props component props
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export const FEaaSComponent = (props) => {
|
|
11
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
12
|
+
const computedRevision = ((_a = props.params) === null || _a === void 0 ? void 0 : _a.ComponentRevision) || props.revisionFallback;
|
|
13
|
+
if (!props.template &&
|
|
14
|
+
(!props.params ||
|
|
15
|
+
!props.params.LibraryId ||
|
|
16
|
+
!props.params.ComponentId ||
|
|
17
|
+
!props.params.ComponentVersion ||
|
|
18
|
+
!props.params.ComponentHostName ||
|
|
19
|
+
!computedRevision)) {
|
|
20
|
+
// Missing FEaaS component required props
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
// combine fetchedData from server with datasource data (if present)
|
|
24
|
+
const data = Object.assign(Object.assign({}, props.fetchedData), { _: getDataFromFields((_b = props.fields) !== null && _b !== void 0 ? _b : {}) });
|
|
25
|
+
// FEaaS control would still be hydrated by client
|
|
26
|
+
// we pass all the props as a workaround to avoid hydration error, until we convert all Content SDK components to server side
|
|
27
|
+
// this also allows component to fall back to full client-side rendering when template or src is empty
|
|
28
|
+
// FEAAS should not fetch anything, since Content SDK does the fetching - so we pass empty array into fetch param
|
|
29
|
+
return (React.createElement(FEAAS.Component, { data: data, template: props.template, cdn: (_c = props.params) === null || _c === void 0 ? void 0 : _c.ComponentHostName, library: (_e = (_d = props.params) === null || _d === void 0 ? void 0 : _d.LibraryId) !== null && _e !== void 0 ? _e : '', version: (_f = props.params) === null || _f === void 0 ? void 0 : _f.ComponentVersion, component: (_h = (_g = props.params) === null || _g === void 0 ? void 0 : _g.ComponentId) !== null && _h !== void 0 ? _h : '', instance: (_j = props.params) === null || _j === void 0 ? void 0 : _j.ComponentInstanceId, revision: computedRevision, fetch: [] }));
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* The FEaaSWrapper component.
|
|
33
|
+
* @param {FEaaSComponentProps} props component props
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
export const FEaaSWrapper = (props) => {
|
|
37
|
+
var _a, _b;
|
|
38
|
+
const styles = `component feaas ${(_a = props.params) === null || _a === void 0 ? void 0 : _a.styles}`.trimEnd();
|
|
39
|
+
const id = (_b = props.params) === null || _b === void 0 ? void 0 : _b.RenderingIdentifier;
|
|
40
|
+
return (React.createElement("div", { className: styles, id: id ? id : undefined },
|
|
41
|
+
React.createElement("div", { className: "component-content" },
|
|
42
|
+
React.createElement(FEaaSComponent, Object.assign({}, props)))));
|
|
43
|
+
};
|
|
@@ -1,105 +1,91 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
* Build component endpoint URL from component's params
|
|
95
|
-
* @param {FEaaSComponentParams} params rendering parameters for FEAAS component
|
|
96
|
-
* @param {RevisionType} revisionFallback fallback revision to fetch if revision is absent in params
|
|
97
|
-
* @returns component endpoint URL
|
|
98
|
-
*/
|
|
99
|
-
export const composeComponentEndpoint = (params, revisionFallback) => {
|
|
100
|
-
const revision = params.ComponentRevision || revisionFallback;
|
|
101
|
-
const hostname = params.ComponentHostName.startsWith('https://')
|
|
102
|
-
? params.ComponentHostName
|
|
103
|
-
: `https://${params.ComponentHostName}`;
|
|
104
|
-
return `${hostname}/components/${params.LibraryId}/${params.ComponentId}/${params.ComponentVersion}/${revision}`;
|
|
105
|
-
};
|
|
1
|
+
import * as FEAAS from '@sitecore-feaas/clientside/react';
|
|
2
|
+
/**
|
|
3
|
+
* Fetches server component props required for server rendering, based on rendering params.
|
|
4
|
+
* @param {BYOCComponentParams} params component params
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export async function fetchBYOCComponentServerProps(params) {
|
|
8
|
+
const fetchDataOptions = params.ComponentDataOverride
|
|
9
|
+
? JSON.parse(params.ComponentDataOverride)
|
|
10
|
+
: {};
|
|
11
|
+
const fetchedData = await FEAAS.DataSettings.fetch(fetchDataOptions || {});
|
|
12
|
+
return {
|
|
13
|
+
fetchedData,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Fetches server component props required for server rendering, based on rendering params.
|
|
18
|
+
* Component endpoint will either be retrieved from params or from endpointOverride
|
|
19
|
+
* @param {FEaaSComponentParams} params component params
|
|
20
|
+
* @param {boolean} [isPageStateNormal] whether page is in normal mode
|
|
21
|
+
* @param {string} [endpointOverride] optional override for component endpoint
|
|
22
|
+
* @public
|
|
23
|
+
*/
|
|
24
|
+
export async function fetchFEaaSComponentServerProps(params, isPageStateNormal, endpointOverride) {
|
|
25
|
+
const revisionFallback = isPageStateNormal ? 'published' : 'staged';
|
|
26
|
+
const src = endpointOverride || composeComponentEndpoint(params, revisionFallback);
|
|
27
|
+
let template = '';
|
|
28
|
+
let fetchedData = {};
|
|
29
|
+
const fetchDataOptions = params.ComponentDataOverride
|
|
30
|
+
? JSON.parse(params.ComponentDataOverride)
|
|
31
|
+
: {};
|
|
32
|
+
try {
|
|
33
|
+
template = await fetchComponentTemplate(src, params, revisionFallback);
|
|
34
|
+
fetchedData = await fetchData(fetchDataOptions);
|
|
35
|
+
}
|
|
36
|
+
catch (e) {
|
|
37
|
+
console.error(e);
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
fetchedData,
|
|
41
|
+
revisionFallback,
|
|
42
|
+
template,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* @param {string} src component endpoint
|
|
47
|
+
* @param {FEaaSComponentParams} params rendering parameters for FEAAS component
|
|
48
|
+
* @param {RevisionType} revisionFallback fallback revision to fetch if revision is absent in params
|
|
49
|
+
*/
|
|
50
|
+
async function fetchComponentTemplate(src, params, revisionFallback) {
|
|
51
|
+
try {
|
|
52
|
+
const { template } = await FEAAS.fetchComponent(src);
|
|
53
|
+
return template;
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
console.error(`Fetch FEAAS component from ${src} failed. Ensure the component revision "${params.ComponentRevision || revisionFallback}" is present`);
|
|
57
|
+
throw error;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Fetches component data based on the provided data options.
|
|
62
|
+
* This function asynchronously fetches data using the FEAAS.DataSettings.fetch method.
|
|
63
|
+
* @param {FEAAS.DataOptions} dataOptions - Options to customize data fetching.
|
|
64
|
+
* @returns {Promise<FEAAS.DataScopes>} A promise that resolves with the fetched data,
|
|
65
|
+
* or rejects with an error if data fetching encounters an issue.
|
|
66
|
+
* @throws {Error} If an error occurs during data fetching, it is propagated as an error.
|
|
67
|
+
*/
|
|
68
|
+
async function fetchData(dataOptions) {
|
|
69
|
+
try {
|
|
70
|
+
const fetchedData = await FEAAS.DataSettings.fetch(dataOptions || {});
|
|
71
|
+
return fetchedData;
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
console.error('Fetch FEAAS component data settings failed');
|
|
75
|
+
throw error;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Build component endpoint URL from component's params
|
|
80
|
+
* @param {FEaaSComponentParams} params rendering parameters for FEAAS component
|
|
81
|
+
* @param {RevisionType} revisionFallback fallback revision to fetch if revision is absent in params
|
|
82
|
+
* @returns component endpoint URL
|
|
83
|
+
*/
|
|
84
|
+
export const composeComponentEndpoint = (params, revisionFallback) => {
|
|
85
|
+
var _a;
|
|
86
|
+
const revision = params.ComponentRevision || revisionFallback;
|
|
87
|
+
const hostname = ((_a = params.ComponentHostName) === null || _a === void 0 ? void 0 : _a.startsWith('https://'))
|
|
88
|
+
? params.ComponentHostName
|
|
89
|
+
: `https://${params.ComponentHostName}`;
|
|
90
|
+
return `${hostname}/components/${params.LibraryId}/${params.ComponentId}/${params.ComponentVersion}/${revision}`;
|
|
91
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { FEaaSWrapper, FEaaSComponent } from './FEaaSWrapper';
|
|
2
|
-
export { BYOCWrapper, BYOCComponent } from './BYOCWrapper';
|
|
3
|
-
export { FEAAS_COMPONENT_RENDERING_NAME, BYOC_COMPONENT_RENDERING_NAME, FEAAS_WRAPPER_RENDERING_NAME, BYOC_WRAPPER_RENDERING_NAME, } from './models';
|
|
4
|
-
export { FEaaSServerWrapper } from './FEaaSSeverWrapper';
|
|
5
|
-
export { BYOCServerWrapper } from './BYOCServerWrapper';
|
|
6
|
-
export { fetchFEaaSComponentServerProps, fetchBYOCComponentServerProps } from './feaas-utils';
|
|
1
|
+
export { FEaaSWrapper, FEaaSComponent } from './FEaaSWrapper';
|
|
2
|
+
export { BYOCWrapper, BYOCComponent } from './BYOCWrapper';
|
|
3
|
+
export { FEAAS_COMPONENT_RENDERING_NAME, BYOC_COMPONENT_RENDERING_NAME, FEAAS_WRAPPER_RENDERING_NAME, BYOC_WRAPPER_RENDERING_NAME, } from './models';
|
|
4
|
+
export { FEaaSServerWrapper } from './FEaaSSeverWrapper';
|
|
5
|
+
export { BYOCServerWrapper } from './BYOCServerWrapper';
|
|
6
|
+
export { fetchFEaaSComponentServerProps, fetchBYOCComponentServerProps } from './feaas-utils';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const FEAAS_WRAPPER_RENDERING_NAME = 'FEaaSWrapper';
|
|
2
|
-
export const FEAAS_COMPONENT_RENDERING_NAME = 'FEaaSComponent';
|
|
3
|
-
export const BYOC_WRAPPER_RENDERING_NAME = 'BYOCWrapper';
|
|
4
|
-
export const BYOC_COMPONENT_RENDERING_NAME = 'BYOCComponent';
|
|
1
|
+
export const FEAAS_WRAPPER_RENDERING_NAME = 'FEaaSWrapper';
|
|
2
|
+
export const FEAAS_COMPONENT_RENDERING_NAME = 'FEaaSComponent';
|
|
3
|
+
export const BYOC_WRAPPER_RENDERING_NAME = 'BYOCWrapper';
|
|
4
|
+
export const BYOC_COMPONENT_RENDERING_NAME = 'BYOCComponent';
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { MetadataKind } from '@sitecore-content-sdk/core/editing';
|
|
3
|
-
/**
|
|
4
|
-
* The component which renders field metadata markup
|
|
5
|
-
* @param {FieldMetadataProps} props the props of the component
|
|
6
|
-
* @returns metadata markup wrapped around children
|
|
7
|
-
*/
|
|
8
|
-
export const FieldMetadata = (props) => {
|
|
9
|
-
const data = JSON.stringify(props.metadata);
|
|
10
|
-
const attributes = {
|
|
11
|
-
type: 'text/sitecore',
|
|
12
|
-
chrometype: 'field',
|
|
13
|
-
className: 'scpm',
|
|
14
|
-
};
|
|
15
|
-
const codeOpenAttributes = Object.assign(Object.assign({}, attributes), { kind: MetadataKind.Open });
|
|
16
|
-
const codeCloseAttributes = Object.assign(Object.assign({}, attributes), { kind: MetadataKind.Close });
|
|
17
|
-
return (React.createElement(React.Fragment, null,
|
|
18
|
-
React.createElement("code", Object.assign({}, codeOpenAttributes), data),
|
|
19
|
-
props.children,
|
|
20
|
-
React.createElement("code", Object.assign({}, codeCloseAttributes))));
|
|
21
|
-
};
|
|
22
|
-
FieldMetadata.displayName = 'FieldMetadata';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MetadataKind } from '@sitecore-content-sdk/core/editing';
|
|
3
|
+
/**
|
|
4
|
+
* The component which renders field metadata markup
|
|
5
|
+
* @param {FieldMetadataProps} props the props of the component
|
|
6
|
+
* @returns metadata markup wrapped around children
|
|
7
|
+
*/
|
|
8
|
+
export const FieldMetadata = (props) => {
|
|
9
|
+
const data = JSON.stringify(props.metadata);
|
|
10
|
+
const attributes = {
|
|
11
|
+
type: 'text/sitecore',
|
|
12
|
+
chrometype: 'field',
|
|
13
|
+
className: 'scpm',
|
|
14
|
+
};
|
|
15
|
+
const codeOpenAttributes = Object.assign(Object.assign({}, attributes), { kind: MetadataKind.Open });
|
|
16
|
+
const codeCloseAttributes = Object.assign(Object.assign({}, attributes), { kind: MetadataKind.Close });
|
|
17
|
+
return (React.createElement(React.Fragment, null,
|
|
18
|
+
React.createElement("code", Object.assign({}, codeOpenAttributes), data),
|
|
19
|
+
props.children,
|
|
20
|
+
React.createElement("code", Object.assign({}, codeCloseAttributes))));
|
|
21
|
+
};
|
|
22
|
+
FieldMetadata.displayName = 'FieldMetadata';
|
|
@@ -1,31 +1,36 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
import { isFieldValueEmpty } from '@sitecore-content-sdk/core/layout';
|
|
13
|
-
import React from 'react';
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
if (
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { isFieldValueEmpty } from '@sitecore-content-sdk/core/layout';
|
|
13
|
+
import React from 'react';
|
|
14
|
+
/**
|
|
15
|
+
* The File component.
|
|
16
|
+
* @param {FileProps} props component props
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
export const File = (_a) => {
|
|
20
|
+
var { field, children } = _a, otherProps = __rest(_a, ["field", "children"]);
|
|
21
|
+
const dynamicField = field;
|
|
22
|
+
if (isFieldValueEmpty(dynamicField)) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
// handle link directly on field for forgetful devs
|
|
26
|
+
const file = (dynamicField.src ? field : dynamicField.value);
|
|
27
|
+
if (!file) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
const linkText = !children ? file.title || file.displayName : null;
|
|
31
|
+
const anchorAttrs = {
|
|
32
|
+
href: file.src,
|
|
33
|
+
};
|
|
34
|
+
return React.createElement('a', Object.assign(Object.assign({}, anchorAttrs), otherProps), linkText, children);
|
|
35
|
+
};
|
|
36
|
+
File.displayName = 'File';
|
|
@@ -1,54 +1,62 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import React, { useEffect, useRef, useState } from 'react';
|
|
3
|
-
import { form } from '@sitecore-content-sdk/core';
|
|
4
|
-
import { useSitecore } from '../enhancers/withSitecore';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
1
|
+
'use client';
|
|
2
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { form } from '@sitecore-content-sdk/core';
|
|
4
|
+
import { useSitecore } from '../enhancers/withSitecore';
|
|
5
|
+
import { ErrorComponent } from './ErrorBoundary';
|
|
6
|
+
let { executeScriptElements, loadForm, subscribeToFormSubmitEvent } = form;
|
|
7
|
+
/**
|
|
8
|
+
* Mock function to replace the form module functions for `testing` purposes.
|
|
9
|
+
* @param {any} formModule - The form module to mock
|
|
10
|
+
*/
|
|
11
|
+
export const mockFormModule = (formModule) => {
|
|
12
|
+
executeScriptElements = formModule.executeScriptElements;
|
|
13
|
+
loadForm = formModule.loadForm;
|
|
14
|
+
subscribeToFormSubmitEvent = formModule.subscribeToFormSubmitEvent;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* The Form component.
|
|
18
|
+
* @param {FormProps} props incoming props
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
export const Form = ({ params, rendering }) => {
|
|
22
|
+
var _a;
|
|
23
|
+
const id = params === null || params === void 0 ? void 0 : params.RenderingIdentifier;
|
|
24
|
+
const [error, setError] = useState(false);
|
|
25
|
+
const [content, setContent] = useState('');
|
|
26
|
+
const context = useSitecore();
|
|
27
|
+
const formRef = useRef(null);
|
|
28
|
+
const isEditing = context.page.mode.isEditing;
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
var _a, _b, _c, _d;
|
|
31
|
+
if (!content) {
|
|
32
|
+
// Forms must use clientContextId since they are rendered client-side
|
|
33
|
+
const edgeId = (_b = (_a = context.api) === null || _a === void 0 ? void 0 : _a.edge) === null || _b === void 0 ? void 0 : _b.clientContextId;
|
|
34
|
+
if (!edgeId) {
|
|
35
|
+
/* eslint-disable no-console */
|
|
36
|
+
console.warn('Warning: clientContextId is missing – form cannot be loaded properly on the client');
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
loadForm(edgeId, params.FormId, (_d = (_c = context.api) === null || _c === void 0 ? void 0 : _c.edge) === null || _d === void 0 ? void 0 : _d.edgeUrl)
|
|
40
|
+
.then(setContent)
|
|
41
|
+
.catch(() => {
|
|
42
|
+
if (isEditing) {
|
|
43
|
+
console.error(`Failed to load form with id ${params.FormId}. Check debug logs for content-sdk:form for more details.`);
|
|
44
|
+
}
|
|
45
|
+
setError(true);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
if (!formRef.current)
|
|
50
|
+
return;
|
|
51
|
+
// If we are in editing mode, we don't want to send any events
|
|
52
|
+
if (!isEditing) {
|
|
53
|
+
subscribeToFormSubmitEvent(formRef.current, rendering.uid);
|
|
54
|
+
}
|
|
55
|
+
executeScriptElements(formRef.current);
|
|
56
|
+
}
|
|
57
|
+
}, [content]);
|
|
58
|
+
if (isEditing && error) {
|
|
59
|
+
return React.createElement(ErrorComponent, { message: "There was a problem loading this section" });
|
|
60
|
+
}
|
|
61
|
+
return (React.createElement("div", { ref: formRef, dangerouslySetInnerHTML: { __html: content }, className: (_a = params.styles) === null || _a === void 0 ? void 0 : _a.trimEnd(), id: id ? id : undefined }));
|
|
62
|
+
};
|