@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/renderApp.js CHANGED
@@ -43636,8 +43636,33 @@ const ComponentVariableSchema$1 = z.object({
43636
43636
  });
43637
43637
  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
43638
43638
  ComponentVariableSchema$1);
43639
+ const THUMBNAIL_IDS$1 = [
43640
+ 'columns',
43641
+ 'columnsPlusRight',
43642
+ 'imagesSquare',
43643
+ 'subtitles',
43644
+ 'rowsPlusBottom',
43645
+ 'userRectangle',
43646
+ 'textbox',
43647
+ 'monitorPlay',
43648
+ 'article',
43649
+ 'table',
43650
+ 'star',
43651
+ 'heartStraight',
43652
+ 'frameCorners',
43653
+ 'rows',
43654
+ 'dotsThreeOutline',
43655
+ 'listDashes',
43656
+ 'checkerBoard',
43657
+ 'gridFour',
43658
+ 'slideshow',
43659
+ 'diamondsFour',
43660
+ 'cards',
43661
+ 'textColumns',
43662
+ ];
43639
43663
  const ComponentSettingsSchema$1 = z.object({
43640
43664
  variableDefinitions: ComponentVariablesSchema$1,
43665
+ thumbnailId: z.enum(THUMBNAIL_IDS$1).optional(),
43641
43666
  variableMappings: VariableMappingsSchema$1.optional(),
43642
43667
  patternPropertyDefinitions: PatternPropertyDefinitionsSchema$1.optional(),
43643
43668
  });
@@ -44120,11 +44145,11 @@ function getArrayValue(entryOrAsset, path, entityStore) {
44120
44145
  return result;
44121
44146
  }
44122
44147
 
