@remkoj/optimizely-cms-react 4.3.1 → 5.0.0
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/components/cms-content/get-content.js +23 -21
- package/dist/components/cms-content/get-content.js.map +1 -1
- package/dist/components/cms-content/resolve-component.d.ts +4 -4
- package/dist/components/cms-content/resolve-component.js +14 -14
- package/dist/components/cms-content/resolve-component.js.map +1 -1
- package/dist/components/cms-content/rsc.d.ts +2 -2
- package/dist/components/cms-content/rsc.js +14 -7
- package/dist/components/cms-content/rsc.js.map +1 -1
- package/dist/components/cms-content/types.d.ts +11 -4
- package/dist/components/cms-content-area/index.d.ts +3 -10
- package/dist/components/cms-content-area/index.js +35 -51
- package/dist/components/cms-content-area/index.js.map +1 -1
- package/dist/components/cms-content-area/types.d.ts +49 -57
- package/dist/components/cms-editable/index.d.ts +48 -13
- package/dist/components/cms-editable/index.js +41 -5
- package/dist/components/cms-editable/index.js.map +1 -1
- package/dist/components/rich-text/components.d.ts +8 -7
- package/dist/components/rich-text/components.js +27 -22
- package/dist/components/rich-text/components.js.map +1 -1
- package/dist/components/rich-text/index.d.ts +4 -4
- package/dist/components/rich-text/index.js +19 -20
- package/dist/components/rich-text/index.js.map +1 -1
- package/dist/components/rich-text/types.d.ts +7 -15
- package/dist/components/rsc.d.ts +12 -12
- package/dist/components/rsc.js +17 -16
- package/dist/components/rsc.js.map +1 -1
- package/dist/components/type-utils.d.ts +13 -0
- package/dist/components/visual-builder/functions.js +1 -1
- package/dist/components/visual-builder/functions.js.map +1 -1
- package/dist/components/visual-builder/index.d.ts +1 -1
- package/dist/components/visual-builder/index.js +11 -9
- package/dist/components/visual-builder/index.js.map +1 -1
- package/dist/components/visual-builder/types.d.ts +3 -3
- package/dist/components/visual-builder/types.js.map +1 -1
- package/dist/components.d.ts +1 -1
- package/dist/context/client.d.ts +16 -4
- package/dist/context/client.js +38 -12
- package/dist/context/client.js.map +1 -1
- package/dist/context/rsc.d.ts +26 -9
- package/dist/context/rsc.js +84 -18
- package/dist/context/rsc.js.map +1 -1
- package/dist/context/shared.d.ts +3 -0
- package/dist/context/shared.js +7 -0
- package/dist/context/shared.js.map +1 -0
- package/dist/context/types.d.ts +24 -2
- package/dist/factory/default.js +16 -16
- package/dist/factory/default.js.map +1 -1
- package/dist/index.d.ts +4 -5
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/rsc.d.ts +2 -4
- package/dist/rsc.js +3 -1
- package/dist/rsc.js.map +1 -1
- package/dist/types.d.ts +5 -0
- package/dist/version.json +3 -0
- package/package.json +7 -7
|
@@ -1,37 +1,43 @@
|
|
|
1
1
|
import { print } from 'graphql';
|
|
2
|
-
import { isContentLink, isInlineContentLink,
|
|
2
|
+
import { isContentLink, isInlineContentLink, OptiCmsSchema } from "@remkoj/optimizely-graph-client";
|
|
3
3
|
import { CmsContentFragments } from "../../data/queries.js";
|
|
4
4
|
import { validatesFragment, contentLinkToRequestVariables, isCmsComponentWithFragment, isCmsComponentWithDataQuery } from "../../utilities.js";
|
|
5
5
|
export function getContent(client, contentLink, Component, fragmentData, noDataLoad) {
|
|
6
6
|
const debug = client?.debug ?? false;
|
|
7
7
|
// Handle provided fragment
|
|
8
8
|
const componentLabel = Component?.displayName ?? Component?.toString() ?? 'undefined';
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if (validatesFragment(Component) && !Component.validateFragment(fragmentData))
|
|
9
|
+
const myFragmentData = fragmentData || {};
|
|
10
|
+
const fragmentProps = Object.getOwnPropertyNames(myFragmentData).filter(x => !CmsContentFragments.IContentDataProps.includes(x));
|
|
11
|
+
if (fragmentProps.length > 0) {
|
|
12
|
+
if (validatesFragment(Component) && !Component.validateFragment(myFragmentData))
|
|
14
13
|
console.warn("🔴 [CmsContent][getContent] Invalid fragment data received, falling back to loading for ", componentLabel);
|
|
15
|
-
else
|
|
16
|
-
|
|
14
|
+
else {
|
|
15
|
+
if (debug)
|
|
16
|
+
console.log("⚪ [CmsContent][getContent] Rendering CMS Component using fragment information");
|
|
17
|
+
return (noDataLoad ? myFragmentData : Promise.resolve(myFragmentData));
|
|
18
|
+
}
|
|
17
19
|
}
|
|
20
|
+
// No meaningful fragment provided with inline content, warn in debug, but just return an empty dataset
|
|
18
21
|
if (isInlineContentLink(contentLink)) {
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
if (debug)
|
|
23
|
+
console.warn(`🟠 [CmsContent][getContent] No data present for inline content item, this may cause errors if your component expects certain fields to be present`);
|
|
24
|
+
return (noDataLoad ? myFragmentData : Promise.resolve(myFragmentData));
|
|
21
25
|
}
|
|
26
|
+
// If no data may be loaded, stop here
|
|
22
27
|
if (noDataLoad) {
|
|
23
28
|
if (debug)
|
|
24
29
|
console.log(`⚪ [CmsContent][getContent] Component of type "${componentLabel}" was prohibited to load data`);
|
|
25
|
-
return
|
|
30
|
+
return myFragmentData;
|
|
26
31
|
}
|
|
32
|
+
// If we don't have a valid link, stop here
|
|
27
33
|
if (!isContentLink(contentLink)) {
|
|
28
34
|
if (debug)
|
|
29
|
-
console.
|
|
30
|
-
return Promise.resolve(
|
|
35
|
+
console.warn(`🟠 [CmsContent][getContent] Unable to load data for "${componentLabel}" without a valid content link`);
|
|
36
|
+
return Promise.resolve(myFragmentData);
|
|
31
37
|
}
|
|
32
38
|
// Return immediately when there's no client
|
|
33
39
|
if (!client) {
|
|
34
|
-
console.
|
|
40
|
+
console.error(`🔴 [CmsContent][getContent] Data loading for "${componentLabel}" requires a GraphQL Client`);
|
|
35
41
|
throw new Error(`Data loading for "${componentLabel}" requires a GraphQL Client`);
|
|
36
42
|
}
|
|
37
43
|
if (isCmsComponentWithFragment(Component))
|
|
@@ -40,17 +46,13 @@ export function getContent(client, contentLink, Component, fragmentData, noDataL
|
|
|
40
46
|
const gqlQuery = Component.getDataQuery();
|
|
41
47
|
const gqlVariables = contentLinkToRequestVariables(contentLink);
|
|
42
48
|
if (client.debug)
|
|
43
|
-
console.log("⚪ [CmsContent] Component data
|
|
44
|
-
return client.request(gqlQuery, gqlVariables)
|
|
45
|
-
if (client.debug)
|
|
46
|
-
console.log("⚪ [CmsContent] Component request the following data:", gqlResponse);
|
|
47
|
-
return gqlResponse;
|
|
48
|
-
});
|
|
49
|
+
console.log("⚪ [CmsContent][getContent] Component fetching data using query, provided variables:", gqlVariables);
|
|
50
|
+
return client.request(gqlQuery, gqlVariables);
|
|
49
51
|
}
|
|
50
52
|
// Assume there's no data load required for the component
|
|
51
53
|
if (client.debug)
|
|
52
54
|
console.log(`⚪ [CmsContent] Component of type "${componentLabel}" did not request loading of data`);
|
|
53
|
-
return Promise.resolve(
|
|
55
|
+
return Promise.resolve(myFragmentData);
|
|
54
56
|
}
|
|
55
57
|
export default getContent;
|
|
56
58
|
async function getComponentDataFromFragment(Component, contentLink, client) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-content.js","sourceRoot":"","sources":["../../../src/components/cms-content/get-content.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAmE,aAAa,EAAE,mBAAmB,EAAE,
|
|
1
|
+
{"version":3,"file":"get-content.js","sourceRoot":"","sources":["../../../src/components/cms-content/get-content.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAmE,aAAa,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAErK,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,6BAA6B,EAAE,0BAA0B,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AAE/I,MAAM,UAAU,UAAU,CAA8B,MAAoC,EAAE,WAAwD,EAAE,SAAwC,EAAE,YAAoD,EAAE,UAAgB;IACtQ,MAAM,KAAK,GAAG,MAAM,EAAE,KAA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,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAA;IAC3L,IAAI,UAAU,GAAG,CAAC,IAAI,MAAM,CAAC,KAAK;QAAE,OAAO,CAAC,IAAI,CAAC,4BAA4B,UAAU,uDAAuD,CAAC,CAAA;IAC/I,IAAI,MAAM,CAAC,oBAAoB,IAAI,aAAa,CAAC,KAAK,EAAE,CAAC;QACvD,gBAAgB,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,GAAG,gBAAgB,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,IAAI,gBAAgB,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,IAAI,CAAA;QACtK,IAAI,gBAAgB,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO;YAC/C,OAAO,gBAAgB,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAA;IACxD,CAAC;IACD,OAAO,gBAAgB,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;AAC9C,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type ComponentTypeHandle } from
|
|
2
|
-
import { type EnhancedCmsComponent } from
|
|
3
|
-
import { type GenericContext } from
|
|
4
|
-
import { type FunctionComponent, type PropsWithChildren, type ComponentType } from
|
|
1
|
+
import { type ComponentTypeHandle } from '../../factory/types.js';
|
|
2
|
+
import { type EnhancedCmsComponent } from './types.js';
|
|
3
|
+
import { type GenericContext } from '../../context/types.js';
|
|
4
|
+
import { type FunctionComponent, type PropsWithChildren, type ComponentType } from 'react';
|
|
5
5
|
/**
|
|
6
6
|
* Helper function to safely resolve a component from the ContentType information to
|
|
7
7
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import * as Utils from
|
|
2
|
+
import * as Utils from '../../utilities.js';
|
|
3
3
|
/**
|
|
4
4
|
* Helper function to safely resolve a component from the ContentType information to
|
|
5
5
|
*
|
|
@@ -12,38 +12,38 @@ export function resolveComponent(contentType, prefix, variant, ctx) {
|
|
|
12
12
|
const { factory, isDebug, inEditMode } = ctx;
|
|
13
13
|
// Ensure we have a factory - we should, but lets' help by providing an explicit error
|
|
14
14
|
if (!factory) {
|
|
15
|
-
console.error(`🔴 [CmsContent] No content type factory registered in the context`);
|
|
16
|
-
throw new Error(
|
|
15
|
+
console.error(`🔴 [CmsContent][resolveComponent] No content type factory registered in the context`);
|
|
16
|
+
throw new Error('Empty factory on the context');
|
|
17
17
|
}
|
|
18
18
|
// Optimizely Graph stores the type in Most Significant first order, we need least significant first, also we're stripping out the common "Content" item from it
|
|
19
|
-
const myContentType = prefix
|
|
20
|
-
Utils.normalizeAndPrefixContentType(Array.isArray(contentType) ? [...contentType].reverse() : contentType, prefix)
|
|
21
|
-
Utils.normalizeContentType(Array.isArray(contentType) ? [...contentType].reverse() : contentType, true);
|
|
19
|
+
const myContentType = prefix
|
|
20
|
+
? Utils.normalizeAndPrefixContentType(Array.isArray(contentType) ? [...contentType].reverse() : contentType, prefix)
|
|
21
|
+
: Utils.normalizeContentType(Array.isArray(contentType) ? [...contentType].reverse() : contentType, true);
|
|
22
22
|
// Validate that we have a value to ask the factory a component for
|
|
23
23
|
if (!myContentType || myContentType.length == 0) {
|
|
24
24
|
if (isDebug)
|
|
25
|
-
console.error(`🔴 [CmsContent] The content type ${JSON.stringify(contentType)}, with prefix ${JSON.stringify(prefix)} yielded an empty normalized type`);
|
|
25
|
+
console.error(`🔴 [CmsContent][resolveComponent] The content type ${JSON.stringify(contentType)}, with prefix ${JSON.stringify(prefix)} yielded an empty normalized type`);
|
|
26
26
|
throw new Error(`The content type ${JSON.stringify(contentType)}, with prefix ${JSON.stringify(prefix)} yielded an empty normalized type`);
|
|
27
27
|
}
|
|
28
|
+
if (isDebug)
|
|
29
|
+
console.log(`⚪ [CmsContent][resolveComponent] Normalized content type ${JSON.stringify(contentType)} to ${myContentType}`);
|
|
28
30
|
// Resolve component
|
|
29
31
|
const Component = Utils.resolveComponentType(factory, myContentType, variant ? [variant] : []);
|
|
30
32
|
// Handle component not found in factory
|
|
31
33
|
if (!Component) {
|
|
32
|
-
const contentTypeDisplay = Array.isArray(myContentType)
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
const contentTypeDisplay = Array.isArray(myContentType)
|
|
35
|
+
? myContentType.join('/')
|
|
36
|
+
: myContentType;
|
|
35
37
|
if (isDebug || inEditMode) {
|
|
36
|
-
const ErrorComponent = props => _jsxs(_Fragment, { children: [_jsxs("div", { className:
|
|
38
|
+
const ErrorComponent = (props) => (_jsxs(_Fragment, { children: [_jsxs("div", { className: "opti-error", children: ["Component of type \"", contentTypeDisplay, "\" not resolved by factory"] }), props.children] }));
|
|
37
39
|
ErrorComponent.displayName = 'Opti::ComponentMissing';
|
|
38
40
|
return ErrorComponent;
|
|
39
41
|
}
|
|
40
|
-
const ErrorComponent = props => props.children;
|
|
42
|
+
const ErrorComponent = (props) => props.children;
|
|
41
43
|
ErrorComponent.displayName = 'Opti::ComponentMissing';
|
|
42
44
|
return ErrorComponent;
|
|
43
45
|
}
|
|
44
46
|
// Return the component
|
|
45
|
-
if (isDebug)
|
|
46
|
-
console.log("⚪ [CmsContent] Rendering item using component:", Component?.displayName ?? Component);
|
|
47
47
|
return Component;
|
|
48
48
|
}
|
|
49
49
|
export default resolveComponent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-component.js","sourceRoot":"","sources":["../../../src/components/cms-content/resolve-component.tsx"],"names":[],"mappings":";AAEA,OAAO,KAAK,KAAK,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"resolve-component.js","sourceRoot":"","sources":["../../../src/components/cms-content/resolve-component.tsx"],"names":[],"mappings":";AAEA,OAAO,KAAK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,SAAS,CAAC,WAAW,CAAC,OAAO,aAAa,EAAE,CAC9G,CAAA;IAEH,oBAAoB;IACpB,MAAM,SAAS,GAAG,KAAK,CAAC,oBAAoB,CAC1C,OAAO,EACP,aAAa,EACb,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CACW,CAAA;IAErC,wCAAwC;IACxC,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,kBAAkB,GAAG,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC;YACrD,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC;YACzB,CAAC,CAAC,aAAa,CAAA;QACjB,IAAI,OAAO,IAAI,UAAU,EAAE,CAAC;YAC1B,MAAM,cAAc,GAA8B,CAAC,KAAK,EAAE,EAAE,CAAC,CAC3D,8BACE,eAAK,SAAS,EAAC,YAAY,qCACL,kBAAkB,kCAClC,EACL,KAAK,CAAC,QAAQ,IACd,CACJ,CAAA;YACD,cAAc,CAAC,WAAW,GAAG,wBAAwB,CAAA;YACrD,OAAO,cAAc,CAAA;QACvB,CAAC;QACD,MAAM,cAAc,GAA8B,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAA;QAC3E,cAAc,CAAC,WAAW,GAAG,wBAAwB,CAAA;QACrD,OAAO,cAAc,CAAA;IACvB,CAAC;IAED,uBAAuB;IACvB,OAAO,SAAS,CAAA;AAClB,CAAC;AAED,eAAe,gBAAgB,CAAA;AAM/B,MAAM,UAAU,2BAA2B,CACzC,MAA6C;IAE7C,OAAO,MAAM,EAAE,WAAW,IAAI,wBAAwB,CAAA;AACxD,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
2
|
import type { BaseCmsContentProps } from './types.js';
|
|
3
|
-
export type * from
|
|
3
|
+
export type * from './types.js';
|
|
4
4
|
/**
|
|
5
5
|
* React Server Side component for the CmsContent
|
|
6
6
|
*
|
|
7
7
|
* @param param0
|
|
8
8
|
* @returns
|
|
9
9
|
*/
|
|
10
|
-
export declare function CmsContent<LocalesType = string>({ contentType, contentTypePrefix, contentLink: rawContentLink, children, fragmentData, layoutProps, noDataLoad, variant, ctx }: BaseCmsContentProps<LocalesType>): Promise<ReactNode>;
|
|
10
|
+
export declare function CmsContent<LocalesType = string>({ contentType, contentTypePrefix, contentLink: rawContentLink, children, fragmentData, layoutProps, noDataLoad, variant, ctx, }: BaseCmsContentProps<LocalesType>): Promise<ReactNode>;
|
|
11
11
|
export default CmsContent;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import getContentType from './get-content-type.js';
|
|
3
3
|
import getContent from './get-content.js';
|
|
4
|
-
import { AuthMode, normalizeContentLink,
|
|
5
|
-
import resolveComponent, { isComponentMissingComponent } from './resolve-component.js';
|
|
4
|
+
import { AuthMode, normalizeContentLink, } from '@remkoj/optimizely-graph-client';
|
|
5
|
+
import resolveComponent, { isComponentMissingComponent, } from './resolve-component.js';
|
|
6
6
|
import resolveContentType from './resolve-content-type.js';
|
|
7
7
|
/**
|
|
8
8
|
* React Server Side component for the CmsContent
|
|
@@ -12,7 +12,7 @@ import resolveContentType from './resolve-content-type.js';
|
|
|
12
12
|
*/
|
|
13
13
|
export async function CmsContent({
|
|
14
14
|
// Own properties
|
|
15
|
-
contentType, contentTypePrefix, contentLink: rawContentLink, children, fragmentData, layoutProps, noDataLoad, variant, ctx }) {
|
|
15
|
+
contentType, contentTypePrefix, contentLink: rawContentLink, children, fragmentData, layoutProps, noDataLoad, variant, ctx, }) {
|
|
16
16
|
// Prepare context
|
|
17
17
|
const graphClient = ctx.client;
|
|
18
18
|
// Normalize the ContentLink
|
|
@@ -32,9 +32,16 @@ contentType, contentTypePrefix, contentLink: rawContentLink, children, fragmentD
|
|
|
32
32
|
}
|
|
33
33
|
// Provide a bit of debugging context
|
|
34
34
|
if (graphClient?.debug) {
|
|
35
|
-
const mode = ctx.inEditMode
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
const mode = ctx.inEditMode
|
|
36
|
+
? 'Edit'
|
|
37
|
+
: ctx.inPreviewMode
|
|
38
|
+
? 'Preview'
|
|
39
|
+
: 'Public';
|
|
40
|
+
/*console.log(
|
|
41
|
+
`👔 [CmsContent] ${mode} mode active for content with id: ${contentLinkToString(contentLink)} of type ${myContentType?.join('/') ?? 'unknown'}`
|
|
42
|
+
)*/
|
|
43
|
+
if ((ctx.inEditMode || ctx.inPreviewMode) &&
|
|
44
|
+
graphClient.currentAuthMode == AuthMode.Public)
|
|
38
45
|
console.warn(`🟠 [CmsContent] ${mode} mode active without an authenticated graphClient, this will cause problems. Make sure the context has an authenticated client.`);
|
|
39
46
|
}
|
|
40
47
|
// Retrieve the Component used to render this item
|
|
@@ -44,7 +51,7 @@ contentType, contentTypePrefix, contentLink: rawContentLink, children, fragmentD
|
|
|
44
51
|
// Ensure we have the data the Component requested
|
|
45
52
|
const data = await getContent(graphClient, contentLink, Component, fragmentData, noDataLoad);
|
|
46
53
|
// Output the actual component
|
|
47
|
-
return _jsx(Component, { contentLink: contentLink, data: data, inEditMode: ctx.inEditMode, layoutProps: layoutProps, children: children });
|
|
54
|
+
return (_jsx(Component, { contentLink: contentLink, data: data, inEditMode: ctx.inEditMode, layoutProps: layoutProps, ctx: ctx, children: children }));
|
|
48
55
|
}
|
|
49
56
|
export default CmsContent;
|
|
50
57
|
//# sourceMappingURL=rsc.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rsc.js","sourceRoot":"","sources":["../../../src/components/cms-content/rsc.tsx"],"names":[],"mappings":";AAEA,OAAO,cAAc,MAAM,uBAAuB,CAAA;AAClD,OAAO,UAAU,MAAM,kBAAkB,CAAA;AACzC,OAAO,
|
|
1
|
+
{"version":3,"file":"rsc.js","sourceRoot":"","sources":["../../../src/components/cms-content/rsc.tsx"],"names":[],"mappings":";AAEA,OAAO,cAA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AC,UAAU,IAAI,GAAG,CAAC,aAAa,CAAC;YACrC,WAAW,CAAC,eAAe,IAAI,QAAQ,CAAC,MAAM;YAE9C,OAAO,CAAC,IAAI,CACV,mBAAmB,IAAI,iIAAiI,CACzJ,CAAA;IACL,CAAC;IAED,kDAAkD;IAClD,MAAM,SAAS,GAAG,gBAAgB,CAChC,aAAa,EACb,iBAAiB,EACjB,OAAO,EACP,GAAG,CACJ,CAAA;IACD,IAAI,2BAA2B,CAAC,SAAS,CAAC;QAAE,OAAO,KAAC,SAAS,KAAG,CAAA;IAEhE,kDAAkD;IAClD,MAAM,IAAI,GAAG,MAAM,UAAU,CAC3B,WAAW,EACX,WAAW,EACX,SAAS,EACT,YAAY,EACZ,UAAU,CACX,CAAA;IAED,8BAA8B;IAC9B,OAAO,CACL,KAAC,SAAS,IACR,WAAW,EAAE,WAA0B,EACvC,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,GAAG,CAAC,UAAU,EAC1B,WAAW,EAAE,WAAW,EACxB,GAAG,EAAE,GAAG,YAEP,QAAQ,GACC,CACb,CAAA;AACH,CAAC;AAED,eAAe,UAAU,CAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type PropsWithChildren, type ComponentType, type ComponentProps, type ReactNode } from 'react';
|
|
2
2
|
import type { CmsComponent } from '../../types.js';
|
|
3
|
-
import type { PropsWithContext } from "../../context/types.js";
|
|
3
|
+
import type { PropsWithContext, PropsWithOptionalContext } from "../../context/types.js";
|
|
4
4
|
import type { ContentLinkWithLocale, InlineContentLinkWithLocale } from "@remkoj/optimizely-graph-client";
|
|
5
|
-
export type CmsContentProps<LocalesType = string> = PropsWithChildren<{
|
|
5
|
+
export type CmsContentProps<LocalesType = string> = PropsWithChildren<PropsWithOptionalContext<{
|
|
6
6
|
/**
|
|
7
7
|
* The content type to render
|
|
8
8
|
*/
|
|
@@ -46,13 +46,20 @@ export type CmsContentProps<LocalesType = string> = PropsWithChildren<{
|
|
|
46
46
|
* the store
|
|
47
47
|
*/
|
|
48
48
|
noDataLoad?: boolean;
|
|
49
|
-
}
|
|
49
|
+
}>>;
|
|
50
50
|
export type PropsWithCmsContent<T = any> = T & {
|
|
51
|
-
cmsContent:
|
|
51
|
+
cmsContent: CmsContentComponentProperty;
|
|
52
52
|
};
|
|
53
53
|
export type BaseCmsContentProps<LocalesType = string> = PropsWithContext<CmsContentProps<LocalesType>>;
|
|
54
|
+
/**
|
|
55
|
+
* The public surface of the CmsContentComponent
|
|
56
|
+
*/
|
|
54
57
|
export type CmsContentComponent = <LocalesType = string>(props: CmsContentProps<LocalesType>) => ReactNode;
|
|
58
|
+
/**
|
|
59
|
+
* The base surface of the CmsContentComponent, which requires a context property to provided
|
|
60
|
+
*/
|
|
55
61
|
export type CmsContentBaseComponent = <LocalesType = string>(props: BaseCmsContentProps<LocalesType>) => ReactNode;
|
|
62
|
+
export type CmsContentComponentProperty = <LocalesType = string>(props: Partial<PropsWithContext> & CmsContentProps<LocalesType>) => ReactNode;
|
|
56
63
|
export type CmsComponentProps = ComponentProps<CmsComponent> & {
|
|
57
64
|
[key: string]: any;
|
|
58
65
|
};
|
|
@@ -1,17 +1,10 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
export type { CmsContentAreaClassMapper, CmsContentAreaProps, ContentAreaItemDefinition, CmsContentAreaComponent } from './types.js';
|
|
1
|
+
import type { CmsContentAreaBaseComponent } from './types.js';
|
|
2
|
+
export type { CmsContentAreaClassMapper, CmsContentAreaProps, ContentAreaItemDefinition, CmsContentAreaComponent, } from './types.js';
|
|
4
3
|
/**
|
|
5
4
|
* React server component to render a content area
|
|
6
5
|
*
|
|
7
6
|
* @param param0 The content area information for rendering
|
|
8
7
|
* @returns
|
|
9
8
|
*/
|
|
10
|
-
export declare const CmsContentArea:
|
|
11
|
-
/**
|
|
12
|
-
*
|
|
13
|
-
* @param items
|
|
14
|
-
* @param locale
|
|
15
|
-
* @returns
|
|
16
|
-
*/
|
|
9
|
+
export declare const CmsContentArea: CmsContentAreaBaseComponent;
|
|
17
10
|
export default CmsContentArea;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import * as Utils from '../../utilities.js';
|
|
3
3
|
import * as Errors from '../../errors.js';
|
|
4
|
-
import { normalizeContentLinkWithLocale, contentLinkToString } from '@remkoj/optimizely-graph-client/utils';
|
|
4
|
+
import { normalizeContentLinkWithLocale, contentLinkToString, } from '@remkoj/optimizely-graph-client/utils';
|
|
5
5
|
import { Suspense } from 'react';
|
|
6
6
|
//#endregion
|
|
7
7
|
/**
|
|
@@ -10,10 +10,12 @@ import { Suspense } from 'react';
|
|
|
10
10
|
* @param param0 The content area information for rendering
|
|
11
11
|
* @returns
|
|
12
12
|
*/
|
|
13
|
-
export const CmsContentArea = ({ items = [], classMapper,
|
|
13
|
+
export const CmsContentArea = ({ items = [], classMapper, fieldName, as: elementType, itemsProperty, itemWrapper, useSuspense = false, fallback, noWrapper: noContentAreaContainer = false, variant, ctx, cmsContent: CmsContent, ...additionalProps }) => {
|
|
14
14
|
const { inEditMode = false } = ctx;
|
|
15
15
|
// Convert the items to a list of enriched content types and filter out items cannot be loaded
|
|
16
|
-
const componentData = (items || [])
|
|
16
|
+
const componentData = (items || [])
|
|
17
|
+
.filter(forValidContentAreaItems)
|
|
18
|
+
.map((item, idx) => {
|
|
17
19
|
// Prepare data from received content area format
|
|
18
20
|
const contentLink = normalizeContentLinkWithLocale(item._metadata);
|
|
19
21
|
if (!contentLink)
|
|
@@ -21,76 +23,58 @@ export const CmsContentArea = ({ items = [], classMapper, className, fieldName,
|
|
|
21
23
|
const contentType = Utils.normalizeContentType(item._metadata.types);
|
|
22
24
|
const fragmentData = item;
|
|
23
25
|
// Read element wrapper configuration
|
|
24
|
-
const { as: ContentAreaItemContainer =
|
|
26
|
+
const { as: ContentAreaItemContainer = 'div', itemsProperty: childrenTarget = 'children', noWrapper: noContentAreaItemContainer = false, className: rawContentAreaItemClassName, ...contentItemElementProps } = itemWrapper ?? {};
|
|
25
27
|
const contentAreaItemKey = `ContentAreaItem-${idx}-${contentLinkToString(contentLink)}`;
|
|
28
|
+
const contentAreaItemClassName = Array.isArray(rawContentAreaItemClassName)
|
|
29
|
+
? rawContentAreaItemClassName.join(' ')
|
|
30
|
+
: rawContentAreaItemClassName;
|
|
26
31
|
// Output if no wrapper is required
|
|
27
32
|
if (noContentAreaItemContainer)
|
|
28
|
-
return useSuspense ?
|
|
29
|
-
_jsx(Suspense, { fallback: fallback, children: _jsx(CmsContent, { contentLink: contentLink, contentType: contentType, fragmentData: fragmentData, contentTypePrefix: "Component", variant: variant }) }, contentAreaItemKey) :
|
|
30
|
-
_jsx(CmsContent, { contentLink: contentLink, contentType: contentType, fragmentData: fragmentData, contentTypePrefix: "Component", variant: variant }, contentAreaItemKey);
|
|
33
|
+
return useSuspense ? (_jsx(Suspense, { fallback: fallback, children: _jsx(CmsContent, { contentLink: contentLink, contentType: contentType, fragmentData: fragmentData, contentTypePrefix: "Component", variant: variant, ctx: ctx }) }, contentAreaItemKey)) : (_jsx(CmsContent, { contentLink: contentLink, contentType: contentType, fragmentData: fragmentData, contentTypePrefix: "Component", variant: variant, ctx: ctx }, contentAreaItemKey));
|
|
31
34
|
// Buld wrapper configuration
|
|
32
35
|
const contentAreaItemContainerProps = {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
'data-epi-block-id': inEditMode && fieldName
|
|
37
|
+
? Utils.getContentEditId(contentLink) || undefined
|
|
38
|
+
: undefined,
|
|
39
|
+
'data-displayoption': item.displayOption || undefined,
|
|
40
|
+
'data-tag': item.tag || undefined,
|
|
41
|
+
'data-component': contentType?.at(0),
|
|
42
|
+
...contentItemElementProps,
|
|
43
|
+
className: `opti-content-area-item opti-content-area-item-${idx}${contentAreaItemClassName ? ' ' + contentAreaItemClassName : ''} ${classMapper ? classMapper(item.displayOption ?? 'default', contentType ?? null, idx) : ''}`,
|
|
39
44
|
};
|
|
40
|
-
const contentAraeItemContent = useSuspense ?
|
|
41
|
-
_jsx(Suspense, { fallback: fallback, children: _jsx(CmsContent, { contentLink: contentLink, contentType: contentType, fragmentData: fragmentData, contentTypePrefix: "Component", variant: variant }) }) :
|
|
42
|
-
_jsx(CmsContent, { contentLink: contentLink, contentType: contentType, fragmentData: fragmentData, contentTypePrefix: "Component", variant: variant });
|
|
45
|
+
const contentAraeItemContent = useSuspense ? (_jsx(Suspense, { fallback: fallback, children: _jsx(CmsContent, { contentLink: contentLink, contentType: contentType, fragmentData: fragmentData, contentTypePrefix: "Component", variant: variant, ctx: ctx }) })) : (_jsx(CmsContent, { contentLink: contentLink, contentType: contentType, fragmentData: fragmentData, contentTypePrefix: "Component", variant: variant, ctx: ctx }));
|
|
43
46
|
// Inject the element into the wrapper
|
|
44
47
|
let contentAreaItemContainerChildren = undefined;
|
|
45
|
-
if (childrenTarget ==
|
|
48
|
+
if (childrenTarget == 'children')
|
|
46
49
|
contentAreaItemContainerChildren = contentAraeItemContent;
|
|
47
50
|
else
|
|
48
51
|
contentAreaItemContainerProps[childrenTarget] = contentAraeItemContent;
|
|
49
|
-
return _jsx(ContentAreaItemContainer, { ...contentAreaItemContainerProps, children: contentAreaItemContainerChildren }, contentAreaItemKey);
|
|
52
|
+
return (_jsx(ContentAreaItemContainer, { ...contentAreaItemContainerProps, children: contentAreaItemContainerChildren }, contentAreaItemKey));
|
|
50
53
|
});
|
|
51
54
|
if (noContentAreaContainer)
|
|
52
55
|
return _jsx(_Fragment, { children: componentData });
|
|
53
56
|
// Build container element
|
|
54
57
|
const contentAreaContainerProps = {
|
|
55
|
-
className: `opti-content-area ${Array.isArray(className) ? className.join(' ') : (className ?? '')}`.trim(),
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
...additionalProps
|
|
58
|
+
className: `opti-content-area ${Array.isArray(additionalProps.className) ? additionalProps.className.join(' ') : (additionalProps.className ?? '')}`.trim(),
|
|
59
|
+
'data-epi-edit': inEditMode && fieldName ? fieldName : undefined,
|
|
60
|
+
'data-component': 'ContentArea',
|
|
61
|
+
...additionalProps,
|
|
59
62
|
};
|
|
60
|
-
const contentAreaContainerChildrenTarget = itemsProperty ??
|
|
63
|
+
const contentAreaContainerChildrenTarget = itemsProperty ?? 'children';
|
|
61
64
|
let contentAreaContainerChildren = undefined;
|
|
62
|
-
if (contentAreaContainerChildrenTarget ==
|
|
65
|
+
if (contentAreaContainerChildrenTarget == 'children')
|
|
63
66
|
contentAreaContainerChildren = componentData;
|
|
64
67
|
else
|
|
65
|
-
contentAreaContainerProps[contentAreaContainerChildrenTarget] =
|
|
66
|
-
|
|
67
|
-
|
|
68
|
+
contentAreaContainerProps[contentAreaContainerChildrenTarget] =
|
|
69
|
+
componentData;
|
|
70
|
+
const ContentAreaContainer = elementType ?? 'div';
|
|
71
|
+
return (_jsx(ContentAreaContainer, { ...contentAreaContainerProps, children: contentAreaContainerChildren }));
|
|
68
72
|
};
|
|
69
73
|
function forValidContentAreaItems(itm) {
|
|
70
|
-
return
|
|
74
|
+
return (typeof itm == 'object' &&
|
|
75
|
+
itm != null &&
|
|
76
|
+
typeof itm._metadata == 'object' &&
|
|
77
|
+
itm._metadata != null);
|
|
71
78
|
}
|
|
72
|
-
/**
|
|
73
|
-
*
|
|
74
|
-
* @param items
|
|
75
|
-
* @param locale
|
|
76
|
-
* @returns
|
|
77
|
-
*/
|
|
78
|
-
/*export function processContentAreaItems( items?: (ContentAreaItemDefinition | null)[] | null, locale?: string) : JSX.Element[]
|
|
79
|
-
{
|
|
80
|
-
const actualItems = (items ?? []).filter(Utils.isNotNullOrUndefined)
|
|
81
|
-
return actualItems.map((item, idx) => {
|
|
82
|
-
// Prepare data from received content area format
|
|
83
|
-
const contentLink = normalizeContentLinkWithLocale({ ...item.item, locale: locale })
|
|
84
|
-
if (!contentLink)
|
|
85
|
-
throw new Errors.InvalidContentLinkError({ ...item.item, locale: locale })
|
|
86
|
-
const contentType = Utils.normalizeContentType(item.item?.data?.contentType)
|
|
87
|
-
const fragmentData = item.item?.data || undefined
|
|
88
|
-
const guidValue = (item.item?.guidValue ?? "00000000-0000-0000-0000-000000000000")+"::"+idx
|
|
89
|
-
|
|
90
|
-
// Build output
|
|
91
|
-
const content : JSX.Element = <CmsContent contentLink={ contentLink } contentType={ contentType } fragmentData={ fragmentData } key={ guidValue } />
|
|
92
|
-
return content
|
|
93
|
-
})
|
|
94
|
-
}*/
|
|
95
79
|
export default CmsContentArea;
|
|
96
80
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/cms-content-area/index.tsx"],"names":[],"mappings":";AACA,OAAO,KAAK,KAAK,MAAM,oBAAoB,CAAA;AAC3C,OAAO,KAAK,MAAM,MAAM,iBAAiB,CAAA;AACzC,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/cms-content-area/index.tsx"],"names":[],"mappings":";AACA,OAAO,KAAK,KAAK,MAAM,oBAAoB,CAAA;AAC3C,OAAO,KAAK,MAAM,MAAM,iBAAiB,CAAA;AACzC,OAAO,EACL,8BAA8B,EAC9B,mBAAmB,GACpB,MAAM,uCAAuC,CAAA;AAO9C,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAShC,YAAY;AAEZ;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GAAgC,CAGzD,EACA,KAAK,GAAG,EAA4C,EACpD,WAAW,EACX,SAAS,EACT,EAAE,EAAE,WAAW,EACf,aAAa,EACb,WAAW,EACX,WAAW,GAAG,KAAqD,EACnE,QAAQ,EACR,SAAS,EAAE,sBAAsB,GAAG,KAGtB,EACd,OAAO,EAEP,GAAG,EACH,UAAU,EAAE,UAAU,EAEtB,GAAG,eAAe,EACY,EAAE,EAAE;IAClC,MAAM,EAAE,UAAU,GAAG,KAAK,EAAE,G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