@contentful/experiences-core 3.8.3-dev-20251020T1356-dca4ced.0 → 3.8.4-dev-20251024T1213-2c026d6.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/cjs/index.cjs +41 -34
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.js +41 -34
- package/dist/esm/index.js.map +1 -1
- package/package.json +3 -3
package/dist/cjs/index.cjs
CHANGED
|
@@ -2842,37 +2842,32 @@ const maybePopulateDesignTokenValue = (variableName, variableValue, mapOfDesignV
|
|
|
2842
2842
|
if (!isCfStyleAttribute(variableName)) {
|
|
2843
2843
|
return variableValue;
|
|
2844
2844
|
}
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2845
|
+
// matches ${...} and captures the content between ${ and }
|
|
2846
|
+
// ${color.Blue}, ${spacing.Sizes.Large} or ${border.Text Heading.Small}
|
|
2847
|
+
const templateStringRegex = /\$\{(\w[^}]*)}/g;
|
|
2848
|
+
const result = variableValue
|
|
2849
|
+
.replace(templateStringRegex, (_, rawKey) => {
|
|
2850
|
+
const value = mapOfDesignVariableKeys[rawKey];
|
|
2851
|
+
if (!value) {
|
|
2852
|
+
if (builtInStyles[variableName]?.defaultValue) {
|
|
2853
|
+
return String(builtInStyles[variableName].defaultValue);
|
|
2851
2854
|
}
|
|
2852
|
-
if (optionalBuiltInStyles[variableName]) {
|
|
2853
|
-
return optionalBuiltInStyles[variableName].defaultValue;
|
|
2855
|
+
if (optionalBuiltInStyles[variableName]?.defaultValue) {
|
|
2856
|
+
return String(optionalBuiltInStyles[variableName].defaultValue);
|
|
2854
2857
|
}
|
|
2855
2858
|
return '0px';
|
|
2856
2859
|
}
|
|
2857
2860
|
if (variableName === 'cfBorder' || variableName.startsWith('cfBorder_')) {
|
|
2858
|
-
if (typeof
|
|
2859
|
-
const { width, style, color } =
|
|
2861
|
+
if (typeof value === 'object') {
|
|
2862
|
+
const { width, style, color } = value;
|
|
2860
2863
|
return `${width} ${style} ${color}`;
|
|
2861
2864
|
}
|
|
2862
2865
|
}
|
|
2863
|
-
return
|
|
2864
|
-
}
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
for (const part of parts) {
|
|
2869
|
-
const tokenValue = templateStringRegex.test(part)
|
|
2870
|
-
? resolveSimpleDesignToken(variableName, part)
|
|
2871
|
-
: part;
|
|
2872
|
-
resolvedValue += `${tokenValue} `;
|
|
2873
|
-
}
|
|
2874
|
-
// Not trimming would end up with a trailing space that breaks the check in `calculateNodeDefaultHeight`
|
|
2875
|
-
return resolvedValue.trim();
|
|
2866
|
+
return String(value);
|
|
2867
|
+
})
|
|
2868
|
+
// Replace all multiple spaces with a single space
|
|
2869
|
+
.replace(/ +/g, ' ');
|
|
2870
|
+
return result;
|
|
2876
2871
|
};
|
|
2877
2872
|
const transformMedia$1 = (boundAsset, width, options) => {
|
|
2878
2873
|
try {
|
|
@@ -3094,18 +3089,30 @@ const indexByBreakpoint = ({ variables, breakpointIds, getBoundEntityById, unbou
|
|
|
3094
3089
|
* `{ 'color.key': [value] }`
|
|
3095
3090
|
*/
|
|
3096
3091
|
const flattenDesignTokenRegistry = (designTokenRegistry) => {
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3092
|
+
const flattenObject = (obj, prefix = '') => {
|
|
3093
|
+
return Object.entries(obj).reduce((acc, [key, value]) => {
|
|
3094
|
+
const newKey = prefix ? `${prefix}.${key}` : key;
|
|
3095
|
+
if (value &&
|
|
3096
|
+
typeof value === 'object' &&
|
|
3097
|
+
!Array.isArray(value) &&
|
|
3098
|
+
// handle border types
|
|
3099
|
+
!(typeof value === 'object' && ('width' in value || 'style' in value || 'color' in value))) {
|
|
3100
|
+
// Recursively flatten nested objects, but skip objects that look like border definitions
|
|
3101
|
+
return {
|
|
3102
|
+
...acc,
|
|
3103
|
+
...flattenObject(value, newKey),
|
|
3104
|
+
};
|
|
3105
|
+
}
|
|
3106
|
+
else {
|
|
3107
|
+
// This is a leaf value (string, number, or border object)
|
|
3108
|
+
return {
|
|
3109
|
+
...acc,
|
|
3110
|
+
[newKey]: value,
|
|
3111
|
+
};
|
|
3112
|
+
}
|
|
3103
3113
|
}, {});
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
...tokensWithCategory,
|
|
3107
|
-
};
|
|
3108
|
-
}, {});
|
|
3114
|
+
};
|
|
3115
|
+
return flattenObject(designTokenRegistry);
|
|
3109
3116
|
};
|
|
3110
3117
|
function mergeDefaultAndOverwriteValues(defaultValue, overwriteValue) {
|
|
3111
3118
|
if (defaultValue?.type === 'DesignValue' && overwriteValue?.type === 'DesignValue') {
|