@contentful/experiences-visual-editor-react 1.31.1-prerelease-20250218T2104-febb4f2.0 → 1.31.1
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 +75 -26
- package/dist/index.js.map +1 -1
- package/dist/renderApp.js +75 -26
- package/dist/renderApp.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -926,14 +926,14 @@ const ComponentValueSchema$1 = z
|
|
|
926
926
|
.strict();
|
|
927
927
|
// TODO: finalize schema structure before release
|
|
928
928
|
// https://contentful.atlassian.net/browse/LUMOS-523
|
|
929
|
-
const
|
|
929
|
+
const EmptyObjectSchema$1 = z.object({ type: z.undefined() });
|
|
930
930
|
const ComponentPropertyValueSchema$1 = z.discriminatedUnion('type', [
|
|
931
931
|
DesignValueSchema$1,
|
|
932
932
|
BoundValueSchema$1,
|
|
933
933
|
UnboundValueSchema$1,
|
|
934
934
|
HyperlinkValueSchema$1,
|
|
935
935
|
ComponentValueSchema$1,
|
|
936
|
-
|
|
936
|
+
EmptyObjectSchema$1,
|
|
937
937
|
]);
|
|
938
938
|
// TODO: finalize schema structure before release
|
|
939
939
|
// https://contentful.atlassian.net/browse/LUMOS-523
|
|
@@ -946,12 +946,13 @@ const VariableMappingsSchema$1 = z.record(propertyKeySchema$1, VariableMappingSc
|
|
|
946
946
|
// TODO: finalize schema structure before release
|
|
947
947
|
// https://contentful.atlassian.net/browse/LUMOS-523
|
|
948
948
|
const PatternPropertyDefinitionSchema$1 = z.object({
|
|
949
|
-
defaultValue: z
|
|
950
|
-
.object({
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
.
|
|
949
|
+
defaultValue: z.union([
|
|
950
|
+
z.object({
|
|
951
|
+
path: z.string(),
|
|
952
|
+
type: z.literal('BoundValue'),
|
|
953
|
+
}),
|
|
954
|
+
z.null(),
|
|
955
|
+
]),
|
|
955
956
|
contentTypes: z.record(z.string(), z.any()),
|
|
956
957
|
});
|
|
957
958
|
const PatternPropertyDefinitionsSchema$1 = z.record(propertyKeySchema$1, PatternPropertyDefinitionSchema$1);
|
|
@@ -1014,8 +1015,33 @@ const ComponentVariableSchema$1 = z.object({
|
|
|
1014
1015
|
});
|
|
1015
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
|
|
1016
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
|
+
];
|
|
1017
1042
|
const ComponentSettingsSchema$1 = z.object({
|
|
1018
1043
|
variableDefinitions: ComponentVariablesSchema$1,
|
|
1044
|
+
thumbnailId: z.enum(THUMBNAIL_IDS$1).optional(),
|
|
1019
1045
|
variableMappings: VariableMappingsSchema$1.optional(),
|
|
1020
1046
|
patternPropertyDefinitions: PatternPropertyDefinitionsSchema$1.optional(),
|
|
1021
1047
|
});
|
|
@@ -1498,11 +1524,11 @@ function getArrayValue(entryOrAsset, path, entityStore) {
|
|
|
1498
1524
|
return result;
|
|
1499
1525
|
}
|
|
1500
1526
|
|
|
1501
|
-
const transformBoundContentValue = (variables, entityStore, binding, resolveDesignValue, variableName,
|
|
1527
|
+
const transformBoundContentValue = (variables, entityStore, binding, resolveDesignValue, variableName, variableType, path) => {
|
|
1502
1528
|
const entityOrAsset = entityStore.getEntryOrAsset(binding, path);
|
|
1503
1529
|
if (!entityOrAsset)
|
|
1504
1530
|
return;
|
|
1505
|
-
switch (
|
|
1531
|
+
switch (variableType) {
|
|
1506
1532
|
case 'Media':
|
|
1507
1533
|
// If we bound a normal entry field to the media variable we just return the bound value
|
|
1508
1534
|
if (entityOrAsset.sys.type === 'Entry') {
|
|
@@ -2993,12 +3019,11 @@ styleInject(css_248z$9);
|
|
|
2993
3019
|
* and then decending by screen width. For mobile-first designs, the order would be ascending
|
|
2994
3020
|
*/
|
|
2995
3021
|
const useBreakpoints = (breakpoints) => {
|
|
2996
|
-
const [
|
|
3022
|
+
const [, initialMediaQueryMatches] = mediaQueryMatcher(breakpoints);
|
|
3023
|
+
const [mediaQueryMatches, setMediaQueryMatches] = useState(initialMediaQueryMatches);
|
|
2997
3024
|
// Register event listeners to update the media query states
|
|
2998
3025
|
useEffect(() => {
|
|
2999
|
-
const [mediaQueryMatchers
|
|
3000
|
-
// Store the media query state in the beginning to initialise the state
|
|
3001
|
-
setMediaQueryMatches(initialMediaQueryMatches);
|
|
3026
|
+
const [mediaQueryMatchers] = mediaQueryMatcher(breakpoints);
|
|
3002
3027
|
const eventListeners = mediaQueryMatchers.map(({ id, signal }) => {
|
|
3003
3028
|
const onChange = () => setMediaQueryMatches((prev) => ({
|
|
3004
3029
|
...prev,
|
|
@@ -3012,8 +3037,6 @@ const useBreakpoints = (breakpoints) => {
|
|
|
3012
3037
|
mediaQueryMatchers[index].signal.removeEventListener('change', eventListener);
|
|
3013
3038
|
});
|
|
3014
3039
|
};
|
|
3015
|
-
// Only re-setup all listeners when the breakpoint definition changed
|
|
3016
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3017
3040
|
}, [breakpoints]);
|
|
3018
3041
|
const resolveDesignValue = useCallback((valuesByBreakpoint, variableName) => {
|
|
3019
3042
|
const fallbackBreakpointIndex = getFallbackBreakpointIndex(breakpoints);
|
|
@@ -3335,14 +3358,14 @@ const ComponentValueSchema = z
|
|
|
3335
3358
|
.strict();
|
|
3336
3359
|
// TODO: finalize schema structure before release
|
|
3337
3360
|
// https://contentful.atlassian.net/browse/LUMOS-523
|
|
3338
|
-
const
|
|
3361
|
+
const EmptyObjectSchema = z.object({ type: z.undefined() });
|
|
3339
3362
|
const ComponentPropertyValueSchema = z.discriminatedUnion('type', [
|
|
3340
3363
|
DesignValueSchema,
|
|
3341
3364
|
BoundValueSchema,
|
|
3342
3365
|
UnboundValueSchema,
|
|
3343
3366
|
HyperlinkValueSchema,
|
|
3344
3367
|
ComponentValueSchema,
|
|
3345
|
-
|
|
3368
|
+
EmptyObjectSchema,
|
|
3346
3369
|
]);
|
|
3347
3370
|
// TODO: finalize schema structure before release
|
|
3348
3371
|
// https://contentful.atlassian.net/browse/LUMOS-523
|
|
@@ -3355,12 +3378,13 @@ const VariableMappingsSchema = z.record(propertyKeySchema, VariableMappingSchema
|
|
|
3355
3378
|
// TODO: finalize schema structure before release
|
|
3356
3379
|
// https://contentful.atlassian.net/browse/LUMOS-523
|
|
3357
3380
|
const PatternPropertyDefinitionSchema = z.object({
|
|
3358
|
-
defaultValue: z
|
|
3359
|
-
.object({
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
.
|
|
3381
|
+
defaultValue: z.union([
|
|
3382
|
+
z.object({
|
|
3383
|
+
path: z.string(),
|
|
3384
|
+
type: z.literal('BoundValue'),
|
|
3385
|
+
}),
|
|
3386
|
+
z.null(),
|
|
3387
|
+
]),
|
|
3364
3388
|
contentTypes: z.record(z.string(), z.any()),
|
|
3365
3389
|
});
|
|
3366
3390
|
const PatternPropertyDefinitionsSchema = z.record(propertyKeySchema, PatternPropertyDefinitionSchema);
|
|
@@ -3423,8 +3447,33 @@ const ComponentVariableSchema = z.object({
|
|
|
3423
3447
|
});
|
|
3424
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
|
|
3425
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
|
+
];
|
|
3426
3474
|
const ComponentSettingsSchema = z.object({
|
|
3427
3475
|
variableDefinitions: ComponentVariablesSchema,
|
|
3476
|
+
thumbnailId: z.enum(THUMBNAIL_IDS).optional(),
|
|
3428
3477
|
variableMappings: VariableMappingsSchema.optional(),
|
|
3429
3478
|
patternPropertyDefinitions: PatternPropertyDefinitionsSchema.optional(),
|
|
3430
3479
|
});
|
|
@@ -4482,7 +4531,7 @@ const useComponentProps = ({ node, areEntitiesFetched, resolveDesignValue, rende
|
|
|
4482
4531
|
const [, uuid, path] = variableMapping.path.split('/');
|
|
4483
4532
|
const binding = dataSource[uuid];
|
|
4484
4533
|
const variableDefinition = definition.variables[variableName];
|
|
4485
|
-
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);
|
|
4486
4535
|
// In some cases, there may be an asset linked in the path, so we need to consider this scenario:
|
|
4487
4536
|
// If no 'boundValue' is found, we also attempt to extract the value associated with the second-to-last item in the path.
|
|
4488
4537
|
// If successful, it means we have identified the linked asset.
|
|
@@ -5206,7 +5255,7 @@ function useSingleColumn(node, resolveDesignValue) {
|
|
|
5206
5255
|
return { isWrapped, wrapColumnsCount };
|
|
5207
5256
|
}
|
|
5208
5257
|
const parentNode = getItem({ id: node.parentId }, tree);
|
|
5209
|
-
if (!parentNode) {
|
|
5258
|
+
if (!parentNode || parentNode.data.blockId !== CONTENTFUL_COMPONENTS$1.columns.id) {
|
|
5210
5259
|
return { isWrapped, wrapColumnsCount };
|
|
5211
5260
|
}
|
|
5212
5261
|
const { cfWrapColumns, cfWrapColumnsCount } = parentNode.data.props;
|