@contentful/experiences-core 1.37.3-dev-20250519T0822-4378dab.0 → 1.37.3-dev-20250523T0645-49fc5b0.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 +17 -13
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/utils/breakpoints.d.ts +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1378,11 +1378,21 @@ const builtInStylesWithDesignTokens = [
|
|
|
1378
1378
|
const isValidBreakpointValue = (value) => {
|
|
1379
1379
|
return value !== undefined && value !== null && value !== '';
|
|
1380
1380
|
};
|
|
1381
|
-
const getValueForBreakpoint = (valuesByBreakpoint, breakpoints, activeBreakpointIndex, fallbackBreakpointIndex,
|
|
1381
|
+
const getValueForBreakpoint = (valuesByBreakpoint, breakpoints, activeBreakpointIndex, fallbackBreakpointIndex,
|
|
1382
|
+
/** Provide the name for built-in styles to replace design tokens. Supported properties are:
|
|
1383
|
+
* cfMargin, cfPadding, cfGap, cfWidth, cfHeight, cfBackgroundColor,
|
|
1384
|
+
* cfBorder, cfBorderRadius, cfFontSize, cfLineHeight, cfLetterSpacing,
|
|
1385
|
+
* cfTextColor, cfMaxWidth
|
|
1386
|
+
*/
|
|
1387
|
+
propertyName, resolveDesignTokens = true) => {
|
|
1382
1388
|
const eventuallyResolveDesignTokens = (value) => {
|
|
1389
|
+
// This is used externally in the web app to determine the original persisted value
|
|
1390
|
+
if (!resolveDesignTokens) {
|
|
1391
|
+
return value;
|
|
1392
|
+
}
|
|
1383
1393
|
// For some built-in design properties, we support design tokens
|
|
1384
|
-
if (builtInStylesWithDesignTokens.includes(
|
|
1385
|
-
return getDesignTokenRegistration(value,
|
|
1394
|
+
if (propertyName && builtInStylesWithDesignTokens.includes(propertyName)) {
|
|
1395
|
+
return getDesignTokenRegistration(value, propertyName);
|
|
1386
1396
|
}
|
|
1387
1397
|
// For all other properties, we just return the breakpoint-specific value
|
|
1388
1398
|
return value;
|
|
@@ -1393,18 +1403,12 @@ const getValueForBreakpoint = (valuesByBreakpoint, breakpoints, activeBreakpoint
|
|
|
1393
1403
|
const breakpointId = breakpoints[index]?.id;
|
|
1394
1404
|
if (isValidBreakpointValue(valuesByBreakpoint[breakpointId])) {
|
|
1395
1405
|
// If the value is defined, we use it and stop the breakpoints cascade
|
|
1396
|
-
|
|
1397
|
-
return eventuallyResolveDesignTokens(valuesByBreakpoint[breakpointId]);
|
|
1398
|
-
}
|
|
1399
|
-
return valuesByBreakpoint[breakpointId];
|
|
1406
|
+
return eventuallyResolveDesignTokens(valuesByBreakpoint[breakpointId]);
|
|
1400
1407
|
}
|
|
1401
1408
|
}
|
|
1402
1409
|
const fallbackBreakpointId = breakpoints[fallbackBreakpointIndex]?.id;
|
|
1403
1410
|
if (isValidBreakpointValue(valuesByBreakpoint[fallbackBreakpointId])) {
|
|
1404
|
-
|
|
1405
|
-
return eventuallyResolveDesignTokens(valuesByBreakpoint[fallbackBreakpointId]);
|
|
1406
|
-
}
|
|
1407
|
-
return valuesByBreakpoint[fallbackBreakpointId];
|
|
1411
|
+
return eventuallyResolveDesignTokens(valuesByBreakpoint[fallbackBreakpointId]);
|
|
1408
1412
|
}
|
|
1409
1413
|
}
|
|
1410
1414
|
else {
|
|
@@ -2703,7 +2707,7 @@ const transformMedia = (asset, variables, resolveDesignValue, variableName, path
|
|
|
2703
2707
|
const optionsVariableName = 'cfImageOptions';
|
|
2704
2708
|
const options = resolveDesignValue(variables[optionsVariableName]?.type === 'DesignValue'
|
|
2705
2709
|
? variables[optionsVariableName].valuesByBreakpoint
|
|
2706
|
-
: {}
|
|
2710
|
+
: {});
|
|
2707
2711
|
if (!options) {
|
|
2708
2712
|
console.error(`Error transforming image asset: Required variable [${optionsVariableName}] missing from component definition`);
|
|
2709
2713
|
return;
|
|
@@ -2728,7 +2732,7 @@ const transformMedia = (asset, variables, resolveDesignValue, variableName, path
|
|
|
2728
2732
|
const optionsVariableName = 'cfBackgroundImageOptions';
|
|
2729
2733
|
const options = resolveDesignValue(variables[optionsVariableName]?.type === 'DesignValue'
|
|
2730
2734
|
? variables[optionsVariableName].valuesByBreakpoint
|
|
2731
|
-
: {}
|
|
2735
|
+
: {});
|
|
2732
2736
|
if (!options) {
|
|
2733
2737
|
console.error(`Error transforming image asset: Required variable [${optionsVariableName}] missing from component definition`);
|
|
2734
2738
|
return;
|