@contentful/experiences-visual-editor-react 3.3.1-dev-20250825T0713-34ae1b3.0 → 3.3.1-dev-20250825T1222-bc8206a.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
@@ -45615,6 +45615,27 @@ const tryParseMessage = (event) => {
45615
45615
  return eventData;
45616
45616
  };
45617
45617
 
45618
+ const splitDirectAndSlotChildren = (allChildNodes, componentDefinition) => {
45619
+ // Bridge difference between editor and delivery mode
45620
+ const getSlotId = (child) => {
45621
+ if ('data' in child)
45622
+ return child.data.slotId;
45623
+ return child.slotId;
45624
+ };
45625
+ const slotNodesMap = {};
45626
+ for (const slotId in componentDefinition.slots) {
45627
+ // We only allow one component per slot (container). This is just safer to not render components twice or not at all
45628
+ const nodes = allChildNodes.filter((child) => getSlotId(child) === slotId);
45629
+ slotNodesMap[slotId] = nodes.length ? nodes : null;
45630
+ }
45631
+ const directChildNodes = allChildNodes.filter((child) => getSlotId(child) === undefined);
45632
+ if (!componentDefinition.children || !directChildNodes.length) {
45633
+ // If there are no children allowed in the component or no children added, render as undefined
45634
+ return { slotNodesMap, directChildNodes: undefined };
45635
+ }
45636
+ return { slotNodesMap, directChildNodes };
45637
+ };
45638
+
45618
45639
  const sendMessage = (eventType, data) => {
45619
45640
  if (typeof window === 'undefined') {
45620
45641
  return;
@@ -50301,18 +50322,19 @@ function EditorBlock({ node, resolveDesignValue, wrappingPatternIds: parentWrapp
50301
50322
  if (isRootAssemblyNode && node.data.blockId && parentWrappingPatternIds.has(node.data.blockId)) {
50302
50323
  return React$1.createElement(CircularDependencyErrorPlaceholder, { wrappingPatternIds: wrappingPatternIds });
50303
50324
  }
50304
- const slotNodes = {};
50305
- for (const slotId in componentRegistration.definition.slots) {
50306
- const nodes = node.children.filter((child) => child.data.slotId === slotId);
50307
- slotNodes[slotId] =
50308
- nodes.length === 0 ? (React$1.createElement("div", { className: styles$1.emptySlot })) : (React$1.createElement(React$1.Fragment, null, nodes.map((slotChildNode) => (React$1.createElement(EditorBlock, { key: slotChildNode.data.id, node: slotChildNode, resolveDesignValue: resolveDesignValue, wrappingPatternIds: wrappingPatternIds, entityStore: entityStore, areEntitiesFetched: areEntitiesFetched })))));
50309
- }
50310
- const children = componentRegistration.definition.children
50311
- ? node.children
50312
- .filter((node) => node.data.slotId === undefined)
50313
- .map((childNode) => (React$1.createElement(EditorBlock, { key: childNode.data.id, node: childNode, resolveDesignValue: resolveDesignValue, wrappingPatternIds: wrappingPatternIds, entityStore: entityStore, areEntitiesFetched: areEntitiesFetched })))
50314
- : null;
50315
- return (React$1.createElement(RegistrationComponent, { node: node, resolveDesignValue: resolveDesignValue, componentRegistration: componentRegistration, slotNodes: slotNodes, entityStore: entityStore, areEntitiesFetched: areEntitiesFetched }, children));
50325
+ const { slotNodesMap, directChildNodes } = splitDirectAndSlotChildren(node.children, componentRegistration.definition);
50326
+ const renderChildNode = (childNode) => (React$1.createElement(EditorBlock, { key: childNode.data.id, node: childNode, resolveDesignValue: resolveDesignValue, wrappingPatternIds: wrappingPatternIds, entityStore: entityStore, areEntitiesFetched: areEntitiesFetched }));
50327
+ const renderedSlotNodesMap = Object.entries(slotNodesMap).reduce((acc, [slotId, nodes]) => {
50328
+ if (nodes?.length) {
50329
+ acc[slotId] = React$1.createElement(React$1.Fragment, null, nodes.map((slotChildNode) => renderChildNode(slotChildNode)));
50330
+ }
50331
+ else {
50332
+ acc[slotId] = React$1.createElement("div", { className: styles$1.emptySlot });
50333
+ }
50334
+ return acc;
50335
+ }, {});
50336
+ const renderedChildren = directChildNodes?.map((childNode) => renderChildNode(childNode));
50337
+ return (React$1.createElement(RegistrationComponent, { node: node, resolveDesignValue: resolveDesignValue, componentRegistration: componentRegistration, slotNodes: renderedSlotNodesMap, entityStore: entityStore, areEntitiesFetched: areEntitiesFetched }, renderedChildren));
50316
50338
  }
50317
50339
  const RegistrationComponent = ({ node, resolveDesignValue, componentRegistration, slotNodes, children, entityStore, areEntitiesFetched, }) => {
50318
50340
  const { componentProps } = useComponentProps({