@contentful/experiences-visual-editor-react 1.31.0 → 1.31.1-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 +62 -17
- package/dist/index.js.map +1 -1
- package/dist/renderApp.js +62 -17
- package/dist/renderApp.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1015,8 +1015,33 @@ const ComponentVariableSchema$1 = z.object({
|
|
|
1015
1015
|
});
|
|
1016
1016
|
const ComponentVariablesSchema$1 = z.record(z.string().regex(/^[a-zA-Z0-9-_]{1,54}$/), // Here the key is <variableName>_<nanoidId> so we need to allow for a longer length
|
|
1017
1017
|
ComponentVariableSchema$1);
|
|
1018
|
+
const THUMBNAIL_IDS$1 = [
|
|
1019
|
+
'columns',
|
|
1020
|
+
'columnsPlusRight',
|
|
1021
|
+
'imagesSquare',
|
|
1022
|
+
'subtitles',
|
|
1023
|
+
'rowsPlusBottom',
|
|
1024
|
+
'userRectangle',
|
|
1025
|
+
'textbox',
|
|
1026
|
+
'monitorPlay',
|
|
1027
|
+
'article',
|
|
1028
|
+
'table',
|
|
1029
|
+
'star',
|
|
1030
|
+
'heartStraight',
|
|
1031
|
+
'frameCorners',
|
|
1032
|
+
'rows',
|
|
1033
|
+
'dotsThreeOutline',
|
|
1034
|
+
'listDashes',
|
|
1035
|
+
'checkerBoard',
|
|
1036
|
+
'gridFour',
|
|
1037
|
+
'slideshow',
|
|
1038
|
+
'diamondsFour',
|
|
1039
|
+
'cards',
|
|
1040
|
+
'textColumns',
|
|
1041
|
+
];
|
|
1018
1042
|
const ComponentSettingsSchema$1 = z.object({
|
|
1019
1043
|
variableDefinitions: ComponentVariablesSchema$1,
|
|
1044
|
+
thumbnailId: z.enum(THUMBNAIL_IDS$1).optional(),
|
|
1020
1045
|
variableMappings: VariableMappingsSchema$1.optional(),
|
|
1021
1046
|
patternPropertyDefinitions: PatternPropertyDefinitionsSchema$1.optional(),
|
|
1022
1047
|
});
|
|
@@ -1499,11 +1524,11 @@ function getArrayValue(entryOrAsset, path, entityStore) {
|
|
|
1499
1524
|
return result;
|
|
1500
1525
|
}
|
|
1501
1526
|
|
|
1502
|
-
const transformBoundContentValue = (variables, entityStore, binding, resolveDesignValue, variableName,
|
|
1527
|
+
const transformBoundContentValue = (variables, entityStore, binding, resolveDesignValue, variableName, variableType, path) => {
|
|
1503
1528
|
const entityOrAsset = entityStore.getEntryOrAsset(binding, path);
|
|
1504
1529
|
if (!entityOrAsset)
|
|
1505
1530
|
return;
|
|
1506
|
-
switch (
|
|
1531
|
+
switch (variableType) {
|
|
1507
1532
|
case 'Media':
|
|
1508
1533
|
// If we bound a normal entry field to the media variable we just return the bound value
|
|
1509
1534
|
if (entityOrAsset.sys.type === 'Entry') {
|
|
@@ -1639,7 +1664,7 @@ const builtInStylesWithDesignTokens = [
|
|
|
1639
1664
|
const isValidBreakpointValue = (value) => {
|
|
1640
1665
|
return value !== undefined && value !== null && value !== '';
|
|
1641
1666
|
};
|
|
1642
|
-
const getValueForBreakpoint = (valuesByBreakpoint, breakpoints, activeBreakpointIndex, variableName, resolveDesignTokens = true) => {
|
|
1667
|
+
const getValueForBreakpoint = (valuesByBreakpoint, breakpoints, activeBreakpointIndex, fallbackBreakpointIndex, variableName, resolveDesignTokens = true) => {
|
|
1643
1668
|
const eventuallyResolveDesignTokens = (value) => {
|
|
1644
1669
|
// For some built-in design properties, we support design tokens
|
|
1645
1670
|
if (builtInStylesWithDesignTokens.includes(variableName)) {
|
|
@@ -1660,8 +1685,6 @@ const getValueForBreakpoint = (valuesByBreakpoint, breakpoints, activeBreakpoint
|
|
|
1660
1685
|
return valuesByBreakpoint[breakpointId];
|
|
1661
1686
|
}
|
|
1662
1687
|
}
|
|
1663
|
-
// If no breakpoint matched, we search and apply the fallback breakpoint
|
|
1664
|
-
const fallbackBreakpointIndex = getFallbackBreakpointIndex(breakpoints);
|
|
1665
1688
|
const fallbackBreakpointId = breakpoints[fallbackBreakpointIndex]?.id;
|
|
1666
1689
|
if (isValidBreakpointValue(valuesByBreakpoint[fallbackBreakpointId])) {
|
|
1667
1690
|
if (resolveDesignTokens) {
|
|
@@ -2996,13 +3019,11 @@ styleInject(css_248z$9);
|
|
|
2996
3019
|
* and then decending by screen width. For mobile-first designs, the order would be ascending
|
|
2997
3020
|
*/
|
|
2998
3021
|
const useBreakpoints = (breakpoints) => {
|
|
2999
|
-
const [
|
|
3000
|
-
const
|
|
3022
|
+
const [, initialMediaQueryMatches] = mediaQueryMatcher(breakpoints);
|
|
3023
|
+
const [mediaQueryMatches, setMediaQueryMatches] = useState(initialMediaQueryMatches);
|
|
3001
3024
|
// Register event listeners to update the media query states
|
|
3002
3025
|
useEffect(() => {
|
|
3003
|
-
const [mediaQueryMatchers
|
|
3004
|
-
// Store the media query state in the beginning to initialise the state
|
|
3005
|
-
setMediaQueryMatches(initialMediaQueryMatches);
|
|
3026
|
+
const [mediaQueryMatchers] = mediaQueryMatcher(breakpoints);
|
|
3006
3027
|
const eventListeners = mediaQueryMatchers.map(({ id, signal }) => {
|
|
3007
3028
|
const onChange = () => setMediaQueryMatches((prev) => ({
|
|
3008
3029
|
...prev,
|
|
@@ -3016,13 +3037,12 @@ const useBreakpoints = (breakpoints) => {
|
|
|
3016
3037
|
mediaQueryMatchers[index].signal.removeEventListener('change', eventListener);
|
|
3017
3038
|
});
|
|
3018
3039
|
};
|
|
3019
|
-
// Only re-setup all listeners when the breakpoint definition changed
|
|
3020
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3021
3040
|
}, [breakpoints]);
|
|
3022
|
-
const activeBreakpointIndex = getActiveBreakpointIndex(breakpoints, mediaQueryMatches, fallbackBreakpointIndex);
|
|
3023
3041
|
const resolveDesignValue = useCallback((valuesByBreakpoint, variableName) => {
|
|
3024
|
-
|
|
3025
|
-
|
|
3042
|
+
const fallbackBreakpointIndex = getFallbackBreakpointIndex(breakpoints);
|
|
3043
|
+
const activeBreakpointIndex = getActiveBreakpointIndex(breakpoints, mediaQueryMatches, fallbackBreakpointIndex);
|
|
3044
|
+
return getValueForBreakpoint(valuesByBreakpoint, breakpoints, activeBreakpointIndex, fallbackBreakpointIndex, variableName);
|
|
3045
|
+
}, [mediaQueryMatches, breakpoints]);
|
|
3026
3046
|
return { resolveDesignValue };
|
|
3027
3047
|
};
|
|
3028
3048
|
|
|
@@ -3427,8 +3447,33 @@ const ComponentVariableSchema = z.object({
|
|
|
3427
3447
|
});
|
|
3428
3448
|
const ComponentVariablesSchema = z.record(z.string().regex(/^[a-zA-Z0-9-_]{1,54}$/), // Here the key is <variableName>_<nanoidId> so we need to allow for a longer length
|
|
3429
3449
|
ComponentVariableSchema);
|
|
3450
|
+
const THUMBNAIL_IDS = [
|
|
3451
|
+
'columns',
|
|
3452
|
+
'columnsPlusRight',
|
|
3453
|
+
'imagesSquare',
|
|
3454
|
+
'subtitles',
|
|
3455
|
+
'rowsPlusBottom',
|
|
3456
|
+
'userRectangle',
|
|
3457
|
+
'textbox',
|
|
3458
|
+
'monitorPlay',
|
|
3459
|
+
'article',
|
|
3460
|
+
'table',
|
|
3461
|
+
'star',
|
|
3462
|
+
'heartStraight',
|
|
3463
|
+
'frameCorners',
|
|
3464
|
+
'rows',
|
|
3465
|
+
'dotsThreeOutline',
|
|
3466
|
+
'listDashes',
|
|
3467
|
+
'checkerBoard',
|
|
3468
|
+
'gridFour',
|
|
3469
|
+
'slideshow',
|
|
3470
|
+
'diamondsFour',
|
|
3471
|
+
'cards',
|
|
3472
|
+
'textColumns',
|
|
3473
|
+
];
|
|
3430
3474
|
const ComponentSettingsSchema = z.object({
|
|
3431
3475
|
variableDefinitions: ComponentVariablesSchema,
|
|
3476
|
+
thumbnailId: z.enum(THUMBNAIL_IDS).optional(),
|
|
3432
3477
|
variableMappings: VariableMappingsSchema.optional(),
|
|
3433
3478
|
patternPropertyDefinitions: PatternPropertyDefinitionsSchema.optional(),
|
|
3434
3479
|
});
|
|
@@ -4486,7 +4531,7 @@ const useComponentProps = ({ node, areEntitiesFetched, resolveDesignValue, rende
|
|
|
4486
4531
|
const [, uuid, path] = variableMapping.path.split('/');
|
|
4487
4532
|
const binding = dataSource[uuid];
|
|
4488
4533
|
const variableDefinition = definition.variables[variableName];
|
|
4489
|
-
let boundValue = transformBoundContentValue(node.data.props, entityStore, binding, resolveDesignValue, variableName, variableDefinition, variableMapping.path);
|
|
4534
|
+
let boundValue = transformBoundContentValue(node.data.props, entityStore, binding, resolveDesignValue, variableName, variableDefinition.type, variableMapping.path);
|
|
4490
4535
|
// In some cases, there may be an asset linked in the path, so we need to consider this scenario:
|
|
4491
4536
|
// If no 'boundValue' is found, we also attempt to extract the value associated with the second-to-last item in the path.
|
|
4492
4537
|
// If successful, it means we have identified the linked asset.
|
|
@@ -5210,7 +5255,7 @@ function useSingleColumn(node, resolveDesignValue) {
|
|
|
5210
5255
|
return { isWrapped, wrapColumnsCount };
|
|
5211
5256
|
}
|
|
5212
5257
|
const parentNode = getItem({ id: node.parentId }, tree);
|
|
5213
|
-
if (!parentNode) {
|
|
5258
|
+
if (!parentNode || parentNode.data.blockId !== CONTENTFUL_COMPONENTS$1.columns.id) {
|
|
5214
5259
|
return { isWrapped, wrapColumnsCount };
|
|
5215
5260
|
}
|
|
5216
5261
|
const { cfWrapColumns, cfWrapColumnsCount } = parentNode.data.props;
|