@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.
Files changed (62) hide show
  1. package/dist/components/AddIcon.js +18 -0
  2. package/dist/components/AddIcon.js.map +1 -0
  3. package/dist/components/BuildingIllustration.js +1 -1
  4. package/dist/components/BuildingIllustration.js.map +1 -1
  5. package/dist/components/EditableRenderer.js +10 -22
  6. package/dist/components/EditableRenderer.js.map +1 -1
  7. package/dist/components/Element.js +81 -38
  8. package/dist/components/Element.js.map +1 -1
  9. package/dist/components/PreviewRenderer.js +0 -19
  10. package/dist/components/PreviewRenderer.js.map +1 -1
  11. package/dist/components/Slot.js +5 -4
  12. package/dist/components/Slot.js.map +1 -1
  13. package/dist/components/WelcomeState.js +44 -27
  14. package/dist/components/WelcomeState.js.map +1 -1
  15. package/dist/components/elements/ConditionBlock.js +9 -35
  16. package/dist/components/elements/ConditionBlock.js.map +1 -1
  17. package/dist/components/elements/Repeater.js +1 -15
  18. package/dist/components/elements/Repeater.js.map +1 -1
  19. package/dist/components/elements/SectionSlot.js +68 -5
  20. package/dist/components/elements/SectionSlot.js.map +1 -1
  21. package/dist/components/styles.js +133 -8
  22. package/dist/components/styles.js.map +1 -1
  23. package/dist/contexts/providers/selected-node.provider.js +7 -1
  24. package/dist/contexts/providers/selected-node.provider.js.map +1 -1
  25. package/dist/hooks/use-active-node-path.hook.js +0 -19
  26. package/dist/hooks/use-active-node-path.hook.js.map +1 -1
  27. package/dist/hooks/use-condition-block-context.js +0 -20
  28. package/dist/hooks/use-condition-block-context.js.map +1 -1
  29. package/dist/hooks/use-design-preview.hook.js +0 -20
  30. package/dist/hooks/use-design-preview.hook.js.map +1 -1
  31. package/dist/hooks/use-preview-mode.hook.js +0 -20
  32. package/dist/hooks/use-preview-mode.hook.js.map +1 -1
  33. package/dist/hooks/use-register-section.hook.js +0 -1
  34. package/dist/hooks/use-register-section.hook.js.map +1 -1
  35. package/dist/hooks/use-renderer.hook.js +0 -20
  36. package/dist/hooks/use-renderer.hook.js.map +1 -1
  37. package/dist/hooks/use-repeater.hook.js +0 -20
  38. package/dist/hooks/use-repeater.hook.js.map +1 -1
  39. package/dist/hooks/use-should-show-design.hook.js +1 -20
  40. package/dist/hooks/use-should-show-design.hook.js.map +1 -1
  41. package/dist/hooks/use-slot-copy-color.hook.js +54 -0
  42. package/dist/hooks/use-slot-copy-color.hook.js.map +1 -0
  43. package/dist/hooks/use-spec-data-listener.hook.js +168 -24
  44. package/dist/hooks/use-spec-data-listener.hook.js.map +1 -1
  45. package/dist/utils/backdrop-watcher.util.js +79 -0
  46. package/dist/utils/backdrop-watcher.util.js.map +1 -0
  47. package/dist/utils/copy-color.util.js +300 -0
  48. package/dist/utils/copy-color.util.js.map +1 -0
  49. package/dist/utils/renderer.util.js +92 -1
  50. package/dist/utils/renderer.util.js.map +1 -1
  51. package/package.json +12 -14
  52. package/LICENSE +0 -21
  53. package/dist/components/elements/Symbol.js +0 -65
  54. package/dist/components/elements/Symbol.js.map +0 -1
  55. package/dist/contexts/providers/symbol-ui.provider.js +0 -88
  56. package/dist/contexts/providers/symbol-ui.provider.js.map +0 -1
  57. package/dist/hooks/use-register-symbol.hook.js +0 -54
  58. package/dist/hooks/use-register-symbol.hook.js.map +0 -1
  59. package/dist/hooks/use-symbol-events.hook.js +0 -45
  60. package/dist/hooks/use-symbol-events.hook.js.map +0 -1
  61. package/dist/hooks/use-symbol-ui-listener.hook.js +0 -17
  62. package/dist/hooks/use-symbol-ui-listener.hook.js.map +0 -1
@@ -1,27 +1,11 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
- import { evaluateCondition } from '@contentstack/studio-client';
3
- import { getBindingString, getRepeaterContextPath } from '@contentstack/studio-registry';
4
- import { produce } from 'immer';
5
- import { get, set } from 'lodash-es';
2
+ import { resolveConditionScope } from '@contentstack/studio-client';
6
3
  import React from 'react';
7
4
  import { DataCtxProvider } from '@contentstack/studio-react-components/contexts';
8
5
  import { useData } from '@contentstack/studio-react-components/hooks';
9
- import '../../contexts/providers/renderer.provider.js';
10
- import '../../contexts/providers/edit-context.provider.js';
11
- import '../../contexts/providers/active-node.provider.js';
12
- import '@contentstack/studio-messenger';
13
- import '../../hooks/use-edit-context-listener.hook.js';
14
- import '@contentstack/studio-internal';
15
- import '@contentstack/studio-core';
16
- import '@contentstack/studio-react-components/basic-components';
17
- import 'goober';
18
- import '../Element.js';
19
- import '../../contexts/providers/section-mode.provider.js';
20
- import { useShouldShowDesign } from '../../hooks/use-should-show-design.hook.js';
21
- import { DesignPreviewContext } from '../../contexts/providers/use-design-preview.provider.js';
22
- import '../../contexts/providers/use-repeater.provider.js';
23
6
  import { ConditionBlockContext } from '../../contexts/providers/use-condition-block.provider.js';
24
- import '../../contexts/providers/preview-mode.provider.js';
7
+ import { DesignPreviewContext } from '../../contexts/providers/use-design-preview.provider.js';
8
+ import { useShouldShowDesign } from '../../hooks/use-should-show-design.hook.js';
25
9
 
26
10
  function ConditionBlock({ condition, children, mode, studioAttributes, }) {
27
11
  const showDesign = useShouldShowDesign(mode);
@@ -34,20 +18,11 @@ function ConditionPreview({ condition, children, studioAttributes, }) {
34
18
  const data = useData();
35
19
  if (!condition)
36
20
  return null;
37
- let conditionAppliedData = data;
38
- const { dataBinding: binding } = condition;
39
- let shouldRender = evaluateCondition(condition, conditionAppliedData);
40
- const dataPath = binding && getBindingString(binding);
41
- const repeaterPath = binding &&
42
- getRepeaterContextPath(binding.value);
43
- if (dataPath) {
44
- const conditionalData = get(data, dataPath);
45
- if (conditionalData && repeaterPath) {
46
- conditionAppliedData = produce(data, (draft) => {
47
- set(draft, repeaterPath, conditionalData);
48
- });
49
- }
50
- }
21
+ const { shouldRender, scopedData } = resolveConditionScope(condition, data);
22
+ // Bail before building children — projecting data and cloning every child
23
+ // only to discard them is pure waste on a condition that is false.
24
+ if (!shouldRender)
25
+ return null;
51
26
  const { "data-cslp": dataCslp, ...rest } = studioAttributes || {};
52
27
  const conditionCSLP = {
53
28
  dataCslp: dataCslp,
@@ -61,8 +36,7 @@ function ConditionPreview({ condition, children, studioAttributes, }) {
61
36
  });
62
37
  }
63
38
  });
64
- // Only render children if condition is met
65
- return shouldRender ? (jsx(ConditionBlockContext.Provider, { value: { isInsideConditionBlock: true }, children: jsx(DesignPreviewContext.Provider, { value: "preview", children: jsx(DataCtxProvider, { value: conditionAppliedData, children: jsx("div", { ...rest, style: { display: "contents" }, children: childrenWithCSLP }) }) }) })) : null;
39
+ return (jsx(ConditionBlockContext.Provider, { value: { isInsideConditionBlock: true }, children: jsx(DesignPreviewContext.Provider, { value: "preview", children: jsx(DataCtxProvider, { value: scopedData, children: jsx("div", { ...rest, style: { display: "contents" }, children: childrenWithCSLP }) }) }) }));
66
40
  }
67
41
 
68
42
  export { ConditionBlock };
