@contentstack/studio-react-editor 1.10.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.
@@ -1,4 +1,4 @@
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
4
  import { CurrentNodeContext } from '@contentstack/studio-react-components/contexts';
@@ -11,6 +11,7 @@ import { TextPlaceholder } from './TextPlaceholder.js';
11
11
  import { RendererErrorBoundary } from './RendererErrorBoundary.js';
12
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';
@@ -299,20 +300,19 @@ const VisualComponent = memo(({ parent, nodes, slotUid, renderError, dataCslp =
299
300
  }
300
301
  }, [parent]);
301
302
  if (!shouldRenderSlot(componentRegistry, parent, nodes, isCompositionBeingEdited)) {
302
- const children = nodes?.map((node, idx) => {
303
- const key = node.uid;
304
- // Stays in the parent's loop rather than moving into SlotChild: these run
305
- // for EVERY child including hidden ones, which are never rendered at all.
306
- if (isCompositionBeingEdited) {
307
- NODE_TO_PATH_NODE.set(node, [slotUid, idx]);
308
- NODE_TO_PARENT.set(node, parent);
309
- }
310
- if (node.metadata.visible === false) {
311
- return;
312
- }
313
- return (jsx(SlotChild, { node: node, slotUid: slotUid, slotIndex: idx, parentNodePath: parentNodePath, renderError: renderError, dataCslp: dataCslp, wellHint: getConditionWellHint(parent, node) }, key));
314
- });
315
- 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
+ } }));
316
316
  }
317
317
  // Placeholder text for this empty slot: the repeater advice, the condition
318
318
  // hint when this slot is a condition block's own, or the hint the block
@@ -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 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 { 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 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 wellHint={getConditionWellHint(parent, node)}\n />\n );\n });\n\n return <>{children}</>;\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","_Fragment"],"mappings":";;;;;;;;;;;;;;;;;;AAsDA,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,GAAG,QAAQ,EAAE,eAAe;AAC5B,gBAAA,GAAG,aAAa;AACjB,aAAA;AACF;UACD,QAAQ,EACd,CAAC,QAAQ,EAAE,aAAa,CAAC,CAC1B;AAED,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,E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E,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;;;;"}
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 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,GAA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+ 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}\n"],"names":["_jsxs","_jsx","_Fragment","Fragment"],"mappings":";;;;;;;;;;AAuBA;AACA,MAAM,qBAAqB,GAAG,OAC5BA,IAAA,CAAA,KAAA,EAAA,EACE,KAAK,EAAC,IAAI,EACV,MAAM,EAAC,IAAI,EACX,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,KAAK,EAAC,4BAA4B,EAAA,aAAA,EACtB,MAAM,EAAA,QAAA,EAAA,CAElBC,cACE,CAAC,EAAC,GAAG,EACL,CAAC,EAAC,KAAK,EACP,KAAK,EAAC,IAAI,EACV,MAAM,EAAC,IAAI,EACX,EAAE,EAAC,GAAG,EACN,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,KAAK,EAAA,CACjB,EACFA,GAAA,CAAA,MAAA,EAAA,EACE,CAAC,EAAC,kBAAkB,EACpB,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,KAAK,EACjB,aAAa,EAAC,OAAO,EAAA,CACrB,EACFA,GAAA,CAAA,MAAA,EAAA,EACE,CAAC,EAAC,6BAA6B,EAC/B,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,KAAK,EACjB,aAAa,EAAC,OAAO,EACrB,cAAc,EAAC,OAAO,EAAA,CACtB,EACFA,GAAA,CAAA,MAAA,EAAA,EACE,CAAC,EAAC,KAAK,EACP,CAAC,EAAC,MAAM,EACR,KAAK,EAAC,IAAI,EACV,MAAM,EAAC,GAAG,EACV,EAAE,EAAC,GAAG,EACN,MAAM,EAAC,cAAc,EAC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,SAAS,EAAC,KAAK,EAAA,CAAG,CAC7D,EACA,iBAAiB,EACjB,SAAS,EAAE,YAAY,KACtBA,IAAC,iBAAiB,EAAA,EAAC,UAAU,EAAE,SAAS,EAAE,SAAS,EAAC,QAAQ,GAAG,CAChE,CAAA,EAAA,EAPY,SAAS,CAAC,GAAG,CAQjB;QAEf,CAAC,CAAC,EAAA,CACD;AAEP;;;;"}
@@ -12,6 +12,7 @@ import { SectionModeContext } from '../../contexts/providers/section-mode.provid
12
12
  import { useRenderer } from '../../hooks/use-renderer.hook.js';
13
13
  import { useSlotCopyColor } from '../../hooks/use-slot-copy-color.hook.js';
14
14
  import MemoizedElement from '../Element.js';
15
+ import { SlotChildrenWithPermanentDropZones } from '../PermanentDropZone.js';
15
16
  import { AddIcon } from '../AddIcon.js';
16
17
 
