@contentful/experiences-core 1.37.2-dev-20250515T1505-4c9ed48.0 → 1.37.3-dev-20250519T0822-4378dab.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/index.js +11 -20
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -2063,25 +2063,16 @@ const detachExperienceStyles = (experience) => {
|
|
|
2063
2063
|
}), {});
|
|
2064
2064
|
// getting the breakpoint ids
|
|
2065
2065
|
const breakpointIds = Object.keys(mediaQueryDataByBreakpoint);
|
|
2066
|
-
const iterateOverTreeAndExtractStyles = ({ componentTree, dataSource, unboundValues, componentSettings, componentVariablesOverwrites, patternWrapper, wrappingPatternIds,
|
|
2066
|
+
const iterateOverTreeAndExtractStyles = ({ componentTree, dataSource, unboundValues, componentSettings, componentVariablesOverwrites, patternWrapper, wrappingPatternIds, wrappingPatternNodeIds = [], }) => {
|
|
2067
2067
|
// traversing the tree
|
|
2068
2068
|
const queue = [];
|
|
2069
|
-
queue.push(...componentTree.children
|
|
2070
|
-
node: child,
|
|
2071
|
-
parentChain: [...parentChainArr],
|
|
2072
|
-
})));
|
|
2069
|
+
queue.push(...componentTree.children);
|
|
2073
2070
|
// for each tree node
|
|
2074
2071
|
while (queue.length) {
|
|
2075
|
-
const
|
|
2076
|
-
if (!queueItem) {
|
|
2077
|
-
break;
|
|
2078
|
-
}
|
|
2079
|
-
const { node: currentNode, parentChain } = queueItem;
|
|
2072
|
+
const currentNode = queue.shift();
|
|
2080
2073
|
if (!currentNode) {
|
|
2081
2074
|
break;
|
|
2082
2075
|
}
|
|
2083
|
-
const currentNodeParentChain = [...parentChain, currentNode.id || ''];
|
|
2084
|
-
const currentPatternNodeIdsChain = currentNodeParentChain.join('');
|
|
2085
2076
|
const usedComponents = experience.entityStore?.usedComponents ?? [];
|
|
2086
2077
|
const isPatternNode = checkIsAssemblyNode({
|
|
2087
2078
|
componentId: currentNode.definitionId,
|
|
@@ -2119,7 +2110,7 @@ const detachExperienceStyles = (experience) => {
|
|
|
2119
2110
|
// pass top-level pattern node to store instance-specific child styles for rendering
|
|
2120
2111
|
patternWrapper: currentNode,
|
|
2121
2112
|
wrappingPatternIds: new Set([...wrappingPatternIds, currentNode.definitionId]),
|
|
2122
|
-
|
|
2113
|
+
wrappingPatternNodeIds: [...wrappingPatternNodeIds, currentNode.id || ''],
|
|
2123
2114
|
});
|
|
2124
2115
|
continue;
|
|
2125
2116
|
}
|
|
@@ -2155,6 +2146,10 @@ const detachExperienceStyles = (experience) => {
|
|
|
2155
2146
|
* }
|
|
2156
2147
|
*/
|
|
2157
2148
|
const currentNodeClassNames = [];
|
|
2149
|
+
// Chain IDs to avoid overwriting styles across multiple instances of the same pattern
|
|
2150
|
+
// e.g. `{outerPatternNodeId}{innerPatternNodeId}-{currentNodeId}`
|
|
2151
|
+
// (!) Notice that the chain of patterns (before the dash) follows the format of prebinding/ patternProperties
|
|
2152
|
+
const currentNodeIdsChain = `${wrappingPatternNodeIds.join('')}-${currentNode.id}`;
|
|
2158
2153
|
// For each breakpoint, resolve design tokens, create the CSS and generate a unique className.
|
|
2159
2154
|
for (const breakpointId of breakpointIds) {
|
|
2160
2155
|
const propsByBreakpointWithResolvedDesignTokens = Object.entries(propsByBreakpoint[breakpointId]).reduce((acc, [variableName, variableValue]) => {
|
|
@@ -2181,7 +2176,7 @@ const detachExperienceStyles = (experience) => {
|
|
|
2181
2176
|
// conflicts between different breakpoint values from multiple nodes where the hash would be equal
|
|
2182
2177
|
// - Adding wrapping pattern nodes IDs to avoid conflicts between similar nested patterns as those
|
|
2183
2178
|
// could override each others CSS for some breakpoints just through the order of `<style>` tags in the DOM.
|
|
2184
|
-
const styleHash = md5(
|
|
2179
|
+
const styleHash = md5(currentNodeIdsChain + breakpointId + generatedCss);
|
|
2185
2180
|
// and prefix the className to make sure the value can be processed
|
|
2186
2181
|
const className = `cf-${styleHash}`;
|
|
2187
2182
|
// I save the generated hashes into an array to later save it in the tree node
|
|
@@ -2210,8 +2205,7 @@ const detachExperienceStyles = (experience) => {
|
|
|
2210
2205
|
patternWrapper.variables.cfSsrClassName = {
|
|
2211
2206
|
...(patternWrapper.variables.cfSsrClassName ?? {}),
|
|
2212
2207
|
type: 'DesignValue',
|
|
2213
|
-
|
|
2214
|
-
[currentPatternNodeIdsChain]: {
|
|
2208
|
+
[currentNodeIdsChain]: {
|
|
2215
2209
|
valuesByBreakpoint: {
|
|
2216
2210
|
[breakpointIds[0]]: currentNodeClassNames.join(' '),
|
|
2217
2211
|
},
|
|
@@ -2226,10 +2220,7 @@ const detachExperienceStyles = (experience) => {
|
|
|
2226
2220
|
},
|
|
2227
2221
|
};
|
|
2228
2222
|
}
|
|
2229
|
-
queue.push(...currentNode.children
|
|
2230
|
-
node: child,
|
|
2231
|
-
parentChain: currentNodeParentChain,
|
|
2232
|
-
})));
|
|
2223
|
+
queue.push(...currentNode.children);
|
|
2233
2224
|
}
|
|
2234
2225
|
};
|
|
2235
2226
|
iterateOverTreeAndExtractStyles({
|