@contentful/experiences-visual-editor-react 1.37.3-dev-20250522T1032-0caa03f.0 → 1.38.0-beta.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 +36 -20
- package/dist/index.js.map +1 -1
- package/dist/renderApp.js +36 -20
- package/dist/renderApp.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -679,7 +679,13 @@ const PatternPropertyDefinitionSchema$1 = z.object({
|
|
|
679
679
|
}),
|
|
680
680
|
}))
|
|
681
681
|
.optional(),
|
|
682
|
-
contentTypes: z.record(z.string(), z.
|
|
682
|
+
contentTypes: z.record(z.string(), z.object({
|
|
683
|
+
sys: z.object({
|
|
684
|
+
type: z.literal('Link'),
|
|
685
|
+
id: z.string(),
|
|
686
|
+
linkType: z.enum(['ContentType']),
|
|
687
|
+
}),
|
|
688
|
+
})),
|
|
683
689
|
});
|
|
684
690
|
const PatternPropertyDefinitionsSchema$1 = z.record(propertyKeySchema$1, PatternPropertyDefinitionSchema$1);
|
|
685
691
|
// TODO: finalize schema structure before release
|
|
@@ -1029,11 +1035,21 @@ const builtInStylesWithDesignTokens = [
|
|
|
1029
1035
|
const isValidBreakpointValue = (value) => {
|
|
1030
1036
|
return value !== undefined && value !== null && value !== '';
|
|
1031
1037
|
};
|
|
1032
|
-
const getValueForBreakpoint = (valuesByBreakpoint, breakpoints, activeBreakpointIndex, fallbackBreakpointIndex,
|
|
1038
|
+
const getValueForBreakpoint = (valuesByBreakpoint, breakpoints, activeBreakpointIndex, fallbackBreakpointIndex,
|
|
1039
|
+
/** Provide the name for built-in styles to replace design tokens. Supported properties are:
|
|
1040
|
+
* cfMargin, cfPadding, cfGap, cfWidth, cfHeight, cfBackgroundColor,
|
|
1041
|
+
* cfBorder, cfBorderRadius, cfFontSize, cfLineHeight, cfLetterSpacing,
|
|
1042
|
+
* cfTextColor, cfMaxWidth
|
|
1043
|
+
*/
|
|
1044
|
+
propertyName, resolveDesignTokens = true) => {
|
|
1033
1045
|
const eventuallyResolveDesignTokens = (value) => {
|
|
1046
|
+
// This is used externally in the web app to determine the original persisted value
|
|
1047
|
+
if (!resolveDesignTokens) {
|
|
1048
|
+
return value;
|
|
1049
|
+
}
|
|
1034
1050
|
// For some built-in design properties, we support design tokens
|
|
1035
|
-
if (builtInStylesWithDesignTokens.includes(
|
|
1036
|
-
return getDesignTokenRegistration(value,
|
|
1051
|
+
if (propertyName && builtInStylesWithDesignTokens.includes(propertyName)) {
|
|
1052
|
+
return getDesignTokenRegistration(value, propertyName);
|
|
1037
1053
|
}
|
|
1038
1054
|
// For all other properties, we just return the breakpoint-specific value
|
|
1039
1055
|
return value;
|
|
@@ -1044,18 +1060,12 @@ const getValueForBreakpoint = (valuesByBreakpoint, breakpoints, activeBreakpoint
|
|
|
1044
1060
|
const breakpointId = breakpoints[index]?.id;
|
|
1045
1061
|
if (isValidBreakpointValue(valuesByBreakpoint[breakpointId])) {
|
|
1046
1062
|
// If the value is defined, we use it and stop the breakpoints cascade
|
|
1047
|
-
|
|
1048
|
-
return eventuallyResolveDesignTokens(valuesByBreakpoint[breakpointId]);
|
|
1049
|
-
}
|
|
1050
|
-
return valuesByBreakpoint[breakpointId];
|
|
1063
|
+
return eventuallyResolveDesignTokens(valuesByBreakpoint[breakpointId]);
|
|
1051
1064
|
}
|
|
1052
1065
|
}
|
|
1053
1066
|
const fallbackBreakpointId = breakpoints[fallbackBreakpointIndex]?.id;
|
|
1054
1067
|
if (isValidBreakpointValue(valuesByBreakpoint[fallbackBreakpointId])) {
|
|
1055
|
-
|
|
1056
|
-
return eventuallyResolveDesignTokens(valuesByBreakpoint[fallbackBreakpointId]);
|
|
1057
|
-
}
|
|
1058
|
-
return valuesByBreakpoint[fallbackBreakpointId];
|
|
1068
|
+
return eventuallyResolveDesignTokens(valuesByBreakpoint[fallbackBreakpointId]);
|
|
1059
1069
|
}
|
|
1060
1070
|
}
|
|
1061
1071
|
else {
|
|
@@ -1742,7 +1752,7 @@ const transformMedia = (asset, variables, resolveDesignValue, variableName, path
|
|
|
1742
1752
|
const optionsVariableName = 'cfImageOptions';
|
|
1743
1753
|
const options = resolveDesignValue(variables[optionsVariableName]?.type === 'DesignValue'
|
|
1744
1754
|
? variables[optionsVariableName].valuesByBreakpoint
|
|
1745
|
-
: {}
|
|
1755
|
+
: {});
|
|
1746
1756
|
if (!options) {
|
|
1747
1757
|
console.error(`Error transforming image asset: Required variable [${optionsVariableName}] missing from component definition`);
|
|
1748
1758
|
return;
|
|
@@ -1767,7 +1777,7 @@ const transformMedia = (asset, variables, resolveDesignValue, variableName, path
|
|
|
1767
1777
|
const optionsVariableName = 'cfBackgroundImageOptions';
|
|
1768
1778
|
const options = resolveDesignValue(variables[optionsVariableName]?.type === 'DesignValue'
|
|
1769
1779
|
? variables[optionsVariableName].valuesByBreakpoint
|
|
1770
|
-
: {}
|
|
1780
|
+
: {});
|
|
1771
1781
|
if (!options) {
|
|
1772
1782
|
console.error(`Error transforming image asset: Required variable [${optionsVariableName}] missing from component definition`);
|
|
1773
1783
|
return;
|
|
@@ -3108,10 +3118,10 @@ const useBreakpoints = (breakpoints) => {
|
|
|
3108
3118
|
});
|
|
3109
3119
|
};
|
|
3110
3120
|
}, [breakpoints]);
|
|
3111
|
-
const resolveDesignValue = useCallback((valuesByBreakpoint,
|
|
3121
|
+
const resolveDesignValue = useCallback((valuesByBreakpoint, propertyName) => {
|
|
3112
3122
|
const fallbackBreakpointIndex = getFallbackBreakpointIndex(breakpoints);
|
|
3113
3123
|
const activeBreakpointIndex = getActiveBreakpointIndex(breakpoints, mediaQueryMatches, fallbackBreakpointIndex);
|
|
3114
|
-
return getValueForBreakpoint(valuesByBreakpoint, breakpoints, activeBreakpointIndex, fallbackBreakpointIndex,
|
|
3124
|
+
return getValueForBreakpoint(valuesByBreakpoint, breakpoints, activeBreakpointIndex, fallbackBreakpointIndex, propertyName);
|
|
3115
3125
|
}, [mediaQueryMatches, breakpoints]);
|
|
3116
3126
|
return { resolveDesignValue };
|
|
3117
3127
|
};
|
|
@@ -3458,7 +3468,13 @@ const PatternPropertyDefinitionSchema = z.object({
|
|
|
3458
3468
|
}),
|
|
3459
3469
|
}))
|
|
3460
3470
|
.optional(),
|
|
3461
|
-
contentTypes: z.record(z.string(), z.
|
|
3471
|
+
contentTypes: z.record(z.string(), z.object({
|
|
3472
|
+
sys: z.object({
|
|
3473
|
+
type: z.literal('Link'),
|
|
3474
|
+
id: z.string(),
|
|
3475
|
+
linkType: z.enum(['ContentType']),
|
|
3476
|
+
}),
|
|
3477
|
+
})),
|
|
3462
3478
|
});
|
|
3463
3479
|
const PatternPropertyDefinitionsSchema = z.record(propertyKeySchema, PatternPropertyDefinitionSchema);
|
|
3464
3480
|
// TODO: finalize schema structure before release
|
|
@@ -4614,7 +4630,7 @@ const useComponentProps = ({ node, areEntitiesFetched, resolveDesignValue, rende
|
|
|
4614
4630
|
const props = useMemo(() => {
|
|
4615
4631
|
const propsBase = {
|
|
4616
4632
|
cfSsrClassName: node.data.props.cfSsrClassName
|
|
4617
|
-
? resolveDesignValue(node.data.props.cfSsrClassName.valuesByBreakpoint
|
|
4633
|
+
? resolveDesignValue(node.data.props.cfSsrClassName.valuesByBreakpoint)
|
|
4618
4634
|
: undefined,
|
|
4619
4635
|
};
|
|
4620
4636
|
// Don't enrich the assembly wrapper node with props
|
|
@@ -5396,7 +5412,7 @@ function useSingleColumn(node, resolveDesignValue) {
|
|
|
5396
5412
|
if (cfWrapColumns.type !== 'DesignValue') {
|
|
5397
5413
|
return false;
|
|
5398
5414
|
}
|
|
5399
|
-
return resolveDesignValue(cfWrapColumns.valuesByBreakpoint
|
|
5415
|
+
return resolveDesignValue(cfWrapColumns.valuesByBreakpoint);
|
|
5400
5416
|
}, [tree, node, isSingleColumn, resolveDesignValue]);
|
|
5401
5417
|
return {
|
|
5402
5418
|
isSingleColumn,
|
|
@@ -5540,7 +5556,7 @@ const useDropzoneDirection = ({ resolveDesignValue, node, zoneId }) => {
|
|
|
5540
5556
|
if (!designValues || !resolveDesignValue || designValues.type !== 'DesignValue') {
|
|
5541
5557
|
return 'vertical';
|
|
5542
5558
|
}
|
|
5543
|
-
const direction = resolveDesignValue(designValues.valuesByBreakpoint
|
|
5559
|
+
const direction = resolveDesignValue(designValues.valuesByBreakpoint);
|
|
5544
5560
|
if (direction === 'row') {
|
|
5545
5561
|
return 'horizontal';
|
|
5546
5562
|
}
|