@contentstack/studio-react-editor 1.7.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 +10 -22
- package/dist/components/EditableRenderer.js.map +1 -1
- package/dist/components/Element.js +81 -38
- package/dist/components/Element.js.map +1 -1
- package/dist/components/PreviewRenderer.js +0 -19
- package/dist/components/PreviewRenderer.js.map +1 -1
- package/dist/components/Slot.js +5 -4
- package/dist/components/Slot.js.map +1 -1
- package/dist/components/WelcomeState.js +44 -27
- package/dist/components/WelcomeState.js.map +1 -1
- package/dist/components/elements/ConditionBlock.js +9 -35
- package/dist/components/elements/ConditionBlock.js.map +1 -1
- package/dist/components/elements/Repeater.js +1 -15
- package/dist/components/elements/Repeater.js.map +1 -1
- package/dist/components/elements/SectionSlot.js +68 -5
- package/dist/components/elements/SectionSlot.js.map +1 -1
- package/dist/components/styles.js +133 -8
- 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-active-node-path.hook.js +0 -19
- package/dist/hooks/use-active-node-path.hook.js.map +1 -1
- package/dist/hooks/use-condition-block-context.js +0 -20
- package/dist/hooks/use-condition-block-context.js.map +1 -1
- package/dist/hooks/use-design-preview.hook.js +0 -20
- package/dist/hooks/use-design-preview.hook.js.map +1 -1
- package/dist/hooks/use-preview-mode.hook.js +0 -20
- package/dist/hooks/use-preview-mode.hook.js.map +1 -1
- package/dist/hooks/use-register-section.hook.js +0 -1
- package/dist/hooks/use-register-section.hook.js.map +1 -1
- package/dist/hooks/use-renderer.hook.js +0 -20
- package/dist/hooks/use-renderer.hook.js.map +1 -1
- package/dist/hooks/use-repeater.hook.js +0 -20
- package/dist/hooks/use-repeater.hook.js.map +1 -1
- package/dist/hooks/use-should-show-design.hook.js +1 -20
- package/dist/hooks/use-should-show-design.hook.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 +168 -24
- 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 +12 -14
- package/LICENSE +0 -21
- package/dist/components/elements/Symbol.js +0 -65
- package/dist/components/elements/Symbol.js.map +0 -1
- package/dist/contexts/providers/symbol-ui.provider.js +0 -88
- package/dist/contexts/providers/symbol-ui.provider.js.map +0 -1
- package/dist/hooks/use-register-symbol.hook.js +0 -54
- package/dist/hooks/use-register-symbol.hook.js.map +0 -1
- package/dist/hooks/use-symbol-events.hook.js +0 -45
- package/dist/hooks/use-symbol-events.hook.js.map +0 -1
- package/dist/hooks/use-symbol-ui-listener.hook.js +0 -17
- package/dist/hooks/use-symbol-ui-listener.hook.js.map +0 -1
|
@@ -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 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":"MAEa,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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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,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;;AAE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GAAG,CAAC;AAChB,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,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;;;;"}
|
|
@@ -1,25 +1,6 @@
|
|
|
1
1
|
import { highlightNodeManager } from '@contentstack/studio-client';
|
|
2
2
|
import { useContext, useState, useEffect } from 'react';
|
|
3
|
-
import '../contexts/providers/renderer.provider.js';
|
|
4
|
-
import '../contexts/providers/edit-context.provider.js';
|
|
5
3
|
import { ActiveComponentPathContext } from '../contexts/providers/active-node.provider.js';
|
|
6
|
-
import 'react/jsx-runtime';
|
|
7
|
-
import '@contentstack/studio-messenger';
|
|
8
|
-
import '@contentstack/studio-react-components/contexts';
|
|
9
|
-
import 'immer';
|
|
10
|
-
import './use-edit-context-listener.hook.js';
|
|
11
|
-
import '@contentstack/studio-internal';
|
|
12
|
-
import '@contentstack/studio-core';
|
|
13
|
-
import '@contentstack/studio-react-components/basic-components';
|
|
14
|
-
import '@contentstack/studio-react-components/hooks';
|
|
15
|
-
import 'goober';
|
|
16
|
-
import '../components/Element.js';
|
|
17
|
-
import '../contexts/providers/section-mode.provider.js';
|
|
18
|
-
import '@contentstack/studio-registry';
|
|
19
|
-
import '../contexts/providers/use-design-preview.provider.js';
|
|
20
|
-
import '../contexts/providers/use-repeater.provider.js';
|
|
21
|
-
import '../contexts/providers/use-condition-block.provider.js';
|
|
22
|
-
import '../contexts/providers/preview-mode.provider.js';
|
|
23
4
|
|
|
24
5
|
function useActiveComponentPath() {
|
|
25
6
|
const activeComponentPath = useContext(ActiveComponentPathContext);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-active-node-path.hook.js","sources":["../../src/hooks/use-active-node-path.hook.ts"],"sourcesContent":["import { StudioSpec, highlightNodeManager } from \"@contentstack/studio-client\";\nimport { Path } from \"@contentstack/studio-internal\";\nimport { useContext, useEffect, useState } from \"react\";\nimport {\n ActiveComponentPathContext,\n ActiveComponentPathContextType,\n} from \"../contexts/providers\";\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":"
|
|
1
|
+
{"version":3,"file":"use-active-node-path.hook.js","sources":["../../src/hooks/use-active-node-path.hook.ts"],"sourcesContent":["import { StudioSpec, highlightNodeManager } from \"@contentstack/studio-client\";\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":";;;;SAQgB,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,25 +1,5 @@
|
|
|
1
1
|
import { useContext } from 'react';
|
|
2
|
-
import '../contexts/providers/renderer.provider.js';
|
|
3
|
-
import '../contexts/providers/edit-context.provider.js';
|
|
4
|
-
import '../contexts/providers/active-node.provider.js';
|
|
5
|
-
import 'react/jsx-runtime';
|
|
6
|
-
import '@contentstack/studio-client';
|
|
7
|
-
import '@contentstack/studio-messenger';
|
|
8
|
-
import '@contentstack/studio-react-components/contexts';
|
|
9
|
-
import 'immer';
|
|
10
|
-
import './use-edit-context-listener.hook.js';
|
|
11
|
-
import '@contentstack/studio-internal';
|
|
12
|
-
import '@contentstack/studio-core';
|
|
13
|
-
import '@contentstack/studio-react-components/basic-components';
|
|
14
|
-
import '@contentstack/studio-react-components/hooks';
|
|
15
|
-
import 'goober';
|
|
16
|
-
import '../components/Element.js';
|
|
17
|
-
import '../contexts/providers/section-mode.provider.js';
|
|
18
|
-
import '@contentstack/studio-registry';
|
|
19
|
-
import '../contexts/providers/use-design-preview.provider.js';
|
|
20
|
-
import '../contexts/providers/use-repeater.provider.js';
|
|
21
2
|
import { ConditionBlockContext } from '../contexts/providers/use-condition-block.provider.js';
|
|
22
|
-
import '../contexts/providers/preview-mode.provider.js';
|
|
23
3
|
|
|
24
4
|
const useConditionBlockContext = () => useContext(ConditionBlockContext);
|
|
25
5
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-condition-block-context.js","sources":["../../src/hooks/use-condition-block-context.ts"],"sourcesContent":["import { useContext } from \"react\";\nimport { ConditionBlockContext } from \"../contexts/providers\";\n\nexport const useConditionBlockContext = () => useContext(ConditionBlockContext);\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-condition-block-context.js","sources":["../../src/hooks/use-condition-block-context.ts"],"sourcesContent":["import { useContext } from \"react\";\nimport { ConditionBlockContext } from \"../contexts/providers/use-condition-block.provider\";\n\nexport const useConditionBlockContext = () => useContext(ConditionBlockContext);\n"],"names":[],"mappings":";;;AAGO,MAAM,wBAAwB,GAAG,MAAM,UAAU,CAAC,qBAAqB;;;;"}
|
|
@@ -1,25 +1,5 @@
|
|
|
1
1
|
import { useContext } from 'react';
|
|
2
|
-
import '../contexts/providers/renderer.provider.js';
|
|
3
|
-
import '../contexts/providers/edit-context.provider.js';
|
|
4
|
-
import '../contexts/providers/active-node.provider.js';
|
|
5
|
-
import 'react/jsx-runtime';
|
|
6
|
-
import '@contentstack/studio-client';
|
|
7
|
-
import '@contentstack/studio-messenger';
|
|
8
|
-
import '@contentstack/studio-react-components/contexts';
|
|
9
|
-
import 'immer';
|
|
10
|
-
import './use-edit-context-listener.hook.js';
|
|
11
|
-
import '@contentstack/studio-internal';
|
|
12
|
-
import '@contentstack/studio-core';
|
|
13
|
-
import '@contentstack/studio-react-components/basic-components';
|
|
14
|
-
import '@contentstack/studio-react-components/hooks';
|
|
15
|
-
import 'goober';
|
|
16
|
-
import '../components/Element.js';
|
|
17
|
-
import '../contexts/providers/section-mode.provider.js';
|
|
18
|
-
import '@contentstack/studio-registry';
|
|
19
2
|
import { DesignPreviewContext } from '../contexts/providers/use-design-preview.provider.js';
|
|
20
|
-
import '../contexts/providers/use-repeater.provider.js';
|
|
21
|
-
import '../contexts/providers/use-condition-block.provider.js';
|
|
22
|
-
import '../contexts/providers/preview-mode.provider.js';
|
|
23
3
|
|
|
24
4
|
const useDesignPreviewContext = () => useContext(DesignPreviewContext);
|
|
25
5
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-design-preview.hook.js","sources":["../../src/hooks/use-design-preview.hook.ts"],"sourcesContent":["import { useContext } from \"react\";\nimport { DesignPreviewContext } from \"../contexts/providers\";\n\nexport const useDesignPreviewContext = () => useContext(DesignPreviewContext);\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-design-preview.hook.js","sources":["../../src/hooks/use-design-preview.hook.ts"],"sourcesContent":["import { useContext } from \"react\";\nimport { DesignPreviewContext } from \"../contexts/providers/use-design-preview.provider\";\n\nexport const useDesignPreviewContext = () => useContext(DesignPreviewContext);\n"],"names":[],"mappings":";;;AAGO,MAAM,uBAAuB,GAAG,MAAM,UAAU,CAAC,oBAAoB;;;;"}
|
|
@@ -1,24 +1,4 @@
|
|
|
1
1
|
import { useContext } from 'react';
|
|
2
|
-
import '../contexts/providers/renderer.provider.js';
|
|
3
|
-
import '../contexts/providers/edit-context.provider.js';
|
|
4
|
-
import '../contexts/providers/active-node.provider.js';
|
|
5
|
-
import 'react/jsx-runtime';
|
|
6
|
-
import '@contentstack/studio-client';
|
|
7
|
-
import '@contentstack/studio-messenger';
|
|
8
|
-
import '@contentstack/studio-react-components/contexts';
|
|
9
|
-
import 'immer';
|
|
10
|
-
import './use-edit-context-listener.hook.js';
|
|
11
|
-
import '@contentstack/studio-internal';
|
|
12
|
-
import '@contentstack/studio-core';
|
|
13
|
-
import '@contentstack/studio-react-components/basic-components';
|
|
14
|
-
import '@contentstack/studio-react-components/hooks';
|
|
15
|
-
import 'goober';
|
|
16
|
-
import '../components/Element.js';
|
|
17
|
-
import '../contexts/providers/section-mode.provider.js';
|
|
18
|
-
import '@contentstack/studio-registry';
|
|
19
|
-
import '../contexts/providers/use-design-preview.provider.js';
|
|
20
|
-
import '../contexts/providers/use-repeater.provider.js';
|
|
21
|
-
import '../contexts/providers/use-condition-block.provider.js';
|
|
22
2
|
import { PreviewModeContext } from '../contexts/providers/preview-mode.provider.js';
|
|
23
3
|
|
|
24
4
|
const usePreviewMode = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-preview-mode.hook.js","sources":["../../src/hooks/use-preview-mode.hook.ts"],"sourcesContent":["import { useContext } from \"react\";\nimport { PreviewModeContext } from \"../contexts/providers\";\n\nexport const usePreviewMode = () => {\n return useContext(PreviewModeContext);\n};\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-preview-mode.hook.js","sources":["../../src/hooks/use-preview-mode.hook.ts"],"sourcesContent":["import { useContext } from \"react\";\nimport { PreviewModeContext } from \"../contexts/providers/preview-mode.provider\";\n\nexport const usePreviewMode = () => {\n return useContext(PreviewModeContext);\n};\n"],"names":[],"mappings":";;;AAGO,MAAM,cAAc,GAAG,MAAK;AACjC,IAAA,OAAO,UAAU,CAAC,kBAAkB,CAAC;AACvC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-register-section.hook.js","sources":["../../src/hooks/use-register-section.hook.tsx"],"sourcesContent":["import {\n SectionCompositionEntry,\n StudioSpec,\n preProcessStaticValues,\n} from \"@contentstack/studio-client\";\nimport {\n ComponentRegistry,\n Props,\n RegisterComponentOptionsInput,\n} from \"@contentstack/studio-registry\";\nimport { Node, NodePropType } from \"@contentstack/studio-internal\";\nimport { ReactNode, useMemo } from \"react\";\nimport { SectionComposition } from \"../components/elements/SectionComposition\";\nimport { useRenderer } from \"./use-renderer.hook\";\n\ninterface ExposedPropDef {\n uid: string;\n nodeUid: string;\n propKey: string;\n propType: string;\n displayName: string;\n}\n\ntype SectionRegistryConfig = RegisterComponentOptionsInput<\n (props?: any) => ReactNode\n>;\n\n/**\n * Reads sectionExposedProps from the section's UI metadata and converts them\n * into the Props format that the component registry understands.\n *\n * This is what makes retrievePropValue resolve exposed-prop bindings on the\n * page-level section-composition node — without these registered props the\n * resolver skips them entirely and the override values never reach the section.\n *\n * Each exposed prop is enriched with the FULL schema of the internal component\n * prop it was exposed from (looked up via the internal node's registered\n * component). Registering only { type, displayName } loses `placeholder` and\n * `defaultValue`, so a CLEARED exposed prop resolves to an empty value instead\n * of the component's editor placeholder (e.g. \"Your text here\"). With the full\n * schema, a cleared exposed prop resolves exactly like a normal unbound node —\n * showing the placeholder in Studio — and the override carries it down to the\n * internal node. The editor panel registration enriches the same way.\n */\nfunction buildRegisteredProps(\n section: SectionCompositionEntry,\n componentRegistry: ComponentRegistry<unknown>,\n): Props {\n const exposedPropDefs: ExposedPropDef[] =\n (section.ui?.metadata?.sectionExposedProps as\n | ExposedPropDef[]\n | undefined) ?? [];\n\n // Index the section's internal nodes by uid so each exposed prop can recover\n // its originating component prop schema.\n const nodeByUid = new Map<string, Node>();\n if (section.ui) {\n for (const [node] of Node.nodes(section.ui as Node)) {\n if (node?.uid) nodeByUid.set(node.uid, node as Node);\n }\n }\n\n const props = Object.fromEntries(\n exposedPropDefs.map((ep) => {\n const internalNode = nodeByUid.get(ep.nodeUid);\n const fullProp = internalNode\n ? componentRegistry.getComponentByNode(internalNode)?.props?.[\n ep.propKey\n ]\n : undefined;\n return [\n ep.uid,\n {\n ...(fullProp ?? {}),\n type: ep.propType as NodePropType,\n displayName: ep.displayName,\n } as Props[string],\n ];\n }),\n );\n\n return props;\n}\n\n/**\n * Registers section composition entries as React components in the component registry.\n * Each section is registered with its exposed props so the page-level binding\n * resolver can resolve override values and pass them down to SectionComposition.\n */\nexport const registerSectionComponents = (\n sections: SectionCompositionEntry[],\n componentRegistry: ComponentRegistry<unknown>,\n) => {\n const sectionConfigs: SectionRegistryConfig[] = sections.map((section) => {\n // Section entries store `static_value` in raw shape (`{ text: [...] }`).\n // The data binder expects the pre-processed flat shape (`{ key: value }`),\n // so transform here before handing the section's spec to the renderer.\n // Without this, every string prop on the section (e.g. SectionSlot's\n // `label`) resolves to empty in consumption mode.\n const rawStaticValue = ((section as any)?.static_value ?? {}) as any;\n const sectionSpec: StudioSpec = {\n ui: section.ui,\n data: {\n dataSources: {},\n static_value: preProcessStaticValues(rawStaticValue),\n },\n compositionEntry: section,\n
|
|
1
|
+
{"version":3,"file":"use-register-section.hook.js","sources":["../../src/hooks/use-register-section.hook.tsx"],"sourcesContent":["import {\n SectionCompositionEntry,\n StudioSpec,\n preProcessStaticValues,\n} from \"@contentstack/studio-client\";\nimport {\n ComponentRegistry,\n Props,\n RegisterComponentOptionsInput,\n} from \"@contentstack/studio-registry\";\nimport { Node, NodePropType } from \"@contentstack/studio-internal\";\nimport { ReactNode, useMemo } from \"react\";\nimport { SectionComposition } from \"../components/elements/SectionComposition\";\nimport { useRenderer } from \"./use-renderer.hook\";\n\ninterface ExposedPropDef {\n uid: string;\n nodeUid: string;\n propKey: string;\n propType: string;\n displayName: string;\n}\n\ntype SectionRegistryConfig = RegisterComponentOptionsInput<\n (props?: any) => ReactNode\n>;\n\n/**\n * Reads sectionExposedProps from the section's UI metadata and converts them\n * into the Props format that the component registry understands.\n *\n * This is what makes retrievePropValue resolve exposed-prop bindings on the\n * page-level section-composition node — without these registered props the\n * resolver skips them entirely and the override values never reach the section.\n *\n * Each exposed prop is enriched with the FULL schema of the internal component\n * prop it was exposed from (looked up via the internal node's registered\n * component). Registering only { type, displayName } loses `placeholder` and\n * `defaultValue`, so a CLEARED exposed prop resolves to an empty value instead\n * of the component's editor placeholder (e.g. \"Your text here\"). With the full\n * schema, a cleared exposed prop resolves exactly like a normal unbound node —\n * showing the placeholder in Studio — and the override carries it down to the\n * internal node. The editor panel registration enriches the same way.\n */\nfunction buildRegisteredProps(\n section: SectionCompositionEntry,\n componentRegistry: ComponentRegistry<unknown>,\n): Props {\n const exposedPropDefs: ExposedPropDef[] =\n (section.ui?.metadata?.sectionExposedProps as\n | ExposedPropDef[]\n | undefined) ?? [];\n\n // Index the section's internal nodes by uid so each exposed prop can recover\n // its originating component prop schema.\n const nodeByUid = new Map<string, Node>();\n if (section.ui) {\n for (const [node] of Node.nodes(section.ui as Node)) {\n if (node?.uid) nodeByUid.set(node.uid, node as Node);\n }\n }\n\n const props = Object.fromEntries(\n exposedPropDefs.map((ep) => {\n const internalNode = nodeByUid.get(ep.nodeUid);\n const fullProp = internalNode\n ? componentRegistry.getComponentByNode(internalNode)?.props?.[\n ep.propKey\n ]\n : undefined;\n return [\n ep.uid,\n {\n ...(fullProp ?? {}),\n type: ep.propType as NodePropType,\n displayName: ep.displayName,\n } as Props[string],\n ];\n }),\n );\n\n return props;\n}\n\n/**\n * Registers section composition entries as React components in the component registry.\n * Each section is registered with its exposed props so the page-level binding\n * resolver can resolve override values and pass them down to SectionComposition.\n */\nexport const registerSectionComponents = (\n sections: SectionCompositionEntry[],\n componentRegistry: ComponentRegistry<unknown>,\n) => {\n const sectionConfigs: SectionRegistryConfig[] = sections.map((section) => {\n // Section entries store `static_value` in raw shape (`{ text: [...] }`).\n // The data binder expects the pre-processed flat shape (`{ key: value }`),\n // so transform here before handing the section's spec to the renderer.\n // Without this, every string prop on the section (e.g. SectionSlot's\n // `label`) resolves to empty in consumption mode.\n const rawStaticValue = ((section as any)?.static_value ?? {}) as any;\n const sectionSpec: StudioSpec = {\n ui: section.ui,\n data: {\n dataSources: {},\n static_value: preProcessStaticValues(rawStaticValue),\n },\n compositionEntry: section,\n sectionCompositions: sections,\n };\n\n return {\n type: section.uid,\n displayName: section.title,\n thumbnailUrl: section?.ui_preview?.url,\n wrap: false,\n // Exposed props registered here so retrievePropValue resolves their\n // page-level bindings and passes the values to SectionComposition.\n props: buildRegisteredProps(section, componentRegistry),\n component: (props) => {\n return (\n <SectionComposition\n {...props}\n compositionUID={section.uid}\n spec={sectionSpec}\n />\n );\n },\n metadata: {\n uid: section.uid,\n type: \"section-composition\",\n },\n };\n });\n\n componentRegistry.registerSectionComponent(sectionConfigs);\n};\n\n/**\n * React hook that registers section components when sections array changes.\n * Automatically handles component registration lifecycle in React components.\n *\n * @param sections - Optional array of section composition entries\n */\nexport const useRegisterSectionComponents = (\n sections?: SectionCompositionEntry[],\n) => {\n const { componentRegistry } = useRenderer();\n\n useMemo(() => {\n if (!sections?.length) return;\n registerSectionComponents(sections, componentRegistry);\n }, [sections, componentRegistry]);\n};\n"],"names":["_jsx"],"mappings":";;;;;;;AA2BA;;;;;;;;;;;;;;;;AAgBG;AACH,SAAS,oBAAoB,CAC3B,OAAgC,EAChC,iBAA6C,EAAA;IAE7C,MAAM,eAAe,GAClB,OAAO,CAAC,EAAE,EAAE,QAAQ,EAAE,mBAET,IAAI,EAAE;;;AAItB,IAAA,MAAM,SAAS,GAAG,IAAI,GAAG,EAAgB;AACzC,IAAA,IAAI,OAAO,CAAC,EAAE,EAAE;AACd,QAAA,KAAK,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAU,CAAC,EAAE;YACnD,IAAI,IAAI,EAAE,GAAG;gBAAE,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,IAAY,CAAC;QACtD;IACF;AAEA,IAAA,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,CAC9B,eAAe,CAAC,GAAG,CAAC,CAAC,EAAE,KAAI;QACzB,MAAM,YAAY,GAAG,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,OAAO,CAAC;QAC9C,MAAM,QAAQ,GAAG;AACf,cAAE,iBAAiB,CAAC,kBAAkB,CAAC,YAAY,CAAC,EAAE,KAAK,GACvD,EAAE,CAAC,OAAO;cAEZ,SAAS;QACb,O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IAAA,CAAC,CAAC;AAEF,IAAA,iBAAiB,CAAC,wBAAwB,CAAC,cAAc,CAAC;AAC5D;AAEA;;;;;AAKG;AACI,MAAM,4BAA4B,GAAG,CAC1C,QAAoC,KAClC;AACF,IAAA,MAAM,EAAE,iBAAiB,EAAE,GAAG,WAAW,EAAE;IAE3C,OAAO,CAAC,MAAK;QACX,IAAI,CAAC,QAAQ,EAAE,MAAM;YAAE;AACvB,QAAA,yBAAyB,CAAC,QAAQ,EAAE,iBAAiB,CAAC;AACxD,IAAA,CAAC,EAAE,CAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAC;AACnC;;;;"}
|
|
@@ -1,25 +1,5 @@
|
|
|
1
1
|
import { rendererContext } from '../contexts/providers/renderer.provider.js';
|
|
2
|
-
import '../contexts/providers/edit-context.provider.js';
|
|
3
|
-
import '../contexts/providers/active-node.provider.js';
|
|
4
|
-
import 'react/jsx-runtime';
|
|
5
|
-
import '@contentstack/studio-client';
|
|
6
|
-
import '@contentstack/studio-messenger';
|
|
7
|
-
import '@contentstack/studio-react-components/contexts';
|
|
8
|
-
import 'immer';
|
|
9
2
|
import { useContext } from 'react';
|
|
10
|
-
import './use-edit-context-listener.hook.js';
|
|
11
|
-
import '@contentstack/studio-internal';
|
|
12
|
-
import '@contentstack/studio-core';
|
|
13
|
-
import '@contentstack/studio-react-components/basic-components';
|
|
14
|
-
import '@contentstack/studio-react-components/hooks';
|
|
15
|
-
import 'goober';
|
|
16
|
-
import '../components/Element.js';
|
|
17
|
-
import '../contexts/providers/section-mode.provider.js';
|
|
18
|
-
import '@contentstack/studio-registry';
|
|
19
|
-
import '../contexts/providers/use-design-preview.provider.js';
|
|
20
|
-
import '../contexts/providers/use-repeater.provider.js';
|
|
21
|
-
import '../contexts/providers/use-condition-block.provider.js';
|
|
22
|
-
import '../contexts/providers/preview-mode.provider.js';
|
|
23
3
|
|
|
24
4
|
const useRenderer = () => {
|
|
25
5
|
const context = useContext(rendererContext);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-renderer.hook.js","sources":["../../src/hooks/use-renderer.hook.ts"],"sourcesContent":["import { rendererContext } from \"../contexts/providers\";\nimport { useContext } from \"react\";\n\nexport const useRenderer = () => {\n const context = useContext(rendererContext);\n return context;\n};\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-renderer.hook.js","sources":["../../src/hooks/use-renderer.hook.ts"],"sourcesContent":["import { rendererContext } from \"../contexts/providers/renderer.provider\";\nimport { useContext } from \"react\";\n\nexport const useRenderer = () => {\n const context = useContext(rendererContext);\n return context;\n};\n"],"names":[],"mappings":";;;AAGO,MAAM,WAAW,GAAG,MAAK;AAC9B,IAAA,MAAM,OAAO,GAAG,UAAU,CAAC,eAAe,CAAC;AAC3C,IAAA,OAAO,OAAO;AAChB;;;;"}
|
|
@@ -1,25 +1,5 @@
|
|
|
1
1
|
import { useContext } from 'react';
|
|
2
|
-
import '../contexts/providers/renderer.provider.js';
|
|
3
|
-
import '../contexts/providers/edit-context.provider.js';
|
|
4
|
-
import '../contexts/providers/active-node.provider.js';
|
|
5
|
-
import 'react/jsx-runtime';
|
|
6
|
-
import '@contentstack/studio-client';
|
|
7
|
-
import '@contentstack/studio-messenger';
|
|
8
|
-
import '@contentstack/studio-react-components/contexts';
|
|
9
|
-
import 'immer';
|
|
10
|
-
import './use-edit-context-listener.hook.js';
|
|
11
|
-
import '@contentstack/studio-internal';
|
|
12
|
-
import '@contentstack/studio-core';
|
|
13
|
-
import '@contentstack/studio-react-components/basic-components';
|
|
14
|
-
import '@contentstack/studio-react-components/hooks';
|
|
15
|
-
import 'goober';
|
|
16
|
-
import '../components/Element.js';
|
|
17
|
-
import '../contexts/providers/section-mode.provider.js';
|
|
18
|
-
import '@contentstack/studio-registry';
|
|
19
|
-
import '../contexts/providers/use-design-preview.provider.js';
|
|
20
2
|
import { RepeaterContext } from '../contexts/providers/use-repeater.provider.js';
|
|
21
|
-
import '../contexts/providers/use-condition-block.provider.js';
|
|
22
|
-
import '../contexts/providers/preview-mode.provider.js';
|
|
23
3
|
|
|
24
4
|
const useRepeaterContext = () => useContext(RepeaterContext);
|
|
25
5
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-repeater.hook.js","sources":["../../src/hooks/use-repeater.hook.ts"],"sourcesContent":["import { useContext } from \"react\";\nimport { RepeaterContext } from \"../contexts/providers\";\n\nexport const useRepeaterContext = () => useContext(RepeaterContext);\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-repeater.hook.js","sources":["../../src/hooks/use-repeater.hook.ts"],"sourcesContent":["import { useContext } from \"react\";\nimport { RepeaterContext } from \"../contexts/providers/use-repeater.provider\";\n\nexport const useRepeaterContext = () => useContext(RepeaterContext);\n"],"names":[],"mappings":";;;AAGO,MAAM,kBAAkB,GAAG,MAAM,UAAU,CAAC,eAAe;;;;"}
|
|
@@ -1,29 +1,10 @@
|
|
|
1
1
|
import { clientRendererModeUtil } from '@contentstack/studio-client';
|
|
2
2
|
import { useContext } from 'react';
|
|
3
|
-
import '../contexts/providers/renderer.provider.js';
|
|
4
|
-
import '../contexts/providers/edit-context.provider.js';
|
|
5
|
-
import '../contexts/providers/active-node.provider.js';
|
|
6
|
-
import 'react/jsx-runtime';
|
|
7
|
-
import '@contentstack/studio-messenger';
|
|
8
|
-
import '@contentstack/studio-react-components/contexts';
|
|
9
|
-
import 'immer';
|
|
10
|
-
import './use-edit-context-listener.hook.js';
|
|
11
|
-
import '@contentstack/studio-internal';
|
|
12
|
-
import '@contentstack/studio-core';
|
|
13
|
-
import '@contentstack/studio-react-components/basic-components';
|
|
14
|
-
import '@contentstack/studio-react-components/hooks';
|
|
15
|
-
import 'goober';
|
|
16
|
-
import '../components/Element.js';
|
|
17
3
|
import { SectionModeContext } from '../contexts/providers/section-mode.provider.js';
|
|
4
|
+
import { useConditionBlockContext } from './use-condition-block-context.js';
|
|
18
5
|
import { useDesignPreviewContext } from './use-design-preview.hook.js';
|
|
19
6
|
import { useRenderer } from './use-renderer.hook.js';
|
|
20
|
-
import '@contentstack/studio-registry';
|
|
21
7
|
import { useRepeaterContext } from './use-repeater.hook.js';
|
|
22
|
-
import { useConditionBlockContext } from './use-condition-block-context.js';
|
|
23
|
-
import '../contexts/providers/use-design-preview.provider.js';
|
|
24
|
-
import '../contexts/providers/use-repeater.provider.js';
|
|
25
|
-
import '../contexts/providers/use-condition-block.provider.js';
|
|
26
|
-
import '../contexts/providers/preview-mode.provider.js';
|
|
27
8
|
|
|
28
9
|
function useShouldShowDesign(mode) {
|
|
29
10
|
const { isCompositionBeingEdited } = useRenderer();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-should-show-design.hook.js","sources":["../../src/hooks/use-should-show-design.hook.ts"],"sourcesContent":["import { clientRendererModeUtil } from \"@contentstack/studio-client\";\nimport { useContext } from \"react\";\nimport { SectionModeContext } from \"../contexts/providers\";\nimport { useConditionBlockContext } from \"./use-condition-block-context\";\nimport { useDesignPreviewContext } from \"./use-design-preview.hook\";\nimport { useRenderer } from \"./use-renderer.hook\";\nimport { useRepeaterContext } from \"./use-repeater.hook\";\n\nexport function useShouldShowDesign(mode: \"design\" | \"preview\") {\n const { isCompositionBeingEdited } = useRenderer();\n const { isInsideRepeater } = useRepeaterContext();\n const { isInsideConditionBlock } = useConditionBlockContext();\n const designPreviewContext = useDesignPreviewContext();\n const sectionMode = useContext(SectionModeContext);\n // Treat the Studio editor frame as design-mode-eligible from the very first\n // render — even before `isCompositionBeingEdited` has resolved — to avoid a\n // one-frame preview render that would inject items[0] context. Use\n // `isInsideStudioFrame()` (URL-param-gated) so Visual Builder's iframe\n // (which should render preview) is correctly excluded.\n const isInsideStudio = clientRendererModeUtil.isInsideStudioFrame();\n if (!isCompositionBeingEdited && !isInsideStudio) return false;\n\n // A placed section forces the mode of everything inside it — a single\n // per-placement switch that overrides each inner node's own `mode`. Only set\n // inside a section placement in the editor; null everywhere else.\n // - PREVIEW always wins → render preview.\n // - DESIGN keeps the section's own drop-zones visible, BUT when the section\n // is itself nested inside an enclosing PREVIEW repeater its internal data\n // repeaters must still iterate — otherwise a data-bound slot child can\n // never resolve its per-iteration context (SP7.1: a slot-bearing section\n // defaults to design via COMS-1595, which froze its inner repeaters). So\n // defer to the enclosing preview context in that case. At the page root\n // designPreviewContext is \"none\", so design is preserved (the slot's own\n // drop-zone-vs-collapsed rendering reads SectionModeContext directly and\n // is unaffected either way).\n if (sectionMode === \"preview\") return false;\n if (sectionMode === \"design\") return designPreviewContext !== \"preview\";\n\n if (isInsideRepeater || isInsideConditionBlock) {\n // If composition is being edited and current node(Repeater or Condition Block) inside another repeater or condition block,\n // and no designPreviewContext is provided, then show design\n if (!designPreviewContext) return true;\n // If designPreviewContext is provided,\n // then show design based on designPreviewContext\n return designPreviewContext === \"design\";\n }\n // if no mode is provided, then show design\n if (!mode) {\n return true;\n }\n // If mode is provided, then show design based on mode\n return mode === \"design\";\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-should-show-design.hook.js","sources":["../../src/hooks/use-should-show-design.hook.ts"],"sourcesContent":["import { clientRendererModeUtil } from \"@contentstack/studio-client\";\nimport { useContext } from \"react\";\nimport { SectionModeContext } from \"../contexts/providers/section-mode.provider\";\nimport { useConditionBlockContext } from \"./use-condition-block-context\";\nimport { useDesignPreviewContext } from \"./use-design-preview.hook\";\nimport { useRenderer } from \"./use-renderer.hook\";\nimport { useRepeaterContext } from \"./use-repeater.hook\";\n\nexport function useShouldShowDesign(mode: \"design\" | \"preview\") {\n const { isCompositionBeingEdited } = useRenderer();\n const { isInsideRepeater } = useRepeaterContext();\n const { isInsideConditionBlock } = useConditionBlockContext();\n const designPreviewContext = useDesignPreviewContext();\n const sectionMode = useContext(SectionModeContext);\n // Treat the Studio editor frame as design-mode-eligible from the very first\n // render — even before `isCompositionBeingEdited` has resolved — to avoid a\n // one-frame preview render that would inject items[0] context. Use\n // `isInsideStudioFrame()` (URL-param-gated) so Visual Builder's iframe\n // (which should render preview) is correctly excluded.\n const isInsideStudio = clientRendererModeUtil.isInsideStudioFrame();\n if (!isCompositionBeingEdited && !isInsideStudio) return false;\n\n // A placed section forces the mode of everything inside it — a single\n // per-placement switch that overrides each inner node's own `mode`. Only set\n // inside a section placement in the editor; null everywhere else.\n // - PREVIEW always wins → render preview.\n // - DESIGN keeps the section's own drop-zones visible, BUT when the section\n // is itself nested inside an enclosing PREVIEW repeater its internal data\n // repeaters must still iterate — otherwise a data-bound slot child can\n // never resolve its per-iteration context (SP7.1: a slot-bearing section\n // defaults to design via COMS-1595, which froze its inner repeaters). So\n // defer to the enclosing preview context in that case. At the page root\n // designPreviewContext is \"none\", so design is preserved (the slot's own\n // drop-zone-vs-collapsed rendering reads SectionModeContext directly and\n // is unaffected either way).\n if (sectionMode === \"preview\") return false;\n if (sectionMode === \"design\") return designPreviewContext !== \"preview\";\n\n if (isInsideRepeater || isInsideConditionBlock) {\n // If composition is being edited and current node(Repeater or Condition Block) inside another repeater or condition block,\n // and no designPreviewContext is provided, then show design\n if (!designPreviewContext) return true;\n // If designPreviewContext is provided,\n // then show design based on designPreviewContext\n return designPreviewContext === \"design\";\n }\n // if no mode is provided, then show design\n if (!mode) {\n return true;\n }\n // If mode is provided, then show design based on mode\n return mode === \"design\";\n}\n"],"names":[],"mappings":";;;;;;;;AAQM,SAAU,mBAAmB,CAAC,IAA0B,EAAA;AAC5D,IAAA,MAAM,EAAE,wBAAwB,EAAE,GAAG,WAAW,EAAE;AAClD,IAAA,MAAM,EAAE,gBAAgB,EAAE,GAAG,kBAAkB,EAAE;AACjD,IAAA,MAAM,EAAE,sBAAsB,EAAE,GAAG,wBAAwB,EAAE;AAC7D,IAAA,MAAM,oBAAoB,GAAG,uBAAuB,EAAE;AACtD,IAAA,MAAM,WAAW,GAAG,UAAU,CAAC,kBAAkB,CAAC;;;;;;AAMlD,IAAA,MAAM,cAAc,GAAG,sBAAsB,CAAC,mBAAmB,EAAE;AACnE,IAAA,IAAI,CAAC,wBAAwB,IAAI,CAAC,cAAc;AAAE,QAAA,OAAO,KAAK;;;;;;;;;;;;;;IAe9D,IAAI,WAAW,KAAK,SAAS;AAAE,QAAA,OAAO,KAAK;IAC3C,IAAI,WAAW,KAAK,QAAQ;QAAE,OAAO,oBAAoB,KAAK,SAAS;AAEvE,IAAA,IAAI,gBAAgB,IAAI,sBAAsB,EAAE;;;AAG9C,QAAA,IAAI,CAAC,oBAAoB;AAAE,YAAA,OAAO,IAAI;;;QAGtC,OAAO,oBAAoB,KAAK,QAAQ;IAC1C;;IAEA,IAAI,CAAC,IAAI,EAAE;AACT,QAAA,OAAO,IAAI;IACb;;IAEA,OAAO,IAAI,KAAK,QAAQ;AAC1B;;;;"}
|
|
@@ -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;AAClB,IAAA,CAAC,EACD,CAAC,OAAO,CAAC,CACV;;;;IAKD,SAAS,CAAC,MAAM,oBAAoB,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;IAE7E,OAAO;QACL,GAAG;AACH,QAAA,IAAI,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