@@ -1 +1 @@
1
- {"version":3,"file":"ConditionBlock.js","sources":["../../../src/components/elements/ConditionBlock.tsx"],"sourcesContent":["import { evaluateCondition } from \"@contentstack/studio-client\";\nimport { Condition } from \"@contentstack/studio-internal\";\nimport {\n getBindingString,\n getRepeaterContextPath,\n RepeaterBindingValue,\n} from \"@contentstack/studio-registry\";\nimport { produce } from \"immer\";\nimport { get, set } from \"lodash-es\";\nimport React from \"react\";\nimport { DataCtxProvider } from \"@contentstack/studio-react-components/contexts\";\nimport { useData } from \"@contentstack/studio-react-components/hooks\";\nimport {\n ConditionBlockContext,\n DesignPreviewContext,\n} from \"../../contexts/providers\";\nimport { useShouldShowDesign } from \"../../hooks\";\n\ninterface ConditionBlockProps {\n condition: Condition;\n children: React.ReactNode;\n mode: \"design\" | \"preview\";\n studioAttributes: any;\n}\n\nexport function ConditionBlock({\n condition,\n children,\n mode,\n studioAttributes,\n}: ConditionBlockProps) {\n const showDesign = useShouldShowDesign(mode);\n\n if (showDesign) {\n return (\n <ConditionBlockContext.Provider value={{ isInsideConditionBlock: true }}>\n <DesignPreviewContext.Provider value=\"design\">\n <div {...studioAttributes} style={{ display: \"contents\" }}>\n {children}\n </div>\n </DesignPreviewContext.Provider>\n </ConditionBlockContext.Provider>\n );\n }\n return (\n <ConditionPreview condition={condition} studioAttributes={studioAttributes}>\n {children}\n </ConditionPreview>\n );\n}\n\nfunction ConditionPreview({\n condition,\n children,\n studioAttributes,\n}: Omit<ConditionBlockProps, \"mode\">) {\n const data = useData();\n if (!condition) return null;\n let conditionAppliedData = data;\n const { dataBinding: binding } = condition;\n let shouldRender = evaluateCondition(condition, conditionAppliedData);\n const dataPath = binding && getBindingString(binding);\n const repeaterPath =\n binding &&\n getRepeaterContextPath(binding.value as unknown as RepeaterBindingValue);\n\n if (dataPath) {\n const conditionalData = get(data, dataPath);\n if (conditionalData && repeaterPath) {\n conditionAppliedData = produce(data, (draft) => {\n set(draft, repeaterPath, conditionalData);\n });\n }\n }\n const { \"data-cslp\": dataCslp, ...rest } = studioAttributes || {};\n\n const conditionCSLP = {\n dataCslp: dataCslp,\n };\n const childrenWithCSLP = React.Children.map(children, (child, index) => {\n const newProps = index === 0 ? conditionCSLP : {};\n if (React.isValidElement(child)) {\n return React.cloneElement(child, {\n key: index,\n ...newProps,\n });\n }\n });\n // Only render children if condition is met\n return shouldRender ? (\n <ConditionBlockContext.Provider value={{ isInsideConditionBlock: true }}>\n <DesignPreviewContext.Provider value=\"preview\">\n <DataCtxProvider value={conditionAppliedData}>\n <div {...rest} style={{ display: \"contents\" }}>\n {childrenWithCSLP}\n </div>\n </DataCtxProvider>\n </DesignPreviewContext.Provider>\n </ConditionBlockContext.Provider>\n ) : null;\n}\n"],"names":["_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAyBM,SAAU,cAAc,CAAC,EAC7B,SAAS,EACT,QAAQ,EACR,IAAI,EACJ,gBAAgB,GACI,EAAA;AACpB,IAAA,MAAM,UAAU,GAAG,mBAAmB,CAAC,IAAI,CAAC;IAE5C,IAAI,UAAU,EAAE;AACd,QAAA,QACEA,GAAA,CAAC,qBAAqB,CAAC,QAAQ,IAAC,KA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QAAQ,EAAE,GAAG,IAAI,EAAE,GAAG,gBAAgB,IAAI,EAAE;AAEjE,IAAA,MAAM,aAAa,GAAG;AACpB,QAAA,QAAQ,EAAE,QAAQ;KACnB;AACD,IAAA,MAAM,gBAAgB,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAI;AACrE,QAAA,MAAM,QAAQ,GAAG,KAAK,KAAK,CAAC,GAAG,aAAa,GAAG,EAAE;AACjD,QAAA,IAAI,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE;AAC/B,YAAA,OAAO,KAAK,CAAC,YAAY,CAAC,KAAK,EAAE;AAC/B,gBAAA,GAAG,EAAE,KAAK;AACV,gBAAA,GAAG,QAAQ;AACZ,aAAA,CAAC;QACJ;AACF,IAAA,CAAC,CAAC;;IAEF,OAAO,YAAY,IACjBA,IAAC,qBAAqB,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,EAAE,sBAAsB,EAAE,IAAI,EAAE,EAAA,QAAA,EACrEA,GAAA,CAAC,oBAAoB,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAC,SAAS,EAAA,QAAA,EAC5CA,IAAC,eAAe,EAAA,EAAC,KAAK,EAAE,oBAAoB,EAAA,QAAA,EAC1CA,GAAA,CAAA,KAAA,EAAA,EAAA,GAAS,IAAI,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,EAAA,QAAA,EAC1C,gBAAgB,EAAA,CACb,EAAA,CACU,EAAA,CACY,EAAA,CACD,IAC/B,IAAI;AACV;;;;"}
1
+ {"version":3,"file":"ConditionBlock.js","sources":["../../../src/components/elements/ConditionBlock.tsx"],"sourcesContent":["import { resolveConditionScope } from \"@contentstack/studio-client\";\nimport { Condition } from \"@contentstack/studio-internal\";\nimport React from \"react\";\nimport { DataCtxProvider } from \"@contentstack/studio-react-components/contexts\";\nimport { useData } from \"@contentstack/studio-react-components/hooks\";\nimport { ConditionBlockContext } from \"../../contexts/providers/use-condition-block.provider\";\nimport { DesignPreviewContext } from \"../../contexts/providers/use-design-preview.provider\";\nimport { useShouldShowDesign } from \"../../hooks/use-should-show-design.hook\";\n\ninterface ConditionBlockProps {\n condition: Condition;\n children: React.ReactNode;\n mode: \"design\" | \"preview\";\n studioAttributes: any;\n}\n\nexport function ConditionBlock({\n condition,\n children,\n mode,\n studioAttributes,\n}: ConditionBlockProps) {\n const showDesign = useShouldShowDesign(mode);\n\n if (showDesign) {\n return (\n <ConditionBlockContext.Provider value={{ isInsideConditionBlock: true }}>\n <DesignPreviewContext.Provider value=\"design\">\n <div {...studioAttributes} style={{ display: \"contents\" }}>\n {children}\n </div>\n </DesignPreviewContext.Provider>\n </ConditionBlockContext.Provider>\n );\n }\n return (\n <ConditionPreview condition={condition} studioAttributes={studioAttributes}>\n {children}\n </ConditionPreview>\n );\n}\n\nfunction ConditionPreview({\n condition,\n children,\n studioAttributes,\n}: Omit<ConditionBlockProps, \"mode\">) {\n const data = useData();\n if (!condition) return null;\n const { shouldRender, scopedData } = resolveConditionScope(condition, data);\n // Bail before building children — projecting data and cloning every child\n // only to discard them is pure waste on a condition that is false.\n if (!shouldRender) return null;\n const { \"data-cslp\": dataCslp, ...rest } = studioAttributes || {};\n\n const conditionCSLP = {\n dataCslp: dataCslp,\n };\n const childrenWithCSLP = React.Children.map(children, (child, index) => {\n const newProps = index === 0 ? conditionCSLP : {};\n if (React.isValidElement(child)) {\n return React.cloneElement(child, {\n key: index,\n ...newProps,\n });\n }\n });\n return (\n <ConditionBlockContext.Provider value={{ isInsideConditionBlock: true }}>\n <DesignPreviewContext.Provider value=\"preview\">\n <DataCtxProvider value={scopedData}>\n <div {...rest} style={{ display: \"contents\" }}>\n {childrenWithCSLP}\n </div>\n </DataCtxProvider>\n </DesignPreviewContext.Provider>\n </ConditionBlockContext.Provider>\n );\n}\n"],"names":["_jsx"],"mappings":";;;;;;;;;AAgBM,SAAU,cAAc,CAAC,EAC7B,SAA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AAM,QAAQ,GAAG,KAAK,KAAK,CAAC,GAAG,aAAa,GAAG,EAAE;AACjD,QAAA,IAAI,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE;AAC/B,YAAA,OAAO,KAAK,CAAC,YAAY,CAAC,KAAK,EAAE;AAC/B,gBAAA,GAAG,EAAE,KAAK;AACV,gBAAA,GAAG,QAAQ;AACZ,aAAA,CAAC;QACJ;AACF,IAAA,CAAC,CAAC;IACF,QACEA,IAAC,qBAAqB,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,EAAE,sBAAsB,EAAE,IAAI,EAAE,YACrEA,GAAA,CAAC,oBAAoB,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAC,SAAS,EAAA,QAAA,EAC5CA,IAAC,eAAe,EAAA,EAAC,KAAK,EAAE,UAAU,YAChCA,GAAA,CAAA,KAAA,EAAA,EAAA,GAAS,IAAI,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,EAAA,QAAA,EAC1C,gBAAgB,GACb,EAAA,CACU,EAAA,CACY,EAAA,CACD;AAErC;;;;"}
@@ -4,23 +4,9 @@ import { getFlattenedData } from '@contentstack/studio-registry';
4
4
  import { DataCtxProvider } from '@contentstack/studio-react-components/contexts';
5
5
  import { useData } from '@contentstack/studio-react-components/hooks';
6
6
  import { Children, isValidElement, cloneElement } from 'react';
7
- import '../../contexts/providers/renderer.provider.js';
8
- import '../../contexts/providers/edit-context.provider.js';
9
- import '../../contexts/providers/active-node.provider.js';
10
- import '@contentstack/studio-messenger';
11
- import 'immer';
12
- import '../../hooks/use-edit-context-listener.hook.js';
13
- import '@contentstack/studio-internal';
14
- import '@contentstack/studio-core';
15
- import '@contentstack/studio-react-components/basic-components';
16
- import 'goober';
17
- import '../Element.js';
18
- import '../../contexts/providers/section-mode.provider.js';
19
- import { useShouldShowDesign } from '../../hooks/use-should-show-design.hook.js';
20
7
  import { DesignPreviewContext } from '../../contexts/providers/use-design-preview.provider.js';
21
8
  import { RepeaterContext } from '../../contexts/providers/use-repeater.provider.js';
22
- import '../../contexts/providers/use-condition-block.provider.js';
23
- import '../../contexts/providers/preview-mode.provider.js';
9
+ import { useShouldShowDesign } from '../../hooks/use-should-show-design.hook.js';
24
10
 
25
11
  function RepeaterPreview({ children, studioAttributes, items = [], _uid, $items, }) {
26
12
  const data = useData();
@@ -1 +1 @@
1
- {"version":3,"file":"Repeater.js","sources":["../../../src/components/elements/Repeater.tsx"],"sourcesContent":["import { COMPOSABLE_DATA_ATTRIBUTES } from \"@contentstack/studio-client\";\nimport { getFlattenedData } from \"@contentstack/studio-registry\";\nimport { DataCtxProvider } from \"@contentstack/studio-react-components/contexts\";\nimport { useData } from \"@contentstack/studio-react-components/hooks\";\nimport React, { Children, cloneElement, isValidElement } from \"react\";\nimport {\n DesignPreviewContext,\n RepeaterContext,\n} from \"../../contexts/providers\";\nimport { useShouldShowDesign } from \"../../hooks\";\n\ntype CSLP = { \"data-cslp\": string };\ninterface RepeaterProps {\n children: React.ReactNode;\n studioAttributes?: any;\n items?: any[];\n data?: any;\n _uid: string;\n mode: \"design\" | \"preview\";\n $items?: CSLP;\n}\n\nfunction RepeaterPreview({\n children,\n studioAttributes,\n items = [],\n _uid,\n $items,\n}: Omit<RepeaterProps, \"mode\">) {\n const data = useData();\n // Get uid from builder attributes or generate a fallback\n const uid =\n _uid || studioAttributes?.[COMPOSABLE_DATA_ATTRIBUTES.ID] || \"default\";\n return (\n <RepeaterContext.Provider value={{ isInsideRepeater: true }}>\n <DesignPreviewContext.Provider value=\"preview\">\n {items.map((item, index) => {\n // Single-level unwrap (see studio-react-components/Repeater.tsx).\n let mergedContext = getFlattenedData(item);\n if (item && typeof item === \"object\" && !Array.isArray(item)) {\n const keys = Object.keys(item).filter(\n (k) => k !== \"$\" && k !== \"_metadata\",\n );\n if (keys.length === 1) {\n const inner = item[keys[0]];\n if (inner && typeof inner === \"object\" && !Array.isArray(inner)) {\n mergedContext = { ...inner, ...item };\n } else {\n mergedContext = item;\n }\n }\n }\n\n const existingRepData = data?.dataSources?.repeater;\n const itemContext = {\n ...data,\n dataSources: {\n ...data?.dataSources,\n repeater: {\n [uid]: {\n context: mergedContext,\n index,\n },\n ...existingRepData,\n },\n },\n };\n const instanceCSLP: any = {};\n if ($items) {\n instanceCSLP.dataCslp = `${$items[\"data-cslp\"]}.${index}`;\n }\n\n // Clone children with the new context\n const childrenWithCSLP = Children.map(children, (child) => {\n if (isValidElement(child)) {\n return cloneElement(child, {\n ...instanceCSLP,\n });\n }\n });\n return (\n //TODO: Handle key with slot uid and support cslp tags\n <DataCtxProvider value={itemContext} key={`${uid}-${index}`}>\n <div {...studioAttributes} style={{ display: \"contents\" }}>\n {childrenWithCSLP}\n </div>\n </DataCtxProvider>\n );\n })}\n </DesignPreviewContext.Provider>\n </RepeaterContext.Provider>\n );\n}\n\n// Optimize repeater\nexport function Repeater({\n children,\n studioAttributes,\n items = [],\n _uid,\n mode,\n $items,\n}: RepeaterProps) {\n const showDesign = useShouldShowDesign(mode);\n\n if (!Array.isArray(items)) {\n return null;\n }\n\n // In canvas\n if (showDesign) {\n return (\n <RepeaterContext.Provider value={{ isInsideRepeater: true }}>\n <DesignPreviewContext.Provider value=\"design\">\n <div {...studioAttributes} style={{ display: \"contents\" }}>\n {children}\n </div>\n </DesignPreviewContext.Provider>\n </RepeaterContext.Provider>\n );\n }\n // Production renderer or mode === \"preview\"\n return (\n <RepeaterPreview\n items={items}\n children={children}\n studioAttributes={studioAttributes}\n _uid={_uid}\n $items={$items}\n />\n );\n}\n"],"names":["_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAS,eAAe,CAAC,EACvB,QAAQ,EACR,gBAAgB,EAChB,KAAK,GAAG,EAAE,EACV,IAAI,EACJ,MAAM,GACsB,EAAA;AAC5B,IAAA,MAAM,IAAI,GAAG,OAAO,EAAE;;AAEtB,IAAA,MAAM,GAAG,GACP,IAAI,IAAI,gBAAgB,GAAG,0BAA0B,CAAC,EAA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A,EAAC,KAAK,EAAC,QAAQ,EAAA,QAAA,EAC3CA,GAAA,CAAA,KAAA,EAAA,EAAA,GAAS,gBAAgB,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,EAAA,QAAA,EACtD,QAAQ,GACL,EAAA,CACwB,EAAA,CACP;IAE/B;;IAEA,QACEA,IAAC,eAAe,EAAA,EACd,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,gBAAgB,EAAE,gBAAgB,EAClC,IAAI,EAAE,IAAI,EAAA,QAAA,EACF,MAAM,EAAA,CACd;AAEN;;;;"}
1
+ {"version":3,"file":"Repeater.js","sources":["../../../src/components/elements/Repeater.tsx"],"sourcesContent":["import { COMPOSABLE_DATA_ATTRIBUTES } from \"@contentstack/studio-client\";\nimport { getFlattenedData } from \"@contentstack/studio-registry\";\nimport { DataCtxProvider } from \"@contentstack/studio-react-components/contexts\";\nimport { useData } from \"@contentstack/studio-react-components/hooks\";\nimport React, { Children, cloneElement, isValidElement } from \"react\";\nimport { DesignPreviewContext } from \"../../contexts/providers/use-design-preview.provider\";\nimport { RepeaterContext } from \"../../contexts/providers/use-repeater.provider\";\nimport { useShouldShowDesign } from \"../../hooks/use-should-show-design.hook\";\n\ntype CSLP = { \"data-cslp\": string };\ninterface RepeaterProps {\n children: React.ReactNode;\n studioAttributes?: any;\n items?: any[];\n data?: any;\n _uid: string;\n mode: \"design\" | \"preview\";\n $items?: CSLP;\n}\n\nfunction RepeaterPreview({\n children,\n studioAttributes,\n items = [],\n _uid,\n $items,\n}: Omit<RepeaterProps, \"mode\">) {\n const data = useData();\n // Get uid from builder attributes or generate a fallback\n const uid =\n _uid || studioAttributes?.[COMPOSABLE_DATA_ATTRIBUTES.ID] || \"default\";\n return (\n <RepeaterContext.Provider value={{ isInsideRepeater: true }}>\n <DesignPreviewContext.Provider value=\"preview\">\n {items.map((item, index) => {\n // Single-level unwrap (see studio-react-components/Repeater.tsx).\n let mergedContext = getFlattenedData(item);\n if (item && typeof item === \"object\" && !Array.isArray(item)) {\n const keys = Object.keys(item).filter(\n (k) => k !== \"$\" && k !== \"_metadata\",\n );\n if (keys.length === 1) {\n const inner = item[keys[0]];\n if (inner && typeof inner === \"object\" && !Array.isArray(inner)) {\n mergedContext = { ...inner, ...item };\n } else {\n mergedContext = item;\n }\n }\n }\n\n const existingRepData = data?.dataSources?.repeater;\n const itemContext = {\n ...data,\n dataSources: {\n ...data?.dataSources,\n repeater: {\n [uid]: {\n context: mergedContext,\n index,\n },\n ...existingRepData,\n },\n },\n };\n const instanceCSLP: any = {};\n if ($items) {\n instanceCSLP.dataCslp = `${$items[\"data-cslp\"]}.${index}`;\n }\n\n // Clone children with the new context\n const childrenWithCSLP = Children.map(children, (child) => {\n if (isValidElement(child)) {\n return cloneElement(child, {\n ...instanceCSLP,\n });\n }\n });\n return (\n //TODO: Handle key with slot uid and support cslp tags\n <DataCtxProvider value={itemContext} key={`${uid}-${index}`}>\n <div {...studioAttributes} style={{ display: \"contents\" }}>\n {childrenWithCSLP}\n </div>\n </DataCtxProvider>\n );\n })}\n </DesignPreviewContext.Provider>\n </RepeaterContext.Provider>\n );\n}\n\n// Optimize repeater\nexport function Repeater({\n children,\n studioAttributes,\n items = [],\n _uid,\n mode,\n $items,\n}: RepeaterProps) {\n const showDesign = useShouldShowDesign(mode);\n\n if (!Array.isArray(items)) {\n return null;\n }\n\n // In canvas\n if (showDesign) {\n return (\n <RepeaterContext.Provider value={{ isInsideRepeater: true }}>\n <DesignPreviewContext.Provider value=\"design\">\n <div {...studioAttributes} style={{ display: \"contents\" }}>\n {children}\n </div>\n </DesignPreviewContext.Provider>\n </RepeaterContext.Provider>\n );\n }\n // Production renderer or mode === \"preview\"\n return (\n <RepeaterPreview\n items={items}\n children={children}\n studioAttributes={studioAttributes}\n _uid={_uid}\n $items={$items}\n />\n );\n}\n"],"names":["_jsx"],"mappings":";;;;;;;;;;AAoBA,SAAS,eAAe,CAAC,EACvB,QAAQ,EACR,gB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AAO,IAAI;IACb;;IAGA,IAAI,UAAU,EAAE;AACd,QAAA,QACEA,GAAA,CAAC,eAAe,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,gBAAgB,EAAE,IAAI,EAAE,YACzDA,GAAA,CAAC,oBAAoB,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAC,QAAQ,EAAA,QAAA,EAC3CA,GAAA,CAAA,KAAA,EAAA,EAAA,GAAS,gBAAgB,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,EAAA,QAAA,EACtD,QAAQ,GACL,EAAA,CACwB,EAAA,CACP;IAE/B;;IAEA,QACEA,IAAC,eAAe,EAAA,EACd,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,gBAAgB,EAAE,gBAAgB,EAClC,IAAI,EAAE,IAAI,EAAA,QAAA,EACF,MAAM,EAAA,CACd;AAEN;;;;"}
@@ -1,7 +1,9 @@
1
- import { jsx, jsxs } from 'react/jsx-runtime';
1
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
2
  import { ELEMENT_TO_NODE, COMPOSABLE_DATA_ATTRIBUTES, NODE_TO_PARENT, NODE_TO_PATH_NODE } from '@contentstack/studio-client';
3
3
  import { SectionInstanceSlotsCtx, DataCtxProvider, CurrentNodeContext } from '@contentstack/studio-react-components/contexts';
4
4
  import { useCurrentNode, useData } from '@contentstack/studio-react-components/hooks';
5
+ import { composableStudioEventManager, POST_MESSAGE_EVENTS } from '@contentstack/studio-messenger';
6
+ import { Button } from '@contentstack/studio-core';
5
7
  import { css } from 'goober';
6
8
  import classNames from 'classnames';
7
9
  import { useContext, useCallback, useMemo } from 'react';
@@ -9,7 +11,10 @@ import { styleFactory } from '../styles.js';
9
11
  import { SelectedNodeProvider } from '../../contexts/providers/selected-node.provider.js';
10
12
  import { PreviewModeContext } from '../../contexts/providers/preview-mode.provider.js';
11
13
  import { SectionModeContext } from '../../contexts/providers/section-mode.provider.js';
14
+ import { useRenderer } from '../../hooks/use-renderer.hook.js';
15
+ import { useSlotCopyColor } from '../../hooks/use-slot-copy-color.hook.js';
12
16
  import MemoizedElement from '../Element.js';
17
+ import { AddIcon } from '../AddIcon.js';
13
18
 
14
19
  /**
15
20
  * In-memory `section-composition` node for a slot's authored default. Rendered
@@ -56,7 +61,18 @@ function makeDefaultSectionNode(instanceUid, slotUid, defaultUid) {
56
61
  function SectionSlot({ studioAttributes, label, _uid, defaultSection, }) {
57
62
  // ALL hooks unconditionally at the top — React doesn't allow conditional
58
63
  // hook calls and the component returns early for authoring/empty modes.
64
+ // One measurement per line of empty-slot chrome: each reads the page colour
65
+ // behind itself and picks the palette entry that separates from it best.
66
+ const authoringCopyColor = useSlotCopyColor();
67
+ const dropCopyColor = useSlotCopyColor();
68
+ const defaultHintCopyColor = useSlotCopyColor();
69
+ const orDividerCopyColor = useSlotCopyColor();
70
+ const allowedLabelCopyColor = useSlotCopyColor();
59
71
  const sectionCtx = useContext(SectionInstanceSlotsCtx);
72
+ // Registry resolves the authored Default section's human title for the
73
+ // design-mode hint (COMS-1770). Sections register with `type = section.uid`
74
+ // and `displayName = section.title`, so a uid lookup yields the title.
75
+ const { componentRegistry } = useRenderer();
60
76
  // When the enclosing placed section is in preview mode, the slot renders like
61
77
  // production: an empty slot collapses to nothing and a filled slot drops its
62
78
  // drop-chrome / selection affordances.
@@ -141,10 +157,46 @@ function SectionSlot({ studioAttributes, label, _uid, defaultSection, }) {
141
157
  const slotUid = _uid ||
142
158
  studioAttributes?.[COMPOSABLE_DATA_ATTRIBUTES.ID] ||
143
159
  "section-slot";
160
+ // Design-mode hint (COMS-1770): resolve the Default section's title for the
161
+ // message. `getComponent` throws for a uid outside the locally-known catalog,
162
+ // so fall back to a nameless hint instead of crashing the slot.
163
+ let defaultSectionTitle;
164
+ if (defaultSection) {
165
+ try {
166
+ defaultSectionTitle =
167
+ componentRegistry.getComponent(defaultSection)?.displayName;
168
+ }
169
+ catch {
170
+ defaultSectionTitle = undefined;
171
+ }
172
+ }
173
+ // COMS-1809: open the section-slot picker. The button lives here in the
174
+ // iframe, but the picker is a parent-app overlay (reusing the Component tab
175
+ // card + hover preview + section catalog — ADR 0010), so we only post the
176
+ // slot identity plus the button's viewport rect. Studio offsets the rect by
177
+ // the iframe's own position to anchor the popover. Plain function (used only
178
+ // in the consumption design-empty branch below), not a hook.
179
+ const handleSelectSection = (event) => {
180
+ event.preventDefault();
181
+ event.stopPropagation();
182
+ const r = event.currentTarget.getBoundingClientRect();
183
+ composableStudioEventManager?.send(POST_MESSAGE_EVENTS.OPEN_SECTION_SLOT_PICKER, {
184
+ sectionInstanceUid: sectionCtx?.sectionInstanceUid,
185
+ slotUid,
186
+ buttonRect: {
187
+ top: r.top,
188
+ left: r.left,
189
+ right: r.right,
190
+ bottom: r.bottom,
191
+ width: r.width,
192
+ height: r.height,
193
+ },
194
+ });
195
+ };
144
196
  // Authoring mode: section is the top-level composition being edited.
145
197
  if (!sectionCtx) {
146
198
  return (jsx("div", { [COMPOSABLE_DATA_ATTRIBUTES.SLOT]: true,
147
- [COMPOSABLE_DATA_ATTRIBUTES.SLOT_UID]: slotUid, ...studioAttributes, className: classNames(styles.slotStyle), children: jsxs("span", { className: styles.slotDropText, children: [jsx(AddIcon, {}), " ", text] }) }));
199
+ [COMPOSABLE_DATA_ATTRIBUTES.SLOT_UID]: slotUid, ...studioAttributes, className: classNames(styles.slotStyle), children: jsxs("span", { ref: authoringCopyColor.ref, className: classNames(styles.slotDropText, authoringCopyColor.colorClassName, authoringCopyColor.strokeClassName), children: [jsx(AddIcon, {}), " ", text] }) }));
148
200
  }
149
201
  // Consumption mode.
150
202
  const filled = (sectionCtx.slotsMap[slotUid] || []);
@@ -171,7 +223,15 @@ function SectionSlot({ studioAttributes, label, _uid, defaultSection, }) {
171
223
  currentNodePath: [...parentNodePath, [slotUid, 0]],
172
224
  }, children: jsx(MemoizedElement, { node: synth, renderError: () => null }) }) }) }) }) }));
173
225
  }
174
- return (jsx("div", { ref: slotDomRef, ...dropZoneAttrs, ...studioAttributes, className: classNames(styles.slotStyle), children: jsxs("span", { className: styles.slotDropText, children: [jsx(AddIcon, {}), " ", text] }) }));
226
+ return (jsxs("div", { ref: slotDomRef, ...dropZoneAttrs, ...studioAttributes,
227
+ // Always column now (COMS-1809): the "Select section" button stacks
228
+ // below the drop copy in every design-mode empty slot.
229
+ className: classNames(styles.slotStyle, styles.slotColumnStyle), children: [jsxs("span", { ref: dropCopyColor.ref, className: classNames(styles.slotDropText, dropCopyColor.colorClassName, dropCopyColor.strokeClassName), children: [jsx(AddIcon, {}), " ", defaultSection
230
+ ? "Drop a section here to replace it."
231
+ : "Drop a section here."] }), defaultSection ? (jsxs("p", { ref: defaultHintCopyColor.ref, className: classNames(styles.slotDefaultHint, defaultHintCopyColor.colorClassName, defaultHintCopyColor.strokeClassName), children: ["(When this slot is empty, the default section", defaultSectionTitle ? (jsxs(Fragment, { children: [" (", jsx("strong", { children: defaultSectionTitle }), ")"] })) : null, " added by the section author is shown in Preview and on the live page.)"] })) : null, jsx("p", { ref: orDividerCopyColor.ref, className: classNames(styles.slotOrDivider, orDividerCopyColor.colorClassName, orDividerCopyColor.strokeClassName), children: "OR" }), jsx("p", { ref: allowedLabelCopyColor.ref, className: classNames(styles.slotAllowedLabel, allowedLabelCopyColor.colorClassName, allowedLabelCopyColor.strokeClassName), children: "Add from the allowed Sections" }), jsxs(Button, { type: "button", "data-studio-ui": true, className: styles.slotSelectButton,
232
+ // Swallow mousedown so the slot's drag-select never starts from the
233
+ // button; the click opens the picker instead.
234
+ onMouseDown: (e) => e.stopPropagation(), onClick: handleSelectSection, children: [jsx(SelectSectionIcon, {}), " Select section"] })] }));
175
235
  }
176
236
  // Transclude filled children. Anchor each child's slate path under the
177
237
  // page-side section-composition node + this slot's uid. In design mode, exit
@@ -191,8 +251,11 @@ function SectionSlot({ studioAttributes, label, _uid, defaultSection, }) {
191
251
  }, children: jsx(SelectedNodeProvider, { children: jsx(MemoizedElement, { node: child, renderError: () => null }) }) }, child.uid));
192
252
  }) }) }) }) }));
193
253
  }
194
- const AddIcon = () => {
195
- return (jsxs("svg", { width: "22", height: "22", viewBox: "0 0 22 22", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsx("rect", { x: "0.5", y: "0.5", width: "21", height: "21", rx: "4.5", fill: "white" }), jsx("rect", { x: "0.5", y: "0.5", width: "21", height: "21", rx: "4.5", stroke: "#475161" }), jsx("path", { d: "M11.2808 6.78125C11.2808 6.62592 11.1548 6.5 10.9995 6.5C10.8442 6.5 10.7183 6.62592 10.7183 6.78125V10.7184H6.78125C6.62592 10.7184 6.5 10.8443 6.5 10.9996C6.5 11.155 6.62592 11.2809 6.78125 11.2809H10.7183V15.218C10.7183 15.3733 10.8442 15.4993 10.9995 15.4993C11.1548 15.4993 11.2808 15.3733 11.2808 15.218V11.2809H15.218C15.3733 11.2809 15.4993 11.155 15.4993 10.9996C15.4993 10.8443 15.3733 10.7184 15.218 10.7184H11.2808V6.78125Z", fill: "#475161" })] }));
254
+ // Marquee-select glyph for the "Select section" button (COMS-1809) — the
255
+ // design's asset verbatim, with fills switched to `currentColor` so it
256
+ // inherits the button's white text.
257
+ const SelectSectionIcon = () => {
258
+ return (jsxs("svg", { width: "18", height: "12", viewBox: "0 0 18 12", fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true", children: [jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M1.09375 0.9375C1.00746 0.9375 0.9375 1.00746 0.9375 1.09375V2.34375C0.9375 2.60263 0.727633 2.8125 0.46875 2.8125C0.209867 2.8125 0 2.60263 0 2.34375V1.09375C0 0.489689 0.489688 0 1.09375 0H2.34375C2.60263 0 2.8125 0.209867 2.8125 0.46875C2.8125 0.727633 2.60263 0.9375 2.34375 0.9375H1.09375ZM4.375 0.46875C4.375 0.209867 4.58487 0 4.84375 0H7.34375C7.60263 0 7.8125 0.209867 7.8125 0.46875C7.8125 0.727633 7.60263 0.9375 7.34375 0.9375H4.84375C4.58487 0.9375 4.375 0.727633 4.375 0.46875ZM9.375 0.46875C9.375 0.209867 9.58487 0 9.84375 0H12.3438C12.6026 0 12.8125 0.209867 12.8125 0.46875C12.8125 0.727633 12.6026 0.9375 12.3438 0.9375H9.84375C9.58487 0.9375 9.375 0.727633 9.375 0.46875ZM14.375 0.46875C14.375 0.209867 14.5849 0 14.8438 0H16.0938C16.6978 0 17.1875 0.489688 17.1875 1.09375V2.5C17.1875 2.75888 16.9776 2.96875 16.7188 2.96875C16.4599 2.96875 16.25 2.75888 16.25 2.5V1.09375C16.25 1.00746 16.18 0.9375 16.0938 0.9375H14.8438C14.5849 0.9375 14.375 0.727633 14.375 0.46875ZM0.46875 4.375C0.727633 4.375 0.9375 4.58487 0.9375 4.84375V6.09375C0.9375 6.18004 1.00746 6.25 1.09375 6.25H2.03125C2.29013 6.25 2.5 6.45987 2.5 6.71875C2.5 6.97763 2.29013 7.1875 2.03125 7.1875H1.09375C0.489689 7.1875 0 6.69781 0 6.09375V4.84375C0 4.58487 0.209867 4.375 0.46875 4.375ZM16.7188 4.84375C16.9776 4.84375 17.1875 5.05362 17.1875 5.3125V6.71875C17.1875 6.97763 16.9776 7.1875 16.7188 7.1875C16.4599 7.1875 16.25 6.97763 16.25 6.71875V5.3125C16.25 5.05362 16.4599 4.84375 16.7188 4.84375ZM3.4375 6.71875C3.4375 6.45987 3.64737 6.25 3.90625 6.25H5.78125C6.04013 6.25 6.25 6.45987 6.25 6.71875C6.25 6.97763 6.04013 7.1875 5.78125 7.1875H3.90625C3.64737 7.1875 3.4375 6.97763 3.4375 6.71875ZM7.1875 6.71875C7.1875 6.45987 7.39737 6.25 7.65625 6.25H8.59375C8.85263 6.25 9.0625 6.45987 9.0625 6.71875C9.0625 6.97763 8.85263 7.1875 8.59375 7.1875H7.65625C7.39737 7.1875 7.1875 6.97763 7.1875 6.71875Z", fill: "currentColor" }), jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M9.79852 4.73594C9.72732 4.06274 10.4877 3.62376 11.0351 4.02202L16.3345 7.8776C16.9193 8.30303 16.6619 9.22617 15.9414 9.28775L13.3774 9.5069L11.9056 11.6178C11.492 12.211 10.5639 11.9723 10.4878 11.2532L9.79852 4.73594ZM10.7678 4.98694L11.3761 10.7381L12.6503 8.91063C12.783 8.7203 12.9934 8.5988 13.2246 8.57904L15.4443 8.38932L10.7678 4.98694Z", fill: "currentColor" })] }));
196
259
  };
197
260
 
198
261
  export { SectionSlot };
@@ -1 +1 @@
1
- {"version":3,"file":"SectionSlot.js","sources":["../../../src/components/elements/SectionSlot.tsx"],"sourcesContent":["import {\n COMPOSABLE_DATA_ATTRIBUTES,\n ELEMENT_TO_NODE,\n NODE_TO_PARENT,\n NODE_TO_PATH_NODE,\n} from \"@contentstack/studio-client\";\nimport { Node, Path } from \"@contentstack/studio-internal\";\nimport {\n CurrentNodeContext,\n DataCtxProvider,\n SectionInstanceSlotsCtx,\n} from \"@contentstack/studio-react-components/contexts\";\nimport {\n useCurrentNode,\n useData,\n} from \"@contentstack/studio-react-components/hooks\";\nimport { css } from \"goober\";\nimport classNames from \"classnames\";\nimport { useCallback, useContext, useMemo } from \"react\";\nimport { styleFactory } from \"../styles\";\nimport { StudioAttributes } from \"../../types\";\nimport { SelectedNodeProvider } from \"../../contexts/providers/selected-node.provider\";\nimport { PreviewModeContext } from \"../../contexts/providers/preview-mode.provider\";\nimport { SectionModeContext } from \"../../contexts/providers/section-mode.provider\";\nimport Element from \"../Element\";\n\ninterface SectionSlotEditorProps extends StudioAttributes {\n label?: string;\n _uid?: string;\n /** Authored Slot default section uid (COMS-1659). Rendered when the slot is\n * empty in preview mode; design mode keeps the dropzone. */\n defaultSection?: string;\n}\n\n/**\n * In-memory `section-composition` node for a slot's authored default. Rendered\n * through the normal element path so the default's spec resolves by\n * `compositionUID` and nested defaults recurse. Stable uid → no remount. Never\n * persisted into the placement.\n */\nfunction makeDefaultSectionNode(\n instanceUid: string | undefined,\n slotUid: string,\n defaultUid: string,\n): Node {\n // Key by the enclosing placement instance too (COMS-1659): the same section\n // placed twice shares one internal `slotUid`, so a slot-uid-only key would\n // collide across placements and make their empty-slot defaults share one\n // uid-keyed data context. The instance uid makes each placement's default\n // distinct.\n const prefix = instanceUid ? `${instanceUid}-` : \"\";\n return {\n type: \"section-composition\",\n uid: `${prefix}${slotUid}-default-${defaultUid}`,\n metadata: { compositionUID: defaultUid, mode: \"preview\" },\n attrs: {},\n props: {},\n slots: {},\n styles: {},\n } as Node;\n}\n\n/**\n * Editor variant of section-slot. Two modes:\n *\n * 1. **Authoring mode** (no SectionInstanceSlotsCtx in scope) — the section\n * composition is being authored. Render a labelled drop-zone-style\n * placeholder; not droppable into (section slots only accept drops when\n * the section is consumed in a page composition).\n *\n * 2. **Consumption mode** (SectionInstanceSlotsCtx present) — the section\n * is being rendered inside a page composition. Look up the page-side\n * slots map by this slot's stable uid (== this node's uid). If filled,\n * transclude the children via <Element> with their paths anchored to\n * the page-side section-composition node, and lift them out of preview\n * mode so they're individually selectable / hover-targetable / draggable\n * like any other page-tree node. If empty, render a labelled drop\n * target that itself acts as a builder node (attributes mapped to the\n * page-side section-composition parent), so hover highlights only the\n * slot zone — not the whole section.\n */\nexport function SectionSlot({\n studioAttributes,\n label,\n _uid,\n defaultSection,\n}: SectionSlotEditorProps) {\n // ALL hooks unconditionally at the top — React doesn't allow conditional\n // hook calls and the component returns early for authoring/empty modes.\n const sectionCtx = useContext(SectionInstanceSlotsCtx);\n // When the enclosing placed section is in preview mode, the slot renders like\n // production: an empty slot collapses to nothing and a filled slot drops its\n // drop-chrome / selection affordances.\n const isSectionPreview = useContext(SectionModeContext) === \"preview\";\n const { currentNodePath: parentNodePath = [] } = useCurrentNode();\n // Current section-local data (template scoped to section, in-section\n // repeater item if surrounding, etc.). Slot children inherit this as\n // their *default* context — the user's authored bindings on slot\n // children resolve against this by default.\n const sectionLocalData = useData();\n const slotDomRef = useCallback(\n (el: HTMLElement | null) => {\n if (el && sectionCtx?.sectionNode) {\n ELEMENT_TO_NODE.set(el, sectionCtx.sectionNode);\n }\n },\n [sectionCtx?.sectionNode],\n );\n // Slot child's data context namespace:\n //\n // dataSources.template = section-local scoped template; if the\n // slot sits inside an in-section\n // Repeater that's currently iterating,\n // this is the active iteration item.\n // Matches what the Data Picker writes\n // when authoring against fields from\n // the slot's surrounding section scope.\n // dataSources.repeater[uid] = in-section Repeater map (full\n // per-uid context). Inherited from\n // sectionLocal via {...sectionDS}.\n // dataSources.static_value = section's persisted static values.\n // dataSources.page = OUTERMOST page-level namespace\n // ({ template, contentstack,\n // contentstack_queries, ... }).\n // Always points to the real page even\n // across recursive slot nesting — see\n // `truePageNamespace` below.\n //\n // Until Phase 8 lands, picker emits `dataSources.<src>.X` paths only.\n // retrieve-data.ts retries unresolved `dataSources.<src>.X` lookups under\n // `dataSources.page.<src>.X` so page-level bindings authored on slot\n // children still resolve.\n const slotChildData = useMemo(() => {\n const sectionLocal: any = sectionLocalData || {};\n const pageOuter: any = sectionCtx?.pageOuterData || {};\n const pageDS = pageOuter?.dataSources || {};\n const sectionDS = sectionLocal?.dataSources || {};\n\n const repeaterMap = (sectionDS.repeater || {}) as Record<string, any>;\n const repeaterUids = Object.keys(repeaterMap);\n const activeRepeaterUid =\n repeaterUids.length > 0\n ? repeaterUids[repeaterUids.length - 1]\n : undefined;\n const activeItem = activeRepeaterUid\n ? repeaterMap[activeRepeaterUid]?.context\n : undefined;\n const sectionLocalTemplate = activeItem ?? sectionDS.template;\n\n // Slot child's default namespace = section-local context AS IS (template,\n // repeater, static_value, …). Page-level sources are nested under `page.*`\n // as the explicit escape. This matches what the Data Picker writes when\n // authoring a slot child (picker shows the slot child's surrounding\n // scope, so its `template.X` / `repeater[uid].context.X` paths resolve\n // natively without rewriting).\n //\n // For nested cases (Section B in Section A's slot), `page` must always\n // point to the OUTERMOST page context — not to Section A's slot-local\n // view. Otherwise each nesting level shadows `page` with the surrounding\n // section's local, and `dataSources.page.template.title` would resolve\n // to a modular_block item instead of the page entry. So: if the outer\n // dataSources already has its own `page` key (because the section we're\n // inside is itself in another slot), inherit THAT — it's the real page.\n const outerPage = (pageDS as any)?.page;\n const truePageNamespace = outerPage ?? pageDS;\n return {\n ...sectionLocal,\n dataSources: {\n ...sectionDS,\n template: sectionLocalTemplate,\n page: truePageNamespace,\n },\n };\n }, [sectionLocalData, sectionCtx?.pageOuterData]);\n\n // ALL hooks above are unconditional. From here, branch based on mode.\n const styles = styleFactory(css);\n const text = label && label.trim().length > 0 ? label : \"Drop Here\";\n const slotUid =\n _uid ||\n (studioAttributes as any)?.[COMPOSABLE_DATA_ATTRIBUTES.ID] ||\n \"section-slot\";\n\n // Authoring mode: section is the top-level composition being edited.\n if (!sectionCtx) {\n return (\n <div\n {...{\n [COMPOSABLE_DATA_ATTRIBUTES.SLOT]: true,\n [COMPOSABLE_DATA_ATTRIBUTES.SLOT_UID]: slotUid,\n }}\n {...studioAttributes}\n className={classNames(styles.slotStyle)}\n >\n <span className={styles.slotDropText}>\n <AddIcon /> {text}\n </span>\n </div>\n );\n }\n\n // Consumption mode.\n const filled = (sectionCtx.slotsMap[slotUid] || []) as Node[];\n const dropZoneAttrs = {\n [COMPOSABLE_DATA_ATTRIBUTES.BUILDER]: true,\n [COMPOSABLE_DATA_ATTRIBUTES.NODE]: true,\n [COMPOSABLE_DATA_ATTRIBUTES.ID]: sectionCtx.sectionInstanceUid,\n [COMPOSABLE_DATA_ATTRIBUTES.SLOT]: true,\n [COMPOSABLE_DATA_ATTRIBUTES.SLOT_UID]: slotUid,\n };\n\n if (filled.length === 0) {\n // Preview mode: an empty slot falls back to its authored default section\n // (COMS-1659), rendered like production — non-interactive, no drop chrome.\n // With no default it collapses to nothing. Design mode always shows the\n // dropzone below (default never shown while authoring the placement).\n if (isSectionPreview) {\n if (!defaultSection) return null;\n const synth = makeDefaultSectionNode(\n sectionCtx.sectionInstanceUid,\n slotUid,\n defaultSection,\n );\n NODE_TO_PARENT.set(synth, sectionCtx.sectionNode);\n NODE_TO_PATH_NODE.set(synth, [slotUid, 0]);\n return (\n <DataCtxProvider value={slotChildData}>\n <PreviewModeContext.Provider value={true}>\n <div style={{ display: \"contents\" }}>\n <SectionInstanceSlotsCtx.Provider value={undefined}>\n <CurrentNodeContext.Provider\n value={{\n currentNodeUid: synth.uid,\n currentNodePath: [...parentNodePath, [slotUid, 0]],\n }}\n >\n <Element node={synth} renderError={() => null as any} />\n </CurrentNodeContext.Provider>\n </SectionInstanceSlotsCtx.Provider>\n </div>\n </PreviewModeContext.Provider>\n </DataCtxProvider>\n );\n }\n return (\n <div\n ref={slotDomRef as any}\n {...dropZoneAttrs}\n {...studioAttributes}\n className={classNames(styles.slotStyle)}\n >\n <span className={styles.slotDropText}>\n <AddIcon /> {text}\n </span>\n </div>\n );\n }\n\n // Transclude filled children. Anchor each child's slate path under the\n // page-side section-composition node + this slot's uid. In design mode, exit\n // preview so Element's internalAttributes get applied — making each child\n // selectable, hover-highlightable, and draggable like a normal node. In\n // preview mode, keep them inside preview (non-interactive) and drop the\n // drop-zone attributes so the slot reads like production.\n return (\n <DataCtxProvider value={slotChildData}>\n <PreviewModeContext.Provider value={isSectionPreview}>\n <div\n ref={slotDomRef as any}\n {...(isSectionPreview ? {} : dropZoneAttrs)}\n {...studioAttributes}\n style={{ display: \"contents\" }}\n >\n {/*\n * The filled children are PAGE-authored content the composer dropped\n * into this slot — not part of the section's authored body. Clear the\n * section-instance context for them so their own internal slots render\n * normally (e.g. an empty Repeater dropped here shows its \"Drop Here\"\n * placeholder instead of being suppressed by Slot.tsx's\n * in-section-consumption guard, which would make it disappear).\n */}\n <SectionInstanceSlotsCtx.Provider value={undefined}>\n {filled.map((child, idx) => {\n if (!child || typeof child !== \"object\") return null;\n NODE_TO_PARENT.set(child, sectionCtx.sectionNode);\n NODE_TO_PATH_NODE.set(child, [slotUid, idx]);\n const childPath: Path = [...parentNodePath, [slotUid, idx]];\n return (\n <CurrentNodeContext.Provider\n key={child.uid}\n value={{\n currentNodeUid: child.uid,\n currentNodePath: childPath,\n }}\n >\n <SelectedNodeProvider>\n <Element node={child} renderError={() => null as any} />\n </SelectedNodeProvider>\n </CurrentNodeContext.Provider>\n );\n })}\n </SectionInstanceSlotsCtx.Provider>\n </div>\n </PreviewModeContext.Provider>\n </DataCtxProvider>\n );\n}\n\nconst AddIcon: React.FC = () => {\n return (\n <svg\n width=\"22\"\n height=\"22\"\n viewBox=\"0 0 22 22\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <rect x=\"0.5\" y=\"0.5\" width=\"21\" height=\"21\" rx=\"4.5\" fill=\"white\" />\n <rect x=\"0.5\" y=\"0.5\" width=\"21\" height=\"21\" rx=\"4.5\" stroke=\"#475161\" />\n <path\n d=\"M11.2808 6.78125C11.2808 6.62592 11.1548 6.5 10.9995 6.5C10.8442 6.5 10.7183 6.62592 10.7183 6.78125V10.7184H6.78125C6.62592 10.7184 6.5 10.8443 6.5 10.9996C6.5 11.155 6.62592 11.2809 6.78125 11.2809H10.7183V15.218C10.7183 15.3733 10.8442 15.4993 10.9995 15.4993C11.1548 15.4993 11.2808 15.3733 11.2808 15.218V11.2809H15.218C15.3733 11.2809 15.4993 11.155 15.4993 10.9996C15.4993 10.8443 15.3733 10.7184 15.218 10.7184H11.2808V6.78125Z\"\n fill=\"#475161\"\n />\n </svg>\n );\n};\n"],"names":["_jsx","_jsxs","Element"],"mappings":";;;;;;;;;;;;;AAkCA;;;;;AAKG;AACH,SAAS,sBAAsB,CAC7B,WAA+B,EAC/B,OAAe,EACf,UAAkB,EAAA;;;;;;AAOlB,IAAA,MAAM,MAAM,GAAG,WAAW,GAAG,CAAA,EAAG,WAAW,CAAA,CAAA,CAAG,GAAG,EAAE;IACnD,OAAO;AACL,QAAA,IAAI,EAAE,qBAAqB;AAC3B,QAAA,GAAG,EAAE,CAAA,EAAG,MAAM,GAAG,OAAO,CAAA,SAAA,EAAY,UAAU,CAAA,CAAE;QAChD,QAAQ,EAAE,EAAE,cAAc,EAAE,UAAU,E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,CAAA,EAAA,CACE;AAEV,CAAC;;;;"}
1
+ {"version":3,"file":"SectionSlot.js","sources":["../../../src/components/elements/SectionSlot.tsx"],"sourcesContent":["import {\n COMPOSABLE_DATA_ATTRIBUTES,\n ELEMENT_TO_NODE,\n NODE_TO_PARENT,\n NODE_TO_PATH_NODE,\n} from \"@contentstack/studio-client\";\nimport { Node, Path } from \"@contentstack/studio-internal\";\nimport {\n CurrentNodeContext,\n DataCtxProvider,\n SectionInstanceSlotsCtx,\n} from \"@contentstack/studio-react-components/contexts\";\nimport {\n useCurrentNode,\n useData,\n} from \"@contentstack/studio-react-components/hooks\";\nimport {\n POST_MESSAGE_EVENTS,\n composableStudioEventManager,\n} from \"@contentstack/studio-messenger\";\nimport { Button } from \"@contentstack/studio-core\";\nimport { css } from \"goober\";\nimport classNames from \"classnames\";\nimport { MouseEvent, useCallback, useContext, useMemo } from \"react\";\nimport { styleFactory } from \"../styles\";\nimport { StudioAttributes } from \"../../types\";\nimport { SelectedNodeProvider } from \"../../contexts/providers/selected-node.provider\";\nimport { PreviewModeContext } from \"../../contexts/providers/preview-mode.provider\";\nimport { SectionModeContext } from \"../../contexts/providers/section-mode.provider\";\nimport { useRenderer } from \"../../hooks/use-renderer.hook\";\nimport { useSlotCopyColor } from \"../../hooks/use-slot-copy-color.hook\";\nimport Element from \"../Element\";\nimport { AddIcon } from \"../AddIcon\";\n\ninterface SectionSlotEditorProps extends StudioAttributes {\n label?: string;\n _uid?: string;\n /** Authored Slot default section uid (COMS-1659). Rendered when the slot is\n * empty in preview mode; design mode keeps the dropzone. */\n defaultSection?: string;\n}\n\n/**\n * In-memory `section-composition` node for a slot's authored default. Rendered\n * through the normal element path so the default's spec resolves by\n * `compositionUID` and nested defaults recurse. Stable uid → no remount. Never\n * persisted into the placement.\n */\nfunction makeDefaultSectionNode(\n instanceUid: string | undefined,\n slotUid: string,\n defaultUid: string,\n): Node {\n // Key by the enclosing placement instance too (COMS-1659): the same section\n // placed twice shares one internal `slotUid`, so a slot-uid-only key would\n // collide across placements and make their empty-slot defaults share one\n // uid-keyed data context. The instance uid makes each placement's default\n // distinct.\n const prefix = instanceUid ? `${instanceUid}-` : \"\";\n return {\n type: \"section-composition\",\n uid: `${prefix}${slotUid}-default-${defaultUid}`,\n metadata: { compositionUID: defaultUid, mode: \"preview\" },\n attrs: {},\n props: {},\n slots: {},\n styles: {},\n } as Node;\n}\n\n/**\n * Editor variant of section-slot. Two modes:\n *\n * 1. **Authoring mode** (no SectionInstanceSlotsCtx in scope) — the section\n * composition is being authored. Render a labelled drop-zone-style\n * placeholder; not droppable into (section slots only accept drops when\n * the section is consumed in a page composition).\n *\n * 2. **Consumption mode** (SectionInstanceSlotsCtx present) — the section\n * is being rendered inside a page composition. Look up the page-side\n * slots map by this slot's stable uid (== this node's uid). If filled,\n * transclude the children via <Element> with their paths anchored to\n * the page-side section-composition node, and lift them out of preview\n * mode so they're individually selectable / hover-targetable / draggable\n * like any other page-tree node. If empty, render a labelled drop\n * target that itself acts as a builder node (attributes mapped to the\n * page-side section-composition parent), so hover highlights only the\n * slot zone — not the whole section.\n */\nexport function SectionSlot({\n studioAttributes,\n label,\n _uid,\n defaultSection,\n}: SectionSlotEditorProps) {\n // ALL hooks unconditionally at the top — React doesn't allow conditional\n // hook calls and the component returns early for authoring/empty modes.\n // One measurement per line of empty-slot chrome: each reads the page colour\n // behind itself and picks the palette entry that separates from it best.\n const authoringCopyColor = useSlotCopyColor<HTMLSpanElement>();\n const dropCopyColor = useSlotCopyColor<HTMLSpanElement>();\n const defaultHintCopyColor = useSlotCopyColor<HTMLParagraphElement>();\n const orDividerCopyColor = useSlotCopyColor<HTMLParagraphElement>();\n const allowedLabelCopyColor = useSlotCopyColor<HTMLParagraphElement>();\n const sectionCtx = useContext(SectionInstanceSlotsCtx);\n // Registry resolves the authored Default section's human title for the\n // design-mode hint (COMS-1770). Sections register with `type = section.uid`\n // and `displayName = section.title`, so a uid lookup yields the title.\n const { componentRegistry } = useRenderer();\n // When the enclosing placed section is in preview mode, the slot renders like\n // production: an empty slot collapses to nothing and a filled slot drops its\n // drop-chrome / selection affordances.\n const isSectionPreview = useContext(SectionModeContext) === \"preview\";\n const { currentNodePath: parentNodePath = [] } = useCurrentNode();\n // Current section-local data (template scoped to section, in-section\n // repeater item if surrounding, etc.). Slot children inherit this as\n // their *default* context — the user's authored bindings on slot\n // children resolve against this by default.\n const sectionLocalData = useData();\n const slotDomRef = useCallback(\n (el: HTMLElement | null) => {\n if (el && sectionCtx?.sectionNode) {\n ELEMENT_TO_NODE.set(el, sectionCtx.sectionNode);\n }\n },\n [sectionCtx?.sectionNode],\n );\n // Slot child's data context namespace:\n //\n // dataSources.template = section-local scoped template; if the\n // slot sits inside an in-section\n // Repeater that's currently iterating,\n // this is the active iteration item.\n // Matches what the Data Picker writes\n // when authoring against fields from\n // the slot's surrounding section scope.\n // dataSources.repeater[uid] = in-section Repeater map (full\n // per-uid context). Inherited from\n // sectionLocal via {...sectionDS}.\n // dataSources.static_value = section's persisted static values.\n // dataSources.page = OUTERMOST page-level namespace\n // ({ template, contentstack,\n // contentstack_queries, ... }).\n // Always points to the real page even\n // across recursive slot nesting — see\n // `truePageNamespace` below.\n //\n // Until Phase 8 lands, picker emits `dataSources.<src>.X` paths only.\n // retrieve-data.ts retries unresolved `dataSources.<src>.X` lookups under\n // `dataSources.page.<src>.X` so page-level bindings authored on slot\n // children still resolve.\n const slotChildData = useMemo(() => {\n const sectionLocal: any = sectionLocalData || {};\n const pageOuter: any = sectionCtx?.pageOuterData || {};\n const pageDS = pageOuter?.dataSources || {};\n const sectionDS = sectionLocal?.dataSources || {};\n\n const repeaterMap = (sectionDS.repeater || {}) as Record<string, any>;\n const repeaterUids = Object.keys(repeaterMap);\n const activeRepeaterUid =\n repeaterUids.length > 0\n ? repeaterUids[repeaterUids.length - 1]\n : undefined;\n const activeItem = activeRepeaterUid\n ? repeaterMap[activeRepeaterUid]?.context\n : undefined;\n const sectionLocalTemplate = activeItem ?? sectionDS.template;\n\n // Slot child's default namespace = section-local context AS IS (template,\n // repeater, static_value, …). Page-level sources are nested under `page.*`\n // as the explicit escape. This matches what the Data Picker writes when\n // authoring a slot child (picker shows the slot child's surrounding\n // scope, so its `template.X` / `repeater[uid].context.X` paths resolve\n // natively without rewriting).\n //\n // For nested cases (Section B in Section A's slot), `page` must always\n // point to the OUTERMOST page context — not to Section A's slot-local\n // view. Otherwise each nesting level shadows `page` with the surrounding\n // section's local, and `dataSources.page.template.title` would resolve\n // to a modular_block item instead of the page entry. So: if the outer\n // dataSources already has its own `page` key (because the section we're\n // inside is itself in another slot), inherit THAT — it's the real page.\n const outerPage = (pageDS as any)?.page;\n const truePageNamespace = outerPage ?? pageDS;\n return {\n ...sectionLocal,\n dataSources: {\n ...sectionDS,\n template: sectionLocalTemplate,\n page: truePageNamespace,\n },\n };\n }, [sectionLocalData, sectionCtx?.pageOuterData]);\n\n // ALL hooks above are unconditional. From here, branch based on mode.\n const styles = styleFactory(css);\n const text = label && label.trim().length > 0 ? label : \"Drop Here\";\n const slotUid =\n _uid ||\n (studioAttributes as any)?.[COMPOSABLE_DATA_ATTRIBUTES.ID] ||\n \"section-slot\";\n\n // Design-mode hint (COMS-1770): resolve the Default section's title for the\n // message. `getComponent` throws for a uid outside the locally-known catalog,\n // so fall back to a nameless hint instead of crashing the slot.\n let defaultSectionTitle: string | undefined;\n if (defaultSection) {\n try {\n defaultSectionTitle =\n componentRegistry.getComponent(defaultSection)?.displayName;\n } catch {\n defaultSectionTitle = undefined;\n }\n }\n\n // COMS-1809: open the section-slot picker. The button lives here in the\n // iframe, but the picker is a parent-app overlay (reusing the Component tab\n // card + hover preview + section catalog — ADR 0010), so we only post the\n // slot identity plus the button's viewport rect. Studio offsets the rect by\n // the iframe's own position to anchor the popover. Plain function (used only\n // in the consumption design-empty branch below), not a hook.\n const handleSelectSection = (event: MouseEvent<HTMLButtonElement>) => {\n event.preventDefault();\n event.stopPropagation();\n const r = event.currentTarget.getBoundingClientRect();\n composableStudioEventManager?.send(\n POST_MESSAGE_EVENTS.OPEN_SECTION_SLOT_PICKER,\n {\n sectionInstanceUid: sectionCtx?.sectionInstanceUid,\n slotUid,\n buttonRect: {\n top: r.top,\n left: r.left,\n right: r.right,\n bottom: r.bottom,\n width: r.width,\n height: r.height,\n },\n },\n );\n };\n\n // Authoring mode: section is the top-level composition being edited.\n if (!sectionCtx) {\n return (\n <div\n {...{\n [COMPOSABLE_DATA_ATTRIBUTES.SLOT]: true,\n [COMPOSABLE_DATA_ATTRIBUTES.SLOT_UID]: slotUid,\n }}\n {...studioAttributes}\n className={classNames(styles.slotStyle)}\n >\n <span\n ref={authoringCopyColor.ref}\n className={classNames(\n styles.slotDropText,\n authoringCopyColor.colorClassName,\n authoringCopyColor.strokeClassName,\n )}\n >\n <AddIcon /> {text}\n </span>\n </div>\n );\n }\n\n // Consumption mode.\n const filled = (sectionCtx.slotsMap[slotUid] || []) as Node[];\n const dropZoneAttrs = {\n [COMPOSABLE_DATA_ATTRIBUTES.BUILDER]: true,\n [COMPOSABLE_DATA_ATTRIBUTES.NODE]: true,\n [COMPOSABLE_DATA_ATTRIBUTES.ID]: sectionCtx.sectionInstanceUid,\n [COMPOSABLE_DATA_ATTRIBUTES.SLOT]: true,\n [COMPOSABLE_DATA_ATTRIBUTES.SLOT_UID]: slotUid,\n };\n\n if (filled.length === 0) {\n // Preview mode: an empty slot falls back to its authored default section\n // (COMS-1659), rendered like production — non-interactive, no drop chrome.\n // With no default it collapses to nothing. Design mode always shows the\n // dropzone below (default never shown while authoring the placement).\n if (isSectionPreview) {\n if (!defaultSection) return null;\n const synth = makeDefaultSectionNode(\n sectionCtx.sectionInstanceUid,\n slotUid,\n defaultSection,\n );\n NODE_TO_PARENT.set(synth, sectionCtx.sectionNode);\n NODE_TO_PATH_NODE.set(synth, [slotUid, 0]);\n return (\n <DataCtxProvider value={slotChildData}>\n <PreviewModeContext.Provider value={true}>\n <div style={{ display: \"contents\" }}>\n <SectionInstanceSlotsCtx.Provider value={undefined}>\n <CurrentNodeContext.Provider\n value={{\n currentNodeUid: synth.uid,\n currentNodePath: [...parentNodePath, [slotUid, 0]],\n }}\n >\n <Element node={synth} renderError={() => null as any} />\n </CurrentNodeContext.Provider>\n </SectionInstanceSlotsCtx.Provider>\n </div>\n </PreviewModeContext.Provider>\n </DataCtxProvider>\n );\n }\n return (\n <div\n ref={slotDomRef as any}\n {...dropZoneAttrs}\n {...studioAttributes}\n // Always column now (COMS-1809): the \"Select section\" button stacks\n // below the drop copy in every design-mode empty slot.\n className={classNames(styles.slotStyle, styles.slotColumnStyle)}\n >\n {/* One empty-state layout regardless of a configured default — only\n the parenthetical hint below is default-only. The drop copy keeps\n \"…to replace it\" solely when there IS a default to replace. */}\n <span\n ref={dropCopyColor.ref}\n className={classNames(\n styles.slotDropText,\n dropCopyColor.colorClassName,\n dropCopyColor.strokeClassName,\n )}\n >\n <AddIcon />{\" \"}\n {defaultSection\n ? \"Drop a section here to replace it.\"\n : \"Drop a section here.\"}\n </span>\n {/* Design-mode hint (COMS-1770): tell the page composer that leaving\n this slot empty will render the author's Default section in preview\n and on the live page. Mirrors the repeater's condition-block hint\n (Slot.tsx). Only shown when a default is configured. */}\n {defaultSection ? (\n <p\n ref={defaultHintCopyColor.ref}\n className={classNames(\n styles.slotDefaultHint,\n defaultHintCopyColor.colorClassName,\n defaultHintCopyColor.strokeClassName,\n )}\n >\n {\"(When this slot is empty, the default section\"}\n {defaultSectionTitle ? (\n <>\n {\" (\"}\n <strong>{defaultSectionTitle}</strong>\n {\")\"}\n </>\n ) : null}\n {\n \" added by the section author is shown in Preview and on the live page.)\"\n }\n </p>\n ) : null}\n {/* COMS-1809: click-to-pick alternative to drag-and-drop. The \"OR\"\n reads DND vs picker, so it shows in every empty slot. */}\n <p\n ref={orDividerCopyColor.ref}\n className={classNames(\n styles.slotOrDivider,\n orDividerCopyColor.colorClassName,\n orDividerCopyColor.strokeClassName,\n )}\n >\n OR\n </p>\n <p\n ref={allowedLabelCopyColor.ref}\n className={classNames(\n styles.slotAllowedLabel,\n allowedLabelCopyColor.colorClassName,\n allowedLabelCopyColor.strokeClassName,\n )}\n >\n Add from the allowed Sections\n </p>\n <Button\n type=\"button\"\n data-studio-ui={true}\n className={styles.slotSelectButton}\n // Swallow mousedown so the slot's drag-select never starts from the\n // button; the click opens the picker instead.\n onMouseDown={(e) => e.stopPropagation()}\n onClick={handleSelectSection}\n >\n <SelectSectionIcon /> Select section\n </Button>\n </div>\n );\n }\n\n // Transclude filled children. Anchor each child's slate path under the\n // page-side section-composition node + this slot's uid. In design mode, exit\n // preview so Element's internalAttributes get applied — making each child\n // selectable, hover-highlightable, and draggable like a normal node. In\n // preview mode, keep them inside preview (non-interactive) and drop the\n // drop-zone attributes so the slot reads like production.\n return (\n <DataCtxProvider value={slotChildData}>\n <PreviewModeContext.Provider value={isSectionPreview}>\n <div\n ref={slotDomRef as any}\n {...(isSectionPreview ? {} : dropZoneAttrs)}\n {...studioAttributes}\n style={{ display: \"contents\" }}\n >\n {/*\n * The filled children are PAGE-authored content the composer dropped\n * into this slot — not part of the section's authored body. Clear the\n * section-instance context for them so their own internal slots render\n * normally (e.g. an empty Repeater dropped here shows its \"Drop Here\"\n * placeholder instead of being suppressed by Slot.tsx's\n * in-section-consumption guard, which would make it disappear).\n */}\n <SectionInstanceSlotsCtx.Provider value={undefined}>\n {filled.map((child, idx) => {\n if (!child || typeof child !== \"object\") return null;\n NODE_TO_PARENT.set(child, sectionCtx.sectionNode);\n NODE_TO_PATH_NODE.set(child, [slotUid, idx]);\n const childPath: Path = [...parentNodePath, [slotUid, idx]];\n return (\n <CurrentNodeContext.Provider\n key={child.uid}\n value={{\n currentNodeUid: child.uid,\n currentNodePath: childPath,\n }}\n >\n <SelectedNodeProvider>\n <Element node={child} renderError={() => null as any} />\n </SelectedNodeProvider>\n </CurrentNodeContext.Provider>\n );\n })}\n </SectionInstanceSlotsCtx.Provider>\n </div>\n </PreviewModeContext.Provider>\n </DataCtxProvider>\n );\n}\n\n// Marquee-select glyph for the \"Select section\" button (COMS-1809) — the\n// design's asset verbatim, with fills switched to `currentColor` so it\n// inherits the button's white text.\nconst SelectSectionIcon: React.FC = () => {\n return (\n <svg\n width=\"18\"\n height=\"12\"\n viewBox=\"0 0 18 12\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n aria-hidden=\"true\"\n >\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M1.09375 0.9375C1.00746 0.9375 0.9375 1.00746 0.9375 1.09375V2.34375C0.9375 2.60263 0.727633 2.8125 0.46875 2.8125C0.209867 2.8125 0 2.60263 0 2.34375V1.09375C0 0.489689 0.489688 0 1.09375 0H2.34375C2.60263 0 2.8125 0.209867 2.8125 0.46875C2.8125 0.727633 2.60263 0.9375 2.34375 0.9375H1.09375ZM4.375 0.46875C4.375 0.209867 4.58487 0 4.84375 0H7.34375C7.60263 0 7.8125 0.209867 7.8125 0.46875C7.8125 0.727633 7.60263 0.9375 7.34375 0.9375H4.84375C4.58487 0.9375 4.375 0.727633 4.375 0.46875ZM9.375 0.46875C9.375 0.209867 9.58487 0 9.84375 0H12.3438C12.6026 0 12.8125 0.209867 12.8125 0.46875C12.8125 0.727633 12.6026 0.9375 12.3438 0.9375H9.84375C9.58487 0.9375 9.375 0.727633 9.375 0.46875ZM14.375 0.46875C14.375 0.209867 14.5849 0 14.8438 0H16.0938C16.6978 0 17.1875 0.489688 17.1875 1.09375V2.5C17.1875 2.75888 16.9776 2.96875 16.7188 2.96875C16.4599 2.96875 16.25 2.75888 16.25 2.5V1.09375C16.25 1.00746 16.18 0.9375 16.0938 0.9375H14.8438C14.5849 0.9375 14.375 0.727633 14.375 0.46875ZM0.46875 4.375C0.727633 4.375 0.9375 4.58487 0.9375 4.84375V6.09375C0.9375 6.18004 1.00746 6.25 1.09375 6.25H2.03125C2.29013 6.25 2.5 6.45987 2.5 6.71875C2.5 6.97763 2.29013 7.1875 2.03125 7.1875H1.09375C0.489689 7.1875 0 6.69781 0 6.09375V4.84375C0 4.58487 0.209867 4.375 0.46875 4.375ZM16.7188 4.84375C16.9776 4.84375 17.1875 5.05362 17.1875 5.3125V6.71875C17.1875 6.97763 16.9776 7.1875 16.7188 7.1875C16.4599 7.1875 16.25 6.97763 16.25 6.71875V5.3125C16.25 5.05362 16.4599 4.84375 16.7188 4.84375ZM3.4375 6.71875C3.4375 6.45987 3.64737 6.25 3.90625 6.25H5.78125C6.04013 6.25 6.25 6.45987 6.25 6.71875C6.25 6.97763 6.04013 7.1875 5.78125 7.1875H3.90625C3.64737 7.1875 3.4375 6.97763 3.4375 6.71875ZM7.1875 6.71875C7.1875 6.45987 7.39737 6.25 7.65625 6.25H8.59375C8.85263 6.25 9.0625 6.45987 9.0625 6.71875C9.0625 6.97763 8.85263 7.1875 8.59375 7.1875H7.65625C7.39737 7.1875 7.1875 6.97763 7.1875 6.71875Z\"\n fill=\"currentColor\"\n />\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M9.79852 4.73594C9.72732 4.06274 10.4877 3.62376 11.0351 4.02202L16.3345 7.8776C16.9193 8.30303 16.6619 9.22617 15.9414 9.28775L13.3774 9.5069L11.9056 11.6178C11.492 12.211 10.5639 11.9723 10.4878 11.2532L9.79852 4.73594ZM10.7678 4.98694L11.3761 10.7381L12.6503 8.91063C12.783 8.7203 12.9934 8.5988 13.2246 8.57904L15.4443 8.38932L10.7678 4.98694Z\"\n fill=\"currentColor\"\n />\n </svg>\n );\n};\n"],"names":["_jsx","_jsxs","Element","_Fragment"],"mappings":";;;;;;;;;;;;;;;;;;AA0CA;;;;;AAKG;AACH,SAAS,sBAAsB,CAC7B,WAA+B,EAC/B,OAAe,EACf,UAAkB,EAAA;;;;;;AAOlB,IAAA,MAAM,MAAM,GAAG,WAAW,GAAG,CAAA,EAAG,WAAW,CAAA,CAAA,CAAG,GAAG,EAAE;IACnD,OAAO;AACL,QAAA,IAAI,EAAE,qBAAqB;AAC3B,QAAA,GAAG,EAAE,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AA,EAAA,CACE;AAEV,CAAC;;;;"}
@@ -1,3 +1,10 @@
1
+ import { STUDIO_CHROME_MODES } from '../utils/copy-color.util.js';
2
+
3
+ /** Builds one class per chrome mode from the same tokens the maths reads. */
4
+ const perMode = (css, rule) => Object.fromEntries(Object.entries(STUDIO_CHROME_MODES).map(([mode, tokens]) => [
5
+ mode,
6
+ css(rule(tokens)),
7
+ ]));
1
8
  const styleFactory = (css) => ({
2
9
  embedStyle: css({
3
10
  height: "100%",
@@ -21,14 +28,35 @@ const styleFactory = (css) => ({
21
28
  gap: "4px",
22
29
  alignItems: "center",
23
30
  justifyContent: "center",
24
- border: "1px dashed #6c5ce7",
31
+ // No background of its own. An earlier fix painted every dropzone white,
32
+ // on the premise that the host page's colour could not be known or read
33
+ // reliably. It can: the walk in copy-color.util.ts reads it, and the chrome
34
+ // colours itself from the answer. A white fill also made empty columns read
35
+ // as occupied — the dashed outline says empty while the fill says full —
36
+ // which is why it is gone rather than kept alongside.
37
+ //
38
+ // Two-tone outline. A lone dashed border leaves its gaps transparent, so
39
+ // the slot boundary washes out against dark or purple-ish host pages.
40
+ // The element's own border is a solid white ring; the dashes are painted
41
+ // over it by the overlay below, leaving white — not the page — in the
42
+ // gaps, which reads on any background.
43
+ position: "relative",
44
+ border: "1px solid #ffffff",
45
+ "&::before": {
46
+ content: '""',
47
+ position: "absolute",
48
+ // Sit on the border ring itself, not inside the padding box.
49
+ inset: "-1px",
50
+ border: "1px dashed #6c5ce7",
51
+ pointerEvents: "none",
52
+ },
25
53
  color: "#475161",
26
54
  fontSize: "14px",
27
55
  fontStyle: "normal",
28
56
  fontWeight: 400,
29
57
  lineHeight: "24px",
30
58
  userSelect: "none",
31
- fontFamily: "Inter",
59
+ fontFamily: "Inter, sans-serif",
32
60
  paddingInline: "2rem",
33
61
  paddingBlock: "1rem",
34
62
  transition: "background-color 0.3s ease",
@@ -41,15 +69,114 @@ const styleFactory = (css) => ({
41
69
  flexDirection: "column",
42
70
  gap: "4px",
43
71
  }),
72
+ // Drop copy and hints sit on top of whatever the host page paints behind
73
+ // the slot, so no fixed colour is readable on every page. These rules carry
74
+ // only layout — the colour comes from a class chosen per line:
75
+ // `slotCopyColors` when the page colour can be measured,
76
+ // `slotCopyOverImage` when it cannot.
44
77
  slotDropText: css({
45
78
  display: "inline-flex",
46
79
  alignItems: "center",
47
- gap: "4px",
80
+ gap: "6px",
48
81
  }),
49
82
  slotHintStyle: css({
50
83
  textAlign: "center",
51
84
  margin: 0,
52
85
  }),
86
+ // Ink per mode, built from the same tokens the contrast maths reads, so the
87
+ // colour that gets scored is the colour that gets painted. `!important`
88
+ // because this chrome renders inside the customer's page, whose CSS would
89
+ // otherwise recolour it.
90
+ slotCopyColors: perMode(css, (tokens) => ({
91
+ color: `${tokens.ink} !important`,
92
+ })),
93
+ // A stroke for a bare label the ink cannot carry on its own — the mid-tone
94
+ // band, where a card would take a surface but a one-line label has nothing to
95
+ // sit on. Stroking in the opposite mode's ink gives each glyph its own local
96
+ // polarity without painting a fill behind it. `paint-order` puts the stroke
97
+ // under the fill so the letterforms stay their own weight.
98
+ slotCopyStroke: perMode(css, (tokens) => ({
99
+ // Stroke in the opposite mode's ink — that is the colour guaranteed to
100
+ // contrast with this mode's.
101
+ WebkitTextStroke: `2px ${tokens.surface}`,
102
+ paintOrder: "stroke fill",
103
+ fontWeight: 600,
104
+ })),
105
+ // Fallback for pages whose background cannot be read from computed styles —
106
+ // a gradient, photo or video behind the slot. With nothing to measure and no
107
+ // fill to sit on, the copy goes white and leans on a soft dark shadow, the
108
+ // usual way text survives over imagery of unknown brightness.
109
+ slotCopyOverImage: css({
110
+ color: "#ffffff !important",
111
+ textShadow: "0 1px 3px rgba(0, 0, 0, 0.85), 0 0 10px rgba(0, 0, 0, 0.55)",
112
+ }),
113
+ // Section-slot Default-section hint (COMS-1770). Typography pinned to the
114
+ // Figma spec (Text/Secondary_Text); the colour comes from the measured copy
115
+ // colour instead. `!important` because this chrome renders inside the
116
+ // customer's page, whose CSS would otherwise override the weight/color
117
+ // (e.g. render it bold).
118
+ slotDefaultHint: css({
119
+ margin: 0,
120
+ textAlign: "center",
121
+ fontFamily: "Inter, sans-serif !important",
122
+ fontSize: "14px !important",
123
+ fontStyle: "normal !important",
124
+ fontWeight: "400 !important",
125
+ lineHeight: "24px !important",
126
+ letterSpacing: "0 !important",
127
+ }),
128
+ // Section-slot "Select section" affordance (COMS-1809). Renders inside the
129
+ // customer's page, so — like slotDefaultHint — the visual props are pinned
130
+ // with `!important` to survive the host page's CSS. The button overrides the
131
+ // shared studio-core Button base (light-purple outline) to the filled-purple
132
+ // primary shown in the design.
133
+ slotSelectButton: css({
134
+ backgroundColor: "#6c5ce7 !important",
135
+ color: "#ffffff !important",
136
+ border: "1px solid #6c5ce7 !important",
137
+ fontWeight: "600 !important",
138
+ // Pin the icon/text alignment too — the studio-core base sets flex
139
+ // centering, but host-page CSS can override it, leaving the icon riding
140
+ // above the label. The svg is inline by default (baseline-aligned), so
141
+ // make it a block flex item.
142
+ display: "inline-flex !important",
143
+ alignItems: "center !important",
144
+ justifyContent: "center !important",
145
+ gap: "0.5rem !important",
146
+ // Typography pinned as well: a host font-size/line-height override makes
147
+ // the label's line box taller than the 12px icon and drags its visual
148
+ // center away from the icon's. line-height 1 makes the text flex item
149
+ // exactly glyph-high, so both centers coincide.
150
+ fontSize: "0.875rem !important",
151
+ lineHeight: "1 !important",
152
+ fontFamily: "'Inter', sans-serif !important",
153
+ "& svg": {
154
+ display: "block",
155
+ flexShrink: 0,
156
+ // Optical centering: the flex boxes align exactly (verified — svg/text
157
+ // center deltas are 0), but the asset's dashed marquee occupies only the
158
+ // top 7.2px of its 18x12 box with the pointer overhanging below-right,
159
+ // so a box-centered icon READS ~2px high. Nudge down so the marquee —
160
+ // the dominant shape — centers on the label, pointer descending like a
161
+ // glyph descender (matches the design).
162
+ transform: "translateY(2px)",
163
+ },
164
+ }),
165
+ slotOrDivider: css({
166
+ margin: 0,
167
+ textAlign: "center",
168
+ fontFamily: "Inter, sans-serif !important",
169
+ fontSize: "12px !important",
170
+ fontWeight: "400 !important",
171
+ textTransform: "uppercase",
172
+ }),
173
+ slotAllowedLabel: css({
174
+ margin: 0,
175
+ textAlign: "center",
176
+ fontFamily: "Inter, sans-serif !important",
177
+ fontSize: "12px !important",
178
+ fontWeight: "600 !important",
179
+ }),
53
180
  embeddedSectionHost: css({
54
181
  position: "relative",
55
182
  ".cs-embedded-section-edit-btn": {
@@ -113,13 +240,11 @@ const styleFactory = (css) => ({
113
240
  welcomeTitle: css({
114
241
  fontSize: "20px",
115
242
  fontWeight: "600",
116
- color: "#475161",
117
243
  margin: "20px 0 10px 0",
118
244
  fontFamily: "Inter, sans-serif",
119
245
  }),
120
246
  welcomeSubtitle: css({
121
247
  fontSize: "14px",
122
- color: "#6E6B86",
123
248
  margin: "0 0 30px 0",
124
249
  maxWidth: "400px",
125
250
  fontFamily: "Inter, sans-serif",
@@ -140,20 +265,20 @@ const styleFactory = (css) => ({
140
265
  "& h3": {
141
266
  fontSize: "16px",
142
267
  fontWeight: "600",
143
- color: "#475161",
144
268
  margin: "0 0 8px 0",
145
269
  fontFamily: "Inter, sans-serif",
146
270
  },
147
271
  "& p": {
148
272
  fontSize: "14px",
149
- color: "#6E6B86",
150
273
  margin: 0,
151
274
  fontFamily: "Inter, sans-serif",
152
275
  lineHeight: "1.4",
153
276
  },
154
277
  }),
278
+ // Fill comes from the measurement; a fixed pale fill swallowed its own copy
279
+ // at 1:1 once the ink adapted pale on a dark page. The purple border is what
280
+ // marks the step regardless.
155
281
  activeWelcomeStep: css({
156
- backgroundColor: "#F9F8FF",
157
282
  border: "1px solid #6C5CE7",
158
283
  }),
159
284
  });