@contentful/experiences-visual-editor-react 1.37.3-dev-20250522T1032-0caa03f.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 +22 -18
- package/dist/index.js.map +1 -1
- package/dist/renderApp.js +22 -18
- package/dist/renderApp.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1029,11 +1029,21 @@ const builtInStylesWithDesignTokens = [
|
|
|
1029
1029
|
const isValidBreakpointValue = (value) => {
|
|
1030
1030
|
return value !== undefined && value !== null && value !== '';
|
|
1031
1031
|
};
|
|
1032
|
-
const getValueForBreakpoint = (valuesByBreakpoint, breakpoints, activeBreakpointIndex, fallbackBreakpointIndex,
|
|
1032
|
+
const getValueForBreakpoint = (valuesByBreakpoint, breakpoints, activeBreakpointIndex, fallbackBreakpointIndex,
|
|
1033
|
+
/** Provide the name for built-in styles to replace design tokens. Supported properties are:
|
|
1034
|
+
* cfMargin, cfPadding, cfGap, cfWidth, cfHeight, cfBackgroundColor,
|
|
1035
|
+
* cfBorder, cfBorderRadius, cfFontSize, cfLineHeight, cfLetterSpacing,
|
|
1036
|
+
* cfTextColor, cfMaxWidth
|
|
1037
|
+
*/
|
|
1038
|
+
propertyName, resolveDesignTokens = true) => {
|
|
1033
1039
|
const eventuallyResolveDesignTokens = (value) => {
|
|
1040
|
+
// This is used externally in the web app to determine the original persisted value
|
|
1041
|
+
if (!resolveDesignTokens) {
|
|
1042
|
+
return value;
|
|
1043
|
+
}
|
|
1034
1044
|
// For some built-in design properties, we support design tokens
|
|
1035
|
-
if (builtInStylesWithDesignTokens.includes(
|
|
1036
|
-
return getDesignTokenRegistration(value,
|
|
1045
|
+
if (propertyName && builtInStylesWithDesignTokens.includes(propertyName)) {
|
|
1046
|
+
return getDesignTokenRegistration(value, propertyName);
|
|
1037
1047
|
}
|
|
1038
1048
|
// For all other properties, we just return the breakpoint-specific value
|
|
1039
1049
|
return value;
|
|
@@ -1044,18 +1054,12 @@ const getValueForBreakpoint = (valuesByBreakpoint, breakpoints, activeBreakpoint
|
|
|
1044
1054
|
const breakpointId = breakpoints[index]?.id;
|
|
1045
1055
|
if (isValidBreakpointValue(valuesByBreakpoint[breakpointId])) {
|
|
1046
1056
|
// If the value is defined, we use it and stop the breakpoints cascade
|
|
1047
|
-
|
|
1048
|
-
return eventuallyResolveDesignTokens(valuesByBreakpoint[breakpointId]);
|
|
1049
|
-
}
|
|
1050
|
-
return valuesByBreakpoint[breakpointId];
|
|
1057
|
+
return eventuallyResolveDesignTokens(valuesByBreakpoint[breakpointId]);
|
|
1051
1058
|
}
|
|
1052
1059
|
}
|
|
1053
1060
|
const fallbackBreakpointId = breakpoints[fallbackBreakpointIndex]?.id;
|
|
1054
1061
|
if (isValidBreakpointValue(valuesByBreakpoint[fallbackBreakpointId])) {
|
|
1055
|
-
|
|
1056
|
-
return eventuallyResolveDesignTokens(valuesByBreakpoint[fallbackBreakpointId]);
|
|
1057
|
-
}
|
|
1058
|
-
return valuesByBreakpoint[fallbackBreakpointId];
|
|
1062
|
+
return eventuallyResolveDesignTokens(valuesByBreakpoint[fallbackBreakpointId]);
|
|
1059
1063
|
}
|
|
1060
1064
|
}
|
|
1061
1065
|
else {
|
|
@@ -1742,7 +1746,7 @@ const transformMedia = (asset, variables, resolveDesignValue, variableName, path
|
|
|
1742
1746
|
const optionsVariableName = 'cfImageOptions';
|
|
1743
1747
|
const options = resolveDesignValue(variables[optionsVariableName]?.type === 'DesignValue'
|
|
1744
1748
|
? variables[optionsVariableName].valuesByBreakpoint
|
|
1745
|
-
: {}
|
|
1749
|
+
: {});
|
|
1746
1750
|
if (!options) {
|
|
1747
1751
|
console.error(`Error transforming image asset: Required variable [${optionsVariableName}] missing from component definition`);
|
|
1748
1752
|
return;
|
|
@@ -1767,7 +1771,7 @@ const transformMedia = (asset, variables, resolveDesignValue, variableName, path
|
|
|
1767
1771
|
const optionsVariableName = 'cfBackgroundImageOptions';
|
|
1768
1772
|
const options = resolveDesignValue(variables[optionsVariableName]?.type === 'DesignValue'
|
|
1769
1773
|
? variables[optionsVariableName].valuesByBreakpoint
|
|
1770
|
-
: {}
|
|
1774
|
+
: {});
|
|
1771
1775
|
if (!options) {
|
|
1772
1776
|
console.error(`Error transforming image asset: Required variable [${optionsVariableName}] missing from component definition`);
|
|
1773
1777
|
return;
|
|
@@ -3108,10 +3112,10 @@ const useBreakpoints = (breakpoints) => {
|
|
|
3108
3112
|
});
|
|
3109
3113
|
};
|
|
3110
3114
|
}, [breakpoints]);
|
|
3111
|
-
const resolveDesignValue = useCallback((valuesByBreakpoint,
|
|
3115
|
+
const resolveDesignValue = useCallback((valuesByBreakpoint, propertyName) => {
|
|
3112
3116
|
const fallbackBreakpointIndex = getFallbackBreakpointIndex(breakpoints);
|
|
3113
3117
|
const activeBreakpointIndex = getActiveBreakpointIndex(breakpoints, mediaQueryMatches, fallbackBreakpointIndex);
|
|
3114
|
-
return getValueForBreakpoint(valuesByBreakpoint, breakpoints, activeBreakpointIndex, fallbackBreakpointIndex,
|
|
3118
|
+
return getValueForBreakpoint(valuesByBreakpoint, breakpoints, activeBreakpointIndex, fallbackBreakpointIndex, propertyName);
|
|
3115
3119
|
}, [mediaQueryMatches, breakpoints]);
|
|
3116
3120
|
return { resolveDesignValue };
|
|
3117
3121
|
};
|
|
@@ -4614,7 +4618,7 @@ const useComponentProps = ({ node, areEntitiesFetched, resolveDesignValue, rende
|
|
|
4614
4618
|
const props = useMemo(() => {
|
|
4615
4619
|
const propsBase = {
|
|
4616
4620
|
cfSsrClassName: node.data.props.cfSsrClassName
|
|
4617
|
-
? resolveDesignValue(node.data.props.cfSsrClassName.valuesByBreakpoint
|
|
4621
|
+
? resolveDesignValue(node.data.props.cfSsrClassName.valuesByBreakpoint)
|
|
4618
4622
|
: undefined,
|
|
4619
4623
|
};
|
|
4620
4624
|
// Don't enrich the assembly wrapper node with props
|
|
@@ -5396,7 +5400,7 @@ function useSingleColumn(node, resolveDesignValue) {
|
|
|
5396
5400
|
if (cfWrapColumns.type !== 'DesignValue') {
|
|
5397
5401
|
return false;
|
|
5398
5402
|
}
|
|
5399
|
-
return resolveDesignValue(cfWrapColumns.valuesByBreakpoint
|
|
5403
|
+
return resolveDesignValue(cfWrapColumns.valuesByBreakpoint);
|
|
5400
5404
|
}, [tree, node, isSingleColumn, resolveDesignValue]);
|
|
5401
5405
|
return {
|
|
5402
5406
|
isSingleColumn,
|
|
@@ -5540,7 +5544,7 @@ const useDropzoneDirection = ({ resolveDesignValue, node, zoneId }) => {
|
|
|
5540
5544
|
if (!designValues || !resolveDesignValue || designValues.type !== 'DesignValue') {
|
|
5541
5545
|
return 'vertical';
|
|
5542
5546
|
}
|
|
5543
|
-
const direction = resolveDesignValue(designValues.valuesByBreakpoint
|
|
5547
|
+
const direction = resolveDesignValue(designValues.valuesByBreakpoint);
|
|
5544
5548
|
if (direction === 'row') {
|
|
5545
5549
|
return 'horizontal';
|
|
5546
5550
|
}
|