@contentstack/studio-react-editor 1.8.0 → 1.9.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/AddIcon.js +18 -0
- package/dist/components/AddIcon.js.map +1 -0
- package/dist/components/BuildingIllustration.js +1 -1
- package/dist/components/BuildingIllustration.js.map +1 -1
- package/dist/components/EditableRenderer.js +4 -3
- package/dist/components/EditableRenderer.js.map +1 -1
- package/dist/components/Element.js +48 -20
- package/dist/components/Element.js.map +1 -1
- package/dist/components/Slot.js +5 -4
- package/dist/components/Slot.js.map +1 -1
- package/dist/components/WelcomeState.js +43 -10
- package/dist/components/WelcomeState.js.map +1 -1
- package/dist/components/elements/ConditionBlock.js +7 -20
- package/dist/components/elements/ConditionBlock.js.map +1 -1
- package/dist/components/elements/SectionSlot.js +12 -6
- package/dist/components/elements/SectionSlot.js.map +1 -1
- package/dist/components/styles.js +73 -17
- package/dist/components/styles.js.map +1 -1
- package/dist/contexts/providers/selected-node.provider.js +7 -1
- package/dist/contexts/providers/selected-node.provider.js.map +1 -1
- package/dist/hooks/use-slot-copy-color.hook.js +54 -0
- package/dist/hooks/use-slot-copy-color.hook.js.map +1 -0
- package/dist/hooks/use-spec-data-listener.hook.js +114 -15
- package/dist/hooks/use-spec-data-listener.hook.js.map +1 -1
- package/dist/utils/backdrop-watcher.util.js +79 -0
- package/dist/utils/backdrop-watcher.util.js.map +1 -0
- package/dist/utils/copy-color.util.js +300 -0
- package/dist/utils/copy-color.util.js.map +1 -0
- package/dist/utils/renderer.util.js +92 -1
- package/dist/utils/renderer.util.js.map +1 -1
- package/package.json +9 -10
- package/LICENSE +0 -21
|
@@ -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 Element from \"../Element\";\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 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 className={styles.slotDropText}>\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 className={styles.slotDropText}>\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 className={styles.slotDefaultHint}>\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 className={styles.slotOrDivider}>OR</p>\n <p className={styles.slotAllowedLabel}>Add from the allowed Sections</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\nconst AddIcon: React.FC = () => {\n return (\n <svg\n width=\"22\"\n height=\"22\"\n viewBox=\"0 0 22 22\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <rect x=\"0.5\" y=\"0.5\" width=\"21\" height=\"21\" rx=\"4.5\" fill=\"white\" />\n <rect x=\"0.5\" y=\"0.5\" width=\"21\" height=\"21\" rx=\"4.5\" stroke=\"#475161\" />\n <path\n d=\"M11.2808 6.78125C11.2808 6.62592 11.1548 6.5 10.9995 6.5C10.8442 6.5 10.7183 6.62592 10.7183 6.78125V10.7184H6.78125C6.62592 10.7184 6.5 10.8443 6.5 10.9996C6.5 11.155 6.62592 11.2809 6.78125 11.2809H10.7183V15.218C10.7183 15.3733 10.8442 15.4993 10.9995 15.4993C11.1548 15.4993 11.2808 15.3733 11.2808 15.218V11.2809H15.218C15.3733 11.2809 15.4993 11.155 15.4993 10.9996C15.4993 10.8443 15.3733 10.7184 15.218 10.7184H11.2808V6.78125Z\"\n fill=\"#475161\"\n />\n </svg>\n );\n};\n\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":";;;;;;;;;;;;;;;;AAwCA;;;;;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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AAC,KAAK,EAAC,CAAC,EAAC,KAAK,EAAC,KAAK,EAAC,IAAI,EAAC,MAAM,EAAC,IAAI,EAAC,EAAE,EAAC,KAAK,EAAC,MAAM,EAAC,SAAS,GAAG,EACzEA,GAAA,CAAA,MAAA,EAAA,EACE,CAAC,EAAC,qbAAqb,EACvb,IAAI,EAAC,SAAS,EAAA,CACd,CAAA,EAAA,CACE;AAEV,CAAC;AAED;AACA;AACA;AACA,MAAM,iBAAiB,GAAa,MAAK;AACvC,IAAA,QACEC,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 {\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;AACX;AAEA;;;;;;;;;;;;;;;;;;AAkBG;AACG,SAAU,WAAW,CAAC,EAC1B,gBAAgB,EAChB,KAAK,EACL,IAAI,EACJ,cAAc,GACS,EAAA;;;;;AAKvB,IAAA,MAAM,kBAAkB,GAAG,gBAAgB,EA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A,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,3 +1,10 @@
|
|
|
1
|
+
import { STUDIO_CHROME_MODES } from '../utils/copy-color.util.js';
|
|
2
|
+
|
|
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)),
|
|
7
|
+
]));
|
|
1
8
|
const styleFactory = (css) => ({
|
|
2
9
|
embedStyle: css({
|
|
3
10
|
height: "100%",
|
|
@@ -21,14 +28,35 @@ const styleFactory = (css) => ({
|
|
|
21
28
|
gap: "4px",
|
|
22
29
|
alignItems: "center",
|
|
23
30
|
justifyContent: "center",
|
|
24
|
-
|
|
31
|
+
// No background of its own. An earlier fix painted every dropzone white,
|
|
32
|
+
// on the premise that the host page's colour could not be known or read
|
|
33
|
+
// reliably. It can: the walk in copy-color.util.ts reads it, and the chrome
|
|
34
|
+
// colours itself from the answer. A white fill also made empty columns read
|
|
35
|
+
// as occupied — the dashed outline says empty while the fill says full —
|
|
36
|
+
// which is why it is gone rather than kept alongside.
|
|
37
|
+
//
|
|
38
|
+
// Two-tone outline. A lone dashed border leaves its gaps transparent, so
|
|
39
|
+
// the slot boundary washes out against dark or purple-ish host pages.
|
|
40
|
+
// The element's own border is a solid white ring; the dashes are painted
|
|
41
|
+
// over it by the overlay below, leaving white — not the page — in the
|
|
42
|
+
// gaps, which reads on any background.
|
|
43
|
+
position: "relative",
|
|
44
|
+
border: "1px solid #ffffff",
|
|
45
|
+
"&::before": {
|
|
46
|
+
content: '""',
|
|
47
|
+
position: "absolute",
|
|
48
|
+
// Sit on the border ring itself, not inside the padding box.
|
|
49
|
+
inset: "-1px",
|
|
50
|
+
border: "1px dashed #6c5ce7",
|
|
51
|
+
pointerEvents: "none",
|
|
52
|
+
},
|
|
25
53
|
color: "#475161",
|
|
26
54
|
fontSize: "14px",
|
|
27
55
|
fontStyle: "normal",
|
|
28
56
|
fontWeight: 400,
|
|
29
57
|
lineHeight: "24px",
|
|
30
58
|
userSelect: "none",
|
|
31
|
-
fontFamily: "Inter",
|
|
59
|
+
fontFamily: "Inter, sans-serif",
|
|
32
60
|
paddingInline: "2rem",
|
|
33
61
|
paddingBlock: "1rem",
|
|
34
62
|
transition: "background-color 0.3s ease",
|
|
@@ -41,29 +69,61 @@ const styleFactory = (css) => ({
|
|
|
41
69
|
flexDirection: "column",
|
|
42
70
|
gap: "4px",
|
|
43
71
|
}),
|
|
72
|
+
// Drop copy and hints sit on top of whatever the host page paints behind
|
|
73
|
+
// the slot, so no fixed colour is readable on every page. These rules carry
|
|
74
|
+
// only layout — the colour comes from a class chosen per line:
|
|
75
|
+
// `slotCopyColors` when the page colour can be measured,
|
|
76
|
+
// `slotCopyOverImage` when it cannot.
|
|
44
77
|
slotDropText: css({
|
|
45
78
|
display: "inline-flex",
|
|
46
79
|
alignItems: "center",
|
|
47
|
-
gap: "
|
|
80
|
+
gap: "6px",
|
|
48
81
|
}),
|
|
49
82
|
slotHintStyle: css({
|
|
50
83
|
textAlign: "center",
|
|
51
84
|
margin: 0,
|
|
52
85
|
}),
|
|
86
|
+
// Ink per mode, built from the same tokens the contrast maths reads, so the
|
|
87
|
+
// colour that gets scored is the colour that gets painted. `!important`
|
|
88
|
+
// because this chrome renders inside the customer's page, whose CSS would
|
|
89
|
+
// otherwise recolour it.
|
|
90
|
+
slotCopyColors: perMode(css, (tokens) => ({
|
|
91
|
+
color: `${tokens.ink} !important`,
|
|
92
|
+
})),
|
|
93
|
+
// A stroke for a bare label the ink cannot carry on its own — the mid-tone
|
|
94
|
+
// band, where a card would take a surface but a one-line label has nothing to
|
|
95
|
+
// sit on. Stroking in the opposite mode's ink gives each glyph its own local
|
|
96
|
+
// polarity without painting a fill behind it. `paint-order` puts the stroke
|
|
97
|
+
// under the fill so the letterforms stay their own weight.
|
|
98
|
+
slotCopyStroke: perMode(css, (tokens) => ({
|
|
99
|
+
// Stroke in the opposite mode's ink — that is the colour guaranteed to
|
|
100
|
+
// contrast with this mode's.
|
|
101
|
+
WebkitTextStroke: `2px ${tokens.surface}`,
|
|
102
|
+
paintOrder: "stroke fill",
|
|
103
|
+
fontWeight: 600,
|
|
104
|
+
})),
|
|
105
|
+
// Fallback for pages whose background cannot be read from computed styles —
|
|
106
|
+
// a gradient, photo or video behind the slot. With nothing to measure and no
|
|
107
|
+
// fill to sit on, the copy goes white and leans on a soft dark shadow, the
|
|
108
|
+
// usual way text survives over imagery of unknown brightness.
|
|
109
|
+
slotCopyOverImage: css({
|
|
110
|
+
color: "#ffffff !important",
|
|
111
|
+
textShadow: "0 1px 3px rgba(0, 0, 0, 0.85), 0 0 10px rgba(0, 0, 0, 0.55)",
|
|
112
|
+
}),
|
|
53
113
|
// Section-slot Default-section hint (COMS-1770). Typography pinned to the
|
|
54
|
-
// Figma spec (Text/Secondary_Text
|
|
55
|
-
// this chrome renders inside the
|
|
56
|
-
// override the weight/color
|
|
114
|
+
// Figma spec (Text/Secondary_Text); the colour comes from the measured copy
|
|
115
|
+
// colour instead. `!important` because this chrome renders inside the
|
|
116
|
+
// customer's page, whose CSS would otherwise override the weight/color
|
|
117
|
+
// (e.g. render it bold).
|
|
57
118
|
slotDefaultHint: css({
|
|
58
119
|
margin: 0,
|
|
59
120
|
textAlign: "center",
|
|
60
|
-
fontFamily: "Inter !important",
|
|
121
|
+
fontFamily: "Inter, sans-serif !important",
|
|
61
122
|
fontSize: "14px !important",
|
|
62
123
|
fontStyle: "normal !important",
|
|
63
124
|
fontWeight: "400 !important",
|
|
64
125
|
lineHeight: "24px !important",
|
|
65
126
|
letterSpacing: "0 !important",
|
|
66
|
-
color: "#475161 !important",
|
|
67
127
|
}),
|
|
68
128
|
// Section-slot "Select section" affordance (COMS-1809). Renders inside the
|
|
69
129
|
// customer's page, so — like slotDefaultHint — the visual props are pinned
|
|
@@ -105,19 +165,17 @@ const styleFactory = (css) => ({
|
|
|
105
165
|
slotOrDivider: css({
|
|
106
166
|
margin: 0,
|
|
107
167
|
textAlign: "center",
|
|
108
|
-
fontFamily: "Inter !important",
|
|
168
|
+
fontFamily: "Inter, sans-serif !important",
|
|
109
169
|
fontSize: "12px !important",
|
|
110
170
|
fontWeight: "400 !important",
|
|
111
|
-
color: "#647696 !important",
|
|
112
171
|
textTransform: "uppercase",
|
|
113
172
|
}),
|
|
114
173
|
slotAllowedLabel: css({
|
|
115
174
|
margin: 0,
|
|
116
175
|
textAlign: "center",
|
|
117
|
-
fontFamily: "Inter !important",
|
|
176
|
+
fontFamily: "Inter, sans-serif !important",
|
|
118
177
|
fontSize: "12px !important",
|
|
119
178
|
fontWeight: "600 !important",
|
|
120
|
-
color: "#647696 !important",
|
|
121
179
|
}),
|
|
122
180
|
embeddedSectionHost: css({
|
|
123
181
|
position: "relative",
|
|
@@ -182,13 +240,11 @@ const styleFactory = (css) => ({
|
|
|
182
240
|
welcomeTitle: css({
|
|
183
241
|
fontSize: "20px",
|
|
184
242
|
fontWeight: "600",
|
|
185
|
-
color: "#475161",
|
|
186
243
|
margin: "20px 0 10px 0",
|
|
187
244
|
fontFamily: "Inter, sans-serif",
|
|
188
245
|
}),
|
|
189
246
|
welcomeSubtitle: css({
|
|
190
247
|
fontSize: "14px",
|
|
191
|
-
color: "#6E6B86",
|
|
192
248
|
margin: "0 0 30px 0",
|
|
193
249
|
maxWidth: "400px",
|
|
194
250
|
fontFamily: "Inter, sans-serif",
|
|
@@ -209,20 +265,20 @@ const styleFactory = (css) => ({
|
|
|
209
265
|
"& h3": {
|
|
210
266
|
fontSize: "16px",
|
|
211
267
|
fontWeight: "600",
|
|
212
|
-
color: "#475161",
|
|
213
268
|
margin: "0 0 8px 0",
|
|
214
269
|
fontFamily: "Inter, sans-serif",
|
|
215
270
|
},
|
|
216
271
|
"& p": {
|
|
217
272
|
fontSize: "14px",
|
|
218
|
-
color: "#6E6B86",
|
|
219
273
|
margin: 0,
|
|
220
274
|
fontFamily: "Inter, sans-serif",
|
|
221
275
|
lineHeight: "1.4",
|
|
222
276
|
},
|
|
223
277
|
}),
|
|
278
|
+
// Fill comes from the measurement; a fixed pale fill swallowed its own copy
|
|
279
|
+
// at 1:1 once the ink adapted pale on a dark page. The purple border is what
|
|
280
|
+
// marks the step regardless.
|
|
224
281
|
activeWelcomeStep: css({
|
|
225
|
-
backgroundColor: "#F9F8FF",
|
|
226
282
|
border: "1px solid #6C5CE7",
|
|
227
283
|
}),
|
|
228
284
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","sources":["../../src/components/styles.ts"],"sourcesContent":["import { css as gooberCss } from \"goober\";\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 border: \"1px dashed #6c5ce7\",\n color: \"#475161\",\n fontSize: \"14px\",\n fontStyle: \"normal\",\n fontWeight: 400,\n lineHeight: \"24px\",\n userSelect: \"none\",\n fontFamily: \"Inter\",\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 slotDropText: css({\n display: \"inline-flex\",\n alignItems: \"center\",\n gap: \"4px\",\n }),\n slotHintStyle: css({\n textAlign: \"center\",\n margin: 0,\n }),\n // Section-slot Default-section hint (COMS-1770). Typography pinned to the\n // Figma spec (Text/Secondary_Text — Tarmac Grey N700). `!important` because\n // this chrome renders inside the customer's page, whose CSS would otherwise\n // override the weight/color (e.g. render it bold).\n slotDefaultHint: css({\n margin: 0,\n textAlign: \"center\",\n fontFamily: \"Inter !important\",\n fontSize: \"14px !important\",\n fontStyle: \"normal !important\",\n fontWeight: \"400 !important\",\n lineHeight: \"24px !important\",\n letterSpacing: \"0 !important\",\n color: \"#475161 !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 !important\",\n fontSize: \"12px !important\",\n fontWeight: \"400 !important\",\n color: \"#647696 !important\",\n textTransform: \"uppercase\",\n }),\n slotAllowedLabel: css({\n margin: 0,\n textAlign: \"center\",\n fontFamily: \"Inter !important\",\n fontSize: \"12px !important\",\n fontWeight: \"600 !important\",\n color: \"#647696 !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 color: \"#475161\",\n margin: \"20px 0 10px 0\",\n fontFamily: \"Inter, sans-serif\",\n }),\n welcomeSubtitle: css({\n fontSize: \"14px\",\n color: \"#6E6B86\",\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 color: \"#475161\",\n margin: \"0 0 8px 0\",\n fontFamily: \"Inter, sans-serif\",\n },\n \"& p\": {\n fontSize: \"14px\",\n color: \"#6E6B86\",\n margin: 0,\n fontFamily: \"Inter, sans-serif\",\n lineHeight: \"1.4\",\n },\n }),\n activeWelcomeStep: css({\n backgroundColor: \"#F9F8FF\",\n border: \"1px solid #6C5CE7\",\n }),\n});\n"],"names":[],"mappings":"MA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ClB,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,KAAK,EAAE,SAAS;AAChB,YAAA,MAAM,EAAE,WAAW;AACnB,YAAA,UAAU,EAAE,mBAAmB;AAChC,SAAA;AACD,QAAA,KAAK,EAAE;AACL,YAAA,QAAQ,EAAE,MAAM;AAChB,YAAA,KAAK,EAAE,SAAS;AAChB,YAAA,MAAM,EAAE,CAAC;AACT,YAAA,UAAU,EAAE,mBAAmB;AAC/B,YAAA,UAAU,EAAE,KAAK;AAClB,SAAA;KACF,CAAC;IACF,iBAAiB,EAAE,GAAG,CAAC;AACrB,QAAA,eAAe,EAAE,SAAS;AAC1B,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 // 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,MAA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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,10 +1,16 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { SelectedNodeContext } from '@contentstack/studio-react-components/contexts';
|
|
3
|
+
import { useMemo } from 'react';
|
|
3
4
|
import { useIsNodeSelected } from '../../hooks/use-is-node-selected.js';
|
|
4
5
|
|
|
5
6
|
function SelectedNodeProvider({ children, }) {
|
|
6
7
|
const isSelected = useIsNodeSelected();
|
|
7
|
-
|
|
8
|
+
// Memoised on the boolean, not rebuilt per render. As an inline object literal
|
|
9
|
+
// this handed every descendant a new context value on each render, so a
|
|
10
|
+
// re-render here propagated through the whole subtree regardless of any memo
|
|
11
|
+
// boundary below it.
|
|
12
|
+
const value = useMemo(() => ({ isSelected }), [isSelected]);
|
|
13
|
+
return (jsx(SelectedNodeContext.Provider, { value: value, children: children }));
|
|
8
14
|
}
|
|
9
15
|
|
|
10
16
|
export { SelectedNodeProvider };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selected-node.provider.js","sources":["../../../src/contexts/providers/selected-node.provider.tsx"],"sourcesContent":["import { SelectedNodeContext } from \"@contentstack/studio-react-components/contexts\";\nimport { useIsNodeSelected } from \"../../hooks/use-is-node-selected\";\n\nexport function SelectedNodeProvider({\n children,\n}: {\n children: React.ReactNode;\n}) {\n const isSelected = useIsNodeSelected();\n\n return (\n <SelectedNodeContext.Provider value={
|
|
1
|
+
{"version":3,"file":"selected-node.provider.js","sources":["../../../src/contexts/providers/selected-node.provider.tsx"],"sourcesContent":["import { SelectedNodeContext } from \"@contentstack/studio-react-components/contexts\";\nimport { useMemo } from \"react\";\nimport { useIsNodeSelected } from \"../../hooks/use-is-node-selected\";\n\nexport function SelectedNodeProvider({\n children,\n}: {\n children: React.ReactNode;\n}) {\n const isSelected = useIsNodeSelected();\n\n // Memoised on the boolean, not rebuilt per render. As an inline object literal\n // this handed every descendant a new context value on each render, so a\n // re-render here propagated through the whole subtree regardless of any memo\n // boundary below it.\n const value = useMemo(() => ({ isSelected }), [isSelected]);\n\n return (\n <SelectedNodeContext.Provider value={value}>\n {children}\n </SelectedNodeContext.Provider>\n );\n}\n"],"names":["_jsx"],"mappings":";;;;;AAIM,SAAU,oBAAoB,CAAC,EACnC,QAAQ,GAGT,EAAA;AACC,IAAA,MAAM,UAAU,GAAG,iBAAiB,EAAE;;;;;AAMtC,IAAA,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC;AAE3D,IAAA,QACEA,GAAA,CAAC,mBAAmB,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,KAAK,EAAA,QAAA,EACvC,QAAQ,EAAA,CACoB;AAEnC;;;;"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { css } from 'goober';
|
|
2
|
+
import { useState, useRef, useCallback, useEffect } from 'react';
|
|
3
|
+
import { styleFactory } from '../components/styles.js';
|
|
4
|
+
import { watchBackdropChanges } from '../utils/backdrop-watcher.util.js';
|
|
5
|
+
import { resolveBackdropColor, pickChromeMode, STUDIO_CHROME_MODES, needsStroke, needsSurface } from '../utils/copy-color.util.js';
|
|
6
|
+
|
|
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
|
+
function useSlotCopyColor() {
|
|
16
|
+
const [measured, setMeasured] = useState(null);
|
|
17
|
+
const styles = styleFactory(css);
|
|
18
|
+
const node = useRef(null);
|
|
19
|
+
const measure = useCallback((element) => {
|
|
20
|
+
const parent = element?.parentElement;
|
|
21
|
+
if (!parent)
|
|
22
|
+
return;
|
|
23
|
+
const backdrop = resolveBackdropColor(parent);
|
|
24
|
+
setMeasured(backdrop ? { mode: pickChromeMode(backdrop), backdrop } : null);
|
|
25
|
+
}, []);
|
|
26
|
+
// Identity must stay stable: a fresh callback each render would make React
|
|
27
|
+
// detach and reattach the node, re-measuring forever.
|
|
28
|
+
const ref = useCallback((element) => {
|
|
29
|
+
node.current = element;
|
|
30
|
+
measure(element);
|
|
31
|
+
}, [measure]);
|
|
32
|
+
// The page can change under the chrome after it mounts — a host with its own
|
|
33
|
+
// dark-mode toggle leaves a colour that was chosen for the previous
|
|
34
|
+
// background, and it can land as low as 1.05:1 against the new one.
|
|
35
|
+
useEffect(() => watchBackdropChanges(() => measure(node.current)), [measure]);
|
|
36
|
+
return {
|
|
37
|
+
ref,
|
|
38
|
+
mode: measured?.mode ?? null,
|
|
39
|
+
backdrop: measured?.backdrop ?? null,
|
|
40
|
+
tokens: measured ? STUDIO_CHROME_MODES[measured.mode] : null,
|
|
41
|
+
surfaceNeeded: measured
|
|
42
|
+
? needsSurface(measured.mode, measured.backdrop)
|
|
43
|
+
: false,
|
|
44
|
+
colorClassName: measured
|
|
45
|
+
? styles.slotCopyColors[measured.mode]
|
|
46
|
+
: styles.slotCopyOverImage,
|
|
47
|
+
strokeClassName: measured && needsStroke(measured.mode, measured.backdrop)
|
|
48
|
+
? styles.slotCopyStroke[measured.mode]
|
|
49
|
+
: null,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export { useSlotCopyColor };
|
|
54
|
+
//# sourceMappingURL=use-slot-copy-color.hook.js.map
|
|
@@ -0,0 +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.slotCopyOverImage,\n strokeClassName:\n measured && needsStroke(measured.mode, measured.backdrop)\n ? styles.slotCopyStroke[measured.mode]\n : null,\n };\n}\n"],"names":[],"mappings":";;;;;;AA0CA;;;;;;;AAOG;SACa,gBAAgB,GAAA;IAC9B,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAG9B,IAAI,CAAC;AACf,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,WAAW,CAAC,QAAQ,GAAG,EAAE,IAAI,EAAE,cAAc,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;IAC7E,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;AACl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