@contentstack/studio-react-editor 1.9.0 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/EditableRenderer.js +2 -1
- package/dist/components/EditableRenderer.js.map +1 -1
- package/dist/components/Element.js +21 -18
- package/dist/components/Element.js.map +1 -1
- package/dist/components/WelcomeState.js +1 -1
- package/dist/components/elements/SectionComposition.js +2 -1
- package/dist/components/elements/SectionComposition.js.map +1 -1
- package/dist/components/elements/SectionSlot.js +4 -39
- package/dist/components/elements/SectionSlot.js.map +1 -1
- package/dist/components/styles.js +0 -52
- package/dist/components/styles.js.map +1 -1
- package/dist/contexts/providers/edit-context.provider.js +2 -2
- package/dist/contexts/providers/edit-context.provider.js.map +1 -1
- package/dist/hooks/use-active-node-path.hook.js +1 -1
- package/dist/hooks/use-active-node-path.hook.js.map +1 -1
- package/dist/hooks/use-canvas-events.hook.js +2 -1
- package/dist/hooks/use-canvas-events.hook.js.map +1 -1
- package/dist/hooks/use-edit-context-listener.hook.js +2 -1
- package/dist/hooks/use-edit-context-listener.hook.js.map +1 -1
- package/dist/hooks/use-section-events.hook.js +2 -1
- package/dist/hooks/use-section-events.hook.js.map +1 -1
- package/dist/hooks/use-spec-data-listener.hook.js +39 -29
- package/dist/hooks/use-spec-data-listener.hook.js.map +1 -1
- package/dist/hooks/use-static-values-listener.hook.js +10 -2
- package/dist/hooks/use-static-values-listener.hook.js.map +1 -1
- package/dist/utils/renderer.util.js +46 -35
- package/dist/utils/renderer.util.js.map +1 -1
- package/package.json +8 -8
|
@@ -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 {\n POST_MESSAGE_EVENTS,\n composableStudioEventManager,\n} from \"@contentstack/studio-messenger\";\nimport { Button } from \"@contentstack/studio-core\";\nimport { css } from \"goober\";\nimport classNames from \"classnames\";\nimport { MouseEvent, 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 orDividerCopyColor = useSlotCopyColor<HTMLParagraphElement>();\n const allowedLabelCopyColor = 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 // COMS-1809: open the section-slot picker. The button lives here in the\n // iframe, but the picker is a parent-app overlay (reusing the Component tab\n // card + hover preview + section catalog — ADR 0010), so we only post the\n // slot identity plus the button's viewport rect. Studio offsets the rect by\n // the iframe's own position to anchor the popover. Plain function (used only\n // in the consumption design-empty branch below), not a hook.\n const handleSelectSection = (event: MouseEvent<HTMLButtonElement>) => {\n event.preventDefault();\n event.stopPropagation();\n const r = event.currentTarget.getBoundingClientRect();\n composableStudioEventManager?.send(\n POST_MESSAGE_EVENTS.OPEN_SECTION_SLOT_PICKER,\n {\n sectionInstanceUid: sectionCtx?.sectionInstanceUid,\n slotUid,\n buttonRect: {\n top: r.top,\n left: r.left,\n right: r.right,\n bottom: r.bottom,\n width: r.width,\n height: r.height,\n },\n },\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 // Always column now (COMS-1809): the \"Select section\" button stacks\n // below the drop copy in every design-mode empty slot.\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 {/* COMS-1809: click-to-pick alternative to drag-and-drop. The \"OR\"\n reads DND vs picker, so it shows in every empty slot. */}\n <p\n ref={orDividerCopyColor.ref}\n className={classNames(\n styles.slotOrDivider,\n orDividerCopyColor.colorClassName,\n orDividerCopyColor.strokeClassName,\n )}\n >\n OR\n </p>\n <p\n ref={allowedLabelCopyColor.ref}\n className={classNames(\n styles.slotAllowedLabel,\n allowedLabelCopyColor.colorClassName,\n allowedLabelCopyColor.strokeClassName,\n )}\n >\n Add from the allowed Sections\n </p>\n <Button\n type=\"button\"\n data-studio-ui={true}\n className={styles.slotSelectButton}\n // Swallow mousedown so the slot's drag-select never starts from the\n // button; the click opens the picker instead.\n onMouseDown={(e) => e.stopPropagation()}\n onClick={handleSelectSection}\n >\n <SelectSectionIcon /> Select section\n </Button>\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\n// Marquee-select glyph for the \"Select section\" button (COMS-1809) — the\n// design's asset verbatim, with fills switched to `currentColor` so it\n// inherits the button's white text.\nconst SelectSectionIcon: React.FC = () => {\n return (\n <svg\n width=\"18\"\n height=\"12\"\n viewBox=\"0 0 18 12\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n aria-hidden=\"true\"\n >\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M1.09375 0.9375C1.00746 0.9375 0.9375 1.00746 0.9375 1.09375V2.34375C0.9375 2.60263 0.727633 2.8125 0.46875 2.8125C0.209867 2.8125 0 2.60263 0 2.34375V1.09375C0 0.489689 0.489688 0 1.09375 0H2.34375C2.60263 0 2.8125 0.209867 2.8125 0.46875C2.8125 0.727633 2.60263 0.9375 2.34375 0.9375H1.09375ZM4.375 0.46875C4.375 0.209867 4.58487 0 4.84375 0H7.34375C7.60263 0 7.8125 0.209867 7.8125 0.46875C7.8125 0.727633 7.60263 0.9375 7.34375 0.9375H4.84375C4.58487 0.9375 4.375 0.727633 4.375 0.46875ZM9.375 0.46875C9.375 0.209867 9.58487 0 9.84375 0H12.3438C12.6026 0 12.8125 0.209867 12.8125 0.46875C12.8125 0.727633 12.6026 0.9375 12.3438 0.9375H9.84375C9.58487 0.9375 9.375 0.727633 9.375 0.46875ZM14.375 0.46875C14.375 0.209867 14.5849 0 14.8438 0H16.0938C16.6978 0 17.1875 0.489688 17.1875 1.09375V2.5C17.1875 2.75888 16.9776 2.96875 16.7188 2.96875C16.4599 2.96875 16.25 2.75888 16.25 2.5V1.09375C16.25 1.00746 16.18 0.9375 16.0938 0.9375H14.8438C14.5849 0.9375 14.375 0.727633 14.375 0.46875ZM0.46875 4.375C0.727633 4.375 0.9375 4.58487 0.9375 4.84375V6.09375C0.9375 6.18004 1.00746 6.25 1.09375 6.25H2.03125C2.29013 6.25 2.5 6.45987 2.5 6.71875C2.5 6.97763 2.29013 7.1875 2.03125 7.1875H1.09375C0.489689 7.1875 0 6.69781 0 6.09375V4.84375C0 4.58487 0.209867 4.375 0.46875 4.375ZM16.7188 4.84375C16.9776 4.84375 17.1875 5.05362 17.1875 5.3125V6.71875C17.1875 6.97763 16.9776 7.1875 16.7188 7.1875C16.4599 7.1875 16.25 6.97763 16.25 6.71875V5.3125C16.25 5.05362 16.4599 4.84375 16.7188 4.84375ZM3.4375 6.71875C3.4375 6.45987 3.64737 6.25 3.90625 6.25H5.78125C6.04013 6.25 6.25 6.45987 6.25 6.71875C6.25 6.97763 6.04013 7.1875 5.78125 7.1875H3.90625C3.64737 7.1875 3.4375 6.97763 3.4375 6.71875ZM7.1875 6.71875C7.1875 6.45987 7.39737 6.25 7.65625 6.25H8.59375C8.85263 6.25 9.0625 6.45987 9.0625 6.71875C9.0625 6.97763 8.85263 7.1875 8.59375 7.1875H7.65625C7.39737 7.1875 7.1875 6.97763 7.1875 6.71875Z\"\n fill=\"currentColor\"\n />\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M9.79852 4.73594C9.72732 4.06274 10.4877 3.62376 11.0351 4.02202L16.3345 7.8776C16.9193 8.30303 16.6619 9.22617 15.9414 9.28775L13.3774 9.5069L11.9056 11.6178C11.492 12.211 10.5639 11.9723 10.4878 11.2532L9.79852 4.73594ZM10.7678 4.98694L11.3761 10.7381L12.6503 8.91063C12.783 8.7203 12.9934 8.5988 13.2246 8.57904L15.4443 8.38932L10.7678 4.98694Z\"\n fill=\"currentColor\"\n />\n </svg>\n );\n};\n"],"names":["_jsx","_jsxs","Element","_Fragment"],"mappings":";;;;;;;;;;;;;;;;;;AA0CA;;;;;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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;AAC3D,wBAAA,QACEA,GAAA,CAAC,kBAAkB,CAAC,QAAQ,EAAA,EAE1B,KAAK,EAAE;gCACL,cAAc,EAAE,KAAK,CAAC,GAAG;AACzB,gCAAA,eAAe,EAAE,SAAS;6BAC3B,EAAA,QAAA,EAEDA,GAAA,CAAC,oBAAoB,EAAA,EAAA,QAAA,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;AAEA;AACA;AACA;AACA,MAAM,iBAAiB,GAAa,MAAK;AACvC,IAAA,QACED,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,CAElBD,GAAA,CAAA,MAAA,EAAA,EACE,QAAQ,EAAC,SAAS,EAClB,QAAQ,EAAC,SAAS,EAClB,CAAC,EAAC,22DAA22D,EAC72D,IAAI,EAAC,cAAc,EAAA,CACnB,EACFA,GAAA,CAAA,MAAA,EAAA,EACE,QAAQ,EAAC,SAAS,EAClB,QAAQ,EAAC,SAAS,EAClB,CAAC,EAAC,6VAA6V,EAC/V,IAAI,EAAC,cAAc,EAAA,CACnB,CAAA,EAAA,CACE;AAEV,CAAC;;;;"}
|
|
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,M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C,GAAG,CAAC,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC;wBACjD,iBAAiB,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;AAC5C,wBAAA,MAAM,SAAS,GAAS,CAAC,GAAG,cAAc,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;AAC3D,wBAAA,QACEA,GAAA,CAAC,kBAAkB,CAAC,QAAQ,EAAA,EAE1B,KAAK,EAAE;gCACL,cAAc,EAAE,KAAK,CAAC,GAAG;AACzB,gCAAA,eAAe,EAAE,SAAS;6BAC3B,EAAA,QAAA,EAEDA,GAAA,CAAC,oBAAoB,EAAA,EAAA,QAAA,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;;;;"}
|
|
@@ -125,58 +125,6 @@ const styleFactory = (css) => ({
|
|
|
125
125
|
lineHeight: "24px !important",
|
|
126
126
|
letterSpacing: "0 !important",
|
|
127
127
|
}),
|
|
128
|
-
// Section-slot "Select section" affordance (COMS-1809). Renders inside the
|
|
129
|
-
// customer's page, so — like slotDefaultHint — the visual props are pinned
|
|
130
|
-
// with `!important` to survive the host page's CSS. The button overrides the
|
|
131
|
-
// shared studio-core Button base (light-purple outline) to the filled-purple
|
|
132
|
-
// primary shown in the design.
|
|
133
|
-
slotSelectButton: css({
|
|
134
|
-
backgroundColor: "#6c5ce7 !important",
|
|
135
|
-
color: "#ffffff !important",
|
|
136
|
-
border: "1px solid #6c5ce7 !important",
|
|
137
|
-
fontWeight: "600 !important",
|
|
138
|
-
// Pin the icon/text alignment too — the studio-core base sets flex
|
|
139
|
-
// centering, but host-page CSS can override it, leaving the icon riding
|
|
140
|
-
// above the label. The svg is inline by default (baseline-aligned), so
|
|
141
|
-
// make it a block flex item.
|
|
142
|
-
display: "inline-flex !important",
|
|
143
|
-
alignItems: "center !important",
|
|
144
|
-
justifyContent: "center !important",
|
|
145
|
-
gap: "0.5rem !important",
|
|
146
|
-
// Typography pinned as well: a host font-size/line-height override makes
|
|
147
|
-
// the label's line box taller than the 12px icon and drags its visual
|
|
148
|
-
// center away from the icon's. line-height 1 makes the text flex item
|
|
149
|
-
// exactly glyph-high, so both centers coincide.
|
|
150
|
-
fontSize: "0.875rem !important",
|
|
151
|
-
lineHeight: "1 !important",
|
|
152
|
-
fontFamily: "'Inter', sans-serif !important",
|
|
153
|
-
"& svg": {
|
|
154
|
-
display: "block",
|
|
155
|
-
flexShrink: 0,
|
|
156
|
-
// Optical centering: the flex boxes align exactly (verified — svg/text
|
|
157
|
-
// center deltas are 0), but the asset's dashed marquee occupies only the
|
|
158
|
-
// top 7.2px of its 18x12 box with the pointer overhanging below-right,
|
|
159
|
-
// so a box-centered icon READS ~2px high. Nudge down so the marquee —
|
|
160
|
-
// the dominant shape — centers on the label, pointer descending like a
|
|
161
|
-
// glyph descender (matches the design).
|
|
162
|
-
transform: "translateY(2px)",
|
|
163
|
-
},
|
|
164
|
-
}),
|
|
165
|
-
slotOrDivider: css({
|
|
166
|
-
margin: 0,
|
|
167
|
-
textAlign: "center",
|
|
168
|
-
fontFamily: "Inter, sans-serif !important",
|
|
169
|
-
fontSize: "12px !important",
|
|
170
|
-
fontWeight: "400 !important",
|
|
171
|
-
textTransform: "uppercase",
|
|
172
|
-
}),
|
|
173
|
-
slotAllowedLabel: css({
|
|
174
|
-
margin: 0,
|
|
175
|
-
textAlign: "center",
|
|
176
|
-
fontFamily: "Inter, sans-serif !important",
|
|
177
|
-
fontSize: "12px !important",
|
|
178
|
-
fontWeight: "600 !important",
|
|
179
|
-
}),
|
|
180
128
|
embeddedSectionHost: css({
|
|
181
129
|
position: "relative",
|
|
182
130
|
".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 // Section-slot \"Select section\" affordance (COMS-1809). Renders inside the\n // customer's page, so — like slotDefaultHint — the visual props are pinned\n // with `!important` to survive the host page's CSS. The button overrides the\n // shared studio-core Button base (light-purple outline) to the filled-purple\n // primary shown in the design.\n slotSelectButton: css({\n backgroundColor: \"#6c5ce7 !important\",\n color: \"#ffffff !important\",\n border: \"1px solid #6c5ce7 !important\",\n fontWeight: \"600 !important\",\n // Pin the icon/text alignment too — the studio-core base sets flex\n // centering, but host-page CSS can override it, leaving the icon riding\n // above the label. The svg is inline by default (baseline-aligned), so\n // make it a block flex item.\n display: \"inline-flex !important\",\n alignItems: \"center !important\",\n justifyContent: \"center !important\",\n gap: \"0.5rem !important\",\n // Typography pinned as well: a host font-size/line-height override makes\n // the label's line box taller than the 12px icon and drags its visual\n // center away from the icon's. line-height 1 makes the text flex item\n // exactly glyph-high, so both centers coincide.\n fontSize: \"0.875rem !important\",\n lineHeight: \"1 !important\",\n fontFamily: \"'Inter', sans-serif !important\",\n \"& svg\": {\n display: \"block\",\n flexShrink: 0,\n // Optical centering: the flex boxes align exactly (verified — svg/text\n // center deltas are 0), but the asset's dashed marquee occupies only the\n // top 7.2px of its 18x12 box with the pointer overhanging below-right,\n // so a box-centered icon READS ~2px high. Nudge down so the marquee —\n // the dominant shape — centers on the label, pointer descending like a\n // glyph descender (matches the design).\n transform: \"translateY(2px)\",\n },\n }),\n slotOrDivider: css({\n margin: 0,\n textAlign: \"center\",\n fontFamily: \"Inter, sans-serif !important\",\n fontSize: \"12px !important\",\n fontWeight: \"400 !important\",\n textTransform: \"uppercase\",\n }),\n slotAllowedLabel: css({\n margin: 0,\n textAlign: \"center\",\n fontFamily: \"Inter, sans-serif !important\",\n fontSize: \"12px !important\",\n fontWeight: \"600 !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,GAAG,CACd,GAAqB,EACrB,IAEiB,KAEjB,MAAM,CAAC,WAAW,CAChB,MAAM,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,KAAK;IAC1D,IAAI;AACJ,IAAA,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAClB,CAAA,CAAC,CACiC;MAE1B,YAAY,GAAG,CAAC,GAAqB,MAAM;IACtD,UAAU,EAAE,GAAG,CAAC;AACd,QAAA,MAAM,EAAE,MAAM;AACd,QAAA,KAAK,EAAE,MAAM;AACb,QAAA,OAAO,EAAE,MAAM;AACf,QAAA,UAAU,EAAE,QAAQ;AACpB,QAAA,OAAO,EAAE,MAAM;AACf,QAAA,MAAM,EAAE,mBAAmB;KAC5B,CAAC;IACF,cAAc,EAAE,GAAG,CAAC;AAClB,QAAA,OAAO,EAAE,GAAG;KACb,CAAC;IACF,SAAS,EAAE,GAAG,CAAC;AACb,QAAA,MAAM,EAAE,MAAM;KACf,CAAC;IACF,SAAS,EAAE,GAAG,CAAC;AACb,QAAA,SAAS,EAAE,YAAY;;AAEvB,QAAA,MAA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AChB,QAAA,OAAO,EAAE,MAAM;AACf,QAAA,aAAa,EAAE,QAAQ;AACvB,QAAA,GAAG,EAAE,MAAM;AACX,QAAA,QAAQ,EAAE,QAAQ;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;;;;"}
|
|
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,GAAG,CACd,GAAqB,EACrB,IAEiB,KAEjB,MAAM,CAAC,WAAW,CAChB,MAAM,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,KAAK;IAC1D,IAAI;AACJ,IAAA,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAClB,CAAA,CAAC,CACiC;MAE1B,YAAY,GAAG,CAAC,GAAqB,MAAM;IACtD,UAAU,EAAE,GAAG,CAAC;AACd,QAAA,MAAM,EAAE,MAAM;AACd,QAAA,KAAK,EAAE,MAAM;AACb,QAAA,OAAO,EAAE,MAAM;AACf,QAAA,UAAU,EAAE,QAAQ;AACpB,QAAA,OAAO,EAAE,MAAM;AACf,QAAA,MAAM,EAAE,mBAAmB;KAC5B,CAAC;IACF,cAAc,EAAE,GAAG,CAAC;AAClB,QAAA,OAAO,EAAE,GAAG;KACb,CAAC;IACF,SAAS,EAAE,GAAG,CAAC;AACb,QAAA,MAAM,EAAE,MAAM;KACf,CAAC;IACF,SAAS,EAAE,GAAG,CAAC;AACb,QAAA,SAAS,EAAE,YAAY;;AAEvB,QAAA,MAAM,EAAE,MAAM;AACd,QAAA,OAAO,EAAE,MAAM;AACf,QAAA,GAAG,EAAE,KAAK;AACV,QAAA,UAAU,EAAE,QAAQ;AACpB,QAAA,cAAc,EAAE,QAAQ;;;;;;;;;;;;;AAaxB,QAAA,QAAQ,EAAE,UAAU;AACpB,QAAA,MAAM,EAAE,mBAAmB;AAC3B,QAAA,WAAW,EAAE;AACX,YAAA,OAAO,EAAE,IAAI;AACb,YAAA,QAAQ,EAAE,UAAU;;AAEpB,YAAA,KAAK,EAAE,MAAM;AACb,YAAA,MAAM,EAAE,oBAAoB;AAC5B,YAA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AAE,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;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { DataStepMode } from '@contentstack/studio-messenger';
|
|
3
|
-
export { DataStepMode } from '@contentstack/studio-messenger';
|
|
2
|
+
import { DataStepMode } from '@contentstack/studio-messenger/constants';
|
|
3
|
+
export { DataStepMode } from '@contentstack/studio-messenger/constants';
|
|
4
4
|
import { createContext } from 'react';
|
|
5
5
|
|
|
6
6
|
const editContext = createContext({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edit-context.provider.js","sources":["../../../src/contexts/providers/edit-context.provider.tsx"],"sourcesContent":["import { DataStepMode } from \"@contentstack/studio-messenger\";\nimport { createContext, FC } from \"react\";\n\n// Re-exported so editor-internal consumers keep importing from the providers\n// barrel; the enum's single source of truth is @contentstack/studio-messenger.\nexport { DataStepMode };\n\n/**\n * Per-composition editor context that Studio computes and pushes into the\n * iframe (pulled via `GET_EDIT_CONTEXT`, updated live via `SET_EDIT_CONTEXT`).\n * Read directly by descendants such as `WelcomeState` — it must live INSIDE\n * `EditableRenderer` (which owns the stateful spec), not the outer\n * `RendererProvider` (which is fed the one-shot initial spec).\n */\nexport interface EditContextValue {\n /**\n * Defaults to `schema-or-pin` so older Studio / anything that can't answer\n * keeps the existing \"Connect a schema or pin data\" copy.\n */\n dataStepMode: DataStepMode;\n}\n\nexport const editContext = createContext<EditContextValue>({\n dataStepMode: DataStepMode.SchemaOrPin,\n});\n\nexport const EditContextProvider: FC<{\n value: EditContextValue;\n children: React.ReactNode;\n}> = ({ value, children }) => {\n return <editContext.Provider value={value}>{children}</editContext.Provider>;\n};\n"],"names":["_jsx"],"mappings":";;;;;AAsBO,MAAM,WAAW,GAAG,aAAa,CAAmB;IACzD,YAAY,EAAE,YAAY,CAAC,WAAW;AACvC,CAAA;AAEM,MAAM,mBAAmB,GAG3B,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAI;IAC3B,OAAOA,GAAA,CAAC,WAAW,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,KAAK,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAwB;AAC9E;;;;"}
|
|
1
|
+
{"version":3,"file":"edit-context.provider.js","sources":["../../../src/contexts/providers/edit-context.provider.tsx"],"sourcesContent":["import { DataStepMode } from \"@contentstack/studio-messenger/constants\";\nimport { createContext, FC } from \"react\";\n\n// Re-exported so editor-internal consumers keep importing from the providers\n// barrel; the enum's single source of truth is @contentstack/studio-messenger.\nexport { DataStepMode };\n\n/**\n * Per-composition editor context that Studio computes and pushes into the\n * iframe (pulled via `GET_EDIT_CONTEXT`, updated live via `SET_EDIT_CONTEXT`).\n * Read directly by descendants such as `WelcomeState` — it must live INSIDE\n * `EditableRenderer` (which owns the stateful spec), not the outer\n * `RendererProvider` (which is fed the one-shot initial spec).\n */\nexport interface EditContextValue {\n /**\n * Defaults to `schema-or-pin` so older Studio / anything that can't answer\n * keeps the existing \"Connect a schema or pin data\" copy.\n */\n dataStepMode: DataStepMode;\n}\n\nexport const editContext = createContext<EditContextValue>({\n dataStepMode: DataStepMode.SchemaOrPin,\n});\n\nexport const EditContextProvider: FC<{\n value: EditContextValue;\n children: React.ReactNode;\n}> = ({ value, children }) => {\n return <editContext.Provider value={value}>{children}</editContext.Provider>;\n};\n"],"names":["_jsx"],"mappings":";;;;;AAsBO,MAAM,WAAW,GAAG,aAAa,CAAmB;IACzD,YAAY,EAAE,YAAY,CAAC,WAAW;AACvC,CAAA;AAEM,MAAM,mBAAmB,GAG3B,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAI;IAC3B,OAAOA,GAAA,CAAC,WAAW,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,KAAK,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAwB;AAC9E;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { highlightNodeManager } from '@contentstack/studio-client';
|
|
1
|
+
import { highlightNodeManager } from '@contentstack/studio-client/editor';
|
|
2
2
|
import { useContext, useState, useEffect } from 'react';
|
|
3
3
|
import { ActiveComponentPathContext } from '../contexts/providers/active-node.provider.js';
|
|
4
4
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-active-node-path.hook.js","sources":["../../src/hooks/use-active-node-path.hook.ts"],"sourcesContent":["import { StudioSpec
|
|
1
|
+
{"version":3,"file":"use-active-node-path.hook.js","sources":["../../src/hooks/use-active-node-path.hook.ts"],"sourcesContent":["import { StudioSpec } from \"@contentstack/studio-client\";\nimport { highlightNodeManager } from \"@contentstack/studio-client/editor\";\nimport { Path } from \"@contentstack/studio-internal\";\nimport { useContext, useEffect, useState } from \"react\";\nimport {\n ActiveComponentPathContext,\n ActiveComponentPathContextType,\n} from \"../contexts/providers/active-node.provider\";\n\nexport function useActiveComponentPath() {\n const activeComponentPath = useContext(ActiveComponentPathContext);\n return activeComponentPath;\n}\n\nexport function useGetActiveComponentPathContext(\n spec: StudioSpec,\n): ActiveComponentPathContextType {\n const [activeComponentPath, setActiveComponentPath] =\n useState<ActiveComponentPathContextType>({\n activeNodeUid: null,\n activeNodePath: null,\n });\n\n useEffect(() => {\n function getActiveNodeCallback(\n activeNodeUid: string,\n activeNodePath: Path,\n ) {\n if (!spec) return;\n\n setActiveComponentPath({\n activeNodeUid,\n activeNodePath,\n });\n }\n\n highlightNodeManager.onActiveNodeChange(getActiveNodeCallback, {\n syncToExistingValue: true,\n });\n\n return () => {\n highlightNodeManager.unsubscribeFromActiveNodeChange(\n getActiveNodeCallback,\n );\n };\n }, [spec]);\n\n return activeComponentPath;\n}\n"],"names":[],"mappings":";;;;SASgB,sBAAsB,GAAA;AACpC,IAAA,MAAM,mBAAmB,GAAG,UAAU,CAAC,0BAA0B,CAAC;AAClE,IAAA,OAAO,mBAAmB;AAC5B;AAEM,SAAU,gCAAgC,CAC9C,IAAgB,EAAA;AAEhB,IAAA,MAAM,CAAC,mBAAmB,EAAE,sBAAsB,CAAC,GACjD,QAAQ,CAAiC;AACvC,QAAA,aAAa,EAAE,IAAI;AACnB,QAAA,cAAc,EAAE,IAAI;AACrB,KAAA,CAAC;IAEJ,SAAS,CAAC,MAAK;AACb,QAAA,SAAS,qBAAqB,CAC5B,aAAqB,EACrB,cAAoB,EAAA;AAEpB,YAAA,IAAI,CAAC,IAAI;gBAAE;AAEX,YAAA,sBAAsB,CAAC;gBACrB,aAAa;gBACb,cAAc;AACf,aAAA,CAAC;QACJ;AAEA,QAAA,oBAAoB,CAAC,kBAAkB,CAAC,qBAAqB,EAAE;AAC7D,YAAA,mBAAmB,EAAE,IAAI;AAC1B,SAAA,CAAC;AAEF,QAAA,OAAO,MAAK;AACV,YAAA,oBAAoB,CAAC,+BAA+B,CAClD,qBAAqB,CACtB;AACH,QAAA,CAAC;AACH,IAAA,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;AAEV,IAAA,OAAO,mBAAmB;AAC5B;;;;"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { isCompositionBeingEdited, clientRendererModeUtil,
|
|
1
|
+
import { isCompositionBeingEdited, clientRendererModeUtil, addUrlChangeListeners, addContextMenuEventListeners, addBreakpointEventListeners, updateStyleOnStyleNodeChange, isInsideVisualBuilderFrame } from '@contentstack/studio-client';
|
|
2
|
+
import { addHighlightNodeEventListeners, addHighlightSpacingEventListeners, dndEventListener, hiddenElementNotificationEventEmitter, getNodeScreenshotEvent, compositionSaveEventListener } from '@contentstack/studio-client/editor';
|
|
2
3
|
import { useEffect } from 'react';
|
|
3
4
|
|
|
4
5
|
const useCanvasEvents = (composableUid) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-canvas-events.hook.js","sources":["../../src/hooks/use-canvas-events.hook.ts"],"sourcesContent":["import {\n addBreakpointEventListeners,\n addContextMenuEventListeners,\n
|
|
1
|
+
{"version":3,"file":"use-canvas-events.hook.js","sources":["../../src/hooks/use-canvas-events.hook.ts"],"sourcesContent":["import {\n addBreakpointEventListeners,\n addContextMenuEventListeners,\n addUrlChangeListeners,\n isCompositionBeingEdited,\n clientRendererModeUtil,\n isInsideVisualBuilderFrame,\n updateStyleOnStyleNodeChange,\n} from \"@contentstack/studio-client\";\nimport {\n dndEventListener,\n getNodeScreenshotEvent,\n hiddenElementNotificationEventEmitter,\n} from \"@contentstack/studio-client/editor\";\nimport {\n addHighlightNodeEventListeners,\n addHighlightSpacingEventListeners,\n compositionSaveEventListener,\n} from \"@contentstack/studio-client/editor\";\nimport { useEffect } from \"react\";\n\nexport const useCanvasEvents = (composableUid?: string) => {\n // HOOK TO ADD HIGHLIGHT NODE EVENT LISTENERS\n useEffect(() => {\n // 🎯 STUDIO CONTEXT CHECK: Only add event listeners when inside Studio, not standalone\n const shouldAddStudioEventListeners =\n isCompositionBeingEdited(composableUid || \"\") &&\n clientRendererModeUtil.isInsideStudioFrame();\n if (!shouldAddStudioEventListeners) return;\n const highlightNodeEventListener = addHighlightNodeEventListeners();\n const urlChangeEventListener = addUrlChangeListeners();\n const highlightSpacingEventListener = addHighlightSpacingEventListeners();\n const contextMenuEventListener = addContextMenuEventListeners();\n const breakpointEventListener = addBreakpointEventListeners();\n const dndListener = dndEventListener();\n const updatedStyleEventListener = updateStyleOnStyleNodeChange();\n const hiddenElementNotificationEventListener =\n hiddenElementNotificationEventEmitter();\n const getNodeScreenshotEventListener = getNodeScreenshotEvent();\n\n return () => {\n highlightNodeEventListener?.removeEventListeners();\n urlChangeEventListener?.removeEventListeners();\n highlightSpacingEventListener?.removeEventListeners();\n contextMenuEventListener?.removeEventListeners();\n breakpointEventListener?.removeEventListeners();\n dndListener?.removeEventListeners();\n updatedStyleEventListener?.removeEventListeners();\n hiddenElementNotificationEventListener?.unregister();\n getNodeScreenshotEventListener?.unregister();\n };\n }, [composableUid]);\n\n useEffect(() => {\n if (!isInsideVisualBuilderFrame()) return;\n const cleanup = compositionSaveEventListener();\n return () => {\n cleanup?.unregister();\n };\n }, []);\n};\n"],"names":[],"mappings":";;;;AAqBO,MAAM,eAAe,GAAG,CAAC,aAAsB,KAAI;;IAExD,SAAS,CAAC,MAAK;;AAEb,QAAA,MAAM,6BAA6B,GACjC,wBAAwB,CAAC,aAAa,IAAI,EAAE,CAAC;YAC7C,sBAAsB,CAAC,mBAAmB,EAAE;AAC9C,QAAA,IAAI,CAAC,6BAA6B;YAAE;AACpC,QAAA,MAAM,0BAA0B,GAAG,8BAA8B,EAAE;AACnE,QAAA,MAAM,sBAAsB,GAAG,qBAAqB,EAAE;AACtD,QAAA,MAAM,6BAA6B,GAAG,iCAAiC,EAAE;AACzE,QAAA,MAAM,wBAAwB,GAAG,4BAA4B,EAAE;AAC/D,QAAA,MAAM,uBAAuB,GAAG,2BAA2B,EAAE;AAC7D,QAAA,MAAM,WAAW,GAAG,gBAAgB,EAAE;AACtC,QAAA,MAAM,yBAAyB,GAAG,4BAA4B,EAAE;AAChE,QAAA,MAAM,sCAAsC,GAC1C,qCAAqC,EAAE;AACzC,QAAA,MAAM,8BAA8B,GAAG,sBAAsB,EAAE;AAE/D,QAAA,OAAO,MAAK;YACV,0BAA0B,EAAE,oBAAoB,EAAE;YAClD,sBAAsB,EAAE,oBAAoB,EAAE;YAC9C,6BAA6B,EAAE,oBAAoB,EAAE;YACrD,wBAAwB,EAAE,oBAAoB,EAAE;YAChD,uBAAuB,EAAE,oBAAoB,EAAE;YAC/C,WAAW,EAAE,oBAAoB,EAAE;YACnC,yBAAyB,EAAE,oBAAoB,EAAE;YACjD,sCAAsC,EAAE,UAAU,EAAE;YACpD,8BAA8B,EAAE,UAAU,EAAE;AAC9C,QAAA,CAAC;AACH,IAAA,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC;IAEnB,SAAS,CAAC,MAAK;QACb,IAAI,CAAC,0BAA0B,EAAE;YAAE;AACnC,QAAA,MAAM,OAAO,GAAG,4BAA4B,EAAE;AAC9C,QAAA,OAAO,MAAK;YACV,OAAO,EAAE,UAAU,EAAE;AACvB,QAAA,CAAC;IACH,CAAC,EAAE,EAAE,CAAC;AACR;;;;"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { clientRendererModeUtil } from '@contentstack/studio-client';
|
|
2
|
-
import { DataStepMode,
|
|
2
|
+
import { DataStepMode, POST_MESSAGE_EVENTS } from '@contentstack/studio-messenger/constants';
|
|
3
|
+
import { composableStudioEventManager } from '@contentstack/studio-messenger';
|
|
3
4
|
import { useState, useEffect } from 'react';
|
|
4
5
|
import '../contexts/providers/edit-context.provider.js';
|
|
5
6
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-edit-context-listener.hook.js","sources":["../../src/hooks/use-edit-context-listener.hook.ts"],"sourcesContent":["import { clientRendererModeUtil } from \"@contentstack/studio-client\";\nimport {\
|
|
1
|
+
{"version":3,"file":"use-edit-context-listener.hook.js","sources":["../../src/hooks/use-edit-context-listener.hook.ts"],"sourcesContent":["import { clientRendererModeUtil } from \"@contentstack/studio-client\";\nimport { POST_MESSAGE_EVENTS } from \"@contentstack/studio-messenger/constants\";\nimport { composableStudioEventManager } from \"@contentstack/studio-messenger\";\nimport { useEffect, useState } from \"react\";\nimport { DataStepMode } from \"../contexts/providers/edit-context.provider\";\n\nconst DATA_STEP_MODES = Object.values(DataStepMode) as DataStepMode[];\nconst isDataStepMode = (v: unknown): v is DataStepMode =>\n DATA_STEP_MODES.includes(v as DataStepMode);\n\n/**\n * Resolves the per-composition editor context Studio owns (currently just\n * `dataStepMode` — see composable-studio ADR 0008).\n *\n * Init is a PULL: once this effect runs (our handlers are mounted) we request\n * the value from Studio, so it can never race an init-time push. A separate\n * `SET_EDIT_CONTEXT` listener applies later live changes (e.g. the Freeform\n * plan toggled mid-session). Defaults to `schema-or-pin` so anything that can't\n * answer keeps the existing copy.\n */\nexport const useEditContextListener = (\n composableUid?: string,\n): { dataStepMode: DataStepMode } => {\n const [dataStepMode, setDataStepMode] = useState<DataStepMode>(\n DataStepMode.SchemaOrPin,\n );\n\n useEffect(() => {\n if (!clientRendererModeUtil.isInsideStudioFrame()) return;\n\n let cancelled = false;\n\n composableStudioEventManager\n ?.send<{ dataStepMode?: DataStepMode }>(\n POST_MESSAGE_EVENTS.GET_EDIT_CONTEXT,\n { composableUid },\n )\n .then((res) => {\n if (!cancelled && isDataStepMode(res?.dataStepMode)) {\n setDataStepMode(res.dataStepMode);\n }\n })\n .catch(() => {\n // Older Studio has no responder — keep the default.\n });\n\n const listener = composableStudioEventManager?.on<{\n dataStepMode?: DataStepMode;\n }>(POST_MESSAGE_EVENTS.SET_EDIT_CONTEXT, (event) => {\n if (isDataStepMode(event?.data?.dataStepMode)) {\n setDataStepMode(event.data.dataStepMode as DataStepMode);\n }\n });\n\n return () => {\n cancelled = true;\n listener?.unregister();\n };\n }, [composableUid]);\n\n return { dataStepMode };\n};\n"],"names":[],"mappings":";;;;;;AAMA,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,YAAY,CAAmB;AACrE,MAAM,cAAc,GAAG,CAAC,CAAU,KAChC,eAAe,CAAC,QAAQ,CAAC,CAAiB,CAAC;AAE7C;;;;;;;;;AASG;AACI,MAAM,sBAAsB,GAAG,CACpC,aAAsB,KACY;AAClC,IAAA,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAC9C,YAAY,CAAC,WAAW,CACzB;IAED,SAAS,CAAC,MAAK;AACb,QAAA,IAAI,CAAC,sBAAsB,CAAC,mBAAmB,EAAE;YAAE;QAEnD,IAAI,SAAS,GAAG,KAAK;QAErB;cACI,IAAI,CACJ,mBAAmB,CAAC,gBAAgB,EACpC,EAAE,aAAa,EAAE;AAElB,aAAA,IAAI,CAAC,CAAC,GAAG,KAAI;YACZ,IAAI,CAAC,SAAS,IAAI,cAAc,CAAC,GAAG,EAAE,YAAY,CAAC,EAAE;AACnD,gBAAA,eAAe,CAAC,GAAG,CAAC,YAAY,CAAC;YACnC;AACF,QAAA,CAAC;aACA,KAAK,CAAC,MAAK;;AAEZ,QAAA,CAAC,CAAC;AAEJ,QAAA,MAAM,QAAQ,GAAG,4BAA4B,EAAE,EAAE,CAE9C,mBAAmB,CAAC,gBAAgB,EAAE,CAAC,KAAK,KAAI;YACjD,IAAI,cAAc,CAAC,KAAK,EAAE,IAAI,EAAE,YAAY,CAAC,EAAE;AAC7C,gBAAA,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,YAA4B,CAAC;YAC1D;AACF,QAAA,CAAC,CAAC;AAEF,QAAA,OAAO,MAAK;YACV,SAAS,GAAG,IAAI;YAChB,QAAQ,EAAE,UAAU,EAAE;AACxB,QAAA,CAAC;AACH,IAAA,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC;IAEnB,OAAO,EAAE,YAAY,EAAE;AACzB;;;;"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { clientRendererModeUtil, isCompositionBeingEdited } from '@contentstack/studio-client';
|
|
2
|
-
import {
|
|
2
|
+
import { POST_MESSAGE_EVENTS } from '@contentstack/studio-messenger/constants';
|
|
3
|
+
import { composableStudioEventManager } from '@contentstack/studio-messenger';
|
|
3
4
|
import { useEffect } from 'react';
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-section-events.hook.js","sources":["../../src/hooks/use-section-events.hook.ts"],"sourcesContent":["import {\n SectionCompositionEntry,\n StudioSpec,\n clientRendererModeUtil,\n isCompositionBeingEdited,\n} from \"@contentstack/studio-client\";\nimport {\
|
|
1
|
+
{"version":3,"file":"use-section-events.hook.js","sources":["../../src/hooks/use-section-events.hook.ts"],"sourcesContent":["import {\n SectionCompositionEntry,\n StudioSpec,\n clientRendererModeUtil,\n isCompositionBeingEdited,\n} from \"@contentstack/studio-client\";\nimport { POST_MESSAGE_EVENTS } from \"@contentstack/studio-messenger/constants\";\nimport { composableStudioEventManager } from \"@contentstack/studio-messenger\";\nimport { useEffect } from \"react\";\n\n/**\n * React hook that manages section composition events from the Studio.\n * Pulls current sections after mount to avoid losing registrations during initial load,\n * AND re-fetches whenever the spec UI references a section uid that isn't yet\n * known locally (e.g. a section was just dropped in Studio).\n *\n * @param setState - State setter function to update the spec\n * @param state - Current studio spec state\n * @param composableUid - UID of the composition being edited\n */\nexport const useSectionEvents = (\n setState: React.Dispatch<React.SetStateAction<StudioSpec>>,\n state?: StudioSpec,\n composableUid?: string,\n) => {\n // Register the catalog-update listener AS SOON AS the iframe is inside\n // the Studio frame — independent of spec arrival. Studio's\n // `useSectionCompositions` pushes the full catalog the moment its React\n // Query resolves; that push can arrive before the iframe has received\n // its first GET_COMPOSITION_SPEC response and populated `composableUid`,\n // so gating the listener on the latter caused NO_REQUEST_LISTENER_FOUND\n // on every fresh page load.\n useEffect(() => {\n if (!clientRendererModeUtil.isInsideStudioFrame()) return;\n const catalogListener = composableStudioEventManager?.on<{\n sectionCompositions: SectionCompositionEntry[];\n }>(POST_MESSAGE_EVENTS.UPDATE_SECTIONS_CATALOG, (event) => {\n if (!event.data?.sectionCompositions) return;\n setState((prevState: StudioSpec) => ({\n ...prevState,\n sectionCompositions: event.data.sectionCompositions,\n }));\n });\n return () => {\n catalogListener?.unregister();\n };\n // Register once on mount; the handler reads via setState's prev so it\n // doesn't need state in deps.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n // GET_SECTIONS one-shot fetch — runs after the composition is known so\n // the initial section catalog is populated even when Studio's React\n // Query was already resolved before the iframe mounted (no catalog push\n // is fired in that case).\n useEffect(() => {\n if (!isCompositionBeingEdited(composableUid || \"\")) return;\n composableStudioEventManager\n ?.send<{ sectionCompositions: SectionCompositionEntry[] }>(\n POST_MESSAGE_EVENTS.GET_SECTIONS,\n {},\n )\n .then((data) => {\n if (!data || !(\"sectionCompositions\" in data)) return;\n setState((prevState: StudioSpec) => ({\n ...prevState,\n sectionCompositions: data.sectionCompositions,\n }));\n })\n .catch(() => {});\n }, [state?.compositionEntry?.uid, composableUid]);\n};\n"],"names":[],"mappings":";;;;;AAUA;;;;;;;;;AASG;AACI,MAAM,gBAAgB,GAAG,CAC9B,QAA0D,EAC1D,KAAkB,EAClB,aAAsB,KACpB;;;;;;;;IAQF,SAAS,CAAC,MAAK;AACb,QAAA,IAAI,CAAC,sBAAsB,CAAC,mBAAmB,EAAE;YAAE;AACnD,QAAA,MAAM,eAAe,GAAG,4BAA4B,EAAE,EAAE,CAErD,mBAAmB,CAAC,uBAAuB,EAAE,CAAC,KAAK,KAAI;AACxD,YAAA,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,mBAAmB;gBAAE;AACtC,YAAA,QAAQ,CAAC,CAAC,SAAqB,MAAM;AACnC,gBAAA,GAAG,SAAS;AACZ,gBAAA,mBAAmB,EAAE,KAAK,CAAC,IAAI,CAAC,mBAAmB;AACpD,aAAA,CAAC,CAAC;AACL,QAAA,CAAC,CAAC;AACF,QAAA,OAAO,MAAK;YACV,eAAe,EAAE,UAAU,EAAE;AAC/B,QAAA,CAAC;;;;IAIH,CAAC,EAAE,EAAE,CAAC;;;;;IAMN,SAAS,CAAC,MAAK;AACb,QAAA,IAAI,CAAC,wBAAwB,CAAC,aAAa,IAAI,EAAE,CAAC;YAAE;QACpD;AACE,cAAE,IAAI,CACJ,mBAAmB,CAAC,YAAY,EAChC,EAAE;AAEH,aAAA,IAAI,CAAC,CAAC,IAAI,KAAI;YACb,IAAI,CAAC,IAAI,IAAI,EAAE,qBAAqB,IAAI,IAAI,CAAC;gBAAE;AAC/C,YAAA,QAAQ,CAAC,CAAC,SAAqB,MAAM;AACnC,gBAAA,GAAG,SAAS;gBACZ,mBAAmB,EAAE,IAAI,CAAC,mBAAmB;AAC9C,aAAA,CAAC,CAAC;AACL,QAAA,CAAC;AACA,aAAA,KAAK,CAAC,MAAK,EAAE,CAAC,CAAC;IACpB,CAAC,EAAE,CAAC,KAAK,EAAE,gBAAgB,EAAE,GAAG,EAAE,aAAa,CAAC,CAAC;AACnD;;;;"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { clientRendererModeUtil, SECTION_COMPOSITIONS_KEY, applyOperation, NODE_TO_PARENT, NODE_TO_PATH_NODE } from '@contentstack/studio-client';
|
|
2
|
-
import {
|
|
2
|
+
import { POST_MESSAGE_EVENTS } from '@contentstack/studio-messenger/constants';
|
|
3
|
+
import { composableStudioEventManager } from '@contentstack/studio-messenger';
|
|
3
4
|
import { DATA_SOURCES_PREFIX } from '@contentstack/studio-registry';
|
|
4
|
-
import { seedSectionInstanceBindings } from '@contentstack/studio-react-components/utils';
|
|
5
|
+
import { seedSectionInstanceBindings, pageDataSourcesOf, keepEqualReferences } from '@contentstack/studio-react-components/utils';
|
|
5
6
|
import { useRef, useEffect } from 'react';
|
|
6
7
|
import { Immer } from 'immer';
|
|
7
8
|
|
|
@@ -41,6 +42,18 @@ function refreshNodeWeakMaps(root) {
|
|
|
41
42
|
};
|
|
42
43
|
visit(root);
|
|
43
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* `next` with every data slice `prev` already holds kept at its old reference,
|
|
47
|
+
* one level into `dataSources` as well. Studio's pushes cross postMessage, so
|
|
48
|
+
* they arrive as new objects even when nothing changed; without this, every
|
|
49
|
+
* push re-renders the page.
|
|
50
|
+
*/
|
|
51
|
+
function keepEqualData(prev, next) {
|
|
52
|
+
return keepEqualReferences(prev, {
|
|
53
|
+
...next,
|
|
54
|
+
[DATA_SOURCES_PREFIX]: keepEqualReferences(prev?.[DATA_SOURCES_PREFIX], next?.[DATA_SOURCES_PREFIX]),
|
|
55
|
+
});
|
|
56
|
+
}
|
|
44
57
|
const useSpecDataListener = (setState,
|
|
45
58
|
// Read into `stateRef` only — listener bodies use `stateRef.current` (not
|
|
46
59
|
// `state` directly) so the effect's deps don't include `state.data`, which
|
|
@@ -74,6 +87,7 @@ state, composableUid) => {
|
|
|
74
87
|
}
|
|
75
88
|
: dataSources[SECTION_COMPOSITIONS_KEY] || {};
|
|
76
89
|
const pageTemplate = dataSources.template;
|
|
90
|
+
const pageDataSources = pageDataSourcesOf(dataSources);
|
|
77
91
|
/**
|
|
78
92
|
* The document an instance's section data lives in (ADR 0017).
|
|
79
93
|
*
|
|
@@ -250,21 +264,22 @@ state, composableUid) => {
|
|
|
250
264
|
// iframe loaded with getSpecFromParent and never fetched the section's
|
|
251
265
|
// data sources itself — the studio pushes them later via
|
|
252
266
|
// UPDATE_SPEC_DATA. Pool-keyed maps would be ideal but the listener
|
|
253
|
-
// doesn't have access to them;
|
|
254
|
-
// superset (same composite-key format the resolver expects).
|
|
267
|
+
// doesn't have access to them; sharing the full page slice is a safe
|
|
268
|
+
// superset (same composite-key format the resolver expects). Shared by
|
|
269
|
+
// reference, not copied, so an unchanged slice compares by identity.
|
|
255
270
|
const refreshedContentstack = dataSources.contentstack && typeof dataSources.contentstack === "object"
|
|
256
|
-
?
|
|
271
|
+
? dataSources.contentstack
|
|
257
272
|
: prev.contentstack || {};
|
|
258
273
|
const refreshedQueries = dataSources.contentstack_queries &&
|
|
259
274
|
typeof dataSources.contentstack_queries === "object"
|
|
260
|
-
?
|
|
275
|
+
? dataSources.contentstack_queries
|
|
261
276
|
: prev.contentstack_queries || {};
|
|
262
277
|
const next = {
|
|
263
278
|
...prev,
|
|
264
279
|
template: scopedTemplate,
|
|
265
280
|
contentstack: refreshedContentstack,
|
|
266
281
|
contentstack_queries: refreshedQueries,
|
|
267
|
-
page:
|
|
282
|
+
page: pageDataSources,
|
|
268
283
|
repeater: repeater ?? prev.repeater,
|
|
269
284
|
// Carry binding metadata so SectionCompositionProvider can re-scope the
|
|
270
285
|
// template from the LIVE per-iteration repeater item. The scopedTemplate
|
|
@@ -278,13 +293,10 @@ state, composableUid) => {
|
|
|
278
293
|
cardinality: binding?.cardinality,
|
|
279
294
|
componentPropsFallback: binding?.componentPropsFallback,
|
|
280
295
|
};
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
prev.contentstack_queries !== next.contentstack_queries ||
|
|
286
|
-
prev.componentPropsFallback !== next.componentPropsFallback) {
|
|
287
|
-
nextScoped[instanceUid] = next;
|
|
296
|
+
// Keep the old entry when its content is unchanged.
|
|
297
|
+
const kept = keepEqualReferences(prev, next);
|
|
298
|
+
if (kept !== prev) {
|
|
299
|
+
nextScoped[instanceUid] = kept;
|
|
288
300
|
changed = true;
|
|
289
301
|
}
|
|
290
302
|
}
|
|
@@ -395,16 +407,13 @@ state, composableUid) => {
|
|
|
395
407
|
...(data?.dataSources || {}),
|
|
396
408
|
[SECTION_COMPOSITIONS_KEY]: mergedSections,
|
|
397
409
|
};
|
|
398
|
-
const mergedData = {
|
|
410
|
+
const mergedData = keepEqualData(state.data, {
|
|
399
411
|
...state.data,
|
|
400
412
|
...data,
|
|
401
413
|
dataSources: mergedDataSources,
|
|
402
|
-
};
|
|
414
|
+
});
|
|
403
415
|
const rebuilt = rebuildScopedFromBindings(mergedData);
|
|
404
|
-
return {
|
|
405
|
-
...state,
|
|
406
|
-
data: rebuilt,
|
|
407
|
-
};
|
|
416
|
+
return rebuilt === state.data ? state : { ...state, data: rebuilt };
|
|
408
417
|
});
|
|
409
418
|
});
|
|
410
419
|
const previewEntryChangeListener = composableStudioEventManager?.on(POST_MESSAGE_EVENTS.REPLACE_PREVIEW_ENTRY, async (event) => {
|
|
@@ -419,13 +428,13 @@ state, composableUid) => {
|
|
|
419
428
|
// dataSources — don't wipe sibling slices like `repeater` or
|
|
420
429
|
// `section_compositions`, which would cause a flicker for sections
|
|
421
430
|
// inside a Repeater (their item context would disappear).
|
|
422
|
-
const mergedData = {
|
|
431
|
+
const mergedData = keepEqualData(prevState.data, {
|
|
423
432
|
...prevState?.data,
|
|
424
433
|
[DATA_SOURCES_PREFIX]: {
|
|
425
434
|
...(prevState?.data?.[DATA_SOURCES_PREFIX] || {}),
|
|
426
435
|
...data?.dataSources,
|
|
427
436
|
},
|
|
428
|
-
};
|
|
437
|
+
});
|
|
429
438
|
// The merge updates dataSources.template, but each section's SCOPED
|
|
430
439
|
// template in section_scoped_data is derived from it — re-scope here,
|
|
431
440
|
// else a section keeps its stale (often null) scope and renders the
|
|
@@ -433,7 +442,9 @@ state, composableUid) => {
|
|
|
433
442
|
// UPDATE_SPEC_DATA handler already rebuilds; this is the equivalent for
|
|
434
443
|
// the preview-entry change path that EntryPickerBtn sends.)
|
|
435
444
|
const rebuilt = rebuildScopedFromBindings(mergedData);
|
|
436
|
-
return
|
|
445
|
+
return rebuilt === prevState.data
|
|
446
|
+
? prevState
|
|
447
|
+
: { ...prevState, data: rebuilt };
|
|
437
448
|
});
|
|
438
449
|
});
|
|
439
450
|
const applyOperationListener = composableStudioEventManager?.on(POST_MESSAGE_EVENTS.APPLY_OPERATION, (event) => {
|
|
@@ -547,13 +558,13 @@ state, composableUid) => {
|
|
|
547
558
|
? { ...incoming, cardinality: prev.cardinality }
|
|
548
559
|
: incoming;
|
|
549
560
|
}
|
|
550
|
-
const mergedData = {
|
|
561
|
+
const mergedData = keepEqualData(prevState.data, {
|
|
551
562
|
...prevState.data,
|
|
552
563
|
dataSources: {
|
|
553
564
|
...prevState.data?.dataSources,
|
|
554
565
|
[SECTION_COMPOSITIONS_KEY]: merged,
|
|
555
566
|
},
|
|
556
|
-
};
|
|
567
|
+
});
|
|
557
568
|
// Pass the MERGED entries for the incoming uids (not the raw incoming)
|
|
558
569
|
// — rebuildScopedFromBindings spreads incomingBindings over the slice,
|
|
559
570
|
// so raw entries would reintroduce the dropped cardinality.
|
|
@@ -562,10 +573,9 @@ state, composableUid) => {
|
|
|
562
573
|
merged[uid],
|
|
563
574
|
]));
|
|
564
575
|
const finalData = rebuildScopedFromBindings(mergedData, incomingMerged);
|
|
565
|
-
return
|
|
566
|
-
|
|
567
|
-
data: finalData
|
|
568
|
-
};
|
|
576
|
+
return finalData === prevState.data
|
|
577
|
+
? prevState
|
|
578
|
+
: { ...prevState, data: finalData };
|
|
569
579
|
});
|
|
570
580
|
});
|
|
571
581
|
// Signal to Studio that our editor→iframe post-message listeners are now
|