44123
- const transformBoundContentValue = (variables, entityStore, binding, resolveDesignValue, variableName, variableDefinition, path) => {
44148
+ const transformBoundContentValue = (variables, entityStore, binding, resolveDesignValue, variableName, variableType, path) => {
44124
44149
  const entityOrAsset = entityStore.getEntryOrAsset(binding, path);
44125
44150
  if (!entityOrAsset)
44126
44151
  return;
44127
- switch (variableDefinition.type) {
44152
+ switch (variableType) {
44128
44153
  case 'Media':
44129
44154
  // If we bound a normal entry field to the media variable we just return the bound value
44130
44155
  if (entityOrAsset.sys.type === 'Entry') {
@@ -44260,7 +44285,7 @@ const builtInStylesWithDesignTokens = [
44260
44285
  const isValidBreakpointValue = (value) => {
44261
44286
  return value !== undefined && value !== null && value !== '';
44262
44287
  };
44263
- const getValueForBreakpoint = (valuesByBreakpoint, breakpoints, activeBreakpointIndex, variableName, resolveDesignTokens = true) => {
44288
+ const getValueForBreakpoint = (valuesByBreakpoint, breakpoints, activeBreakpointIndex, fallbackBreakpointIndex, variableName, resolveDesignTokens = true) => {
44264
44289
  const eventuallyResolveDesignTokens = (value) => {
44265
44290
  // For some built-in design properties, we support design tokens
44266
44291
  if (builtInStylesWithDesignTokens.includes(variableName)) {
@@ -44281,8 +44306,6 @@ const getValueForBreakpoint = (valuesByBreakpoint, breakpoints, activeBreakpoint
44281
44306
  return valuesByBreakpoint[breakpointId];
44282
44307
  }
44283
44308
  }
44284
- // If no breakpoint matched, we search and apply the fallback breakpoint
44285
- const fallbackBreakpointIndex = getFallbackBreakpointIndex(breakpoints);
44286
44309
  const fallbackBreakpointId = breakpoints[fallbackBreakpointIndex]?.id;
44287
44310
  if (isValidBreakpointValue(valuesByBreakpoint[fallbackBreakpointId])) {
44288
44311
  if (resolveDesignTokens) {
@@ -56684,13 +56707,11 @@ styleInject(css_248z$9);
56684
56707
  * and then decending by screen width. For mobile-first designs, the order would be ascending
56685
56708
  */
56686
56709
  const useBreakpoints = (breakpoints) => {
56687
- const [mediaQueryMatches, setMediaQueryMatches] = reactExports.useState({});
56688
- const fallbackBreakpointIndex = getFallbackBreakpointIndex(breakpoints);
56710
+ const [, initialMediaQueryMatches] = mediaQueryMatcher(breakpoints);
56711
+ const [mediaQueryMatches, setMediaQueryMatches] = reactExports.useState(initialMediaQueryMatches);
56689
56712
  // Register event listeners to update the media query states
56690
56713
  reactExports.useEffect(() => {
56691
- const [mediaQueryMatchers, initialMediaQueryMatches] = mediaQueryMatcher(breakpoints);
56692
- // Store the media query state in the beginning to initialise the state
56693
- setMediaQueryMatches(initialMediaQueryMatches);
56714
+ const [mediaQueryMatchers] = mediaQueryMatcher(breakpoints);
56694
56715
  const eventListeners = mediaQueryMatchers.map(({ id, signal }) => {
56695
56716
  const onChange = () => setMediaQueryMatches((prev) => ({
56696
56717
  ...prev,
@@ -56704,13 +56725,12 @@ const useBreakpoints = (breakpoints) => {
56704
56725
  mediaQueryMatchers[index].signal.removeEventListener('change', eventListener);
56705
56726
  });
56706
56727
  };
56707
- // Only re-setup all listeners when the breakpoint definition changed
56708
- // eslint-disable-next-line react-hooks/exhaustive-deps
56709
56728
  }, [breakpoints]);
56710
- const activeBreakpointIndex = getActiveBreakpointIndex(breakpoints, mediaQueryMatches, fallbackBreakpointIndex);
56711
56729
  const resolveDesignValue = reactExports.useCallback((valuesByBreakpoint, variableName) => {
56712
- return getValueForBreakpoint(valuesByBreakpoint, breakpoints, activeBreakpointIndex, variableName);
56713
- }, [activeBreakpointIndex, breakpoints]);
56730
+ const fallbackBreakpointIndex = getFallbackBreakpointIndex(breakpoints);
56731
+ const activeBreakpointIndex = getActiveBreakpointIndex(breakpoints, mediaQueryMatches, fallbackBreakpointIndex);
56732
+ return getValueForBreakpoint(valuesByBreakpoint, breakpoints, activeBreakpointIndex, fallbackBreakpointIndex, variableName);
56733
+ }, [mediaQueryMatches, breakpoints]);
56714
56734
  return { resolveDesignValue };
56715
56735
  };
56716
56736
 
@@ -58341,8 +58361,33 @@ const ComponentVariableSchema = z.object({
58341
58361
  });
58342
58362
  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
58343
58363
  ComponentVariableSchema);
58364
+ const THUMBNAIL_IDS = [
58365
+ 'columns',
58366
+ 'columnsPlusRight',
58367
+ 'imagesSquare',
58368
+ 'subtitles',
58369
+ 'rowsPlusBottom',
58370
+ 'userRectangle',
58371
+ 'textbox',
58372
+ 'monitorPlay',
58373
+ 'article',
58374
+ 'table',
58375
+ 'star',
58376
+ 'heartStraight',
58377
+ 'frameCorners',
58378
+ 'rows',
58379
+ 'dotsThreeOutline',
58380
+ 'listDashes',
58381
+ 'checkerBoard',
58382
+ 'gridFour',
58383
+ 'slideshow',
58384
+ 'diamondsFour',
58385
+ 'cards',
58386
+ 'textColumns',
58387
+ ];
58344
58388
  const ComponentSettingsSchema = z.object({
58345
58389
  variableDefinitions: ComponentVariablesSchema,
58390
+ thumbnailId: z.enum(THUMBNAIL_IDS).optional(),
58346
58391
  variableMappings: VariableMappingsSchema.optional(),
58347
58392
  patternPropertyDefinitions: PatternPropertyDefinitionsSchema.optional(),
58348
58393
  });
@@ -59455,7 +59500,7 @@ const useComponentProps = ({ node, areEntitiesFetched, resolveDesignValue, rende
59455
59500
  const [, uuid, path] = variableMapping.path.split('/');
59456
59501
  const binding = dataSource[uuid];
59457
59502
  const variableDefinition = definition.variables[variableName];
59458
- let boundValue = transformBoundContentValue(node.data.props, entityStore, binding, resolveDesignValue, variableName, variableDefinition, variableMapping.path);
59503
+ let boundValue = transformBoundContentValue(node.data.props, entityStore, binding, resolveDesignValue, variableName, variableDefinition.type, variableMapping.path);
59459
59504
  // In some cases, there may be an asset linked in the path, so we need to consider this scenario:
59460
59505
  // If no 'boundValue' is found, we also attempt to extract the value associated with the second-to-last item in the path.
59461
59506
  // If successful, it means we have identified the linked asset.
@@ -60253,7 +60298,7 @@ function useSingleColumn(node, resolveDesignValue) {
60253
60298
  return { isWrapped, wrapColumnsCount };
60254
60299
  }
60255
60300
  const parentNode = getItem({ id: node.parentId }, tree);
60256
- if (!parentNode) {
60301
+ if (!parentNode || parentNode.data.blockId !== CONTENTFUL_COMPONENTS$1.columns.id) {
60257
60302
  return { isWrapped, wrapColumnsCount };
60258
60303
  }
60259
60304
  const { cfWrapColumns, cfWrapColumnsCount } = parentNode.data.props;