@contentstack/studio-react-editor 1.4.0 → 1.5.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/BuildingIllustration.js +8 -0
- package/dist/components/BuildingIllustration.js.map +1 -0
- package/dist/components/EditableRenderer.js +26 -4
- package/dist/components/EditableRenderer.js.map +1 -1
- package/dist/components/Element.js +68 -22
- package/dist/components/Element.js.map +1 -1
- package/dist/components/PreviewRenderer.js +5 -0
- package/dist/components/PreviewRenderer.js.map +1 -1
- package/dist/components/Slot.js +26 -4
- package/dist/components/Slot.js.map +1 -1
- package/dist/components/WelcomeState.js +33 -0
- package/dist/components/WelcomeState.js.map +1 -0
- package/dist/components/elements/ConditionBlock.js +5 -0
- package/dist/components/elements/ConditionBlock.js.map +1 -1
- package/dist/components/elements/Repeater.js +9 -38
- package/dist/components/elements/Repeater.js.map +1 -1
- package/dist/components/elements/SectionComposition.js +208 -0
- package/dist/components/elements/SectionComposition.js.map +1 -0
- package/dist/components/elements/SectionSlot.js +164 -0
- package/dist/components/elements/SectionSlot.js.map +1 -0
- package/dist/components/elements/Symbol.js +7 -2
- package/dist/components/elements/Symbol.js.map +1 -1
- package/dist/components/styles.js +72 -0
- package/dist/components/styles.js.map +1 -1
- package/dist/contexts/providers/renderer.provider.js +1 -0
- package/dist/contexts/providers/renderer.provider.js.map +1 -1
- package/dist/contexts/providers/section-mode.provider.js +15 -0
- package/dist/contexts/providers/section-mode.provider.js.map +1 -0
- package/dist/contexts/providers/symbol-ui.provider.js +19 -6
- package/dist/contexts/providers/symbol-ui.provider.js.map +1 -1
- package/dist/hooks/use-active-node-path.hook.js +6 -1
- package/dist/hooks/use-active-node-path.hook.js.map +1 -1
- package/dist/hooks/use-condition-block-context.js +6 -1
- package/dist/hooks/use-condition-block-context.js.map +1 -1
- package/dist/hooks/use-design-preview.hook.js +6 -1
- package/dist/hooks/use-design-preview.hook.js.map +1 -1
- package/dist/hooks/use-preview-mode.hook.js +6 -1
- package/dist/hooks/use-preview-mode.hook.js.map +1 -1
- package/dist/hooks/use-register-section.hook.js +110 -0
- package/dist/hooks/use-register-section.hook.js.map +1 -0
- package/dist/hooks/use-renderer.hook.js +6 -1
- package/dist/hooks/use-renderer.hook.js.map +1 -1
- package/dist/hooks/use-repeater.hook.js +6 -1
- package/dist/hooks/use-repeater.hook.js.map +1 -1
- package/dist/hooks/use-section-events.hook.js +63 -0
- package/dist/hooks/use-section-events.hook.js.map +1 -0
- package/dist/hooks/use-should-show-design.hook.js +46 -2
- package/dist/hooks/use-should-show-design.hook.js.map +1 -1
- package/dist/hooks/use-spec-data-listener.hook.js +352 -12
- package/dist/hooks/use-spec-data-listener.hook.js.map +1 -1
- package/dist/hooks/use-symbol-events.hook.js +13 -0
- package/dist/hooks/use-symbol-events.hook.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/package.json +11 -15
|
@@ -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 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});\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,OAAO,EAAE,MAAM;AACf,QAAA,GAAG,EAAE,KAAK;AACV,Q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,QAAA,aAAa,EAAE,QAAQ;AACvB,QAAA,GAAG,EAAE,MAAM;AACX,QAAA,SAAS,EAAE;AACT,YAAA,OAAO,EAAE,MAAM;AACf,YAAA,UAAU,EAAE,QAAQ;AACpB,YAAA,GAAG,EAAE,QAAQ;AACd,SAAA;AACD,QAAA,EAAE,EAAE;AACF,YAAA,QAAQ,EAAE,MAAM;AAChB,YAAA,UAAU,EAAE,GAAG;AACf,YAAA,MAAM,EAAE,CAAC;AACV,SAAA;AACD,QAAA,CAAC,EAAE;AACD,YAAA,QAAQ,EAAE,MAAM;AAChB,YAAA,UAAU,EAAE,GAAG;AACf,YAAA,UAAU,EAAE,MAAM;AAClB,YAAA,aAAa,EAAE,IAAI;AACnB,YAAA,MAAM,EAAE,CAAC;AACV,SAAA;KACF,CAAC;AACH,CAAA;;;;"}
|
|
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,OAAO,EAAE,MAAM;AACf,QAAA,GAAG,EAAE,KAAK;AACV,QAAA,UAAU,EAAE,QAAQ;AACpB,QAAA,cAAc,EAAE,QAAQ;AACxB,QAAA,MAAM,EAAE,oBAAoB;AAC5B,QAAA,KAAK,EAAE,SAAS;AAChB,QAAA,QAAQ,EAAE,MAAM;AAChB,QAAA,SAAS,EAAE,QAAQ;AACnB,QAAA,UAAU,EAAE,GAAG;AACf,QAAA,UAAU,EAAE,MAAM;AAClB,QAAA,UAAU,EAAE,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,EAAE,OAAO;AACjB,QAAA,UAAU,EAAE,mBAAmB;AAC/B,QAAA,UAAU,EAAE,KAAK;KAClB,CAAC;IACF,YAAY,EAAE,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,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;;;;"}
|
|
@@ -13,6 +13,7 @@ const RendererProvider = (props) => {
|
|
|
13
13
|
return {
|
|
14
14
|
isCompositionBeingEdited: isCompositionEdited,
|
|
15
15
|
componentRegistry,
|
|
16
|
+
compositionPlacement: spec?.compositionEntry?.place_composition_as,
|
|
16
17
|
};
|
|
17
18
|
}, [spec, componentRegistry]);
|
|
18
19
|
return jsx(Provider, { value: value, children: children });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderer.provider.js","sources":["../../../src/contexts/providers/renderer.provider.tsx"],"sourcesContent":["import {\n StudioSpec,\n isCompositionBeingEdited,\n} from \"@contentstack/studio-client\";\nimport { createContext, FC, useMemo } from \"react\";\nimport { ComponentRegistryType } from \"../../types/renderer.type\";\n\ninterface RendererContext {\n isCompositionBeingEdited: boolean;\n componentRegistry: ComponentRegistryType;\n}\n\ninterface RendererProviderProps {\n componentRegistry: ComponentRegistryType;\n spec: StudioSpec;\n children: React.ReactNode;\n}\n\nexport const rendererContext = createContext<RendererContext>({\n isCompositionBeingEdited: false,\n} as RendererContext);\n\nconst { Provider } = rendererContext;\n\nexport const RendererProvider: FC<RendererProviderProps> = (props) => {\n const { children, spec, componentRegistry } = props;\n const value = useMemo(() => {\n const isCompositionEdited = isCompositionBeingEdited(\n spec?.compositionEntry?.composable_uid ?? \"\",\n );\n return {\n isCompositionBeingEdited: isCompositionEdited,\n componentRegistry,\n };\n }, [spec, componentRegistry]);\n return <Provider value={value}>{children}</Provider>;\n};\n"],"names":["_jsx"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"renderer.provider.js","sources":["../../../src/contexts/providers/renderer.provider.tsx"],"sourcesContent":["import {\n StudioSpec,\n isCompositionBeingEdited,\n type CompositionPlacement,\n} from \"@contentstack/studio-client\";\nimport { createContext, FC, useMemo } from \"react\";\nimport { ComponentRegistryType } from \"../../types/renderer.type\";\n\ninterface RendererContext {\n isCompositionBeingEdited: boolean;\n componentRegistry: ComponentRegistryType;\n compositionPlacement?: CompositionPlacement;\n}\n\ninterface RendererProviderProps {\n componentRegistry: ComponentRegistryType;\n spec: StudioSpec;\n children: React.ReactNode;\n}\n\nexport const rendererContext = createContext<RendererContext>({\n isCompositionBeingEdited: false,\n} as RendererContext);\n\nconst { Provider } = rendererContext;\n\nexport const RendererProvider: FC<RendererProviderProps> = (props) => {\n const { children, spec, componentRegistry } = props;\n const value = useMemo(() => {\n const isCompositionEdited = isCompositionBeingEdited(\n spec?.compositionEntry?.composable_uid ?? \"\",\n );\n return {\n isCompositionBeingEdited: isCompositionEdited,\n componentRegistry,\n compositionPlacement: spec?.compositionEntry?.place_composition_as,\n };\n }, [spec, componentRegistry]);\n return <Provider value={value}>{children}</Provider>;\n};\n"],"names":["_jsx"],"mappings":";;;;AAoBO,MAAM,eAAe,GAAG,aAAa,CAAkB;AAC5D,IAAA,wBAAwB,EAAE,KAAK;AACb,CAAA;AAEpB,MAAM,EAAE,QAAQ,EAAE,GAAG,eAAe;AAE7B,MAAM,gBAAgB,GAA8B,CAAC,KAAK,KAAI;IACnE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,iBAAiB,EAAE,GAAG,KAAK;AACnD,IAAA,MAAM,KAAK,GAAG,OAAO,CAAC,MAAK;AACzB,QAAA,MAAM,mBAAmB,GAAG,wBAAwB,CAClD,IAAI,EAAE,gBAAgB,EAAE,cAAc,IAAI,EAAE,CAC7C;QACD,OAAO;AACL,YAAA,wBAAwB,EAAE,mBAAmB;YAC7C,iBAAiB;AACjB,YAAA,oBAAoB,EAAE,IAAI,EAAE,gBAAgB,EAAE,oBAAoB;SACnE;AACH,IAAA,CAAC,EAAE,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;IAC7B,OAAOA,GAAA,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,KAAK,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAY;AACtD;;;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createContext } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Forced design/preview mode contributed by an enclosing placed section.
|
|
5
|
+
*
|
|
6
|
+
* A placed section-composition node carries its own `metadata.mode`. When set,
|
|
7
|
+
* every repeater, condition-block, and section-slot rendered inside that section
|
|
8
|
+
* follows this mode instead of its own — a single per-placement switch derives
|
|
9
|
+
* all inner modes. `null` means "no enclosing section forcing a mode" (the inner
|
|
10
|
+
* node falls back to its own `mode`). Editor-only; production never forces.
|
|
11
|
+
*/
|
|
12
|
+
const SectionModeContext = createContext(null);
|
|
13
|
+
|
|
14
|
+
export { SectionModeContext };
|
|
15
|
+
//# sourceMappingURL=section-mode.provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"section-mode.provider.js","sources":["../../../src/contexts/providers/section-mode.provider.tsx"],"sourcesContent":["import { createContext } from \"react\";\n\n/**\n * Forced design/preview mode contributed by an enclosing placed section.\n *\n * A placed section-composition node carries its own `metadata.mode`. When set,\n * every repeater, condition-block, and section-slot rendered inside that section\n * follows this mode instead of its own — a single per-placement switch derives\n * all inner modes. `null` means \"no enclosing section forcing a mode\" (the inner\n * node falls back to its own `mode`). Editor-only; production never forces.\n */\nexport const SectionModeContext = createContext<\"design\" | \"preview\" | null>(\n null,\n);\n"],"names":[],"mappings":";;AAEA;;;;;;;;AAQG;MACU,kBAAkB,GAAG,aAAa,CAC7C,IAAI;;;;"}
|
|
@@ -4,14 +4,21 @@ import { composableStudioEventManager, POST_MESSAGE_EVENTS } from '@contentstack
|
|
|
4
4
|
import { SymbolUICtx } from '@contentstack/studio-react-components/contexts';
|
|
5
5
|
import { produce } from 'immer';
|
|
6
6
|
import { useState, useEffect } from 'react';
|
|
7
|
-
import
|
|
8
|
-
import
|
|
7
|
+
import '@contentstack/studio-internal';
|
|
8
|
+
import '@contentstack/studio-core';
|
|
9
|
+
import '@contentstack/studio-react-components/basic-components';
|
|
10
|
+
import '@contentstack/studio-react-components/hooks';
|
|
11
|
+
import 'goober';
|
|
12
|
+
import '../../components/Element.js';
|
|
9
13
|
import './renderer.provider.js';
|
|
10
14
|
import './active-node.provider.js';
|
|
11
15
|
import './use-design-preview.provider.js';
|
|
12
16
|
import './use-repeater.provider.js';
|
|
13
17
|
import './use-condition-block.provider.js';
|
|
14
18
|
import './preview-mode.provider.js';
|
|
19
|
+
import './section-mode.provider.js';
|
|
20
|
+
import { useRenderer } from '../../hooks/use-renderer.hook.js';
|
|
21
|
+
import { registerSymbolComponent } from '../../hooks/use-register-symbol.hook.js';
|
|
15
22
|
|
|
16
23
|
const SymbolUIProvider = ({ symbols, children, }) => {
|
|
17
24
|
const { componentRegistry } = useRenderer();
|
|
@@ -20,11 +27,17 @@ const SymbolUIProvider = ({ symbols, children, }) => {
|
|
|
20
27
|
return acc;
|
|
21
28
|
}, {}));
|
|
22
29
|
useEffect(() => {
|
|
23
|
-
|
|
24
|
-
acc
|
|
25
|
-
|
|
26
|
-
|
|
30
|
+
if (symbols.length > 0) {
|
|
31
|
+
setSymbolUIs(symbols.reduce((acc, symbol) => {
|
|
32
|
+
acc[symbol.uid] = symbol;
|
|
33
|
+
return acc;
|
|
34
|
+
}, {}));
|
|
35
|
+
}
|
|
27
36
|
}, [symbols]);
|
|
37
|
+
// UPDATE_SYMBOLS / GET_SYMBOLS are handled by use-symbol-events.hook.ts,
|
|
38
|
+
// which updates `state.symbols` — that flows down here as the `symbols`
|
|
39
|
+
// prop and is picked up by the useEffect above. Registering another
|
|
40
|
+
// listener here just produced a duplicate-registration warning.
|
|
28
41
|
useEffect(() => {
|
|
29
42
|
const handleApplySymbolOperation = (data) => {
|
|
30
43
|
const { uid, operations } = data;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"symbol-ui.provider.js","sources":["../../../src/contexts/providers/symbol-ui.provider.tsx"],"sourcesContent":["import { applyOperation, SymbolEntry } from \"@contentstack/studio-client\";\nimport { Operation } from \"@contentstack/studio-internal\";\nimport {\n composableStudioEventManager,\n POST_MESSAGE_EVENTS,\n} from \"@contentstack/studio-messenger\";\nimport { SymbolUICtx } from \"@contentstack/studio-react-components/contexts\";\nimport { produce } from \"immer\";\nimport { useEffect, useState } from \"react\";\nimport { registerSymbolComponent, useRenderer } from \"../../hooks\";\n\nexport interface SymbolUIProvider {\n [uid: string]: SymbolEntry;\n}\ninterface SymbolUIProviderProps {\n children: React.ReactNode;\n symbols: SymbolEntry[];\n}\nexport const SymbolUIProvider = ({\n symbols,\n children,\n}: SymbolUIProviderProps) => {\n const { componentRegistry } = useRenderer();\n const [symbolUIs, setSymbolUIs] = useState<SymbolUIProvider>(\n symbols.reduce((acc, symbol) => {\n acc[symbol.uid] = symbol;\n return acc;\n }, {} as SymbolUIProvider),\n );\n\n useEffect(() => {\n setSymbolUIs(\n
|
|
1
|
+
{"version":3,"file":"symbol-ui.provider.js","sources":["../../../src/contexts/providers/symbol-ui.provider.tsx"],"sourcesContent":["import { applyOperation, SymbolEntry } from \"@contentstack/studio-client\";\nimport { Operation } from \"@contentstack/studio-internal\";\nimport {\n composableStudioEventManager,\n POST_MESSAGE_EVENTS,\n} from \"@contentstack/studio-messenger\";\nimport { SymbolUICtx } from \"@contentstack/studio-react-components/contexts\";\nimport { produce } from \"immer\";\nimport { useEffect, useState } from \"react\";\nimport { registerSymbolComponent, useRenderer } from \"../../hooks\";\n\nexport interface SymbolUIProvider {\n [uid: string]: SymbolEntry;\n}\ninterface SymbolUIProviderProps {\n children: React.ReactNode;\n symbols: SymbolEntry[];\n}\nexport const SymbolUIProvider = ({\n symbols,\n children,\n}: SymbolUIProviderProps) => {\n const { componentRegistry } = useRenderer();\n const [symbolUIs, setSymbolUIs] = useState<SymbolUIProvider>(\n symbols.reduce((acc, symbol) => {\n acc[symbol.uid] = symbol;\n return acc;\n }, {} as SymbolUIProvider),\n );\n\n useEffect(() => {\n if (symbols.length > 0) {\n setSymbolUIs(\n symbols.reduce((acc, symbol) => {\n acc[symbol.uid] = symbol;\n return acc;\n }, {} as SymbolUIProvider),\n );\n }\n }, [symbols]);\n\n // UPDATE_SYMBOLS / GET_SYMBOLS are handled by use-symbol-events.hook.ts,\n // which updates `state.symbols` — that flows down here as the `symbols`\n // prop and is picked up by the useEffect above. Registering another\n // listener here just produced a duplicate-registration warning.\n\n useEffect(() => {\n const handleApplySymbolOperation = (data: {\n operations: Operation[];\n uid: string;\n }) => {\n const { uid, operations } = data;\n setSymbolUIs((symbolUIs) => {\n if (!symbolUIs[uid]) return symbolUIs;\n const newSymbolUIs = produce(symbolUIs, (draft) => {\n const symbol = draft[uid];\n if (!symbol) return;\n const newSymbol = applyOperation(symbol.ui, operations);\n symbol.ui = newSymbol;\n draft[uid] = {\n ...symbol,\n };\n });\n registerSymbolComponent([newSymbolUIs[uid]], componentRegistry);\n return newSymbolUIs;\n });\n };\n\n const applySymbolOperationListener = composableStudioEventManager?.on<{\n operations: Operation[];\n uid: string;\n }>(POST_MESSAGE_EVENTS.APPLY_SYMBOL_OPERATION, (event) => {\n handleApplySymbolOperation(event.data);\n });\n return () => {\n applySymbolOperationListener?.unregister();\n };\n }, []);\n\n useEffect(() => {\n const newSymbolListener = composableStudioEventManager?.on<{\n symbol: SymbolEntry;\n }>(POST_MESSAGE_EVENTS.ADD_NEW_SYMBOL, (event) => {\n const { symbol } = event.data;\n registerSymbolComponent([symbol], componentRegistry);\n setSymbolUIs((symbolUIs) => {\n return produce(symbolUIs, (draft) => {\n draft[symbol.uid] = symbol;\n });\n });\n });\n return () => {\n newSymbolListener?.unregister();\n };\n }, []);\n return (\n <SymbolUICtx.Provider value={symbolUIs}>{children}</SymbolUICtx.Provider>\n );\n};\n"],"names":["_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAkBO,MAAM,gBAAgB,GAAG,CAAC,EAC/B,OAAO,EACP,QAAQ,GACc,KAAI;AAC1B,IAAA,MAAM,EAAE,iBAAiB,EAAE,GAAG,WAAW,EAAE;AAC3C,IAAA,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CACxC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM,KAAI;AAC7B,QAAA,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM;AACxB,QAAA,OAAO,GAAG;AACZ,IAAA,CAAC,EAAE,EAAsB,CAAC,CAC3B;IAED,SAAS,CAAC,MAAK;AACb,QAAA,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;YACtB,YAAY,CACV,OAAO,CAAC,MAAM,C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AA,CAAC;IACH,CAAC,EAAE,EAAE,CAAC;IAEN,SAAS,CAAC,MAAK;AACb,QAAA,MAAM,iBAAiB,GAAG,4BAA4B,EAAE,EAAE,CAEvD,mBAAmB,CAAC,cAAc,EAAE,CAAC,KAAK,KAAI;AAC/C,YAAA,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC,IAAI;AAC7B,YAAA,uBAAuB,CAAC,CAAC,MAAM,CAAC,EAAE,iBAAiB,CAAC;AACpD,YAAA,YAAY,CAAC,CAAC,SAAS,KAAI;AACzB,gBAAA,OAAO,OAAO,CAAC,SAAS,EAAE,CAAC,KAAK,KAAI;AAClC,oBAAA,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM;AAC5B,gBAAA,CAAC,CAAC;AACJ,YAAA,CAAC,CAAC;AACJ,QAAA,CAAC,CAAC;AACF,QAAA,OAAO,MAAK;YACV,iBAAiB,EAAE,UAAU,EAAE;AACjC,QAAA,CAAC;IACH,CAAC,EAAE,EAAE,CAAC;AACN,IAAA,QACEA,GAAA,CAAC,WAAW,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,SAAS,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAwB;AAE7E;;;;"}
|
|
@@ -6,9 +6,14 @@ import 'react/jsx-runtime';
|
|
|
6
6
|
import '@contentstack/studio-messenger';
|
|
7
7
|
import '@contentstack/studio-react-components/contexts';
|
|
8
8
|
import 'immer';
|
|
9
|
+
import '@contentstack/studio-internal';
|
|
10
|
+
import '@contentstack/studio-core';
|
|
11
|
+
import '@contentstack/studio-react-components/basic-components';
|
|
9
12
|
import '@contentstack/studio-react-components/hooks';
|
|
10
|
-
import '
|
|
13
|
+
import 'goober';
|
|
11
14
|
import '../components/Element.js';
|
|
15
|
+
import '../contexts/providers/section-mode.provider.js';
|
|
16
|
+
import '@contentstack/studio-registry';
|
|
12
17
|
import '../contexts/providers/use-design-preview.provider.js';
|
|
13
18
|
import '../contexts/providers/use-repeater.provider.js';
|
|
14
19
|
import '../contexts/providers/use-condition-block.provider.js';
|
|
@@ -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\";\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;;;;"}
|
|
@@ -6,9 +6,14 @@ import '@contentstack/studio-client';
|
|
|
6
6
|
import '@contentstack/studio-messenger';
|
|
7
7
|
import '@contentstack/studio-react-components/contexts';
|
|
8
8
|
import 'immer';
|
|
9
|
+
import '@contentstack/studio-internal';
|
|
10
|
+
import '@contentstack/studio-core';
|
|
11
|
+
import '@contentstack/studio-react-components/basic-components';
|
|
9
12
|
import '@contentstack/studio-react-components/hooks';
|
|
10
|
-
import '
|
|
13
|
+
import 'goober';
|
|
11
14
|
import '../components/Element.js';
|
|
15
|
+
import '../contexts/providers/section-mode.provider.js';
|
|
16
|
+
import '@contentstack/studio-registry';
|
|
12
17
|
import '../contexts/providers/use-design-preview.provider.js';
|
|
13
18
|
import '../contexts/providers/use-repeater.provider.js';
|
|
14
19
|
import { ConditionBlockContext } from '../contexts/providers/use-condition-block.provider.js';
|
|
@@ -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\";\n\nexport const useConditionBlockContext = () => useContext(ConditionBlockContext);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAGO,MAAM,wBAAwB,GAAG,MAAM,UAAU,CAAC,qBAAqB;;;;"}
|
|
@@ -6,9 +6,14 @@ import '@contentstack/studio-client';
|
|
|
6
6
|
import '@contentstack/studio-messenger';
|
|
7
7
|
import '@contentstack/studio-react-components/contexts';
|
|
8
8
|
import 'immer';
|
|
9
|
+
import '@contentstack/studio-internal';
|
|
10
|
+
import '@contentstack/studio-core';
|
|
11
|
+
import '@contentstack/studio-react-components/basic-components';
|
|
9
12
|
import '@contentstack/studio-react-components/hooks';
|
|
10
|
-
import '
|
|
13
|
+
import 'goober';
|
|
11
14
|
import '../components/Element.js';
|
|
15
|
+
import '../contexts/providers/section-mode.provider.js';
|
|
16
|
+
import '@contentstack/studio-registry';
|
|
12
17
|
import { DesignPreviewContext } from '../contexts/providers/use-design-preview.provider.js';
|
|
13
18
|
import '../contexts/providers/use-repeater.provider.js';
|
|
14
19
|
import '../contexts/providers/use-condition-block.provider.js';
|
|
@@ -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\";\n\nexport const useDesignPreviewContext = () => useContext(DesignPreviewContext);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAGO,MAAM,uBAAuB,GAAG,MAAM,UAAU,CAAC,oBAAoB;;;;"}
|
|
@@ -6,9 +6,14 @@ import '@contentstack/studio-client';
|
|
|
6
6
|
import '@contentstack/studio-messenger';
|
|
7
7
|
import '@contentstack/studio-react-components/contexts';
|
|
8
8
|
import 'immer';
|
|
9
|
+
import '@contentstack/studio-internal';
|
|
10
|
+
import '@contentstack/studio-core';
|
|
11
|
+
import '@contentstack/studio-react-components/basic-components';
|
|
9
12
|
import '@contentstack/studio-react-components/hooks';
|
|
10
|
-
import '
|
|
13
|
+
import 'goober';
|
|
11
14
|
import '../components/Element.js';
|
|
15
|
+
import '../contexts/providers/section-mode.provider.js';
|
|
16
|
+
import '@contentstack/studio-registry';
|
|
12
17
|
import '../contexts/providers/use-design-preview.provider.js';
|
|
13
18
|
import '../contexts/providers/use-repeater.provider.js';
|
|
14
19
|
import '../contexts/providers/use-condition-block.provider.js';
|
|
@@ -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\";\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;;;;"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { preProcessStaticValues } from '@contentstack/studio-client';
|
|
3
|
+
import { Node } from '@contentstack/studio-internal';
|
|
4
|
+
import { useMemo } from 'react';
|
|
5
|
+
import { SectionComposition } from '../components/elements/SectionComposition.js';
|
|
6
|
+
import { useRenderer } from './use-renderer.hook.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Reads sectionExposedProps from the section's UI metadata and converts them
|
|
10
|
+
* into the Props format that the component registry understands.
|
|
11
|
+
*
|
|
12
|
+
* This is what makes retrievePropValue resolve exposed-prop bindings on the
|
|
13
|
+
* page-level section-composition node — without these registered props the
|
|
14
|
+
* resolver skips them entirely and the override values never reach the section.
|
|
15
|
+
*
|
|
16
|
+
* Each exposed prop is enriched with the FULL schema of the internal component
|
|
17
|
+
* prop it was exposed from (looked up via the internal node's registered
|
|
18
|
+
* component). Registering only { type, displayName } loses `placeholder` and
|
|
19
|
+
* `defaultValue`, so a CLEARED exposed prop resolves to an empty value instead
|
|
20
|
+
* of the component's editor placeholder (e.g. "Your text here"). With the full
|
|
21
|
+
* schema, a cleared exposed prop resolves exactly like a normal unbound node —
|
|
22
|
+
* showing the placeholder in Studio — and the override carries it down to the
|
|
23
|
+
* internal node. The editor panel registration enriches the same way.
|
|
24
|
+
*/
|
|
25
|
+
function buildRegisteredProps(section, componentRegistry) {
|
|
26
|
+
const exposedPropDefs = section.ui?.metadata?.sectionExposedProps ?? [];
|
|
27
|
+
// Index the section's internal nodes by uid so each exposed prop can recover
|
|
28
|
+
// its originating component prop schema.
|
|
29
|
+
const nodeByUid = new Map();
|
|
30
|
+
if (section.ui) {
|
|
31
|
+
for (const [node] of Node.nodes(section.ui)) {
|
|
32
|
+
if (node?.uid)
|
|
33
|
+
nodeByUid.set(node.uid, node);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const props = Object.fromEntries(exposedPropDefs.map((ep) => {
|
|
37
|
+
const internalNode = nodeByUid.get(ep.nodeUid);
|
|
38
|
+
const fullProp = internalNode
|
|
39
|
+
? componentRegistry.getComponentByNode(internalNode)?.props?.[ep.propKey]
|
|
40
|
+
: undefined;
|
|
41
|
+
return [
|
|
42
|
+
ep.uid,
|
|
43
|
+
{
|
|
44
|
+
...(fullProp ?? {}),
|
|
45
|
+
type: ep.propType,
|
|
46
|
+
displayName: ep.displayName,
|
|
47
|
+
},
|
|
48
|
+
];
|
|
49
|
+
}));
|
|
50
|
+
return props;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Registers section composition entries as React components in the component registry.
|
|
54
|
+
* Each section is registered with its exposed props so the page-level binding
|
|
55
|
+
* resolver can resolve override values and pass them down to SectionComposition.
|
|
56
|
+
*/
|
|
57
|
+
const registerSectionComponents = (sections, componentRegistry) => {
|
|
58
|
+
const sectionConfigs = sections.map((section) => {
|
|
59
|
+
// Section entries store `static_value` in raw shape (`{ text: [...] }`).
|
|
60
|
+
// The data binder expects the pre-processed flat shape (`{ key: value }`),
|
|
61
|
+
// so transform here before handing the section's spec to the renderer.
|
|
62
|
+
// Without this, every string prop on the section (e.g. SectionSlot's
|
|
63
|
+
// `label`) resolves to empty in consumption mode.
|
|
64
|
+
const rawStaticValue = (section?.static_value ?? {});
|
|
65
|
+
const sectionSpec = {
|
|
66
|
+
ui: section.ui,
|
|
67
|
+
data: {
|
|
68
|
+
dataSources: {},
|
|
69
|
+
static_value: preProcessStaticValues(rawStaticValue),
|
|
70
|
+
},
|
|
71
|
+
compositionEntry: section,
|
|
72
|
+
symbols: [],
|
|
73
|
+
sectionCompositions: sections,
|
|
74
|
+
};
|
|
75
|
+
return {
|
|
76
|
+
type: section.uid,
|
|
77
|
+
displayName: section.title,
|
|
78
|
+
thumbnailUrl: section?.ui_preview?.url,
|
|
79
|
+
wrap: false,
|
|
80
|
+
// Exposed props registered here so retrievePropValue resolves their
|
|
81
|
+
// page-level bindings and passes the values to SectionComposition.
|
|
82
|
+
props: buildRegisteredProps(section, componentRegistry),
|
|
83
|
+
component: (props) => {
|
|
84
|
+
return (jsx(SectionComposition, { ...props, compositionUID: section.uid, spec: sectionSpec }));
|
|
85
|
+
},
|
|
86
|
+
metadata: {
|
|
87
|
+
uid: section.uid,
|
|
88
|
+
type: "section-composition",
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
});
|
|
92
|
+
componentRegistry.registerSectionComponent(sectionConfigs);
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* React hook that registers section components when sections array changes.
|
|
96
|
+
* Automatically handles component registration lifecycle in React components.
|
|
97
|
+
*
|
|
98
|
+
* @param sections - Optional array of section composition entries
|
|
99
|
+
*/
|
|
100
|
+
const useRegisterSectionComponents = (sections) => {
|
|
101
|
+
const { componentRegistry } = useRenderer();
|
|
102
|
+
useMemo(() => {
|
|
103
|
+
if (!sections?.length)
|
|
104
|
+
return;
|
|
105
|
+
registerSectionComponents(sections, componentRegistry);
|
|
106
|
+
}, [sections, componentRegistry]);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export { registerSectionComponents, useRegisterSectionComponents };
|
|
110
|
+
//# sourceMappingURL=use-register-section.hook.js.map
|
|
@@ -0,0 +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 symbols: [],\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,OAAO;AACL,YAAA,EAAE,CAAC,GAAG;AACN,YAAA;AACE,gBAAA,IAAI,QAAQ,IAAI,EAAE,CAAC;gBACnB,IAAI,EAAE,EAAE,CAAC,QAAwB;gBACjC,WAAW,EAAE,EAAE,CAAC,WAAW;AACX,aAAA;SACnB;IACH,CAAC,CAAC,CACH;AAED,IAAA,OAAO,KAAK;AACd;AAEA;;;;AAIG;MACU,yBAAyB,GAAG,CACvC,QAAmC,EACnC,iBAA6C,KAC3C;IACF,MAAM,cAAc,GAA4B,QAAQ,CAAC,GAAG,CAAC,CAAC,OAA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CAAC,EAAE,CAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAC;AACnC;;;;"}
|
|
@@ -6,9 +6,14 @@ import '@contentstack/studio-messenger';
|
|
|
6
6
|
import '@contentstack/studio-react-components/contexts';
|
|
7
7
|
import 'immer';
|
|
8
8
|
import { useContext } from 'react';
|
|
9
|
+
import '@contentstack/studio-internal';
|
|
10
|
+
import '@contentstack/studio-core';
|
|
11
|
+
import '@contentstack/studio-react-components/basic-components';
|
|
9
12
|
import '@contentstack/studio-react-components/hooks';
|
|
10
|
-
import '
|
|
13
|
+
import 'goober';
|
|
11
14
|
import '../components/Element.js';
|
|
15
|
+
import '../contexts/providers/section-mode.provider.js';
|
|
16
|
+
import '@contentstack/studio-registry';
|
|
12
17
|
import '../contexts/providers/use-design-preview.provider.js';
|
|
13
18
|
import '../contexts/providers/use-repeater.provider.js';
|
|
14
19
|
import '../contexts/providers/use-condition-block.provider.js';
|
|
@@ -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\";\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;;;;"}
|
|
@@ -6,9 +6,14 @@ import '@contentstack/studio-client';
|
|
|
6
6
|
import '@contentstack/studio-messenger';
|
|
7
7
|
import '@contentstack/studio-react-components/contexts';
|
|
8
8
|
import 'immer';
|
|
9
|
+
import '@contentstack/studio-internal';
|
|
10
|
+
import '@contentstack/studio-core';
|
|
11
|
+
import '@contentstack/studio-react-components/basic-components';
|
|
9
12
|
import '@contentstack/studio-react-components/hooks';
|
|
10
|
-
import '
|
|
13
|
+
import 'goober';
|
|
11
14
|
import '../components/Element.js';
|
|
15
|
+
import '../contexts/providers/section-mode.provider.js';
|
|
16
|
+
import '@contentstack/studio-registry';
|
|
12
17
|
import '../contexts/providers/use-design-preview.provider.js';
|
|
13
18
|
import { RepeaterContext } from '../contexts/providers/use-repeater.provider.js';
|
|
14
19
|
import '../contexts/providers/use-condition-block.provider.js';
|
|
@@ -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\";\n\nexport const useRepeaterContext = () => useContext(RepeaterContext);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAGO,MAAM,kBAAkB,GAAG,MAAM,UAAU,CAAC,eAAe;;;;"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { clientRendererModeUtil, isCompositionBeingEdited } from '@contentstack/studio-client';
|
|
2
|
+
import { composableStudioEventManager, POST_MESSAGE_EVENTS } from '@contentstack/studio-messenger';
|
|
3
|
+
import { useEffect } from 'react';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* React hook that manages section composition events from the Studio.
|
|
7
|
+
* Pulls current sections after mount to avoid losing registrations during initial load,
|
|
8
|
+
* AND re-fetches whenever the spec UI references a section uid that isn't yet
|
|
9
|
+
* known locally (e.g. a section was just dropped in Studio).
|
|
10
|
+
*
|
|
11
|
+
* @param setState - State setter function to update the spec
|
|
12
|
+
* @param state - Current studio spec state
|
|
13
|
+
* @param composableUid - UID of the composition being edited
|
|
14
|
+
*/
|
|
15
|
+
const useSectionEvents = (setState, state, composableUid) => {
|
|
16
|
+
// Register the catalog-update listener AS SOON AS the iframe is inside
|
|
17
|
+
// the Studio frame — independent of spec arrival. Studio's
|
|
18
|
+
// `useSectionCompositions` pushes the full catalog the moment its React
|
|
19
|
+
// Query resolves; that push can arrive before the iframe has received
|
|
20
|
+
// its first GET_COMPOSITION_SPEC response and populated `composableUid`,
|
|
21
|
+
// so gating the listener on the latter caused NO_REQUEST_LISTENER_FOUND
|
|
22
|
+
// on every fresh page load.
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (!clientRendererModeUtil.isInsideStudioFrame())
|
|
25
|
+
return;
|
|
26
|
+
const catalogListener = composableStudioEventManager?.on(POST_MESSAGE_EVENTS.UPDATE_SECTIONS_CATALOG, (event) => {
|
|
27
|
+
if (!event.data?.sectionCompositions)
|
|
28
|
+
return;
|
|
29
|
+
setState((prevState) => ({
|
|
30
|
+
...prevState,
|
|
31
|
+
sectionCompositions: event.data.sectionCompositions,
|
|
32
|
+
}));
|
|
33
|
+
});
|
|
34
|
+
return () => {
|
|
35
|
+
catalogListener?.unregister();
|
|
36
|
+
};
|
|
37
|
+
// Register once on mount; the handler reads via setState's prev so it
|
|
38
|
+
// doesn't need state in deps.
|
|
39
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
40
|
+
}, []);
|
|
41
|
+
// GET_SECTIONS one-shot fetch — runs after the composition is known so
|
|
42
|
+
// the initial section catalog is populated even when Studio's React
|
|
43
|
+
// Query was already resolved before the iframe mounted (no catalog push
|
|
44
|
+
// is fired in that case).
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
if (!isCompositionBeingEdited(composableUid || ""))
|
|
47
|
+
return;
|
|
48
|
+
composableStudioEventManager
|
|
49
|
+
?.send(POST_MESSAGE_EVENTS.GET_SECTIONS, {})
|
|
50
|
+
.then((data) => {
|
|
51
|
+
if (!data || !("sectionCompositions" in data))
|
|
52
|
+
return;
|
|
53
|
+
setState((prevState) => ({
|
|
54
|
+
...prevState,
|
|
55
|
+
sectionCompositions: data.sectionCompositions,
|
|
56
|
+
}));
|
|
57
|
+
})
|
|
58
|
+
.catch(() => { });
|
|
59
|
+
}, [state?.compositionEntry?.uid, composableUid]);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export { useSectionEvents };
|
|
63
|
+
//# sourceMappingURL=use-section-events.hook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-section-events.hook.js","sources":["../../src/hooks/use-section-events.hook.ts"],"sourcesContent":["import {\n SectionCompositionEntry,\n StudioSpec,\n clientRendererModeUtil,\n isCompositionBeingEdited,\n} from \"@contentstack/studio-client\";\nimport {\n composableStudioEventManager,\n POST_MESSAGE_EVENTS,\n} from \"@contentstack/studio-messenger\";\nimport { useEffect } from \"react\";\n\n/**\n * React hook that manages section composition events from the Studio.\n * Pulls current sections after mount to avoid losing registrations during initial load,\n * AND re-fetches whenever the spec UI references a section uid that isn't yet\n * known locally (e.g. a section was just dropped in Studio).\n *\n * @param setState - State setter function to update the spec\n * @param state - Current studio spec state\n * @param composableUid - UID of the composition being edited\n */\nexport const useSectionEvents = (\n setState: React.Dispatch<React.SetStateAction<StudioSpec>>,\n state?: StudioSpec,\n composableUid?: string,\n) => {\n // Register the catalog-update listener AS SOON AS the iframe is inside\n // the Studio frame — independent of spec arrival. Studio's\n // `useSectionCompositions` pushes the full catalog the moment its React\n // Query resolves; that push can arrive before the iframe has received\n // its first GET_COMPOSITION_SPEC response and populated `composableUid`,\n // so gating the listener on the latter caused NO_REQUEST_LISTENER_FOUND\n // on every fresh page load.\n useEffect(() => {\n if (!clientRendererModeUtil.isInsideStudioFrame()) return;\n const catalogListener = composableStudioEventManager?.on<{\n sectionCompositions: SectionCompositionEntry[];\n }>(POST_MESSAGE_EVENTS.UPDATE_SECTIONS_CATALOG, (event) => {\n if (!event.data?.sectionCompositions) return;\n setState((prevState: StudioSpec) => ({\n ...prevState,\n sectionCompositions: event.data.sectionCompositions,\n }));\n });\n return () => {\n catalogListener?.unregister();\n };\n // Register once on mount; the handler reads via setState's prev so it\n // doesn't need state in deps.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n // GET_SECTIONS one-shot fetch — runs after the composition is known so\n // the initial section catalog is populated even when Studio's React\n // Query was already resolved before the iframe mounted (no catalog push\n // is fired in that case).\n useEffect(() => {\n if (!isCompositionBeingEdited(composableUid || \"\")) return;\n composableStudioEventManager\n ?.send<{ sectionCompositions: SectionCompositionEntry[] }>(\n POST_MESSAGE_EVENTS.GET_SECTIONS,\n {},\n )\n .then((data) => {\n if (!data || !(\"sectionCompositions\" in data)) return;\n setState((prevState: StudioSpec) => ({\n ...prevState,\n sectionCompositions: data.sectionCompositions,\n }));\n })\n .catch(() => {});\n }, [state?.compositionEntry?.uid, composableUid]);\n};\n"],"names":[],"mappings":";;;;AAYA;;;;;;;;;AASG;AACI,MAAM,gBAAgB,GAAG,CAC9B,QAA0D,EAC1D,KAAkB,EAClB,aAAsB,KACpB;;;;;;;;IAQF,SAAS,CAAC,MAAK;AACb,QAAA,IAAI,CAAC,sBAAsB,CAAC,mBAAmB,EAAE;YAAE;AACnD,QAAA,MAAM,eAAe,GAAG,4BAA4B,EAAE,EAAE,CAErD,mBAAmB,CAAC,uBAAuB,EAAE,CAAC,KAAK,KAAI;AACxD,YAAA,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,mBAAmB;gBAAE;AACtC,YAAA,QAAQ,CAAC,CAAC,SAAqB,MAAM;AACnC,gBAAA,GAAG,SAAS;AACZ,gBAAA,mBAAmB,EAAE,KAAK,CAAC,IAAI,CAAC,mBAAmB;AACpD,aAAA,CAAC,CAAC;AACL,QAAA,CAAC,CAAC;AACF,QAAA,OAAO,MAAK;YACV,eAAe,EAAE,UAAU,EAAE;AAC/B,QAAA,CAAC;;;;IAIH,CAAC,EAAE,EAAE,CAAC;;;;;IAMN,SAAS,CAAC,MAAK;AACb,QAAA,IAAI,CAAC,wBAAwB,CAAC,aAAa,IAAI,EAAE,CAAC;YAAE;QACpD;AACE,cAAE,IAAI,CACJ,mBAAmB,CAAC,YAAY,EAChC,EAAE;AAEH,aAAA,IAAI,CAAC,CAAC,IAAI,KAAI;YACb,IAAI,CAAC,IAAI,IAAI,EAAE,qBAAqB,IAAI,IAAI,CAAC;gBAAE;AAC/C,YAAA,QAAQ,CAAC,CAAC,SAAqB,MAAM;AACnC,gBAAA,GAAG,SAAS;gBACZ,mBAAmB,EAAE,IAAI,CAAC,mBAAmB;AAC9C,aAAA,CAAC,CAAC;AACL,QAAA,CAAC;AACA,aAAA,KAAK,CAAC,MAAK,EAAE,CAAC,CAAC;IACpB,CAAC,EAAE,CAAC,KAAK,EAAE,gBAAgB,EAAE,GAAG,EAAE,aAAa,CAAC,CAAC;AACnD;;;;"}
|
|
@@ -1,15 +1,59 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { clientRendererModeUtil } from '@contentstack/studio-client';
|
|
2
|
+
import { useContext } from 'react';
|
|
3
|
+
import '../contexts/providers/renderer.provider.js';
|
|
4
|
+
import '../contexts/providers/active-node.provider.js';
|
|
5
|
+
import 'react/jsx-runtime';
|
|
6
|
+
import '@contentstack/studio-messenger';
|
|
7
|
+
import '@contentstack/studio-react-components/contexts';
|
|
8
|
+
import 'immer';
|
|
9
|
+
import '@contentstack/studio-internal';
|
|
10
|
+
import '@contentstack/studio-core';
|
|
11
|
+
import '@contentstack/studio-react-components/basic-components';
|
|
12
|
+
import '@contentstack/studio-react-components/hooks';
|
|
13
|
+
import 'goober';
|
|
14
|
+
import '../components/Element.js';
|
|
15
|
+
import { SectionModeContext } from '../contexts/providers/section-mode.provider.js';
|
|
2
16
|
import { useDesignPreviewContext } from './use-design-preview.hook.js';
|
|
3
17
|
import { useRenderer } from './use-renderer.hook.js';
|
|
18
|
+
import '@contentstack/studio-registry';
|
|
4
19
|
import { useRepeaterContext } from './use-repeater.hook.js';
|
|
20
|
+
import { useConditionBlockContext } from './use-condition-block-context.js';
|
|
21
|
+
import '../contexts/providers/use-design-preview.provider.js';
|
|
22
|
+
import '../contexts/providers/use-repeater.provider.js';
|
|
23
|
+
import '../contexts/providers/use-condition-block.provider.js';
|
|
24
|
+
import '../contexts/providers/preview-mode.provider.js';
|
|
5
25
|
|
|
6
26
|
function useShouldShowDesign(mode) {
|
|
7
27
|
const { isCompositionBeingEdited } = useRenderer();
|
|
8
28
|
const { isInsideRepeater } = useRepeaterContext();
|
|
9
29
|
const { isInsideConditionBlock } = useConditionBlockContext();
|
|
10
30
|
const designPreviewContext = useDesignPreviewContext();
|
|
11
|
-
|
|
31
|
+
const sectionMode = useContext(SectionModeContext);
|
|
32
|
+
// Treat the Studio editor frame as design-mode-eligible from the very first
|
|
33
|
+
// render — even before `isCompositionBeingEdited` has resolved — to avoid a
|
|
34
|
+
// one-frame preview render that would inject items[0] context. Use
|
|
35
|
+
// `isInsideStudioFrame()` (URL-param-gated) so Visual Builder's iframe
|
|
36
|
+
// (which should render preview) is correctly excluded.
|
|
37
|
+
const isInsideStudio = clientRendererModeUtil.isInsideStudioFrame();
|
|
38
|
+
if (!isCompositionBeingEdited && !isInsideStudio)
|
|
39
|
+
return false;
|
|
40
|
+
// A placed section forces the mode of everything inside it — a single
|
|
41
|
+
// per-placement switch that overrides each inner node's own `mode`. Only set
|
|
42
|
+
// inside a section placement in the editor; null everywhere else.
|
|
43
|
+
// - PREVIEW always wins → render preview.
|
|
44
|
+
// - DESIGN keeps the section's own drop-zones visible, BUT when the section
|
|
45
|
+
// is itself nested inside an enclosing PREVIEW repeater its internal data
|
|
46
|
+
// repeaters must still iterate — otherwise a data-bound slot child can
|
|
47
|
+
// never resolve its per-iteration context (SP7.1: a slot-bearing section
|
|
48
|
+
// defaults to design via COMS-1595, which froze its inner repeaters). So
|
|
49
|
+
// defer to the enclosing preview context in that case. At the page root
|
|
50
|
+
// designPreviewContext is "none", so design is preserved (the slot's own
|
|
51
|
+
// drop-zone-vs-collapsed rendering reads SectionModeContext directly and
|
|
52
|
+
// is unaffected either way).
|
|
53
|
+
if (sectionMode === "preview")
|
|
12
54
|
return false;
|
|
55
|
+
if (sectionMode === "design")
|
|
56
|
+
return designPreviewContext !== "preview";
|
|
13
57
|
if (isInsideRepeater || isInsideConditionBlock) {
|
|
14
58
|
// If composition is being edited and current node(Repeater or Condition Block) inside another repeater or condition block,
|
|
15
59
|
// and no designPreviewContext is provided, then show design
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-should-show-design.hook.js","sources":["../../src/hooks/use-should-show-design.hook.ts"],"sourcesContent":["import { 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 if (!isCompositionBeingEdited) return false;\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\";\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;;;;"}
|