@contentstack/studio-react-editor 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/BuildingIllustration.js +8 -0
- package/dist/components/BuildingIllustration.js.map +1 -0
- package/dist/components/EditableRenderer.js +29 -6
- package/dist/components/EditableRenderer.js.map +1 -1
- package/dist/components/Element.js +52 -25
- package/dist/components/Element.js.map +1 -1
- package/dist/components/PreviewRenderer.js +4 -0
- package/dist/components/PreviewRenderer.js.map +1 -1
- package/dist/components/Slot.js +26 -4
- package/dist/components/Slot.js.map +1 -1
- package/dist/components/WelcomeState.js +33 -0
- package/dist/components/WelcomeState.js.map +1 -0
- package/dist/components/elements/ConditionBlock.js +4 -0
- package/dist/components/elements/ConditionBlock.js.map +1 -1
- package/dist/components/elements/Repeater.js +8 -38
- package/dist/components/elements/Repeater.js.map +1 -1
- package/dist/components/elements/SectionComposition.js +94 -0
- package/dist/components/elements/SectionComposition.js.map +1 -0
- package/dist/components/elements/SectionSlot.js +154 -0
- package/dist/components/elements/SectionSlot.js.map +1 -0
- package/dist/components/elements/Symbol.js +6 -2
- package/dist/components/elements/Symbol.js.map +1 -1
- package/dist/components/styles.js +72 -0
- package/dist/components/styles.js.map +1 -1
- package/dist/contexts/providers/renderer.provider.js +1 -0
- package/dist/contexts/providers/renderer.provider.js.map +1 -1
- package/dist/contexts/providers/symbol-ui.provider.js +18 -6
- package/dist/contexts/providers/symbol-ui.provider.js.map +1 -1
- package/dist/hooks/use-active-node-path.hook.js +5 -1
- package/dist/hooks/use-active-node-path.hook.js.map +1 -1
- package/dist/hooks/use-canvas-events.hook.js +5 -2
- package/dist/hooks/use-canvas-events.hook.js.map +1 -1
- package/dist/hooks/use-condition-block-context.js +5 -1
- package/dist/hooks/use-condition-block-context.js.map +1 -1
- package/dist/hooks/use-design-preview.hook.js +5 -1
- package/dist/hooks/use-design-preview.hook.js.map +1 -1
- package/dist/hooks/use-preview-mode.hook.js +5 -1
- package/dist/hooks/use-preview-mode.hook.js.map +1 -1
- package/dist/hooks/use-register-section.hook.js +110 -0
- package/dist/hooks/use-register-section.hook.js.map +1 -0
- package/dist/hooks/use-renderer.hook.js +5 -1
- package/dist/hooks/use-renderer.hook.js.map +1 -1
- package/dist/hooks/use-repeater.hook.js +5 -1
- package/dist/hooks/use-repeater.hook.js.map +1 -1
- package/dist/hooks/use-section-events.hook.js +63 -0
- package/dist/hooks/use-section-events.hook.js.map +1 -0
- package/dist/hooks/use-should-show-design.hook.js +8 -1
- package/dist/hooks/use-should-show-design.hook.js.map +1 -1
- package/dist/hooks/use-spec-data-listener.hook.js +335 -10
- package/dist/hooks/use-spec-data-listener.hook.js.map +1 -1
- package/dist/hooks/use-symbol-events.hook.js +13 -0
- package/dist/hooks/use-symbol-events.hook.js.map +1 -1
- package/package.json +10 -10
|
@@ -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 { CurrentNodeContext } from \"@contentstack/studio-react-components/contexts\";\nimport {\n useCurrentNode,\n useData,\n} from \"@contentstack/studio-react-components/hooks\";\nimport {\n getBindingString,\n getCslpTag,\n getRepeaterBinding,\n GetSlotsParams,\n resolveMetadataBindings,\n retrievePropValue,\n INTERNAL_COMPONENTS_NAMES,\n ComponentRegistry,\n} from \"@contentstack/studio-registry\";\nimport classNames from \"classnames\";\nimport { memo, RefCallback, useCallback, useEffect, useRef } from \"react\";\nimport { BuilderNodeInternalAttributes, StudioComponentRef } from \"../types\";\nimport { RendererErrorComponent } from \"./ErrorComponent\";\nimport { TextPlaceholder } from \"./TextPlaceholder\";\nimport { RendererErrorBoundary } from \"./RendererErrorBoundary\";\nimport { shouldRenderSlot } from \"../utils\";\nimport Slot from \"./Slot\";\nimport { usePreviewMode, useRenderer } from \"../hooks\";\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 data = useData();\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 // TODO: link to the documentation\n console.error(\n \"Open method is not available on the reference. Please check the documentation for more details.\",\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 // TODO: link to the documentation\n console.error(\n \"Close method is not available on the reference. Please check the documentation for more details.\",\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 if (!componentRegistry) {\n return <RendererErrorComponent reason=\"SDK is not initialized\" />;\n }\n let internalAttributes: BuilderNodeInternalAttributes = {};\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 // 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 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 = 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 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 const componentClass = classNames(\n resolvedProps.className,\n defaultResponsiveClass,\n attrs.className,\n );\n\n const attrsWithResponsiveClass = {\n ...attrs,\n ...namedResponsiveClasses,\n className: componentClass,\n };\n\n const WrapTag =\n typeof componentOptions.wrap === \"string\"\n ? componentOptions.wrap || \"div\"\n : \"div\";\n if (componentOptions.wrap) {\n return (\n <RendererErrorBoundary renderError={renderError}>\n <WrapTag {...internalAttributes}>\n <Component {...attrsWithResponsiveClass} {...resolvedProps} />\n </WrapTag>\n </RendererErrorBoundary>\n );\n }\n return (\n <RendererErrorBoundary renderError={renderError}>\n <Component\n studioAttributes={internalAttributes}\n {...attrsWithResponsiveClass}\n {...resolvedProps}\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\nconst VisualComponent = ({\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 { isCompositionBeingEdited, componentRegistry } = useRenderer();\n const { currentNodePath: parentNodePath = [] } = 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 const currentNodePath: Path = [...parentNodePath, [slotUid, idx]];\n\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 <CurrentNodeContext.Provider\n key={key}\n value={{\n currentNodeUid: key,\n currentNodePath: currentNodePath,\n }}\n >\n <SelectedNodeProvider>\n <Element\n key={key}\n node={node}\n renderError={renderError}\n dataCslp={dataCslp}\n />\n </SelectedNodeProvider>\n </CurrentNodeContext.Provider>\n );\n });\n\n return <>{children}</>;\n }\n\n // Compute hint for repeater slots bound to modular blocks or references\n const hint =\n parent.type === INTERNAL_COMPONENTS_NAMES.REPEATER &&\n parent.metadata?.repeaterBindingFieldType\n ? \"It is recommended to drop a condition block inside the repeater to handle Modular Blocks & References.\"\n : undefined;\n\n if (!isCompositionBeingEdited || isPreviewMode) {\n return <Slot studioAttributes={{}} slotUid={slotUid} hint={hint} />;\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 studioAttributes={internalAttributes} slotUid={slotUid} hint={hint} />\n );\n};\n\nexport default MemoizedElement;\n"],"names":["_jsx","_Fragment"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,MAAM,OAAO,GAAG,CAAC,EACf,IAAI,EACJ,WAAW,EACX,QAAQ,GAKT,KAAqB;AACpB,IAAA,MAAM,aAAa,GAAG,cAAc,EAAE;AACtC,IAAA,MAAM,IAAI,GAAG,OAAO,EAAE;AACtB,IAAA,MAAM,EAAE,KAAK,GAAG,EAAE,EAAE,MAAM,GAAG,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI;IAC7C,MAAM,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,GAAG,WAAW,EAAE;AACrE,IAAA,uBAAuB,CAAC,IAAI,EAAE,IAAI,CAAC;AACnC,IAAA,MAAM,SAAS,GAAG,MAAM,CAAqB,IAAI,CAAC;;IAGlD,SAAS,CAAC,MAAK;AACb,QAAA,MAAM,sCAAsC,GAAG,CAC7C,IAAwC,KACtC;AACF,YAAA,IAAI,CAAC,wBAAwB;gBAAE;AAE/B,YAAA,IAAI,IAAI,CAAC,GAAG,KAAK,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,KAAK,SAAS;gBAAE;AAErD,YAAA,IAAI,SAAS,CAAC,OAAO,EAAE;AACrB,gBAAA,IAAI,IAAI,CAAC,MAAM,KAAK,MAAM,EAAE;AAC1B,oBAAA,IACE,MAAM,IAAI,SAAS,CAAC,OAAO;wBAC3B,OAAO,SAAS,CAAC,OAAO,CAAC,IAAI,KAAK,UAAU,EAC5C;AACA,w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AAE;UACA,SAAS;AAEf,IAAA,IAAI,CAAC,wBAAwB,IAAI,aAAa,EAAE;AAC9C,QAAA,OAAOD,GAAA,CAAC,IAAI,EAAA,EAAC,gBAAgB,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,GAAI;IACrE;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;AACD,IAAA,QACEA,GAAA,CAAC,IAAI,EAAA,EAAC,gBAAgB,EAAE,kBAAkB,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAA,CAAI;AAEhF,CAAC;;;;"}
|
|
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} from \"@contentstack/studio-react-components/hooks\";\nimport {\n getBindingString,\n getCslpTag,\n getRepeaterBinding,\n GetSlotsParams,\n resolveMetadataBindings,\n retrievePropValue,\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 useRef,\n} from \"react\";\nimport { BuilderNodeInternalAttributes, StudioComponentRef } from \"../types\";\nimport { RendererErrorComponent } from \"./ErrorComponent\";\nimport { TextPlaceholder } from \"./TextPlaceholder\";\nimport { RendererErrorBoundary } from \"./RendererErrorBoundary\";\nimport { shouldRenderSlot } from \"../utils\";\nimport Slot from \"./Slot\";\nimport { usePreviewMode, useRenderer } from \"../hooks\";\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 data = useData();\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 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 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 = 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 const componentClass = classNames(\n resolvedProps.className,\n defaultResponsiveClass,\n attrs.className,\n );\n\n const attrsWithResponsiveClass = {\n ...attrs,\n ...namedResponsiveClasses,\n className: componentClass,\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\nconst VisualComponent = ({\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 { isCompositionBeingEdited, componentRegistry, compositionPlacement } =\n useRenderer();\n const { currentNodePath: parentNodePath = [] } = 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 const currentNodePath: Path = [...parentNodePath, [slotUid, idx]];\n\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 <CurrentNodeContext.Provider\n key={key}\n value={{\n currentNodeUid: key,\n currentNodePath: currentNodePath,\n }}\n >\n <SelectedNodeProvider>\n <Element\n key={key}\n node={node}\n renderError={renderError}\n dataCslp={dataCslp}\n />\n </SelectedNodeProvider>\n </CurrentNodeContext.Provider>\n );\n });\n\n return <>{children}</>;\n }\n\n // Compute hint for repeater slots bound to modular blocks or references\n const hint =\n parent.type === INTERNAL_COMPONENTS_NAMES.REPEATER &&\n parent.metadata?.repeaterBindingFieldType\n ? \"It is recommended to drop a condition block inside the repeater to handle Modular Blocks & References.\"\n : undefined;\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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A,CAAC,CAAC;QAEF,OAAOA,GAAA,CAAAC,QAAA,EAAA,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAI;IACxB;;IAGA,MAAM,IAAI,GACR,MAAM,CAAC,IAAI,KAAK,yBAAyB,CAAC,QAAQ;QAClD,MAAM,CAAC,QAAQ,EAAE;AACf,UAAE;UACA,SAAS;;IAGf,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,KAAK,yBAAyB,CAAC,IAAI;AAEjE,IAAA,IAAI,CAAC,wBAAwB,IAAI,aAAa,EAAE;QAC9C,QACED,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;;;;"}
|
|
@@ -7,7 +7,11 @@ import '@contentstack/studio-messenger';
|
|
|
7
7
|
import '@contentstack/studio-react-components/contexts';
|
|
8
8
|
import 'immer';
|
|
9
9
|
import 'react';
|
|
10
|
+
import '@contentstack/studio-internal';
|
|
11
|
+
import '@contentstack/studio-core';
|
|
12
|
+
import '@contentstack/studio-react-components/basic-components';
|
|
10
13
|
import '@contentstack/studio-react-components/hooks';
|
|
14
|
+
import 'goober';
|
|
11
15
|
import '@contentstack/studio-registry';
|
|
12
16
|
import '../contexts/providers/use-design-preview.provider.js';
|
|
13
17
|
import '../contexts/providers/use-repeater.provider.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PreviewRenderer.js","sources":["../../src/components/PreviewRenderer.tsx"],"sourcesContent":["import { StudioSpec } from \"@contentstack/studio-client\";\nimport { ComposableStudioData } from \"@contentstack/studio-registry\";\nimport Element from \"./Element\";\nimport { PreviewModeContext } from \"../contexts/providers\";\n\nexport interface StudioComponentLiteProps {\n spec: Omit<StudioSpec, \"compositionEntry\">;\n data?: ComposableStudioData[\"component_props\"];\n}\n\nexport function PreviewRenderer(props: StudioComponentLiteProps) {\n const { spec } = props;\n return (\n <PreviewModeContext.Provider value={true}>\n <Element node={spec.ui} />\n </PreviewModeContext.Provider>\n );\n}\n"],"names":["_jsx","Element"],"mappings":"
|
|
1
|
+
{"version":3,"file":"PreviewRenderer.js","sources":["../../src/components/PreviewRenderer.tsx"],"sourcesContent":["import { StudioSpec } from \"@contentstack/studio-client\";\nimport { ComposableStudioData } from \"@contentstack/studio-registry\";\nimport Element from \"./Element\";\nimport { PreviewModeContext } from \"../contexts/providers\";\n\nexport interface StudioComponentLiteProps {\n spec: Omit<StudioSpec, \"compositionEntry\">;\n data?: ComposableStudioData[\"component_props\"];\n}\n\nexport function PreviewRenderer(props: StudioComponentLiteProps) {\n const { spec } = props;\n\n return (\n <PreviewModeContext.Provider value={true}>\n <Element node={spec.ui} />\n </PreviewModeContext.Provider>\n );\n}\n"],"names":["_jsx","Element"],"mappings":";;;;;;;;;;;;;;;;;;;;AAUM,SAAU,eAAe,CAAC,KAA+B,EAAA;AAC7D,IAAA,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK;IAEtB,QACEA,IAAC,kBAAkB,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,IAAI,EAAA,QAAA,EACtCA,IAACC,eAAO,EAAA,EAAC,IAAI,EAAE,IAAI,CAAC,EAAE,EAAA,CAAI,EAAA,CACE;AAElC;;;;"}
|
package/dist/components/Slot.js
CHANGED
|
@@ -1,10 +1,21 @@
|
|
|
1
|
-
import { jsxs,
|
|
2
|
-
import { COMPOSABLE_DATA_ATTRIBUTES } from '@contentstack/studio-client';
|
|
1
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { COMPOSABLE_DATA_ATTRIBUTES, COMPOSITION_PLACEMENT_OPTIONS } from '@contentstack/studio-client';
|
|
3
|
+
import { SectionInstanceSlotsCtx } from '@contentstack/studio-react-components/contexts';
|
|
3
4
|
import { css } from 'goober';
|
|
5
|
+
import { useContext } from 'react';
|
|
4
6
|
import { styleFactory } from './styles.js';
|
|
7
|
+
import { WelcomeState } from './WelcomeState.js';
|
|
5
8
|
import classNames from 'classnames';
|
|
6
9
|
|
|
7
|
-
function Slot({ studioAttributes, slotUid, hint }) {
|
|
10
|
+
function Slot({ studioAttributes, slotUid, hint, isRootSlot = false, compositionPlacement, }) {
|
|
11
|
+
// When a section is consumed inside another composition, only the section's
|
|
12
|
+
// exposed `section-slot` placeholders are intended to be filled by the page
|
|
13
|
+
// composer — the section's own internal Box/Row/Column slots are part of
|
|
14
|
+
// its authored body and should NOT surface as page-level drop targets.
|
|
15
|
+
// Suppress the drop UI for those internal slots in consumption mode.
|
|
16
|
+
const inSectionConsumption = useContext(SectionInstanceSlotsCtx);
|
|
17
|
+
if (inSectionConsumption)
|
|
18
|
+
return null;
|
|
8
19
|
const attributes = {
|
|
9
20
|
[COMPOSABLE_DATA_ATTRIBUTES.SLOT]: true,
|
|
10
21
|
[COMPOSABLE_DATA_ATTRIBUTES.SLOT_UID]: slotUid,
|
|
@@ -13,7 +24,18 @@ function Slot({ studioAttributes, slotUid, hint }) {
|
|
|
13
24
|
const slotClassName = classNames(styles.slotStyle, {
|
|
14
25
|
[styles.slotColumnStyle]: hint,
|
|
15
26
|
});
|
|
16
|
-
|
|
27
|
+
// Render welcome state for root slots
|
|
28
|
+
const renderWelcomeState = () => {
|
|
29
|
+
if (!isRootSlot)
|
|
30
|
+
return null;
|
|
31
|
+
// Handle undefined, null, and empty string by defaulting to PAGE (backward compatibility)
|
|
32
|
+
const placement = !compositionPlacement || compositionPlacement === ""
|
|
33
|
+
? COMPOSITION_PLACEMENT_OPTIONS.PAGE
|
|
34
|
+
: compositionPlacement;
|
|
35
|
+
return jsx(WelcomeState, { compositionPlacement: placement });
|
|
36
|
+
};
|
|
37
|
+
const welcomeState = renderWelcomeState();
|
|
38
|
+
return (jsx("div", { ...attributes, className: slotClassName, ...studioAttributes, children: welcomeState ? (welcomeState) : (jsxs(Fragment, { children: [jsxs("span", { className: styles.slotDropText, children: [jsx(AddIcon, {}), " Drop Here"] }), hint && jsxs("p", { className: styles.slotHintStyle, children: ["(", hint, ")"] })] })) }));
|
|
17
39
|
}
|
|
18
40
|
const AddIcon = () => {
|
|
19
41
|
return (jsxs("svg", { width: "22", height: "22", viewBox: "0 0 22 22", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsx("rect", { x: "0.5", y: "0.5", width: "21", height: "21", rx: "4.5", fill: "white" }), jsx("rect", { x: "0.5", y: "0.5", width: "21", height: "21", rx: "4.5", stroke: "#475161" }), jsx("path", { d: "M11.2808 6.78125C11.2808 6.62592 11.1548 6.5 10.9995 6.5C10.8442 6.5 10.7183 6.62592 10.7183 6.78125V10.7184H6.78125C6.62592 10.7184 6.5 10.8443 6.5 10.9996C6.5 11.155 6.62592 11.2809 6.78125 11.2809H10.7183V15.218C10.7183 15.3733 10.8442 15.4993 10.9995 15.4993C11.1548 15.4993 11.2808 15.3733 11.2808 15.218V11.2809H15.218C15.3733 11.2809 15.4993 11.155 15.4993 10.9996C15.4993 10.8443 15.3733 10.7184 15.218 10.7184H11.2808V6.78125Z", fill: "#475161" })] }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Slot.js","sources":["../../src/components/Slot.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"Slot.js","sources":["../../src/components/Slot.tsx"],"sourcesContent":["import {\n COMPOSABLE_DATA_ATTRIBUTES,\n type CompositionPlacement,\n COMPOSITION_PLACEMENT_OPTIONS,\n} from \"@contentstack/studio-client\";\nimport { SectionInstanceSlotsCtx } from \"@contentstack/studio-react-components/contexts\";\nimport { css } from \"goober\";\nimport { useContext } from \"react\";\nimport { styleFactory } from \"./styles\";\nimport { StudioAttributes } from \"../types/renderer.type\";\nimport { WelcomeState } from \"./WelcomeState\";\nimport classNames from \"classnames\";\n\ninterface SlotProps extends StudioAttributes {\n slotUid: string;\n hint?: string;\n isRootSlot?: boolean;\n compositionPlacement?: CompositionPlacement;\n}\n\nexport default function Slot({\n studioAttributes,\n slotUid,\n hint,\n isRootSlot = false,\n compositionPlacement,\n}: SlotProps) {\n // When a section is consumed inside another composition, only the section's\n // exposed `section-slot` placeholders are intended to be filled by the page\n // composer — the section's own internal Box/Row/Column slots are part of\n // its authored body and should NOT surface as page-level drop targets.\n // Suppress the drop UI for those internal slots in consumption mode.\n const inSectionConsumption = useContext(SectionInstanceSlotsCtx);\n if (inSectionConsumption) return null;\n\n const attributes = {\n [COMPOSABLE_DATA_ATTRIBUTES.SLOT]: true,\n [COMPOSABLE_DATA_ATTRIBUTES.SLOT_UID]: slotUid,\n };\n const styles = styleFactory(css);\n const slotClassName = classNames(styles.slotStyle, {\n [styles.slotColumnStyle]: hint,\n });\n\n // Render welcome state for root slots\n const renderWelcomeState = () => {\n if (!isRootSlot) return null;\n\n // Handle undefined, null, and empty string by defaulting to PAGE (backward compatibility)\n const placement =\n !compositionPlacement || (compositionPlacement as string) === \"\"\n ? COMPOSITION_PLACEMENT_OPTIONS.PAGE\n : compositionPlacement;\n\n return <WelcomeState compositionPlacement={placement} />;\n };\n\n const welcomeState = renderWelcomeState();\n\n return (\n <div {...attributes} className={slotClassName} {...studioAttributes}>\n {welcomeState ? (\n welcomeState\n ) : (\n <>\n <span className={styles.slotDropText}>\n <AddIcon /> Drop Here\n </span>\n {hint && <p className={styles.slotHintStyle}>({hint})</p>}\n </>\n )}\n </div>\n );\n}\n\nconst AddIcon: React.FC = () => {\n return (\n <svg\n width=\"22\"\n height=\"22\"\n viewBox=\"0 0 22 22\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <rect x=\"0.5\" y=\"0.5\" width=\"21\" height=\"21\" rx=\"4.5\" fill=\"white\" />\n <rect x=\"0.5\" y=\"0.5\" width=\"21\" height=\"21\" rx=\"4.5\" stroke=\"#475161\" />\n <path\n d=\"M11.2808 6.78125C11.2808 6.62592 11.1548 6.5 10.9995 6.5C10.8442 6.5 10.7183 6.62592 10.7183 6.78125V10.7184H6.78125C6.62592 10.7184 6.5 10.8443 6.5 10.9996C6.5 11.155 6.62592 11.2809 6.78125 11.2809H10.7183V15.218C10.7183 15.3733 10.8442 15.4993 10.9995 15.4993C11.1548 15.4993 11.2808 15.3733 11.2808 15.218V11.2809H15.218C15.3733 11.2809 15.4993 11.155 15.4993 10.9996C15.4993 10.8443 15.3733 10.7184 15.218 10.7184H11.2808V6.78125Z\"\n fill=\"#475161\"\n />\n </svg>\n );\n};\n"],"names":["_jsx","_jsxs","_Fragment"],"mappings":";;;;;;;;;AAoBc,SAAU,IAAI,CAAC,EAC3B,gBAAgB,EAChB,OAAO,EACP,IAAI,EACJ,UAAU,GAAG,KAAK,EAClB,oBAAoB,GACV,EAAA;;;;;;AAMV,IAAA,MAAM,oBAAoB,GAAG,UAAU,CAAC,uBAAuB,CAAC;AAChE,IAAA,IAAI,oBAAoB;AAAE,QAAA,OAAO,IAAI;AAErC,IAAA,MAAM,UAAU,GAAG;AACjB,QAAA,CAAC,0BAA0B,CAAC,IAAI,GAAG,IAAI;AACvC,QAAA,CAAC,0BAA0B,CAAC,QAAQ,GAAG,OAAO;KAC/C;AACD,IAAA,MAAM,MAAM,GAAG,YAAY,CAAC,GAAG,CAAC;AAChC,IAAA,MAAM,aAAa,GAAG,UAAU,CAAC,MAAM,CAAC,SAAS,EAAE;AACjD,QAAA,CAAC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EA,GAAA,CAAA,MAAA,EAAA,EAAM,CAAC,EAAC,KAAK,EAAC,CAAC,EAAC,KAAK,EAAC,KAAK,EAAC,IAAI,EAAC,MAAM,EAAC,IAAI,EAAC,EAAE,EAAC,KAAK,EAAC,MAAM,EAAC,SAAS,GAAG,EACzEA,GAAA,CAAA,MAAA,EAAA,EACE,CAAC,EAAC,qbAAqb,EACvb,IAAI,EAAC,SAAS,EAAA,CACd,CAAA,EAAA,CACE;AAEV,CAAC;;;;"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { COMPOSITION_PLACEMENT_OPTIONS } from '@contentstack/studio-client';
|
|
3
|
+
import { css } from 'goober';
|
|
4
|
+
import { styleFactory } from './styles.js';
|
|
5
|
+
import { BuildingIllustration } from './BuildingIllustration.js';
|
|
6
|
+
import classNames from 'classnames';
|
|
7
|
+
|
|
8
|
+
const getWelcomeContent = (placement) => {
|
|
9
|
+
if (placement === COMPOSITION_PLACEMENT_OPTIONS.PAGE) {
|
|
10
|
+
return {
|
|
11
|
+
title: "Start Building Template",
|
|
12
|
+
subtitle: "Add components and bind data to complete your setup.",
|
|
13
|
+
step1Description: "Drag and drop components from the LHS components panel to create your design.",
|
|
14
|
+
step2Description: "Bind structured data or pin flexible content to your components.",
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
return {
|
|
19
|
+
title: "Start Building Section",
|
|
20
|
+
subtitle: "Add components and bind data to complete your section setup.",
|
|
21
|
+
step1Description: "Drag and drop components from the LHS components panel to create your section design.",
|
|
22
|
+
step2Description: "Connect a schema for structured content or pin data for flexible use.",
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const WelcomeState = ({ compositionPlacement, }) => {
|
|
27
|
+
const content = getWelcomeContent(compositionPlacement);
|
|
28
|
+
const styles = styleFactory(css);
|
|
29
|
+
return (jsxs("div", { className: styles.welcomeContainer, children: [jsx(BuildingIllustration, {}), jsx("h2", { className: styles.welcomeTitle, children: content.title }), jsx("p", { className: styles.welcomeSubtitle, children: content.subtitle }), jsxs("div", { className: styles.welcomeSteps, children: [jsxs("div", { className: classNames(styles.welcomeStep, styles.activeWelcomeStep), children: [jsx("h3", { children: "Step 1: Add components to canvas" }), jsx("p", { children: content.step1Description })] }), jsxs("div", { className: styles.welcomeStep, children: [jsx("h3", { children: "Step 2: Connect a schema or pin data" }), jsx("p", { children: content.step2Description })] })] })] }));
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { WelcomeState };
|
|
33
|
+
//# sourceMappingURL=WelcomeState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WelcomeState.js","sources":["../../src/components/WelcomeState.tsx"],"sourcesContent":["import React from \"react\";\nimport {\n type CompositionPlacement,\n COMPOSITION_PLACEMENT_OPTIONS,\n} from \"@contentstack/studio-client\";\nimport { css } from \"goober\";\nimport { styleFactory } from \"./styles\";\nimport { BuildingIllustration } from \"./BuildingIllustration\";\nimport classNames from \"classnames\";\n\ninterface WelcomeStateProps {\n compositionPlacement: CompositionPlacement;\n}\n\ninterface WelcomeContent {\n title: string;\n subtitle: string;\n step1Description: string;\n step2Description: string;\n}\n\nconst getWelcomeContent = (placement: CompositionPlacement): WelcomeContent => {\n if (placement === COMPOSITION_PLACEMENT_OPTIONS.PAGE) {\n return {\n title: \"Start Building Template\",\n subtitle: \"Add components and bind data to complete your setup.\",\n step1Description:\n \"Drag and drop components from the LHS components panel to create your design.\",\n step2Description:\n \"Bind structured data or pin flexible content to your components.\",\n };\n } else {\n return {\n title: \"Start Building Section\",\n subtitle: \"Add components and bind data to complete your section setup.\",\n step1Description:\n \"Drag and drop components from the LHS components panel to create your section design.\",\n step2Description:\n \"Connect a schema for structured content or pin data for flexible use.\",\n };\n }\n};\n\nexport const WelcomeState: React.FC<WelcomeStateProps> = ({\n compositionPlacement,\n}) => {\n const content = getWelcomeContent(compositionPlacement);\n const styles = styleFactory(css);\n\n return (\n <div className={styles.welcomeContainer}>\n <BuildingIllustration />\n <h2 className={styles.welcomeTitle}>{content.title}</h2>\n <p className={styles.welcomeSubtitle}>{content.subtitle}</p>\n <div className={styles.welcomeSteps}>\n <div\n className={classNames(styles.welcomeStep, styles.activeWelcomeStep)}\n >\n <h3>Step 1: Add components to canvas</h3>\n <p>{content.step1Description}</p>\n </div>\n <div className={styles.welcomeStep}>\n <h3>Step 2: Connect a schema or pin data</h3>\n <p>{content.step2Description}</p>\n </div>\n </div>\n </div>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;AAqBA,MAAM,iBAAiB,GAAG,CAAC,SAA+B,KAAoB;AAC5E,IAAA,IAAI,SAAS,KAAK,6BAA6B,CAAC,IAAI,EAAE;QACpD,OAAO;AACL,YAAA,KAAK,EAAE,yBAAyB;AAChC,YAAA,QAAQ,EAAE,sDAAsD;AAChE,YAAA,gBAAgB,EACd,+EAA+E;AACjF,YAAA,gBAAgB,EACd,kEAAkE;SACrE;IACH;SAAO;QACL,OAAO;AACL,YAAA,KAAK,EAAE,wBAAwB;AAC/B,YAAA,QAAQ,EAAE,8DAA8D;AACxE,YAAA,gBAAgB,EACd,uFAAuF;AACzF,YAAA,gBAAgB,EACd,uEAAuE;SAC1E;IACH;AACF,CAAC;MAEY,YAAY,GAAgC,CAAC,EACxD,oBAAoB,GACrB,KAAI;AACH,IAAA,MAAM,OAAO,GAAG,iBAAiB,CAAC,oBAAoB,CAAC;AACvD,IAAA,MAAM,MAAM,GAAG,YAAY,CAAC,GAAG,CAAC;AAEhC,IAAA,QACEA,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,MAAM,CAAC,gBAAgB,EAAA,QAAA,EAAA,CACrCC,GAAA,CAAC,oBAAoB,EAAA,EAAA,CAAG,EACxBA,GAAA,CAAA,IAAA,EAAA,EAAI,SAAS,EAAE,MAAM,CAAC,YAAY,EAAA,QAAA,EAAG,OAAO,CAAC,KAAK,GAAM,EACxDA,GAAA,CAAA,GAAA,EAAA,EAAG,SAAS,EAAE,MAAM,CAAC,eAAe,EAAA,QAAA,EAAG,OAAO,CAAC,QAAQ,EAAA,CAAK,EAC5DD,cAAK,SAAS,EAAE,MAAM,CAAC,YAAY,EAAA,QAAA,EAAA,CACjCA,IAAA,CAAA,KAAA,EAAA,EACE,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,iBAAiB,CAAC,EAAA,QAAA,EAAA,CAEnEC,GAAA,CAAA,IAAA,EAAA,EAAA,QAAA,EAAA,kCAAA,EAAA,CAAyC,EACzCA,GAAA,CAAA,GAAA,EAAA,EAAA,QAAA,EAAI,OAAO,CAAC,gBAAgB,EAAA,CAAK,CAAA,EAAA,CAC7B,EACND,cAAK,SAAS,EAAE,MAAM,CAAC,WAAW,aAChCC,GAAA,CAAA,IAAA,EAAA,EAAA,QAAA,EAAA,sCAAA,EAAA,CAA6C,EAC7CA,GAAA,CAAA,GAAA,EAAA,EAAA,QAAA,EAAI,OAAO,CAAC,gBAAgB,EAAA,CAAK,IAC7B,CAAA,EAAA,CACF,CAAA,EAAA,CACF;AAEV;;;;"}
|
|
@@ -9,6 +9,10 @@ import { useData } from '@contentstack/studio-react-components/hooks';
|
|
|
9
9
|
import '../../contexts/providers/renderer.provider.js';
|
|
10
10
|
import '../../contexts/providers/active-node.provider.js';
|
|
11
11
|
import '@contentstack/studio-messenger';
|
|
12
|
+
import '@contentstack/studio-internal';
|
|
13
|
+
import '@contentstack/studio-core';
|
|
14
|
+
import '@contentstack/studio-react-components/basic-components';
|
|
15
|
+
import 'goober';
|
|
12
16
|
import '../Element.js';
|
|
13
17
|
import { useShouldShowDesign } from '../../hooks/use-should-show-design.hook.js';
|
|
14
18
|
import { DesignPreviewContext } from '../../contexts/providers/use-design-preview.provider.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConditionBlock.js","sources":["../../../src/components/elements/ConditionBlock.tsx"],"sourcesContent":["import { evaluateCondition } from \"@contentstack/studio-client\";\nimport { Condition } from \"@contentstack/studio-internal\";\nimport {\n getBindingString,\n getRepeaterContextPath,\n RepeaterBindingValue,\n} from \"@contentstack/studio-registry\";\nimport { produce } from \"immer\";\nimport { get, set } from \"lodash-es\";\nimport React from \"react\";\nimport { DataCtxProvider } from \"@contentstack/studio-react-components/contexts\";\nimport { useData } from \"@contentstack/studio-react-components/hooks\";\nimport {\n ConditionBlockContext,\n DesignPreviewContext,\n} from \"../../contexts/providers\";\nimport { useShouldShowDesign } from \"../../hooks\";\n\ninterface ConditionBlockProps {\n condition: Condition;\n children: React.ReactNode;\n mode: \"design\" | \"preview\";\n studioAttributes: any;\n}\n\nexport function ConditionBlock({\n condition,\n children,\n mode,\n studioAttributes,\n}: ConditionBlockProps) {\n const showDesign = useShouldShowDesign(mode);\n\n if (showDesign) {\n return (\n <ConditionBlockContext.Provider value={{ isInsideConditionBlock: true }}>\n <DesignPreviewContext.Provider value=\"design\">\n <div {...studioAttributes} style={{ display: \"contents\" }}>\n {children}\n </div>\n </DesignPreviewContext.Provider>\n </ConditionBlockContext.Provider>\n );\n }\n return (\n <ConditionPreview condition={condition} studioAttributes={studioAttributes}>\n {children}\n </ConditionPreview>\n );\n}\n\nfunction ConditionPreview({\n condition,\n children,\n studioAttributes,\n}: Omit<ConditionBlockProps, \"mode\">) {\n const data = useData();\n if (!condition) return null;\n let conditionAppliedData = data;\n const { dataBinding: binding } = condition;\n let shouldRender = evaluateCondition(condition, conditionAppliedData);\n const dataPath = binding && getBindingString(binding);\n const repeaterPath =\n binding &&\n getRepeaterContextPath(binding.value as unknown as RepeaterBindingValue);\n\n if (dataPath) {\n const conditionalData = get(data, dataPath);\n if (conditionalData && repeaterPath) {\n conditionAppliedData = produce(data, (draft) => {\n set(draft, repeaterPath, conditionalData);\n });\n }\n }\n const { \"data-cslp\": dataCslp, ...rest } = studioAttributes || {};\n\n const conditionCSLP = {\n dataCslp: dataCslp,\n };\n const childrenWithCSLP = React.Children.map(children, (child, index) => {\n const newProps = index === 0 ? conditionCSLP : {};\n if (React.isValidElement(child)) {\n return React.cloneElement(child, {\n key: index,\n ...newProps,\n });\n }\n });\n // Only render children if condition is met\n return shouldRender ? (\n <ConditionBlockContext.Provider value={{ isInsideConditionBlock: true }}>\n <DesignPreviewContext.Provider value=\"preview\">\n <DataCtxProvider value={conditionAppliedData}>\n <div {...rest} style={{ display: \"contents\" }}>\n {childrenWithCSLP}\n </div>\n </DataCtxProvider>\n </DesignPreviewContext.Provider>\n </ConditionBlockContext.Provider>\n ) : null;\n}\n"],"names":["_jsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ConditionBlock.js","sources":["../../../src/components/elements/ConditionBlock.tsx"],"sourcesContent":["import { evaluateCondition } from \"@contentstack/studio-client\";\nimport { Condition } from \"@contentstack/studio-internal\";\nimport {\n getBindingString,\n getRepeaterContextPath,\n RepeaterBindingValue,\n} from \"@contentstack/studio-registry\";\nimport { produce } from \"immer\";\nimport { get, set } from \"lodash-es\";\nimport React from \"react\";\nimport { DataCtxProvider } from \"@contentstack/studio-react-components/contexts\";\nimport { useData } from \"@contentstack/studio-react-components/hooks\";\nimport {\n ConditionBlockContext,\n DesignPreviewContext,\n} from \"../../contexts/providers\";\nimport { useShouldShowDesign } from \"../../hooks\";\n\ninterface ConditionBlockProps {\n condition: Condition;\n children: React.ReactNode;\n mode: \"design\" | \"preview\";\n studioAttributes: any;\n}\n\nexport function ConditionBlock({\n condition,\n children,\n mode,\n studioAttributes,\n}: ConditionBlockProps) {\n const showDesign = useShouldShowDesign(mode);\n\n if (showDesign) {\n return (\n <ConditionBlockContext.Provider value={{ isInsideConditionBlock: true }}>\n <DesignPreviewContext.Provider value=\"design\">\n <div {...studioAttributes} style={{ display: \"contents\" }}>\n {children}\n </div>\n </DesignPreviewContext.Provider>\n </ConditionBlockContext.Provider>\n );\n }\n return (\n <ConditionPreview condition={condition} studioAttributes={studioAttributes}>\n {children}\n </ConditionPreview>\n );\n}\n\nfunction ConditionPreview({\n condition,\n children,\n studioAttributes,\n}: Omit<ConditionBlockProps, \"mode\">) {\n const data = useData();\n if (!condition) return null;\n let conditionAppliedData = data;\n const { dataBinding: binding } = condition;\n let shouldRender = evaluateCondition(condition, conditionAppliedData);\n const dataPath = binding && getBindingString(binding);\n const repeaterPath =\n binding &&\n getRepeaterContextPath(binding.value as unknown as RepeaterBindingValue);\n\n if (dataPath) {\n const conditionalData = get(data, dataPath);\n if (conditionalData && repeaterPath) {\n conditionAppliedData = produce(data, (draft) => {\n set(draft, repeaterPath, conditionalData);\n });\n }\n }\n const { \"data-cslp\": dataCslp, ...rest } = studioAttributes || {};\n\n const conditionCSLP = {\n dataCslp: dataCslp,\n };\n const childrenWithCSLP = React.Children.map(children, (child, index) => {\n const newProps = index === 0 ? conditionCSLP : {};\n if (React.isValidElement(child)) {\n return React.cloneElement(child, {\n key: index,\n ...newProps,\n });\n }\n });\n // Only render children if condition is met\n return shouldRender ? (\n <ConditionBlockContext.Provider value={{ isInsideConditionBlock: true }}>\n <DesignPreviewContext.Provider value=\"preview\">\n <DataCtxProvider value={conditionAppliedData}>\n <div {...rest} style={{ display: \"contents\" }}>\n {childrenWithCSLP}\n </div>\n </DataCtxProvider>\n </DesignPreviewContext.Provider>\n </ConditionBlockContext.Provider>\n ) : null;\n}\n"],"names":["_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAyBM,SAAU,cAAc,CAAC,EAC7B,SAAS,EACT,QAAQ,EACR,IAAI,EACJ,gBAAgB,GACI,EAAA;AACpB,IAAA,MAAM,UAAU,GAAG,mBAAmB,CAAC,IAAI,CAAC;IAE5C,IAAI,UAAU,EAAE;AACd,QAAA,QACEA,GAAA,CAAC,qBAAqB,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,sBAAsB,EAAE,IAAI,EAAE,YACrEA,GAAA,CAAC,oBAAoB,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAC,QAAQ,EAAA,Q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KACnB;AACD,IAAA,MAAM,gBAAgB,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAI;AACrE,QAAA,MAAM,QAAQ,GAAG,KAAK,KAAK,CAAC,GAAG,aAAa,GAAG,EAAE;AACjD,QAAA,IAAI,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE;AAC/B,YAAA,OAAO,KAAK,CAAC,YAAY,CAAC,KAAK,EAAE;AAC/B,gBAAA,GAAG,EAAE,KAAK;AACV,gBAAA,GAAG,QAAQ;AACZ,aAAA,CAAC;QACJ;AACF,IAAA,CAAC,CAAC;;IAEF,OAAO,YAAY,IACjBA,IAAC,qBAAqB,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,EAAE,sBAAsB,EAAE,IAAI,EAAE,EAAA,QAAA,EACrEA,GAAA,CAAC,oBAAoB,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAC,SAAS,EAAA,QAAA,EAC5CA,IAAC,eAAe,EAAA,EAAC,KAAK,EAAE,oBAAoB,EAAA,QAAA,EAC1CA,GAAA,CAAA,KAAA,EAAA,EAAA,GAAS,IAAI,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,EAAA,QAAA,EAC1C,gBAAgB,EAAA,CACb,EAAA,CACU,EAAA,CACY,EAAA,CACD,IAC/B,IAAI;AACV;;;;"}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { COMPOSABLE_DATA_ATTRIBUTES } from '@contentstack/studio-client';
|
|
2
3
|
import { getFlattenedData } from '@contentstack/studio-registry';
|
|
3
4
|
import { DataCtxProvider } from '@contentstack/studio-react-components/contexts';
|
|
4
5
|
import { useData } from '@contentstack/studio-react-components/hooks';
|
|
5
6
|
import { Children, isValidElement, cloneElement } from 'react';
|
|
6
7
|
import '../../contexts/providers/renderer.provider.js';
|
|
7
8
|
import '../../contexts/providers/active-node.provider.js';
|
|
8
|
-
import '@contentstack/studio-client';
|
|
9
9
|
import '@contentstack/studio-messenger';
|
|
10
10
|
import 'immer';
|
|
11
|
+
import '@contentstack/studio-internal';
|
|
12
|
+
import '@contentstack/studio-core';
|
|
13
|
+
import '@contentstack/studio-react-components/basic-components';
|
|
14
|
+
import 'goober';
|
|
11
15
|
import '../Element.js';
|
|
12
16
|
import { useShouldShowDesign } from '../../hooks/use-should-show-design.hook.js';
|
|
13
17
|
import { DesignPreviewContext } from '../../contexts/providers/use-design-preview.provider.js';
|
|
@@ -18,7 +22,7 @@ import '../../contexts/providers/preview-mode.provider.js';
|
|
|
18
22
|
function RepeaterPreview({ children, studioAttributes, items = [], _uid, $items, }) {
|
|
19
23
|
const data = useData();
|
|
20
24
|
// Get uid from builder attributes or generate a fallback
|
|
21
|
-
const uid = _uid || studioAttributes?.[
|
|
25
|
+
const uid = _uid || studioAttributes?.[COMPOSABLE_DATA_ATTRIBUTES.ID] || "default";
|
|
22
26
|
return (jsx(RepeaterContext.Provider, { value: { isInsideRepeater: true }, children: jsx(DesignPreviewContext.Provider, { value: "preview", children: items.map((item, index) => {
|
|
23
27
|
// Single-level unwrap (see studio-react-components/Repeater.tsx).
|
|
24
28
|
let mergedContext = getFlattenedData(item);
|
|
@@ -68,46 +72,12 @@ function RepeaterPreview({ children, studioAttributes, items = [], _uid, $items,
|
|
|
68
72
|
// Optimize repeater
|
|
69
73
|
function Repeater({ children, studioAttributes, items = [], _uid, mode, $items, }) {
|
|
70
74
|
const showDesign = useShouldShowDesign(mode);
|
|
71
|
-
// In canvas
|
|
72
|
-
const data = useData();
|
|
73
75
|
if (!Array.isArray(items)) {
|
|
74
76
|
return null;
|
|
75
77
|
}
|
|
78
|
+
// In canvas
|
|
76
79
|
if (showDesign) {
|
|
77
|
-
|
|
78
|
-
// In design mode, we wrap the children with the context of the first item if available
|
|
79
|
-
// to allow data resolution to work for the "template" children.
|
|
80
|
-
// Single-level unwrap (same logic as preview mode above).
|
|
81
|
-
const rawFirst = items[0];
|
|
82
|
-
let mergedFirst = getFlattenedData(rawFirst);
|
|
83
|
-
if (rawFirst && typeof rawFirst === "object" && !Array.isArray(rawFirst)) {
|
|
84
|
-
const keys = Object.keys(rawFirst).filter((k) => k !== "$" && k !== "_metadata");
|
|
85
|
-
if (keys.length === 1) {
|
|
86
|
-
const inner = rawFirst[keys[0]];
|
|
87
|
-
if (inner && typeof inner === "object" && !Array.isArray(inner)) {
|
|
88
|
-
mergedFirst = { ...inner, ...rawFirst };
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
mergedFirst = rawFirst;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
const itemContext = mergedFirst !== undefined
|
|
96
|
-
? {
|
|
97
|
-
...data,
|
|
98
|
-
dataSources: {
|
|
99
|
-
...data?.dataSources,
|
|
100
|
-
repeater: {
|
|
101
|
-
[uid]: {
|
|
102
|
-
context: mergedFirst,
|
|
103
|
-
index: 0,
|
|
104
|
-
},
|
|
105
|
-
...data?.dataSources?.repeater,
|
|
106
|
-
},
|
|
107
|
-
},
|
|
108
|
-
}
|
|
109
|
-
: data;
|
|
110
|
-
return (jsx(RepeaterContext.Provider, { value: { isInsideRepeater: true }, children: jsx(DesignPreviewContext.Provider, { value: "design", children: jsx(DataCtxProvider, { value: itemContext, children: jsx("div", { ...studioAttributes, style: { display: "contents" }, children: children }) }) }) }));
|
|
80
|
+
return (jsx(RepeaterContext.Provider, { value: { isInsideRepeater: true }, children: jsx(DesignPreviewContext.Provider, { value: "design", children: jsx("div", { ...studioAttributes, style: { display: "contents" }, children: children }) }) }));
|
|
111
81
|
}
|
|
112
82
|
// Production renderer or mode === "preview"
|
|
113
83
|
return (jsx(RepeaterPreview, { items: items, children: children, studioAttributes: studioAttributes, _uid: _uid, "$items": $items }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Repeater.js","sources":["../../../src/components/elements/Repeater.tsx"],"sourcesContent":["import { getFlattenedData } from \"@contentstack/studio-registry\";\nimport { DataCtxProvider } from \"@contentstack/studio-react-components/contexts\";\nimport { useData } from \"@contentstack/studio-react-components/hooks\";\nimport React, { Children, cloneElement, isValidElement } from \"react\";\nimport {\n DesignPreviewContext,\n RepeaterContext,\n} from \"../../contexts/providers\";\nimport { useShouldShowDesign } from \"../../hooks\";\n\ntype CSLP = { \"data-cslp\": string };\ninterface RepeaterProps {\n children: React.ReactNode;\n studioAttributes?: any;\n items?: any[];\n data?: any;\n _uid: string;\n mode: \"design\" | \"preview\";\n $items?: CSLP;\n}\n\nfunction RepeaterPreview({\n children,\n studioAttributes,\n items = [],\n _uid,\n $items,\n}: Omit<RepeaterProps, \"mode\">) {\n const data = useData();\n // Get uid from builder attributes or generate a fallback\n const uid =\n _uid || studioAttributes?.[
|
|
1
|
+
{"version":3,"file":"Repeater.js","sources":["../../../src/components/elements/Repeater.tsx"],"sourcesContent":["import { COMPOSABLE_DATA_ATTRIBUTES } from \"@contentstack/studio-client\";\nimport { getFlattenedData } from \"@contentstack/studio-registry\";\nimport { DataCtxProvider } from \"@contentstack/studio-react-components/contexts\";\nimport { useData } from \"@contentstack/studio-react-components/hooks\";\nimport React, { Children, cloneElement, isValidElement } from \"react\";\nimport {\n DesignPreviewContext,\n RepeaterContext,\n} from \"../../contexts/providers\";\nimport { useShouldShowDesign } from \"../../hooks\";\n\ntype CSLP = { \"data-cslp\": string };\ninterface RepeaterProps {\n children: React.ReactNode;\n studioAttributes?: any;\n items?: any[];\n data?: any;\n _uid: string;\n mode: \"design\" | \"preview\";\n $items?: CSLP;\n}\n\nfunction RepeaterPreview({\n children,\n studioAttributes,\n items = [],\n _uid,\n $items,\n}: Omit<RepeaterProps, \"mode\">) {\n const data = useData();\n // Get uid from builder attributes or generate a fallback\n const uid =\n _uid || studioAttributes?.[COMPOSABLE_DATA_ATTRIBUTES.ID] || \"default\";\n return (\n <RepeaterContext.Provider value={{ isInsideRepeater: true }}>\n <DesignPreviewContext.Provider value=\"preview\">\n {items.map((item, index) => {\n // Single-level unwrap (see studio-react-components/Repeater.tsx).\n let mergedContext = getFlattenedData(item);\n if (item && typeof item === \"object\" && !Array.isArray(item)) {\n const keys = Object.keys(item).filter(\n (k) => k !== \"$\" && k !== \"_metadata\",\n );\n if (keys.length === 1) {\n const inner = item[keys[0]];\n if (inner && typeof inner === \"object\" && !Array.isArray(inner)) {\n mergedContext = { ...inner, ...item };\n } else {\n mergedContext = item;\n }\n }\n }\n\n const existingRepData = data?.dataSources?.repeater;\n const itemContext = {\n ...data,\n dataSources: {\n ...data?.dataSources,\n repeater: {\n [uid]: {\n context: mergedContext,\n index,\n },\n ...existingRepData,\n },\n },\n };\n const instanceCSLP: any = {};\n if ($items) {\n instanceCSLP.dataCslp = `${$items[\"data-cslp\"]}.${index}`;\n }\n\n // Clone children with the new context\n const childrenWithCSLP = Children.map(children, (child) => {\n if (isValidElement(child)) {\n return cloneElement(child, {\n ...instanceCSLP,\n });\n }\n });\n return (\n //TODO: Handle key with slot uid and support cslp tags\n <DataCtxProvider value={itemContext} key={`${uid}-${index}`}>\n <div {...studioAttributes} style={{ display: \"contents\" }}>\n {childrenWithCSLP}\n </div>\n </DataCtxProvider>\n );\n })}\n </DesignPreviewContext.Provider>\n </RepeaterContext.Provider>\n );\n}\n\n// Optimize repeater\nexport function Repeater({\n children,\n studioAttributes,\n items = [],\n _uid,\n mode,\n $items,\n}: RepeaterProps) {\n const showDesign = useShouldShowDesign(mode);\n\n if (!Array.isArray(items)) {\n return null;\n }\n\n // In canvas\n if (showDesign) {\n return (\n <RepeaterContext.Provider value={{ isInsideRepeater: true }}>\n <DesignPreviewContext.Provider value=\"design\">\n <div {...studioAttributes} style={{ display: \"contents\" }}>\n {children}\n </div>\n </DesignPreviewContext.Provider>\n </RepeaterContext.Provider>\n );\n }\n // Production renderer or mode === \"preview\"\n return (\n <RepeaterPreview\n items={items}\n children={children}\n studioAttributes={studioAttributes}\n _uid={_uid}\n $items={$items}\n />\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BAAmB,CAAC,IAAI,CAAC;IAE5C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;AACzB,QAAA,OAAO,IAAI;IACb;;IAGA,IAAI,UAAU,EAAE;AACd,QAAA,QACEA,GAAA,CAAC,eAAe,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,gBAAgB,EAAE,IAAI,EAAE,YACzDA,GAAA,CAAC,oBAAoB,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAC,QAAQ,EAAA,QAAA,EAC3CA,GAAA,CAAA,KAAA,EAAA,EAAA,GAAS,gBAAgB,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,EAAA,QAAA,EACtD,QAAQ,GACL,EAAA,CACwB,EAAA,CACP;IAE/B;;IAEA,QACEA,IAAC,eAAe,EAAA,EACd,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,gBAAgB,EAAE,gBAAgB,EAClC,IAAI,EAAE,IAAI,EAAA,QAAA,EACF,MAAM,EAAA,CACd;AAEN;;;;"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { Button, EDIT_COMPOSITION_LABEL } from '@contentstack/studio-core';
|
|
3
|
+
import { composableStudioEventManager, POST_MESSAGE_EVENTS } from '@contentstack/studio-messenger';
|
|
4
|
+
import { COMPOSABLE_DATA_ATTRIBUTES } from '@contentstack/studio-client';
|
|
5
|
+
import { SectionCompositionProvider } from '@contentstack/studio-react-components/basic-components';
|
|
6
|
+
import { DataCtxProvider } from '@contentstack/studio-react-components/contexts';
|
|
7
|
+
import { useData } from '@contentstack/studio-react-components/hooks';
|
|
8
|
+
import { css } from 'goober';
|
|
9
|
+
import { useCallback, useMemo } from 'react';
|
|
10
|
+
import { PreviewRenderer } from '../PreviewRenderer.js';
|
|
11
|
+
import { styleFactory } from '../styles.js';
|
|
12
|
+
|
|
13
|
+
// ─── Helpers ─────────────────────────────────────────────────────────────────
|
|
14
|
+
/** Reads sectionExposedProps from the section spec's UI metadata. */
|
|
15
|
+
function getExposedPropDefs(spec) {
|
|
16
|
+
const compositionEntry = spec.compositionEntry;
|
|
17
|
+
return (compositionEntry?.ui?.metadata?.sectionExposedProps ?? []);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Builds a map of { [ep.uid]: resolvedValue } from the props that
|
|
21
|
+
* retrievePropValue already resolved for the page-level section node.
|
|
22
|
+
*
|
|
23
|
+
* retrievePropValue resolves the bindings the page composer set on the section
|
|
24
|
+
* node's exposed props (e.g. template.heroTitle) and spreads them onto this
|
|
25
|
+
* component. The page node's binding is the SOLE source of truth for an exposed
|
|
26
|
+
* prop, so we emit an entry for EVERY exposed prop — including cleared/empty
|
|
27
|
+
* ones (value `undefined`/`""`). That lets a cleared prop render its empty value
|
|
28
|
+
* downstream instead of falling back to the section's internal binding.
|
|
29
|
+
*/
|
|
30
|
+
function buildOverrideValues(exposedPropDefs, rest) {
|
|
31
|
+
const overrides = {};
|
|
32
|
+
for (const ep of exposedPropDefs) {
|
|
33
|
+
overrides[ep.uid] = rest[ep.uid];
|
|
34
|
+
}
|
|
35
|
+
return overrides;
|
|
36
|
+
}
|
|
37
|
+
// ─── Icon ────────────────────────────────────────────────────────────────────
|
|
38
|
+
function StudioIcon() {
|
|
39
|
+
return (jsxs("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsx("path", { fillRule: "evenodd", clipRule: "evenodd", 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", fill: "#6C5CE7" }), jsx("path", { fillRule: "evenodd", clipRule: "evenodd", 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", fill: "#6C5CE7" }), jsx("path", { fillRule: "evenodd", clipRule: "evenodd", 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", fill: "#6C5CE7" }), jsx("path", { fillRule: "evenodd", clipRule: "evenodd", 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", fill: "#6C5CE7" }), jsx("path", { 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", fill: "#6C5CE7" })] }));
|
|
40
|
+
}
|
|
41
|
+
// ─── Component ───────────────────────────────────────────────────────────────
|
|
42
|
+
function SectionComposition({ spec, compositionUID, studioAttributes, className, ...rest }) {
|
|
43
|
+
const styles = styleFactory(css);
|
|
44
|
+
const handleEditClick = useCallback((event) => {
|
|
45
|
+
event.preventDefault();
|
|
46
|
+
event.stopPropagation();
|
|
47
|
+
composableStudioEventManager?.send(POST_MESSAGE_EVENTS.OPEN_IN_COMPOSABLE_STUDIO_EVENT_MESSAGE, { compositionEntryUid: compositionUID, compositionQuery: null });
|
|
48
|
+
}, [compositionUID]);
|
|
49
|
+
// Definitions of which props are exposed (uid, bindingAtExposeTime, etc.)
|
|
50
|
+
const exposedPropDefs = useMemo(() => getExposedPropDefs(spec), [spec]);
|
|
51
|
+
// Map of { [ep.uid]: resolvedPageValue } — values already resolved by
|
|
52
|
+
// retrievePropValue against the page's data context and spread into rest.
|
|
53
|
+
const overrideValues = useMemo(() => buildOverrideValues(exposedPropDefs, rest), [
|
|
54
|
+
exposedPropDefs,
|
|
55
|
+
JSON.stringify(exposedPropDefs.map((ep) => rest[ep.uid])),
|
|
56
|
+
]);
|
|
57
|
+
// Exclude exposed prop keys and their $-prefixed CSLP counterparts from DOM
|
|
58
|
+
// spread. retrievePropValue adds both `uid` (resolved value) and `$uid` (CSLP
|
|
59
|
+
// live-preview tag) to the resolved props — both are invalid as div attributes.
|
|
60
|
+
const domProps = useMemo(() => {
|
|
61
|
+
const excluded = new Set(exposedPropDefs.flatMap((ep) => [ep.uid, `$${ep.uid}`]));
|
|
62
|
+
return Object.fromEntries(Object.entries(rest).filter(([k]) => !excluded.has(k)));
|
|
63
|
+
}, [exposedPropDefs, rest]);
|
|
64
|
+
return (jsxs("div", { ...domProps, ...studioAttributes, className: [styles.embeddedSectionHost, className]
|
|
65
|
+
.filter(Boolean)
|
|
66
|
+
.join(" "), children: [jsxs(Button, { className: `cs-embedded-section-edit-btn ${styles.embeddedSectionButton}`, onClick: handleEditClick, type: "button", "data-studio-ui": true, children: [jsx(StudioIcon, {}), EDIT_COMPOSITION_LABEL] }), jsx(SectionCompositionProvider, { uid: compositionUID, instanceUid: studioAttributes?.[COMPOSABLE_DATA_ATTRIBUTES.ID], exposedPropDefs: exposedPropDefs, overrideValues: overrideValues, children: jsx(SectionDataMerger, { spec: spec, children: jsx(PreviewRenderer, { spec: spec }) }) })] }));
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Merges the section's own `spec.data.static_value` into the active data
|
|
70
|
+
* context so static-value-bound props authored inside the section (e.g. a
|
|
71
|
+
* SectionSlot's `label`, or any Text/Number/etc. inside the section's body)
|
|
72
|
+
* resolve against the section's persisted values when the section is
|
|
73
|
+
* consumed in a page. Without this, child Elements call useData() and get
|
|
74
|
+
* the page's data, which doesn't contain the section's static_value keys.
|
|
75
|
+
*/
|
|
76
|
+
function SectionDataMerger({ spec, children, }) {
|
|
77
|
+
const outerData = useData();
|
|
78
|
+
const merged = useMemo(() => {
|
|
79
|
+
const sectionStatic = spec?.data?.static_value;
|
|
80
|
+
if (!sectionStatic || typeof sectionStatic !== "object")
|
|
81
|
+
return outerData;
|
|
82
|
+
return {
|
|
83
|
+
...outerData,
|
|
84
|
+
static_value: {
|
|
85
|
+
...(outerData?.static_value || {}),
|
|
86
|
+
...sectionStatic,
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
}, [outerData, spec]);
|
|
90
|
+
return jsx(DataCtxProvider, { value: merged, children: children });
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export { SectionComposition };
|
|
94
|
+
//# sourceMappingURL=SectionComposition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SectionComposition.js","sources":["../../../src/components/elements/SectionComposition.tsx"],"sourcesContent":["import { Button, EDIT_COMPOSITION_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 { DataCtxProvider } from \"@contentstack/studio-react-components/contexts\";\nimport { useData } from \"@contentstack/studio-react-components/hooks\";\nimport { css } from \"goober\";\nimport { MouseEvent, useCallback, useMemo } from \"react\";\nimport { PreviewRenderer } from \"../PreviewRenderer\";\nimport { StudioAttributes } from \"../../types\";\nimport { styleFactory } from \"../styles\";\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 [key: string]: any;\n}\n\n// ─── Helpers ─────────────────────────────────────────────────────────────────\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// ─── 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 ...rest\n}: SectionCompositionProps) {\n const styles = styleFactory(css);\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 // 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 );\n return Object.fromEntries(\n Object.entries(rest).filter(([k]) => !excluded.has(k)),\n );\n }, [exposedPropDefs, rest]);\n\n return (\n <div\n {...domProps}\n {...studioAttributes}\n className={[styles.embeddedSectionHost, className]\n .filter(Boolean)\n .join(\" \")}\n >\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_COMPOSITION_LABEL}\n </Button>\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 <SectionCompositionProvider\n uid={compositionUID}\n instanceUid={studioAttributes?.[COMPOSABLE_DATA_ATTRIBUTES.ID]}\n exposedPropDefs={exposedPropDefs}\n overrideValues={overrideValues}\n >\n <SectionDataMerger spec={spec}>\n <PreviewRenderer spec={spec as any} />\n </SectionDataMerger>\n </SectionCompositionProvider>\n </div>\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":";;;;;;;;;;;;AA+CA;AAEA;AACA,SAAS,kBAAkB,CAAC,IAAiB,EAAA;AAC3C,IAAA,MAAM,gBAAgB,GAAG,IAAI,CAAC,gBAEjB;IAC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