17
18
  /**
@@ -210,17 +211,17 @@ function SectionSlot({ studioAttributes, label, _uid, defaultSection, }) {
210
211
  // selectable, hover-highlightable, and draggable like a normal node. In
211
212
  // preview mode, keep them inside preview (non-interactive) and drop the
212
213
  // drop-zone attributes so the slot reads like production.
213
- return (jsx(DataCtxProvider, { value: slotChildData, children: jsx(PreviewModeContext.Provider, { value: isSectionPreview, children: jsx("div", { ref: slotDomRef, ...(isSectionPreview ? {} : dropZoneAttrs), ...studioAttributes, style: { display: "contents" }, children: jsx(SectionInstanceSlotsCtx.Provider, { value: undefined, children: filled.map((child, idx) => {
214
- if (!child || typeof child !== "object")
215
- return null;
216
- NODE_TO_PARENT.set(child, sectionCtx.sectionNode);
217
- NODE_TO_PATH_NODE.set(child, [slotUid, idx]);
218
- const childPath = [...parentNodePath, [slotUid, idx]];
219
- return (jsx(CurrentNodeContext.Provider, { value: {
220
- currentNodeUid: child.uid,
221
- currentNodePath: childPath,
222
- }, children: jsx(SelectedNodeProvider, { children: jsx(MemoizedElement, { node: child, renderError: () => null }) }) }, child.uid));
223
- }) }) }) }) }));
214
+ return (jsx(DataCtxProvider, { value: slotChildData, children: jsx(PreviewModeContext.Provider, { value: isSectionPreview, children: jsx("div", { ref: slotDomRef, ...(isSectionPreview ? {} : dropZoneAttrs), ...studioAttributes, style: { display: "contents" }, children: jsx(SectionInstanceSlotsCtx.Provider, { value: undefined, children: jsx(SlotChildrenWithPermanentDropZones, { slotOwner: sectionCtx.sectionNode, slotChildren: filled, renderSlotChild: (child, idx) => {
215
+ if (!child || typeof child !== "object")
216
+ return null;
217
+ NODE_TO_PARENT.set(child, sectionCtx.sectionNode);
218
+ NODE_TO_PATH_NODE.set(child, [slotUid, idx]);
219
+ const childPath = [...parentNodePath, [slotUid, idx]];
220
+ return (jsx(CurrentNodeContext.Provider, { value: {
221
+ currentNodeUid: child.uid,
222
+ currentNodePath: childPath,
223
+ }, children: jsx(SelectedNodeProvider, { children: jsx(MemoizedElement, { node: child, renderError: () => null }) }) }));
224
+ } }) }) }) }) }));
224
225
  }
225
226
 
226
227
  export { SectionSlot };
@@ -1 +1 @@
1
- {"version":3,"file":"SectionSlot.js","sources":["../../../src/components/elements/SectionSlot.tsx"],"sourcesContent":["import {\n COMPOSABLE_DATA_ATTRIBUTES,\n ELEMENT_TO_NODE,\n NODE_TO_PARENT,\n NODE_TO_PATH_NODE,\n} from \"@contentstack/studio-client\";\nimport { Node, Path } from \"@contentstack/studio-internal\";\nimport {\n CurrentNodeContext,\n DataCtxProvider,\n SectionInstanceSlotsCtx,\n} from \"@contentstack/studio-react-components/contexts\";\nimport {\n useCurrentNode,\n useData,\n} from \"@contentstack/studio-react-components/hooks\";\nimport { css } from \"goober\";\nimport classNames from \"classnames\";\nimport { useCallback, useContext, useMemo } from \"react\";\nimport { styleFactory } from \"../styles\";\nimport { StudioAttributes } from \"../../types\";\nimport { SelectedNodeProvider } from \"../../contexts/providers/selected-node.provider\";\nimport { PreviewModeContext } from \"../../contexts/providers/preview-mode.provider\";\nimport { SectionModeContext } from \"../../contexts/providers/section-mode.provider\";\nimport { useRenderer } from \"../../hooks/use-renderer.hook\";\nimport { useSlotCopyColor } from \"../../hooks/use-slot-copy-color.hook\";\nimport Element from \"../Element\";\nimport { AddIcon } from \"../AddIcon\";\n\ninterface SectionSlotEditorProps extends StudioAttributes {\n label?: string;\n _uid?: string;\n /** Authored Slot default section uid (COMS-1659). Rendered when the slot is\n * empty in preview mode; design mode keeps the dropzone. */\n defaultSection?: string;\n}\n\n/**\n * In-memory `section-composition` node for a slot's authored default. Rendered\n * through the normal element path so the default's spec resolves by\n * `compositionUID` and nested defaults recurse. Stable uid → no remount. Never\n * persisted into the placement.\n */\nfunction makeDefaultSectionNode(\n instanceUid: string | undefined,\n slotUid: string,\n defaultUid: string,\n): Node {\n // Key by the enclosing placement instance too (COMS-1659): the same section\n // placed twice shares one internal `slotUid`, so a slot-uid-only key would\n // collide across placements and make their empty-slot defaults share one\n // uid-keyed data context. The instance uid makes each placement's default\n // distinct.\n const prefix = instanceUid ? `${instanceUid}-` : \"\";\n return {\n type: \"section-composition\",\n uid: `${prefix}${slotUid}-default-${defaultUid}`,\n metadata: { compositionUID: defaultUid, mode: \"preview\" },\n attrs: {},\n props: {},\n slots: {},\n styles: {},\n } as Node;\n}\n\n/**\n * Editor variant of section-slot. Two modes:\n *\n * 1. **Authoring mode** (no SectionInstanceSlotsCtx in scope) — the section\n * composition is being authored. Render a labelled drop-zone-style\n * placeholder; not droppable into (section slots only accept drops when\n * the section is consumed in a page composition).\n *\n * 2. **Consumption mode** (SectionInstanceSlotsCtx present) — the section\n * is being rendered inside a page composition. Look up the page-side\n * slots map by this slot's stable uid (== this node's uid). If filled,\n * transclude the children via <Element> with their paths anchored to\n * the page-side section-composition node, and lift them out of preview\n * mode so they're individually selectable / hover-targetable / draggable\n * like any other page-tree node. If empty, render a labelled drop\n * target that itself acts as a builder node (attributes mapped to the\n * page-side section-composition parent), so hover highlights only the\n * slot zone — not the whole section.\n */\nexport function SectionSlot({\n studioAttributes,\n label,\n _uid,\n defaultSection,\n}: SectionSlotEditorProps) {\n // ALL hooks unconditionally at the top — React doesn't allow conditional\n // hook calls and the component returns early for authoring/empty modes.\n // One measurement per line of empty-slot chrome: each reads the page colour\n // behind itself and picks the palette entry that separates from it best.\n const authoringCopyColor = useSlotCopyColor<HTMLSpanElement>();\n const dropCopyColor = useSlotCopyColor<HTMLSpanElement>();\n const defaultHintCopyColor = useSlotCopyColor<HTMLParagraphElement>();\n const sectionCtx = useContext(SectionInstanceSlotsCtx);\n // Registry resolves the authored Default section's human title for the\n // design-mode hint (COMS-1770). Sections register with `type = section.uid`\n // and `displayName = section.title`, so a uid lookup yields the title.\n const { componentRegistry } = useRenderer();\n // When the enclosing placed section is in preview mode, the slot renders like\n // production: an empty slot collapses to nothing and a filled slot drops its\n // drop-chrome / selection affordances.\n const isSectionPreview = useContext(SectionModeContext) === \"preview\";\n const { currentNodePath: parentNodePath = [] } = useCurrentNode();\n // Current section-local data (template scoped to section, in-section\n // repeater item if surrounding, etc.). Slot children inherit this as\n // their *default* context — the user's authored bindings on slot\n // children resolve against this by default.\n const sectionLocalData = useData();\n const slotDomRef = useCallback(\n (el: HTMLElement | null) => {\n if (el && sectionCtx?.sectionNode) {\n ELEMENT_TO_NODE.set(el, sectionCtx.sectionNode);\n }\n },\n [sectionCtx?.sectionNode],\n );\n // Slot child's data context namespace:\n //\n // dataSources.template = section-local scoped template; if the\n // slot sits inside an in-section\n // Repeater that's currently iterating,\n // this is the active iteration item.\n // Matches what the Data Picker writes\n // when authoring against fields from\n // the slot's surrounding section scope.\n // dataSources.repeater[uid] = in-section Repeater map (full\n // per-uid context). Inherited from\n // sectionLocal via {...sectionDS}.\n // dataSources.static_value = section's persisted static values.\n // dataSources.page = OUTERMOST page-level namespace\n // ({ template, contentstack,\n // contentstack_queries, ... }).\n // Always points to the real page even\n // across recursive slot nesting — see\n // `truePageNamespace` below.\n //\n // Until Phase 8 lands, picker emits `dataSources.<src>.X` paths only.\n // retrieve-data.ts retries unresolved `dataSources.<src>.X` lookups under\n // `dataSources.page.<src>.X` so page-level bindings authored on slot\n // children still resolve.\n const slotChildData = useMemo(() => {\n const sectionLocal: any = sectionLocalData || {};\n const pageOuter: any = sectionCtx?.pageOuterData || {};\n const pageDS = pageOuter?.dataSources || {};\n const sectionDS = sectionLocal?.dataSources || {};\n\n const repeaterMap = (sectionDS.repeater || {}) as Record<string, any>;\n const repeaterUids = Object.keys(repeaterMap);\n const activeRepeaterUid =\n repeaterUids.length > 0\n ? repeaterUids[repeaterUids.length - 1]\n : undefined;\n const activeItem = activeRepeaterUid\n ? repeaterMap[activeRepeaterUid]?.context\n : undefined;\n const sectionLocalTemplate = activeItem ?? sectionDS.template;\n\n // Slot child's default namespace = section-local context AS IS (template,\n // repeater, static_value, …). Page-level sources are nested under `page.*`\n // as the explicit escape. This matches what the Data Picker writes when\n // authoring a slot child (picker shows the slot child's surrounding\n // scope, so its `template.X` / `repeater[uid].context.X` paths resolve\n // natively without rewriting).\n //\n // For nested cases (Section B in Section A's slot), `page` must always\n // point to the OUTERMOST page context — not to Section A's slot-local\n // view. Otherwise each nesting level shadows `page` with the surrounding\n // section's local, and `dataSources.page.template.title` would resolve\n // to a modular_block item instead of the page entry. So: if the outer\n // dataSources already has its own `page` key (because the section we're\n // inside is itself in another slot), inherit THAT — it's the real page.\n const outerPage = (pageDS as any)?.page;\n const truePageNamespace = outerPage ?? pageDS;\n return {\n ...sectionLocal,\n dataSources: {\n ...sectionDS,\n template: sectionLocalTemplate,\n page: truePageNamespace,\n },\n };\n }, [sectionLocalData, sectionCtx?.pageOuterData]);\n\n // ALL hooks above are unconditional. From here, branch based on mode.\n const styles = styleFactory(css);\n const text = label && label.trim().length > 0 ? label : \"Drop Here\";\n const slotUid =\n _uid ||\n (studioAttributes as any)?.[COMPOSABLE_DATA_ATTRIBUTES.ID] ||\n \"section-slot\";\n\n // Design-mode hint (COMS-1770): resolve the Default section's title for the\n // message. `getComponent` throws for a uid outside the locally-known catalog,\n // so fall back to a nameless hint instead of crashing the slot.\n let defaultSectionTitle: string | undefined;\n if (defaultSection) {\n try {\n defaultSectionTitle =\n componentRegistry.getComponent(defaultSection)?.displayName;\n } catch {\n defaultSectionTitle = undefined;\n }\n }\n\n // Authoring mode: section is the top-level composition being edited.\n if (!sectionCtx) {\n return (\n <div\n {...{\n [COMPOSABLE_DATA_ATTRIBUTES.SLOT]: true,\n [COMPOSABLE_DATA_ATTRIBUTES.SLOT_UID]: slotUid,\n }}\n {...studioAttributes}\n className={classNames(styles.slotStyle)}\n >\n <span\n ref={authoringCopyColor.ref}\n className={classNames(\n styles.slotDropText,\n authoringCopyColor.colorClassName,\n authoringCopyColor.strokeClassName,\n )}\n >\n <AddIcon /> {text}\n </span>\n </div>\n );\n }\n\n // Consumption mode.\n const filled = (sectionCtx.slotsMap[slotUid] || []) as Node[];\n const dropZoneAttrs = {\n [COMPOSABLE_DATA_ATTRIBUTES.BUILDER]: true,\n [COMPOSABLE_DATA_ATTRIBUTES.NODE]: true,\n [COMPOSABLE_DATA_ATTRIBUTES.ID]: sectionCtx.sectionInstanceUid,\n [COMPOSABLE_DATA_ATTRIBUTES.SLOT]: true,\n [COMPOSABLE_DATA_ATTRIBUTES.SLOT_UID]: slotUid,\n };\n\n if (filled.length === 0) {\n // Preview mode: an empty slot falls back to its authored default section\n // (COMS-1659), rendered like production — non-interactive, no drop chrome.\n // With no default it collapses to nothing. Design mode always shows the\n // dropzone below (default never shown while authoring the placement).\n if (isSectionPreview) {\n if (!defaultSection) return null;\n const synth = makeDefaultSectionNode(\n sectionCtx.sectionInstanceUid,\n slotUid,\n defaultSection,\n );\n NODE_TO_PARENT.set(synth, sectionCtx.sectionNode);\n NODE_TO_PATH_NODE.set(synth, [slotUid, 0]);\n return (\n <DataCtxProvider value={slotChildData}>\n <PreviewModeContext.Provider value={true}>\n <div style={{ display: \"contents\" }}>\n <SectionInstanceSlotsCtx.Provider value={undefined}>\n <CurrentNodeContext.Provider\n value={{\n currentNodeUid: synth.uid,\n currentNodePath: [...parentNodePath, [slotUid, 0]],\n }}\n >\n <Element node={synth} renderError={() => null as any} />\n </CurrentNodeContext.Provider>\n </SectionInstanceSlotsCtx.Provider>\n </div>\n </PreviewModeContext.Provider>\n </DataCtxProvider>\n );\n }\n return (\n <div\n ref={slotDomRef as any}\n {...dropZoneAttrs}\n {...studioAttributes}\n // Column: the default-section hint stacks below the drop copy. Sections\n // are added by dropping one here or from the slot's Insert handle in\n // Studio (COMS-2392), which offers the slot's allowed sections.\n className={classNames(styles.slotStyle, styles.slotColumnStyle)}\n >\n {/* One empty-state layout regardless of a configured default — only\n the parenthetical hint below is default-only. The drop copy keeps\n \"…to replace it\" solely when there IS a default to replace. */}\n <span\n ref={dropCopyColor.ref}\n className={classNames(\n styles.slotDropText,\n dropCopyColor.colorClassName,\n dropCopyColor.strokeClassName,\n )}\n >\n <AddIcon />{\" \"}\n {defaultSection\n ? \"Drop a section here to replace it.\"\n : \"Drop a section here.\"}\n </span>\n {/* Design-mode hint (COMS-1770): tell the page composer that leaving\n this slot empty will render the author's Default section in preview\n and on the live page. Mirrors the repeater's condition-block hint\n (Slot.tsx). Only shown when a default is configured. */}\n {defaultSection ? (\n <p\n ref={defaultHintCopyColor.ref}\n className={classNames(\n styles.slotDefaultHint,\n defaultHintCopyColor.colorClassName,\n defaultHintCopyColor.strokeClassName,\n )}\n >\n {\"(When this slot is empty, the default section\"}\n {defaultSectionTitle ? (\n <>\n {\" (\"}\n <strong>{defaultSectionTitle}</strong>\n {\")\"}\n </>\n ) : null}\n {\n \" added by the section author is shown in Preview and on the live page.)\"\n }\n </p>\n ) : null}\n </div>\n );\n }\n\n // Transclude filled children. Anchor each child's slate path under the\n // page-side section-composition node + this slot's uid. In design mode, exit\n // preview so Element's internalAttributes get applied — making each child\n // selectable, hover-highlightable, and draggable like a normal node. In\n // preview mode, keep them inside preview (non-interactive) and drop the\n // drop-zone attributes so the slot reads like production.\n return (\n <DataCtxProvider value={slotChildData}>\n <PreviewModeContext.Provider value={isSectionPreview}>\n <div\n ref={slotDomRef as any}\n {...(isSectionPreview ? {} : dropZoneAttrs)}\n {...studioAttributes}\n style={{ display: \"contents\" }}\n >\n {/*\n * The filled children are PAGE-authored content the composer dropped\n * into this slot — not part of the section's authored body. Clear the\n * section-instance context for them so their own internal slots render\n * normally (e.g. an empty Repeater dropped here shows its \"Drop Here\"\n * placeholder instead of being suppressed by Slot.tsx's\n * in-section-consumption guard, which would make it disappear).\n */}\n <SectionInstanceSlotsCtx.Provider value={undefined}>\n {filled.map((child, idx) => {\n if (!child || typeof child !== \"object\") return null;\n NODE_TO_PARENT.set(child, sectionCtx.sectionNode);\n NODE_TO_PATH_NODE.set(child, [slotUid, idx]);\n const childPath: Path = [...parentNodePath, [slotUid, idx]];\n return (\n <CurrentNodeContext.Provider\n key={child.uid}\n value={{\n currentNodeUid: child.uid,\n currentNodePath: childPath,\n }}\n >\n <SelectedNodeProvider>\n <Element node={child} renderError={() => null as any} />\n </SelectedNodeProvider>\n </CurrentNodeContext.Provider>\n );\n })}\n </SectionInstanceSlotsCtx.Provider>\n </div>\n </PreviewModeContext.Provider>\n </DataCtxProvider>\n );\n}\n"],"names":["_jsx","_jsxs","Element","_Fragment"],"mappings":";;;;;;;;;;;;;;;;AAqCA;;;;;AAKG;AACH,SAAS,sBAAsB,CAC7B,WAA+B,EAC/B,OAAe,EACf,UAAkB,EAAA;;;;;;AAOlB,IAAA,MAAM,MAAM,GAAG,WAAW,GAAG,CAAA,EAAG,WAAW,CAAA,CAAA,CAAG,GAAG,EAAE;IACnD,OAAO;AACL,QAAA,IAAI,EAAE,qBAAqB;AAC3B,QAAA,GAAG,EAAE,CAAA,EAAG,MAAM,GAAG,OAAO,CAAA,SAAA,EAAY,UAAU,CAAA,CAAE;QAChD,QAAQ,EAAE,EAAE,cAAc,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE;AACzD,QAAA,KAAK,EAAE,EAAE;AACT,QAAA,KAAK,EAAE,EAAE;AACT,QAAA,KAAK,EAAE,EAAE;AACT,QAAA,MAAM,EAAE,EAAE;KACH;AACX;AAEA;;;;;;;;;;;;;;;;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A,EACnBA,GAAA,CAACE,eAAO,IAAC,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,IAAW,EAAA,CAAI,EAAA,CACnC,EAAA,EARlB,KAAK,CAAC,GAAG,CASc;AAElC,oBAAA,CAAC,CAAC,EAAA,CAC+B,EAAA,CAC/B,EAAA,CACsB,EAAA,CACd;AAEtB;;;;"}
1
+ {"version":3,"file":"SectionSlot.js","sources":["../../../src/components/elements/SectionSlot.tsx"],"sourcesContent":["import {\n COMPOSABLE_DATA_ATTRIBUTES,\n ELEMENT_TO_NODE,\n NODE_TO_PARENT,\n NODE_TO_PATH_NODE,\n} from \"@contentstack/studio-client\";\nimport { Node, Path } from \"@contentstack/studio-internal\";\nimport {\n CurrentNodeContext,\n DataCtxProvider,\n SectionInstanceSlotsCtx,\n} from \"@contentstack/studio-react-components/contexts\";\nimport {\n useCurrentNode,\n useData,\n} from \"@contentstack/studio-react-components/hooks\";\nimport { css } from \"goober\";\nimport classNames from \"classnames\";\nimport { useCallback, useContext, useMemo } from \"react\";\nimport { styleFactory } from \"../styles\";\nimport { StudioAttributes } from \"../../types\";\nimport { SelectedNodeProvider } from \"../../contexts/providers/selected-node.provider\";\nimport { PreviewModeContext } from \"../../contexts/providers/preview-mode.provider\";\nimport { SectionModeContext } from \"../../contexts/providers/section-mode.provider\";\nimport { useRenderer } from \"../../hooks/use-renderer.hook\";\nimport { useSlotCopyColor } from \"../../hooks/use-slot-copy-color.hook\";\nimport Element from \"../Element\";\nimport { SlotChildrenWithPermanentDropZones } from \"../PermanentDropZone\";\nimport { AddIcon } from \"../AddIcon\";\n\ninterface SectionSlotEditorProps extends StudioAttributes {\n label?: string;\n _uid?: string;\n /** Authored Slot default section uid (COMS-1659). Rendered when the slot is\n * empty in preview mode; design mode keeps the dropzone. */\n defaultSection?: string;\n}\n\n/**\n * In-memory `section-composition` node for a slot's authored default. Rendered\n * through the normal element path so the default's spec resolves by\n * `compositionUID` and nested defaults recurse. Stable uid → no remount. Never\n * persisted into the placement.\n */\nfunction makeDefaultSectionNode(\n instanceUid: string | undefined,\n slotUid: string,\n defaultUid: string,\n): Node {\n // Key by the enclosing placement instance too (COMS-1659): the same section\n // placed twice shares one internal `slotUid`, so a slot-uid-only key would\n // collide across placements and make their empty-slot defaults share one\n // uid-keyed data context. The instance uid makes each placement's default\n // distinct.\n const prefix = instanceUid ? `${instanceUid}-` : \"\";\n return {\n type: \"section-composition\",\n uid: `${prefix}${slotUid}-default-${defaultUid}`,\n metadata: { compositionUID: defaultUid, mode: \"preview\" },\n attrs: {},\n props: {},\n slots: {},\n styles: {},\n } as Node;\n}\n\n/**\n * Editor variant of section-slot. Two modes:\n *\n * 1. **Authoring mode** (no SectionInstanceSlotsCtx in scope) — the section\n * composition is being authored. Render a labelled drop-zone-style\n * placeholder; not droppable into (section slots only accept drops when\n * the section is consumed in a page composition).\n *\n * 2. **Consumption mode** (SectionInstanceSlotsCtx present) — the section\n * is being rendered inside a page composition. Look up the page-side\n * slots map by this slot's stable uid (== this node's uid). If filled,\n * transclude the children via <Element> with their paths anchored to\n * the page-side section-composition node, and lift them out of preview\n * mode so they're individually selectable / hover-targetable / draggable\n * like any other page-tree node. If empty, render a labelled drop\n * target that itself acts as a builder node (attributes mapped to the\n * page-side section-composition parent), so hover highlights only the\n * slot zone — not the whole section.\n */\nexport function SectionSlot({\n studioAttributes,\n label,\n _uid,\n defaultSection,\n}: SectionSlotEditorProps) {\n // ALL hooks unconditionally at the top — React doesn't allow conditional\n // hook calls and the component returns early for authoring/empty modes.\n // One measurement per line of empty-slot chrome: each reads the page colour\n // behind itself and picks the palette entry that separates from it best.\n const authoringCopyColor = useSlotCopyColor<HTMLSpanElement>();\n const dropCopyColor = useSlotCopyColor<HTMLSpanElement>();\n const defaultHintCopyColor = useSlotCopyColor<HTMLParagraphElement>();\n const sectionCtx = useContext(SectionInstanceSlotsCtx);\n // Registry resolves the authored Default section's human title for the\n // design-mode hint (COMS-1770). Sections register with `type = section.uid`\n // and `displayName = section.title`, so a uid lookup yields the title.\n const { componentRegistry } = useRenderer();\n // When the enclosing placed section is in preview mode, the slot renders like\n // production: an empty slot collapses to nothing and a filled slot drops its\n // drop-chrome / selection affordances.\n const isSectionPreview = useContext(SectionModeContext) === \"preview\";\n const { currentNodePath: parentNodePath = [] } = useCurrentNode();\n // Current section-local data (template scoped to section, in-section\n // repeater item if surrounding, etc.). Slot children inherit this as\n // their *default* context — the user's authored bindings on slot\n // children resolve against this by default.\n const sectionLocalData = useData();\n const slotDomRef = useCallback(\n (el: HTMLElement | null) => {\n if (el && sectionCtx?.sectionNode) {\n ELEMENT_TO_NODE.set(el, sectionCtx.sectionNode);\n }\n },\n [sectionCtx?.sectionNode],\n );\n // Slot child's data context namespace:\n //\n // dataSources.template = section-local scoped template; if the\n // slot sits inside an in-section\n // Repeater that's currently iterating,\n // this is the active iteration item.\n // Matches what the Data Picker writes\n // when authoring against fields from\n // the slot's surrounding section scope.\n // dataSources.repeater[uid] = in-section Repeater map (full\n // per-uid context). Inherited from\n // sectionLocal via {...sectionDS}.\n // dataSources.static_value = section's persisted static values.\n // dataSources.page = OUTERMOST page-level namespace\n // ({ template, contentstack,\n // contentstack_queries, ... }).\n // Always points to the real page even\n // across recursive slot nesting — see\n // `truePageNamespace` below.\n //\n // Until Phase 8 lands, picker emits `dataSources.<src>.X` paths only.\n // retrieve-data.ts retries unresolved `dataSources.<src>.X` lookups under\n // `dataSources.page.<src>.X` so page-level bindings authored on slot\n // children still resolve.\n const slotChildData = useMemo(() => {\n const sectionLocal: any = sectionLocalData || {};\n const pageOuter: any = sectionCtx?.pageOuterData || {};\n const pageDS = pageOuter?.dataSources || {};\n const sectionDS = sectionLocal?.dataSources || {};\n\n const repeaterMap = (sectionDS.repeater || {}) as Record<string, any>;\n const repeaterUids = Object.keys(repeaterMap);\n const activeRepeaterUid =\n repeaterUids.length > 0\n ? repeaterUids[repeaterUids.length - 1]\n : undefined;\n const activeItem = activeRepeaterUid\n ? repeaterMap[activeRepeaterUid]?.context\n : undefined;\n const sectionLocalTemplate = activeItem ?? sectionDS.template;\n\n // Slot child's default namespace = section-local context AS IS (template,\n // repeater, static_value, …). Page-level sources are nested under `page.*`\n // as the explicit escape. This matches what the Data Picker writes when\n // authoring a slot child (picker shows the slot child's surrounding\n // scope, so its `template.X` / `repeater[uid].context.X` paths resolve\n // natively without rewriting).\n //\n // For nested cases (Section B in Section A's slot), `page` must always\n // point to the OUTERMOST page context — not to Section A's slot-local\n // view. Otherwise each nesting level shadows `page` with the surrounding\n // section's local, and `dataSources.page.template.title` would resolve\n // to a modular_block item instead of the page entry. So: if the outer\n // dataSources already has its own `page` key (because the section we're\n // inside is itself in another slot), inherit THAT — it's the real page.\n const outerPage = (pageDS as any)?.page;\n const truePageNamespace = outerPage ?? pageDS;\n return {\n ...sectionLocal,\n dataSources: {\n ...sectionDS,\n template: sectionLocalTemplate,\n page: truePageNamespace,\n },\n };\n }, [sectionLocalData, sectionCtx?.pageOuterData]);\n\n // ALL hooks above are unconditional. From here, branch based on mode.\n const styles = styleFactory(css);\n const text = label && label.trim().length > 0 ? label : \"Drop Here\";\n const slotUid =\n _uid ||\n (studioAttributes as any)?.[COMPOSABLE_DATA_ATTRIBUTES.ID] ||\n \"section-slot\";\n\n // Design-mode hint (COMS-1770): resolve the Default section's title for the\n // message. `getComponent` throws for a uid outside the locally-known catalog,\n // so fall back to a nameless hint instead of crashing the slot.\n let defaultSectionTitle: string | undefined;\n if (defaultSection) {\n try {\n defaultSectionTitle =\n componentRegistry.getComponent(defaultSection)?.displayName;\n } catch {\n defaultSectionTitle = undefined;\n }\n }\n\n // Authoring mode: section is the top-level composition being edited.\n if (!sectionCtx) {\n return (\n <div\n {...{\n [COMPOSABLE_DATA_ATTRIBUTES.SLOT]: true,\n [COMPOSABLE_DATA_ATTRIBUTES.SLOT_UID]: slotUid,\n }}\n {...studioAttributes}\n className={classNames(styles.slotStyle)}\n >\n <span\n ref={authoringCopyColor.ref}\n className={classNames(\n styles.slotDropText,\n authoringCopyColor.colorClassName,\n authoringCopyColor.strokeClassName,\n )}\n >\n <AddIcon /> {text}\n </span>\n </div>\n );\n }\n\n // Consumption mode.\n const filled = (sectionCtx.slotsMap[slotUid] || []) as Node[];\n const dropZoneAttrs = {\n [COMPOSABLE_DATA_ATTRIBUTES.BUILDER]: true,\n [COMPOSABLE_DATA_ATTRIBUTES.NODE]: true,\n [COMPOSABLE_DATA_ATTRIBUTES.ID]: sectionCtx.sectionInstanceUid,\n [COMPOSABLE_DATA_ATTRIBUTES.SLOT]: true,\n [COMPOSABLE_DATA_ATTRIBUTES.SLOT_UID]: slotUid,\n };\n\n if (filled.length === 0) {\n // Preview mode: an empty slot falls back to its authored default section\n // (COMS-1659), rendered like production — non-interactive, no drop chrome.\n // With no default it collapses to nothing. Design mode always shows the\n // dropzone below (default never shown while authoring the placement).\n if (isSectionPreview) {\n if (!defaultSection) return null;\n const synth = makeDefaultSectionNode(\n sectionCtx.sectionInstanceUid,\n slotUid,\n defaultSection,\n );\n NODE_TO_PARENT.set(synth, sectionCtx.sectionNode);\n NODE_TO_PATH_NODE.set(synth, [slotUid, 0]);\n return (\n <DataCtxProvider value={slotChildData}>\n <PreviewModeContext.Provider value={true}>\n <div style={{ display: \"contents\" }}>\n <SectionInstanceSlotsCtx.Provider value={undefined}>\n <CurrentNodeContext.Provider\n value={{\n currentNodeUid: synth.uid,\n currentNodePath: [...parentNodePath, [slotUid, 0]],\n }}\n >\n <Element node={synth} renderError={() => null as any} />\n </CurrentNodeContext.Provider>\n </SectionInstanceSlotsCtx.Provider>\n </div>\n </PreviewModeContext.Provider>\n </DataCtxProvider>\n );\n }\n return (\n <div\n ref={slotDomRef as any}\n {...dropZoneAttrs}\n {...studioAttributes}\n // Column: the default-section hint stacks below the drop copy. Sections\n // are added by dropping one here or from the slot's Insert handle in\n // Studio (COMS-2392), which offers the slot's allowed sections.\n className={classNames(styles.slotStyle, styles.slotColumnStyle)}\n >\n {/* One empty-state layout regardless of a configured default — only\n the parenthetical hint below is default-only. The drop copy keeps\n \"…to replace it\" solely when there IS a default to replace. */}\n <span\n ref={dropCopyColor.ref}\n className={classNames(\n styles.slotDropText,\n dropCopyColor.colorClassName,\n dropCopyColor.strokeClassName,\n )}\n >\n <AddIcon />{\" \"}\n {defaultSection\n ? \"Drop a section here to replace it.\"\n : \"Drop a section here.\"}\n </span>\n {/* Design-mode hint (COMS-1770): tell the page composer that leaving\n this slot empty will render the author's Default section in preview\n and on the live page. Mirrors the repeater's condition-block hint\n (Slot.tsx). Only shown when a default is configured. */}\n {defaultSection ? (\n <p\n ref={defaultHintCopyColor.ref}\n className={classNames(\n styles.slotDefaultHint,\n defaultHintCopyColor.colorClassName,\n defaultHintCopyColor.strokeClassName,\n )}\n >\n {\"(When this slot is empty, the default section\"}\n {defaultSectionTitle ? (\n <>\n {\" (\"}\n <strong>{defaultSectionTitle}</strong>\n {\")\"}\n </>\n ) : null}\n {\n \" added by the section author is shown in Preview and on the live page.)\"\n }\n </p>\n ) : null}\n </div>\n );\n }\n\n // Transclude filled children. Anchor each child's slate path under the\n // page-side section-composition node + this slot's uid. In design mode, exit\n // preview so Element's internalAttributes get applied — making each child\n // selectable, hover-highlightable, and draggable like a normal node. In\n // preview mode, keep them inside preview (non-interactive) and drop the\n // drop-zone attributes so the slot reads like production.\n return (\n <DataCtxProvider value={slotChildData}>\n <PreviewModeContext.Provider value={isSectionPreview}>\n <div\n ref={slotDomRef as any}\n {...(isSectionPreview ? {} : dropZoneAttrs)}\n {...studioAttributes}\n style={{ display: \"contents\" }}\n >\n {/*\n * The filled children are PAGE-authored content the composer dropped\n * into this slot — not part of the section's authored body. Clear the\n * section-instance context for them so their own internal slots render\n * normally (e.g. an empty Repeater dropped here shows its \"Drop Here\"\n * placeholder instead of being suppressed by Slot.tsx's\n * in-section-consumption guard, which would make it disappear).\n */}\n <SectionInstanceSlotsCtx.Provider value={undefined}>\n <SlotChildrenWithPermanentDropZones\n slotOwner={sectionCtx.sectionNode}\n slotChildren={filled}\n renderSlotChild={(child, idx) => {\n if (!child || typeof child !== \"object\") return null;\n NODE_TO_PARENT.set(child, sectionCtx.sectionNode);\n NODE_TO_PATH_NODE.set(child, [slotUid, idx]);\n const childPath: Path = [...parentNodePath, [slotUid, idx]];\n return (\n <CurrentNodeContext.Provider\n value={{\n currentNodeUid: child.uid,\n currentNodePath: childPath,\n }}\n >\n <SelectedNodeProvider>\n <Element node={child} renderError={() => null as any} />\n </SelectedNodeProvider>\n </CurrentNodeContext.Provider>\n );\n }}\n />\n </SectionInstanceSlotsCtx.Provider>\n </div>\n </PreviewModeContext.Provider>\n </DataCtxProvider>\n );\n}\n"],"names":["_jsx","_jsxs","Element","_Fragment"],"mappings":";;;;;;;;;;;;;;;;;AAsCA;;;;;AAKG;AACH,SAAS,sBAAsB,CAC7B,WAA+B,EAC/B,OAAe,EACf,UAAkB,EAAA;;;;;;AAOlB,IAAA,MAAM,MAAM,GAAG,WAAW,GAAG,CAAA,EAAG,WAAW,CAAA,CAAA,CAAG,GAAG,EAAE;IACnD,OAAO;AACL,QAAA,IAAI,EAAE,qBAAqB;AAC3B,QAAA,GAAG,EAAE,CAAA,EAAG,MAAM,GAAG,OAAO,CAAA,SAAA,EAAY,UAAU,CAAA,CAAE;QAChD,QAAQ,EAAE,EAAE,cAAc,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE;AACzD,QAAA,KAAK,EAAE,EAAE;AACT,QAAA,KAAK,EAAE,EAAE;AACT,QAAA,KAAK,EAAE,EAAE;AACT,QAAA,MAAM,EAAE,EAAE;KACH;AACX;AAEA;;;;;;;;;;;;;;;;;;AAkBG;AACG,SAAU,WAAW,CAAC,EAC1B,gBAAgB,EAChB,KAAK,EACL,IAAI,EACJ,cAAc,GACS,EAAA;;;;;AAKvB,IAAA,MAAM,kBAAkB,GAAG,gBAAgB,EAAmB;AAC9D,IAAA,MAAM,aAAa,GAAG,gBAAgB,EAAmB;AACzD,IAAA,MAAM,oBAAoB,GAAG,gBAAgB,EAAwB;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EAAA,CACd;AAEtB;;;;"}
@@ -1,10 +1,33 @@
1
+ import { COMPOSABLE_DATA_ATTRIBUTES } from '@contentstack/studio-client';
1
2
  import { STUDIO_CHROME_MODES } from '../utils/copy-color.util.js';
2
3
 
3
- /** Builds one class per chrome mode from the same tokens the maths reads. */
4
- const perMode = (css, rule) => Object.fromEntries(Object.entries(STUDIO_CHROME_MODES).map(([mode, tokens]) => [
5
- mode,
6
- css(rule(tokens)),
4
+ /** Builds one class per chrome mode from a table of each mode's tokens. */
5
+ const buildClassPerChromeMode = (css, tokensByChromeMode, buildRule) => Object.fromEntries(Object.keys(tokensByChromeMode).map((chromeMode) => [
6
+ chromeMode,
7
+ css(buildRule(tokensByChromeMode[chromeMode])),
7
8
  ]));
9
+ /**
10
+ * Light keeps the pinned design; dark takes the dark chrome tokens so the zone
11
+ * doesn't glare on a dark page.
12
+ */
13
+ const PERMANENT_DROP_ZONE_COLORS_BY_CHROME_MODE = {
14
+ light: {
15
+ background: "#FAFAFA",
16
+ borderColor: "#D1D5DB",
17
+ targetedBackground: "#EDE9FE",
18
+ iconColor: "#9CA3AF",
19
+ // Darker than the design's grey, which read as disabled; matches the ink
20
+ // of the empty-slot copy.
21
+ labelColor: STUDIO_CHROME_MODES.light.secondary,
22
+ },
23
+ dark: {
24
+ background: STUDIO_CHROME_MODES.dark.surface,
25
+ borderColor: STUDIO_CHROME_MODES.dark.surfaceEdge,
26
+ targetedBackground: STUDIO_CHROME_MODES.dark.emphasisSurface,
27
+ iconColor: "rgba(255, 255, 255, 0.6)",
28
+ labelColor: STUDIO_CHROME_MODES.dark.secondary,
29
+ },
30
+ };
8
31
  const styleFactory = (css) => ({
9
32
  embedStyle: css({
10
33
  height: "100%",
@@ -87,7 +110,7 @@ const styleFactory = (css) => ({
87
110
  // colour that gets scored is the colour that gets painted. `!important`
88
111
  // because this chrome renders inside the customer's page, whose CSS would
89
112
  // otherwise recolour it.
90
- slotCopyColors: perMode(css, (tokens) => ({
113
+ slotCopyColors: buildClassPerChromeMode(css, STUDIO_CHROME_MODES, (tokens) => ({
91
114
  color: `${tokens.ink} !important`,
92
115
  })),
93
116
  // A stroke for a bare label the ink cannot carry on its own — the mid-tone
@@ -95,7 +118,7 @@ const styleFactory = (css) => ({
95
118
  // sit on. Stroking in the opposite mode's ink gives each glyph its own local
96
119
  // polarity without painting a fill behind it. `paint-order` puts the stroke
97
120
  // under the fill so the letterforms stay their own weight.
98
- slotCopyStroke: perMode(css, (tokens) => ({
121
+ slotCopyStroke: buildClassPerChromeMode(css, STUDIO_CHROME_MODES, (tokens) => ({
99
122
  // Stroke in the opposite mode's ink — that is the colour guaranteed to
100
123
  // contrast with this mode's.
101
124
  WebkitTextStroke: `2px ${tokens.surface}`,
@@ -125,6 +148,59 @@ const styleFactory = (css) => ({
125
148
  lineHeight: "24px !important",
126
149
  letterSpacing: "0 !important",
127
150
  }),
151
+ // A permanent drop zone beside a Repeater. Layout only; its colours come
152
+ // from `permanentDropZoneColors`, picked per page tone like the slot chrome.
153
+ permanentDropZone: css({
154
+ boxSizing: "border-box",
155
+ margin: 0,
156
+ display: "flex",
157
+ flexFlow: "wrap",
158
+ alignItems: "center",
159
+ justifyContent: "center",
160
+ gap: "0 12px",
161
+ padding: "8px 16px",
162
+ minHeight: "44px",
163
+ borderWidth: "2px",
164
+ borderStyle: "dashed",
165
+ borderRadius: 0,
166
+ userSelect: "none",
167
+ transition: "background-color 0.15s, border-color 0.15s",
168
+ }),
169
+ // The zone has its own fill, so it stays readable in light on a page whose
170
+ // colour can't be measured. `!important` on the copy, set through these
171
+ // variables, because the customer's CSS reaches it too.
172
+ permanentDropZoneColors: buildClassPerChromeMode(css, PERMANENT_DROP_ZONE_COLORS_BY_CHROME_MODE, (colors) => ({
173
+ background: colors.background,
174
+ borderColor: colors.borderColor,
175
+ "--cs-permanent-drop-zone-icon": colors.iconColor,
176
+ "--cs-permanent-drop-zone-label": colors.labelColor,
177
+ // Highlights while a drag targets it: the client marks the zone it picked
178
+ // as the drop target, the same choice that tells Studio where it drops.
179
+ [`&[${COMPOSABLE_DATA_ATTRIBUTES.PERMANENT_DROP_ZONE_TARGETED}]`]: {
180
+ background: colors.targetedBackground,
181
+ borderColor: "#6C5CE7",
182
+ },
183
+ })),
184
+ permanentDropZoneAwaitingBackdrop: css({
185
+ display: "none !important",
186
+ }),
187
+ permanentDropZoneLabelRow: css({
188
+ display: "flex",
189
+ alignItems: "center",
190
+ gap: "8px",
191
+ // The icon draws in `currentColor`.
192
+ color: "var(--cs-permanent-drop-zone-icon) !important",
193
+ "& svg": {
194
+ flexShrink: 0,
195
+ },
196
+ }),
197
+ permanentDropZoneLabel: css({
198
+ color: "var(--cs-permanent-drop-zone-label) !important",
199
+ fontFamily: "Inter, sans-serif !important",
200
+ fontSize: "13px !important",
201
+ fontStyle: "normal !important",
202
+ fontWeight: "500 !important",
203
+ }),
128
204
  embeddedSectionHost: css({
129
205
  position: "relative",
130
206
  ".cs-embedded-section-edit-btn": {
@@ -1 +1 @@
1
- {"version":3,"file":"styles.js","sources":["../../src/components/styles.ts"],"sourcesContent":["import { css as gooberCss, CSSAttribute } from \"goober\";\nimport {\n STUDIO_CHROME_MODES,\n StudioChromeMode,\n} from \"../utils/copy-color.util\";\n\n/** Builds one class per chrome mode from the same tokens the maths reads. */\nconst perMode = (\n css: typeof gooberCss,\n rule: (\n tokens: (typeof STUDIO_CHROME_MODES)[StudioChromeMode],\n ) => CSSAttribute,\n): Record<StudioChromeMode, string> =>\n Object.fromEntries(\n Object.entries(STUDIO_CHROME_MODES).map(([mode, tokens]) => [\n mode,\n css(rule(tokens)),\n ]),\n ) as Record<StudioChromeMode, string>;\n\nexport const styleFactory = (css: typeof gooberCss) => ({\n embedStyle: css({\n height: \"100%\",\n width: \"100%\",\n display: \"grid\",\n placeItems: \"center\",\n padding: \"1rem\",\n border: \"1px solid #dde3ee\",\n }),\n embedIconStyle: css({\n opacity: 0.5,\n }),\n pageStyle: css({\n height: \"100%\",\n }),\n slotStyle: css({\n boxSizing: \"border-box\",\n // width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n gap: \"4px\",\n alignItems: \"center\",\n justifyContent: \"center\",\n // No background of its own. An earlier fix painted every dropzone white,\n // on the premise that the host page's colour could not be known or read\n // reliably. It can: the walk in copy-color.util.ts reads it, and the chrome\n // colours itself from the answer. A white fill also made empty columns read\n // as occupied — the dashed outline says empty while the fill says full —\n // which is why it is gone rather than kept alongside.\n //\n // Two-tone outline. A lone dashed border leaves its gaps transparent, so\n // the slot boundary washes out against dark or purple-ish host pages.\n // The element's own border is a solid white ring; the dashes are painted\n // over it by the overlay below, leaving white — not the page — in the\n // gaps, which reads on any background.\n position: \"relative\",\n border: \"1px solid #ffffff\",\n \"&::before\": {\n content: '\"\"',\n position: \"absolute\",\n // Sit on the border ring itself, not inside the padding box.\n inset: \"-1px\",\n border: \"1px dashed #6c5ce7\",\n pointerEvents: \"none\",\n },\n color: \"#475161\",\n fontSize: \"14px\",\n fontStyle: \"normal\",\n fontWeight: 400,\n lineHeight: \"24px\",\n userSelect: \"none\",\n fontFamily: \"Inter, sans-serif\",\n paddingInline: \"2rem\",\n paddingBlock: \"1rem\",\n transition: \"background-color 0.3s ease\",\n }),\n slotContentStyle: css({\n marginBottom: 0,\n marginTop: 0,\n }),\n slotColumnStyle: css({\n flexDirection: \"column\",\n gap: \"4px\",\n }),\n // Drop copy and hints sit on top of whatever the host page paints behind\n // the slot, so no fixed colour is readable on every page. These rules carry\n // only layout — the colour comes from a class chosen per line:\n // `slotCopyColors` when the page colour can be measured,\n // `slotCopyOverImage` when it cannot.\n slotDropText: css({\n display: \"inline-flex\",\n alignItems: \"center\",\n gap: \"6px\",\n }),\n slotHintStyle: css({\n textAlign: \"center\",\n margin: 0,\n }),\n // Ink per mode, built from the same tokens the contrast maths reads, so the\n // colour that gets scored is the colour that gets painted. `!important`\n // because this chrome renders inside the customer's page, whose CSS would\n // otherwise recolour it.\n slotCopyColors: perMode(css, (tokens) => ({\n color: `${tokens.ink} !important`,\n })),\n // A stroke for a bare label the ink cannot carry on its own — the mid-tone\n // band, where a card would take a surface but a one-line label has nothing to\n // sit on. Stroking in the opposite mode's ink gives each glyph its own local\n // polarity without painting a fill behind it. `paint-order` puts the stroke\n // under the fill so the letterforms stay their own weight.\n slotCopyStroke: perMode(css, (tokens) => ({\n // Stroke in the opposite mode's ink — that is the colour guaranteed to\n // contrast with this mode's.\n WebkitTextStroke: `2px ${tokens.surface}`,\n paintOrder: \"stroke fill\",\n fontWeight: 600,\n })),\n // Fallback for pages whose background cannot be read from computed styles —\n // a gradient, photo or video behind the slot. With nothing to measure and no\n // fill to sit on, the copy goes white and leans on a soft dark shadow, the\n // usual way text survives over imagery of unknown brightness.\n slotCopyOverImage: css({\n color: \"#ffffff !important\",\n textShadow: \"0 1px 3px rgba(0, 0, 0, 0.85), 0 0 10px rgba(0, 0, 0, 0.55)\",\n }),\n // Section-slot Default-section hint (COMS-1770). Typography pinned to the\n // Figma spec (Text/Secondary_Text); the colour comes from the measured copy\n // colour instead. `!important` because this chrome renders inside the\n // customer's page, whose CSS would otherwise override the weight/color\n // (e.g. render it bold).\n slotDefaultHint: css({\n margin: 0,\n textAlign: \"center\",\n fontFamily: \"Inter, sans-serif !important\",\n fontSize: \"14px !important\",\n fontStyle: \"normal !important\",\n fontWeight: \"400 !important\",\n lineHeight: \"24px !important\",\n letterSpacing: \"0 !important\",\n }),\n embeddedSectionHost: css({\n position: \"relative\",\n \".cs-embedded-section-edit-btn\": {\n display: \"none\",\n },\n \"&:hover\": {\n \".cs-embedded-section-edit-btn\": {\n display: \"flex\",\n },\n },\n }),\n embeddedSectionButton: css({\n position: \"absolute\",\n top: \"0.75rem\",\n right: \"0.75rem\",\n zIndex: 2,\n }),\n rendererErrorComponent: css({\n boxSizing: \"border-box\",\n backgroundColor: \"#fff0ed\",\n borderWidth: \"1px\",\n borderStyle: \"solid\",\n borderColor: \"#fdafa3\",\n boxShadow: `0px 2px 4px rgba(0, 0, 0, 0.14),\n 0px 5px 5px rgba(0, 0, 0, 0.12),\n 0px 1px 10px rgba(108, 92, 231, 0.2)`,\n borderRadius: \"4px\",\n padding: \"1rem\",\n color: \"#475161\",\n fontFamily: \"Inter, sans-serif\",\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"1rem\",\n \".header\": {\n display: \"flex\",\n alignItems: \"center\",\n gap: \"0.5rem\",\n },\n h3: {\n fontSize: \"14px\",\n fontWeight: 600,\n margin: 0,\n },\n p: {\n fontSize: \"1rem\",\n fontWeight: 400,\n lineHeight: \"24px\",\n letterSpacing: \"1%\",\n margin: 0,\n },\n }),\n welcomeContainer: css({\n display: \"flex\",\n flexDirection: \"column\",\n alignItems: \"center\",\n justifyContent: \"center\",\n padding: \"40px 20px\",\n textAlign: \"center\",\n minHeight: \"400px\",\n }),\n welcomeTitle: css({\n fontSize: \"20px\",\n fontWeight: \"600\",\n margin: \"20px 0 10px 0\",\n fontFamily: \"Inter, sans-serif\",\n }),\n welcomeSubtitle: css({\n fontSize: \"14px\",\n margin: \"0 0 30px 0\",\n maxWidth: \"400px\",\n fontFamily: \"Inter, sans-serif\",\n lineHeight: \"1.5\",\n }),\n welcomeSteps: css({\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"16px\",\n maxWidth: \"1000px\",\n width: \"100%\",\n }),\n welcomeStep: css({\n padding: \"16px\",\n border: \"1px solid #DDE3EE\",\n borderRadius: \"8px\",\n textAlign: \"left\",\n \"& h3\": {\n fontSize: \"16px\",\n fontWeight: \"600\",\n margin: \"0 0 8px 0\",\n fontFamily: \"Inter, sans-serif\",\n },\n \"& p\": {\n fontSize: \"14px\",\n margin: 0,\n fontFamily: \"Inter, sans-serif\",\n lineHeight: \"1.4\",\n },\n }),\n // Fill comes from the measurement; a fixed pale fill swallowed its own copy\n // at 1:1 once the ink adapted pale on a dark page. The purple border is what\n // marks the step regardless.\n activeWelcomeStep: css({\n border: \"1px solid #6C5CE7\",\n }),\n});\n"],"names":[],"mappings":";;AAMA;AACA,MAAM,OAAO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AE,KAAK;AACnB,QAAA,SAAS,EAAE,MAAM;AACjB,QAAA,MAAM,EAAE;AACN,YAAA,QAAQ,EAAE,MAAM;AAChB,YAAA,UAAU,EAAE,KAAK;AACjB,YAAA,MAAM,EAAE,WAAW;AACnB,YAAA,UAAU,EAAE,mBAAmB;AAChC,SAAA;AACD,QAAA,KAAK,EAAE;AACL,YAAA,QAAQ,EAAE,MAAM;AAChB,YAAA,MAAM,EAAE,CAAC;AACT,YAAA,UAAU,EAAE,mBAAmB;AAC/B,YAAA,UAAU,EAAE,KAAK;AAClB,SAAA;KACF,CAAC;;;;IAIF,iBAAiB,EAAE,GAAG,CAAC;AACrB,QAAA,MAAM,EAAE,mBAAmB;KAC5B,CAAC;AACH,CAAA;;;;"}
1
+ {"version":3,"file":"styles.js","sources":["../../src/components/styles.ts"],"sourcesContent":["import { COMPOSABLE_DATA_ATTRIBUTES } from \"@contentstack/studio-client\";\nimport { css as gooberCss, CSSAttribute } from \"goober\";\nimport {\n STUDIO_CHROME_MODES,\n StudioChromeMode,\n} from \"../utils/copy-color.util\";\n\n/** Builds one class per chrome mode from a table of each mode's tokens. */\nconst buildClassPerChromeMode = <\n TokensByChromeMode extends Record<StudioChromeMode, object>,\n>(\n css: typeof gooberCss,\n tokensByChromeMode: TokensByChromeMode,\n buildRule: (tokens: TokensByChromeMode[StudioChromeMode]) => CSSAttribute,\n): Record<StudioChromeMode, string> =>\n Object.fromEntries(\n (Object.keys(tokensByChromeMode) as StudioChromeMode[]).map(\n (chromeMode) => [\n chromeMode,\n css(buildRule(tokensByChromeMode[chromeMode])),\n ],\n ),\n ) as Record<StudioChromeMode, string>;\n\n/** The colours one chrome mode paints a permanent drop zone in. */\ninterface PermanentDropZoneColors {\n background: string;\n borderColor: string;\n /** Background while a drag targets the zone. */\n targetedBackground: string;\n iconColor: string;\n labelColor: string;\n}\n\n/**\n * Light keeps the pinned design; dark takes the dark chrome tokens so the zone\n * doesn't glare on a dark page.\n */\nconst PERMANENT_DROP_ZONE_COLORS_BY_CHROME_MODE: Record<\n StudioChromeMode,\n PermanentDropZoneColors\n> = {\n light: {\n background: \"#FAFAFA\",\n borderColor: \"#D1D5DB\",\n targetedBackground: \"#EDE9FE\",\n iconColor: \"#9CA3AF\",\n // Darker than the design's grey, which read as disabled; matches the ink\n // of the empty-slot copy.\n labelColor: STUDIO_CHROME_MODES.light.secondary,\n },\n dark: {\n background: STUDIO_CHROME_MODES.dark.surface,\n borderColor: STUDIO_CHROME_MODES.dark.surfaceEdge,\n targetedBackground: STUDIO_CHROME_MODES.dark.emphasisSurface,\n iconColor: \"rgba(255, 255, 255, 0.6)\",\n labelColor: STUDIO_CHROME_MODES.dark.secondary,\n },\n};\n\nexport const styleFactory = (css: typeof gooberCss) => ({\n embedStyle: css({\n height: \"100%\",\n width: \"100%\",\n display: \"grid\",\n placeItems: \"center\",\n padding: \"1rem\",\n border: \"1px solid #dde3ee\",\n }),\n embedIconStyle: css({\n opacity: 0.5,\n }),\n pageStyle: css({\n height: \"100%\",\n }),\n slotStyle: css({\n boxSizing: \"border-box\",\n // width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n gap: \"4px\",\n alignItems: \"center\",\n justifyContent: \"center\",\n // No background of its own. An earlier fix painted every dropzone white,\n // on the premise that the host page's colour could not be known or read\n // reliably. It can: the walk in copy-color.util.ts reads it, and the chrome\n // colours itself from the answer. A white fill also made empty columns read\n // as occupied — the dashed outline says empty while the fill says full —\n // which is why it is gone rather than kept alongside.\n //\n // Two-tone outline. A lone dashed border leaves its gaps transparent, so\n // the slot boundary washes out against dark or purple-ish host pages.\n // The element's own border is a solid white ring; the dashes are painted\n // over it by the overlay below, leaving white — not the page — in the\n // gaps, which reads on any background.\n position: \"relative\",\n border: \"1px solid #ffffff\",\n \"&::before\": {\n content: '\"\"',\n position: \"absolute\",\n // Sit on the border ring itself, not inside the padding box.\n inset: \"-1px\",\n border: \"1px dashed #6c5ce7\",\n pointerEvents: \"none\",\n },\n color: \"#475161\",\n fontSize: \"14px\",\n fontStyle: \"normal\",\n fontWeight: 400,\n lineHeight: \"24px\",\n userSelect: \"none\",\n fontFamily: \"Inter, sans-serif\",\n paddingInline: \"2rem\",\n paddingBlock: \"1rem\",\n transition: \"background-color 0.3s ease\",\n }),\n slotContentStyle: css({\n marginBottom: 0,\n marginTop: 0,\n }),\n slotColumnStyle: css({\n flexDirection: \"column\",\n gap: \"4px\",\n }),\n // Drop copy and hints sit on top of whatever the host page paints behind\n // the slot, so no fixed colour is readable on every page. These rules carry\n // only layout — the colour comes from a class chosen per line:\n // `slotCopyColors` when the page colour can be measured,\n // `slotCopyOverImage` when it cannot.\n slotDropText: css({\n display: \"inline-flex\",\n alignItems: \"center\",\n gap: \"6px\",\n }),\n slotHintStyle: css({\n textAlign: \"center\",\n margin: 0,\n }),\n // Ink per mode, built from the same tokens the contrast maths reads, so the\n // colour that gets scored is the colour that gets painted. `!important`\n // because this chrome renders inside the customer's page, whose CSS would\n // otherwise recolour it.\n slotCopyColors: buildClassPerChromeMode(\n css,\n STUDIO_CHROME_MODES,\n (tokens) => ({\n color: `${tokens.ink} !important`,\n }),\n ),\n // A stroke for a bare label the ink cannot carry on its own — the mid-tone\n // band, where a card would take a surface but a one-line label has nothing to\n // sit on. Stroking in the opposite mode's ink gives each glyph its own local\n // polarity without painting a fill behind it. `paint-order` puts the stroke\n // under the fill so the letterforms stay their own weight.\n slotCopyStroke: buildClassPerChromeMode(\n css,\n STUDIO_CHROME_MODES,\n (tokens) => ({\n // Stroke in the opposite mode's ink — that is the colour guaranteed to\n // contrast with this mode's.\n WebkitTextStroke: `2px ${tokens.surface}`,\n paintOrder: \"stroke fill\",\n fontWeight: 600,\n }),\n ),\n // Fallback for pages whose background cannot be read from computed styles —\n // a gradient, photo or video behind the slot. With nothing to measure and no\n // fill to sit on, the copy goes white and leans on a soft dark shadow, the\n // usual way text survives over imagery of unknown brightness.\n slotCopyOverImage: css({\n color: \"#ffffff !important\",\n textShadow: \"0 1px 3px rgba(0, 0, 0, 0.85), 0 0 10px rgba(0, 0, 0, 0.55)\",\n }),\n // Section-slot Default-section hint (COMS-1770). Typography pinned to the\n // Figma spec (Text/Secondary_Text); the colour comes from the measured copy\n // colour instead. `!important` because this chrome renders inside the\n // customer's page, whose CSS would otherwise override the weight/color\n // (e.g. render it bold).\n slotDefaultHint: css({\n margin: 0,\n textAlign: \"center\",\n fontFamily: \"Inter, sans-serif !important\",\n fontSize: \"14px !important\",\n fontStyle: \"normal !important\",\n fontWeight: \"400 !important\",\n lineHeight: \"24px !important\",\n letterSpacing: \"0 !important\",\n }),\n // A permanent drop zone beside a Repeater. Layout only; its colours come\n // from `permanentDropZoneColors`, picked per page tone like the slot chrome.\n permanentDropZone: css({\n boxSizing: \"border-box\",\n margin: 0,\n display: \"flex\",\n flexFlow: \"wrap\",\n alignItems: \"center\",\n justifyContent: \"center\",\n gap: \"0 12px\",\n padding: \"8px 16px\",\n minHeight: \"44px\",\n borderWidth: \"2px\",\n borderStyle: \"dashed\",\n borderRadius: 0,\n userSelect: \"none\",\n transition: \"background-color 0.15s, border-color 0.15s\",\n }),\n // The zone has its own fill, so it stays readable in light on a page whose\n // colour can't be measured. `!important` on the copy, set through these\n // variables, because the customer's CSS reaches it too.\n permanentDropZoneColors: buildClassPerChromeMode(\n css,\n PERMANENT_DROP_ZONE_COLORS_BY_CHROME_MODE,\n (colors) => ({\n background: colors.background,\n borderColor: colors.borderColor,\n \"--cs-permanent-drop-zone-icon\": colors.iconColor,\n \"--cs-permanent-drop-zone-label\": colors.labelColor,\n // Highlights while a drag targets it: the client marks the zone it picked\n // as the drop target, the same choice that tells Studio where it drops.\n [`&[${COMPOSABLE_DATA_ATTRIBUTES.PERMANENT_DROP_ZONE_TARGETED}]`]: {\n background: colors.targetedBackground,\n borderColor: \"#6C5CE7\",\n },\n }),\n ),\n permanentDropZoneAwaitingBackdrop: css({\n display: \"none !important\",\n }),\n permanentDropZoneLabelRow: css({\n display: \"flex\",\n alignItems: \"center\",\n gap: \"8px\",\n // The icon draws in `currentColor`.\n color: \"var(--cs-permanent-drop-zone-icon) !important\",\n \"& svg\": {\n flexShrink: 0,\n },\n }),\n permanentDropZoneLabel: css({\n color: \"var(--cs-permanent-drop-zone-label) !important\",\n fontFamily: \"Inter, sans-serif !important\",\n fontSize: \"13px !important\",\n fontStyle: \"normal !important\",\n fontWeight: \"500 !important\",\n }),\n embeddedSectionHost: css({\n position: \"relative\",\n \".cs-embedded-section-edit-btn\": {\n display: \"none\",\n },\n \"&:hover\": {\n \".cs-embedded-section-edit-btn\": {\n display: \"flex\",\n },\n },\n }),\n embeddedSectionButton: css({\n position: \"absolute\",\n top: \"0.75rem\",\n right: \"0.75rem\",\n zIndex: 2,\n }),\n rendererErrorComponent: css({\n boxSizing: \"border-box\",\n backgroundColor: \"#fff0ed\",\n borderWidth: \"1px\",\n borderStyle: \"solid\",\n borderColor: \"#fdafa3\",\n boxShadow: `0px 2px 4px rgba(0, 0, 0, 0.14),\n 0px 5px 5px rgba(0, 0, 0, 0.12),\n 0px 1px 10px rgba(108, 92, 231, 0.2)`,\n borderRadius: \"4px\",\n padding: \"1rem\",\n color: \"#475161\",\n fontFamily: \"Inter, sans-serif\",\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"1rem\",\n \".header\": {\n display: \"flex\",\n alignItems: \"center\",\n gap: \"0.5rem\",\n },\n h3: {\n fontSize: \"14px\",\n fontWeight: 600,\n margin: 0,\n },\n p: {\n fontSize: \"1rem\",\n fontWeight: 400,\n lineHeight: \"24px\",\n letterSpacing: \"1%\",\n margin: 0,\n },\n }),\n welcomeContainer: css({\n display: \"flex\",\n flexDirection: \"column\",\n alignItems: \"center\",\n justifyContent: \"center\",\n padding: \"40px 20px\",\n textAlign: \"center\",\n minHeight: \"400px\",\n }),\n welcomeTitle: css({\n fontSize: \"20px\",\n fontWeight: \"600\",\n margin: \"20px 0 10px 0\",\n fontFamily: \"Inter, sans-serif\",\n }),\n welcomeSubtitle: css({\n fontSize: \"14px\",\n margin: \"0 0 30px 0\",\n maxWidth: \"400px\",\n fontFamily: \"Inter, sans-serif\",\n lineHeight: \"1.5\",\n }),\n welcomeSteps: css({\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"16px\",\n maxWidth: \"1000px\",\n width: \"100%\",\n }),\n welcomeStep: css({\n padding: \"16px\",\n border: \"1px solid #DDE3EE\",\n borderRadius: \"8px\",\n textAlign: \"left\",\n \"& h3\": {\n fontSize: \"16px\",\n fontWeight: \"600\",\n margin: \"0 0 8px 0\",\n fontFamily: \"Inter, sans-serif\",\n },\n \"& p\": {\n fontSize: \"14px\",\n margin: 0,\n fontFamily: \"Inter, sans-serif\",\n lineHeight: \"1.4\",\n },\n }),\n // Fill comes from the measurement; a fixed pale fill swallowed its own copy\n // at 1:1 once the ink adapted pale on a dark page. The purple border is what\n // marks the step regardless.\n activeWelcomeStep: css({\n border: \"1px solid #6C5CE7\",\n }),\n});\n"],"names":[],"mappings":";;;AAOA;AACA,MAAM,uBAAuB,GAAG,CAG9B,GAAqB,EACrB,kBAAsC,EACtC,SAAyE,KAEzE,MAAM,CAAC,WAAW,CACf,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAwB,CAAC,GAAG,CACzD,CAAC,UAAU,KAAK;IACd,UAAU;IACV,GAAG,CAAC,SAAS,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC,CAAC;AAC/C,CAAA,CACF,CACkC;AAYvC;;;AAGG;AACH,MAAM,yCAAyC,GAG3C;AACF,IAAA,KAAK,EAAE;AACL,QAAA,UAAU,EAAE,SAAS;AACrB,QAAA,WAAW,EAAE,SAAS;AACtB,QAAA,kBAAkB,EAAE,SAAS;AAC7B,QAAA,SAAS,EAAE,SAAS;;;AAGpB,QAAA,UAAU,EAAE,mBAAmB,CAAC,KAAK,CAAC,SAAS;AAChD,KAAA;AACD,IAAA,IAAI,EAAE;AACJ,QAAA,UAAU,EAAE,mBAAmB,CAAC,IAAI,CAAC,OAAO;AAC5C,QAAA,WAAW,EAAE,mBAAm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;AAClB,QAAA,KAAK,EAAE,MAAM;KACd,CAAC;IACF,WAAW,EAAE,GAAG,CAAC;AACf,QAAA,OAAO,EAAE,MAAM;AACf,QAAA,MAAM,EAAE,mBAAmB;AAC3B,QAAA,YAAY,EAAE,KAAK;AACnB,QAAA,SAAS,EAAE,MAAM;AACjB,QAAA,MAAM,EAAE;AACN,YAAA,QAAQ,EAAE,MAAM;AAChB,YAAA,UAAU,EAAE,KAAK;AACjB,YAAA,MAAM,EAAE,WAAW;AACnB,YAAA,UAAU,EAAE,mBAAmB;AAChC,SAAA;AACD,QAAA,KAAK,EAAE;AACL,YAAA,QAAQ,EAAE,MAAM;AAChB,YAAA,MAAM,EAAE,CAAC;AACT,YAAA,UAAU,EAAE,mBAAmB;AAC/B,YAAA,UAAU,EAAE,KAAK;AAClB,SAAA;KACF,CAAC;;;;IAIF,iBAAiB,EAAE,GAAG,CAAC;AACrB,QAAA,MAAM,EAAE,mBAAmB;KAC5B,CAAC;AACH,CAAA;;;;"}
@@ -0,0 +1,20 @@
1
+ import { useDesignPreviewContext } from './use-design-preview.hook.js';
2
+ import { usePreviewMode } from './use-preview-mode.hook.js';
3
+ import { useRenderer } from './use-renderer.hook.js';
4
+
5
+ /**
6
+ * Whether permanent drop zones may show here: only while editing, never in
7
+ * preview mode, and never inside a Repeater or Condition block that is showing
8
+ * its preview, where children render once per item and zones would repeat.
9
+ */
10
+ function useCanShowPermanentDropZones() {
11
+ const { isCompositionBeingEdited } = useRenderer();
12
+ const isPreviewMode = usePreviewMode();
13
+ const designPreviewContext = useDesignPreviewContext();
14
+ return (isCompositionBeingEdited &&
15
+ !isPreviewMode &&
16
+ designPreviewContext !== "preview");
17
+ }
18
+
19
+ export { useCanShowPermanentDropZones };
20
+ //# sourceMappingURL=use-can-show-permanent-drop-zones.hook.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-can-show-permanent-drop-zones.hook.js","sources":["../../src/hooks/use-can-show-permanent-drop-zones.hook.ts"],"sourcesContent":["import { useDesignPreviewContext } from \"./use-design-preview.hook\";\nimport { usePreviewMode } from \"./use-preview-mode.hook\";\nimport { useRenderer } from \"./use-renderer.hook\";\n\n/**\n * Whether permanent drop zones may show here: only while editing, never in\n * preview mode, and never inside a Repeater or Condition block that is showing\n * its preview, where children render once per item and zones would repeat.\n */\nexport function useCanShowPermanentDropZones(): boolean {\n const { isCompositionBeingEdited } = useRenderer();\n const isPreviewMode = usePreviewMode();\n const designPreviewContext = useDesignPreviewContext();\n return (\n isCompositionBeingEdited &&\n !isPreviewMode &&\n designPreviewContext !== \"preview\"\n );\n}\n"],"names":[],"mappings":";;;;AAIA;;;;AAIG;SACa,4BAA4B,GAAA;AAC1C,IAAA,MAAM,EAAE,wBAAwB,EAAE,GAAG,WAAW,EAAE;AAClD,IAAA,MAAM,aAAa,GAAG,cAAc,EAAE;AACtC,IAAA,MAAM,oBAAoB,GAAG,uBAAuB,EAAE;AACtD,IAAA,QACE,wBAAwB;AACxB,QAAA,CAAC,aAAa;QACd,oBAAoB,KAAK,SAAS;AAEtC;;;;"}
@@ -6,7 +6,14 @@ import { useDesignPreviewContext } from './use-design-preview.hook.js';
6
6
  import { useRenderer } from './use-renderer.hook.js';
7
7
  import { useRepeaterContext } from './use-repeater.hook.js';
8
8
 
9
- function useShouldShowDesign(mode) {
9
+ /**
10
+ * The design-or-preview rule for a Repeater or Condition block rendered in the
11
+ * calling component's context, as a function of the node's own `mode`. Code
12
+ * that judges a slot's children before they render, like permanent drop zone
13
+ * placement, calls it with each child's `metadata.mode` to get the answer the
14
+ * child will reach.
15
+ */
16
+ function useRendersDesignForMode() {
10
17
  const { isCompositionBeingEdited } = useRenderer();
11
18
  const { isInsideRepeater } = useRepeaterContext();
12
19
  const { isInsideConditionBlock } = useConditionBlockContext();
@@ -18,41 +25,46 @@ function useShouldShowDesign(mode) {
18
25
  // `isInsideStudioFrame()` (URL-param-gated) so Visual Builder's iframe
19
26
  // (which should render preview) is correctly excluded.
20
27
  const isInsideStudio = clientRendererModeUtil.isInsideStudioFrame();
21
- if (!isCompositionBeingEdited && !isInsideStudio)
22
- return false;
23
- // A placed section forces the mode of everything inside it — a single
24
- // per-placement switch that overrides each inner node's own `mode`. Only set
25
- // inside a section placement in the editor; null everywhere else.
26
- // - PREVIEW always wins → render preview.
27
- // - DESIGN keeps the section's own drop-zones visible, BUT when the section
28
- // is itself nested inside an enclosing PREVIEW repeater its internal data
29
- // repeaters must still iterate — otherwise a data-bound slot child can
30
- // never resolve its per-iteration context (SP7.1: a slot-bearing section
31
- // defaults to design via COMS-1595, which froze its inner repeaters). So
32
- // defer to the enclosing preview context in that case. At the page root
33
- // designPreviewContext is "none", so design is preserved (the slot's own
34
- // drop-zone-vs-collapsed rendering reads SectionModeContext directly and
35
- // is unaffected either way).
36
- if (sectionMode === "preview")
37
- return false;
38
- if (sectionMode === "design")
39
- return designPreviewContext !== "preview";
40
- if (isInsideRepeater || isInsideConditionBlock) {
41
- // If composition is being edited and current node(Repeater or Condition Block) inside another repeater or condition block,
42
- // and no designPreviewContext is provided, then show design
43
- if (!designPreviewContext)
28
+ return (mode) => {
29
+ if (!isCompositionBeingEdited && !isInsideStudio)
30
+ return false;
31
+ // A placed section forces the mode of everything inside it — a single
32
+ // per-placement switch that overrides each inner node's own `mode`. Only set
33
+ // inside a section placement in the editor; null everywhere else.
34
+ // - PREVIEW always wins → render preview.
35
+ // - DESIGN keeps the section's own drop-zones visible, BUT when the section
36
+ // is itself nested inside an enclosing PREVIEW repeater its internal data
37
+ // repeaters must still iterate — otherwise a data-bound slot child can
38
+ // never resolve its per-iteration context (SP7.1: a slot-bearing section
39
+ // defaults to design via COMS-1595, which froze its inner repeaters). So
40
+ // defer to the enclosing preview context in that case. At the page root
41
+ // designPreviewContext is "none", so design is preserved (the slot's own
42
+ // drop-zone-vs-collapsed rendering reads SectionModeContext directly and
43
+ // is unaffected either way).
44
+ if (sectionMode === "preview")
45
+ return false;
46
+ if (sectionMode === "design")
47
+ return designPreviewContext !== "preview";
48
+ if (isInsideRepeater || isInsideConditionBlock) {
49
+ // If composition is being edited and current node(Repeater or Condition Block) inside another repeater or condition block,
50
+ // and no designPreviewContext is provided, then show design
51
+ if (!designPreviewContext)
52
+ return true;
53
+ // If designPreviewContext is provided,
54
+ // then show design based on designPreviewContext
55
+ return designPreviewContext === "design";
56
+ }
57
+ // if no mode is provided, then show design
58
+ if (!mode) {
44
59
  return true;
45
- // If designPreviewContext is provided,
46
- // then show design based on designPreviewContext
47
- return designPreviewContext === "design";
48
- }
49
- // if no mode is provided, then show design
50
- if (!mode) {
51
- return true;
52
- }
53
- // If mode is provided, then show design based on mode
54
- return mode === "design";
60
+ }
61
+ // If mode is provided, then show design based on mode
62
+ return mode === "design";
63
+ };
64
+ }
65
+ function useShouldShowDesign(mode) {
66
+ return useRendersDesignForMode()(mode);
55
67
  }
56
68
 
57
- export { useShouldShowDesign };
69
+ export { useRendersDesignForMode, useShouldShowDesign };
58
70
  //# sourceMappingURL=use-should-show-design.hook.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-should-show-design.hook.js","sources":["../../src/hooks/use-should-show-design.hook.ts"],"sourcesContent":["import { clientRendererModeUtil } from \"@contentstack/studio-client\";\nimport { useContext } from \"react\";\nimport { SectionModeContext } from \"../contexts/providers/section-mode.provider\";\nimport { useConditionBlockContext } from \"./use-condition-block-context\";\nimport { useDesignPreviewContext } from \"./use-design-preview.hook\";\nimport { useRenderer } from \"./use-renderer.hook\";\nimport { useRepeaterContext } from \"./use-repeater.hook\";\n\nexport function useShouldShowDesign(mode: \"design\" | \"preview\") {\n const { isCompositionBeingEdited } = useRenderer();\n const { isInsideRepeater } = useRepeaterContext();\n const { isInsideConditionBlock } = useConditionBlockContext();\n const designPreviewContext = useDesignPreviewContext();\n const sectionMode = useContext(SectionModeContext);\n // Treat the Studio editor frame as design-mode-eligible from the very first\n // render — even before `isCompositionBeingEdited` has resolved — to avoid a\n // one-frame preview render that would inject items[0] context. Use\n // `isInsideStudioFrame()` (URL-param-gated) so Visual Builder's iframe\n // (which should render preview) is correctly excluded.\n const isInsideStudio = clientRendererModeUtil.isInsideStudioFrame();\n if (!isCompositionBeingEdited && !isInsideStudio) return false;\n\n // A placed section forces the mode of everything inside it — a single\n // per-placement switch that overrides each inner node's own `mode`. Only set\n // inside a section placement in the editor; null everywhere else.\n // - PREVIEW always wins → render preview.\n // - DESIGN keeps the section's own drop-zones visible, BUT when the section\n // is itself nested inside an enclosing PREVIEW repeater its internal data\n // repeaters must still iterate — otherwise a data-bound slot child can\n // never resolve its per-iteration context (SP7.1: a slot-bearing section\n // defaults to design via COMS-1595, which froze its inner repeaters). So\n // defer to the enclosing preview context in that case. At the page root\n // designPreviewContext is \"none\", so design is preserved (the slot's own\n // drop-zone-vs-collapsed rendering reads SectionModeContext directly and\n // is unaffected either way).\n if (sectionMode === \"preview\") return false;\n if (sectionMode === \"design\") return designPreviewContext !== \"preview\";\n\n if (isInsideRepeater || isInsideConditionBlock) {\n // If composition is being edited and current node(Repeater or Condition Block) inside another repeater or condition block,\n // and no designPreviewContext is provided, then show design\n if (!designPreviewContext) return true;\n // If designPreviewContext is provided,\n // then show design based on designPreviewContext\n return designPreviewContext === \"design\";\n }\n // if no mode is provided, then show design\n if (!mode) {\n return true;\n }\n // If mode is provided, then show design based on mode\n return mode === \"design\";\n}\n"],"names":[],"mappings":";;;;;;;;AAQM,SAAU,mBAAmB,CAAC,IAA0B,EAAA;AAC5D,IAAA,MAAM,EAAE,wBAAwB,EAAE,GAAG,WAAW,EAAE;AAClD,IAAA,MAAM,EAAE,gBAAgB,EAAE,GAAG,kBAAkB,EAAE;AACjD,IAAA,MAAM,EAAE,sBAAsB,EAAE,GAAG,wBAAwB,EAAE;AAC7D,IAAA,MAAM,oBAAoB,GAAG,uBAAuB,EAAE;AACtD,IAAA,MAAM,WAAW,GAAG,UAAU,CAAC,kBAAkB,CAAC;;;;;;AAMlD,IAAA,MAAM,cAAc,GAAG,sBAAsB,CAAC,mBAAmB,EAAE;AACnE,IAAA,IAAI,CAAC,wBAAwB,IAAI,CAAC,cAAc;AAAE,QAAA,OAAO,KAAK;;;;;;;;;;;;;;IAe9D,IAAI,WAAW,KAAK,SAAS;AAAE,QAAA,OAAO,KAAK;IAC3C,IAAI,WAAW,KAAK,QAAQ;QAAE,OAAO,oBAAoB,KAAK,SAAS;AAEvE,IAAA,IAAI,gBAAgB,IAAI,sBAAsB,EAAE;;;AAG9C,QAAA,IAAI,CAAC,oBAAoB;AAAE,YAAA,OAAO,IAAI;;;QAGtC,OAAO,oBAAoB,KAAK,QAAQ;IAC1C;;IAEA,IAAI,CAAC,IAAI,EAAE;AACT,QAAA,OAAO,IAAI;IACb;;IAEA,OAAO,IAAI,KAAK,QAAQ;AAC1B;;;;"}
1
+ {"version":3,"file":"use-should-show-design.hook.js","sources":["../../src/hooks/use-should-show-design.hook.ts"],"sourcesContent":["import { clientRendererModeUtil } from \"@contentstack/studio-client\";\nimport { useContext } from \"react\";\nimport type { DesignPreviewMode, RendersDesignForMode } from \"../types\";\nimport { SectionModeContext } from \"../contexts/providers/section-mode.provider\";\nimport { useConditionBlockContext } from \"./use-condition-block-context\";\nimport { useDesignPreviewContext } from \"./use-design-preview.hook\";\nimport { useRenderer } from \"./use-renderer.hook\";\nimport { useRepeaterContext } from \"./use-repeater.hook\";\n\n/**\n * The design-or-preview rule for a Repeater or Condition block rendered in the\n * calling component's context, as a function of the node's own `mode`. Code\n * that judges a slot's children before they render, like permanent drop zone\n * placement, calls it with each child's `metadata.mode` to get the answer the\n * child will reach.\n */\nexport function useRendersDesignForMode(): RendersDesignForMode {\n const { isCompositionBeingEdited } = useRenderer();\n const { isInsideRepeater } = useRepeaterContext();\n const { isInsideConditionBlock } = useConditionBlockContext();\n const designPreviewContext = useDesignPreviewContext();\n const sectionMode = useContext(SectionModeContext);\n // Treat the Studio editor frame as design-mode-eligible from the very first\n // render — even before `isCompositionBeingEdited` has resolved — to avoid a\n // one-frame preview render that would inject items[0] context. Use\n // `isInsideStudioFrame()` (URL-param-gated) so Visual Builder's iframe\n // (which should render preview) is correctly excluded.\n const isInsideStudio = clientRendererModeUtil.isInsideStudioFrame();\n return (mode) => {\n if (!isCompositionBeingEdited && !isInsideStudio) return false;\n\n // A placed section forces the mode of everything inside it — a single\n // per-placement switch that overrides each inner node's own `mode`. Only set\n // inside a section placement in the editor; null everywhere else.\n // - PREVIEW always wins → render preview.\n // - DESIGN keeps the section's own drop-zones visible, BUT when the section\n // is itself nested inside an enclosing PREVIEW repeater its internal data\n // repeaters must still iterate — otherwise a data-bound slot child can\n // never resolve its per-iteration context (SP7.1: a slot-bearing section\n // defaults to design via COMS-1595, which froze its inner repeaters). So\n // defer to the enclosing preview context in that case. At the page root\n // designPreviewContext is \"none\", so design is preserved (the slot's own\n // drop-zone-vs-collapsed rendering reads SectionModeContext directly and\n // is unaffected either way).\n if (sectionMode === \"preview\") return false;\n if (sectionMode === \"design\") return designPreviewContext !== \"preview\";\n\n if (isInsideRepeater || isInsideConditionBlock) {\n // If composition is being edited and current node(Repeater or Condition Block) inside another repeater or condition block,\n // and no designPreviewContext is provided, then show design\n if (!designPreviewContext) return true;\n // If designPreviewContext is provided,\n // then show design based on designPreviewContext\n return designPreviewContext === \"design\";\n }\n // if no mode is provided, then show design\n if (!mode) {\n return true;\n }\n // If mode is provided, then show design based on mode\n return mode === \"design\";\n };\n}\n\nexport function useShouldShowDesign(mode: DesignPreviewMode) {\n return useRendersDesignForMode()(mode);\n}\n"],"names":[],"mappings":";;;;;;;;AASA;;;;;;AAMG;SACa,uBAAuB,GAAA;AACrC,IAAA,MAAM,EAAE,wBAAwB,EAAE,GAAG,WAAW,EAAE;AAClD,IAAA,MAAM,EAAE,gBAAgB,EAAE,GAAG,kBAAkB,EAAE;AACjD,IAAA,MAAM,EAAE,sBAAsB,EAAE,GAAG,wBAAwB,EAAE;AAC7D,IAAA,MAAM,oBAAoB,GAAG,uBAAuB,EAAE;AACtD,IAAA,MAAM,WAAW,GAAG,UAAU,CAAC,kBAAkB,CAAC;;;;;;AAMlD,IAAA,MAAM,cAAc,GAAG,sBAAsB,CAAC,mBAAmB,EAAE;IACnE,OAAO,CAAC,IAAI,KAAI;AACd,QAAA,IAAI,CAAC,wBAAwB,IAAI,CAAC,cAAc;AAAE,YAAA,OAAO,KAAK;;;;;;;;;;;;;;QAe9D,IAAI,WAAW,KAAK,SAAS;AAAE,YAAA,OAAO,KAAK;QAC3C,IAAI,WAAW,KAAK,QAAQ;YAAE,OAAO,oBAAoB,KAAK,SAAS;AAEvE,QAAA,IAAI,gBAAgB,IAAI,sBAAsB,EAAE;;;AAG9C,YAAA,IAAI,CAAC,oBAAoB;AAAE,gBAAA,OAAO,IAAI;;;YAGtC,OAAO,oBAAoB,KAAK,QAAQ;QAC1C;;QAEA,IAAI,CAAC,IAAI,EAAE;AACT,YAAA,OAAO,IAAI;QACb;;QAEA,OAAO,IAAI,KAAK,QAAQ;AAC1B,IAAA,CAAC;AACH;AAEM,SAAU,mBAAmB,CAAC,IAAuB,EAAA;AACzD,IAAA,OAAO,uBAAuB,EAAE,CAAC,IAAI,CAAC;AACxC;;;;"}
@@ -1,19 +1,14 @@
1
1
  import { css } from 'goober';
2
+ import { isEqual } from 'lodash-es';
2
3
  import { useState, useRef, useCallback, useEffect } from 'react';
3
4
  import { styleFactory } from '../components/styles.js';
4
5
  import { watchBackdropChanges } from '../utils/backdrop-watcher.util.js';
5
6
  import { resolveBackdropColor, pickChromeMode, STUDIO_CHROME_MODES, needsStroke, needsSurface } from '../utils/copy-color.util.js';
6
7
 
7
- /**
8
- * Resolves which mode a piece of slot chrome should render in, from the page
9
- * colour behind it.
10
- *
11
- * Measures from the element's parent so the walk starts outside the chrome
12
- * itself. Pages whose background cannot be read from computed styles — a
13
- * gradient, photo or video — fall back to a treatment that needs no measuring.
14
- */
15
8
  function useSlotCopyColor() {
16
- const [measured, setMeasured] = useState(null);
9
+ // `undefined` until the first measurement; `null` when the page colour
10
+ // could not be read.
11
+ const [measured, setMeasured] = useState(undefined);
17
12
  const styles = styleFactory(css);
18
13
  const node = useRef(null);
19
14
  const measure = useCallback((element) => {
@@ -21,7 +16,14 @@ function useSlotCopyColor() {
21
16
  if (!parent)
22
17
  return;
23
18
  const backdrop = resolveBackdropColor(parent);
24
- setMeasured(backdrop ? { mode: pickChromeMode(backdrop), backdrop } : null);
19
+ const nextMeasurement = backdrop
20
+ ? { mode: pickChromeMode(backdrop), backdrop }
21
+ : null;
22
+ // The watcher re-measures on any style change in the page; keep the same
23
+ // state when the answer hasn't changed, so the chrome doesn't re-render.
24
+ setMeasured((previousMeasurement) => isEqual(previousMeasurement, nextMeasurement)
25
+ ? previousMeasurement
26
+ : nextMeasurement);
25
27
  }, []);
26
28
  // Identity must stay stable: a fresh callback each render would make React
27
29
  // detach and reattach the node, re-measuring forever.
@@ -37,6 +39,7 @@ function useSlotCopyColor() {
37
39
  ref,
38
40
  mode: measured?.mode ?? null,
39
41
  backdrop: measured?.backdrop ?? null,
42
+ hasMeasuredBackdrop: measured !== undefined,
40
43
  tokens: measured ? STUDIO_CHROME_MODES[measured.mode] : null,
41
44
  surfaceNeeded: measured
42
45
  ? needsSurface(measured.mode, measured.backdrop)
@@ -1 +1 @@
1
- {"version":3,"file":"use-slot-copy-color.hook.js","sources":["../../src/hooks/use-slot-copy-color.hook.ts"],"sourcesContent":["import { css } from \"goober\";\nimport { RefCallback, useCallback, useEffect, useRef, useState } from \"react\";\nimport { styleFactory } from \"../components/styles\";\nimport { watchBackdropChanges } from \"../utils/backdrop-watcher.util\";\nimport {\n needsStroke,\n needsSurface,\n pickChromeMode,\n resolveBackdropColor,\n Rgb,\n STUDIO_CHROME_MODES,\n StudioChromeMode,\n} from \"../utils/copy-color.util\";\n\nexport interface SlotChrome<T extends HTMLElement> {\n /**\n * Attach to the element carrying the chrome. A callback ref rather than an\n * object one: it measures the moment the node attaches, and it types the same\n * way against React 18 and 19.\n */\n ref: RefCallback<T>;\n /** Ink colour class to apply alongside the element's own class. */\n colorClassName: string;\n /** The mode in use, or null while the page colour could not be read. */\n mode: StudioChromeMode | null;\n /** The measured page colour, or null when it could not be read. */\n backdrop: Rgb | null;\n /**\n * True where the mode's ink cannot carry body copy on the page itself, so\n * chrome with more than a label in it needs the mode's surface behind it.\n */\n surfaceNeeded: boolean;\n /** The mode's Venus tokens, or null while unmeasured. */\n tokens: (typeof STUDIO_CHROME_MODES)[StudioChromeMode] | null;\n /**\n * Stroke class for a bare label the ink alone cannot carry on this page, or\n * null where it can. Only chrome that is a bare label needs this; anything\n * with a surface available should take the surface instead.\n */\n strokeClassName: string | null;\n}\n\n/**\n * Resolves which mode a piece of slot chrome should render in, from the page\n * colour behind it.\n *\n * Measures from the element's parent so the walk starts outside the chrome\n * itself. Pages whose background cannot be read from computed styles — a\n * gradient, photo or video — fall back to a treatment that needs no measuring.\n */\nexport function useSlotCopyColor<T extends HTMLElement>(): SlotChrome<T> {\n const [measured, setMeasured] = useState<{\n mode: StudioChromeMode;\n backdrop: Rgb;\n } | null>(null);\n const styles = styleFactory(css);\n\n const node = useRef<T | null>(null);\n\n const measure = useCallback((element: T | null) => {\n const parent = element?.parentElement;\n if (!parent) return;\n const backdrop = resolveBackdropColor(parent);\n setMeasured(backdrop ? { mode: pickChromeMode(backdrop), backdrop } : null);\n }, []);\n\n // Identity must stay stable: a fresh callback each render would make React\n // detach and reattach the node, re-measuring forever.\n const ref = useCallback<RefCallback<T>>(\n (element) => {\n node.current = element;\n measure(element);\n },\n [measure],\n );\n\n // The page can change under the chrome after it mounts — a host with its own\n // dark-mode toggle leaves a colour that was chosen for the previous\n // background, and it can land as low as 1.05:1 against the new one.\n useEffect(() => watchBackdropChanges(() => measure(node.current)), [measure]);\n\n return {\n ref,\n mode: measured?.mode ?? null,\n backdrop: measured?.backdrop ?? null,\n tokens: measured ? STUDIO_CHROME_MODES[measured.mode] : null,\n surfaceNeeded: measured\n ? needsSurface(measured.mode, measured.backdrop)\n : false,\n colorClassName: measured\n ? styles.slotCopyColors[measured.mode]\n : styles.slotC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AAE;cACX,YAAY,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,QAAQ;AAC/C,cAAE,KAAK;AACT,QAAA,cAAc,EAAE;cACZ,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAI;cACnC,MAAM,CAAC,iBAAiB;AAC5B,QAAA,eAAe,EACb,QAAQ,IAAI,WAAW,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,QAAQ;cACpD,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAI;AACrC,cAAE,IAAI;KACX;AACH;;;;"}
1
+ {"version":3,"file":"use-slot-copy-color.hook.js","sources":["../../src/hooks/use-slot-copy-color.hook.ts"],"sourcesContent":["import { css } from \"goober\";\nimport { isEqual } from \"lodash-es\";\nimport { RefCallback, useCallback, useEffect, useRef, useState } from \"react\";\nimport { styleFactory } from \"../components/styles\";\nimport { watchBackdropChanges } from \"../utils/backdrop-watcher.util\";\nimport {\n needsStroke,\n needsSurface,\n pickChromeMode,\n resolveBackdropColor,\n Rgb,\n STUDIO_CHROME_MODES,\n StudioChromeMode,\n} from \"../utils/copy-color.util\";\n\nexport interface SlotChrome<T extends HTMLElement> {\n /**\n * Attach to the element carrying the chrome. A callback ref rather than an\n * object one: it measures the moment the node attaches, and it types the same\n * way against React 18 and 19.\n */\n ref: RefCallback<T>;\n /** Ink colour class to apply alongside the element's own class. */\n colorClassName: string;\n /** The mode in use, or null while the page colour could not be read. */\n mode: StudioChromeMode | null;\n /** The measured page colour, or null when it could not be read. */\n backdrop: Rgb | null;\n /**\n * False until the page colour behind the element has been read once, even\n * if it turned out unreadable. Chrome that animates its colours stays out of\n * layout until then, so it never paints the fallback and fades from it.\n */\n hasMeasuredBackdrop: boolean;\n /**\n * True where the mode's ink cannot carry body copy on the page itself, so\n * chrome with more than a label in it needs the mode's surface behind it.\n */\n surfaceNeeded: boolean;\n /** The mode's Venus tokens, or null while unmeasured. */\n tokens: (typeof STUDIO_CHROME_MODES)[StudioChromeMode] | null;\n /**\n * Stroke class for a bare label the ink alone cannot carry on this page, or\n * null where it can. Only chrome that is a bare label needs this; anything\n * with a surface available should take the surface instead.\n */\n strokeClassName: string | null;\n}\n\n/**\n * Resolves which mode a piece of slot chrome should render in, from the page\n * colour behind it.\n *\n * Measures from the element's parent so the walk starts outside the chrome\n * itself. Pages whose background cannot be read from computed styles — a\n * gradient, photo or video — fall back to a treatment that needs no measuring.\n */\n/** The page colour behind the chrome and the mode picked for it. */\ninterface BackdropMeasurement {\n mode: StudioChromeMode;\n backdrop: Rgb;\n}\n\nexport function useSlotCopyColor<T extends HTMLElement>(): SlotChrome<T> {\n // `undefined` until the first measurement; `null` when the page colour\n // could not be read.\n const [measured, setMeasured] = useState<\n BackdropMeasurement | null | undefined\n >(undefined);\n const styles = styleFactory(css);\n\n const node = useRef<T | null>(null);\n\n const measure = useCallback((element: T | null) => {\n const parent = element?.parentElement;\n if (!parent) return;\n const backdrop = resolveBackdropColor(parent);\n const nextMeasurement: BackdropMeasurement | null = backdrop\n ? { mode: pickChromeMode(backdrop), backdrop }\n : null;\n // The watcher re-measures on any style change in the page; keep the same\n // state when the answer hasn't changed, so the chrome doesn't re-render.\n setMeasured((previousMeasurement) =>\n isEqual(previousMeasurement, nextMeasurement)\n ? previousMeasurement\n : nextMeasurement,\n );\n }, []);\n\n // Identity must stay stable: a fresh callback each render would make React\n // detach and reattach the node, re-measuring forever.\n const ref = useCallback<RefCallback<T>>(\n (element) => {\n node.current = element;\n measure(element);\n },\n [measure],\n );\n\n // The page can change under the chrome after it mounts — a host with its own\n // dark-mode toggle leaves a colour that was chosen for the previous\n // background, and it can land as low as 1.05:1 against the new one.\n useEffect(() => watchBackdropChanges(() => measure(node.current)), [measure]);\n\n return {\n ref,\n mode: measured?.mode ?? null,\n backdrop: measured?.backdrop ?? null,\n hasMeasuredBackdrop: measured !== undefined,\n tokens: measured ? STUDIO_CHROME_MODES[measured.mode] : null,\n surfaceNeeded: measured\n ? needsSurface(measured.mode, measured.backdrop)\n : false,\n colorClassName: measured\n ? styles.slotCopyColors[measured.mode]\n : styles.slotCopyOverImage,\n strokeClassName:\n measured && needsStroke(measured.mode, measured.backdrop)\n ? styles.slotCopyStroke[measured.mode]\n : null,\n };\n}\n"],"names":[],"mappings":";;;;;;;SA+DgB,gBAAgB,GAAA;;;IAG9B,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAEtC,SAAS,CAAC;AACZ,IAAA,MAAM,MAAM,GAAG,YAAY,CAAC,GAAG,CAAC;AAEhC,IAAA,MAAM,IAAI,GAAG,MAAM,CAAW,IAAI,CAAC;AAEnC,IAAA,MAAM,OAAO,GAAG,WAAW,CAAC,CAAC,OAAiB,KAAI;AAChD,QAAA,MAAM,MAAM,GAAG,OAAO,EAAE,aAAa;AACrC,QAAA,IAAI,CAAC,MAAM;YAAE;AACb,QAAA,MAAM,QAAQ,GAAG,oBAAoB,CAAC,MAAM,CAAC;QAC7C,MAAM,eAAe,GAA+B;cAChD,EAAE,IAAI,EAAE,cAAc,CAAC,QAAQ,CAAC,EAAE,QAAQ;cAC1C,IAAI;;;QAGR,WAAW,CAAC,CAAC,mBAAmB,KAC9B,OAAO,CAAC,mBAAmB,EAAE,eAAe;AAC1C,cAAE;cACA,eAAe,CACpB;IACH,CAAC,EAAE,EAAE,CAAC;;;AAIN,IAAA,MAAM,GAAG,GAAG,WAAW,CACrB,CAAC,OAAO,KAAI;AACV,QAAA,IAAI,CAAC,OAAO,GAAG,OAAO;QACtB,OAAO,CAAC,OAAO,CAAC;AAClB,IAAA,CAAC,EACD,CAAC,OAAO,CAAC,CACV;;;;IAKD,SAAS,CAAC,MAAM,oBAAoB,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;IAE7E,OAAO;QACL,GAAG;AACH,QAAA,IAAI,EAAE,QAAQ,EAAE,IAAI,IAAI,IAAI;AAC5B,QAAA,QAAQ,EAAE,QAAQ,EAAE,QAAQ,IAAI,IAAI;QACpC,mBAAmB,EAAE,QAAQ,KAAK,SAAS;AAC3C,QAAA,MAAM,EAAE,QAAQ,GAAG,mBAAmB,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,IAAI;AAC5D,QAAA,aAAa,EAAE;cACX,YAAY,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,QAAQ;AAC/C,cAAE,KAAK;AACT,QAAA,cAAc,EAAE;cACZ,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAI;cACnC,MAAM,CAAC,iBAAiB;AAC5B,QAAA,eAAe,EACb,QAAQ,IAAI,WAAW,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,QAAQ;cACpD,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAI;AACrC,cAAE,IAAI;KACX;AACH;;;;"}
@@ -109,6 +109,65 @@ const getRepeaterFieldName = (node) => {
109
109
  const field = path?.split(".").pop();
110
110
  return field ? uidToDisplayName(field) : undefined;
111
111
  };
112
+ const NO_PERMANENT_DROP_ZONES = new Map();
113
+ /**
114
+ * The node's own Design/Preview toggle. `metadata` is loosely typed, so anything
115
+ * other than the two toggle values reads as unset.
116
+ */
117
+ const readDesignPreviewMode = (node) => {
118
+ const mode = node.metadata.mode;
119
+ return mode === "design" || mode === "preview" ? mode : undefined;
120
+ };
121
+ /**
122
+ * A Repeater that renders its design and whose own items include a Condition
123
+ * block: a Repeater over modular blocks, built by hand or by the starting
124
+ * layout. Its canvas shows only per-block drop targets, so the author needs the
125
+ * zones to see where content for the rest of the page goes. Any other
126
+ * Repeater is ordinary content.
127
+ */
128
+ const isModularBlockRepeaterInDesign = (node, rendersDesignForMode) => node.type === INTERNAL_COMPONENTS_NAMES.REPEATER &&
129
+ rendersDesignForMode(readDesignPreviewMode(node)) &&
130
+ Object.values(node.slots).some((items) => items.some((item) => item.type === INTERNAL_COMPONENTS_NAMES.CONDITION_BLOCK));
131
+ /**
132
+ * Whether `candidate`, a child of `slotOwner`, gets a block Repeater's
133
+ * permanent drop zones. A wrapped Repeater's zones go on its wrapper, never
134
+ * inside it; a wrapper with no such Repeater left in it, or only a hidden one
135
+ * the canvas never draws, is just a Box.
136
+ */
137
+ const isPermanentDropZoneAnchor = (candidate, slotOwner, rendersDesignForMode) => {
138
+ if (candidate.metadata.repeaterWrapper) {
139
+ return Object.values(candidate.slots).some((items) => items.some((item) => item.metadata.visible !== false &&
140
+ isModularBlockRepeaterInDesign(item, rendersDesignForMode)));
141
+ }
142
+ return (!slotOwner.metadata.repeaterWrapper &&
143
+ isModularBlockRepeaterInDesign(candidate, rendersDesignForMode));
144
+ };
145
+ /**
146
+ * Permanent drop zones for one slot's children, keyed by slot index. A zone
147
+ * marks an empty gap next to a block Repeater (first, between two, last), so
148
+ * filling the gap removes it. Hidden children are skipped: gaps are judged by
149
+ * what the canvas draws.
150
+ *
151
+ * @param rendersDesignForMode - The design-or-preview rule in the slot's context, so a
152
+ * Repeater counts as in design exactly when it will render its design.
153
+ */
154
+ const getPermanentDropZonePlacements = (slotOwner, slotChildren, rendersDesignForMode) => {
155
+ const visibleChildIndexes = slotChildren.flatMap((child, index) => child.metadata.visible === false ? [] : [index]);
156
+ const isAnchorAtVisiblePosition = visibleChildIndexes.map((childIndex) => isPermanentDropZoneAnchor(slotChildren[childIndex], slotOwner, rendersDesignForMode));
157
+ if (!isAnchorAtVisiblePosition.includes(true))
158
+ return NO_PERMANENT_DROP_ZONES;
159
+ const placementsBySlotIndex = new Map();
160
+ visibleChildIndexes.forEach((childIndex, visiblePosition) => {
161
+ if (!isAnchorAtVisiblePosition[visiblePosition])
162
+ return;
163
+ placementsBySlotIndex.set(childIndex, {
164
+ hasZoneBefore: visiblePosition === 0,
165
+ hasZoneAfter: visiblePosition === visibleChildIndexes.length - 1 ||
166
+ isAnchorAtVisiblePosition[visiblePosition + 1],
167
+ });
168
+ });
169
+ return placementsBySlotIndex;
170
+ };
112
171
 
113
- export { getConditionWellHint, getSlotHint, shouldRenderSlot };
172
+ export { getConditionWellHint, getPermanentDropZonePlacements, getSlotHint, shouldRenderSlot };
114
173
  //# sourceMappingURL=renderer.util.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"renderer.util.js","sources":["../../src/utils/renderer.util.ts"],"sourcesContent":["import { NODE_TO_PARENT } from \"@contentstack/studio-client\";\nimport type {\n Condition,\n ConditionDisplay,\n Node,\n} from \"@contentstack/studio-internal\";\nimport {\n getBindingFieldPath,\n getConditionHint,\n uidToDisplayName,\n} from \"@contentstack/studio-internal\";\nimport {\n ComponentRegistry,\n INTERNAL_COMPONENTS_NAMES,\n} from \"@contentstack/studio-registry\";\nimport { ReactNode } from \"react\";\n\nexport const shouldRenderSlot = (\n componentRegistry: ComponentRegistry<(props?: any) => ReactNode>,\n parent: Node,\n nodes: Node[],\n isCompositionBeingEdited: boolean,\n) => {\n if (!isCompositionBeingEdited) return false;\n if (!componentRegistry?.hasComponent(parent)) {\n return false;\n }\n const isEmpty = nodes.length === 0;\n\n return isEmpty;\n};\n\n/**\n * Placeholder text for an empty slot owned by `parent`, or `undefined` for the\n * plain \"Drop Here\".\n *\n * Covers the two hints a node can read off itself: the repeater advice, and a\n * condition block's own empty slot. The third case — the single container inside\n * a condition block — is handed down by the block instead; see\n * `getConditionWellHint`.\n *\n * Repeater and condition hints are mutually exclusive by construction — a node\n * cannot be both — so they share the single `hint` channel and need no\n * precedence rule between them.\n */\nexport const getSlotHint = (parent: Node): string | undefined => {\n if (\n parent.type === INTERNAL_COMPONENTS_NAMES.REPEATER &&\n parent.metadata?.repeaterBindingFieldType\n ) {\n return \"It is recommended to drop a condition block inside the repeater to handle Modular Blocks & References.\";\n }\n\n if (parent.type !== INTERNAL_COMPONENTS_NAMES.CONDITION_BLOCK)\n return undefined;\n\n return getConditionBlockHint(parent);\n};\n\n/**\n * The hint a condition block hands down to `child` when the child's empty slot is\n * the block's **drop well**, or `undefined` when it is not.\n *\n * A condition block is `display: contents`, so it has no drop area of its own.\n * The well is therefore the block's own slot while the block is empty (handled by\n * `getSlotHint`), and the slot of the single container placed inside it once one\n * has been (typically the Box auto-inserted for modular-block / reference\n * repeaters). Those two are mutually exclusive in time: the moment the Box\n * exists, the block's own slot is filled and stops rendering a placeholder.\n *\n * The block computes this and passes it DOWN, rather than the container looking\n * UP for its block. Elements are memoised on node identity, and editor state is\n * structurally shared: setting the block's condition replaces the block and its\n * ancestors but leaves the container the same object. A container that read the\n * condition off its parent would therefore never re-render and keep the hint it\n * drew before the condition existed. The block always re-renders when anything\n * the hint depends on changes — its own condition, or the container filling —\n * so deriving it there and passing it as a prop keeps the two in step.\n *\n * The rule is positional, not provenance-based: a Box the author dropped in\n * themselves is treated exactly like the auto-inserted one, because its\n * provenance is invisible to the author and should not change what the slot\n * says. Depth stops at one hop — a well is a single slot, so a placeholder\n * nested deeper is not standing in for the block's contents.\n */\nexport const getConditionWellHint = (\n block: Node,\n child: Node,\n): string | undefined => {\n if (block.type !== INTERNAL_COMPONENTS_NAMES.CONDITION_BLOCK)\n return undefined;\n\n // The block must hold exactly this one node. With two empty containers there\n // is no single well, and printing the hint on both would be noise.\n const blockChildren = Object.values(block.slots || {}).flat();\n if (blockChildren.length !== 1 || blockChildren[0]?.uid !== child.uid)\n return undefined;\n\n // And that node must itself be empty — once real content lands anywhere under\n // the block, no slot beneath it is standing in for the block's contents.\n if (Object.values(child.slots || {}).flat().length > 0) return undefined;\n\n return getConditionBlockHint(block);\n};\n\n/** The condition a block's drop well describes, as \"When …\" text. */\nconst getConditionBlockHint = (block: Node): string | undefined => {\n // An `unsupported` hint means a condition IS set but cannot be described.\n // \"Drop Here\" on its own is already a complete, correct message, so the well\n // says nothing extra rather than guessing.\n //\n // `conditionDisplay` carries the display names resolved when the condition was\n // authored. The helper falls back to the stored uids when it is absent, which\n // is the permanent case for conditions written by the CLI or the API.\n const hint = getConditionHint(\n block.metadata?.condition as Condition | undefined,\n block.metadata?.conditionDisplay as ConditionDisplay | undefined,\n {\n subject: getRepeaterFieldName(\n NODE_TO_PARENT.get(block) as Node | undefined,\n ),\n },\n );\n return hint?.kind === \"info\" ? `${hint.prefix} ${hint.value}` : undefined;\n};\n\n/**\n * The field a Repeater iterates, as a display name — `hero_sections` → \"Hero\n * Sections\".\n *\n * Recovers the subject of a condition whose own binding has collapsed into its\n * value: a repeater-scoped condition's `path` is rewritten to the branch, but the\n * Repeater it sits in still names the field. Used only as a fallback, so a name\n * stamped at author time always wins.\n *\n * De-uid-ified deliberately, unlike a subject read from the condition's own\n * binding. This is the same string the Repeater's own hint renders one row up in\n * Layers (\"Iterates Hero Sections\"), so showing it raw here would make the two\n * disagree about the same field.\n */\nconst getRepeaterFieldName = (node?: Node): string | undefined => {\n if (node?.type !== INTERNAL_COMPONENTS_NAMES.REPEATER) return undefined;\n const binding = (node.props?.items as { binding?: any } | undefined)?.binding;\n const path = getBindingFieldPath(binding);\n const field = path?.split(\".\").pop();\n return field ? uidToDisplayName(field) : undefined;\n};\n"],"names":[],"mappings":";;;;AAiBO,MAAM,gBAAgB,GAAG,CAC9B,iBAAgE,EAChE,MAAY,EACZ,KAAa,EACb,wBAAiC,KAC/B;AACF,IAAA,IAAI,CAAC,wBAAwB;AAAE,QAAA,OAAO,KAAK;IAC3C,IAAI,CAAC,iBAAiB,EAAE,YAAY,CAAC,MAAM,CAAC,EAAE;AAC5C,QAAA,OAAO,KAAK;IACd;AACA,IAAA,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,KAAK,CAAC;AAElC,IAAA,OAAO,OAAO;AAChB;AAEA;;;;;;;;;;;;AAYG;AACI,MAAM,WAAW,GAAG,CAAC,MAAY,KAAwB;AAC9D,IAAA,IACE,MAAM,CAAC,IAAI,KAAK,yBAAyB,CAAC,QAAQ;AAClD,QAAA,MAAM,CAAC,QAAQ,EAAE,wBAAwB,EACzC;AACA,QAAA,OAAO,wGAAwG;IACjH;AAEA,IAAA,IAAI,MAAM,CAAC,IAAI,KAAK,yBAAyB,CAAC,eAAe;A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AK,yBAAyB,CAAC,QAAQ;AAAE,QAAA,OAAO,SAAS;IACvE,MAAM,OAAO,GAAI,IAAI,CAAC,KAAK,EAAE,KAAuC,EAAE,OAAO;AAC7E,IAAA,MAAM,IAAI,GAAG,mBAAmB,CAAC,OAAO,CAAC;IACzC,MAAM,KAAK,GAAG,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE;AACpC,IAAA,OAAO,KAAK,GAAG,gBAAgB,CAAC,KAAK,CAAC,GAAG,SAAS;AACpD,CAAC;;;;"}
1
+ {"version":3,"file":"renderer.util.js","sources":["../../src/utils/renderer.util.ts"],"sourcesContent":["import { NODE_TO_PARENT } from \"@contentstack/studio-client\";\nimport type {\n Condition,\n ConditionDisplay,\n Node,\n} from \"@contentstack/studio-internal\";\nimport {\n getBindingFieldPath,\n getConditionHint,\n uidToDisplayName,\n} from \"@contentstack/studio-internal\";\nimport {\n ComponentRegistry,\n INTERNAL_COMPONENTS_NAMES,\n} from \"@contentstack/studio-registry\";\nimport { ReactNode } from \"react\";\nimport type { DesignPreviewMode, RendersDesignForMode } from \"../types\";\n\nexport const shouldRenderSlot = (\n componentRegistry: ComponentRegistry<(props?: any) => ReactNode>,\n parent: Node,\n nodes: Node[],\n isCompositionBeingEdited: boolean,\n) => {\n if (!isCompositionBeingEdited) return false;\n if (!componentRegistry?.hasComponent(parent)) {\n return false;\n }\n const isEmpty = nodes.length === 0;\n\n return isEmpty;\n};\n\n/**\n * Placeholder text for an empty slot owned by `parent`, or `undefined` for the\n * plain \"Drop Here\".\n *\n * Covers the two hints a node can read off itself: the repeater advice, and a\n * condition block's own empty slot. The third case — the single container inside\n * a condition block — is handed down by the block instead; see\n * `getConditionWellHint`.\n *\n * Repeater and condition hints are mutually exclusive by construction — a node\n * cannot be both — so they share the single `hint` channel and need no\n * precedence rule between them.\n */\nexport const getSlotHint = (parent: Node): string | undefined => {\n if (\n parent.type === INTERNAL_COMPONENTS_NAMES.REPEATER &&\n parent.metadata?.repeaterBindingFieldType\n ) {\n return \"It is recommended to drop a condition block inside the repeater to handle Modular Blocks & References.\";\n }\n\n if (parent.type !== INTERNAL_COMPONENTS_NAMES.CONDITION_BLOCK)\n return undefined;\n\n return getConditionBlockHint(parent);\n};\n\n/**\n * The hint a condition block hands down to `child` when the child's empty slot is\n * the block's **drop well**, or `undefined` when it is not.\n *\n * A condition block is `display: contents`, so it has no drop area of its own.\n * The well is therefore the block's own slot while the block is empty (handled by\n * `getSlotHint`), and the slot of the single container placed inside it once one\n * has been (typically the Box auto-inserted for modular-block / reference\n * repeaters). Those two are mutually exclusive in time: the moment the Box\n * exists, the block's own slot is filled and stops rendering a placeholder.\n *\n * The block computes this and passes it DOWN, rather than the container looking\n * UP for its block. Elements are memoised on node identity, and editor state is\n * structurally shared: setting the block's condition replaces the block and its\n * ancestors but leaves the container the same object. A container that read the\n * condition off its parent would therefore never re-render and keep the hint it\n * drew before the condition existed. The block always re-renders when anything\n * the hint depends on changes — its own condition, or the container filling —\n * so deriving it there and passing it as a prop keeps the two in step.\n *\n * The rule is positional, not provenance-based: a Box the author dropped in\n * themselves is treated exactly like the auto-inserted one, because its\n * provenance is invisible to the author and should not change what the slot\n * says. Depth stops at one hop — a well is a single slot, so a placeholder\n * nested deeper is not standing in for the block's contents.\n */\nexport const getConditionWellHint = (\n block: Node,\n child: Node,\n): string | undefined => {\n if (block.type !== INTERNAL_COMPONENTS_NAMES.CONDITION_BLOCK)\n return undefined;\n\n // The block must hold exactly this one node. With two empty containers there\n // is no single well, and printing the hint on both would be noise.\n const blockChildren = Object.values(block.slots || {}).flat();\n if (blockChildren.length !== 1 || blockChildren[0]?.uid !== child.uid)\n return undefined;\n\n // And that node must itself be empty — once real content lands anywhere under\n // the block, no slot beneath it is standing in for the block's contents.\n if (Object.values(child.slots || {}).flat().length > 0) return undefined;\n\n return getConditionBlockHint(block);\n};\n\n/** The condition a block's drop well describes, as \"When …\" text. */\nconst getConditionBlockHint = (block: Node): string | undefined => {\n // An `unsupported` hint means a condition IS set but cannot be described.\n // \"Drop Here\" on its own is already a complete, correct message, so the well\n // says nothing extra rather than guessing.\n //\n // `conditionDisplay` carries the display names resolved when the condition was\n // authored. The helper falls back to the stored uids when it is absent, which\n // is the permanent case for conditions written by the CLI or the API.\n const hint = getConditionHint(\n block.metadata?.condition as Condition | undefined,\n block.metadata?.conditionDisplay as ConditionDisplay | undefined,\n {\n subject: getRepeaterFieldName(\n NODE_TO_PARENT.get(block) as Node | undefined,\n ),\n },\n );\n return hint?.kind === \"info\" ? `${hint.prefix} ${hint.value}` : undefined;\n};\n\n/**\n * The field a Repeater iterates, as a display name — `hero_sections` → \"Hero\n * Sections\".\n *\n * Recovers the subject of a condition whose own binding has collapsed into its\n * value: a repeater-scoped condition's `path` is rewritten to the branch, but the\n * Repeater it sits in still names the field. Used only as a fallback, so a name\n * stamped at author time always wins.\n *\n * De-uid-ified deliberately, unlike a subject read from the condition's own\n * binding. This is the same string the Repeater's own hint renders one row up in\n * Layers (\"Iterates Hero Sections\"), so showing it raw here would make the two\n * disagree about the same field.\n */\nconst getRepeaterFieldName = (node?: Node): string | undefined => {\n if (node?.type !== INTERNAL_COMPONENTS_NAMES.REPEATER) return undefined;\n const binding = (node.props?.items as { binding?: any } | undefined)?.binding;\n const path = getBindingFieldPath(binding);\n const field = path?.split(\".\").pop();\n return field ? uidToDisplayName(field) : undefined;\n};\n\n/** Where a slot child gets permanent drop zones. */\nexport interface PermanentDropZonePlacement {\n hasZoneBefore: boolean;\n hasZoneAfter: boolean;\n}\n\n/** Permanent drop zone placements, keyed by the child's index in its slot. */\nexport type PermanentDropZonePlacementsBySlotIndex = ReadonlyMap<\n number,\n PermanentDropZonePlacement\n>;\n\nconst NO_PERMANENT_DROP_ZONES: PermanentDropZonePlacementsBySlotIndex =\n new Map();\n\n/**\n * The node's own Design/Preview toggle. `metadata` is loosely typed, so anything\n * other than the two toggle values reads as unset.\n */\nconst readDesignPreviewMode = (node: Node): DesignPreviewMode | undefined => {\n const mode: unknown = node.metadata.mode;\n return mode === \"design\" || mode === \"preview\" ? mode : undefined;\n};\n\n/**\n * A Repeater that renders its design and whose own items include a Condition\n * block: a Repeater over modular blocks, built by hand or by the starting\n * layout. Its canvas shows only per-block drop targets, so the author needs the\n * zones to see where content for the rest of the page goes. Any other\n * Repeater is ordinary content.\n */\nconst isModularBlockRepeaterInDesign = (\n node: Node,\n rendersDesignForMode: RendersDesignForMode,\n): boolean =>\n node.type === INTERNAL_COMPONENTS_NAMES.REPEATER &&\n rendersDesignForMode(readDesignPreviewMode(node)) &&\n Object.values(node.slots).some((items) =>\n items.some(\n (item) => item.type === INTERNAL_COMPONENTS_NAMES.CONDITION_BLOCK,\n ),\n );\n\n/**\n * Whether `candidate`, a child of `slotOwner`, gets a block Repeater's\n * permanent drop zones. A wrapped Repeater's zones go on its wrapper, never\n * inside it; a wrapper with no such Repeater left in it, or only a hidden one\n * the canvas never draws, is just a Box.\n */\nconst isPermanentDropZoneAnchor = (\n candidate: Node,\n slotOwner: Node,\n rendersDesignForMode: RendersDesignForMode,\n): boolean => {\n if (candidate.metadata.repeaterWrapper) {\n return Object.values(candidate.slots).some((items) =>\n items.some(\n (item) =>\n item.metadata.visible !== false &&\n isModularBlockRepeaterInDesign(item, rendersDesignForMode),\n ),\n );\n }\n return (\n !slotOwner.metadata.repeaterWrapper &&\n isModularBlockRepeaterInDesign(candidate, rendersDesignForMode)\n );\n};\n\n/**\n * Permanent drop zones for one slot's children, keyed by slot index. A zone\n * marks an empty gap next to a block Repeater (first, between two, last), so\n * filling the gap removes it. Hidden children are skipped: gaps are judged by\n * what the canvas draws.\n *\n * @param rendersDesignForMode - The design-or-preview rule in the slot's context, so a\n * Repeater counts as in design exactly when it will render its design.\n */\nexport const getPermanentDropZonePlacements = (\n slotOwner: Node,\n slotChildren: Node[],\n rendersDesignForMode: RendersDesignForMode,\n): PermanentDropZonePlacementsBySlotIndex => {\n const visibleChildIndexes = slotChildren.flatMap((child, index) =>\n child.metadata.visible === false ? [] : [index],\n );\n const isAnchorAtVisiblePosition = visibleChildIndexes.map((childIndex) =>\n isPermanentDropZoneAnchor(\n slotChildren[childIndex],\n slotOwner,\n rendersDesignForMode,\n ),\n );\n if (!isAnchorAtVisiblePosition.includes(true)) return NO_PERMANENT_DROP_ZONES;\n\n const placementsBySlotIndex = new Map<number, PermanentDropZonePlacement>();\n visibleChildIndexes.forEach((childIndex, visiblePosition) => {\n if (!isAnchorAtVisiblePosition[visiblePosition]) return;\n placementsBySlotIndex.set(childIndex, {\n hasZoneBefore: visiblePosition === 0,\n hasZoneAfter:\n visiblePosition === visibleChildIndexes.length - 1 ||\n isAnchorAtVisiblePosition[visiblePosition + 1],\n });\n });\n return placementsBySlotIndex;\n};\n"],"names":[],"mappings":";;;;AAkBO,MAAM,gBAAgB,GAAG,CAC9B,iBAAgE,EAChE,MAAY,EACZ,KAAa,EACb,wBAAiC,KAC/B;AACF,IAAA,IAAI,CAAC,wBAAwB;AAAE,QAAA,OAAO,KAAK;IAC3C,IAAI,CAAC,iBAAiB,EAAE,YAAY,CAAC,MAAM,CAAC,EAAE;AAC5C,QAAA,OAAO,KAAK;IACd;AACA,IAAA,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,KAAK,CAAC;AAElC,IAAA,OAAO,OAAO;AAChB;AAEA;;;;;;;;;;;;AAYG;AACI,MAAM,WAAW,GAAG,CAAC,MAAY,KAAwB;AAC9D,IAAA,IACE,MAAM,CAAC,IAAI,KAAK,yBAAyB,CAAC,QAAQ;AAClD,QAAA,MAAM,CAAC,QAAQ,EAAE,wBAAwB,EACzC;AACA,QAAA,OAAO,wGAAwG;IACjH;AAEA,IAAA,IAAI,MAAM,CAAC,IAAI,KAAK,yBAAyB,CAAC,eAAe;AAC3D,QAAA,OAAO,SAAS;AAElB,IAAA,OAAO,qBAAqB,CAAC,MAAM,CAAC;AACtC;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;AAyBG;MACU,oBAAoB,GAAG,CAClC,KAAW,EACX,K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C,SAAS,CAAC,QAAQ,CAAC,eAAe;AACnC,QAAA,8BAA8B,CAAC,SAAS,EAAE,oBAAoB,CAAC;AAEnE,CAAC;AAED;;;;;;;;AAQG;AACI,MAAM,8BAA8B,GAAG,CAC5C,SAAe,EACf,YAAoB,EACpB,oBAA0C,KACA;AAC1C,IAAA,MAAM,mBAAmB,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,KAAK,KAC5D,KAAK,CAAC,QAAQ,CAAC,OAAO,KAAK,KAAK,GAAG,EAAE,GAAG,CAAC,KAAK,CAAC,CAChD;IACD,MAAM,yBAAyB,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC,UAAU,KACnE,yBAAyB,CACvB,YAAY,CAAC,UAAU,CAAC,EACxB,SAAS,EACT,oBAAoB,CACrB,CACF;AACD,IAAA,IAAI,CAAC,yBAAyB,CAAC,QAAQ,CAAC,IAAI,CAAC;AAAE,QAAA,OAAO,uBAAuB;AAE7E,IAAA,MAAM,qBAAqB,GAAG,IAAI,GAAG,EAAsC;IAC3E,mBAAmB,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,eAAe,KAAI;AAC1D,QAAA,IAAI,CAAC,yBAAyB,CAAC,eAAe,CAAC;YAAE;AACjD,QAAA,qBAAqB,CAAC,GAAG,CAAC,UAAU,EAAE;YACpC,aAAa,EAAE,eAAe,KAAK,CAAC;AACpC,YAAA,YAAY,EACV,eAAe,KAAK,mBAAmB,CAAC,MAAM,GAAG,CAAC;AAClD,gBAAA,yBAAyB,CAAC,eAAe,GAAG,CAAC,CAAC;AACjD,SAAA,CAAC;AACJ,IAAA,CAAC,CAAC;AACF,IAAA,OAAO,qBAAqB;AAC9B;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentstack/studio-react-editor",
3
- "version": "1.10.0",
3
+ "version": "1.11.0",
4
4
  "description": "Contains all logic of editing for react based environment",
5
5
  "author": "RavenColEvol <ravilamkoti@gmail.com>",
6
6
  "homepage": "https://github.com/contentstack/composable-studio-sdk#readme",
@@ -38,7 +38,7 @@
38
38
  "react-dom": "^18.0.0 || ^19.0.0"
39
39
  },
40
40
  "devDependencies": {
41
- "@contentstack/common-config": "^1.2.5",
41
+ "@contentstack/common-config": "^1.2.6",
42
42
  "@rollup/plugin-commonjs": "^28.0.6",
43
43
  "@rollup/plugin-node-resolve": "^16.0.1",
44
44
  "@rollup/plugin-terser": "^1.0.0",
@@ -58,12 +58,12 @@
58
58
  "typescript": "^5.2.2"
59
59
  },
60
60
  "dependencies": {
61
- "@contentstack/studio-client": "^4.0.0",
62
- "@contentstack/studio-core": "^1.4.3",
63
- "@contentstack/studio-internal": "^1.8.0",
64
- "@contentstack/studio-messenger": "^3.2.0",
65
- "@contentstack/studio-react-components": "^2.0.0",
66
- "@contentstack/studio-registry": "^2.0.0",
61
+ "@contentstack/studio-client": "^4.1.0",
62
+ "@contentstack/studio-core": "^1.4.4",
63
+ "@contentstack/studio-internal": "^1.8.1",
64
+ "@contentstack/studio-messenger": "^3.2.1",
65
+ "@contentstack/studio-react-components": "^2.0.1",
66
+ "@contentstack/studio-registry": "^2.0.1",
67
67
  "classnames": "^2.5.1",
68
68
  "goober": "^2.1.16",
69
69
  "immer": "^10.1.1",