@contentstack/studio-react-editor 1.9.0 → 1.11.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.
Files changed (36) hide show
  1. package/dist/components/EditableRenderer.js +2 -1
  2. package/dist/components/EditableRenderer.js.map +1 -1
  3. package/dist/components/Element.js +35 -32
  4. package/dist/components/Element.js.map +1 -1
  5. package/dist/components/PermanentDropZone.js +77 -0
  6. package/dist/components/PermanentDropZone.js.map +1 -0
  7. package/dist/components/WelcomeState.js +1 -1
  8. package/dist/components/elements/SectionComposition.js +2 -1
  9. package/dist/components/elements/SectionComposition.js.map +1 -1
  10. package/dist/components/elements/SectionSlot.js +16 -50
  11. package/dist/components/elements/SectionSlot.js.map +1 -1
  12. package/dist/components/styles.js +76 -52
  13. package/dist/components/styles.js.map +1 -1
  14. package/dist/contexts/providers/edit-context.provider.js +2 -2
  15. package/dist/contexts/providers/edit-context.provider.js.map +1 -1
  16. package/dist/hooks/use-active-node-path.hook.js +1 -1
  17. package/dist/hooks/use-active-node-path.hook.js.map +1 -1
  18. package/dist/hooks/use-can-show-permanent-drop-zones.hook.js +20 -0
  19. package/dist/hooks/use-can-show-permanent-drop-zones.hook.js.map +1 -0
  20. package/dist/hooks/use-canvas-events.hook.js +2 -1
  21. package/dist/hooks/use-canvas-events.hook.js.map +1 -1
  22. package/dist/hooks/use-edit-context-listener.hook.js +2 -1
  23. package/dist/hooks/use-edit-context-listener.hook.js.map +1 -1
  24. package/dist/hooks/use-section-events.hook.js +2 -1
  25. package/dist/hooks/use-section-events.hook.js.map +1 -1
  26. package/dist/hooks/use-should-show-design.hook.js +47 -35
  27. package/dist/hooks/use-should-show-design.hook.js.map +1 -1
  28. package/dist/hooks/use-slot-copy-color.hook.js +13 -10
  29. package/dist/hooks/use-slot-copy-color.hook.js.map +1 -1
  30. package/dist/hooks/use-spec-data-listener.hook.js +39 -29
  31. package/dist/hooks/use-spec-data-listener.hook.js.map +1 -1
  32. package/dist/hooks/use-static-values-listener.hook.js +10 -2
  33. package/dist/hooks/use-static-values-listener.hook.js.map +1 -1
  34. package/dist/utils/renderer.util.js +105 -35
  35. package/dist/utils/renderer.util.js.map +1 -1
  36. package/package.json +8 -8
@@ -1,6 +1,7 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
2
  import { isCompositionBeingEdited, clientRendererModeUtil, NODE_TO_PARENT, NODE_TO_PATH_NODE } from '@contentstack/studio-client';
3
- import { composableStudioEventManager, POST_MESSAGE_EVENTS } from '@contentstack/studio-messenger';
3
+ import { POST_MESSAGE_EVENTS } from '@contentstack/studio-messenger/constants';
4
+ import { composableStudioEventManager } from '@contentstack/studio-messenger';
4
5
  import { DataCtxProvider, SectionScopedDataCtxProvider } from '@contentstack/studio-react-components/contexts';
5
6
  import { useDataWithSpec, useSectionScopedDataFromSpec } from '@contentstack/studio-react-components/hooks';
6
7
  import { SectionCompositionProvider } from '@contentstack/studio-react-components/basic-components';
