@contentful/experiences-visual-editor-react 3.6.0 → 3.6.1-dev-20250904T1515-03d5e42.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
@@ -50152,6 +50152,15 @@ const maybeMergePatternDefaultDesignValues = ({ variableName, variableMapping, n
50152
50152
  return variableMapping.valuesByBreakpoint;
50153
50153
  };
50154
50154
 
50155
+ const checkIsNodeVisible = (node, resolveDesignValue) => {
50156
+ if (node.type === ASSEMBLY_NODE_TYPE || node.type === ROOT_ID) {
50157
+ // If this is a wrapping pattern/root with no visible children, it is invisible as well
50158
+ return node.children.some((childNode) => checkIsNodeVisible(childNode, resolveDesignValue));
50159
+ }
50160
+ // Check if the current node is visible (`cfVisibility` is enforced on all nodes)
50161
+ return !!resolveDesignValue(node.data.props['cfVisibility'].valuesByBreakpoint);
50162
+ };
50163
+
50155
50164
  const useComponentProps = ({ node, entityStore, areEntitiesFetched, resolveDesignValue, definition, options, }) => {
50156
50165
  const unboundValues = useEditorStore((state) => state.unboundValues);
50157
50166
  const hyperlinkPattern = useEditorStore((state) => state.hyperLinkPattern);
@@ -50292,7 +50301,8 @@ const useComponentProps = ({ node, entityStore, areEntitiesFetched, resolveDesig
50292
50301
  ...transformVisibility(props.cfVisibility),
50293
50302
  }), [props]);
50294
50303
  const shouldRenderEmptySpaceWithMinSize = reactExports.useMemo(() => {
50295
- if (node.children.length)
50304
+ const isAnyChildrenVisible = node.children.some((childNode) => checkIsNodeVisible(childNode, resolveDesignValue));
50305
+ if (isAnyChildrenVisible)
50296
50306
  return false;
50297
50307
  // Render with minimum height and with in those two scenarios:
50298
50308
  if (isStructureWithRelativeHeight(node.data.blockId, cfStyles.height))
@@ -50300,7 +50310,7 @@ const useComponentProps = ({ node, entityStore, areEntitiesFetched, resolveDesig
50300
50310
  if (definition?.children)
50301
50311
  return true;
50302
50312
  return false;
50303
- }, [cfStyles.height, definition?.children, node.children.length, node.data.blockId]);
50313
+ }, [cfStyles.height, definition?.children, node.children, node.data.blockId, resolveDesignValue]);
50304
50314
  // Styles that will be applied to the component element
50305
50315
  const componentStyles = reactExports.useMemo(() => ({
50306
50316
  ...cfStyles,
@@ -50321,7 +50331,8 @@ const useComponentProps = ({ node, entityStore, areEntitiesFetched, resolveDesig
50321
50331
  editorProps.isEditorMode = true;
50322
50332
  }
50323
50333
  if (options?.enableEditorProperties?.isEmpty) {
50324
- editorProps.isEmpty = node.children.length === 0;
50334
+ const areAllChildrenHidden = node.children.every((childNode) => !checkIsNodeVisible(childNode, resolveDesignValue));
50335
+ editorProps.isEmpty = node.children.length === 0 || areAllChildrenHidden;
50325
50336
  }
50326
50337
  if (options?.enableEditorProperties?.nodeBlockId) {
50327
50338
  editorProps.nodeBlockId = node.data.blockId;
@@ -50331,12 +50342,12 @@ const useComponentProps = ({ node, entityStore, areEntitiesFetched, resolveDesig
50331
50342
  }
50332
50343
  return editorProps;
50333
50344
  }, [
50334
- node.children.length,
50335
- node.data.blockId,
50336
50345
  options?.enableEditorProperties?.isEditorMode,
50337
50346
  options?.enableEditorProperties?.isEmpty,
50338
50347
  options?.enableEditorProperties?.nodeBlockId,
50339
50348
  options?.enableCustomEditorView,
50349
+ node,
50350
+ resolveDesignValue,
50340
50351
  ]);
50341
50352
  const componentProps = reactExports.useMemo(() => {
50342
50353
  const sharedProps = {
@@ -50608,7 +50619,8 @@ const RootRenderer = ({ inMemoryEntitiesStore, canvasMode }) => {
50608
50619
  const wrappingPatternIds = rootBlockId !== ROOT_ID ? new Set([rootBlockId]) : new Set();
50609
50620
  const entityStore = inMemoryEntitiesStore((state) => state.entityStore);
50610
50621
  const areEntitiesFetched = inMemoryEntitiesStore((state) => state.areEntitiesFetched);
50611
- return (React$1.createElement(React$1.Fragment, null, !tree.root.children.length ? (React$1.createElement(EmptyCanvasMessage, null)) : (tree.root.children.map((topLevelChildNode) => (React$1.createElement(EditorBlock, { key: topLevelChildNode.data.id, node: topLevelChildNode, resolveDesignValue: resolveDesignValue, wrappingPatternIds: wrappingPatternIds, entityStore: entityStore, areEntitiesFetched: areEntitiesFetched }))))));
50622
+ const isAnyNodeVisible = checkIsNodeVisible(tree.root, resolveDesignValue);
50623
+ return (React$1.createElement(React$1.Fragment, null, !isAnyNodeVisible ? (React$1.createElement(EmptyCanvasMessage, null)) : (tree.root.children.map((topLevelChildNode) => (React$1.createElement(EditorBlock, { key: topLevelChildNode.data.id, node: topLevelChildNode, resolveDesignValue: resolveDesignValue, wrappingPatternIds: wrappingPatternIds, entityStore: entityStore, areEntitiesFetched: areEntitiesFetched }))))));
50612
50624
  };
50613
50625
 
50614
50626
  const useInitializeEditor = (inMemoryEntitiesStore) => {