@contentful/experiences-sdk-react 3.4.0 → 3.4.1-dev-20250828T1024-c2a782a.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/ExperienceRoot.js +1 -1
- package/dist/ExperienceRoot.js.map +1 -1
- package/dist/blocks/preview/CompositionBlock.js +3 -3
- package/dist/blocks/preview/CompositionBlock.js.map +1 -1
- package/dist/blocks/preview/PreviewDeliveryRoot.js +2 -2
- package/dist/blocks/preview/PreviewDeliveryRoot.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/sdkVersion.js +1 -1
- package/dist/sdkVersion.js.map +1 -1
- package/dist/src/sdkVersion.d.ts +1 -1
- package/dist/utils/parseComponentProps.js +1 -1
- package/dist/utils/parseComponentProps.js.map +1 -1
- package/package.json +6 -6
package/dist/ExperienceRoot.js
CHANGED
|
@@ -9,7 +9,7 @@ import { StudioCanvasMode } from '@contentful/experiences-core/constants';
|
|
|
9
9
|
const ExperienceRoot = ({ locale, experience, visualEditorMode = VisualEditorMode.LazyLoad, debug: debug$1, }) => {
|
|
10
10
|
const mode = useDetectCanvasMode();
|
|
11
11
|
if (typeof debug$1 === 'boolean') {
|
|
12
|
-
debug.
|
|
12
|
+
debug.setActiveLevel(debug$1 ? 'debug' : 'warn');
|
|
13
13
|
}
|
|
14
14
|
//If experience is passed in as a JSON string, recreate it to an experience object
|
|
15
15
|
const experienceObject = typeof experience === 'string' ? createExperience(experience) : experience;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExperienceRoot.js","sources":["../../src/ExperienceRoot.tsx"],"sourcesContent":["'use client';\nimport React from 'react';\nimport {\n VisualEditorMode,\n createExperience,\n validateExperienceBuilderConfig,\n debug as cfDebug,\n} from '@contentful/experiences-core';\nimport { EntityStore } from '@contentful/experiences-core';\nimport type { Experience } from '@contentful/experiences-core/types';\nimport { PreviewDeliveryRoot } from './blocks/preview/PreviewDeliveryRoot';\nimport VisualEditorRoot from './blocks/editor/VisualEditorRoot';\nimport { useDetectCanvasMode } from './hooks/useDetectCanvasMode';\nimport { StudioCanvasMode } from '@contentful/experiences-core/constants';\n\ntype ExperienceRootProps = {\n experience?: Experience<EntityStore> | string | null;\n locale: string;\n visualEditorMode?: VisualEditorMode;\n /** Enables extra logging in the SDK to support troubleshooting.\n * This option is not recommended for production environments as it\n * will result in too many unnecessary logs being produced during runtime.\n * Default: false\n */\n debug?: boolean;\n};\n\nexport const ExperienceRoot = ({\n locale,\n experience,\n visualEditorMode = VisualEditorMode.LazyLoad,\n debug,\n}: ExperienceRootProps) => {\n const mode = useDetectCanvasMode();\n\n if (typeof debug === 'boolean') {\n cfDebug.
|
|
1
|
+
{"version":3,"file":"ExperienceRoot.js","sources":["../../src/ExperienceRoot.tsx"],"sourcesContent":["'use client';\nimport React from 'react';\nimport {\n VisualEditorMode,\n createExperience,\n validateExperienceBuilderConfig,\n debug as cfDebug,\n} from '@contentful/experiences-core';\nimport { EntityStore } from '@contentful/experiences-core';\nimport type { Experience } from '@contentful/experiences-core/types';\nimport { PreviewDeliveryRoot } from './blocks/preview/PreviewDeliveryRoot';\nimport VisualEditorRoot from './blocks/editor/VisualEditorRoot';\nimport { useDetectCanvasMode } from './hooks/useDetectCanvasMode';\nimport { StudioCanvasMode } from '@contentful/experiences-core/constants';\n\ntype ExperienceRootProps = {\n experience?: Experience<EntityStore> | string | null;\n locale: string;\n visualEditorMode?: VisualEditorMode;\n /** Enables extra logging in the SDK to support troubleshooting.\n * This option is not recommended for production environments as it\n * will result in too many unnecessary logs being produced during runtime.\n * Default: false\n */\n debug?: boolean;\n};\n\nexport const ExperienceRoot = ({\n locale,\n experience,\n visualEditorMode = VisualEditorMode.LazyLoad,\n debug,\n}: ExperienceRootProps) => {\n const mode = useDetectCanvasMode();\n\n if (typeof debug === 'boolean') {\n cfDebug.setActiveLevel(debug ? 'debug' : 'warn');\n }\n\n //If experience is passed in as a JSON string, recreate it to an experience object\n const experienceObject =\n typeof experience === 'string' ? createExperience(experience) : experience;\n\n validateExperienceBuilderConfig({\n locale,\n mode,\n });\n\n if (mode === StudioCanvasMode.EDITOR || mode === StudioCanvasMode.READ_ONLY) {\n return (\n <VisualEditorRoot\n experience={experienceObject as Experience<EntityStore> | undefined}\n visualEditorMode={visualEditorMode}\n initialLocale={locale}\n canvasMode={mode}\n />\n );\n }\n\n if (!experienceObject) return null;\n\n return <PreviewDeliveryRoot locale={locale} experience={experienceObject} />;\n};\n"],"names":[],"mappings":";;;;;;;;AA2Ba;AAMX;AAEA;AACE;;;AAIF;AAGA;;;AAGC;AAED;;;AAWA;AAAuB;;AAGzB;;"}
|
|
@@ -171,14 +171,14 @@ const CompositionBlock = ({ node: rawNode, locale, entityStore, hyperlinkPattern
|
|
|
171
171
|
return getPatternChildNodeClassName?.(childNodeId);
|
|
172
172
|
};
|
|
173
173
|
const { slotNodesMap, directChildNodes } = splitDirectAndSlotChildren(node.children, componentRegistration.definition);
|
|
174
|
-
const renderChildNode = (childNode) => (jsx(CompositionBlock, { getPatternChildNodeClassName: isPatternNode || getPatternChildNodeClassName ? _getPatternChildNodeClassName : undefined, node: childNode, locale: locale, hyperlinkPattern: hyperlinkPattern, entityStore: entityStore, resolveDesignValue: resolveDesignValue, wrappingPatternIds: wrappingPatternIds, wrappingParameters: wrappingParameters, patternRootNodeIdsChain: patternRootNodeIdsChain }, childNode.id));
|
|
174
|
+
const renderChildNode = (childNode, index) => (jsx(CompositionBlock, { getPatternChildNodeClassName: isPatternNode || getPatternChildNodeClassName ? _getPatternChildNodeClassName : undefined, node: childNode, locale: locale, hyperlinkPattern: hyperlinkPattern, entityStore: entityStore, resolveDesignValue: resolveDesignValue, wrappingPatternIds: wrappingPatternIds, wrappingParameters: wrappingParameters, patternRootNodeIdsChain: patternRootNodeIdsChain }, childNode.id ?? index));
|
|
175
175
|
const renderedSlotNodesMap = Object.entries(slotNodesMap).reduce((acc, [slotId, nodes]) => {
|
|
176
176
|
if (nodes?.length) {
|
|
177
|
-
acc[slotId] = jsx(Fragment, { children: nodes.map(
|
|
177
|
+
acc[slotId] = jsx(Fragment, { children: nodes.map(renderChildNode) });
|
|
178
178
|
}
|
|
179
179
|
return acc;
|
|
180
180
|
}, {});
|
|
181
|
-
const renderedChildren = directChildNodes?.map(
|
|
181
|
+
const renderedChildren = directChildNodes?.map(renderChildNode);
|
|
182
182
|
// TODO: we might be able to remove this special case as well by not dropping the two props in the sanitizeNodeProps function
|
|
183
183
|
if (isContainerOrSection(node.definitionId)) {
|
|
184
184
|
return (jsx(ContentfulContainer, { cfHyperlink: contentProps.cfHyperlink, cfOpenInNewTab: contentProps.cfOpenInNewTab, className: props.className, children: renderedChildren }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompositionBlock.js","sources":["../../../../src/blocks/preview/CompositionBlock.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\nimport type { UnresolvedLink } from 'contentful';\nimport { Entry } from 'contentful';\nimport {\n checkIsAssemblyEntry,\n checkIsAssemblyNode,\n EntityStore,\n resolveHyperlinkPattern,\n sanitizeNodeProps,\n transformBoundContentValue,\n splitDirectAndSlotChildren,\n} from '@contentful/experiences-core';\nimport {\n CONTENTFUL_COMPONENTS,\n HYPERLINK_DEFAULT_PATTERN,\n} from '@contentful/experiences-core/constants';\nimport type {\n ComponentTreeNode,\n DesignValue,\n Parameter,\n PrimitiveValue,\n ResolveDesignValueType,\n StyleProps,\n} from '@contentful/experiences-core/types';\nimport { createAssemblyRegistration, getComponentRegistration } from '../../core/componentRegistry';\nimport { useInjectStylesheet } from '../../hooks/useInjectStylesheet';\nimport { Assembly, ContentfulContainer } from '@contentful/experiences-components-react';\nimport { resolvePattern } from '../../core/preview/assemblyUtils';\nimport { resolveMaybePrebindingDefaultValuePath } from '../../utils/prebindingUtils';\nimport { parseComponentProps } from '../../utils/parseComponentProps';\n\ntype CompositionBlockProps = {\n node: ComponentTreeNode;\n locale: string;\n entityStore: EntityStore;\n hyperlinkPattern?: string | undefined;\n resolveDesignValue: ResolveDesignValueType;\n getPatternChildNodeClassName?: (childNodeId: string) => string | undefined;\n /** Set of definition IDs of wrapping patterns to prevent circular dependencies. */\n wrappingPatternIds?: Set<string>;\n /**\n * Chained IDs to ensure uniqueness across multiple instances of the same pattern\n * when storing & accessing cfSsrClassName.\n */\n patternRootNodeIdsChain?: string;\n wrappingParameters?: Record<string, Parameter>;\n};\n\nexport const CompositionBlock = ({\n node: rawNode,\n locale,\n entityStore,\n hyperlinkPattern,\n resolveDesignValue,\n getPatternChildNodeClassName,\n wrappingPatternIds: parentWrappingPatternIds = new Set(),\n wrappingParameters: parentWrappingParameters = {},\n patternRootNodeIdsChain: parentPatternRootNodeIdsChain = '',\n}: CompositionBlockProps) => {\n const isPatternNode = useMemo(() => {\n return checkIsAssemblyNode({\n componentId: rawNode.definitionId,\n usedComponents: entityStore.usedComponents,\n });\n }, [entityStore.usedComponents, rawNode.definitionId]);\n\n const isPatternEntry = useMemo(() => {\n return checkIsAssemblyEntry({ fields: entityStore.experienceEntryFields } as unknown as Entry);\n }, [entityStore]);\n\n const patternRootNodeIdsChain = useMemo(() => {\n if (isPatternNode) {\n // Pattern nodes are chained without a separator (following the format for prebinding/parameters)\n return `${parentPatternRootNodeIdsChain}${rawNode.id}`;\n }\n return parentPatternRootNodeIdsChain;\n }, [isPatternNode, parentPatternRootNodeIdsChain, rawNode.id]);\n\n const node = useMemo(() => {\n if (isPatternNode) {\n return resolvePattern({\n node: rawNode,\n entityStore,\n parentParameters: parentWrappingParameters,\n patternRootNodeIdsChain,\n });\n } else {\n return rawNode;\n }\n }, [entityStore, isPatternNode, rawNode, parentWrappingParameters, patternRootNodeIdsChain]);\n\n const wrappingPatternIds = useMemo(() => {\n if (isPatternNode) {\n return new Set([node.definitionId, ...parentWrappingPatternIds]);\n }\n return parentWrappingPatternIds;\n }, [isPatternNode, node, parentWrappingPatternIds]);\n\n // Merge the pattern properties of the current node with the parent's pattern properties\n // to ensure nested patterns receive relevant pattern properties that were bubbled up\n // during assembly serialization.\n const wrappingParameters = useMemo(() => {\n if (isPatternNode) {\n return { ...parentWrappingParameters, ...(rawNode.parameters || {}) };\n }\n return parentWrappingParameters;\n }, [isPatternNode, rawNode, parentWrappingParameters]);\n\n const componentRegistration = useMemo(() => {\n const registration = getComponentRegistration(node.definitionId as string);\n\n if (isPatternNode && !registration) {\n return createAssemblyRegistration({\n definitionId: node.definitionId as string,\n component: Assembly,\n });\n }\n return registration;\n }, [isPatternNode, node.definitionId]);\n\n const { ssrProps, contentProps, props, mediaQuery } = useMemo(() => {\n // In SSR, we store the className under breakpoints[0] which is resolved here to the actual string\n const cfSsrClassNameValues = node.variables.cfSsrClassName as DesignValue | undefined;\n const mainBreakpoint = entityStore.breakpoints[0];\n const cfSsrClassName = cfSsrClassNameValues?.valuesByBreakpoint?.[mainBreakpoint.id] as\n | string\n | undefined;\n\n // Don't enrich the assembly wrapper node with props\n if (!componentRegistration || isPatternNode) {\n const ssrProps = { cfSsrClassName };\n const props: Record<string, PrimitiveValue> = { className: cfSsrClassName };\n return {\n ssrProps,\n props,\n };\n }\n\n const ssrProps: Record<string, string | undefined> = {\n cfSsrClassName:\n node.id && getPatternChildNodeClassName\n ? getPatternChildNodeClassName(node.id)\n : cfSsrClassName,\n };\n\n const {\n contentProps = {},\n styleProps = {},\n customDesignProps = {},\n mediaQuery,\n } = parseComponentProps({\n breakpoints: entityStore.breakpoints,\n mainBreakpoint,\n componentDefinition: componentRegistration.definition,\n patternRootNodeIdsChain,\n node,\n resolveDesignValue,\n resolveBoundValue: ({ binding, propertyName, dataType }) => {\n const [, uuid] = binding.path.split('/');\n const boundEntityLink = entityStore.dataSource[uuid] as UnresolvedLink<'Entry' | 'Asset'>;\n return transformBoundContentValue(\n node.variables,\n entityStore,\n boundEntityLink,\n resolveDesignValue,\n propertyName,\n dataType,\n binding.path,\n );\n },\n resolveHyperlinkValue: ({ linkTargetKey }) => {\n const boundEntity = entityStore.dataSource[linkTargetKey];\n const hyperlinkEntry = entityStore.getEntryOrAsset(boundEntity, linkTargetKey);\n\n return resolveHyperlinkPattern(\n componentRegistration.definition.hyperlinkPattern ||\n hyperlinkPattern ||\n HYPERLINK_DEFAULT_PATTERN,\n hyperlinkEntry as Entry,\n locale,\n );\n },\n resolveUnboundValue: ({ mappingKey, defaultValue }) => {\n return entityStore.unboundValues[mappingKey]?.value ?? defaultValue;\n },\n resolvePrebindingValue: ({ mappingKey, propertyName, dataType, resolveBoundValue }) => {\n if (isPatternEntry) {\n const path = resolveMaybePrebindingDefaultValuePath({\n componentValueKey: mappingKey,\n entityStore,\n });\n\n if (path) {\n return resolveBoundValue({\n propertyName,\n dataType,\n binding: {\n type: 'BoundValue',\n path,\n },\n });\n }\n }\n },\n });\n\n const props: Record<string, PrimitiveValue> = {\n className: ssrProps.cfSsrClassName ?? mediaQuery?.className,\n ...styleProps,\n ...contentProps,\n ...customDesignProps,\n };\n\n return {\n ssrProps,\n contentProps,\n mediaQuery,\n props,\n };\n }, [\n node,\n isPatternEntry,\n entityStore,\n componentRegistration,\n isPatternNode,\n getPatternChildNodeClassName,\n resolveDesignValue,\n hyperlinkPattern,\n locale,\n patternRootNodeIdsChain,\n ]);\n\n // do not inject the stylesheet into the dom because it's already been done on the server side\n useInjectStylesheet(ssrProps.cfSsrClassName ? undefined : mediaQuery?.css);\n\n if (!componentRegistration) {\n return null;\n }\n\n // When detecting a circular dependency, we stop silently. The editor mode will render an actionable error.\n if (parentWrappingPatternIds.has(node.definitionId)) {\n return null;\n }\n\n const { component: component } = componentRegistration;\n\n // Retrieves the CSS class name for a given child node ID.\n const _getPatternChildNodeClassName = (childNodeId: string) => {\n if (isPatternNode) {\n const nodeIdsChain = `${patternRootNodeIdsChain}-${childNodeId}`;\n // @ts-expect-error -- property cfSsrClassName is a map (id to classNames) that is added during rendering in ssrStyles\n const classesForNode: DesignValue | undefined = node.variables.cfSsrClassName?.[nodeIdsChain];\n if (!classesForNode) return undefined;\n return resolveDesignValue(classesForNode.valuesByBreakpoint) as string;\n }\n return getPatternChildNodeClassName?.(childNodeId);\n };\n\n const { slotNodesMap, directChildNodes } = splitDirectAndSlotChildren(\n node.children,\n componentRegistration.definition,\n );\n\n const renderChildNode = (childNode: ComponentTreeNode) => (\n <CompositionBlock\n getPatternChildNodeClassName={\n isPatternNode || getPatternChildNodeClassName ? _getPatternChildNodeClassName : undefined\n }\n node={childNode}\n key={childNode.id}\n locale={locale}\n hyperlinkPattern={hyperlinkPattern}\n entityStore={entityStore}\n resolveDesignValue={resolveDesignValue}\n wrappingPatternIds={wrappingPatternIds}\n wrappingParameters={wrappingParameters}\n patternRootNodeIdsChain={patternRootNodeIdsChain}\n />\n );\n\n const renderedSlotNodesMap = Object.entries(slotNodesMap).reduce(\n (acc, [slotId, nodes]) => {\n if (nodes?.length) {\n acc[slotId] = <>{nodes.map((slotChildNode) => renderChildNode(slotChildNode))}</>;\n }\n return acc;\n },\n {} as Record<string, React.JSX.Element>,\n );\n\n const renderedChildren = directChildNodes?.map((childNode) => renderChildNode(childNode));\n\n // TODO: we might be able to remove this special case as well by not dropping the two props in the sanitizeNodeProps function\n if (isContainerOrSection(node.definitionId)) {\n return (\n <ContentfulContainer\n cfHyperlink={(contentProps as StyleProps).cfHyperlink}\n cfOpenInNewTab={(contentProps as StyleProps).cfOpenInNewTab}\n className={props.className as string | undefined}>\n {renderedChildren}\n </ContentfulContainer>\n );\n }\n\n return React.createElement(\n component,\n {\n ...sanitizeNodeProps(props),\n ...renderedSlotNodesMap,\n },\n renderedChildren,\n );\n};\n\nconst isContainerOrSection = (\n nodeDefinitionId: string,\n): nodeDefinitionId is 'contentful-container' | 'contentful-section' =>\n [CONTENTFUL_COMPONENTS.container.id, CONTENTFUL_COMPONENTS.section.id].includes(\n nodeDefinitionId as 'contentful-container' | 'contentful-section',\n );\n"],"names":["_jsx"],"mappings":";;;;;;;;;;;AAgDa,MAAA,gBAAgB,GAAG,CAAC,EAC/B,IAAI,EAAE,OAAO,EACb,MAAM,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AiE,CAClE;;;;"}
|
|
1
|
+
{"version":3,"file":"CompositionBlock.js","sources":["../../../../src/blocks/preview/CompositionBlock.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\nimport type { UnresolvedLink } from 'contentful';\nimport { Entry } from 'contentful';\nimport {\n checkIsAssemblyEntry,\n checkIsAssemblyNode,\n EntityStore,\n resolveHyperlinkPattern,\n sanitizeNodeProps,\n transformBoundContentValue,\n splitDirectAndSlotChildren,\n} from '@contentful/experiences-core';\nimport {\n CONTENTFUL_COMPONENTS,\n HYPERLINK_DEFAULT_PATTERN,\n} from '@contentful/experiences-core/constants';\nimport type {\n ComponentTreeNode,\n DesignValue,\n Parameter,\n PrimitiveValue,\n ResolveDesignValueType,\n StyleProps,\n} from '@contentful/experiences-core/types';\nimport { createAssemblyRegistration, getComponentRegistration } from '../../core/componentRegistry';\nimport { useInjectStylesheet } from '../../hooks/useInjectStylesheet';\nimport { Assembly, ContentfulContainer } from '@contentful/experiences-components-react';\nimport { resolvePattern } from '../../core/preview/assemblyUtils';\nimport { resolveMaybePrebindingDefaultValuePath } from '../../utils/prebindingUtils';\nimport { parseComponentProps } from '../../utils/parseComponentProps';\n\ntype CompositionBlockProps = {\n node: ComponentTreeNode;\n locale: string;\n entityStore: EntityStore;\n hyperlinkPattern?: string | undefined;\n resolveDesignValue: ResolveDesignValueType;\n getPatternChildNodeClassName?: (childNodeId: string) => string | undefined;\n /** Set of definition IDs of wrapping patterns to prevent circular dependencies. */\n wrappingPatternIds?: Set<string>;\n /**\n * Chained IDs to ensure uniqueness across multiple instances of the same pattern\n * when storing & accessing cfSsrClassName.\n */\n patternRootNodeIdsChain?: string;\n wrappingParameters?: Record<string, Parameter>;\n};\n\nexport const CompositionBlock = ({\n node: rawNode,\n locale,\n entityStore,\n hyperlinkPattern,\n resolveDesignValue,\n getPatternChildNodeClassName,\n wrappingPatternIds: parentWrappingPatternIds = new Set(),\n wrappingParameters: parentWrappingParameters = {},\n patternRootNodeIdsChain: parentPatternRootNodeIdsChain = '',\n}: CompositionBlockProps) => {\n const isPatternNode = useMemo(() => {\n return checkIsAssemblyNode({\n componentId: rawNode.definitionId,\n usedComponents: entityStore.usedComponents,\n });\n }, [entityStore.usedComponents, rawNode.definitionId]);\n\n const isPatternEntry = useMemo(() => {\n return checkIsAssemblyEntry({ fields: entityStore.experienceEntryFields } as unknown as Entry);\n }, [entityStore]);\n\n const patternRootNodeIdsChain = useMemo(() => {\n if (isPatternNode) {\n // Pattern nodes are chained without a separator (following the format for prebinding/parameters)\n return `${parentPatternRootNodeIdsChain}${rawNode.id}`;\n }\n return parentPatternRootNodeIdsChain;\n }, [isPatternNode, parentPatternRootNodeIdsChain, rawNode.id]);\n\n const node = useMemo(() => {\n if (isPatternNode) {\n return resolvePattern({\n node: rawNode,\n entityStore,\n parentParameters: parentWrappingParameters,\n patternRootNodeIdsChain,\n });\n } else {\n return rawNode;\n }\n }, [entityStore, isPatternNode, rawNode, parentWrappingParameters, patternRootNodeIdsChain]);\n\n const wrappingPatternIds = useMemo(() => {\n if (isPatternNode) {\n return new Set([node.definitionId, ...parentWrappingPatternIds]);\n }\n return parentWrappingPatternIds;\n }, [isPatternNode, node, parentWrappingPatternIds]);\n\n // Merge the pattern properties of the current node with the parent's pattern properties\n // to ensure nested patterns receive relevant pattern properties that were bubbled up\n // during assembly serialization.\n const wrappingParameters = useMemo(() => {\n if (isPatternNode) {\n return { ...parentWrappingParameters, ...(rawNode.parameters || {}) };\n }\n return parentWrappingParameters;\n }, [isPatternNode, rawNode, parentWrappingParameters]);\n\n const componentRegistration = useMemo(() => {\n const registration = getComponentRegistration(node.definitionId as string);\n\n if (isPatternNode && !registration) {\n return createAssemblyRegistration({\n definitionId: node.definitionId as string,\n component: Assembly,\n });\n }\n return registration;\n }, [isPatternNode, node.definitionId]);\n\n const { ssrProps, contentProps, props, mediaQuery } = useMemo(() => {\n // In SSR, we store the className under breakpoints[0] which is resolved here to the actual string\n const cfSsrClassNameValues = node.variables.cfSsrClassName as DesignValue | undefined;\n const mainBreakpoint = entityStore.breakpoints[0];\n const cfSsrClassName = cfSsrClassNameValues?.valuesByBreakpoint?.[mainBreakpoint.id] as\n | string\n | undefined;\n\n // Don't enrich the assembly wrapper node with props\n if (!componentRegistration || isPatternNode) {\n const ssrProps = { cfSsrClassName };\n const props: Record<string, PrimitiveValue> = { className: cfSsrClassName };\n return {\n ssrProps,\n props,\n };\n }\n\n const ssrProps: Record<string, string | undefined> = {\n cfSsrClassName:\n node.id && getPatternChildNodeClassName\n ? getPatternChildNodeClassName(node.id)\n : cfSsrClassName,\n };\n\n const {\n contentProps = {},\n styleProps = {},\n customDesignProps = {},\n mediaQuery,\n } = parseComponentProps({\n breakpoints: entityStore.breakpoints,\n mainBreakpoint,\n componentDefinition: componentRegistration.definition,\n patternRootNodeIdsChain,\n node,\n resolveDesignValue,\n resolveBoundValue: ({ binding, propertyName, dataType }) => {\n const [, uuid] = binding.path.split('/');\n const boundEntityLink = entityStore.dataSource[uuid] as UnresolvedLink<'Entry' | 'Asset'>;\n return transformBoundContentValue(\n node.variables,\n entityStore,\n boundEntityLink,\n resolveDesignValue,\n propertyName,\n dataType,\n binding.path,\n );\n },\n resolveHyperlinkValue: ({ linkTargetKey }) => {\n const boundEntity = entityStore.dataSource[linkTargetKey];\n const hyperlinkEntry = entityStore.getEntryOrAsset(boundEntity, linkTargetKey);\n\n return resolveHyperlinkPattern(\n componentRegistration.definition.hyperlinkPattern ||\n hyperlinkPattern ||\n HYPERLINK_DEFAULT_PATTERN,\n hyperlinkEntry as Entry,\n locale,\n );\n },\n resolveUnboundValue: ({ mappingKey, defaultValue }) => {\n return entityStore.unboundValues[mappingKey]?.value ?? defaultValue;\n },\n resolvePrebindingValue: ({ mappingKey, propertyName, dataType, resolveBoundValue }) => {\n if (isPatternEntry) {\n const path = resolveMaybePrebindingDefaultValuePath({\n componentValueKey: mappingKey,\n entityStore,\n });\n\n if (path) {\n return resolveBoundValue({\n propertyName,\n dataType,\n binding: {\n type: 'BoundValue',\n path,\n },\n });\n }\n }\n },\n });\n\n const props: Record<string, PrimitiveValue> = {\n className: ssrProps.cfSsrClassName ?? mediaQuery?.className,\n ...styleProps,\n ...contentProps,\n ...customDesignProps,\n };\n\n return {\n ssrProps,\n contentProps,\n mediaQuery,\n props,\n };\n }, [\n node,\n isPatternEntry,\n entityStore,\n componentRegistration,\n isPatternNode,\n getPatternChildNodeClassName,\n resolveDesignValue,\n hyperlinkPattern,\n locale,\n patternRootNodeIdsChain,\n ]);\n\n // do not inject the stylesheet into the dom because it's already been done on the server side\n useInjectStylesheet(ssrProps.cfSsrClassName ? undefined : mediaQuery?.css);\n\n if (!componentRegistration) {\n return null;\n }\n\n // When detecting a circular dependency, we stop silently. The editor mode will render an actionable error.\n if (parentWrappingPatternIds.has(node.definitionId)) {\n return null;\n }\n\n const { component: component } = componentRegistration;\n\n // Retrieves the CSS class name for a given child node ID.\n const _getPatternChildNodeClassName = (childNodeId: string) => {\n if (isPatternNode) {\n const nodeIdsChain = `${patternRootNodeIdsChain}-${childNodeId}`;\n // @ts-expect-error -- property cfSsrClassName is a map (id to classNames) that is added during rendering in ssrStyles\n const classesForNode: DesignValue | undefined = node.variables.cfSsrClassName?.[nodeIdsChain];\n if (!classesForNode) return undefined;\n return resolveDesignValue(classesForNode.valuesByBreakpoint) as string;\n }\n return getPatternChildNodeClassName?.(childNodeId);\n };\n\n const { slotNodesMap, directChildNodes } = splitDirectAndSlotChildren(\n node.children,\n componentRegistration.definition,\n );\n\n const renderChildNode = (childNode: ComponentTreeNode, index: number) => (\n <CompositionBlock\n getPatternChildNodeClassName={\n isPatternNode || getPatternChildNodeClassName ? _getPatternChildNodeClassName : undefined\n }\n node={childNode}\n key={childNode.id ?? index}\n locale={locale}\n hyperlinkPattern={hyperlinkPattern}\n entityStore={entityStore}\n resolveDesignValue={resolveDesignValue}\n wrappingPatternIds={wrappingPatternIds}\n wrappingParameters={wrappingParameters}\n patternRootNodeIdsChain={patternRootNodeIdsChain}\n />\n );\n\n const renderedSlotNodesMap = Object.entries(slotNodesMap).reduce(\n (acc, [slotId, nodes]) => {\n if (nodes?.length) {\n acc[slotId] = <>{nodes.map(renderChildNode)}</>;\n }\n return acc;\n },\n {} as Record<string, React.JSX.Element>,\n );\n\n const renderedChildren = directChildNodes?.map(renderChildNode);\n\n // TODO: we might be able to remove this special case as well by not dropping the two props in the sanitizeNodeProps function\n if (isContainerOrSection(node.definitionId)) {\n return (\n <ContentfulContainer\n cfHyperlink={(contentProps as StyleProps).cfHyperlink}\n cfOpenInNewTab={(contentProps as StyleProps).cfOpenInNewTab}\n className={props.className as string | undefined}>\n {renderedChildren}\n </ContentfulContainer>\n );\n }\n\n return React.createElement(\n component,\n {\n ...sanitizeNodeProps(props),\n ...renderedSlotNodesMap,\n },\n renderedChildren,\n );\n};\n\nconst isContainerOrSection = (\n nodeDefinitionId: string,\n): nodeDefinitionId is 'contentful-container' | 'contentful-section' =>\n [CONTENTFUL_COMPONENTS.container.id, CONTENTFUL_COMPONENTS.section.id].includes(\n nodeDefinitionId as 'contentful-container' | 'contentful-section',\n );\n"],"names":["_jsx","_Fragment"],"mappings":";;;;;;;;;;;AAgDa,MAAA,gBAAgB,GAAG,CAAC,EAC/B,IAAI,EAAE,OAAO,EACb,MAAM,EACN,WAAW,EACX,gBAAgB,EAChB,kBAAkB,EAClB,4BAA4B,EAC5B,kBAAkB,EAAE,wBAAwB,GAAG,IAAI,GAAG,EAAE,EACxD,kBAAkB,EAAE,wBAAwB,GAAG,EAAE,EACjD,uBAAuB,EAAE,6BAA6B,GAAG,EAAE,GACrC,KAAI;AAC1B,IAAA,MAAM,aAAa,GAAG,OAAO,CAAC,MAAK;AACjC,QAAA,OAAO,mBAAmB,CAAC;YACzB,WAAW,EAAE,OAAO,CAAC,YAAY;YACjC,cAAc,EAAE,WAAW,CAAC,cAAc;AAC3C,SAAA,CAAC,CAAC;KACJ,EAAE,CAAC,WAAW,CAAC,cAAc,EAAE,OAAO,CAAC,YAAY,CAAC,CA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KAAK,CAAC,GAAG,CAAC,eAAe,CAAC,EAAA,CAAI,CAAC;SACjD;AACD,QAAA,OAAO,GAAG,CAAC;KACZ,EACD,EAAuC,CACxC,CAAC;IAEF,MAAM,gBAAgB,GAAG,gBAAgB,EAAE,GAAG,CAAC,eAAe,CAAC,CAAC;;AAGhE,IAAA,IAAI,oBAAoB,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE;QAC3C,QACED,GAAC,CAAA,mBAAmB,EAClB,EAAA,WAAW,EAAG,YAA2B,CAAC,WAAW,EACrD,cAAc,EAAG,YAA2B,CAAC,cAAc,EAC3D,SAAS,EAAE,KAAK,CAAC,SAA+B,EAC/C,QAAA,EAAA,gBAAgB,EACG,CAAA,EACtB;KACH;AAED,IAAA,OAAO,KAAK,CAAC,aAAa,CACxB,SAAS,EACT;QACE,GAAG,iBAAiB,CAAC,KAAK,CAAC;AAC3B,QAAA,GAAG,oBAAoB;KACxB,EACD,gBAAgB,CACjB,CAAC;AACJ,EAAE;AAEF,MAAM,oBAAoB,GAAG,CAC3B,gBAAwB,KAExB,CAAC,qBAAqB,CAAC,SAAS,CAAC,EAAE,EAAE,qBAAqB,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,QAAQ,CAC7E,gBAAiE,CAClE;;;;"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { debug } from '@contentful/experiences-core';
|
|
2
3
|
import { CompositionBlock } from './CompositionBlock.js';
|
|
3
4
|
import { compatibleVersions } from '../../constants.js';
|
|
4
5
|
import { useBreakpoints } from '../../hooks/useBreakpoints.js';
|
|
5
6
|
import 'react';
|
|
6
7
|
import '@contentful/experiences-core/constants';
|
|
7
|
-
import '@contentful/experiences-core';
|
|
8
8
|
|
|
9
9
|
const PreviewDeliveryRoot = ({ locale, experience }) => {
|
|
10
10
|
const { entityStore } = experience;
|
|
@@ -13,7 +13,7 @@ const PreviewDeliveryRoot = ({ locale, experience }) => {
|
|
|
13
13
|
return null;
|
|
14
14
|
}
|
|
15
15
|
if (!compatibleVersions.includes(entityStore.schemaVersion)) {
|
|
16
|
-
|
|
16
|
+
debug.warn(`[experiences-sdk-react::PreviewDeliveryRoot] Contentful experience schema version: ${entityStore.schemaVersion} does not match the compatible schema versions: ${compatibleVersions}. Aborting.`);
|
|
17
17
|
return null;
|
|
18
18
|
}
|
|
19
19
|
return (jsx(Fragment, { children: entityStore.experienceEntryFields.componentTree.children.map((childNode, index) => (jsx(CompositionBlock, { node: childNode, hyperlinkPattern: experience.hyperlinkPattern, locale: locale, entityStore: entityStore, resolveDesignValue: resolveDesignValue }, index))) }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PreviewDeliveryRoot.js","sources":["../../../../src/blocks/preview/PreviewDeliveryRoot.tsx"],"sourcesContent":["import React from 'react';\nimport { EntityStore } from '@contentful/experiences-core';\nimport type { Experience } from '@contentful/experiences-core/types';\nimport { CompositionBlock } from './CompositionBlock';\nimport { compatibleVersions } from '../../constants';\nimport { useBreakpoints } from '../../hooks';\n\ntype DeliveryRootProps = {\n experience: Experience<EntityStore>;\n locale: string;\n};\n\nexport const PreviewDeliveryRoot = ({ locale, experience }: DeliveryRootProps) => {\n const { entityStore } = experience;\n\n const { resolveDesignValue } = useBreakpoints(entityStore?.breakpoints ?? []);\n\n if (!entityStore?.experienceEntryFields || !entityStore?.schemaVersion) {\n return null;\n }\n\n if (!compatibleVersions.includes(entityStore.schemaVersion)) {\n
|
|
1
|
+
{"version":3,"file":"PreviewDeliveryRoot.js","sources":["../../../../src/blocks/preview/PreviewDeliveryRoot.tsx"],"sourcesContent":["import React from 'react';\nimport { debug, EntityStore } from '@contentful/experiences-core';\nimport type { Experience } from '@contentful/experiences-core/types';\nimport { CompositionBlock } from './CompositionBlock';\nimport { compatibleVersions } from '../../constants';\nimport { useBreakpoints } from '../../hooks';\n\ntype DeliveryRootProps = {\n experience: Experience<EntityStore>;\n locale: string;\n};\n\nexport const PreviewDeliveryRoot = ({ locale, experience }: DeliveryRootProps) => {\n const { entityStore } = experience;\n\n const { resolveDesignValue } = useBreakpoints(entityStore?.breakpoints ?? []);\n\n if (!entityStore?.experienceEntryFields || !entityStore?.schemaVersion) {\n return null;\n }\n\n if (!compatibleVersions.includes(entityStore.schemaVersion)) {\n debug.warn(\n `[experiences-sdk-react::PreviewDeliveryRoot] Contentful experience schema version: ${entityStore.schemaVersion} does not match the compatible schema versions: ${compatibleVersions}. Aborting.`,\n );\n return null;\n }\n\n return (\n <>\n {entityStore.experienceEntryFields.componentTree.children.map((childNode, index) => (\n <CompositionBlock\n key={index}\n node={childNode}\n hyperlinkPattern={experience.hyperlinkPattern}\n locale={locale}\n entityStore={entityStore}\n resolveDesignValue={resolveDesignValue}\n />\n ))}\n </>\n );\n};\n"],"names":["_jsx"],"mappings":";;;;;;;;AAYa,MAAA,mBAAmB,GAAG,CAAC,EAAE,MAAM,EAAE,UAAU,EAAqB,KAAI;AAC/E,IAAA,MAAM,EAAE,WAAW,EAAE,GAAG,UAAU,CAAC;AAEnC,IAAA,MAAM,EAAE,kBAAkB,EAAE,GAAG,cAAc,CAAC,WAAW,EAAE,WAAW,IAAI,EAAE,CAAC,CAAC;IAE9E,IAAI,CAAC,WAAW,EAAE,qBAAqB,IAAI,CAAC,WAAW,EAAE,aAAa,EAAE;AACtE,QAAA,OAAO,IAAI,CAAC;KACb;IAED,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,WAAW,CAAC,aAAa,CAAC,EAAE;QAC3D,KAAK,CAAC,IAAI,CACR,CAAsF,mFAAA,EAAA,WAAW,CAAC,aAAa,CAAmD,gDAAA,EAAA,kBAAkB,CAAa,WAAA,CAAA,CAClM,CAAC;AACF,QAAA,OAAO,IAAI,CAAC;KACb;IAED,QACEA,0BACG,WAAW,CAAC,qBAAqB,CAAC,aAAa,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,KAAK,MAC7EA,GAAA,CAAC,gBAAgB,EAAA,EAEf,IAAI,EAAE,SAAS,EACf,gBAAgB,EAAE,UAAU,CAAC,gBAAgB,EAC7C,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW,EACxB,kBAAkB,EAAE,kBAAkB,EALjC,EAAA,KAAK,CAMV,CACH,CAAC,EACD,CAAA,EACH;AACJ;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import * as _contentful_experiences_core_constants from '@contentful/experiences
|
|
|
9
9
|
export { CF_STYLE_ATTRIBUTES, CONTENTFUL_COMPONENTS, LATEST_SCHEMA_VERSION } from '@contentful/experiences-core/constants';
|
|
10
10
|
import { ContentfulClientApi } from 'contentful';
|
|
11
11
|
|
|
12
|
-
declare const SDK_VERSION = "3.4.0";
|
|
12
|
+
declare const SDK_VERSION = "3.4.1-dev-20250828T1024-c2a782a.0";
|
|
13
13
|
|
|
14
14
|
type ExperienceRootProps = {
|
|
15
15
|
experience?: Experience<EntityStore> | string | null;
|
package/dist/sdkVersion.js
CHANGED
package/dist/sdkVersion.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdkVersion.js","sources":["../../src/sdkVersion.ts"],"sourcesContent":["export const SDK_VERSION = '3.4.0';\n"],"names":[],"mappings":"AAAO,MAAM,WAAW,GAAG;;;;"}
|
|
1
|
+
{"version":3,"file":"sdkVersion.js","sources":["../../src/sdkVersion.ts"],"sourcesContent":["export const SDK_VERSION = '3.4.1-dev-20250828T1024-c2a782a.0';\n"],"names":[],"mappings":"AAAO,MAAM,WAAW,GAAG;;;;"}
|
package/dist/src/sdkVersion.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "3.4.0";
|
|
1
|
+
export declare const SDK_VERSION = "3.4.1-dev-20250828T1024-c2a782a.0";
|
|
@@ -19,7 +19,7 @@ const parseComponentProps = ({ breakpoints, componentDefinition, patternRootNode
|
|
|
19
19
|
const styleProps = {};
|
|
20
20
|
const customDesignProps = {};
|
|
21
21
|
const contentProps = {};
|
|
22
|
-
debug.log('Parsing component props for node with id: ', node.id);
|
|
22
|
+
debug.log('[experiences-sdk-react::parseComponentProps] Parsing component props for node with id: ', node.id);
|
|
23
23
|
for (const [propName, propDefinition] of Object.entries(componentDefinition.variables)) {
|
|
24
24
|
const propertyValue = node.variables[propName];
|
|
25
25
|
if (!propertyValue)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseComponentProps.js","sources":["../../../src/utils/parseComponentProps.ts"],"sourcesContent":["import { isCfStyleAttribute, debug } from '@contentful/experiences-core';\nimport {\n BoundComponentPropertyTypes,\n BoundValue,\n Breakpoint,\n ComponentDefinition,\n ComponentDefinitionVariable,\n ComponentDefinitionVariableType,\n ComponentTreeNode,\n DesignValue,\n PrimitiveValue,\n ResolveDesignValueType,\n} from '@contentful/experiences-core/types';\nimport { convertResolvedDesignValuesToMediaQuery } from '../core/styles/convertResolvedDesignValuesToMediaQuery';\nimport { createStylesheetsForBuiltInStyles } from '../core/styles/createStylesheetsForBuiltInStyles';\n\n// TODO: Test this for nested patterns as the name might be just a random hash without the actual name (needs to be validated).\n/**\n * Checks if prop is a \"siamese\" prop. So far we have only one such prop: `cfBackgroundImageUrl`.\n * It is considered \"siamese\" because despite being a content variable, it always goes in pair\n * (is coupled) with the `cfBackgroundImageOptions` design variable. Without presence of the\n * `cfBackgroundImageUrl` the `cfBackgroundImageOptions` is useless (and is not going to be\n * rendered by the styleTransformers.ts#transformBackgroundImageUrl()).\n *\n * Because of this coupling, we need to create an \"ephemeral\" cfBackgroundImageUrl style(!) prop.\n */\nconst isSpecialCaseCssProp = (propName: string) => {\n return propName === 'cfBackgroundImageUrl' || propName.startsWith('cfBackgroundImageUrl_');\n};\n\n/**\n * The previous logic of prop mapping was too complex and mixed different ues cases together.\n * In this function, I aim to simplify the logic by focusing on the following specific cases FOR PREVIEW/DELIVERY MODES\n * 1) Any non `DesignValue` props should be resolved and returned as is\n * 2) Some exceptions like `cfImageAsset` and `cfBackgroundImageUrl` (BoundValue) should be handled separately\n * and be resolved for the default breakpoint only (cause we don't allow binding per breakpoint anyway)\n * 3) Those DesignValue props which can be converted to CSS should be grouped and resolved into a CSS media query\n * for each breakpoint\n * 4) Those DesignValue props which can NOT be converted to CSS (custom design props) should be resolved dynamically\n * for each breakpoint\n */\ntype ResolveBoundValueType = (data: {\n propertyName: string;\n dataType: ComponentDefinitionVariableType;\n binding: BoundValue;\n}) => BoundComponentPropertyTypes;\n\nexport const parseComponentProps = ({\n breakpoints,\n componentDefinition,\n patternRootNodeIdsChain,\n node,\n resolveDesignValue,\n resolveBoundValue,\n resolveHyperlinkValue,\n resolveUnboundValue,\n resolvePrebindingValue,\n}: {\n breakpoints: Breakpoint[];\n mainBreakpoint: Breakpoint;\n componentDefinition: ComponentDefinition;\n patternRootNodeIdsChain?: string;\n node: ComponentTreeNode;\n resolveDesignValue: ResolveDesignValueType;\n resolveBoundValue: ResolveBoundValueType;\n resolveHyperlinkValue: (data: { linkTargetKey: string }) => string | null;\n resolveUnboundValue: (data: {\n mappingKey: string;\n defaultValue: ComponentDefinitionVariable['defaultValue'];\n }) => PrimitiveValue;\n resolvePrebindingValue: (data: {\n propertyName: string;\n mappingKey: string;\n dataType: ComponentDefinitionVariableType;\n resolveBoundValue: ResolveBoundValueType;\n }) => PrimitiveValue;\n}) => {\n const styleProps: Record<string, DesignValue['valuesByBreakpoint']> = {};\n const customDesignProps: Record<string, PrimitiveValue> = {};\n const contentProps: Record<string, PrimitiveValue> = {};\n\n debug.log('Parsing component props for node with id: ', node.id);\n\n for (const [propName, propDefinition] of Object.entries(componentDefinition.variables)) {\n const propertyValue = node.variables[propName];\n if (!propertyValue) continue;\n\n switch (propertyValue.type) {\n case 'DesignValue': {\n if (isCfStyleAttribute(propName)) {\n // for such properties we know how to convert them to CSS, so we will build a media query from it below after the loop is over\n styleProps[propName] = propertyValue.valuesByBreakpoint;\n } else {\n // for custom design props, the value will be resolved with the javascript per breakpoint at runtime\n customDesignProps[propName] = resolveDesignValue(propertyValue.valuesByBreakpoint);\n }\n break;\n }\n case 'BoundValue': {\n const boundValue = resolveBoundValue({\n propertyName: propName,\n dataType: propDefinition.type as ComponentDefinitionVariableType,\n binding: propertyValue,\n });\n\n const propValue = boundValue ?? propDefinition.defaultValue;\n\n if (isSpecialCaseCssProp(propName)) {\n // styleProps[propName] = { [mainBreakpoint.id]: propValue };\n // Here we create kind of \"fake\" style property out of a bound value.\n // As bound values are breakpoint-universal (they apply to all breakpoints),\n // but styleProps are breakpoint-specific, we need to ensure that\n // semantically our \"fake\" emphemeral style property will be universall as well,\n // by expanding it to all the breakpoints. This is important as\n // styleTransformers.ts#transformBackgroundImageUrl() expects\n // cfBackgroundImageUrl to be present for all breakpoints\n // where cfBackgroundImageOptions is present.\n styleProps[propName] = Object.fromEntries(breakpoints.map((b) => [b.id, propValue]));\n } else {\n contentProps[propName] = propValue;\n }\n break;\n }\n\n case 'HyperlinkValue': {\n const hyperlink = resolveHyperlinkValue({\n linkTargetKey: propertyValue.linkTargetKey,\n });\n if (hyperlink) {\n contentProps[propName] = hyperlink;\n }\n break;\n }\n case 'UnboundValue': {\n const unboundValue = resolveUnboundValue({\n mappingKey: propertyValue.key,\n defaultValue: propDefinition.defaultValue,\n });\n\n if (isSpecialCaseCssProp(propName)) {\n styleProps[propName] = Object.fromEntries(breakpoints.map((b) => [b.id, unboundValue]));\n } else {\n contentProps[propName] = unboundValue;\n }\n break;\n }\n case 'ComponentValue': {\n // This can either be a design (style) or a content property.\n // Where prebinding is used, we resolve like they are a BoundValue.\n const propValue =\n resolvePrebindingValue({\n propertyName: propName,\n mappingKey: propertyValue.key,\n dataType: propDefinition.type,\n resolveBoundValue,\n }) ?? propDefinition.defaultValue;\n\n if (isSpecialCaseCssProp(propName)) {\n styleProps[propName] = Object.fromEntries(breakpoints.map((b) => [b.id, propValue]));\n } else {\n contentProps[propName] = propValue;\n }\n break;\n }\n default:\n break;\n }\n }\n /* [Data Format] After resolving all properties, `styleProps` contains solely the plain design values\n * styleProps = {\n * cfMargin: { desktop: '42px', tablet: '13px' },\n * cfBackgroundColor: { desktop: 'rgba(246, 246, 246, 1)' },\n * cfBackgroundImage: { desktop: 'url(https://example.com/image.jpg)' }\n * }\n */\n\n const stylePropsIndexedByBreakpoint = Object.entries(styleProps).reduce<\n Record<string, Record<string, PrimitiveValue>>\n >((acc, [propName, valuesByBreakpoint]) => {\n for (const [breakpointId, value] of Object.entries(valuesByBreakpoint)) {\n if (!acc[breakpointId]) {\n acc[breakpointId] = {};\n }\n\n acc[breakpointId][propName] = value;\n }\n\n return acc;\n }, {});\n /* [Data Format] `stylePropsIndexedByBreakpoint` contains the plain design values grouped by breakpoint\n * stylePropsIndexedByBreakpoint = {\n * desktop: {\n * cfMargin: '42px',\n * cfBackgroundColor: 'rgba(246, 246, 246, 1)',\n * cfBackgroundImage: 'url(https://example.com/image.jpg)'\n * },\n * tablet: {\n * cfMargin: '13px'\n * }\n * }\n */\n\n const stylesheetData = createStylesheetsForBuiltInStyles({\n designPropertiesByBreakpoint: stylePropsIndexedByBreakpoint,\n breakpoints,\n node,\n patternRootNodeIdsChain,\n });\n /* [Data Format] Stylesheet data provides objects containing `className`, `breakpointCondition`, and `css`.\n * stylesheetData = [{\n * className: 'uniqueMD5Hash',\n * breakpointCondition: '<768px',\n * css: 'margin:13px;'\n * visibilityCss: 'display:none !important;'\n * }, ...]\n */\n const mediaQuery = convertResolvedDesignValuesToMediaQuery(stylesheetData);\n /* [Data Format] `mediaQuery` is a joined string of all media query CSS code\n * mediaQuery = \".cfstyles-123{margin:42px;}@media(max-width:768px){.cfstyles-456{margin:13px;}}\"\n */\n return {\n styleProps,\n mediaQuery,\n customDesignProps,\n contentProps,\n };\n};\n"],"names":[],"mappings":";;;;AAgBA;AACA;;;;;;;;AAQG;AACH,MAAM,oBAAoB,GAAG,CAAC,QAAgB,KAAI;IAChD,OAAO,QAAQ,KAAK,sBAAsB,IAAI,QAA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ponentProps.js","sources":["../../../src/utils/parseComponentProps.ts"],"sourcesContent":["import { isCfStyleAttribute, debug } from '@contentful/experiences-core';\nimport {\n BoundComponentPropertyTypes,\n BoundValue,\n Breakpoint,\n ComponentDefinition,\n ComponentDefinitionVariable,\n ComponentDefinitionVariableType,\n ComponentTreeNode,\n DesignValue,\n PrimitiveValue,\n ResolveDesignValueType,\n} from '@contentful/experiences-core/types';\nimport { convertResolvedDesignValuesToMediaQuery } from '../core/styles/convertResolvedDesignValuesToMediaQuery';\nimport { createStylesheetsForBuiltInStyles } from '../core/styles/createStylesheetsForBuiltInStyles';\n\n// TODO: Test this for nested patterns as the name might be just a random hash without the actual name (needs to be validated).\n/**\n * Checks if prop is a \"siamese\" prop. So far we have only one such prop: `cfBackgroundImageUrl`.\n * It is considered \"siamese\" because despite being a content variable, it always goes in pair\n * (is coupled) with the `cfBackgroundImageOptions` design variable. Without presence of the\n * `cfBackgroundImageUrl` the `cfBackgroundImageOptions` is useless (and is not going to be\n * rendered by the styleTransformers.ts#transformBackgroundImageUrl()).\n *\n * Because of this coupling, we need to create an \"ephemeral\" cfBackgroundImageUrl style(!) prop.\n */\nconst isSpecialCaseCssProp = (propName: string) => {\n return propName === 'cfBackgroundImageUrl' || propName.startsWith('cfBackgroundImageUrl_');\n};\n\n/**\n * The previous logic of prop mapping was too complex and mixed different ues cases together.\n * In this function, I aim to simplify the logic by focusing on the following specific cases FOR PREVIEW/DELIVERY MODES\n * 1) Any non `DesignValue` props should be resolved and returned as is\n * 2) Some exceptions like `cfImageAsset` and `cfBackgroundImageUrl` (BoundValue) should be handled separately\n * and be resolved for the default breakpoint only (cause we don't allow binding per breakpoint anyway)\n * 3) Those DesignValue props which can be converted to CSS should be grouped and resolved into a CSS media query\n * for each breakpoint\n * 4) Those DesignValue props which can NOT be converted to CSS (custom design props) should be resolved dynamically\n * for each breakpoint\n */\ntype ResolveBoundValueType = (data: {\n propertyName: string;\n dataType: ComponentDefinitionVariableType;\n binding: BoundValue;\n}) => BoundComponentPropertyTypes;\n\nexport const parseComponentProps = ({\n breakpoints,\n componentDefinition,\n patternRootNodeIdsChain,\n node,\n resolveDesignValue,\n resolveBoundValue,\n resolveHyperlinkValue,\n resolveUnboundValue,\n resolvePrebindingValue,\n}: {\n breakpoints: Breakpoint[];\n mainBreakpoint: Breakpoint;\n componentDefinition: ComponentDefinition;\n patternRootNodeIdsChain?: string;\n node: ComponentTreeNode;\n resolveDesignValue: ResolveDesignValueType;\n resolveBoundValue: ResolveBoundValueType;\n resolveHyperlinkValue: (data: { linkTargetKey: string }) => string | null;\n resolveUnboundValue: (data: {\n mappingKey: string;\n defaultValue: ComponentDefinitionVariable['defaultValue'];\n }) => PrimitiveValue;\n resolvePrebindingValue: (data: {\n propertyName: string;\n mappingKey: string;\n dataType: ComponentDefinitionVariableType;\n resolveBoundValue: ResolveBoundValueType;\n }) => PrimitiveValue;\n}) => {\n const styleProps: Record<string, DesignValue['valuesByBreakpoint']> = {};\n const customDesignProps: Record<string, PrimitiveValue> = {};\n const contentProps: Record<string, PrimitiveValue> = {};\n\n debug.log(\n '[experiences-sdk-react::parseComponentProps] Parsing component props for node with id: ',\n node.id,\n );\n\n for (const [propName, propDefinition] of Object.entries(componentDefinition.variables)) {\n const propertyValue = node.variables[propName];\n if (!propertyValue) continue;\n\n switch (propertyValue.type) {\n case 'DesignValue': {\n if (isCfStyleAttribute(propName)) {\n // for such properties we know how to convert them to CSS, so we will build a media query from it below after the loop is over\n styleProps[propName] = propertyValue.valuesByBreakpoint;\n } else {\n // for custom design props, the value will be resolved with the javascript per breakpoint at runtime\n customDesignProps[propName] = resolveDesignValue(propertyValue.valuesByBreakpoint);\n }\n break;\n }\n case 'BoundValue': {\n const boundValue = resolveBoundValue({\n propertyName: propName,\n dataType: propDefinition.type as ComponentDefinitionVariableType,\n binding: propertyValue,\n });\n\n const propValue = boundValue ?? propDefinition.defaultValue;\n\n if (isSpecialCaseCssProp(propName)) {\n // styleProps[propName] = { [mainBreakpoint.id]: propValue };\n // Here we create kind of \"fake\" style property out of a bound value.\n // As bound values are breakpoint-universal (they apply to all breakpoints),\n // but styleProps are breakpoint-specific, we need to ensure that\n // semantically our \"fake\" emphemeral style property will be universall as well,\n // by expanding it to all the breakpoints. This is important as\n // styleTransformers.ts#transformBackgroundImageUrl() expects\n // cfBackgroundImageUrl to be present for all breakpoints\n // where cfBackgroundImageOptions is present.\n styleProps[propName] = Object.fromEntries(breakpoints.map((b) => [b.id, propValue]));\n } else {\n contentProps[propName] = propValue;\n }\n break;\n }\n\n case 'HyperlinkValue': {\n const hyperlink = resolveHyperlinkValue({\n linkTargetKey: propertyValue.linkTargetKey,\n });\n if (hyperlink) {\n contentProps[propName] = hyperlink;\n }\n break;\n }\n case 'UnboundValue': {\n const unboundValue = resolveUnboundValue({\n mappingKey: propertyValue.key,\n defaultValue: propDefinition.defaultValue,\n });\n\n if (isSpecialCaseCssProp(propName)) {\n styleProps[propName] = Object.fromEntries(breakpoints.map((b) => [b.id, unboundValue]));\n } else {\n contentProps[propName] = unboundValue;\n }\n break;\n }\n case 'ComponentValue': {\n // This can either be a design (style) or a content property.\n // Where prebinding is used, we resolve like they are a BoundValue.\n const propValue =\n resolvePrebindingValue({\n propertyName: propName,\n mappingKey: propertyValue.key,\n dataType: propDefinition.type,\n resolveBoundValue,\n }) ?? propDefinition.defaultValue;\n\n if (isSpecialCaseCssProp(propName)) {\n styleProps[propName] = Object.fromEntries(breakpoints.map((b) => [b.id, propValue]));\n } else {\n contentProps[propName] = propValue;\n }\n break;\n }\n default:\n break;\n }\n }\n /* [Data Format] After resolving all properties, `styleProps` contains solely the plain design values\n * styleProps = {\n * cfMargin: { desktop: '42px', tablet: '13px' },\n * cfBackgroundColor: { desktop: 'rgba(246, 246, 246, 1)' },\n * cfBackgroundImage: { desktop: 'url(https://example.com/image.jpg)' }\n * }\n */\n\n const stylePropsIndexedByBreakpoint = Object.entries(styleProps).reduce<\n Record<string, Record<string, PrimitiveValue>>\n >((acc, [propName, valuesByBreakpoint]) => {\n for (const [breakpointId, value] of Object.entries(valuesByBreakpoint)) {\n if (!acc[breakpointId]) {\n acc[breakpointId] = {};\n }\n\n acc[breakpointId][propName] = value;\n }\n\n return acc;\n }, {});\n /* [Data Format] `stylePropsIndexedByBreakpoint` contains the plain design values grouped by breakpoint\n * stylePropsIndexedByBreakpoint = {\n * desktop: {\n * cfMargin: '42px',\n * cfBackgroundColor: 'rgba(246, 246, 246, 1)',\n * cfBackgroundImage: 'url(https://example.com/image.jpg)'\n * },\n * tablet: {\n * cfMargin: '13px'\n * }\n * }\n */\n\n const stylesheetData = createStylesheetsForBuiltInStyles({\n designPropertiesByBreakpoint: stylePropsIndexedByBreakpoint,\n breakpoints,\n node,\n patternRootNodeIdsChain,\n });\n /* [Data Format] Stylesheet data provides objects containing `className`, `breakpointCondition`, and `css`.\n * stylesheetData = [{\n * className: 'uniqueMD5Hash',\n * breakpointCondition: '<768px',\n * css: 'margin:13px;'\n * visibilityCss: 'display:none !important;'\n * }, ...]\n */\n const mediaQuery = convertResolvedDesignValuesToMediaQuery(stylesheetData);\n /* [Data Format] `mediaQuery` is a joined string of all media query CSS code\n * mediaQuery = \".cfstyles-123{margin:42px;}@media(max-width:768px){.cfstyles-456{margin:13px;}}\"\n */\n return {\n styleProps,\n mediaQuery,\n customDesignProps,\n contentProps,\n };\n};\n"],"names":[],"mappings":";;;;AAgBA;AACA;;;;;;;;AAQG;AACH,MAAM,oBAAoB,GAAG,CAAC,QAAgB,KAAI;IAChD,OAAO,QAAQ,KAAK,sBAAsB,IAAI,QAAQ,CAAC,UAAU,CAAC,uBAAuB,CAAC,CAAC;AAC7F,CAAC,CAAC;AAmBW,MAAA,mBAAmB,GAAG,CAAC,EAClC,WAAW,EACX,mBAAmB,EACnB,uBAAuB,EACvB,IAAI,EACJ,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,EACnB,sBAAsB,GAoBvB,KAAI;IACH,MAAM,UAAU,GAAsD,EAAE,CAA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M;AACL,oBAAA,YAAY,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAC;iBACpC;gBACD,MAAM;aACP;SAGF;KACF;AACD;;;;;;AAMG;IAEH,MAAM,6BAA6B,GAAG,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,MAAM,CAErE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,kBAAkB,CAAC,KAAI;AACxC,QAAA,KAAK,MAAM,CAAC,YAAY,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,EAAE;AACtE,YAAA,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE;AACtB,gBAAA,GAAG,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC;aACxB;YAED,GAAG,CAAC,YAAY,CAAC,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC;SACrC;AAED,QAAA,OAAO,GAAG,CAAC;KACZ,EAAE,EAAE,CAAC,CAAC;AACP;;;;;;;;;;;AAWG;IAEH,MAAM,cAAc,GAAG,iCAAiC,CAAC;AACvD,QAAA,4BAA4B,EAAE,6BAA6B;QAC3D,WAAW;QACX,IAAI;QACJ,uBAAuB;AACxB,KAAA,CAAC,CAAC;AACH;;;;;;;AAOG;AACH,IAAA,MAAM,UAAU,GAAG,uCAAuC,CAAC,cAAc,CAAC,CAAC;AAC3E;;AAEG;IACH,OAAO;QACL,UAAU;QACV,UAAU;QACV,iBAAiB;QACjB,YAAY;KACb,CAAC;AACJ;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/experiences-sdk-react",
|
|
3
|
-
"version": "3.4.0",
|
|
3
|
+
"version": "3.4.1-dev-20250828T1024-c2a782a.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.js",
|
|
6
6
|
"typings": "./dist/src/index.d.ts",
|
|
@@ -41,10 +41,10 @@
|
|
|
41
41
|
"depcruise": "depcruise src"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@contentful/experiences-components-react": "3.4.0",
|
|
45
|
-
"@contentful/experiences-core": "3.4.0",
|
|
46
|
-
"@contentful/experiences-validators": "3.4.0",
|
|
47
|
-
"@contentful/experiences-visual-editor-react": "3.4.0",
|
|
44
|
+
"@contentful/experiences-components-react": "3.4.1-dev-20250828T1024-c2a782a.0",
|
|
45
|
+
"@contentful/experiences-core": "3.4.1-dev-20250828T1024-c2a782a.0",
|
|
46
|
+
"@contentful/experiences-validators": "3.4.1-dev-20250828T1024-c2a782a.0",
|
|
47
|
+
"@contentful/experiences-visual-editor-react": "3.4.1-dev-20250828T1024-c2a782a.0",
|
|
48
48
|
"@contentful/rich-text-types": "^17.0.0",
|
|
49
49
|
"csstype": "^3.1.2",
|
|
50
50
|
"immer": "^10.0.3",
|
|
@@ -98,5 +98,5 @@
|
|
|
98
98
|
"dist",
|
|
99
99
|
"package.json"
|
|
100
100
|
],
|
|
101
|
-
"gitHead": "
|
|
101
|
+
"gitHead": "9b961ec89c484b3bb72b7e82920e085b45603f0c"
|
|
102
102
|
}
|