@contentful/experiences-sdk-react 1.30.0-dev-20250128T1255-1f90987.0 → 1.30.0-dev-20250128T1255-64f728a.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/blocks/preview/CompositionBlock.js +15 -4
- package/dist/blocks/preview/CompositionBlock.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/blocks/preview/CompositionBlock.d.ts +2 -1
- package/dist/src/sdkVersion.d.ts +1 -1
- package/dist/test/__fixtures__/assembly.d.ts +4 -97
- package/package.json +6 -6
|
@@ -8,7 +8,7 @@ import { Assembly, ContentfulContainer, Columns, SingleColumn } from '@contentfu
|
|
|
8
8
|
import { resolveAssembly } from '../../core/preview/assemblyUtils.js';
|
|
9
9
|
import PreviewUnboundImage from './PreviewUnboundImage.js';
|
|
10
10
|
|
|
11
|
-
const CompositionBlock = ({ node: rawNode, locale, entityStore, hyperlinkPattern, resolveDesignValue, getPatternChildNodeClassName, }) => {
|
|
11
|
+
const CompositionBlock = ({ node: rawNode, locale, entityStore, hyperlinkPattern, resolveDesignValue, getPatternChildNodeClassName, wrappingPatternIds: parentWrappingPatternIds = new Set(), }) => {
|
|
12
12
|
const isAssembly = useMemo(() => checkIsAssemblyNode({
|
|
13
13
|
componentId: rawNode.definitionId,
|
|
14
14
|
usedComponents: entityStore.usedComponents,
|
|
@@ -21,6 +21,12 @@ const CompositionBlock = ({ node: rawNode, locale, entityStore, hyperlinkPattern
|
|
|
21
21
|
})
|
|
22
22
|
: rawNode;
|
|
23
23
|
}, [entityStore, isAssembly, rawNode]);
|
|
24
|
+
const wrappingPatternIds = useMemo(() => {
|
|
25
|
+
if (isAssembly) {
|
|
26
|
+
return new Set([node.definitionId, ...parentWrappingPatternIds]);
|
|
27
|
+
}
|
|
28
|
+
return parentWrappingPatternIds;
|
|
29
|
+
}, [isAssembly, node, parentWrappingPatternIds]);
|
|
24
30
|
const componentRegistration = useMemo(() => {
|
|
25
31
|
const registration = getComponentRegistration(node.definitionId);
|
|
26
32
|
if (isAssembly && !registration) {
|
|
@@ -89,27 +95,32 @@ const CompositionBlock = ({ node: rawNode, locale, entityStore, hyperlinkPattern
|
|
|
89
95
|
for (const slotId in componentRegistration.definition.slots) {
|
|
90
96
|
const slotNode = node.children.find((child) => child.slotId === slotId);
|
|
91
97
|
if (slotNode) {
|
|
92
|
-
props[slotId] = (jsx(CompositionBlock, { node: slotNode, locale: locale, hyperlinkPattern: hyperlinkPattern, entityStore: entityStore, resolveDesignValue: resolveDesignValue }));
|
|
98
|
+
props[slotId] = (jsx(CompositionBlock, { node: slotNode, locale: locale, hyperlinkPattern: hyperlinkPattern, entityStore: entityStore, resolveDesignValue: resolveDesignValue, wrappingPatternIds: wrappingPatternIds }));
|
|
93
99
|
}
|
|
94
100
|
}
|
|
95
101
|
}
|
|
96
102
|
return props;
|
|
97
103
|
}, [
|
|
98
|
-
resolveDesignValue,
|
|
99
104
|
node.variables,
|
|
100
105
|
node.id,
|
|
101
106
|
node.children,
|
|
107
|
+
resolveDesignValue,
|
|
102
108
|
componentRegistration,
|
|
103
109
|
isAssembly,
|
|
104
110
|
getPatternChildNodeClassName,
|
|
105
111
|
entityStore,
|
|
106
112
|
hyperlinkPattern,
|
|
107
113
|
locale,
|
|
114
|
+
wrappingPatternIds,
|
|
108
115
|
]);
|
|
109
116
|
const className = useClassName({ props: nodeProps, node });
|
|
110
117
|
if (!componentRegistration) {
|
|
111
118
|
return null;
|
|
112
119
|
}
|
|
120
|
+
// When detecting a circular dependency, we stop silently. The editor mode will render an actionable error.
|
|
121
|
+
if (parentWrappingPatternIds.has(node.definitionId)) {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
113
124
|
const { component } = componentRegistration;
|
|
114
125
|
// Retrieves the CSS class name for a given child node ID.
|
|
115
126
|
const _getPatternChildNodeClassName = (childNodeId) => {
|
|
@@ -126,7 +137,7 @@ const CompositionBlock = ({ node: rawNode, locale, entityStore, hyperlinkPattern
|
|
|
126
137
|
? node.children.map((childNode, index) => {
|
|
127
138
|
return (jsx(CompositionBlock, { getPatternChildNodeClassName: isAssembly || getPatternChildNodeClassName
|
|
128
139
|
? _getPatternChildNodeClassName
|
|
129
|
-
: undefined, node: childNode, locale: locale, hyperlinkPattern: hyperlinkPattern, entityStore: entityStore, resolveDesignValue: resolveDesignValue }, index));
|
|
140
|
+
: undefined, node: childNode, locale: locale, hyperlinkPattern: hyperlinkPattern, entityStore: entityStore, resolveDesignValue: resolveDesignValue, wrappingPatternIds: wrappingPatternIds }, index));
|
|
130
141
|
})
|
|
131
142
|
: null;
|
|
132
143
|
if ([CONTENTFUL_COMPONENTS.container.id, CONTENTFUL_COMPONENTS.section.id].includes(node.definitionId)) {
|
|
@@ -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 {\n EntityStore,\n resolveHyperlinkPattern,\n sanitizeNodeProps,\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 PrimitiveValue,\n ResolveDesignValueType,\n StyleProps,\n} from '@contentful/experiences-core/types';\nimport { createAssemblyRegistration, getComponentRegistration } from '../../core/componentRegistry';\nimport { checkIsAssemblyNode, transformBoundContentValue } from '@contentful/experiences-core';\nimport { useClassName } from '../../hooks/useClassName';\nimport {\n Assembly,\n Columns,\n ContentfulContainer,\n SingleColumn,\n} from '@contentful/experiences-components-react';\n\nimport { resolveAssembly } from '../../core/preview/assemblyUtils';\nimport { Entry } from 'contentful';\nimport PreviewUnboundImage from './PreviewUnboundImage';\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};\n\nexport const CompositionBlock = ({\n node: rawNode,\n locale,\n entityStore,\n hyperlinkPattern,\n resolveDesignValue,\n getPatternChildNodeClassName,\n}: CompositionBlockProps) => {\n const isAssembly = useMemo(\n () =>\n checkIsAssemblyNode({\n componentId: rawNode.definitionId,\n usedComponents: entityStore.usedComponents,\n }),\n [entityStore.usedComponents, rawNode.definitionId],\n );\n\n const node = useMemo(() => {\n return isAssembly\n ? resolveAssembly({\n node: rawNode,\n entityStore,\n })\n : rawNode;\n }, [entityStore, isAssembly, rawNode]);\n\n const componentRegistration = useMemo(() => {\n const registration = getComponentRegistration(node.definitionId as string);\n\n if (isAssembly && !registration) {\n return createAssemblyRegistration({\n definitionId: node.definitionId as string,\n component: Assembly,\n });\n }\n return registration;\n }, [isAssembly, node.definitionId]);\n\n const nodeProps = 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 cfSsrClassName = resolveDesignValue(\n cfSsrClassNameValues?.valuesByBreakpoint,\n 'cfSsrClassName',\n );\n\n // Don't enrich the assembly wrapper node with props\n if (!componentRegistration || isAssembly) {\n return { cfSsrClassName };\n }\n\n const propMap: Record<string, PrimitiveValue> = {\n cfSsrClassName:\n node.id && getPatternChildNodeClassName\n ? getPatternChildNodeClassName(node.id)\n : cfSsrClassName,\n };\n\n const props = Object.entries(componentRegistration.definition.variables).reduce(\n (acc, [variableName, variableDefinition]) => {\n const variable = node.variables[variableName];\n if (!variable) return acc;\n\n switch (variable.type) {\n case 'DesignValue':\n acc[variableName] = resolveDesignValue(variable.valuesByBreakpoint, variableName);\n break;\n case 'BoundValue': {\n const [, uuid] = variable.path.split('/');\n const binding = entityStore.dataSource[uuid] as UnresolvedLink<'Entry' | 'Asset'>;\n\n const value = transformBoundContentValue(\n node.variables,\n entityStore,\n binding,\n resolveDesignValue,\n variableName,\n variableDefinition,\n variable.path,\n );\n acc[variableName] = value ?? variableDefinition.defaultValue;\n break;\n }\n\n case 'HyperlinkValue': {\n const binding = entityStore.dataSource[variable.linkTargetKey];\n const hyperlinkEntry = entityStore.getEntryOrAsset(binding, variable.linkTargetKey);\n\n const value = resolveHyperlinkPattern(\n componentRegistration.definition.hyperlinkPattern ||\n hyperlinkPattern ||\n HYPERLINK_DEFAULT_PATTERN,\n hyperlinkEntry as Entry,\n locale,\n );\n if (value) {\n acc[variableName] = value;\n }\n break;\n }\n case 'UnboundValue': {\n const uuid = variable.key;\n acc[variableName] =\n entityStore.unboundValues[uuid]?.value ?? variableDefinition.defaultValue;\n break;\n }\n case 'ComponentValue':\n // We're rendering a pattern entry. Content cannot be set for ComponentValue type properties\n // directly in the pattern so we can safely use the default value\n // This can either a design (style) or a content variable\n acc[variableName] = variableDefinition.defaultValue;\n break;\n default:\n break;\n }\n return acc;\n },\n propMap,\n );\n\n if (componentRegistration.definition.slots) {\n for (const slotId in componentRegistration.definition.slots) {\n const slotNode = node.children.find((child) => child.slotId === slotId);\n if (slotNode) {\n props[slotId] = (\n <CompositionBlock\n node={slotNode}\n locale={locale}\n hyperlinkPattern={hyperlinkPattern}\n entityStore={entityStore}\n resolveDesignValue={resolveDesignValue}\n />\n );\n }\n }\n }\n\n return props;\n }, [\n resolveDesignValue,\n node.variables,\n node.id,\n node.children,\n componentRegistration,\n isAssembly,\n getPatternChildNodeClassName,\n entityStore,\n hyperlinkPattern,\n locale,\n ]);\n\n const className = useClassName({ props: nodeProps, node });\n\n if (!componentRegistration) {\n return null;\n }\n\n const { component } = componentRegistration;\n\n // Retrieves the CSS class name for a given child node ID.\n const _getPatternChildNodeClassName = (childNodeId: string) => {\n if (isAssembly) {\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?.[childNodeId];\n if (!classesForNode) return undefined;\n return resolveDesignValue(classesForNode.valuesByBreakpoint, 'cfSsrClassName') as string;\n }\n return getPatternChildNodeClassName?.(childNodeId);\n };\n\n const children =\n componentRegistration.definition.children === true\n ? node.children.map((childNode: ComponentTreeNode, index) => {\n return (\n <CompositionBlock\n getPatternChildNodeClassName={\n isAssembly || getPatternChildNodeClassName\n ? _getPatternChildNodeClassName\n : undefined\n }\n node={childNode}\n key={index}\n locale={locale}\n hyperlinkPattern={hyperlinkPattern}\n entityStore={entityStore}\n resolveDesignValue={resolveDesignValue}\n />\n );\n })\n : null;\n\n if (\n [CONTENTFUL_COMPONENTS.container.id, CONTENTFUL_COMPONENTS.section.id].includes(\n node.definitionId,\n )\n ) {\n return (\n <ContentfulContainer\n editorMode={false}\n cfHyperlink={(nodeProps as StyleProps).cfHyperlink}\n cfOpenInNewTab={(nodeProps as StyleProps).cfOpenInNewTab}\n className={className}>\n {children}\n </ContentfulContainer>\n );\n }\n\n if (node.definitionId === CONTENTFUL_COMPONENTS.columns.id) {\n return (\n <Columns editorMode={false} className={className}>\n {children}\n </Columns>\n );\n }\n\n if (node.definitionId === CONTENTFUL_COMPONENTS.singleColumn.id) {\n return (\n <SingleColumn editorMode={false} className={className}>\n {children}\n </SingleColumn>\n );\n }\n\n if (\n node.definitionId === CONTENTFUL_COMPONENTS.image.id &&\n node.variables.cfImageAsset?.type === 'UnboundValue'\n ) {\n return <PreviewUnboundImage node={node} nodeProps={nodeProps} component={component} />;\n }\n\n return React.createElement(\n component,\n {\n ...sanitizeNodeProps(nodeProps),\n className,\n },\n children ?? (typeof nodeProps.children === 'string' ? nodeProps.children : null),\n );\n};\n"],"names":["_jsx"],"mappings":";;;;;;;;;;MAyCa,gBAAgB,GAAG,CAAC,EAC/B,IAAI,EAAE,OAAO,EACb,MAAM,EACN,WAAW,EACX,gBAAgB,EAChB,kBAAkB,EAClB,4BAA4B,GACN,KAAI;IAC1B,MAAM,UAAU,GAAG,OAAO,CACxB,MACE,mBAAm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Block.js","sources":["../../../../src/blocks/preview/CompositionBlock.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\nimport type { UnresolvedLink } from 'contentful';\nimport {\n EntityStore,\n resolveHyperlinkPattern,\n sanitizeNodeProps,\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 PrimitiveValue,\n ResolveDesignValueType,\n StyleProps,\n} from '@contentful/experiences-core/types';\nimport { createAssemblyRegistration, getComponentRegistration } from '../../core/componentRegistry';\nimport { checkIsAssemblyNode, transformBoundContentValue } from '@contentful/experiences-core';\nimport { useClassName } from '../../hooks/useClassName';\nimport {\n Assembly,\n Columns,\n ContentfulContainer,\n SingleColumn,\n} from '@contentful/experiences-components-react';\n\nimport { resolveAssembly } from '../../core/preview/assemblyUtils';\nimport { Entry } from 'contentful';\nimport PreviewUnboundImage from './PreviewUnboundImage';\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 wrappingPatternIds?: Set<string>;\n};\n\nexport const CompositionBlock = ({\n node: rawNode,\n locale,\n entityStore,\n hyperlinkPattern,\n resolveDesignValue,\n getPatternChildNodeClassName,\n wrappingPatternIds: parentWrappingPatternIds = new Set(),\n}: CompositionBlockProps) => {\n const isAssembly = useMemo(\n () =>\n checkIsAssemblyNode({\n componentId: rawNode.definitionId,\n usedComponents: entityStore.usedComponents,\n }),\n [entityStore.usedComponents, rawNode.definitionId],\n );\n\n const node = useMemo(() => {\n return isAssembly\n ? resolveAssembly({\n node: rawNode,\n entityStore,\n })\n : rawNode;\n }, [entityStore, isAssembly, rawNode]);\n\n const wrappingPatternIds = useMemo(() => {\n if (isAssembly) {\n return new Set([node.definitionId, ...parentWrappingPatternIds]);\n }\n return parentWrappingPatternIds;\n }, [isAssembly, node, parentWrappingPatternIds]);\n\n const componentRegistration = useMemo(() => {\n const registration = getComponentRegistration(node.definitionId as string);\n\n if (isAssembly && !registration) {\n return createAssemblyRegistration({\n definitionId: node.definitionId as string,\n component: Assembly,\n });\n }\n return registration;\n }, [isAssembly, node.definitionId]);\n\n const nodeProps = 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 cfSsrClassName = resolveDesignValue(\n cfSsrClassNameValues?.valuesByBreakpoint,\n 'cfSsrClassName',\n );\n\n // Don't enrich the assembly wrapper node with props\n if (!componentRegistration || isAssembly) {\n return { cfSsrClassName };\n }\n\n const propMap: Record<string, PrimitiveValue> = {\n cfSsrClassName:\n node.id && getPatternChildNodeClassName\n ? getPatternChildNodeClassName(node.id)\n : cfSsrClassName,\n };\n\n const props = Object.entries(componentRegistration.definition.variables).reduce(\n (acc, [variableName, variableDefinition]) => {\n const variable = node.variables[variableName];\n if (!variable) return acc;\n\n switch (variable.type) {\n case 'DesignValue':\n acc[variableName] = resolveDesignValue(variable.valuesByBreakpoint, variableName);\n break;\n case 'BoundValue': {\n const [, uuid] = variable.path.split('/');\n const binding = entityStore.dataSource[uuid] as UnresolvedLink<'Entry' | 'Asset'>;\n\n const value = transformBoundContentValue(\n node.variables,\n entityStore,\n binding,\n resolveDesignValue,\n variableName,\n variableDefinition,\n variable.path,\n );\n acc[variableName] = value ?? variableDefinition.defaultValue;\n break;\n }\n\n case 'HyperlinkValue': {\n const binding = entityStore.dataSource[variable.linkTargetKey];\n const hyperlinkEntry = entityStore.getEntryOrAsset(binding, variable.linkTargetKey);\n\n const value = resolveHyperlinkPattern(\n componentRegistration.definition.hyperlinkPattern ||\n hyperlinkPattern ||\n HYPERLINK_DEFAULT_PATTERN,\n hyperlinkEntry as Entry,\n locale,\n );\n if (value) {\n acc[variableName] = value;\n }\n break;\n }\n case 'UnboundValue': {\n const uuid = variable.key;\n acc[variableName] =\n entityStore.unboundValues[uuid]?.value ?? variableDefinition.defaultValue;\n break;\n }\n case 'ComponentValue':\n // We're rendering a pattern entry. Content cannot be set for ComponentValue type properties\n // directly in the pattern so we can safely use the default value\n // This can either a design (style) or a content variable\n acc[variableName] = variableDefinition.defaultValue;\n break;\n default:\n break;\n }\n return acc;\n },\n propMap,\n );\n\n if (componentRegistration.definition.slots) {\n for (const slotId in componentRegistration.definition.slots) {\n const slotNode = node.children.find((child) => child.slotId === slotId);\n if (slotNode) {\n props[slotId] = (\n <CompositionBlock\n node={slotNode}\n locale={locale}\n hyperlinkPattern={hyperlinkPattern}\n entityStore={entityStore}\n resolveDesignValue={resolveDesignValue}\n wrappingPatternIds={wrappingPatternIds}\n />\n );\n }\n }\n }\n\n return props;\n }, [\n node.variables,\n node.id,\n node.children,\n resolveDesignValue,\n componentRegistration,\n isAssembly,\n getPatternChildNodeClassName,\n entityStore,\n hyperlinkPattern,\n locale,\n wrappingPatternIds,\n ]);\n\n const className = useClassName({ props: nodeProps, node });\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 } = componentRegistration;\n\n // Retrieves the CSS class name for a given child node ID.\n const _getPatternChildNodeClassName = (childNodeId: string) => {\n if (isAssembly) {\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?.[childNodeId];\n if (!classesForNode) return undefined;\n return resolveDesignValue(classesForNode.valuesByBreakpoint, 'cfSsrClassName') as string;\n }\n return getPatternChildNodeClassName?.(childNodeId);\n };\n\n const children =\n componentRegistration.definition.children === true\n ? node.children.map((childNode: ComponentTreeNode, index) => {\n return (\n <CompositionBlock\n getPatternChildNodeClassName={\n isAssembly || getPatternChildNodeClassName\n ? _getPatternChildNodeClassName\n : undefined\n }\n node={childNode}\n key={index}\n locale={locale}\n hyperlinkPattern={hyperlinkPattern}\n entityStore={entityStore}\n resolveDesignValue={resolveDesignValue}\n wrappingPatternIds={wrappingPatternIds}\n />\n );\n })\n : null;\n\n if (\n [CONTENTFUL_COMPONENTS.container.id, CONTENTFUL_COMPONENTS.section.id].includes(\n node.definitionId,\n )\n ) {\n return (\n <ContentfulContainer\n editorMode={false}\n cfHyperlink={(nodeProps as StyleProps).cfHyperlink}\n cfOpenInNewTab={(nodeProps as StyleProps).cfOpenInNewTab}\n className={className}>\n {children}\n </ContentfulContainer>\n );\n }\n\n if (node.definitionId === CONTENTFUL_COMPONENTS.columns.id) {\n return (\n <Columns editorMode={false} className={className}>\n {children}\n </Columns>\n );\n }\n\n if (node.definitionId === CONTENTFUL_COMPONENTS.singleColumn.id) {\n return (\n <SingleColumn editorMode={false} className={className}>\n {children}\n </SingleColumn>\n );\n }\n\n if (\n node.definitionId === CONTENTFUL_COMPONENTS.image.id &&\n node.variables.cfImageAsset?.type === 'UnboundValue'\n ) {\n return <PreviewUnboundImage node={node} nodeProps={nodeProps} component={component} />;\n }\n\n return React.createElement(\n component,\n {\n ...sanitizeNodeProps(nodeProps),\n className,\n },\n children ?? (typeof nodeProps.children === 'string' ? nodeProps.children : null),\n );\n};\n"],"names":["_jsx"],"mappings":";;;;;;;;;;AA0CO,MAAM,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,GAClC,KAAI;IAC1B,MAAM,UAAU,GAAG,OAAO,CACxB,MACE,mBAAmB,CAAC;QAClB,WAAW,EAAE,OAAO,CAAC,YAAY;QACjC,cAAc,EAAE,WAAW,CAAC,cAAc;KAC3C,CAAC,EACJ,CAAC,WAAW,CAAC,cAAc,EAAE,OAAO,CAAC,YAAY,CAAC,CACnD,CAA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SAAS,EAAE,SAAS,GAAI,CAAC;KACxF;AAED,IAAA,OAAO,KAAK,CAAC,aAAa,CACxB,SAAS,EACT;QACE,GAAG,iBAAiB,CAAC,SAAS,CAAC;QAC/B,SAAS;KACV,EACD,QAAQ,KAAK,OAAO,SAAS,CAAC,QAAQ,KAAK,QAAQ,GAAG,SAAS,CAAC,QAAQ,GAAG,IAAI,CAAC,CACjF,CAAC;AACJ;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import * as _contentful_experiences_core_constants from '@contentful/experiences
|
|
|
8
8
|
export { CF_STYLE_ATTRIBUTES, CONTENTFUL_COMPONENTS, LATEST_SCHEMA_VERSION } from '@contentful/experiences-core/constants';
|
|
9
9
|
import { ContentfulClientApi } from 'contentful';
|
|
10
10
|
|
|
11
|
-
declare const SDK_VERSION = "1.30.0-dev-20250128T1255-
|
|
11
|
+
declare const SDK_VERSION = "1.30.0-dev-20250128T1255-64f728a.0";
|
|
12
12
|
|
|
13
13
|
type ExperienceRootProps = {
|
|
14
14
|
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 = '1.30.0-dev-20250128T1255-
|
|
1
|
+
{"version":3,"file":"sdkVersion.js","sources":["../../src/sdkVersion.ts"],"sourcesContent":["export const SDK_VERSION = '1.30.0-dev-20250128T1255-64f728a.0';\n"],"names":[],"mappings":"AAAO,MAAM,WAAW,GAAG;;;;"}
|
|
@@ -7,6 +7,7 @@ type CompositionBlockProps = {
|
|
|
7
7
|
hyperlinkPattern?: string | undefined;
|
|
8
8
|
resolveDesignValue: ResolveDesignValueType;
|
|
9
9
|
getPatternChildNodeClassName?: (childNodeId: string) => string | undefined;
|
|
10
|
+
wrappingPatternIds?: Set<string>;
|
|
10
11
|
};
|
|
11
|
-
export declare const CompositionBlock: ({ node: rawNode, locale, entityStore, hyperlinkPattern, resolveDesignValue, getPatternChildNodeClassName, }: CompositionBlockProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
12
|
+
export declare const CompositionBlock: ({ node: rawNode, locale, entityStore, hyperlinkPattern, resolveDesignValue, getPatternChildNodeClassName, wrappingPatternIds: parentWrappingPatternIds, }: CompositionBlockProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
12
13
|
export {};
|
package/dist/src/sdkVersion.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "1.30.0-dev-20250128T1255-
|
|
1
|
+
export declare const SDK_VERSION = "1.30.0-dev-20250128T1255-64f728a.0";
|
|
@@ -1,105 +1,12 @@
|
|
|
1
|
-
import type { ExperienceTreeNode, SchemaVersions } from '@contentful/experiences-core/types';
|
|
1
|
+
import type { ExperienceEntry, ExperienceTreeNode, SchemaVersions } from '@contentful/experiences-core/types';
|
|
2
2
|
type createAssemblyEntryArgs = {
|
|
3
|
-
schemaVersion
|
|
4
|
-
id
|
|
3
|
+
schemaVersion?: SchemaVersions;
|
|
4
|
+
id?: string;
|
|
5
5
|
};
|
|
6
6
|
export declare const defaultAssemblyId = "assembly-id";
|
|
7
7
|
export declare const assemblyGeneratedVariableName = "text_uuid1Assembly";
|
|
8
8
|
export declare const assemblyGeneratedDesignVariableName = "cfWidth_uuid2Assembly";
|
|
9
|
-
export declare const createAssemblyEntry: ({ schemaVersion, id, }
|
|
10
|
-
sys: {
|
|
11
|
-
id: string;
|
|
12
|
-
type: string;
|
|
13
|
-
contentType: {
|
|
14
|
-
sys: {
|
|
15
|
-
id: string;
|
|
16
|
-
type: string;
|
|
17
|
-
linkType: string;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
createdAt: string;
|
|
21
|
-
updatedAt: string;
|
|
22
|
-
revision: number;
|
|
23
|
-
space: {
|
|
24
|
-
sys: {
|
|
25
|
-
type: string;
|
|
26
|
-
linkType: string;
|
|
27
|
-
id: string;
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
environment: {
|
|
31
|
-
sys: {
|
|
32
|
-
type: string;
|
|
33
|
-
linkType: string;
|
|
34
|
-
id: string;
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
metadata: {
|
|
39
|
-
tags: never[];
|
|
40
|
-
};
|
|
41
|
-
fields: {
|
|
42
|
-
title: string;
|
|
43
|
-
slug: string;
|
|
44
|
-
componentTree: {
|
|
45
|
-
children: {
|
|
46
|
-
definitionId: string;
|
|
47
|
-
variables: {
|
|
48
|
-
cfWidth: {
|
|
49
|
-
type: string;
|
|
50
|
-
key: string;
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
children: {
|
|
54
|
-
definitionId: string;
|
|
55
|
-
variables: {
|
|
56
|
-
text: {
|
|
57
|
-
key: string;
|
|
58
|
-
type: string;
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
children: never[];
|
|
62
|
-
}[];
|
|
63
|
-
}[];
|
|
64
|
-
breakpoints: {
|
|
65
|
-
id: string;
|
|
66
|
-
query: string;
|
|
67
|
-
previewSize: string;
|
|
68
|
-
displayName: string;
|
|
69
|
-
}[];
|
|
70
|
-
schemaVersion: "2023-09-28";
|
|
71
|
-
};
|
|
72
|
-
dataSource: {};
|
|
73
|
-
unboundValues: {
|
|
74
|
-
unbound_uuid1Assembly: {
|
|
75
|
-
value: string;
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
componentSettings: {
|
|
79
|
-
variableDefinitions: {
|
|
80
|
-
text_uuid1Assembly: {
|
|
81
|
-
displayName: string;
|
|
82
|
-
type: "Text";
|
|
83
|
-
defaultValue: {
|
|
84
|
-
type: "UnboundValue";
|
|
85
|
-
key: string;
|
|
86
|
-
};
|
|
87
|
-
};
|
|
88
|
-
cfWidth_uuid2Assembly: {
|
|
89
|
-
displayName: string;
|
|
90
|
-
type: "Text";
|
|
91
|
-
group: string;
|
|
92
|
-
defaultValue: {
|
|
93
|
-
type: "DesignValue";
|
|
94
|
-
valuesByBreakpoint: {
|
|
95
|
-
desktop: string;
|
|
96
|
-
};
|
|
97
|
-
};
|
|
98
|
-
};
|
|
99
|
-
};
|
|
100
|
-
};
|
|
101
|
-
};
|
|
102
|
-
};
|
|
9
|
+
export declare const createAssemblyEntry: ({ schemaVersion, id, }?: createAssemblyEntryArgs) => ExperienceEntry;
|
|
103
10
|
type createAssemblyNodeArgs = {
|
|
104
11
|
id: string;
|
|
105
12
|
blockId?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/experiences-sdk-react",
|
|
3
|
-
"version": "1.30.0-dev-20250128T1255-
|
|
3
|
+
"version": "1.30.0-dev-20250128T1255-64f728a.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": "1.30.0-dev-20250128T1255-
|
|
45
|
-
"@contentful/experiences-core": "1.30.0-dev-20250128T1255-
|
|
46
|
-
"@contentful/experiences-validators": "1.30.0-dev-20250128T1255-
|
|
47
|
-
"@contentful/experiences-visual-editor-react": "1.30.0-dev-20250128T1255-
|
|
44
|
+
"@contentful/experiences-components-react": "1.30.0-dev-20250128T1255-64f728a.0",
|
|
45
|
+
"@contentful/experiences-core": "1.30.0-dev-20250128T1255-64f728a.0",
|
|
46
|
+
"@contentful/experiences-validators": "1.30.0-dev-20250128T1255-64f728a.0",
|
|
47
|
+
"@contentful/experiences-visual-editor-react": "1.30.0-dev-20250128T1255-64f728a.0",
|
|
48
48
|
"@contentful/rich-text-types": "^17.0.0",
|
|
49
49
|
"classnames": "^2.3.2",
|
|
50
50
|
"csstype": "^3.1.2",
|
|
@@ -102,5 +102,5 @@
|
|
|
102
102
|
"dist",
|
|
103
103
|
"package.json"
|
|
104
104
|
],
|
|
105
|
-
"gitHead": "
|
|
105
|
+
"gitHead": "8609cfa992e92dcebf8841757862d58ddd2c153c"
|
|
106
106
|
}
|