@@ -1 +1 @@
1
- {"version":3,"file":"EditableRenderer.js","sources":["../../src/components/EditableRenderer.tsx"],"sourcesContent":["import {\n StudioSpec,\n isCompositionBeingEdited,\n clientRendererModeUtil,\n NODE_TO_PARENT,\n NODE_TO_PATH_NODE,\n} from \"@contentstack/studio-client\";\nimport {\n composableStudioEventManager,\n POST_MESSAGE_EVENTS,\n} from \"@contentstack/studio-messenger\";\nimport {\n DataCtxProvider,\n SectionScopedDataCtxProvider,\n} from \"@contentstack/studio-react-components/contexts\";\nimport {\n useDataWithSpec,\n useSectionScopedDataFromSpec,\n} from \"@contentstack/studio-react-components/hooks\";\nimport { SectionCompositionProvider } from \"@contentstack/studio-react-components/basic-components\";\nimport {\n ComposableStudioData,\n INTERNAL_COMPONENTS_NAMES,\n} from \"@contentstack/studio-registry\";\nimport { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { ActiveComponentPathContext } from \"../contexts/providers/active-node.provider\";\nimport { EditContextProvider } from \"../contexts/providers/edit-context.provider\";\nimport { RendererProvider } from \"../contexts/providers/renderer.provider\";\nimport { useCanvasEvents } from \"../hooks/use-canvas-events.hook\";\nimport { useEditContextListener } from \"../hooks/use-edit-context-listener.hook\";\nimport { useGetActiveComponentPathContext } from \"../hooks/use-active-node-path.hook\";\nimport { useSectionEvents } from \"../hooks/use-section-events.hook\";\nimport { useSpecDataListener } from \"../hooks/use-spec-data-listener.hook\";\nimport { useRegisterSectionComponents } from \"../hooks/use-register-section.hook\";\nimport { useStaticValuesListener } from \"../hooks/use-static-values-listener.hook\";\nimport { ComponentRegistryType } from \"../types\";\nimport Element from \"./Element\";\nimport { RenderErrorHOC } from \"./RenderErrorHOC\";\nimport { ConditionBlock, Repeater, SectionSlot } from \"./elements\";\n\ninterface EditableRendererHOCProps {\n spec: StudioSpec;\n data: ComposableStudioData;\n componentRegistry: ComponentRegistryType;\n renderError: (props: { error: Error }) => JSX.Element;\n}\n\nexport default function EditableRendererHOC(\n props: EditableRendererHOCProps & { children: React.ReactNode },\n) {\n const { spec, componentRegistry } = props;\n return (\n <RendererProvider spec={spec} componentRegistry={componentRegistry}>\n <EditableRenderer {...props} />\n </RendererProvider>\n );\n}\n\ninterface EditableRendererProps {\n spec: StudioSpec;\n data: ComposableStudioData;\n componentRegistry: ComponentRegistryType;\n renderError: (props: { error: Error }) => JSX.Element;\n}\n\nfunction EditableRenderer({\n spec: initialSpec,\n data: stateData,\n componentRegistry,\n renderError,\n}: EditableRendererProps): JSX.Element {\n const [spec, setSpec] = useState<StudioSpec>(initialSpec);\n const composableUid = spec?.compositionEntry?.composable_uid ?? \"\";\n const isCompositionEdited = isCompositionBeingEdited(composableUid);\n useCanvasEvents(composableUid);\n useSpecDataListener(setSpec, spec, composableUid);\n const { dataStepMode } = useEditContextListener(composableUid);\n useStaticValuesListener(setSpec, spec, composableUid);\n useSectionEvents(setSpec, spec, composableUid);\n useRegisterSectionComponents(spec.sectionCompositions || []);\n // Swap basic (preview-only) Repeater/ConditionBlock with their\n // editor-aware versions BEFORE the first render. Doing this in useEffect\n // would let the basic Repeater render once (iterating items + injecting\n // `dataSources.repeater[uid].context`) before being replaced — visible\n // as a one-frame flicker for sections inside the Repeater whose scope\n // jumps from REPEATER_ITEM to the design-mode passthrough.\n // useMemo runs during the render phase, so the registry is updated before\n // any child component renders.\n useMemo(() => {\n componentRegistry.updateComponents([\n {\n type: INTERNAL_COMPONENTS_NAMES.REPEATER,\n component: Repeater,\n },\n {\n type: INTERNAL_COMPONENTS_NAMES.CONDITION_BLOCK,\n component: ConditionBlock,\n },\n {\n type: INTERNAL_COMPONENTS_NAMES.SECTION_SLOT,\n component: SectionSlot,\n },\n ]);\n return null;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const data: ComposableStudioData = useDataWithSpec(spec, stateData);\n const sectionScoped = useSectionScopedDataFromSpec(spec);\n const activeComponentPathContext = useGetActiveComponentPathContext(spec);\n\n useEffect(() => {\n // 🎯 STUDIO CONTEXT CHECK: Only send postMessage when inside Studio, not standalone\n const shouldSendStudioEvents =\n isCompositionEdited && clientRendererModeUtil.isInsideStudioFrame();\n if (!shouldSendStudioEvents) return;\n\n composableStudioEventManager\n ?.send(POST_MESSAGE_EVENTS.GET_COMPONENT_PROPS, data)\n .catch((error: any) => {\n console.error(\"Error while setting component props.\", error);\n });\n }, [data, isCompositionEdited]);\n\n // * When we render the components, we set the parent and path for the nodes,\n // * However, the root node and the page node are not set during the render.\n // * Hence, we set the parent and path for the root and page node here.\n useMemo(() => {\n if (!spec || !isCompositionEdited) return;\n const rootNode = spec.ui;\n if (!rootNode || !rootNode.slots) return;\n\n const rootSlotUid = Object.keys(rootNode.slots)[0];\n if (!rootSlotUid || !rootNode.slots[rootSlotUid]) return;\n\n const pageNode = rootNode.slots[rootSlotUid][0];\n if (!pageNode) return;\n\n NODE_TO_PARENT.set(rootNode, undefined);\n NODE_TO_PARENT.set(pageNode, rootNode);\n NODE_TO_PATH_NODE.set(pageNode, [rootSlotUid, 0]);\n }, [spec, isCompositionEdited]);\n const renderErrorComponent = useCallback(({ error }: { error: Error }) => {\n return <RenderErrorHOC error={error} renderError={renderError} />;\n }, []);\n\n const isSection = spec.compositionEntry?.place_composition_as === \"section\";\n const compositionUid = spec.compositionEntry?.uid;\n\n return (\n <ActiveComponentPathContext.Provider value={activeComponentPathContext}>\n <EditContextProvider value={{ dataStepMode }}>\n <DataCtxProvider value={data}>\n <SectionScopedDataCtxProvider value={sectionScoped}>\n {isSection && compositionUid ? (\n <SectionCompositionProvider uid={compositionUid}>\n <Element node={spec.ui} renderError={renderErrorComponent} />\n </SectionCompositionProvider>\n ) : (\n <Element node={spec.ui} renderError={renderErrorComponent} />\n )}\n </SectionScopedDataCtxProvider>\n </DataCtxProvider>\n </EditContextProvider>\n </ActiveComponentPathContext.Provider>\n );\n}\n"],"names":["_jsx","Element"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA+Cc,SAAU,mBAAmB,CACzC,KAA+D,EAAA;AAE/D,IAAA,MAAM,EAAE,IAAI,EAAE,iBAAiB,EAAE,GAAG,KAAK;AACzC,IAAA,QACEA,GAAA,CAAC,gBAAgB,IAAC,IAAI,EAAE,IAAI,EAAE,iBAAiB,EAAE,iBAAiB,EAAA,QAAA,EAChEA,IAAC,gBAAgB,EAAA,EAAA,GAAK,KAAK,EAAA,CAAI,EAAA,CACd;AAEvB;AASA,SAAS,gBAAgB,CAAC,EACxB,IAAI,EAAE,WAAW,EACjB,IAAI,EAAE,SAAS,EACf,iBAAiB,EACjB,WAAW,GACW,EAAA;IACtB,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAa,WAAW,CAAC;IACzD,MAAM,aAAa,GAAG,IAAI,EAAE,gBAAgB,EAAE,cAAc,IAAI,EAAE;AAClE,IAAA,MAAM,mBAAmB,GAAG,wBAAwB,CAAC,aAAa,CAAC;IACnE,eAAe,CAAC,aAAa,CAAC;AAC9B,IAAA,mBAAmB,CAAC,OAAO,EAAE,IAAI,EAAE,aAAa,CAAC;IACjD,MAAM,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AA,EAAC,KAAK,EAAE,EAAE,YAAY,EAAE,EAAA,QAAA,EAC1CA,GAAA,CAAC,eAAe,EAAA,EAAC,KAAK,EAAE,IAAI,YAC1BA,GAAA,CAAC,4BAA4B,IAAC,KAAK,EAAE,aAAa,EAAA,QAAA,EAC/C,SAAS,IAAI,cAAc,IAC1BA,GAAA,CAAC,0BAA0B,EAAA,EAAC,GAAG,EAAE,cAAc,EAAA,QAAA,EAC7CA,IAACC,eAAO,EAAA,EAAC,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,WAAW,EAAE,oBAAoB,EAAA,CAAI,EAAA,CAClC,KAE7BD,IAACC,eAAO,EAAA,EAAC,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,WAAW,EAAE,oBAAoB,GAAI,CAC9D,EAAA,CAC4B,GACf,EAAA,CACE,EAAA,CACc;AAE1C;;;;"}
1
+ {"version":3,"file":"EditableRenderer.js","sources":["../../src/components/EditableRenderer.tsx"],"sourcesContent":["import {\n StudioSpec,\n isCompositionBeingEdited,\n clientRendererModeUtil,\n NODE_TO_PARENT,\n NODE_TO_PATH_NODE,\n} from \"@contentstack/studio-client\";\nimport { POST_MESSAGE_EVENTS } from \"@contentstack/studio-messenger/constants\";\nimport { composableStudioEventManager } from \"@contentstack/studio-messenger\";\nimport {\n DataCtxProvider,\n SectionScopedDataCtxProvider,\n} from \"@contentstack/studio-react-components/contexts\";\nimport {\n useDataWithSpec,\n useSectionScopedDataFromSpec,\n} from \"@contentstack/studio-react-components/hooks\";\nimport { SectionCompositionProvider } from \"@contentstack/studio-react-components/basic-components\";\nimport {\n ComposableStudioData,\n INTERNAL_COMPONENTS_NAMES,\n} from \"@contentstack/studio-registry\";\nimport { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { ActiveComponentPathContext } from \"../contexts/providers/active-node.provider\";\nimport { EditContextProvider } from \"../contexts/providers/edit-context.provider\";\nimport { RendererProvider } from \"../contexts/providers/renderer.provider\";\nimport { useCanvasEvents } from \"../hooks/use-canvas-events.hook\";\nimport { useEditContextListener } from \"../hooks/use-edit-context-listener.hook\";\nimport { useGetActiveComponentPathContext } from \"../hooks/use-active-node-path.hook\";\nimport { useSectionEvents } from \"../hooks/use-section-events.hook\";\nimport { useSpecDataListener } from \"../hooks/use-spec-data-listener.hook\";\nimport { useRegisterSectionComponents } from \"../hooks/use-register-section.hook\";\nimport { useStaticValuesListener } from \"../hooks/use-static-values-listener.hook\";\nimport { ComponentRegistryType } from \"../types\";\nimport Element from \"./Element\";\nimport { RenderErrorHOC } from \"./RenderErrorHOC\";\nimport { ConditionBlock, Repeater, SectionSlot } from \"./elements\";\n\ninterface EditableRendererHOCProps {\n spec: StudioSpec;\n data: ComposableStudioData;\n componentRegistry: ComponentRegistryType;\n renderError: (props: { error: Error }) => JSX.Element;\n}\n\nexport default function EditableRendererHOC(\n props: EditableRendererHOCProps & { children: React.ReactNode },\n) {\n const { spec, componentRegistry } = props;\n return (\n <RendererProvider spec={spec} componentRegistry={componentRegistry}>\n <EditableRenderer {...props} />\n </RendererProvider>\n );\n}\n\ninterface EditableRendererProps {\n spec: StudioSpec;\n data: ComposableStudioData;\n componentRegistry: ComponentRegistryType;\n renderError: (props: { error: Error }) => JSX.Element;\n}\n\nfunction EditableRenderer({\n spec: initialSpec,\n data: stateData,\n componentRegistry,\n renderError,\n}: EditableRendererProps): JSX.Element {\n const [spec, setSpec] = useState<StudioSpec>(initialSpec);\n const composableUid = spec?.compositionEntry?.composable_uid ?? \"\";\n const isCompositionEdited = isCompositionBeingEdited(composableUid);\n useCanvasEvents(composableUid);\n useSpecDataListener(setSpec, spec, composableUid);\n const { dataStepMode } = useEditContextListener(composableUid);\n useStaticValuesListener(setSpec, spec, composableUid);\n useSectionEvents(setSpec, spec, composableUid);\n useRegisterSectionComponents(spec.sectionCompositions || []);\n // Swap basic (preview-only) Repeater/ConditionBlock with their\n // editor-aware versions BEFORE the first render. Doing this in useEffect\n // would let the basic Repeater render once (iterating items + injecting\n // `dataSources.repeater[uid].context`) before being replaced — visible\n // as a one-frame flicker for sections inside the Repeater whose scope\n // jumps from REPEATER_ITEM to the design-mode passthrough.\n // useMemo runs during the render phase, so the registry is updated before\n // any child component renders.\n useMemo(() => {\n componentRegistry.updateComponents([\n {\n type: INTERNAL_COMPONENTS_NAMES.REPEATER,\n component: Repeater,\n },\n {\n type: INTERNAL_COMPONENTS_NAMES.CONDITION_BLOCK,\n component: ConditionBlock,\n },\n {\n type: INTERNAL_COMPONENTS_NAMES.SECTION_SLOT,\n component: SectionSlot,\n },\n ]);\n return null;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const data: ComposableStudioData = useDataWithSpec(spec, stateData);\n const sectionScoped = useSectionScopedDataFromSpec(spec);\n const activeComponentPathContext = useGetActiveComponentPathContext(spec);\n\n useEffect(() => {\n // 🎯 STUDIO CONTEXT CHECK: Only send postMessage when inside Studio, not standalone\n const shouldSendStudioEvents =\n isCompositionEdited && clientRendererModeUtil.isInsideStudioFrame();\n if (!shouldSendStudioEvents) return;\n\n composableStudioEventManager\n ?.send(POST_MESSAGE_EVENTS.GET_COMPONENT_PROPS, data)\n .catch((error: any) => {\n console.error(\"Error while setting component props.\", error);\n });\n }, [data, isCompositionEdited]);\n\n // * When we render the components, we set the parent and path for the nodes,\n // * However, the root node and the page node are not set during the render.\n // * Hence, we set the parent and path for the root and page node here.\n useMemo(() => {\n if (!spec || !isCompositionEdited) return;\n const rootNode = spec.ui;\n if (!rootNode || !rootNode.slots) return;\n\n const rootSlotUid = Object.keys(rootNode.slots)[0];\n if (!rootSlotUid || !rootNode.slots[rootSlotUid]) return;\n\n const pageNode = rootNode.slots[rootSlotUid][0];\n if (!pageNode) return;\n\n NODE_TO_PARENT.set(rootNode, undefined);\n NODE_TO_PARENT.set(pageNode, rootNode);\n NODE_TO_PATH_NODE.set(pageNode, [rootSlotUid, 0]);\n }, [spec, isCompositionEdited]);\n const renderErrorComponent = useCallback(({ error }: { error: Error }) => {\n return <RenderErrorHOC error={error} renderError={renderError} />;\n }, []);\n\n const isSection = spec.compositionEntry?.place_composition_as === \"section\";\n const compositionUid = spec.compositionEntry?.uid;\n\n return (\n <ActiveComponentPathContext.Provider value={activeComponentPathContext}>\n <EditContextProvider value={{ dataStepMode }}>\n <DataCtxProvider value={data}>\n <SectionScopedDataCtxProvider value={sectionScoped}>\n {isSection && compositionUid ? (\n <SectionCompositionProvider uid={compositionUid}>\n <Element node={spec.ui} renderError={renderErrorComponent} />\n </SectionCompositionProvider>\n ) : (\n <Element node={spec.ui} renderError={renderErrorComponent} />\n )}\n </SectionScopedDataCtxProvider>\n </DataCtxProvider>\n </EditContextProvider>\n </ActiveComponentPathContext.Provider>\n );\n}\n"],"names":["_jsx","Element"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA6Cc,SAAU,mBAAmB,CACzC,KAA+D,EAAA;AAE/D,IAAA,MAAM,EAAE,IAAI,EAAE,iBAAiB,EAAE,GAAG,KAAK;AACzC,IAAA,QACEA,GAAA,CAAC,gBAAgB,IAAC,IAAI,EAAE,IAAI,EAAE,iBAAiB,EAAE,iBAAiB,EAAA,QAAA,EAChEA,IAAC,gBAAgB,EAAA,EAAA,GAAK,KAAK,EAAA,CAAI,EAAA,CACd;AAEvB;AASA,SAAS,gBAAgB,CAAC,EACxB,IAAI,EAAE,WAAW,EACjB,IAAI,EAAE,SAAS,EACf,iBAAiB,EACjB,WAAW,GACW,EAAA;IACtB,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAa,WAAW,CAAC;IACzD,MAAM,aAAa,GAAG,IAAI,EAAE,gBAAgB,EAAE,cAAc,IAAI,EAAE;AAClE,IAAA,MAAM,mBAAmB,GAAG,wBAAwB,CAAC,aAAa,CAAC;IACnE,eAAe,CAAC,aAAa,CAAC;AAC9B,IAAA,mBAAmB,CAAC,OAAO,EAAE,IAAI,EAAE,aAAa,CAAC;IACjD,MAAM,EAAE,YAAY,EAAE,GAAG,sBAAsB,CAAC,aAAa,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,QAAA,EAC1CA,GAAA,CAAC,eAAe,EAAA,EAAC,KAAK,EAAE,IAAI,YAC1BA,GAAA,CAAC,4BAA4B,IAAC,KAAK,EAAE,aAAa,EAAA,QAAA,EAC/C,SAAS,IAAI,cAAc,IAC1BA,GAAA,CAAC,0BAA0B,EAAA,EAAC,GAAG,EAAE,cAAc,EAAA,QAAA,EAC7CA,IAACC,eAAO,EAAA,EAAC,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,WAAW,EAAE,oBAAoB,EAAA,CAAI,EAAA,CAClC,KAE7BD,IAACC,eAAO,EAAA,EAAC,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,WAAW,EAAE,oBAAoB,GAAI,CAC9D,EAAA,CAC4B,GACf,EAAA,CACE,EAAA,CACc;AAE1C;;;;"}
@@ -1,7 +1,7 @@
1
- import { jsx, Fragment } from 'react/jsx-runtime';
1
+ import { jsx } from 'react/jsx-runtime';
2
2
  import { ELEMENT_TO_NODE, NODE_TO_ELEMENT, NODE_TO_PATH_NODE, NODE_TO_PARENT, COMPOSABLE_DATA_ATTRIBUTES, composableStudioEventEmitter, COMPOSABLE_STUDIO_EMITTED_EVENTS, loadGoogleFont, getJSONRTE } from '@contentstack/studio-client';
3
3
  import { handleNodeStyles, lightSdk, sdk } from '@contentstack/studio-core';
4
- import { CurrentNodeContext, SectionInstanceSlotsCtxProvider } from '@contentstack/studio-react-components/contexts';
4
+ import { CurrentNodeContext } from '@contentstack/studio-react-components/contexts';
5
5
  import { useCurrentNode, useData, useNodeStateBindings, useNodeBoundFunctionName } from '@contentstack/studio-react-components/hooks';
6
6
  import { INTERNAL_COMPONENTS_NAMES, resolveMetadataBindings, clearReportedBindingErrorsForNode, getRepeaterBinding, getBindingString, getCslpTag, wrapActionProps, retrievePropValue, callStudioFunction } from '@contentstack/studio-registry';
7
7
  import classNames from 'classnames';
@@ -9,13 +9,15 @@ import { memo, useMemo, useCallback, useRef, useEffect } from 'react';
9
9
  import { RendererErrorComponent } from './ErrorComponent.js';
10
10
  import { TextPlaceholder } from './TextPlaceholder.js';
11
11
  import { RendererErrorBoundary } from './RendererErrorBoundary.js';
12
- import { shouldRenderSlot, getSlotHint } from '../utils/renderer.util.js';
12
+ import { shouldRenderSlot, getConditionWellHint, getSlotHint } from '../utils/renderer.util.js';
13
13
  import Slot from './Slot.js';
14
+ import { SlotChildrenWithPermanentDropZones } from './PermanentDropZone.js';
14
15
  import { usePreviewMode } from '../hooks/use-preview-mode.hook.js';
15
16
  import { useRenderer } from '../hooks/use-renderer.hook.js';
16
17
  import { SelectedNodeProvider } from '../contexts/providers/selected-node.provider.js';
18
+ import { NodeComponent } from '@contentstack/studio-react-components/basic-components';
17
19
 
18
- const Element = ({ node, renderError, dataCslp, }) => {
20
+ const Element = ({ node, renderError, dataCslp, wellHint, }) => {
19
21
  const isPreviewMode = usePreviewMode();
20
22
  const pageData = useData();
21
23
  // Canvas parity with the production renderer's BaseElement: declared state
@@ -185,7 +187,7 @@ const Element = ({ node, renderError, dataCslp, }) => {
185
187
  nodeUid: uid,
186
188
  jsonRTE: getJSONRTE(),
187
189
  getSlots({ slots, parent, slotUid }) {
188
- return (jsx(VisualComponent, { parent: parent, nodes: slots, slotUid: slotUid, renderError: renderError }));
190
+ return (jsx(VisualComponent, { parent: parent, nodes: slots, slotUid: slotUid, renderError: renderError, wellHint: wellHint }));
189
191
  },
190
192
  isCompositionBeingEdited,
191
193
  }));
@@ -218,16 +220,15 @@ const Element = ({ node, renderError, dataCslp, }) => {
218
220
  // under the page's data context — so bindings authored on the dropped
219
221
  // components resolve against the page's preview entry / additional
220
222
  // entries / queries as if the components were on the page directly.
221
- const wrapWithSectionInstanceCtx = (children) => node.type === "section-composition" ? (jsx(SectionInstanceSlotsCtxProvider, { value: {
223
+ const sectionInstance = node.type === "section-composition"
224
+ ? {
222
225
  sectionInstanceUid: uid,
223
226
  sectionNode: node,
224
227
  slotsMap: (node.slots ?? {}),
225
228
  pageOuterData: data,
226
- }, children: children })) : (children);
227
- if (componentOptions.wrap) {
228
- return (jsx(RendererErrorBoundary, { renderError: renderError, children: jsx(WrapTag, { ...internalAttributes, children: wrapWithSectionInstanceCtx(jsx(Component, { ...attrsWithResponsiveClass, ...resolvedProps })) }) }));
229
- }
230
- return (jsx(RendererErrorBoundary, { renderError: renderError, children: wrapWithSectionInstanceCtx(jsx(Component, { studioAttributes: internalAttributes, ...attrsWithResponsiveClass, ...resolvedProps })) }));
229
+ }
230
+ : undefined;
231
+ return (jsx(RendererErrorBoundary, { renderError: renderError, children: jsx(NodeComponent, { Component: Component, props: { ...attrsWithResponsiveClass, ...resolvedProps }, wrapTag: componentOptions.wrap ? WrapTag : undefined, wrapAttributes: componentOptions.wrap ? internalAttributes : undefined, studioAttributes: componentOptions.wrap ? undefined : internalAttributes, sectionInstance: sectionInstance }) }));
231
232
  }
232
233
  catch (error) {
233
234
  if (error instanceof Error) {
@@ -240,7 +241,8 @@ const Element = ({ node, renderError, dataCslp, }) => {
240
241
  const MemoizedElement = memo(Element, (prev, next) => {
241
242
  const isSame = prev.node === next.node &&
242
243
  prev.dataCslp === next.dataCslp &&
243
- prev.renderError === next.renderError;
244
+ prev.renderError === next.renderError &&
245
+ prev.wellHint === next.wellHint;
244
246
  return isSame;
245
247
  });
246
248
  /**
@@ -268,13 +270,13 @@ const EMPTY_NODE_PATH = [];
268
270
  * change and re-renders, so its path context and `useIsNodeSelected` stay
269
271
  * correct, while genuinely untouched siblings skip.
270
272
  */
271
- const SlotChild = memo(({ node, slotUid, slotIndex, parentNodePath, renderError, dataCslp, }) => {
273
+ const SlotChild = memo(({ node, slotUid, slotIndex, parentNodePath, renderError, dataCslp, wellHint, }) => {
272
274
  const currentNodePath = useMemo(() => [...parentNodePath, [slotUid, slotIndex]], [parentNodePath, slotUid, slotIndex]);
273
275
  const currentNode = useMemo(() => ({ currentNodeUid: node.uid, currentNodePath }), [node.uid, currentNodePath]);
274
- return (jsx(CurrentNodeContext.Provider, { value: currentNode, children: jsx(SelectedNodeProvider, { children: jsx(MemoizedElement, { node: node, renderError: renderError, dataCslp: dataCslp }) }) }));
276
+ return (jsx(CurrentNodeContext.Provider, { value: currentNode, children: jsx(SelectedNodeProvider, { children: jsx(MemoizedElement, { node: node, renderError: renderError, dataCslp: dataCslp, wellHint: wellHint }) }) }));
275
277
  });
276
278
  SlotChild.displayName = "SlotChild";
277
- const VisualComponent = memo(({ parent, nodes, slotUid, renderError, dataCslp = "", }) => {
279
+ const VisualComponent = memo(({ parent, nodes, slotUid, renderError, dataCslp = "", wellHint, }) => {
278
280
  const { uid } = parent;
279
281
  const isPreviewMode = usePreviewMode();
280
282
  const { isCompositionBeingEdited, componentRegistry, compositionPlacement, } = useRenderer();
@@ -298,24 +300,25 @@ const VisualComponent = memo(({ parent, nodes, slotUid, renderError, dataCslp =
298
300
  }
299
301
  }, [parent]);
300
302
  if (!shouldRenderSlot(componentRegistry, parent, nodes, isCompositionBeingEdited)) {
301
- const children = nodes?.map((node, idx) => {
302
- const key = node.uid;
303
- // Stays in the parent's loop rather than moving into SlotChild: these run
304
- // for EVERY child including hidden ones, which are never rendered at all.
305
- if (isCompositionBeingEdited) {
306
- NODE_TO_PATH_NODE.set(node, [slotUid, idx]);
307
- NODE_TO_PARENT.set(node, parent);
308
- }
309
- if (node.metadata.visible === false) {
310
- return;
311
- }
312
- return (jsx(SlotChild, { node: node, slotUid: slotUid, slotIndex: idx, parentNodePath: parentNodePath, renderError: renderError, dataCslp: dataCslp }, key));
313
- });
314
- return jsx(Fragment, { children: children });
303
+ return (jsx(SlotChildrenWithPermanentDropZones, { slotOwner: parent, slotChildren: nodes, renderSlotChild: (node, idx) => {
304
+ // Stays in the parent's loop rather than moving into SlotChild:
305
+ // these run for EVERY child including hidden ones, which are never
306
+ // rendered at all.
307
+ if (isCompositionBeingEdited) {
308
+ NODE_TO_PATH_NODE.set(node, [slotUid, idx]);
309
+ NODE_TO_PARENT.set(node, parent);
310
+ }
311
+ if (node.metadata.visible === false) {
312
+ return null;
313
+ }
314
+ return (jsx(SlotChild, { node: node, slotUid: slotUid, slotIndex: idx, parentNodePath: parentNodePath, renderError: renderError, dataCslp: dataCslp, wellHint: getConditionWellHint(parent, node) }));
315
+ } }));
315
316
  }
316
- // Placeholder text for this empty slot: the repeater advice, or the condition
317
- // hint when this slot is a condition block's drop well. See `getSlotHint`.
318
- const hint = getSlotHint(parent);
317
+ // Placeholder text for this empty slot: the repeater advice, the condition
318
+ // hint when this slot is a condition block's own, or the hint the block
319
+ // handed down when this slot is its drop well. See `getSlotHint` and
320
+ // `getConditionWellHint`.
321
+ const hint = getSlotHint(parent) ?? wellHint;
319
322
  // Detect if this is a page slot for welcome message
320
323
  const isPageSlot = parent.type === INTERNAL_COMPONENTS_NAMES.PAGE;
321
324
  if (!isCompositionBeingEdited || isPreviewMode) {
@@ -1 +1 @@
1
- {"version":3,"file":"Element.js","sources":["../../src/components/Element.tsx"],"sourcesContent":["import {\n COMPOSABLE_DATA_ATTRIBUTES,\n COMPOSABLE_STUDIO_EMITTED_EVENTS,\n composableStudioEventEmitter,\n ELEMENT_TO_NODE,\n getJSONRTE,\n loadGoogleFont,\n NODE_TO_ELEMENT,\n NODE_TO_PARENT,\n NODE_TO_PATH_NODE,\n} from \"@contentstack/studio-client\";\nimport { lightSdk, sdk, handleNodeStyles } from \"@contentstack/studio-core\";\nimport { Node, Path, SlotUid } from \"@contentstack/studio-internal\";\nimport { HiddenElementNotificationEventData } from \"@contentstack/studio-messenger\";\nimport {\n CurrentNodeContext,\n SectionInstanceSlotsCtxProvider,\n} from \"@contentstack/studio-react-components/contexts\";\nimport {\n useCurrentNode,\n useData,\n useNodeStateBindings,\n useNodeBoundFunctionName,\n} from \"@contentstack/studio-react-components/hooks\";\nimport {\n clearReportedBindingErrorsForNode,\n getBindingString,\n getCslpTag,\n getRepeaterBinding,\n GetSlotsParams,\n resolveMetadataBindings,\n retrievePropValue,\n wrapActionProps,\n callStudioFunction,\n INTERNAL_COMPONENTS_NAMES,\n ComponentRegistry,\n} from \"@contentstack/studio-registry\";\nimport classNames from \"classnames\";\nimport {\n memo,\n ReactNode,\n RefCallback,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n} from \"react\";\nimport { BuilderNodeInternalAttributes, StudioComponentRef } from \"../types\";\nimport { RendererErrorComponent } from \"./ErrorComponent\";\nimport { TextPlaceholder } from \"./TextPlaceholder\";\nimport { RendererErrorBoundary } from \"./RendererErrorBoundary\";\nimport { getSlotHint, shouldRenderSlot } from \"../utils\";\nimport Slot from \"./Slot\";\nimport { usePreviewMode } from \"../hooks/use-preview-mode.hook\";\nimport { useRenderer } from \"../hooks/use-renderer.hook\";\nimport { SelectedNodeProvider } from \"../contexts/providers/selected-node.provider\";\n\nconst Element = ({\n node,\n renderError,\n dataCslp,\n}: {\n node: Node;\n renderError?: React.ComponentType<{ error: Error }>;\n dataCslp?: string;\n}): React.ReactNode => {\n const isPreviewMode = usePreviewMode();\n const pageData = useData();\n\n // Canvas parity with the production renderer's BaseElement: declared state\n // variables bound via component_props resolve from the shared BYOS state\n // store. Per-node subscription — only this node re-renders when one of ITS\n // bound state keys changes.\n const stateSnapshot = useNodeStateBindings(node);\n // Behavior assignment (BYOS): reactive — re-reads when the app registers\n // functions (commonly after this node's first render).\n const boundFunctionName = useNodeBoundFunctionName(node);\n const data = useMemo(\n () =>\n stateSnapshot\n ? {\n ...pageData,\n component_props: {\n ...pageData?.component_props,\n ...stateSnapshot,\n },\n }\n : pageData,\n [pageData, stateSnapshot],\n );\n\n const { attrs = {}, styles = {}, uid } = node;\n const { isCompositionBeingEdited, componentRegistry } = useRenderer();\n resolveMetadataBindings(node, data);\n const reference = useRef<StudioComponentRef>(null);\n\n // handles the hidden element notification event\n useEffect(() => {\n const hiddenElementNotificationEventListener = (\n data: HiddenElementNotificationEventData,\n ) => {\n if (!isCompositionBeingEdited) return;\n\n if (data.uid !== node.uid && data.uid !== \"__all__\") return;\n\n if (reference.current) {\n if (data.action === \"open\") {\n if (\n \"open\" in reference.current &&\n typeof reference.current.open === \"function\"\n ) {\n reference.current.open();\n } else {\n // Open method is optional - only components with _hiddenElementNotification: true need it\n console.debug(\n \"Open method not available on this component reference.\",\n );\n }\n } else {\n if (\n \"close\" in reference.current &&\n typeof reference.current.close === \"function\"\n ) {\n reference.current.close();\n } else {\n // Close method is optional - only components with _hiddenElementNotification: true need it\n console.debug(\n \"Close method not available on this component reference.\",\n );\n }\n }\n }\n };\n\n composableStudioEventEmitter.on(\n COMPOSABLE_STUDIO_EMITTED_EVENTS.HIDDEN_ELEMENT_NOTIFICATION,\n hiddenElementNotificationEventListener,\n );\n\n return () => {\n composableStudioEventEmitter.off(\n COMPOSABLE_STUDIO_EMITTED_EVENTS.HIDDEN_ELEMENT_NOTIFICATION,\n hiddenElementNotificationEventListener,\n );\n };\n }, []);\n\n // When this node leaves the tree (or its uid changes), retract any binding-\n // mismatch errors we reported for it. retrievePropValue's in-render retraction\n // can only fire while the node still renders, so without this an unmounted\n // node's \"Data Mismatch Found\" badge would latch and its tracking entry leak.\n useEffect(() => {\n if (!isCompositionBeingEdited) return;\n return () => clearReportedBindingErrorsForNode(node.uid);\n }, [node.uid, isCompositionBeingEdited]);\n\n const ref: RefCallback<StudioComponentRef> = useCallback(\n (ref) => {\n // NOTE: if you change this condition, make sure to update the internal attributes above\n if (isCompositionBeingEdited && !isPreviewMode) {\n reference.current = ref;\n let refElement: HTMLElement | null = null;\n if (ref instanceof HTMLElement) {\n refElement = ref;\n } else if (ref) {\n if (\"element\" in ref) {\n refElement = ref.element ?? null;\n } else {\n // TODO: Link to documentation explaining how to use the element property\n console.error(\n \"Reference is not a valid object. It should have a element property.\",\n );\n }\n }\n\n if (refElement && node) {\n ELEMENT_TO_NODE.set(refElement, node);\n NODE_TO_ELEMENT.set(node, refElement);\n } else if (!refElement) {\n const element = NODE_TO_ELEMENT.get(node);\n if (element) {\n ELEMENT_TO_NODE.delete(element);\n }\n if (NODE_TO_ELEMENT.has(node)) {\n NODE_TO_ELEMENT.delete(node);\n }\n }\n }\n },\n [node],\n );\n\n // Node style extraction + Google-font side effect. These previously lived\n // inside the try below, AFTER the early `return null` for an unregistered\n // component — so the hook count varied between renders (\"Rendered more hooks\n // than during the previous render\") whenever a node's component wasn't\n // registered yet on the first paint, or `componentRegistry` was momentarily\n // absent. React requires hooks to be unconditional, so they run here before\n // ANY early return. handleNodeStyles is a pure style extractor (no hooks/SDK).\n const [\n defaultResponsiveClass,\n namedResponsiveClasses,\n fontFamilies,\n fontVariants,\n ] = handleNodeStyles(styles, uid);\n\n // TODO: @RavenColEvol, can we memoize this?\n useEffect(() => {\n fontFamilies.forEach((fontFamily) => {\n loadGoogleFont(fontFamily, fontVariants.get(fontFamily)!, styles, uid);\n });\n }, [fontFamilies, styles, uid]);\n\n // Every hook above runs unconditionally; the early returns below are now safe.\n if (!componentRegistry) {\n return <RendererErrorComponent reason=\"SDK is not initialized\" />;\n }\n let internalAttributes: BuilderNodeInternalAttributes = {};\n\n // NOTE: if you change this condition, make sure to update the ref callback above\n if (isCompositionBeingEdited && !isPreviewMode) {\n internalAttributes = {\n [COMPOSABLE_DATA_ATTRIBUTES.BUILDER]: true,\n [COMPOSABLE_DATA_ATTRIBUTES.NODE]: true,\n [COMPOSABLE_DATA_ATTRIBUTES.ID]: uid,\n ref,\n };\n }\n\n try {\n const componentOptions = componentRegistry.getComponentByNode(node, false);\n if (!componentOptions) return null;\n const Component = componentOptions.component;\n\n // RSC client-reference safeguard (see studio-react/src/renderer/index.tsx).\n // Editor normally only runs in-browser, but consumers may render the\n // composition tree from a server entry; mirror the renderer's guard so\n // SSR never invokes a client-reference proxy.\n const isClientReference =\n (Component as any)?.$$typeof === Symbol.for(\"react.client.reference\");\n if (isClientReference && typeof window === \"undefined\") {\n const PlaceholderTag = (componentOptions.wrap as any) || \"div\";\n return (\n <PlaceholderTag\n {...internalAttributes}\n data-cs-defer-builtin={node.type}\n suppressHydrationWarning\n />\n );\n }\n\n if (dataCslp) {\n internalAttributes[\"data-cslp\"] = dataCslp;\n }\n const config =\n lightSdk?.internal?.getConfig() ?? sdk?.internal?.getConfig();\n\n if (node.metadata.repeaterWrapper && config?.cslp.appendTags) {\n const binding = getRepeaterBinding(node);\n if (binding) {\n const bindingPath = getBindingString(binding);\n const cslpValue = getCslpTag({ bindedField: bindingPath, data });\n if (cslpValue[\"data-cslp\"]) {\n internalAttributes[\"data-cslp\"] = cslpValue[\"data-cslp\"];\n }\n }\n }\n const resolvedProps = wrapActionProps(\n componentOptions.props,\n retrievePropValue<string, React.ReactNode>({\n data,\n defaultSlot: \"I am a default slot\", // TODO: this should be an component\n componentOptions: componentOptions,\n node: node,\n placeholders: {\n string: (placeholder?: string) => (\n <TextPlaceholder placeholder={placeholder} />\n ),\n },\n cslp: {\n appendTags: config?.cslp.appendTags ?? false,\n },\n nodeUid: uid,\n jsonRTE: getJSONRTE(),\n getSlots({ slots, parent, slotUid }: GetSlotsParams) {\n return (\n <VisualComponent\n parent={parent}\n nodes={slots}\n slotUid={slotUid}\n renderError={renderError}\n />\n );\n },\n isCompositionBeingEdited,\n }),\n );\n\n const componentClass = classNames(\n resolvedProps.className,\n defaultResponsiveClass,\n attrs.className,\n );\n\n // Behavior assignment (BYOS): component_props binding whose key is a\n // registered studio function → node click runs it (mirrors the live\n // renderer; in edit mode the canvas overlay owns clicks, so this fires\n // only in preview / interactive contexts).\n const attrsWithResponsiveClass = {\n ...attrs,\n ...namedResponsiveClasses,\n className: componentClass,\n ...(boundFunctionName\n ? {\n onClick: (event: React.MouseEvent) => {\n (attrs as { onClick?: (e: React.MouseEvent) => void }).onClick?.(\n event,\n );\n callStudioFunction(boundFunctionName);\n },\n }\n : {}),\n };\n\n const WrapTag =\n typeof componentOptions.wrap === \"string\"\n ? componentOptions.wrap || \"div\"\n : \"div\";\n\n // For section-composition nodes, expose the page-side instance uid,\n // its filled slots map, AND the page-level outer data (captured here\n // BEFORE SectionCompositionProvider downstream scopes `template` to\n // the section's selected_field). section-slot placeholders inside the\n // section's body read this context to transclude filled children\n // under the page's data context — so bindings authored on the dropped\n // components resolve against the page's preview entry / additional\n // entries / queries as if the components were on the page directly.\n const wrapWithSectionInstanceCtx = (children: ReactNode) =>\n node.type === \"section-composition\" ? (\n <SectionInstanceSlotsCtxProvider\n value={{\n sectionInstanceUid: uid,\n sectionNode: node,\n slotsMap: (node.slots ?? {}) as Record<string, any[]>,\n pageOuterData: data,\n }}\n >\n {children}\n </SectionInstanceSlotsCtxProvider>\n ) : (\n children\n );\n\n if (componentOptions.wrap) {\n return (\n <RendererErrorBoundary renderError={renderError}>\n <WrapTag {...internalAttributes}>\n {wrapWithSectionInstanceCtx(\n <Component {...attrsWithResponsiveClass} {...resolvedProps} />,\n )}\n </WrapTag>\n </RendererErrorBoundary>\n );\n }\n return (\n <RendererErrorBoundary renderError={renderError}>\n {wrapWithSectionInstanceCtx(\n <Component\n studioAttributes={internalAttributes}\n {...attrsWithResponsiveClass}\n {...resolvedProps}\n />,\n )}\n </RendererErrorBoundary>\n );\n } catch (error) {\n if (error instanceof Error) {\n console.error(\"Error while rendering component\", error);\n return (\n <RendererErrorComponent\n builderAttributes={internalAttributes}\n reason={error.message}\n />\n );\n }\n throw error;\n }\n};\n\nconst MemoizedElement = memo(Element, (prev, next) => {\n const isSame =\n prev.node === next.node &&\n prev.dataCslp === next.dataCslp &&\n prev.renderError === next.renderError;\n return isSame;\n});\n\n/**\n * A slot child's node path when it has no parent path yet (the root slot).\n * Module-level so the root's context value is reference-stable across renders --\n * a `= []` default would mint a fresh array every render and break the memo\n * chain at the very top, where it matters most.\n */\nconst EMPTY_NODE_PATH: Path = [];\n\n/**\n * One child of a slot: its node contexts plus the element itself, memoised.\n *\n * This exists so an ancestor's re-render does not re-render every descendant.\n * Three things have to hold at once for that, and they are why this is a\n * component rather than inline JSX:\n *\n * - the element renders through `MemoizedElement`, not the bare `Element`;\n * - `CurrentNodeContext`'s value is built with `useMemo`. It used to be an\n * object literal inside the parent's `.map()`, where no hook can run, so\n * every parent render minted a new context value and forced every descendant\n * reading `useCurrentNode` to re-render -- which defeats memoising the\n * element on its own;\n * - `slotIndex` is a PROP, not a closure variable. A sibling whose position\n * shifted (something was inserted earlier in the slot) therefore sees a prop\n * change and re-renders, so its path context and `useIsNodeSelected` stay\n * correct, while genuinely untouched siblings skip.\n */\nconst SlotChild = memo(\n ({\n node,\n slotUid,\n slotIndex,\n parentNodePath,\n renderError,\n dataCslp,\n }: {\n node: Node;\n slotUid: SlotUid;\n slotIndex: number;\n parentNodePath: Path;\n renderError?: React.ComponentType<{ error: Error }>;\n dataCslp?: string;\n }) => {\n const currentNodePath = useMemo<Path>(\n () => [...parentNodePath, [slotUid, slotIndex]],\n [parentNodePath, slotUid, slotIndex],\n );\n const currentNode = useMemo(\n () => ({ currentNodeUid: node.uid, currentNodePath }),\n [node.uid, currentNodePath],\n );\n\n return (\n <CurrentNodeContext.Provider value={currentNode}>\n <SelectedNodeProvider>\n <MemoizedElement\n node={node}\n renderError={renderError}\n dataCslp={dataCslp}\n />\n </SelectedNodeProvider>\n </CurrentNodeContext.Provider>\n );\n },\n);\nSlotChild.displayName = \"SlotChild\";\n\nconst VisualComponent = memo(\n ({\n parent,\n nodes,\n slotUid,\n renderError,\n dataCslp = \"\",\n }: {\n parent: Node;\n nodes: Node[];\n slotUid: SlotUid;\n renderError?: React.ComponentType<{ error: Error }>;\n dataCslp?: string;\n }) => {\n const { uid } = parent;\n const isPreviewMode = usePreviewMode();\n const {\n isCompositionBeingEdited,\n componentRegistry,\n compositionPlacement,\n } = useRenderer();\n const { currentNodePath: parentNodePath = EMPTY_NODE_PATH } =\n useCurrentNode();\n const ref = useCallback(\n (ref: HTMLElement) => {\n if (isPreviewMode) return;\n if (ref && parent) {\n ELEMENT_TO_NODE.set(ref, parent);\n NODE_TO_ELEMENT.set(parent, ref);\n } else if (!ref) {\n // When component unmounts, remove references safely\n const element = NODE_TO_ELEMENT.get(parent);\n if (element) {\n ELEMENT_TO_NODE.delete(element);\n }\n if (NODE_TO_ELEMENT.has(parent)) {\n NODE_TO_ELEMENT.delete(parent);\n }\n }\n },\n [parent],\n );\n if (\n !shouldRenderSlot(\n componentRegistry!,\n parent,\n nodes,\n isCompositionBeingEdited,\n )\n ) {\n const children = nodes?.map((node, idx) => {\n const key = node.uid;\n\n // Stays in the parent's loop rather than moving into SlotChild: these run\n // for EVERY child including hidden ones, which are never rendered at all.\n if (isCompositionBeingEdited) {\n NODE_TO_PATH_NODE.set(node, [slotUid, idx]);\n NODE_TO_PARENT.set(node, parent);\n }\n\n if (node.metadata.visible === false) {\n return;\n }\n return (\n <SlotChild\n key={key}\n node={node}\n slotUid={slotUid}\n slotIndex={idx}\n parentNodePath={parentNodePath}\n renderError={renderError}\n dataCslp={dataCslp}\n />\n );\n });\n\n return <>{children}</>;\n }\n\n // Placeholder text for this empty slot: the repeater advice, or the condition\n // hint when this slot is a condition block's drop well. See `getSlotHint`.\n const hint = getSlotHint(parent);\n\n // Detect if this is a page slot for welcome message\n const isPageSlot = parent.type === INTERNAL_COMPONENTS_NAMES.PAGE;\n\n if (!isCompositionBeingEdited || isPreviewMode) {\n return (\n <Slot\n studioAttributes={{}}\n slotUid={slotUid}\n hint={hint}\n isRootSlot={isPageSlot}\n compositionPlacement={compositionPlacement}\n />\n );\n }\n const internalAttributes: BuilderNodeInternalAttributes = {\n [COMPOSABLE_DATA_ATTRIBUTES.BUILDER]: true,\n [COMPOSABLE_DATA_ATTRIBUTES.NODE]: true,\n [COMPOSABLE_DATA_ATTRIBUTES.ID]: uid,\n ref,\n };\n return (\n <Slot\n studioAttributes={internalAttributes}\n slotUid={slotUid}\n hint={hint}\n isRootSlot={isPageSlot}\n compositionPlacement={compositionPlacement}\n />\n );\n },\n);\nVisualComponent.displayName = \"VisualComponent\";\n\nexport default MemoizedElement;\n"],"names":["_jsx","_Fragment"],"mappings":";;;;;;;;;;;;;;;;;AAyDA,MAAM,OAAO,GAAG,CAAC,EACf,IAAI,EACJ,WAAW,EACX,QAAQ,GAKT,KAAqB;AACpB,IAAA,MAAM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["../../src/components/Element.tsx"],"sourcesContent":["import {\n COMPOSABLE_DATA_ATTRIBUTES,\n COMPOSABLE_STUDIO_EMITTED_EVENTS,\n composableStudioEventEmitter,\n ELEMENT_TO_NODE,\n getJSONRTE,\n loadGoogleFont,\n NODE_TO_ELEMENT,\n NODE_TO_PARENT,\n NODE_TO_PATH_NODE,\n} from \"@contentstack/studio-client\";\nimport { lightSdk, sdk, handleNodeStyles } from \"@contentstack/studio-core\";\nimport { Node, Path, SlotUid } from \"@contentstack/studio-internal\";\nimport type { HiddenElementNotificationEventData } from \"@contentstack/studio-messenger\";\nimport { CurrentNodeContext } from \"@contentstack/studio-react-components/contexts\";\nimport {\n useCurrentNode,\n useData,\n useNodeStateBindings,\n useNodeBoundFunctionName,\n} from \"@contentstack/studio-react-components/hooks\";\nimport {\n clearReportedBindingErrorsForNode,\n getBindingString,\n getCslpTag,\n getRepeaterBinding,\n GetSlotsParams,\n resolveMetadataBindings,\n retrievePropValue,\n wrapActionProps,\n callStudioFunction,\n INTERNAL_COMPONENTS_NAMES,\n ComponentRegistry,\n} from \"@contentstack/studio-registry\";\nimport classNames from \"classnames\";\nimport {\n memo,\n RefCallback,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n} from \"react\";\nimport { BuilderNodeInternalAttributes, StudioComponentRef } from \"../types\";\nimport { RendererErrorComponent } from \"./ErrorComponent\";\nimport { TextPlaceholder } from \"./TextPlaceholder\";\nimport { RendererErrorBoundary } from \"./RendererErrorBoundary\";\nimport { getConditionWellHint, getSlotHint, shouldRenderSlot } from \"../utils\";\nimport Slot from \"./Slot\";\nimport { SlotChildrenWithPermanentDropZones } from \"./PermanentDropZone\";\nimport { usePreviewMode } from \"../hooks/use-preview-mode.hook\";\nimport { useRenderer } from \"../hooks/use-renderer.hook\";\nimport { SelectedNodeProvider } from \"../contexts/providers/selected-node.provider\";\nimport { NodeComponent } from \"@contentstack/studio-react-components/basic-components\";\n\nconst Element = ({\n node,\n renderError,\n dataCslp,\n wellHint,\n}: {\n node: Node;\n renderError?: React.ComponentType<{ error: Error }>;\n dataCslp?: string;\n /**\n * Condition hint handed down by a parent condition block when this node's\n * empty slot is the block's drop well. See `getConditionWellHint`.\n */\n wellHint?: string;\n}): React.ReactNode => {\n const isPreviewMode = usePreviewMode();\n const pageData = useData();\n\n // Canvas parity with the production renderer's BaseElement: declared state\n // variables bound via component_props resolve from the shared BYOS state\n // store. Per-node subscription — only this node re-renders when one of ITS\n // bound state keys changes.\n const stateSnapshot = useNodeStateBindings(node);\n // Behavior assignment (BYOS): reactive — re-reads when the app registers\n // functions (commonly after this node's first render).\n const boundFunctionName = useNodeBoundFunctionName(node);\n const data = useMemo(\n () =>\n stateSnapshot\n ? {\n ...pageData,\n component_props: {\n ...pageData?.component_props,\n ...stateSnapshot,\n },\n }\n : pageData,\n [pageData, stateSnapshot],\n );\n\n const { attrs = {}, styles = {}, uid } = node;\n const { isCompositionBeingEdited, componentRegistry } = useRenderer();\n resolveMetadataBindings(node, data);\n const reference = useRef<StudioComponentRef>(null);\n\n // handles the hidden element notification event\n useEffect(() => {\n const hiddenElementNotificationEventListener = (\n data: HiddenElementNotificationEventData,\n ) => {\n if (!isCompositionBeingEdited) return;\n\n if (data.uid !== node.uid && data.uid !== \"__all__\") return;\n\n if (reference.current) {\n if (data.action === \"open\") {\n if (\n \"open\" in reference.current &&\n typeof reference.current.open === \"function\"\n ) {\n reference.current.open();\n } else {\n // Open method is optional - only components with _hiddenElementNotification: true need it\n console.debug(\n \"Open method not available on this component reference.\",\n );\n }\n } else {\n if (\n \"close\" in reference.current &&\n typeof reference.current.close === \"function\"\n ) {\n reference.current.close();\n } else {\n // Close method is optional - only components with _hiddenElementNotification: true need it\n console.debug(\n \"Close method not available on this component reference.\",\n );\n }\n }\n }\n };\n\n composableStudioEventEmitter.on(\n COMPOSABLE_STUDIO_EMITTED_EVENTS.HIDDEN_ELEMENT_NOTIFICATION,\n hiddenElementNotificationEventListener,\n );\n\n return () => {\n composableStudioEventEmitter.off(\n COMPOSABLE_STUDIO_EMITTED_EVENTS.HIDDEN_ELEMENT_NOTIFICATION,\n hiddenElementNotificationEventListener,\n );\n };\n }, []);\n\n // When this node leaves the tree (or its uid changes), retract any binding-\n // mismatch errors we reported for it. retrievePropValue's in-render retraction\n // can only fire while the node still renders, so without this an unmounted\n // node's \"Data Mismatch Found\" badge would latch and its tracking entry leak.\n useEffect(() => {\n if (!isCompositionBeingEdited) return;\n return () => clearReportedBindingErrorsForNode(node.uid);\n }, [node.uid, isCompositionBeingEdited]);\n\n const ref: RefCallback<StudioComponentRef> = useCallback(\n (ref) => {\n // NOTE: if you change this condition, make sure to update the internal attributes above\n if (isCompositionBeingEdited && !isPreviewMode) {\n reference.current = ref;\n let refElement: HTMLElement | null = null;\n if (ref instanceof HTMLElement) {\n refElement = ref;\n } else if (ref) {\n if (\"element\" in ref) {\n refElement = ref.element ?? null;\n } else {\n // TODO: Link to documentation explaining how to use the element property\n console.error(\n \"Reference is not a valid object. It should have a element property.\",\n );\n }\n }\n\n if (refElement && node) {\n ELEMENT_TO_NODE.set(refElement, node);\n NODE_TO_ELEMENT.set(node, refElement);\n } else if (!refElement) {\n const element = NODE_TO_ELEMENT.get(node);\n if (element) {\n ELEMENT_TO_NODE.delete(element);\n }\n if (NODE_TO_ELEMENT.has(node)) {\n NODE_TO_ELEMENT.delete(node);\n }\n }\n }\n },\n [node],\n );\n\n // Node style extraction + Google-font side effect. These previously lived\n // inside the try below, AFTER the early `return null` for an unregistered\n // component — so the hook count varied between renders (\"Rendered more hooks\n // than during the previous render\") whenever a node's component wasn't\n // registered yet on the first paint, or `componentRegistry` was momentarily\n // absent. React requires hooks to be unconditional, so they run here before\n // ANY early return. handleNodeStyles is a pure style extractor (no hooks/SDK).\n const [\n defaultResponsiveClass,\n namedResponsiveClasses,\n fontFamilies,\n fontVariants,\n ] = handleNodeStyles(styles, uid);\n\n // TODO: @RavenColEvol, can we memoize this?\n useEffect(() => {\n fontFamilies.forEach((fontFamily) => {\n loadGoogleFont(fontFamily, fontVariants.get(fontFamily)!, styles, uid);\n });\n }, [fontFamilies, styles, uid]);\n\n // Every hook above runs unconditionally; the early returns below are now safe.\n if (!componentRegistry) {\n return <RendererErrorComponent reason=\"SDK is not initialized\" />;\n }\n let internalAttributes: BuilderNodeInternalAttributes = {};\n\n // NOTE: if you change this condition, make sure to update the ref callback above\n if (isCompositionBeingEdited && !isPreviewMode) {\n internalAttributes = {\n [COMPOSABLE_DATA_ATTRIBUTES.BUILDER]: true,\n [COMPOSABLE_DATA_ATTRIBUTES.NODE]: true,\n [COMPOSABLE_DATA_ATTRIBUTES.ID]: uid,\n ref,\n };\n }\n\n try {\n const componentOptions = componentRegistry.getComponentByNode(node, false);\n if (!componentOptions) return null;\n const Component = componentOptions.component;\n\n // RSC client-reference safeguard (see studio-react/src/renderer/index.tsx).\n // Editor normally only runs in-browser, but consumers may render the\n // composition tree from a server entry; mirror the renderer's guard so\n // SSR never invokes a client-reference proxy.\n const isClientReference =\n (Component as any)?.$$typeof === Symbol.for(\"react.client.reference\");\n if (isClientReference && typeof window === \"undefined\") {\n const PlaceholderTag = (componentOptions.wrap as any) || \"div\";\n return (\n <PlaceholderTag\n {...internalAttributes}\n data-cs-defer-builtin={node.type}\n suppressHydrationWarning\n />\n );\n }\n\n if (dataCslp) {\n internalAttributes[\"data-cslp\"] = dataCslp;\n }\n const config =\n lightSdk?.internal?.getConfig() ?? sdk?.internal?.getConfig();\n\n if (node.metadata.repeaterWrapper && config?.cslp.appendTags) {\n const binding = getRepeaterBinding(node);\n if (binding) {\n const bindingPath = getBindingString(binding);\n const cslpValue = getCslpTag({ bindedField: bindingPath, data });\n if (cslpValue[\"data-cslp\"]) {\n internalAttributes[\"data-cslp\"] = cslpValue[\"data-cslp\"];\n }\n }\n }\n const resolvedProps = wrapActionProps(\n componentOptions.props,\n retrievePropValue<string, React.ReactNode>({\n data,\n defaultSlot: \"I am a default slot\", // TODO: this should be an component\n componentOptions: componentOptions,\n node: node,\n placeholders: {\n string: (placeholder?: string) => (\n <TextPlaceholder placeholder={placeholder} />\n ),\n },\n cslp: {\n appendTags: config?.cslp.appendTags ?? false,\n },\n nodeUid: uid,\n jsonRTE: getJSONRTE(),\n getSlots({ slots, parent, slotUid }: GetSlotsParams) {\n return (\n <VisualComponent\n parent={parent}\n nodes={slots}\n slotUid={slotUid}\n renderError={renderError}\n wellHint={wellHint}\n />\n );\n },\n isCompositionBeingEdited,\n }),\n );\n\n const componentClass = classNames(\n resolvedProps.className,\n defaultResponsiveClass,\n attrs.className,\n );\n\n // Behavior assignment (BYOS): component_props binding whose key is a\n // registered studio function → node click runs it (mirrors the live\n // renderer; in edit mode the canvas overlay owns clicks, so this fires\n // only in preview / interactive contexts).\n const attrsWithResponsiveClass = {\n ...attrs,\n ...namedResponsiveClasses,\n className: componentClass,\n ...(boundFunctionName\n ? {\n onClick: (event: React.MouseEvent) => {\n (attrs as { onClick?: (e: React.MouseEvent) => void }).onClick?.(\n event,\n );\n callStudioFunction(boundFunctionName);\n },\n }\n : {}),\n };\n\n const WrapTag =\n typeof componentOptions.wrap === \"string\"\n ? componentOptions.wrap || \"div\"\n : \"div\";\n\n // For section-composition nodes, expose the page-side instance uid,\n // its filled slots map, AND the page-level outer data (captured here\n // BEFORE SectionCompositionProvider downstream scopes `template` to\n // the section's selected_field). section-slot placeholders inside the\n // section's body read this context to transclude filled children\n // under the page's data context — so bindings authored on the dropped\n // components resolve against the page's preview entry / additional\n // entries / queries as if the components were on the page directly.\n const sectionInstance =\n node.type === \"section-composition\"\n ? {\n sectionInstanceUid: uid,\n sectionNode: node,\n slotsMap: (node.slots ?? {}) as Record<string, any[]>,\n pageOuterData: data,\n }\n : undefined;\n\n return (\n <RendererErrorBoundary renderError={renderError}>\n <NodeComponent\n Component={Component}\n props={{ ...attrsWithResponsiveClass, ...resolvedProps }}\n wrapTag={componentOptions.wrap ? WrapTag : undefined}\n wrapAttributes={\n componentOptions.wrap ? internalAttributes : undefined\n }\n studioAttributes={\n componentOptions.wrap ? undefined : internalAttributes\n }\n sectionInstance={sectionInstance}\n />\n </RendererErrorBoundary>\n );\n } catch (error) {\n if (error instanceof Error) {\n console.error(\"Error while rendering component\", error);\n return (\n <RendererErrorComponent\n builderAttributes={internalAttributes}\n reason={error.message}\n />\n );\n }\n throw error;\n }\n};\n\nconst MemoizedElement = memo(Element, (prev, next) => {\n const isSame =\n prev.node === next.node &&\n prev.dataCslp === next.dataCslp &&\n prev.renderError === next.renderError &&\n prev.wellHint === next.wellHint;\n return isSame;\n});\n\n/**\n * A slot child's node path when it has no parent path yet (the root slot).\n * Module-level so the root's context value is reference-stable across renders --\n * a `= []` default would mint a fresh array every render and break the memo\n * chain at the very top, where it matters most.\n */\nconst EMPTY_NODE_PATH: Path = [];\n\n/**\n * One child of a slot: its node contexts plus the element itself, memoised.\n *\n * This exists so an ancestor's re-render does not re-render every descendant.\n * Three things have to hold at once for that, and they are why this is a\n * component rather than inline JSX:\n *\n * - the element renders through `MemoizedElement`, not the bare `Element`;\n * - `CurrentNodeContext`'s value is built with `useMemo`. It used to be an\n * object literal inside the parent's `.map()`, where no hook can run, so\n * every parent render minted a new context value and forced every descendant\n * reading `useCurrentNode` to re-render -- which defeats memoising the\n * element on its own;\n * - `slotIndex` is a PROP, not a closure variable. A sibling whose position\n * shifted (something was inserted earlier in the slot) therefore sees a prop\n * change and re-renders, so its path context and `useIsNodeSelected` stay\n * correct, while genuinely untouched siblings skip.\n */\nconst SlotChild = memo(\n ({\n node,\n slotUid,\n slotIndex,\n parentNodePath,\n renderError,\n dataCslp,\n wellHint,\n }: {\n node: Node;\n slotUid: SlotUid;\n slotIndex: number;\n parentNodePath: Path;\n renderError?: React.ComponentType<{ error: Error }>;\n dataCslp?: string;\n wellHint?: string;\n }) => {\n const currentNodePath = useMemo<Path>(\n () => [...parentNodePath, [slotUid, slotIndex]],\n [parentNodePath, slotUid, slotIndex],\n );\n const currentNode = useMemo(\n () => ({ currentNodeUid: node.uid, currentNodePath }),\n [node.uid, currentNodePath],\n );\n\n return (\n <CurrentNodeContext.Provider value={currentNode}>\n <SelectedNodeProvider>\n <MemoizedElement\n node={node}\n renderError={renderError}\n dataCslp={dataCslp}\n wellHint={wellHint}\n />\n </SelectedNodeProvider>\n </CurrentNodeContext.Provider>\n );\n },\n);\nSlotChild.displayName = \"SlotChild\";\n\nconst VisualComponent = memo(\n ({\n parent,\n nodes,\n slotUid,\n renderError,\n dataCslp = \"\",\n wellHint,\n }: {\n parent: Node;\n nodes: Node[];\n slotUid: SlotUid;\n renderError?: React.ComponentType<{ error: Error }>;\n dataCslp?: string;\n /** The owning node's `wellHint`, if its parent condition block passed one. */\n wellHint?: string;\n }) => {\n const { uid } = parent;\n const isPreviewMode = usePreviewMode();\n const {\n isCompositionBeingEdited,\n componentRegistry,\n compositionPlacement,\n } = useRenderer();\n const { currentNodePath: parentNodePath = EMPTY_NODE_PATH } =\n useCurrentNode();\n const ref = useCallback(\n (ref: HTMLElement) => {\n if (isPreviewMode) return;\n if (ref && parent) {\n ELEMENT_TO_NODE.set(ref, parent);\n NODE_TO_ELEMENT.set(parent, ref);\n } else if (!ref) {\n // When component unmounts, remove references safely\n const element = NODE_TO_ELEMENT.get(parent);\n if (element) {\n ELEMENT_TO_NODE.delete(element);\n }\n if (NODE_TO_ELEMENT.has(parent)) {\n NODE_TO_ELEMENT.delete(parent);\n }\n }\n },\n [parent],\n );\n if (\n !shouldRenderSlot(\n componentRegistry!,\n parent,\n nodes,\n isCompositionBeingEdited,\n )\n ) {\n return (\n <SlotChildrenWithPermanentDropZones\n slotOwner={parent}\n slotChildren={nodes}\n renderSlotChild={(node, idx) => {\n // Stays in the parent's loop rather than moving into SlotChild:\n // these run for EVERY child including hidden ones, which are never\n // rendered at all.\n if (isCompositionBeingEdited) {\n NODE_TO_PATH_NODE.set(node, [slotUid, idx]);\n NODE_TO_PARENT.set(node, parent);\n }\n\n if (node.metadata.visible === false) {\n return null;\n }\n return (\n <SlotChild\n node={node}\n slotUid={slotUid}\n slotIndex={idx}\n parentNodePath={parentNodePath}\n renderError={renderError}\n dataCslp={dataCslp}\n wellHint={getConditionWellHint(parent, node)}\n />\n );\n }}\n />\n );\n }\n\n // Placeholder text for this empty slot: the repeater advice, the condition\n // hint when this slot is a condition block's own, or the hint the block\n // handed down when this slot is its drop well. See `getSlotHint` and\n // `getConditionWellHint`.\n const hint = getSlotHint(parent) ?? wellHint;\n\n // Detect if this is a page slot for welcome message\n const isPageSlot = parent.type === INTERNAL_COMPONENTS_NAMES.PAGE;\n\n if (!isCompositionBeingEdited || isPreviewMode) {\n return (\n <Slot\n studioAttributes={{}}\n slotUid={slotUid}\n hint={hint}\n isRootSlot={isPageSlot}\n compositionPlacement={compositionPlacement}\n />\n );\n }\n const internalAttributes: BuilderNodeInternalAttributes = {\n [COMPOSABLE_DATA_ATTRIBUTES.BUILDER]: true,\n [COMPOSABLE_DATA_ATTRIBUTES.NODE]: true,\n [COMPOSABLE_DATA_ATTRIBUTES.ID]: uid,\n ref,\n };\n return (\n <Slot\n studioAttributes={internalAttributes}\n slotUid={slotUid}\n hint={hint}\n isRootSlot={isPageSlot}\n compositionPlacement={compositionPlacement}\n />\n );\n },\n);\nVisualComponent.displayName = \"VisualComponent\";\n\nexport default MemoizedElement;\n"],"names":["_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;AAuDA,MAAM,OAAO,GAAG,CAAC,EACf,IAAI,EACJ,WAAW,EACX,QAAQ,EACR,QAAQ,GAUT,KAAqB;AACpB,IAAA,MAAM,aAAa,GAAG,cAAc,EAAE;AACtC,IAAA,MAAM,QAAQ,GAAG,OAAO,EAAE;;;;;AAM1B,IAAA,MAAM,aAAa,GAAG,oBAAoB,CAAC,IAAI,CAAC;;;AAGhD,IAAA,MAAM,iBAAiB,GAAG,wBAAwB,CAAC,IAAI,CAAC;AACxD,IAAA,MAAM,IAAI,GAAG,OAAO,CAClB,MACE;AACE,UAAE;AACE,YAAA,GAAG,QAAQ;AACX,YAAA,eAAe,EAAE;gBACf,GA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M,EAAE,IAAI,CAAC,EAAA,CAC5C;YAEN,CAAC,EAAA,CACD;IAEN;;;;;IAMA,MAAM,IAAI,GAAG,WAAW,CAAC,MAAM,CAAC,IAAI,QAAQ;;IAG5C,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,KAAK,yBAAyB,CAAC,IAAI;AAEjE,IAAA,IAAI,CAAC,wBAAwB,IAAI,aAAa,EAAE;QAC9C,QACEA,GAAA,CAAC,IAAI,EAAA,EACH,gBAAgB,EAAE,EAAE,EACpB,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,UAAU,EACtB,oBAAoB,EAAE,oBAAoB,EAAA,CAC1C;IAEN;AACA,IAAA,MAAM,kBAAkB,GAAkC;AACxD,QAAA,CAAC,0BAA0B,CAAC,OAAO,GAAG,IAAI;AAC1C,QAAA,CAAC,0BAA0B,CAAC,IAAI,GAAG,IAAI;AACvC,QAAA,CAAC,0BAA0B,CAAC,EAAE,GAAG,GAAG;QACpC,GAAG;KACJ;IACD,QACEA,GAAA,CAAC,IAAI,EAAA,EACH,gBAAgB,EAAE,kBAAkB,EACpC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,UAAU,EACtB,oBAAoB,EAAE,oBAAoB,EAAA,CAC1C;AAEN,CAAC,CACF;AACD,eAAe,CAAC,WAAW,GAAG,iBAAiB;;;;"}
@@ -0,0 +1,77 @@
1
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
+ import { PERMANENT_DROP_ZONE_ELEMENTS, ELEMENT_TO_NODE, COMPOSABLE_DATA_ATTRIBUTES } from '@contentstack/studio-client';
3
+ import { css } from 'goober';
4
+ import { memo, useRef, useCallback, useLayoutEffect, Fragment as Fragment$1 } from 'react';
5
+ import { useCanShowPermanentDropZones } from '../hooks/use-can-show-permanent-drop-zones.hook.js';
6
+ import { useRendersDesignForMode } from '../hooks/use-should-show-design.hook.js';
7
+ import { useSlotCopyColor } from '../hooks/use-slot-copy-color.hook.js';
8
+ import { getPermanentDropZonePlacements } from '../utils/renderer.util.js';
9
+ import { styleFactory } from './styles.js';
10
+
11
+ /** Box above an arrow into a dashed slot: "drop it here". */
12
+ const PermanentDropZoneIcon = () => (jsxs("svg", { width: "20", height: "20", viewBox: "0 0 28 28", fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true", children: [jsx("rect", { x: "9", y: "1.5", width: "10", height: "10", rx: "2", stroke: "currentColor", strokeWidth: "1.5" }), jsx("path", { d: "M12 5.2h4M12 8h4", stroke: "currentColor", strokeWidth: "1.3", strokeLinecap: "round" }), jsx("path", { d: "M14 13.5v4m0 0l-2-2m2 2l2-2", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }), jsx("rect", { x: "3.5", y: "19.5", width: "21", height: "7", rx: "2", stroke: "currentColor", strokeWidth: "1.5", strokeDasharray: "3 2.5" })] }));
13
+ /**
14
+ * An editor-only drop zone beside a Repeater over modular blocks, for content
15
+ * that always shows.
16
+ * It isn't a node and is never saved: it maps to `anchorNode`, so a drop on it
17
+ * is a sibling drop before or after `anchorNode`.
18
+ */
19
+ const PermanentDropZone = memo(function PermanentDropZone({ anchorNode, direction, }) {
20
+ const styles = styleFactory(css);
21
+ const { ref: measureBackdropChromeMode, mode: chromeMode, hasMeasuredBackdrop, } = useSlotCopyColor();
22
+ const registeredZoneElement = useRef(null);
23
+ // Registers the zone as a drop target the client can find, and unregisters
24
+ // it when it unmounts. Stable, so the page tone is measured once per mount
25
+ // rather than on every edit that replaces the anchor node.
26
+ const registerZoneElement = useCallback((zoneElement) => {
27
+ measureBackdropChromeMode(zoneElement);
28
+ if (registeredZoneElement.current) {
29
+ PERMANENT_DROP_ZONE_ELEMENTS.delete(registeredZoneElement.current);
30
+ }
31
+ registeredZoneElement.current = zoneElement;
32
+ if (zoneElement)
33
+ PERMANENT_DROP_ZONE_ELEMENTS.add(zoneElement);
34
+ }, [measureBackdropChromeMode]);
35
+ // Maps the zone to its current anchor, so a drop on it lands beside that.
36
+ useLayoutEffect(() => {
37
+ if (registeredZoneElement.current) {
38
+ ELEMENT_TO_NODE.set(registeredZoneElement.current, anchorNode);
39
+ }
40
+ }, [anchorNode]);
41
+ const permanentDropZoneAttributes = {
42
+ [COMPOSABLE_DATA_ATTRIBUTES.BUILDER]: true,
43
+ [COMPOSABLE_DATA_ATTRIBUTES.NODE]: true,
44
+ [COMPOSABLE_DATA_ATTRIBUTES.PERMANENT_DROP_ZONE_DIRECTION]: direction,
45
+ };
46
+ return (jsx("div", { ref: registerZoneElement, ...permanentDropZoneAttributes, className: [
47
+ styles.permanentDropZone,
48
+ styles.permanentDropZoneColors[chromeMode ?? "light"],
49
+ // Out of layout until the page tone is read, so the zone appears in
50
+ // its final colours instead of fading in from the light fallback.
51
+ !hasMeasuredBackdrop && styles.permanentDropZoneAwaitingBackdrop,
52
+ ]
53
+ .filter(Boolean)
54
+ .join(" "), children: jsxs("div", { className: styles.permanentDropZoneLabelRow, children: [jsx(PermanentDropZoneIcon, {}), jsx("span", { className: styles.permanentDropZoneLabel, children: "Drop a component here to always display it" })] }) }));
55
+ });
56
+ /**
57
+ * Renders a slot's children with the permanent drop zones their gaps need.
58
+ * Every editor loop over slot children goes through this, so the gap rule and
59
+ * when zones may show live in one place.
60
+ */
61
+ function SlotChildrenWithPermanentDropZones({ slotOwner, slotChildren, renderSlotChild, }) {
62
+ const canShowPermanentDropZones = useCanShowPermanentDropZones();
63
+ const rendersDesignForMode = useRendersDesignForMode();
64
+ const placementsBySlotIndex = canShowPermanentDropZones
65
+ ? getPermanentDropZonePlacements(slotOwner, slotChildren, rendersDesignForMode)
66
+ : undefined;
67
+ return (jsx(Fragment, { children: slotChildren.map((slotChild, slotIndex) => {
68
+ const renderedSlotChild = renderSlotChild(slotChild, slotIndex);
69
+ if (renderedSlotChild === null)
70
+ return null;
71
+ const placement = placementsBySlotIndex?.get(slotIndex);
72
+ return (jsxs(Fragment$1, { children: [placement?.hasZoneBefore && (jsx(PermanentDropZone, { anchorNode: slotChild, direction: "top" })), renderedSlotChild, placement?.hasZoneAfter && (jsx(PermanentDropZone, { anchorNode: slotChild, direction: "bottom" }))] }, slotChild.uid));
73
+ }) }));
74
+ }
75
+
76
+ export { PermanentDropZone, SlotChildrenWithPermanentDropZones };
77
+ //# sourceMappingURL=PermanentDropZone.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PermanentDropZone.js","sources":["../../src/components/PermanentDropZone.tsx"],"sourcesContent":["import {\n COMPOSABLE_DATA_ATTRIBUTES,\n ELEMENT_TO_NODE,\n PERMANENT_DROP_ZONE_ELEMENTS,\n type PermanentDropZoneDirection,\n} from \"@contentstack/studio-client\";\nimport { Node } from \"@contentstack/studio-internal\";\nimport { css } from \"goober\";\nimport {\n Fragment,\n memo,\n ReactNode,\n useCallback,\n useLayoutEffect,\n useRef,\n} from \"react\";\nimport { useCanShowPermanentDropZones } from \"../hooks/use-can-show-permanent-drop-zones.hook\";\nimport { useRendersDesignForMode } from \"../hooks/use-should-show-design.hook\";\nimport { useSlotCopyColor } from \"../hooks/use-slot-copy-color.hook\";\nimport { PermanentDropZoneInternalAttributes } from \"../types\";\nimport { getPermanentDropZonePlacements } from \"../utils\";\nimport { styleFactory } from \"./styles\";\n\n/** Box above an arrow into a dashed slot: \"drop it here\". */\nconst PermanentDropZoneIcon = () => (\n <svg\n width=\"20\"\n height=\"20\"\n viewBox=\"0 0 28 28\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n aria-hidden=\"true\"\n >\n <rect\n x=\"9\"\n y=\"1.5\"\n width=\"10\"\n height=\"10\"\n rx=\"2\"\n stroke=\"currentColor\"\n strokeWidth=\"1.5\"\n />\n <path\n d=\"M12 5.2h4M12 8h4\"\n stroke=\"currentColor\"\n strokeWidth=\"1.3\"\n strokeLinecap=\"round\"\n />\n <path\n d=\"M14 13.5v4m0 0l-2-2m2 2l2-2\"\n stroke=\"currentColor\"\n strokeWidth=\"1.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n <rect\n x=\"3.5\"\n y=\"19.5\"\n width=\"21\"\n height=\"7\"\n rx=\"2\"\n stroke=\"currentColor\"\n strokeWidth=\"1.5\"\n strokeDasharray=\"3 2.5\"\n />\n </svg>\n);\n\ninterface PermanentDropZoneProps {\n /** The block Repeater, or its wrapper Box, that the zone sits beside. */\n anchorNode: Node;\n /** Which side of `anchorNode` the zone is on. */\n direction: PermanentDropZoneDirection;\n}\n\n/**\n * An editor-only drop zone beside a Repeater over modular blocks, for content\n * that always shows.\n * It isn't a node and is never saved: it maps to `anchorNode`, so a drop on it\n * is a sibling drop before or after `anchorNode`.\n */\nexport const PermanentDropZone = memo(function PermanentDropZone({\n anchorNode,\n direction,\n}: PermanentDropZoneProps) {\n const styles = styleFactory(css);\n const {\n ref: measureBackdropChromeMode,\n mode: chromeMode,\n hasMeasuredBackdrop,\n } = useSlotCopyColor<HTMLDivElement>();\n const registeredZoneElement = useRef<HTMLDivElement | null>(null);\n // Registers the zone as a drop target the client can find, and unregisters\n // it when it unmounts. Stable, so the page tone is measured once per mount\n // rather than on every edit that replaces the anchor node.\n const registerZoneElement = useCallback(\n (zoneElement: HTMLDivElement | null) => {\n measureBackdropChromeMode(zoneElement);\n if (registeredZoneElement.current) {\n PERMANENT_DROP_ZONE_ELEMENTS.delete(registeredZoneElement.current);\n }\n registeredZoneElement.current = zoneElement;\n if (zoneElement) PERMANENT_DROP_ZONE_ELEMENTS.add(zoneElement);\n },\n [measureBackdropChromeMode],\n );\n // Maps the zone to its current anchor, so a drop on it lands beside that.\n useLayoutEffect(() => {\n if (registeredZoneElement.current) {\n ELEMENT_TO_NODE.set(registeredZoneElement.current, anchorNode);\n }\n }, [anchorNode]);\n const permanentDropZoneAttributes: PermanentDropZoneInternalAttributes = {\n [COMPOSABLE_DATA_ATTRIBUTES.BUILDER]: true,\n [COMPOSABLE_DATA_ATTRIBUTES.NODE]: true,\n [COMPOSABLE_DATA_ATTRIBUTES.PERMANENT_DROP_ZONE_DIRECTION]: direction,\n };\n return (\n <div\n ref={registerZoneElement}\n {...permanentDropZoneAttributes}\n className={[\n styles.permanentDropZone,\n styles.permanentDropZoneColors[chromeMode ?? \"light\"],\n // Out of layout until the page tone is read, so the zone appears in\n // its final colours instead of fading in from the light fallback.\n !hasMeasuredBackdrop && styles.permanentDropZoneAwaitingBackdrop,\n ]\n .filter(Boolean)\n .join(\" \")}\n >\n <div className={styles.permanentDropZoneLabelRow}>\n <PermanentDropZoneIcon />\n <span className={styles.permanentDropZoneLabel}>\n Drop a component here to always display it\n </span>\n </div>\n </div>\n );\n});\n\ninterface SlotChildrenWithPermanentDropZonesProps {\n /** The node whose slot holds `slotChildren`. */\n slotOwner: Node;\n slotChildren: Node[];\n /** Renders one child at its slot index, or `null` to leave it out. */\n renderSlotChild: (slotChild: Node, slotIndex: number) => ReactNode;\n}\n\n/**\n * Renders a slot's children with the permanent drop zones their gaps need.\n * Every editor loop over slot children goes through this, so the gap rule and\n * when zones may show live in one place.\n */\nexport function SlotChildrenWithPermanentDropZones({\n slotOwner,\n slotChildren,\n renderSlotChild,\n}: SlotChildrenWithPermanentDropZonesProps) {\n const canShowPermanentDropZones = useCanShowPermanentDropZones();\n const rendersDesignForMode = useRendersDesignForMode();\n const placementsBySlotIndex = canShowPermanentDropZones\n ? getPermanentDropZonePlacements(\n slotOwner,\n slotChildren,\n rendersDesignForMode,\n )\n : undefined;\n return (\n <>\n {slotChildren.map((slotChild, slotIndex) => {\n const renderedSlotChild = renderSlotChild(slotChild, slotIndex);\n if (renderedSlotChild === null) return null;\n const placement = placementsBySlotIndex?.get(slotIndex);\n return (\n <Fragment key={slotChild.uid}>\n {placement?.hasZoneBefore && (\n <PermanentDropZone anchorNode={slotChild} direction=\"top\" />\n )}\n {renderedSlotChild}\n {placement?.hasZoneAfter && (\n <PermanentDropZone anchorNode={slotChild} direction=\"bottom\" />\n )}\n </Fragment>\n );\n })}\n </>\n );\n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js';
7
7
  import { useSlotCopyColor } from '../hooks/use-slot-copy-color.hook.js';
8
8
  import { editContext } from '../contexts/providers/edit-context.provider.js';
9
9
  import classNames from 'classnames';
10
- import { DataStepMode } from '@contentstack/studio-messenger';
10
+ import { DataStepMode } from '@contentstack/studio-messenger/constants';
11
11
 
12
12
  // Data-step wording follows the options the editor actually offers for this
13
13
  // composition (composable-studio ADR 0008): a freeform page can only pin, a
@@ -1,6 +1,7 @@
1
1
  import { jsx, jsxs } from 'react/jsx-runtime';
2
2
  import { Button, EDIT_SECTIONS_LABEL } from '@contentstack/studio-core';
3
- import { composableStudioEventManager, POST_MESSAGE_EVENTS } from '@contentstack/studio-messenger';
3
+ import { POST_MESSAGE_EVENTS } from '@contentstack/studio-messenger/constants';
4
+ import { composableStudioEventManager } from '@contentstack/studio-messenger';
4
5
  import { COMPOSABLE_DATA_ATTRIBUTES } from '@contentstack/studio-client';
5
6
  import { SectionCompositionProvider } from '@contentstack/studio-react-components/basic-components';
6
7
  import { DefaultChainCtx, DataCtxProvider } from '@contentstack/studio-react-components/contexts';
@@ -1 +1 @@
1
- {"version":3,"file":"SectionComposition.js","sources":["../../../src/components/elements/SectionComposition.tsx"],"sourcesContent":["import { Button, EDIT_SECTIONS_LABEL } from \"@contentstack/studio-core\";\nimport {\n POST_MESSAGE_EVENTS,\n composableStudioEventManager,\n} from \"@contentstack/studio-messenger\";\nimport { COMPOSABLE_DATA_ATTRIBUTES } from \"@contentstack/studio-client\";\nimport { SectionCompositionProvider } from \"@contentstack/studio-react-components/basic-components\";\nimport {\n DataCtxProvider,\n DefaultChainCtx,\n} from \"@contentstack/studio-react-components/contexts\";\nimport {\n useCurrentNode,\n useData,\n} from \"@contentstack/studio-react-components/hooks\";\nimport { css } from \"goober\";\nimport { MouseEvent, useCallback, useContext, useMemo } from \"react\";\nimport { PreviewRenderer } from \"../PreviewRenderer\";\nimport { StudioAttributes } from \"../../types\";\nimport { styleFactory } from \"../styles\";\nimport { SectionModeContext } from \"../../contexts/providers/section-mode.provider\";\nimport { useDesignPreviewContext } from \"../../hooks/use-design-preview.hook\";\n\n// ─── Types ───────────────────────────────────────────────────────────────────\n\ninterface BindingValue {\n path?: Record<string, unknown>;\n [key: string]: unknown;\n}\n\nexport interface ExposedPropDef {\n uid: string;\n nodeUid: string;\n propKey: string;\n /** The binding the internal node had at expose-time (e.g. template.title).\n * SectionCompositionProvider uses this to know which field in the\n * section-scoped template to override. */\n bindingAtExposeTime?: { type: string; value: BindingValue };\n}\n\ntype SectionSpec = {\n compositionEntry?: {\n uid: string;\n };\n ui?: any;\n [key: string]: any;\n};\n\ninterface SectionCompositionProps extends StudioAttributes {\n spec: SectionSpec;\n compositionUID: string;\n className?: string;\n /** Per-placement design/preview mode from the placed node's `metadata.mode`. */\n mode?: \"design\" | \"preview\";\n [key: string]: any;\n}\n\n// ─── Helpers ─────────────────────────────────────────────────────────────────\n\n/** Whether the section's authored UI contains at least one section-slot. */\nfunction sectionHasSlot(ui: any): boolean {\n if (!ui || typeof ui !== \"object\") return false;\n if (ui.type === \"section-slot\") return true;\n const slots = ui.slots || {};\n for (const slotId of Object.keys(slots)) {\n for (const child of slots[slotId] || []) {\n if (sectionHasSlot(child)) return true;\n }\n }\n return false;\n}\n\n/**\n * Effective design/preview mode for a placed section. The placement's explicit\n * `metadata.mode` (passed as the `mode` prop) wins; otherwise derive from the\n * section's content — `design` if it has a section-slot (so its drop-zones stay\n * visible) else `preview`. Mirrors `deriveSectionMode` on the Studio side.\n */\nfunction resolveSectionMode(\n mode: \"design\" | \"preview\" | undefined,\n spec: SectionSpec,\n): \"design\" | \"preview\" {\n if (mode === \"design\" || mode === \"preview\") return mode;\n return sectionHasSlot(spec?.ui) ? \"design\" : \"preview\";\n}\n\n/** Reads sectionExposedProps from the section spec's UI metadata. */\nfunction getExposedPropDefs(spec: SectionSpec): ExposedPropDef[] {\n const compositionEntry = spec.compositionEntry as\n | { ui?: { metadata?: Record<string, unknown> } }\n | undefined;\n return (\n (compositionEntry?.ui?.metadata?.sectionExposedProps as\n | ExposedPropDef[]\n | undefined) ?? []\n );\n}\n\n/**\n * Builds a map of { [ep.uid]: resolvedValue } from the props that\n * retrievePropValue already resolved for the page-level section node.\n *\n * retrievePropValue resolves the bindings the page composer set on the section\n * node's exposed props (e.g. template.heroTitle) and spreads them onto this\n * component. The page node's binding is the SOLE source of truth for an exposed\n * prop, so we emit an entry for EVERY exposed prop — including cleared/empty\n * ones (value `undefined`/`\"\"`). That lets a cleared prop render its empty value\n * downstream instead of falling back to the section's internal binding.\n */\nfunction buildOverrideValues(\n exposedPropDefs: ExposedPropDef[],\n rest: Record<string, unknown>,\n): Record<string, unknown> {\n const overrides: Record<string, unknown> = {};\n for (const ep of exposedPropDefs) {\n overrides[ep.uid] = rest[ep.uid];\n }\n return overrides;\n}\n\n/**\n * Builds a map of { [ep.uid]: cslpTag } from the `$<ep.uid>` CSLP props\n * retrievePropValue resolved for the page-level section node. Forwarded to the\n * provider so an overridden exposed prop keeps its `data-cslp` edit tag — the\n * override short-circuits retrievePropValue before it would compute one, and\n * the page-level tag (e.g. blog_post.<entry>.<locale>.hero_card.title) is the\n * correct target for the edit overlay. `domProps` strips these `$`-keys from the\n * DOM spread, so capture them here first.\n */\nfunction buildOverrideCslp(\n exposedPropDefs: ExposedPropDef[],\n rest: Record<string, unknown>,\n): Record<string, unknown> {\n const cslp: Record<string, unknown> = {};\n for (const ep of exposedPropDefs) {\n cslp[ep.uid] = rest[`$${ep.uid}`];\n }\n return cslp;\n}\n\n// ─── Icon ────────────────────────────────────────────────────────────────────\n\nfunction StudioIcon() {\n return (\n <svg\n width=\"20\"\n height=\"20\"\n viewBox=\"0 0 20 20\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M2.5 5.37989C2.5 4.39075 3.36764 3.62971 4.34018 3.76578L4.96257 3.85287C8.30481 4.3205 11.6952 4.3205 15.0374 3.85287L15.6598 3.76579C16.6324 3.62971 17.5 4.39075 17.5 5.37989V12.1389C17.5 13.1281 16.6324 13.8891 15.6598 13.753L15.2334 13.6934C14.9921 13.6596 14.8236 13.4351 14.8571 13.192C14.8907 12.9489 15.1135 12.7792 15.3548 12.8129L15.7812 12.8726C16.2233 12.9345 16.6176 12.5885 16.6176 12.1389V5.37989C16.6176 4.93028 16.2233 4.58436 15.7812 4.64621L15.1588 4.73329C11.736 5.21219 8.26397 5.21219 4.84118 4.73329L4.2188 4.64621C3.77673 4.58436 3.38235 4.93028 3.38235 5.37989V12.1389C3.38235 12.5885 3.77673 12.9345 4.2188 12.8726L4.64519 12.8129C4.88653 12.7792 5.10934 12.9489 5.14286 13.192C5.17638 13.4351 5.00791 13.6596 4.76657 13.6934L4.34019 13.753C3.36764 13.8891 2.5 13.1281 2.5 12.1389V5.37989Z\"\n fill=\"#6C5CE7\"\n />\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M6.02941 9.0557C6.02941 8.64661 6.35861 8.31497 6.76471 8.31497H8.52941C8.9355 8.31497 9.26471 8.64661 9.26471 9.0557V10.801C9.26471 11.2101 8.9355 11.5418 8.52941 11.5418H6.76471C6.35861 11.5418 6.02941 11.2101 6.02941 10.801V9.0557ZM6.91176 9.20384V10.6529H8.38235V9.20384H6.91176Z\"\n fill=\"#6C5CE7\"\n />\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M10.1471 8.16682C10.1471 7.59409 10.6079 7.1298 11.1765 7.1298H13.5294C14.0979 7.1298 14.5588 7.59409 14.5588 8.16682V10.5047C14.5588 11.0775 14.0979 11.5418 13.5294 11.5418H11.1765C10.6079 11.5418 10.1471 11.0775 10.1471 10.5047V8.16682ZM11.1765 8.01868C11.0953 8.01868 11.0294 8.08501 11.0294 8.16682V10.5047C11.0294 10.5866 11.0953 10.6529 11.1765 10.6529H13.5294C13.6106 10.6529 13.6765 10.5866 13.6765 10.5047V8.16682C13.6765 8.08501 13.6106 8.01868 13.5294 8.01868H11.1765Z\"\n fill=\"#6C5CE7\"\n />\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M10 12.4306C10.5685 12.4306 11.0294 12.8949 11.0294 13.4677V15.838C11.0294 16.4107 10.5685 16.875 10 16.875H7.05882C6.49029 16.875 6.02941 16.4107 6.02941 15.838L6.02941 13.4677C6.02941 12.8949 6.49029 12.4306 7.05882 12.4306H10ZM10.1471 13.4677C10.1471 13.3858 10.0812 13.3195 10 13.3195H7.05882C6.97761 13.3195 6.91176 13.3858 6.91176 13.4677V15.838C6.91176 15.9198 6.97761 15.9861 7.05882 15.9861H10C10.0812 15.9861 10.1471 15.9198 10.1471 15.838V13.4677Z\"\n fill=\"#6C5CE7\"\n />\n <path\n d=\"M12.7134 12.9508C12.7104 12.902 12.7639 12.8707 12.8044 12.8976L14.6152 14.0966C14.6598 14.1261 14.6455 14.1954 14.5929 14.2045L13.6175 14.3742C13.6036 14.3766 13.5911 14.3839 13.5821 14.3948L12.9517 15.1636C12.9177 15.205 12.8509 15.1832 12.8476 15.1295L12.7134 12.9508Z\"\n fill=\"#6C5CE7\"\n />\n </svg>\n );\n}\n\n// ─── Component ───────────────────────────────────────────────────────────────\n\nexport function SectionComposition({\n spec,\n compositionUID,\n studioAttributes,\n className,\n mode,\n ...rest\n}: SectionCompositionProps) {\n const styles = styleFactory(css);\n const data = useData();\n // The page-side instance uid keys this section's per-instance scoped data\n // (section_scoped_data[instanceUid] — carries selectedField/parentRepeaterUID\n // for per-iteration re-scope). It is normally read from the builder node id in\n // `studioAttributes`, but the editor strips that attribute when a node renders\n // in PREVIEW mode (e.g. a section transcluded into a section-slot whose\n // enclosing placed section has Preview Mode on — see SectionSlot). Falling back\n // to the surrounding CurrentNodeContext keeps the instance identity (and thus\n // the correct scoped entry) intact in preview, so a slot-nested section still\n // binds to its per-iteration repeater item instead of the page root.\n const { currentNodeUid } = useCurrentNode();\n const instanceUid =\n studioAttributes?.[COMPOSABLE_DATA_ATTRIBUTES.ID] ?? currentNodeUid;\n\n // A single section-composition node renders ONCE PER ITERATION when wrapped\n // by an iterating ancestor Repeater (page-side OR section-internal). Each\n // render produces its own \"Edit Composition\" button — all pointing at the\n // same compositionUID. Show the button only when every ancestor Repeater is\n // at iteration 0 (or there are no iterating ancestors). This collapses the\n // N-button UI down to one without restructuring the render tree.\n //\n // The map contains only ancestor Repeaters because the editor's Repeater\n // spreads its new entry on top of the inherited map; siblings can't reach\n // this subtree through React context. Design-mode Repeaters don't push a\n // context entry at all, so they don't trigger the gate.\n const isFirstIteration = useMemo(() => {\n const repeaterMap = (data as any)?.dataSources?.repeater;\n if (!repeaterMap || typeof repeaterMap !== \"object\") return true;\n for (const uid of Object.keys(repeaterMap)) {\n const idx = repeaterMap[uid]?.index;\n if (typeof idx === \"number\" && idx !== 0) return false;\n }\n return true;\n }, [data]);\n\n // Mode for everything inside this section. The topmost mode node owns it: if\n // this section is itself inside a repeater/condition-block, that ancestor's\n // DesignPreviewContext (design|preview) wins, overriding the section's own\n // mode. Otherwise the section owns it — explicit placement value, else derived\n // from content. `none` = no enclosing mode node.\n const enclosingMode = useDesignPreviewContext();\n // A section nested inside another section's slot must follow the enclosing\n // section's mode too — not just an enclosing repeater's (COMS-1659). A\n // slot-bearing nested section derives `design`, so its own SectionModeContext\n // Provider (below) would clobber the inherited preview and freeze its data\n // Repeaters (they iterate only when useShouldShowDesign sees section preview).\n // Only PREVIEW cascades (design is not inherited); the enclosing-repeater path\n // still takes precedence, so the working repeater-context behavior is intact.\n const enclosingSectionMode = useContext(SectionModeContext);\n // Ancestor section chain on this render path (COMS-1659 cycle guard).\n const defaultChain = useContext(DefaultChainCtx);\n const sectionMode =\n enclosingMode === \"design\" || enclosingMode === \"preview\"\n ? enclosingMode\n : enclosingSectionMode === \"preview\"\n ? \"preview\"\n : resolveSectionMode(mode, spec);\n\n const handleEditClick = useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n event.preventDefault();\n event.stopPropagation();\n composableStudioEventManager?.send(\n POST_MESSAGE_EVENTS.OPEN_IN_COMPOSABLE_STUDIO_EVENT_MESSAGE,\n { compositionEntryUid: compositionUID, compositionQuery: null },\n );\n },\n [compositionUID],\n );\n\n // Definitions of which props are exposed (uid, bindingAtExposeTime, etc.)\n const exposedPropDefs = useMemo(() => getExposedPropDefs(spec), [spec]);\n\n // Map of { [ep.uid]: resolvedPageValue } — values already resolved by\n // retrievePropValue against the page's data context and spread into rest.\n const overrideValues = useMemo(\n () => buildOverrideValues(exposedPropDefs, rest),\n [\n exposedPropDefs,\n JSON.stringify(exposedPropDefs.map((ep) => rest[ep.uid])),\n ],\n );\n\n // Page composer's LIVE binding type per exposed prop (emitted by\n // retrievePropValue for section-composition nodes). Lets the provider tell an\n // untouched repeater seed from a real page-level override.\n const exposedBindingTypes = (rest.section_exposed_binding_types ??\n {}) as Record<string, string>;\n // Which exposed props are still auto-seeded (untouched) — those defer to the\n // section's internal binding so they follow schema switches / repeater context.\n const exposedAutoSeeded = (rest.section_exposed_auto_seeded ?? {}) as Record<\n string,\n boolean\n >;\n // Map of { [ep.uid]: cslpTag } — the page-resolved `$<ep.uid>` tags, forwarded\n // so overridden exposed props keep their live-preview edit tag.\n const overrideCslp = useMemo(\n () => buildOverrideCslp(exposedPropDefs, rest),\n [\n exposedPropDefs,\n JSON.stringify(exposedPropDefs.map((ep) => rest[`$${ep.uid}`])),\n ],\n );\n\n // Exclude exposed prop keys and their $-prefixed CSLP counterparts from DOM\n // spread. retrievePropValue adds both `uid` (resolved value) and `$uid` (CSLP\n // live-preview tag) to the resolved props — both are invalid as div attributes.\n const domProps = useMemo(() => {\n const excluded = new Set([\n ...exposedPropDefs.flatMap((ep) => [ep.uid, `$${ep.uid}`]),\n \"section_exposed_binding_types\",\n \"section_exposed_auto_seeded\",\n ]);\n return Object.fromEntries(\n Object.entries(rest).filter(([k]) => !excluded.has(k)),\n );\n }, [exposedPropDefs, rest]);\n\n // Keep the section instance's id on its host even in PREVIEW mode, where the\n // editor (Element) strips builder attributes from slot children. The id alone\n // carries no selection affordance — interaction is driven by the\n // ELEMENT_TO_NODE map the builder ref populates, which preview omits — but it\n // preserves the per-instance DOM identity the \"Edit Composition\" button is\n // scoped under and keeps a stable hook for each placed section.\n const instanceIdAttr = instanceUid\n ? { [COMPOSABLE_DATA_ATTRIBUTES.ID]: instanceUid }\n : {};\n\n // Cycle guard (COMS-1659): if this section's compositionUID is already an\n // ancestor on the path, a slot-default chain loops back on itself\n // (A→B→…→A). Render nothing to cut the back-edge — terminates at the first\n // repeat, no fetch, safe even for cycles saved directly via the CMA.\n if (compositionUID && defaultChain.has(compositionUID)) return null;\n\n return (\n <DefaultChainCtx.Provider\n value={new Set([...defaultChain, compositionUID])}\n >\n <div\n {...domProps}\n {...instanceIdAttr}\n {...studioAttributes}\n className={[styles.embeddedSectionHost, className]\n .filter(Boolean)\n .join(\" \")}\n >\n {isFirstIteration && (\n <Button\n className={`cs-embedded-section-edit-btn ${styles.embeddedSectionButton}`}\n onClick={handleEditClick}\n type=\"button\"\n data-studio-ui={true}\n >\n <StudioIcon />\n {EDIT_SECTIONS_LABEL}\n </Button>\n )}\n\n {/*\n * exposedPropDefs + overrideValues are forwarded to the provider so it\n * can inject the page-composer's override values into the section-scoped\n * template before the internal UI tree renders.\n */}\n <SectionModeContext.Provider value={sectionMode}>\n <SectionCompositionProvider\n uid={compositionUID}\n instanceUid={instanceUid}\n exposedPropDefs={exposedPropDefs}\n overrideValues={overrideValues}\n exposedBindingTypes={exposedBindingTypes}\n exposedAutoSeeded={exposedAutoSeeded}\n overrideCslp={overrideCslp}\n >\n <SectionDataMerger spec={spec}>\n <PreviewRenderer spec={spec as any} />\n </SectionDataMerger>\n </SectionCompositionProvider>\n </SectionModeContext.Provider>\n </div>\n </DefaultChainCtx.Provider>\n );\n}\n\n/**\n * Merges the section's own `spec.data.static_value` into the active data\n * context so static-value-bound props authored inside the section (e.g. a\n * SectionSlot's `label`, or any Text/Number/etc. inside the section's body)\n * resolve against the section's persisted values when the section is\n * consumed in a page. Without this, child Elements call useData() and get\n * the page's data, which doesn't contain the section's static_value keys.\n */\nfunction SectionDataMerger({\n spec,\n children,\n}: {\n spec: SectionSpec;\n children: React.ReactNode;\n}) {\n const outerData = useData();\n const merged = useMemo(() => {\n const sectionStatic = (spec as any)?.data?.static_value;\n if (!sectionStatic || typeof sectionStatic !== \"object\") return outerData;\n return {\n ...(outerData as any),\n static_value: {\n ...((outerData as any)?.static_value || {}),\n ...sectionStatic,\n },\n };\n }, [outerData, spec]);\n return <DataCtxProvider value={merged as any}>{children}</DataCtxProvider>;\n}\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;;;;AAyDA;AAEA;AACA,SAAS,cAAc,CAAC,EAAO,EAAA;AAC7B,IAAA,IAAI,CAAC,EAAE,IAAI,OAAO,EAAE,KAAK,QAAQ;AAAE,QAAA,OAAO,KAAK;AAC/C,IAAA,IAAI,EAAE,CAAC,IAAI,KAAK,cAAc;AAAE,QAAA,OAAO,IAAI;AAC3C,IAAA,MAAM,KAAK,GAAG,EAAE,CAAC,KAAK,IAAI,EAAE;IAC5B,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;QACvC,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE;YACvC,IAAI,cAAc,CAAC,KAAK,CAAC;AAAE,gBAAA,OAAO,IAAI;QACxC;IACF;AACA,IAAA,OAAO,KAAK;AACd;AAEA;;;;;AAKG;AACH,SAAS,kBAAkB,CACzB,IAAsC,EACtC,IAAiB,EAAA;AAEjB,IAAA,IAAI,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,SAAS;AAAE,QAAA,OAAO,IAAI;AACxD,IAAA,OAAO,cAAc,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,QAAQ,GAAG,SAAS;AACxD;AAEA;AACA,SAAS,kBAAkB,CAAC,IAAiB,EAAA;AAC3C,IA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AAA,CAAC,EAAE,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IACrB,OAAOA,GAAA,CAAC,eAAe,EAAA,EAAC,KAAK,EAAE,MAAa,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAmB;AAC5E;;;;"}
1
+ {"version":3,"file":"SectionComposition.js","sources":["../../../src/components/elements/SectionComposition.tsx"],"sourcesContent":["import { Button, EDIT_SECTIONS_LABEL } from \"@contentstack/studio-core\";\nimport { POST_MESSAGE_EVENTS } from \"@contentstack/studio-messenger/constants\";\nimport { composableStudioEventManager } from \"@contentstack/studio-messenger\";\nimport { COMPOSABLE_DATA_ATTRIBUTES } from \"@contentstack/studio-client\";\nimport { SectionCompositionProvider } from \"@contentstack/studio-react-components/basic-components\";\nimport {\n DataCtxProvider,\n DefaultChainCtx,\n} from \"@contentstack/studio-react-components/contexts\";\nimport {\n useCurrentNode,\n useData,\n} from \"@contentstack/studio-react-components/hooks\";\nimport { css } from \"goober\";\nimport { MouseEvent, useCallback, useContext, useMemo } from \"react\";\nimport { PreviewRenderer } from \"../PreviewRenderer\";\nimport { StudioAttributes } from \"../../types\";\nimport { styleFactory } from \"../styles\";\nimport { SectionModeContext } from \"../../contexts/providers/section-mode.provider\";\nimport { useDesignPreviewContext } from \"../../hooks/use-design-preview.hook\";\n\n// ─── Types ───────────────────────────────────────────────────────────────────\n\ninterface BindingValue {\n path?: Record<string, unknown>;\n [key: string]: unknown;\n}\n\nexport interface ExposedPropDef {\n uid: string;\n nodeUid: string;\n propKey: string;\n /** The binding the internal node had at expose-time (e.g. template.title).\n * SectionCompositionProvider uses this to know which field in the\n * section-scoped template to override. */\n bindingAtExposeTime?: { type: string; value: BindingValue };\n}\n\ntype SectionSpec = {\n compositionEntry?: {\n uid: string;\n };\n ui?: any;\n [key: string]: any;\n};\n\ninterface SectionCompositionProps extends StudioAttributes {\n spec: SectionSpec;\n compositionUID: string;\n className?: string;\n /** Per-placement design/preview mode from the placed node's `metadata.mode`. */\n mode?: \"design\" | \"preview\";\n [key: string]: any;\n}\n\n// ─── Helpers ─────────────────────────────────────────────────────────────────\n\n/** Whether the section's authored UI contains at least one section-slot. */\nfunction sectionHasSlot(ui: any): boolean {\n if (!ui || typeof ui !== \"object\") return false;\n if (ui.type === \"section-slot\") return true;\n const slots = ui.slots || {};\n for (const slotId of Object.keys(slots)) {\n for (const child of slots[slotId] || []) {\n if (sectionHasSlot(child)) return true;\n }\n }\n return false;\n}\n\n/**\n * Effective design/preview mode for a placed section. The placement's explicit\n * `metadata.mode` (passed as the `mode` prop) wins; otherwise derive from the\n * section's content — `design` if it has a section-slot (so its drop-zones stay\n * visible) else `preview`. Mirrors `deriveSectionMode` on the Studio side.\n */\nfunction resolveSectionMode(\n mode: \"design\" | \"preview\" | undefined,\n spec: SectionSpec,\n): \"design\" | \"preview\" {\n if (mode === \"design\" || mode === \"preview\") return mode;\n return sectionHasSlot(spec?.ui) ? \"design\" : \"preview\";\n}\n\n/** Reads sectionExposedProps from the section spec's UI metadata. */\nfunction getExposedPropDefs(spec: SectionSpec): ExposedPropDef[] {\n const compositionEntry = spec.compositionEntry as\n | { ui?: { metadata?: Record<string, unknown> } }\n | undefined;\n return (\n (compositionEntry?.ui?.metadata?.sectionExposedProps as\n | ExposedPropDef[]\n | undefined) ?? []\n );\n}\n\n/**\n * Builds a map of { [ep.uid]: resolvedValue } from the props that\n * retrievePropValue already resolved for the page-level section node.\n *\n * retrievePropValue resolves the bindings the page composer set on the section\n * node's exposed props (e.g. template.heroTitle) and spreads them onto this\n * component. The page node's binding is the SOLE source of truth for an exposed\n * prop, so we emit an entry for EVERY exposed prop — including cleared/empty\n * ones (value `undefined`/`\"\"`). That lets a cleared prop render its empty value\n * downstream instead of falling back to the section's internal binding.\n */\nfunction buildOverrideValues(\n exposedPropDefs: ExposedPropDef[],\n rest: Record<string, unknown>,\n): Record<string, unknown> {\n const overrides: Record<string, unknown> = {};\n for (const ep of exposedPropDefs) {\n overrides[ep.uid] = rest[ep.uid];\n }\n return overrides;\n}\n\n/**\n * Builds a map of { [ep.uid]: cslpTag } from the `$<ep.uid>` CSLP props\n * retrievePropValue resolved for the page-level section node. Forwarded to the\n * provider so an overridden exposed prop keeps its `data-cslp` edit tag — the\n * override short-circuits retrievePropValue before it would compute one, and\n * the page-level tag (e.g. blog_post.<entry>.<locale>.hero_card.title) is the\n * correct target for the edit overlay. `domProps` strips these `$`-keys from the\n * DOM spread, so capture them here first.\n */\nfunction buildOverrideCslp(\n exposedPropDefs: ExposedPropDef[],\n rest: Record<string, unknown>,\n): Record<string, unknown> {\n const cslp: Record<string, unknown> = {};\n for (const ep of exposedPropDefs) {\n cslp[ep.uid] = rest[`$${ep.uid}`];\n }\n return cslp;\n}\n\n// ─── Icon ────────────────────────────────────────────────────────────────────\n\nfunction StudioIcon() {\n return (\n <svg\n width=\"20\"\n height=\"20\"\n viewBox=\"0 0 20 20\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M2.5 5.37989C2.5 4.39075 3.36764 3.62971 4.34018 3.76578L4.96257 3.85287C8.30481 4.3205 11.6952 4.3205 15.0374 3.85287L15.6598 3.76579C16.6324 3.62971 17.5 4.39075 17.5 5.37989V12.1389C17.5 13.1281 16.6324 13.8891 15.6598 13.753L15.2334 13.6934C14.9921 13.6596 14.8236 13.4351 14.8571 13.192C14.8907 12.9489 15.1135 12.7792 15.3548 12.8129L15.7812 12.8726C16.2233 12.9345 16.6176 12.5885 16.6176 12.1389V5.37989C16.6176 4.93028 16.2233 4.58436 15.7812 4.64621L15.1588 4.73329C11.736 5.21219 8.26397 5.21219 4.84118 4.73329L4.2188 4.64621C3.77673 4.58436 3.38235 4.93028 3.38235 5.37989V12.1389C3.38235 12.5885 3.77673 12.9345 4.2188 12.8726L4.64519 12.8129C4.88653 12.7792 5.10934 12.9489 5.14286 13.192C5.17638 13.4351 5.00791 13.6596 4.76657 13.6934L4.34019 13.753C3.36764 13.8891 2.5 13.1281 2.5 12.1389V5.37989Z\"\n fill=\"#6C5CE7\"\n />\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M6.02941 9.0557C6.02941 8.64661 6.35861 8.31497 6.76471 8.31497H8.52941C8.9355 8.31497 9.26471 8.64661 9.26471 9.0557V10.801C9.26471 11.2101 8.9355 11.5418 8.52941 11.5418H6.76471C6.35861 11.5418 6.02941 11.2101 6.02941 10.801V9.0557ZM6.91176 9.20384V10.6529H8.38235V9.20384H6.91176Z\"\n fill=\"#6C5CE7\"\n />\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M10.1471 8.16682C10.1471 7.59409 10.6079 7.1298 11.1765 7.1298H13.5294C14.0979 7.1298 14.5588 7.59409 14.5588 8.16682V10.5047C14.5588 11.0775 14.0979 11.5418 13.5294 11.5418H11.1765C10.6079 11.5418 10.1471 11.0775 10.1471 10.5047V8.16682ZM11.1765 8.01868C11.0953 8.01868 11.0294 8.08501 11.0294 8.16682V10.5047C11.0294 10.5866 11.0953 10.6529 11.1765 10.6529H13.5294C13.6106 10.6529 13.6765 10.5866 13.6765 10.5047V8.16682C13.6765 8.08501 13.6106 8.01868 13.5294 8.01868H11.1765Z\"\n fill=\"#6C5CE7\"\n />\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M10 12.4306C10.5685 12.4306 11.0294 12.8949 11.0294 13.4677V15.838C11.0294 16.4107 10.5685 16.875 10 16.875H7.05882C6.49029 16.875 6.02941 16.4107 6.02941 15.838L6.02941 13.4677C6.02941 12.8949 6.49029 12.4306 7.05882 12.4306H10ZM10.1471 13.4677C10.1471 13.3858 10.0812 13.3195 10 13.3195H7.05882C6.97761 13.3195 6.91176 13.3858 6.91176 13.4677V15.838C6.91176 15.9198 6.97761 15.9861 7.05882 15.9861H10C10.0812 15.9861 10.1471 15.9198 10.1471 15.838V13.4677Z\"\n fill=\"#6C5CE7\"\n />\n <path\n d=\"M12.7134 12.9508C12.7104 12.902 12.7639 12.8707 12.8044 12.8976L14.6152 14.0966C14.6598 14.1261 14.6455 14.1954 14.5929 14.2045L13.6175 14.3742C13.6036 14.3766 13.5911 14.3839 13.5821 14.3948L12.9517 15.1636C12.9177 15.205 12.8509 15.1832 12.8476 15.1295L12.7134 12.9508Z\"\n fill=\"#6C5CE7\"\n />\n </svg>\n );\n}\n\n// ─── Component ───────────────────────────────────────────────────────────────\n\nexport function SectionComposition({\n spec,\n compositionUID,\n studioAttributes,\n className,\n mode,\n ...rest\n}: SectionCompositionProps) {\n const styles = styleFactory(css);\n const data = useData();\n // The page-side instance uid keys this section's per-instance scoped data\n // (section_scoped_data[instanceUid] — carries selectedField/parentRepeaterUID\n // for per-iteration re-scope). It is normally read from the builder node id in\n // `studioAttributes`, but the editor strips that attribute when a node renders\n // in PREVIEW mode (e.g. a section transcluded into a section-slot whose\n // enclosing placed section has Preview Mode on — see SectionSlot). Falling back\n // to the surrounding CurrentNodeContext keeps the instance identity (and thus\n // the correct scoped entry) intact in preview, so a slot-nested section still\n // binds to its per-iteration repeater item instead of the page root.\n const { currentNodeUid } = useCurrentNode();\n const instanceUid =\n studioAttributes?.[COMPOSABLE_DATA_ATTRIBUTES.ID] ?? currentNodeUid;\n\n // A single section-composition node renders ONCE PER ITERATION when wrapped\n // by an iterating ancestor Repeater (page-side OR section-internal). Each\n // render produces its own \"Edit Composition\" button — all pointing at the\n // same compositionUID. Show the button only when every ancestor Repeater is\n // at iteration 0 (or there are no iterating ancestors). This collapses the\n // N-button UI down to one without restructuring the render tree.\n //\n // The map contains only ancestor Repeaters because the editor's Repeater\n // spreads its new entry on top of the inherited map; siblings can't reach\n // this subtree through React context. Design-mode Repeaters don't push a\n // context entry at all, so they don't trigger the gate.\n const isFirstIteration = useMemo(() => {\n const repeaterMap = (data as any)?.dataSources?.repeater;\n if (!repeaterMap || typeof repeaterMap !== \"object\") return true;\n for (const uid of Object.keys(repeaterMap)) {\n const idx = repeaterMap[uid]?.index;\n if (typeof idx === \"number\" && idx !== 0) return false;\n }\n return true;\n }, [data]);\n\n // Mode for everything inside this section. The topmost mode node owns it: if\n // this section is itself inside a repeater/condition-block, that ancestor's\n // DesignPreviewContext (design|preview) wins, overriding the section's own\n // mode. Otherwise the section owns it — explicit placement value, else derived\n // from content. `none` = no enclosing mode node.\n const enclosingMode = useDesignPreviewContext();\n // A section nested inside another section's slot must follow the enclosing\n // section's mode too — not just an enclosing repeater's (COMS-1659). A\n // slot-bearing nested section derives `design`, so its own SectionModeContext\n // Provider (below) would clobber the inherited preview and freeze its data\n // Repeaters (they iterate only when useShouldShowDesign sees section preview).\n // Only PREVIEW cascades (design is not inherited); the enclosing-repeater path\n // still takes precedence, so the working repeater-context behavior is intact.\n const enclosingSectionMode = useContext(SectionModeContext);\n // Ancestor section chain on this render path (COMS-1659 cycle guard).\n const defaultChain = useContext(DefaultChainCtx);\n const sectionMode =\n enclosingMode === \"design\" || enclosingMode === \"preview\"\n ? enclosingMode\n : enclosingSectionMode === \"preview\"\n ? \"preview\"\n : resolveSectionMode(mode, spec);\n\n const handleEditClick = useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n event.preventDefault();\n event.stopPropagation();\n composableStudioEventManager?.send(\n POST_MESSAGE_EVENTS.OPEN_IN_COMPOSABLE_STUDIO_EVENT_MESSAGE,\n { compositionEntryUid: compositionUID, compositionQuery: null },\n );\n },\n [compositionUID],\n );\n\n // Definitions of which props are exposed (uid, bindingAtExposeTime, etc.)\n const exposedPropDefs = useMemo(() => getExposedPropDefs(spec), [spec]);\n\n // Map of { [ep.uid]: resolvedPageValue } — values already resolved by\n // retrievePropValue against the page's data context and spread into rest.\n const overrideValues = useMemo(\n () => buildOverrideValues(exposedPropDefs, rest),\n [\n exposedPropDefs,\n JSON.stringify(exposedPropDefs.map((ep) => rest[ep.uid])),\n ],\n );\n\n // Page composer's LIVE binding type per exposed prop (emitted by\n // retrievePropValue for section-composition nodes). Lets the provider tell an\n // untouched repeater seed from a real page-level override.\n const exposedBindingTypes = (rest.section_exposed_binding_types ??\n {}) as Record<string, string>;\n // Which exposed props are still auto-seeded (untouched) — those defer to the\n // section's internal binding so they follow schema switches / repeater context.\n const exposedAutoSeeded = (rest.section_exposed_auto_seeded ?? {}) as Record<\n string,\n boolean\n >;\n // Map of { [ep.uid]: cslpTag } — the page-resolved `$<ep.uid>` tags, forwarded\n // so overridden exposed props keep their live-preview edit tag.\n const overrideCslp = useMemo(\n () => buildOverrideCslp(exposedPropDefs, rest),\n [\n exposedPropDefs,\n JSON.stringify(exposedPropDefs.map((ep) => rest[`$${ep.uid}`])),\n ],\n );\n\n // Exclude exposed prop keys and their $-prefixed CSLP counterparts from DOM\n // spread. retrievePropValue adds both `uid` (resolved value) and `$uid` (CSLP\n // live-preview tag) to the resolved props — both are invalid as div attributes.\n const domProps = useMemo(() => {\n const excluded = new Set([\n ...exposedPropDefs.flatMap((ep) => [ep.uid, `$${ep.uid}`]),\n \"section_exposed_binding_types\",\n \"section_exposed_auto_seeded\",\n ]);\n return Object.fromEntries(\n Object.entries(rest).filter(([k]) => !excluded.has(k)),\n );\n }, [exposedPropDefs, rest]);\n\n // Keep the section instance's id on its host even in PREVIEW mode, where the\n // editor (Element) strips builder attributes from slot children. The id alone\n // carries no selection affordance — interaction is driven by the\n // ELEMENT_TO_NODE map the builder ref populates, which preview omits — but it\n // preserves the per-instance DOM identity the \"Edit Composition\" button is\n // scoped under and keeps a stable hook for each placed section.\n const instanceIdAttr = instanceUid\n ? { [COMPOSABLE_DATA_ATTRIBUTES.ID]: instanceUid }\n : {};\n\n // Cycle guard (COMS-1659): if this section's compositionUID is already an\n // ancestor on the path, a slot-default chain loops back on itself\n // (A→B→…→A). Render nothing to cut the back-edge — terminates at the first\n // repeat, no fetch, safe even for cycles saved directly via the CMA.\n if (compositionUID && defaultChain.has(compositionUID)) return null;\n\n return (\n <DefaultChainCtx.Provider\n value={new Set([...defaultChain, compositionUID])}\n >\n <div\n {...domProps}\n {...instanceIdAttr}\n {...studioAttributes}\n className={[styles.embeddedSectionHost, className]\n .filter(Boolean)\n .join(\" \")}\n >\n {isFirstIteration && (\n <Button\n className={`cs-embedded-section-edit-btn ${styles.embeddedSectionButton}`}\n onClick={handleEditClick}\n type=\"button\"\n data-studio-ui={true}\n >\n <StudioIcon />\n {EDIT_SECTIONS_LABEL}\n </Button>\n )}\n\n {/*\n * exposedPropDefs + overrideValues are forwarded to the provider so it\n * can inject the page-composer's override values into the section-scoped\n * template before the internal UI tree renders.\n */}\n <SectionModeContext.Provider value={sectionMode}>\n <SectionCompositionProvider\n uid={compositionUID}\n instanceUid={instanceUid}\n exposedPropDefs={exposedPropDefs}\n overrideValues={overrideValues}\n exposedBindingTypes={exposedBindingTypes}\n exposedAutoSeeded={exposedAutoSeeded}\n overrideCslp={overrideCslp}\n >\n <SectionDataMerger spec={spec}>\n <PreviewRenderer spec={spec as any} />\n </SectionDataMerger>\n </SectionCompositionProvider>\n </SectionModeContext.Provider>\n </div>\n </DefaultChainCtx.Provider>\n );\n}\n\n/**\n * Merges the section's own `spec.data.static_value` into the active data\n * context so static-value-bound props authored inside the section (e.g. a\n * SectionSlot's `label`, or any Text/Number/etc. inside the section's body)\n * resolve against the section's persisted values when the section is\n * consumed in a page. Without this, child Elements call useData() and get\n * the page's data, which doesn't contain the section's static_value keys.\n */\nfunction SectionDataMerger({\n spec,\n children,\n}: {\n spec: SectionSpec;\n children: React.ReactNode;\n}) {\n const outerData = useData();\n const merged = useMemo(() => {\n const sectionStatic = (spec as any)?.data?.static_value;\n if (!sectionStatic || typeof sectionStatic !== \"object\") return outerData;\n return {\n ...(outerData as any),\n static_value: {\n ...((outerData as any)?.static_value || {}),\n ...sectionStatic,\n },\n };\n }, [outerData, spec]);\n return <DataCtxProvider value={merged as any}>{children}</DataCtxProvider>;\n}\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;;;;;AAuDA;AAEA;AACA,SAAS,cAAc,CAAC,EAAO,EAAA;AAC7B,IAAA,IAAI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