@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,37 +1,40 @@
1
1
  import { jsx, Fragment } from 'react/jsx-runtime';
2
- import { composableStudioEventEmitter, COMPOSABLE_STUDIO_EMITTED_EVENTS, ELEMENT_TO_NODE, NODE_TO_ELEMENT, loadGoogleFont, COMPOSABLE_DATA_ATTRIBUTES, getJSONRTE, NODE_TO_PATH_NODE, NODE_TO_PARENT } from '@contentstack/studio-client';
2
+ import { ELEMENT_TO_NODE, NODE_TO_ELEMENT, NODE_TO_PATH_NODE, NODE_TO_PARENT, COMPOSABLE_DATA_ATTRIBUTES, composableStudioEventEmitter, COMPOSABLE_STUDIO_EMITTED_EVENTS, loadGoogleFont, getJSONRTE } from '@contentstack/studio-client';
3
3
  import { handleNodeStyles, lightSdk, sdk } from '@contentstack/studio-core';
4
- import { SectionInstanceSlotsCtxProvider, CurrentNodeContext } from '@contentstack/studio-react-components/contexts';
5
- import { useData, useCurrentNode } from '@contentstack/studio-react-components/hooks';
6
- import { resolveMetadataBindings, clearReportedBindingErrorsForNode, getRepeaterBinding, getBindingString, getCslpTag, retrievePropValue, INTERNAL_COMPONENTS_NAMES } from '@contentstack/studio-registry';
4
+ import { CurrentNodeContext, SectionInstanceSlotsCtxProvider } from '@contentstack/studio-react-components/contexts';
5
+ import { useCurrentNode, useData, useNodeStateBindings, useNodeBoundFunctionName } from '@contentstack/studio-react-components/hooks';
6
+ import { INTERNAL_COMPONENTS_NAMES, resolveMetadataBindings, clearReportedBindingErrorsForNode, getRepeaterBinding, getBindingString, getCslpTag, wrapActionProps, retrievePropValue, callStudioFunction } from '@contentstack/studio-registry';
7
7
  import classNames from 'classnames';
8
- import { memo, useRef, useEffect, useCallback } from 'react';
8
+ import { memo, useMemo, useCallback, useRef, useEffect } from 'react';
9
9
  import { RendererErrorComponent } from './ErrorComponent.js';
10
10
  import { TextPlaceholder } from './TextPlaceholder.js';
11
11
  import { RendererErrorBoundary } from './RendererErrorBoundary.js';
12
- import { shouldRenderSlot } from '../utils/renderer.util.js';
12
+ import { shouldRenderSlot, getSlotHint } from '../utils/renderer.util.js';
13
13
  import Slot from './Slot.js';
14
- import '../hooks/use-edit-context-listener.hook.js';
15
- import '@contentstack/studio-messenger';
16
- import '@contentstack/studio-internal';
17
- import '@contentstack/studio-react-components/basic-components';
18
- import 'goober';
19
- import '../contexts/providers/renderer.provider.js';
20
- import '../contexts/providers/edit-context.provider.js';
21
- import '../contexts/providers/active-node.provider.js';
22
- import 'immer';
23
- import '../contexts/providers/use-design-preview.provider.js';
24
- import '../contexts/providers/use-repeater.provider.js';
25
- import '../contexts/providers/use-condition-block.provider.js';
26
- import '../contexts/providers/preview-mode.provider.js';
27
- import '../contexts/providers/section-mode.provider.js';
28
- import { useRenderer } from '../hooks/use-renderer.hook.js';
29
14
  import { usePreviewMode } from '../hooks/use-preview-mode.hook.js';
15
+ import { useRenderer } from '../hooks/use-renderer.hook.js';
30
16
  import { SelectedNodeProvider } from '../contexts/providers/selected-node.provider.js';
31
17
 
32
18
  const Element = ({ node, renderError, dataCslp, }) => {
33
19
  const isPreviewMode = usePreviewMode();
34
- const data = useData();
20
+ const pageData = useData();
21
+ // Canvas parity with the production renderer's BaseElement: declared state
22
+ // variables bound via component_props resolve from the shared BYOS state
23
+ // store. Per-node subscription — only this node re-renders when one of ITS
24
+ // bound state keys changes.
25
+ const stateSnapshot = useNodeStateBindings(node);
26
+ // Behavior assignment (BYOS): reactive — re-reads when the app registers
27
+ // functions (commonly after this node's first render).
28
+ const boundFunctionName = useNodeBoundFunctionName(node);
29
+ const data = useMemo(() => stateSnapshot
30
+ ? {
31
+ ...pageData,
32
+ component_props: {
33
+ ...pageData?.component_props,
34
+ ...stateSnapshot,
35
+ },
36
+ }
37
+ : pageData, [pageData, stateSnapshot]);
35
38
  const { attrs = {}, styles = {}, uid } = node;
36
39
  const { isCompositionBeingEdited, componentRegistry } = useRenderer();
37
40
  resolveMetadataBindings(node, data);
@@ -168,7 +171,7 @@ const Element = ({ node, renderError, dataCslp, }) => {
168
171
  }
169
172
  }
170
173
  }
171
- const resolvedProps = retrievePropValue({
174
+ const resolvedProps = wrapActionProps(componentOptions.props, retrievePropValue({
172
175
  data,
173
176
  defaultSlot: "I am a default slot", // TODO: this should be an component
174
177
  componentOptions: componentOptions,
@@ -185,12 +188,24 @@ const Element = ({ node, renderError, dataCslp, }) => {
185
188
  return (jsx(VisualComponent, { parent: parent, nodes: slots, slotUid: slotUid, renderError: renderError }));
186
189
  },
187
190
  isCompositionBeingEdited,
188
- });
191
+ }));
189
192
  const componentClass = classNames(resolvedProps.className, defaultResponsiveClass, attrs.className);
193
+ // Behavior assignment (BYOS): component_props binding whose key is a
194
+ // registered studio function → node click runs it (mirrors the live
195
+ // renderer; in edit mode the canvas overlay owns clicks, so this fires
196
+ // only in preview / interactive contexts).
190
197
  const attrsWithResponsiveClass = {
191
198
  ...attrs,
192
199
  ...namedResponsiveClasses,
193
200
  className: componentClass,
201
+ ...(boundFunctionName
202
+ ? {
203
+ onClick: (event) => {
204
+ attrs.onClick?.(event);
205
+ callStudioFunction(boundFunctionName);
206
+ },
207
+ }
208
+ : {}),
194
209
  };
195
210
  const WrapTag = typeof componentOptions.wrap === "string"
196
211
  ? componentOptions.wrap || "div"
@@ -228,11 +243,42 @@ const MemoizedElement = memo(Element, (prev, next) => {
228
243
  prev.renderError === next.renderError;
229
244
  return isSame;
230
245
  });
231
- const VisualComponent = ({ parent, nodes, slotUid, renderError, dataCslp = "", }) => {
246
+ /**
247
+ * A slot child's node path when it has no parent path yet (the root slot).
248
+ * Module-level so the root's context value is reference-stable across renders --
249
+ * a `= []` default would mint a fresh array every render and break the memo
250
+ * chain at the very top, where it matters most.
251
+ */
252
+ const EMPTY_NODE_PATH = [];
253
+ /**
254
+ * One child of a slot: its node contexts plus the element itself, memoised.
255
+ *
256
+ * This exists so an ancestor's re-render does not re-render every descendant.
257
+ * Three things have to hold at once for that, and they are why this is a
258
+ * component rather than inline JSX:
259
+ *
260
+ * - the element renders through `MemoizedElement`, not the bare `Element`;
261
+ * - `CurrentNodeContext`'s value is built with `useMemo`. It used to be an
262
+ * object literal inside the parent's `.map()`, where no hook can run, so
263
+ * every parent render minted a new context value and forced every descendant
264
+ * reading `useCurrentNode` to re-render -- which defeats memoising the
265
+ * element on its own;
266
+ * - `slotIndex` is a PROP, not a closure variable. A sibling whose position
267
+ * shifted (something was inserted earlier in the slot) therefore sees a prop
268
+ * change and re-renders, so its path context and `useIsNodeSelected` stay
269
+ * correct, while genuinely untouched siblings skip.
270
+ */
271
+ const SlotChild = memo(({ node, slotUid, slotIndex, parentNodePath, renderError, dataCslp, }) => {
272
+ const currentNodePath = useMemo(() => [...parentNodePath, [slotUid, slotIndex]], [parentNodePath, slotUid, slotIndex]);
273
+ const currentNode = useMemo(() => ({ currentNodeUid: node.uid, currentNodePath }), [node.uid, currentNodePath]);
274
+ return (jsx(CurrentNodeContext.Provider, { value: currentNode, children: jsx(SelectedNodeProvider, { children: jsx(MemoizedElement, { node: node, renderError: renderError, dataCslp: dataCslp }) }) }));
275
+ });
276
+ SlotChild.displayName = "SlotChild";
277
+ const VisualComponent = memo(({ parent, nodes, slotUid, renderError, dataCslp = "", }) => {
232
278
  const { uid } = parent;
233
279
  const isPreviewMode = usePreviewMode();
234
- const { isCompositionBeingEdited, componentRegistry, compositionPlacement } = useRenderer();
235
- const { currentNodePath: parentNodePath = [] } = useCurrentNode();
280
+ const { isCompositionBeingEdited, componentRegistry, compositionPlacement, } = useRenderer();
281
+ const { currentNodePath: parentNodePath = EMPTY_NODE_PATH } = useCurrentNode();
236
282
  const ref = useCallback((ref) => {
237
283
  if (isPreviewMode)
238
284
  return;
@@ -254,7 +300,8 @@ const VisualComponent = ({ parent, nodes, slotUid, renderError, dataCslp = "", }
254
300
  if (!shouldRenderSlot(componentRegistry, parent, nodes, isCompositionBeingEdited)) {
255
301
  const children = nodes?.map((node, idx) => {
256
302
  const key = node.uid;
257
- const currentNodePath = [...parentNodePath, [slotUid, idx]];
303
+ // Stays in the parent's loop rather than moving into SlotChild: these run
304
+ // for EVERY child including hidden ones, which are never rendered at all.
258
305
  if (isCompositionBeingEdited) {
259
306
  NODE_TO_PATH_NODE.set(node, [slotUid, idx]);
260
307
  NODE_TO_PARENT.set(node, parent);
@@ -262,18 +309,13 @@ const VisualComponent = ({ parent, nodes, slotUid, renderError, dataCslp = "", }
262
309
  if (node.metadata.visible === false) {
263
310
  return;
264
311
  }
265
- return (jsx(CurrentNodeContext.Provider, { value: {
266
- currentNodeUid: key,
267
- currentNodePath: currentNodePath,
268
- }, children: jsx(SelectedNodeProvider, { children: jsx(Element, { node: node, renderError: renderError, dataCslp: dataCslp }, key) }) }, key));
312
+ return (jsx(SlotChild, { node: node, slotUid: slotUid, slotIndex: idx, parentNodePath: parentNodePath, renderError: renderError, dataCslp: dataCslp }, key));
269
313
  });
270
314
  return jsx(Fragment, { children: children });
271
315
  }
272
- // Compute hint for repeater slots bound to modular blocks or references
273
- const hint = parent.type === INTERNAL_COMPONENTS_NAMES.REPEATER &&
274
- parent.metadata?.repeaterBindingFieldType
275
- ? "It is recommended to drop a condition block inside the repeater to handle Modular Blocks & References."
276
- : undefined;
316
+ // Placeholder text for this empty slot: the repeater advice, or the condition
317
+ // hint when this slot is a condition block's drop well. See `getSlotHint`.
318
+ const hint = getSlotHint(parent);
277
319
  // Detect if this is a page slot for welcome message
278
320
  const isPageSlot = parent.type === INTERNAL_COMPONENTS_NAMES.PAGE;
279
321
  if (!isCompositionBeingEdited || isPreviewMode) {
@@ -286,7 +328,8 @@ const VisualComponent = ({ parent, nodes, slotUid, renderError, dataCslp = "", }
286
328
  ref,
287
329
  };
288
330
  return (jsx(Slot, { studioAttributes: internalAttributes, slotUid: slotUid, hint: hint, isRootSlot: isPageSlot, compositionPlacement: compositionPlacement }));
289
- };
331
+ });
332
+ VisualComponent.displayName = "VisualComponent";
290
333
 
291
334
  export { MemoizedElement as default };
292
335
  //# sourceMappingURL=Element.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Element.js","sources":["../../src/components/Element.tsx"],"sourcesContent":["import {\n COMPOSABLE_DATA_ATTRIBUTES,\n COMPOSABLE_STUDIO_EMITTED_EVENTS,\n composableStudioEventEmitter,\n ELEMENT_TO_NODE,\n getJSONRTE,\n loadGoogleFont,\n NODE_TO_ELEMENT,\n NODE_TO_PARENT,\n NODE_TO_PATH_NODE,\n} from \"@contentstack/studio-client\";\nimport { lightSdk, sdk, handleNodeStyles } from \"@contentstack/studio-core\";\nimport { Node, Path, SlotUid } from \"@contentstack/studio-internal\";\nimport { HiddenElementNotificationEventData } from \"@contentstack/studio-messenger\";\nimport {\n CurrentNodeContext,\n SectionInstanceSlotsCtxProvider,\n} from \"@contentstack/studio-react-components/contexts\";\nimport {\n useCurrentNode,\n useData,\n} from \"@contentstack/studio-react-components/hooks\";\nimport {\n clearReportedBindingErrorsForNode,\n getBindingString,\n getCslpTag,\n getRepeaterBinding,\n GetSlotsParams,\n resolveMetadataBindings,\n retrievePropValue,\n INTERNAL_COMPONENTS_NAMES,\n ComponentRegistry,\n} from \"@contentstack/studio-registry\";\nimport classNames from \"classnames\";\nimport {\n memo,\n ReactNode,\n RefCallback,\n useCallback,\n useEffect,\n useRef,\n} from \"react\";\nimport { BuilderNodeInternalAttributes, StudioComponentRef } from \"../types\";\nimport { RendererErrorComponent } from \"./ErrorComponent\";\nimport { TextPlaceholder } from \"./TextPlaceholder\";\nimport { RendererErrorBoundary } from \"./RendererErrorBoundary\";\nimport { shouldRenderSlot } from \"../utils\";\nimport Slot from \"./Slot\";\nimport { usePreviewMode, useRenderer } from \"../hooks\";\nimport { SelectedNodeProvider } from \"../contexts/providers/selected-node.provider\";\n\nconst Element = ({\n node,\n renderError,\n dataCslp,\n}: {\n node: Node;\n renderError?: React.ComponentType<{ error: Error }>;\n dataCslp?: string;\n}): React.ReactNode => {\n const isPreviewMode = usePreviewMode();\n const data = useData();\n const { attrs = {}, styles = {}, uid } = node;\n const { isCompositionBeingEdited, componentRegistry } = useRenderer();\n resolveMetadataBindings(node, data);\n const reference = useRef<StudioComponentRef>(null);\n\n // handles the hidden element notification event\n useEffect(() => {\n const hiddenElementNotificationEventListener = (\n data: HiddenElementNotificationEventData,\n ) => {\n if (!isCompositionBeingEdited) return;\n\n if (data.uid !== node.uid && data.uid !== \"__all__\") return;\n\n if (reference.current) {\n if (data.action === \"open\") {\n if (\n \"open\" in reference.current &&\n typeof reference.current.open === \"function\"\n ) {\n reference.current.open();\n } else {\n // Open method is optional - only components with _hiddenElementNotification: true need it\n console.debug(\n \"Open method not available on this component reference.\",\n );\n }\n } else {\n if (\n \"close\" in reference.current &&\n typeof reference.current.close === \"function\"\n ) {\n reference.current.close();\n } else {\n // Close method is optional - only components with _hiddenElementNotification: true need it\n console.debug(\n \"Close method not available on this component reference.\",\n );\n }\n }\n }\n };\n\n composableStudioEventEmitter.on(\n COMPOSABLE_STUDIO_EMITTED_EVENTS.HIDDEN_ELEMENT_NOTIFICATION,\n hiddenElementNotificationEventListener,\n );\n\n return () => {\n composableStudioEventEmitter.off(\n COMPOSABLE_STUDIO_EMITTED_EVENTS.HIDDEN_ELEMENT_NOTIFICATION,\n hiddenElementNotificationEventListener,\n );\n };\n }, []);\n\n // When this node leaves the tree (or its uid changes), retract any binding-\n // mismatch errors we reported for it. retrievePropValue's in-render retraction\n // can only fire while the node still renders, so without this an unmounted\n // node's \"Data Mismatch Found\" badge would latch and its tracking entry leak.\n useEffect(() => {\n if (!isCompositionBeingEdited) return;\n return () => clearReportedBindingErrorsForNode(node.uid);\n }, [node.uid, isCompositionBeingEdited]);\n\n const ref: RefCallback<StudioComponentRef> = useCallback(\n (ref) => {\n // NOTE: if you change this condition, make sure to update the internal attributes above\n if (isCompositionBeingEdited && !isPreviewMode) {\n reference.current = ref;\n let refElement: HTMLElement | null = null;\n if (ref instanceof HTMLElement) {\n refElement = ref;\n } else if (ref) {\n if (\"element\" in ref) {\n refElement = ref.element ?? null;\n } else {\n // TODO: Link to documentation explaining how to use the element property\n console.error(\n \"Reference is not a valid object. It should have a element property.\",\n );\n }\n }\n\n if (refElement && node) {\n ELEMENT_TO_NODE.set(refElement, node);\n NODE_TO_ELEMENT.set(node, refElement);\n } else if (!refElement) {\n const element = NODE_TO_ELEMENT.get(node);\n if (element) {\n ELEMENT_TO_NODE.delete(element);\n }\n if (NODE_TO_ELEMENT.has(node)) {\n NODE_TO_ELEMENT.delete(node);\n }\n }\n }\n },\n [node],\n );\n\n // Node style extraction + Google-font side effect. These previously lived\n // inside the try below, AFTER the early `return null` for an unregistered\n // component — so the hook count varied between renders (\"Rendered more hooks\n // than during the previous render\") whenever a node's component wasn't\n // registered yet on the first paint, or `componentRegistry` was momentarily\n // absent. React requires hooks to be unconditional, so they run here before\n // ANY early return. handleNodeStyles is a pure style extractor (no hooks/SDK).\n const [\n defaultResponsiveClass,\n namedResponsiveClasses,\n fontFamilies,\n fontVariants,\n ] = handleNodeStyles(styles, uid);\n\n // TODO: @RavenColEvol, can we memoize this?\n useEffect(() => {\n fontFamilies.forEach((fontFamily) => {\n loadGoogleFont(fontFamily, fontVariants.get(fontFamily)!, styles, uid);\n });\n }, [fontFamilies, styles, uid]);\n\n // Every hook above runs unconditionally; the early returns below are now safe.\n if (!componentRegistry) {\n return <RendererErrorComponent reason=\"SDK is not initialized\" />;\n }\n let internalAttributes: BuilderNodeInternalAttributes = {};\n\n // NOTE: if you change this condition, make sure to update the ref callback above\n if (isCompositionBeingEdited && !isPreviewMode) {\n internalAttributes = {\n [COMPOSABLE_DATA_ATTRIBUTES.BUILDER]: true,\n [COMPOSABLE_DATA_ATTRIBUTES.NODE]: true,\n [COMPOSABLE_DATA_ATTRIBUTES.ID]: uid,\n ref,\n };\n }\n\n try {\n const componentOptions = componentRegistry.getComponentByNode(node, false);\n if (!componentOptions) return null;\n const Component = componentOptions.component;\n\n // RSC client-reference safeguard (see studio-react/src/renderer/index.tsx).\n // Editor normally only runs in-browser, but consumers may render the\n // composition tree from a server entry; mirror the renderer's guard so\n // SSR never invokes a client-reference proxy.\n const isClientReference =\n (Component as any)?.$$typeof === Symbol.for(\"react.client.reference\");\n if (isClientReference && typeof window === \"undefined\") {\n const PlaceholderTag = (componentOptions.wrap as any) || \"div\";\n return (\n <PlaceholderTag\n {...internalAttributes}\n data-cs-defer-builtin={node.type}\n suppressHydrationWarning\n />\n );\n }\n\n if (dataCslp) {\n internalAttributes[\"data-cslp\"] = dataCslp;\n }\n const config =\n lightSdk?.internal?.getConfig() ?? sdk?.internal?.getConfig();\n\n if (node.metadata.repeaterWrapper && config?.cslp.appendTags) {\n const binding = getRepeaterBinding(node);\n if (binding) {\n const bindingPath = getBindingString(binding);\n const cslpValue = getCslpTag({ bindedField: bindingPath, data });\n if (cslpValue[\"data-cslp\"]) {\n internalAttributes[\"data-cslp\"] = cslpValue[\"data-cslp\"];\n }\n }\n }\n const resolvedProps = retrievePropValue<string, React.ReactNode>({\n data,\n defaultSlot: \"I am a default slot\", // TODO: this should be an component\n componentOptions: componentOptions,\n node: node,\n placeholders: {\n string: (placeholder?: string) => (\n <TextPlaceholder placeholder={placeholder} />\n ),\n },\n cslp: {\n appendTags: config?.cslp.appendTags ?? false,\n },\n nodeUid: uid,\n jsonRTE: getJSONRTE(),\n getSlots({ slots, parent, slotUid }: GetSlotsParams) {\n return (\n <VisualComponent\n parent={parent}\n nodes={slots}\n slotUid={slotUid}\n renderError={renderError}\n />\n );\n },\n isCompositionBeingEdited,\n });\n\n const componentClass = classNames(\n resolvedProps.className,\n defaultResponsiveClass,\n attrs.className,\n );\n\n const attrsWithResponsiveClass = {\n ...attrs,\n ...namedResponsiveClasses,\n className: componentClass,\n };\n\n const WrapTag =\n typeof componentOptions.wrap === \"string\"\n ? componentOptions.wrap || \"div\"\n : \"div\";\n\n // For section-composition nodes, expose the page-side instance uid,\n // its filled slots map, AND the page-level outer data (captured here\n // BEFORE SectionCompositionProvider downstream scopes `template` to\n // the section's selected_field). section-slot placeholders inside the\n // section's body read this context to transclude filled children\n // under the page's data context — so bindings authored on the dropped\n // components resolve against the page's preview entry / additional\n // entries / queries as if the components were on the page directly.\n const wrapWithSectionInstanceCtx = (children: ReactNode) =>\n node.type === \"section-composition\" ? (\n <SectionInstanceSlotsCtxProvider\n value={{\n sectionInstanceUid: uid,\n sectionNode: node,\n slotsMap: (node.slots ?? {}) as Record<string, any[]>,\n pageOuterData: data,\n }}\n >\n {children}\n </SectionInstanceSlotsCtxProvider>\n ) : (\n children\n );\n\n if (componentOptions.wrap) {\n return (\n <RendererErrorBoundary renderError={renderError}>\n <WrapTag {...internalAttributes}>\n {wrapWithSectionInstanceCtx(\n <Component {...attrsWithResponsiveClass} {...resolvedProps} />,\n )}\n </WrapTag>\n </RendererErrorBoundary>\n );\n }\n return (\n <RendererErrorBoundary renderError={renderError}>\n {wrapWithSectionInstanceCtx(\n <Component\n studioAttributes={internalAttributes}\n {...attrsWithResponsiveClass}\n {...resolvedProps}\n />,\n )}\n </RendererErrorBoundary>\n );\n } catch (error) {\n if (error instanceof Error) {\n console.error(\"Error while rendering component\", error);\n return (\n <RendererErrorComponent\n builderAttributes={internalAttributes}\n reason={error.message}\n />\n );\n }\n throw error;\n }\n};\n\nconst MemoizedElement = memo(Element, (prev, next) => {\n const isSame =\n prev.node === next.node &&\n prev.dataCslp === next.dataCslp &&\n prev.renderError === next.renderError;\n return isSame;\n});\n\nconst VisualComponent = ({\n parent,\n nodes,\n slotUid,\n renderError,\n dataCslp = \"\",\n}: {\n parent: Node;\n nodes: Node[];\n slotUid: SlotUid;\n renderError?: React.ComponentType<{ error: Error }>;\n dataCslp?: string;\n}) => {\n const { uid } = parent;\n const isPreviewMode = usePreviewMode();\n const { isCompositionBeingEdited, componentRegistry, compositionPlacement } =\n useRenderer();\n const { currentNodePath: parentNodePath = [] } = useCurrentNode();\n const ref = useCallback(\n (ref: HTMLElement) => {\n if (isPreviewMode) return;\n if (ref && parent) {\n ELEMENT_TO_NODE.set(ref, parent);\n NODE_TO_ELEMENT.set(parent, ref);\n } else if (!ref) {\n // When component unmounts, remove references safely\n const element = NODE_TO_ELEMENT.get(parent);\n if (element) {\n ELEMENT_TO_NODE.delete(element);\n }\n if (NODE_TO_ELEMENT.has(parent)) {\n NODE_TO_ELEMENT.delete(parent);\n }\n }\n },\n [parent],\n );\n if (\n !shouldRenderSlot(\n componentRegistry!,\n parent,\n nodes,\n isCompositionBeingEdited,\n )\n ) {\n const children = nodes?.map((node, idx) => {\n const key = node.uid;\n const currentNodePath: Path = [...parentNodePath, [slotUid, idx]];\n\n if (isCompositionBeingEdited) {\n NODE_TO_PATH_NODE.set(node, [slotUid, idx]);\n NODE_TO_PARENT.set(node, parent);\n }\n\n if (node.metadata.visible === false) {\n return;\n }\n return (\n <CurrentNodeContext.Provider\n key={key}\n value={{\n currentNodeUid: key,\n currentNodePath: currentNodePath,\n }}\n >\n <SelectedNodeProvider>\n <Element\n key={key}\n node={node}\n renderError={renderError}\n dataCslp={dataCslp}\n />\n </SelectedNodeProvider>\n </CurrentNodeContext.Provider>\n );\n });\n\n return <>{children}</>;\n }\n\n // Compute hint for repeater slots bound to modular blocks or references\n const hint =\n parent.type === INTERNAL_COMPONENTS_NAMES.REPEATER &&\n parent.metadata?.repeaterBindingFieldType\n ? \"It is recommended to drop a condition block inside the repeater to handle Modular Blocks & References.\"\n : undefined;\n\n // Detect if this is a page slot for welcome message\n const isPageSlot = parent.type === INTERNAL_COMPONENTS_NAMES.PAGE;\n\n if (!isCompositionBeingEdited || isPreviewMode) {\n return (\n <Slot\n studioAttributes={{}}\n slotUid={slotUid}\n hint={hint}\n isRootSlot={isPageSlot}\n compositionPlacement={compositionPlacement}\n />\n );\n }\n const internalAttributes: BuilderNodeInternalAttributes = {\n [COMPOSABLE_DATA_ATTRIBUTES.BUILDER]: true,\n [COMPOSABLE_DATA_ATTRIBUTES.NODE]: true,\n [COMPOSABLE_DATA_ATTRIBUTES.ID]: uid,\n ref,\n };\n return (\n <Slot\n studioAttributes={internalAttributes}\n slotUid={slotUid}\n hint={hint}\n isRootSlot={isPageSlot}\n compositionPlacement={compositionPlacement}\n />\n );\n};\n\nexport default MemoizedElement;\n"],"names":["_jsx","_Fragment"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,MAAM,OAAO,GAAG,CAAC,EACf,IAAI,EACJ,WAAW,EACX,QAAQ,GAKT,KAAqB;AACpB,IAAA,MAAM,aAAa,GAAG,cAAc,EAAE;AACtC,IAAA,MAAM,IAAI,GAAG,OAAO,EAAE;A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.tsx"],"sourcesContent":["import {\n COMPOSABLE_DATA_ATTRIBUTES,\n COMPOSABLE_STUDIO_EMITTED_EVENTS,\n composableStudioEventEmitter,\n ELEMENT_TO_NODE,\n getJSONRTE,\n loadGoogleFont,\n NODE_TO_ELEMENT,\n NODE_TO_PARENT,\n NODE_TO_PATH_NODE,\n} from \"@contentstack/studio-client\";\nimport { lightSdk, sdk, handleNodeStyles } from \"@contentstack/studio-core\";\nimport { Node, Path, SlotUid } from \"@contentstack/studio-internal\";\nimport { HiddenElementNotificationEventData } from \"@contentstack/studio-messenger\";\nimport {\n CurrentNodeContext,\n SectionInstanceSlotsCtxProvider,\n} from \"@contentstack/studio-react-components/contexts\";\nimport {\n useCurrentNode,\n useData,\n useNodeStateBindings,\n useNodeBoundFunctionName,\n} from \"@contentstack/studio-react-components/hooks\";\nimport {\n clearReportedBindingErrorsForNode,\n getBindingString,\n getCslpTag,\n getRepeaterBinding,\n GetSlotsParams,\n resolveMetadataBindings,\n retrievePropValue,\n wrapActionProps,\n callStudioFunction,\n INTERNAL_COMPONENTS_NAMES,\n ComponentRegistry,\n} from \"@contentstack/studio-registry\";\nimport classNames from \"classnames\";\nimport {\n memo,\n ReactNode,\n RefCallback,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n} from \"react\";\nimport { BuilderNodeInternalAttributes, StudioComponentRef } from \"../types\";\nimport { RendererErrorComponent } from \"./ErrorComponent\";\nimport { TextPlaceholder } from \"./TextPlaceholder\";\nimport { RendererErrorBoundary } from \"./RendererErrorBoundary\";\nimport { getSlotHint, shouldRenderSlot } from \"../utils\";\nimport Slot from \"./Slot\";\nimport { usePreviewMode } from \"../hooks/use-preview-mode.hook\";\nimport { useRenderer } from \"../hooks/use-renderer.hook\";\nimport { SelectedNodeProvider } from \"../contexts/providers/selected-node.provider\";\n\nconst Element = ({\n node,\n renderError,\n dataCslp,\n}: {\n node: Node;\n renderError?: React.ComponentType<{ error: Error }>;\n dataCslp?: string;\n}): React.ReactNode => {\n const isPreviewMode = usePreviewMode();\n const pageData = useData();\n\n // Canvas parity with the production renderer's BaseElement: declared state\n // variables bound via component_props resolve from the shared BYOS state\n // store. Per-node subscription — only this node re-renders when one of ITS\n // bound state keys changes.\n const stateSnapshot = useNodeStateBindings(node);\n // Behavior assignment (BYOS): reactive — re-reads when the app registers\n // functions (commonly after this node's first render).\n const boundFunctionName = useNodeBoundFunctionName(node);\n const data = useMemo(\n () =>\n stateSnapshot\n ? {\n ...pageData,\n component_props: {\n ...pageData?.component_props,\n ...stateSnapshot,\n },\n }\n : pageData,\n [pageData, stateSnapshot],\n );\n\n const { attrs = {}, styles = {}, uid } = node;\n const { isCompositionBeingEdited, componentRegistry } = useRenderer();\n resolveMetadataBindings(node, data);\n const reference = useRef<StudioComponentRef>(null);\n\n // handles the hidden element notification event\n useEffect(() => {\n const hiddenElementNotificationEventListener = (\n data: HiddenElementNotificationEventData,\n ) => {\n if (!isCompositionBeingEdited) return;\n\n if (data.uid !== node.uid && data.uid !== \"__all__\") return;\n\n if (reference.current) {\n if (data.action === \"open\") {\n if (\n \"open\" in reference.current &&\n typeof reference.current.open === \"function\"\n ) {\n reference.current.open();\n } else {\n // Open method is optional - only components with _hiddenElementNotification: true need it\n console.debug(\n \"Open method not available on this component reference.\",\n );\n }\n } else {\n if (\n \"close\" in reference.current &&\n typeof reference.current.close === \"function\"\n ) {\n reference.current.close();\n } else {\n // Close method is optional - only components with _hiddenElementNotification: true need it\n console.debug(\n \"Close method not available on this component reference.\",\n );\n }\n }\n }\n };\n\n composableStudioEventEmitter.on(\n COMPOSABLE_STUDIO_EMITTED_EVENTS.HIDDEN_ELEMENT_NOTIFICATION,\n hiddenElementNotificationEventListener,\n );\n\n return () => {\n composableStudioEventEmitter.off(\n COMPOSABLE_STUDIO_EMITTED_EVENTS.HIDDEN_ELEMENT_NOTIFICATION,\n hiddenElementNotificationEventListener,\n );\n };\n }, []);\n\n // When this node leaves the tree (or its uid changes), retract any binding-\n // mismatch errors we reported for it. retrievePropValue's in-render retraction\n // can only fire while the node still renders, so without this an unmounted\n // node's \"Data Mismatch Found\" badge would latch and its tracking entry leak.\n useEffect(() => {\n if (!isCompositionBeingEdited) return;\n return () => clearReportedBindingErrorsForNode(node.uid);\n }, [node.uid, isCompositionBeingEdited]);\n\n const ref: RefCallback<StudioComponentRef> = useCallback(\n (ref) => {\n // NOTE: if you change this condition, make sure to update the internal attributes above\n if (isCompositionBeingEdited && !isPreviewMode) {\n reference.current = ref;\n let refElement: HTMLElement | null = null;\n if (ref instanceof HTMLElement) {\n refElement = ref;\n } else if (ref) {\n if (\"element\" in ref) {\n refElement = ref.element ?? null;\n } else {\n // TODO: Link to documentation explaining how to use the element property\n console.error(\n \"Reference is not a valid object. It should have a element property.\",\n );\n }\n }\n\n if (refElement && node) {\n ELEMENT_TO_NODE.set(refElement, node);\n NODE_TO_ELEMENT.set(node, refElement);\n } else if (!refElement) {\n const element = NODE_TO_ELEMENT.get(node);\n if (element) {\n ELEMENT_TO_NODE.delete(element);\n }\n if (NODE_TO_ELEMENT.has(node)) {\n NODE_TO_ELEMENT.delete(node);\n }\n }\n }\n },\n [node],\n );\n\n // Node style extraction + Google-font side effect. These previously lived\n // inside the try below, AFTER the early `return null` for an unregistered\n // component — so the hook count varied between renders (\"Rendered more hooks\n // than during the previous render\") whenever a node's component wasn't\n // registered yet on the first paint, or `componentRegistry` was momentarily\n // absent. React requires hooks to be unconditional, so they run here before\n // ANY early return. handleNodeStyles is a pure style extractor (no hooks/SDK).\n const [\n defaultResponsiveClass,\n namedResponsiveClasses,\n fontFamilies,\n fontVariants,\n ] = handleNodeStyles(styles, uid);\n\n // TODO: @RavenColEvol, can we memoize this?\n useEffect(() => {\n fontFamilies.forEach((fontFamily) => {\n loadGoogleFont(fontFamily, fontVariants.get(fontFamily)!, styles, uid);\n });\n }, [fontFamilies, styles, uid]);\n\n // Every hook above runs unconditionally; the early returns below are now safe.\n if (!componentRegistry) {\n return <RendererErrorComponent reason=\"SDK is not initialized\" />;\n }\n let internalAttributes: BuilderNodeInternalAttributes = {};\n\n // NOTE: if you change this condition, make sure to update the ref callback above\n if (isCompositionBeingEdited && !isPreviewMode) {\n internalAttributes = {\n [COMPOSABLE_DATA_ATTRIBUTES.BUILDER]: true,\n [COMPOSABLE_DATA_ATTRIBUTES.NODE]: true,\n [COMPOSABLE_DATA_ATTRIBUTES.ID]: uid,\n ref,\n };\n }\n\n try {\n const componentOptions = componentRegistry.getComponentByNode(node, false);\n if (!componentOptions) return null;\n const Component = componentOptions.component;\n\n // RSC client-reference safeguard (see studio-react/src/renderer/index.tsx).\n // Editor normally only runs in-browser, but consumers may render the\n // composition tree from a server entry; mirror the renderer's guard so\n // SSR never invokes a client-reference proxy.\n const isClientReference =\n (Component as any)?.$$typeof === Symbol.for(\"react.client.reference\");\n if (isClientReference && typeof window === \"undefined\") {\n const PlaceholderTag = (componentOptions.wrap as any) || \"div\";\n return (\n <PlaceholderTag\n {...internalAttributes}\n data-cs-defer-builtin={node.type}\n suppressHydrationWarning\n />\n );\n }\n\n if (dataCslp) {\n internalAttributes[\"data-cslp\"] = dataCslp;\n }\n const config =\n lightSdk?.internal?.getConfig() ?? sdk?.internal?.getConfig();\n\n if (node.metadata.repeaterWrapper && config?.cslp.appendTags) {\n const binding = getRepeaterBinding(node);\n if (binding) {\n const bindingPath = getBindingString(binding);\n const cslpValue = getCslpTag({ bindedField: bindingPath, data });\n if (cslpValue[\"data-cslp\"]) {\n internalAttributes[\"data-cslp\"] = cslpValue[\"data-cslp\"];\n }\n }\n }\n const resolvedProps = wrapActionProps(\n componentOptions.props,\n retrievePropValue<string, React.ReactNode>({\n data,\n defaultSlot: \"I am a default slot\", // TODO: this should be an component\n componentOptions: componentOptions,\n node: node,\n placeholders: {\n string: (placeholder?: string) => (\n <TextPlaceholder placeholder={placeholder} />\n ),\n },\n cslp: {\n appendTags: config?.cslp.appendTags ?? false,\n },\n nodeUid: uid,\n jsonRTE: getJSONRTE(),\n getSlots({ slots, parent, slotUid }: GetSlotsParams) {\n return (\n <VisualComponent\n parent={parent}\n nodes={slots}\n slotUid={slotUid}\n renderError={renderError}\n />\n );\n },\n isCompositionBeingEdited,\n }),\n );\n\n const componentClass = classNames(\n resolvedProps.className,\n defaultResponsiveClass,\n attrs.className,\n );\n\n // Behavior assignment (BYOS): component_props binding whose key is a\n // registered studio function → node click runs it (mirrors the live\n // renderer; in edit mode the canvas overlay owns clicks, so this fires\n // only in preview / interactive contexts).\n const attrsWithResponsiveClass = {\n ...attrs,\n ...namedResponsiveClasses,\n className: componentClass,\n ...(boundFunctionName\n ? {\n onClick: (event: React.MouseEvent) => {\n (attrs as { onClick?: (e: React.MouseEvent) => void }).onClick?.(\n event,\n );\n callStudioFunction(boundFunctionName);\n },\n }\n : {}),\n };\n\n const WrapTag =\n typeof componentOptions.wrap === \"string\"\n ? componentOptions.wrap || \"div\"\n : \"div\";\n\n // For section-composition nodes, expose the page-side instance uid,\n // its filled slots map, AND the page-level outer data (captured here\n // BEFORE SectionCompositionProvider downstream scopes `template` to\n // the section's selected_field). section-slot placeholders inside the\n // section's body read this context to transclude filled children\n // under the page's data context — so bindings authored on the dropped\n // components resolve against the page's preview entry / additional\n // entries / queries as if the components were on the page directly.\n const wrapWithSectionInstanceCtx = (children: ReactNode) =>\n node.type === \"section-composition\" ? (\n <SectionInstanceSlotsCtxProvider\n value={{\n sectionInstanceUid: uid,\n sectionNode: node,\n slotsMap: (node.slots ?? {}) as Record<string, any[]>,\n pageOuterData: data,\n }}\n >\n {children}\n </SectionInstanceSlotsCtxProvider>\n ) : (\n children\n );\n\n if (componentOptions.wrap) {\n return (\n <RendererErrorBoundary renderError={renderError}>\n <WrapTag {...internalAttributes}>\n {wrapWithSectionInstanceCtx(\n <Component {...attrsWithResponsiveClass} {...resolvedProps} />,\n )}\n </WrapTag>\n </RendererErrorBoundary>\n );\n }\n return (\n <RendererErrorBoundary renderError={renderError}>\n {wrapWithSectionInstanceCtx(\n <Component\n studioAttributes={internalAttributes}\n {...attrsWithResponsiveClass}\n {...resolvedProps}\n />,\n )}\n </RendererErrorBoundary>\n );\n } catch (error) {\n if (error instanceof Error) {\n console.error(\"Error while rendering component\", error);\n return (\n <RendererErrorComponent\n builderAttributes={internalAttributes}\n reason={error.message}\n />\n );\n }\n throw error;\n }\n};\n\nconst MemoizedElement = memo(Element, (prev, next) => {\n const isSame =\n prev.node === next.node &&\n prev.dataCslp === next.dataCslp &&\n prev.renderError === next.renderError;\n return isSame;\n});\n\n/**\n * A slot child's node path when it has no parent path yet (the root slot).\n * Module-level so the root's context value is reference-stable across renders --\n * a `= []` default would mint a fresh array every render and break the memo\n * chain at the very top, where it matters most.\n */\nconst EMPTY_NODE_PATH: Path = [];\n\n/**\n * One child of a slot: its node contexts plus the element itself, memoised.\n *\n * This exists so an ancestor's re-render does not re-render every descendant.\n * Three things have to hold at once for that, and they are why this is a\n * component rather than inline JSX:\n *\n * - the element renders through `MemoizedElement`, not the bare `Element`;\n * - `CurrentNodeContext`'s value is built with `useMemo`. It used to be an\n * object literal inside the parent's `.map()`, where no hook can run, so\n * every parent render minted a new context value and forced every descendant\n * reading `useCurrentNode` to re-render -- which defeats memoising the\n * element on its own;\n * - `slotIndex` is a PROP, not a closure variable. A sibling whose position\n * shifted (something was inserted earlier in the slot) therefore sees a prop\n * change and re-renders, so its path context and `useIsNodeSelected` stay\n * correct, while genuinely untouched siblings skip.\n */\nconst SlotChild = memo(\n ({\n node,\n slotUid,\n slotIndex,\n parentNodePath,\n renderError,\n dataCslp,\n }: {\n node: Node;\n slotUid: SlotUid;\n slotIndex: number;\n parentNodePath: Path;\n renderError?: React.ComponentType<{ error: Error }>;\n dataCslp?: string;\n }) => {\n const currentNodePath = useMemo<Path>(\n () => [...parentNodePath, [slotUid, slotIndex]],\n [parentNodePath, slotUid, slotIndex],\n );\n const currentNode = useMemo(\n () => ({ currentNodeUid: node.uid, currentNodePath }),\n [node.uid, currentNodePath],\n );\n\n return (\n <CurrentNodeContext.Provider value={currentNode}>\n <SelectedNodeProvider>\n <MemoizedElement\n node={node}\n renderError={renderError}\n dataCslp={dataCslp}\n />\n </SelectedNodeProvider>\n </CurrentNodeContext.Provider>\n );\n },\n);\nSlotChild.displayName = \"SlotChild\";\n\nconst VisualComponent = memo(\n ({\n parent,\n nodes,\n slotUid,\n renderError,\n dataCslp = \"\",\n }: {\n parent: Node;\n nodes: Node[];\n slotUid: SlotUid;\n renderError?: React.ComponentType<{ error: Error }>;\n dataCslp?: string;\n }) => {\n const { uid } = parent;\n const isPreviewMode = usePreviewMode();\n const {\n isCompositionBeingEdited,\n componentRegistry,\n compositionPlacement,\n } = useRenderer();\n const { currentNodePath: parentNodePath = EMPTY_NODE_PATH } =\n useCurrentNode();\n const ref = useCallback(\n (ref: HTMLElement) => {\n if (isPreviewMode) return;\n if (ref && parent) {\n ELEMENT_TO_NODE.set(ref, parent);\n NODE_TO_ELEMENT.set(parent, ref);\n } else if (!ref) {\n // When component unmounts, remove references safely\n const element = NODE_TO_ELEMENT.get(parent);\n if (element) {\n ELEMENT_TO_NODE.delete(element);\n }\n if (NODE_TO_ELEMENT.has(parent)) {\n NODE_TO_ELEMENT.delete(parent);\n }\n }\n },\n [parent],\n );\n if (\n !shouldRenderSlot(\n componentRegistry!,\n parent,\n nodes,\n isCompositionBeingEdited,\n )\n ) {\n const children = nodes?.map((node, idx) => {\n const key = node.uid;\n\n // Stays in the parent's loop rather than moving into SlotChild: these run\n // for EVERY child including hidden ones, which are never rendered at all.\n if (isCompositionBeingEdited) {\n NODE_TO_PATH_NODE.set(node, [slotUid, idx]);\n NODE_TO_PARENT.set(node, parent);\n }\n\n if (node.metadata.visible === false) {\n return;\n }\n return (\n <SlotChild\n key={key}\n node={node}\n slotUid={slotUid}\n slotIndex={idx}\n parentNodePath={parentNodePath}\n renderError={renderError}\n dataCslp={dataCslp}\n />\n );\n });\n\n return <>{children}</>;\n }\n\n // Placeholder text for this empty slot: the repeater advice, or the condition\n // hint when this slot is a condition block's drop well. See `getSlotHint`.\n const hint = getSlotHint(parent);\n\n // Detect if this is a page slot for welcome message\n const isPageSlot = parent.type === INTERNAL_COMPONENTS_NAMES.PAGE;\n\n if (!isCompositionBeingEdited || isPreviewMode) {\n return (\n <Slot\n studioAttributes={{}}\n slotUid={slotUid}\n hint={hint}\n isRootSlot={isPageSlot}\n compositionPlacement={compositionPlacement}\n />\n );\n }\n const internalAttributes: BuilderNodeInternalAttributes = {\n [COMPOSABLE_DATA_ATTRIBUTES.BUILDER]: true,\n [COMPOSABLE_DATA_ATTRIBUTES.NODE]: true,\n [COMPOSABLE_DATA_ATTRIBUTES.ID]: uid,\n ref,\n };\n return (\n <Slot\n studioAttributes={internalAttributes}\n slotUid={slotUid}\n hint={hint}\n isRootSlot={isPageSlot}\n compositionPlacement={compositionPlacement}\n />\n );\n },\n);\nVisualComponent.displayName = \"VisualComponent\";\n\nexport default MemoizedElement;\n"],"names":["_jsx","_Fragment"],"mappings":";;;;;;;;;;;;;;;;;AAyDA,MAAM,OAAO,GAAG,CAAC,EACf,IAAI,EACJ,WAAW,EACX,QAAQ,GAKT,KAAqB;AACpB,IAAA,MAAM,aAAa,GAAG,cAAc,EAAE;AACtC,IAAA,MAAM,QAAQ,GAAG,OAAO,EAAE;;;;;AAM1B,IAAA,MAAM,aAAa,GAAG,oBAAoB,CAAC,IAAI,CAAC;;;AAGhD,IAAA,MAAM,iBAAiB,GAAG,wBAAwB,CAAC,IAAI,CAAC;AACxD,IAAA,MAAM,IAAI,GAAG,OAAO,CAClB,MACE;AACE,UAAE;AACE,YAAA,GAAG,QAAQ;AACX,YAAA,eAAe,EAAE;gBACf,GAAG,QAAQ,EAAE,eAAe;AAC5B,gBAAA,GAAG,aAAa;AACjB,aAAA;AACF;UACD,QAAQ,EACd,CAAC,QAAQ,EAAE,aAAa,CAAC,CAC1B;AAED,IAAA,MAAM,EAAE,KAAK,GAAG,EAAE,EAAE,MAAM,GAAG,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI;IAC7C,MAAM,EAAE,wBAA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AAI,CAAC,wBAAwB,IAAI,aAAa,EAAE;QAC9C,QACED,GAAA,CAAC,IAAI,EAAA,EACH,gBAAgB,EAAE,EAAE,EACpB,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,UAAU,EACtB,oBAAoB,EAAE,oBAAoB,EAAA,CAC1C;IAEN;AACA,IAAA,MAAM,kBAAkB,GAAkC;AACxD,QAAA,CAAC,0BAA0B,CAAC,OAAO,GAAG,IAAI;AAC1C,QAAA,CAAC,0BAA0B,CAAC,IAAI,GAAG,IAAI;AACvC,QAAA,CAAC,0BAA0B,CAAC,EAAE,GAAG,GAAG;QACpC,GAAG;KACJ;IACD,QACEA,GAAA,CAAC,IAAI,EAAA,EACH,gBAAgB,EAAE,kBAAkB,EACpC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,UAAU,EACtB,oBAAoB,EAAE,oBAAoB,EAAA,CAC1C;AAEN,CAAC,CACF;AACD,eAAe,CAAC,WAAW,GAAG,iBAAiB;;;;"}
@@ -1,24 +1,5 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
2
  import MemoizedElement from './Element.js';
3
- import '../contexts/providers/renderer.provider.js';
4
- import '../contexts/providers/edit-context.provider.js';
5
- import '../contexts/providers/active-node.provider.js';
6
- import '@contentstack/studio-client';
7
- import '@contentstack/studio-messenger';
8
- import '@contentstack/studio-react-components/contexts';
9
- import 'immer';
10
- import 'react';
11
- import '../hooks/use-edit-context-listener.hook.js';
12
- import '@contentstack/studio-internal';
13
- import '@contentstack/studio-core';
14
- import '@contentstack/studio-react-components/basic-components';
15
- import '@contentstack/studio-react-components/hooks';
16
- import 'goober';
17
- import '../contexts/providers/section-mode.provider.js';
18
- import '@contentstack/studio-registry';
19
- import '../contexts/providers/use-design-preview.provider.js';
20
- import '../contexts/providers/use-repeater.provider.js';
21
- import '../contexts/providers/use-condition-block.provider.js';
22
3
  import { PreviewModeContext } from '../contexts/providers/preview-mode.provider.js';
23
4
 
24
5
  function PreviewRenderer(props) {
@@ -1 +1 @@
1
- {"version":3,"file":"PreviewRenderer.js","sources":["../../src/components/PreviewRenderer.tsx"],"sourcesContent":["import { StudioSpec } from \"@contentstack/studio-client\";\nimport { ComposableStudioData } from \"@contentstack/studio-registry\";\nimport Element from \"./Element\";\nimport { PreviewModeContext } from \"../contexts/providers\";\n\nexport interface StudioComponentLiteProps {\n spec: Omit<StudioSpec, \"compositionEntry\">;\n data?: ComposableStudioData[\"component_props\"];\n}\n\nexport function PreviewRenderer(props: StudioComponentLiteProps) {\n const { spec } = props;\n\n return (\n <PreviewModeContext.Provider value={true}>\n <Element node={spec.ui} />\n </PreviewModeContext.Provider>\n );\n}\n"],"names":["_jsx","Element"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAUM,SAAU,eAAe,CAAC,KAA+B,EAAA;AAC7D,IAAA,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK;IAEtB,QACEA,IAAC,kBAAkB,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,IAAI,EAAA,QAAA,EACtCA,IAACC,eAAO,EAAA,EAAC,IAAI,EAAE,IAAI,CAAC,EAAE,EAAA,CAAI,EAAA,CACE;AAElC;;;;"}
1
+ {"version":3,"file":"PreviewRenderer.js","sources":["../../src/components/PreviewRenderer.tsx"],"sourcesContent":["import { StudioSpec } from \"@contentstack/studio-client\";\nimport { ComposableStudioData } from \"@contentstack/studio-registry\";\nimport Element from \"./Element\";\nimport { PreviewModeContext } from \"../contexts/providers/preview-mode.provider\";\n\nexport interface StudioComponentLiteProps {\n spec: Omit<StudioSpec, \"compositionEntry\">;\n data?: ComposableStudioData[\"component_props\"];\n}\n\nexport function PreviewRenderer(props: StudioComponentLiteProps) {\n const { spec } = props;\n\n return (\n <PreviewModeContext.Provider value={true}>\n <Element node={spec.ui} />\n </PreviewModeContext.Provider>\n );\n}\n"],"names":["_jsx","Element"],"mappings":";;;;AAUM,SAAU,eAAe,CAAC,KAA+B,EAAA;AAC7D,IAAA,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK;IAEtB,QACEA,IAAC,kBAAkB,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,IAAI,EAAA,QAAA,EACtCA,IAACC,eAAO,EAAA,EAAC,IAAI,EAAE,IAAI,CAAC,EAAE,EAAA,CAAI,EAAA,CACE;AAElC;;;;"}
@@ -4,10 +4,14 @@ import { SectionInstanceSlotsCtx } from '@contentstack/studio-react-components/c
4
4
  import { css } from 'goober';
5
5
  import { useContext } from 'react';
6
6
  import { styleFactory } from './styles.js';
7
+ import { useSlotCopyColor } from '../hooks/use-slot-copy-color.hook.js';
7
8
  import { WelcomeState } from './WelcomeState.js';
8
9
  import classNames from 'classnames';
10
+ import { AddIcon } from './AddIcon.js';
9
11
 
10
12
  function Slot({ studioAttributes, slotUid, hint, isRootSlot = false, compositionPlacement, }) {
13
+ const dropCopyColor = useSlotCopyColor();
14
+ const hintCopyColor = useSlotCopyColor();
11
15
  // When a section is consumed inside another composition, only the section's
12
16
  // exposed `section-slot` placeholders are intended to be filled by the page
13
17
  // composer — the section's own internal Box/Row/Column slots are part of
@@ -35,11 +39,8 @@ function Slot({ studioAttributes, slotUid, hint, isRootSlot = false, composition
35
39
  return jsx(WelcomeState, { compositionPlacement: placement });
36
40
  };
37
41
  const welcomeState = renderWelcomeState();
38
- return (jsx("div", { ...attributes, className: slotClassName, ...studioAttributes, children: welcomeState ? (welcomeState) : (jsxs(Fragment, { children: [jsxs("span", { className: styles.slotDropText, children: [jsx(AddIcon, {}), " Drop Here"] }), hint && jsxs("p", { className: styles.slotHintStyle, children: ["(", hint, ")"] })] })) }));
42
+ return (jsx("div", { ...attributes, className: slotClassName, ...studioAttributes, children: welcomeState ? (welcomeState) : (jsxs(Fragment, { children: [jsxs("span", { ref: dropCopyColor.ref, className: classNames(styles.slotDropText, dropCopyColor.colorClassName, dropCopyColor.strokeClassName), children: [jsx(AddIcon, {}), " Drop Here"] }), hint && (jsxs("p", { ref: hintCopyColor.ref, className: classNames(styles.slotHintStyle, hintCopyColor.colorClassName, hintCopyColor.strokeClassName), children: ["(", hint, ")"] }))] })) }));
39
43
  }
40
- const AddIcon = () => {
41
- 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" })] }));
42
- };
43
44
 
44
45
  export { Slot as default };
45
46
  //# sourceMappingURL=Slot.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Slot.js","sources":["../../src/components/Slot.tsx"],"sourcesContent":["import {\n COMPOSABLE_DATA_ATTRIBUTES,\n type CompositionPlacement,\n COMPOSITION_PLACEMENT_OPTIONS,\n} from \"@contentstack/studio-client\";\nimport { SectionInstanceSlotsCtx } from \"@contentstack/studio-react-components/contexts\";\nimport { css } from \"goober\";\nimport { useContext } from \"react\";\nimport { styleFactory } from \"./styles\";\nimport { StudioAttributes } from \"../types/renderer.type\";\nimport { WelcomeState } from \"./WelcomeState\";\nimport classNames from \"classnames\";\n\ninterface SlotProps extends StudioAttributes {\n slotUid: string;\n hint?: string;\n isRootSlot?: boolean;\n compositionPlacement?: CompositionPlacement;\n}\n\nexport default function Slot({\n studioAttributes,\n slotUid,\n hint,\n isRootSlot = false,\n compositionPlacement,\n}: SlotProps) {\n // When a section is consumed inside another composition, only the section's\n // exposed `section-slot` placeholders are intended to be filled by the page\n // composer — the section's own internal Box/Row/Column slots are part of\n // its authored body and should NOT surface as page-level drop targets.\n // Suppress the drop UI for those internal slots in consumption mode.\n const inSectionConsumption = useContext(SectionInstanceSlotsCtx);\n if (inSectionConsumption) return null;\n\n const attributes = {\n [COMPOSABLE_DATA_ATTRIBUTES.SLOT]: true,\n [COMPOSABLE_DATA_ATTRIBUTES.SLOT_UID]: slotUid,\n };\n const styles = styleFactory(css);\n const slotClassName = classNames(styles.slotStyle, {\n [styles.slotColumnStyle]: hint,\n });\n\n // Render welcome state for root slots\n const renderWelcomeState = () => {\n if (!isRootSlot) return null;\n\n // Handle undefined, null, and empty string by defaulting to PAGE (backward compatibility)\n const placement =\n !compositionPlacement || (compositionPlacement as string) === \"\"\n ? COMPOSITION_PLACEMENT_OPTIONS.PAGE\n : compositionPlacement;\n\n return <WelcomeState compositionPlacement={placement} />;\n };\n\n const welcomeState = renderWelcomeState();\n\n return (\n <div {...attributes} className={slotClassName} {...studioAttributes}>\n {welcomeState ? (\n welcomeState\n ) : (\n <>\n <span className={styles.slotDropText}>\n <AddIcon /> Drop Here\n </span>\n {hint && <p className={styles.slotHintStyle}>({hint})</p>}\n </>\n )}\n </div>\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","_Fragment"],"mappings":";;;;;;;;;AAoBc,SAAU,IAAI,CAAC,EAC3B,gBAAgB,EAChB,OAAO,EACP,IAAI,EACJ,UAAU,GAAG,KAAK,EAClB,oBAAoB,GACV,EAAA;;;;;;AAMV,IAAA,MAAM,oBAAoB,GAAG,UAAU,CAAC,uBAAuB,CAAC;AAChE,IAAA,IAAI,oBAAoB;AAAE,QAAA,OAAO,IAAI;AAErC,IAAA,MAAM,UAAU,GAAG;AACjB,QAAA,CAAC,0BAA0B,CAAC,IAAI,GAAG,IAAI;AACvC,QAAA,CAAC,0BAA0B,CAAC,QAAQ,GAAG,OAAO;KAC/C;AACD,IAAA,MAAM,MAAM,GAAG,YAAY,CAAC,GAAG,CAAC;AAChC,IAAA,MAAM,aAAa,GAAG,UAAU,CAAC,MAAM,CAAC,SAAS,EAAE;AACjD,QAAA,CAAC,MAAM,CAAC,eAAe,GAAG,IAAI;AAC/B,KAAA,CAAC;;IAGF,MAAM,kBAAkB,GAAG,MAAK;AAC9B,QAAA,IAAI,CAAC,UAAU;AAAE,YAAA,OAAO,IAAI;;AAG5B,QAAA,MAAM,SAAS,GACb,CAAC,oBAAoB,IAAK,oBAA+B,KAAK;cAC1D,6BAA6B,CAAC;cAC9B,oBAAoB;AAE1B,QAAA,OAAOA,IAAC,YAAY,EAAA,EAAC,oBAAoB,EAAE,SAAS,GAAI;AAC1D,IAAA,CAAC;AAED,IAAA,MAAM,YAAY,GAAG,kBAAkB,EAAE;IAEzC,QACEA,gBAAS,UAAU,EAAE,SAAS,EAAE,aAAa,EAAA,GAAM,gBAAgB,EAAA,QAAA,EAChE,YAAY,IACX,YAAY,KAEZC,IAAA,CAAAC,QAAA,EAAA,EAAA,QAAA,EAAA,CACED,IAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAE,MAAM,CAAC,YAAY,EAAA,QAAA,EAAA,CAClCD,GAAA,CAAC,OAAO,EAAA,EAAA,CAAG,EAAA,YAAA,CAAA,EAAA,CACN,EACN,IAAI,IAAIC,IAAA,CAAA,GAAA,EAAA,EAAG,SAAS,EAAE,MAAM,CAAC,aAAa,EAAA,QAAA,EAAA,CAAA,GAAA,EAAI,IAAI,SAAM,CAAA,EAAA,CACxD,CACJ,EAAA,CACG;AAEV;AAEA,MAAM,OAAO,GAAa,MAAK;AAC7B,IAAA,QACEA,IAAA,CAAA,KAAA,EAAA,EACE,KAAK,EAAC,IAAI,EACV,MAAM,EAAC,IAAI,EACX,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,KAAK,EAAC,4BAA4B,EAAA,QAAA,EAAA,CAElCD,cAAM,CAAC,EAAC,KAAK,EAAC,CAAC,EAAC,KAAK,EAAC,KAAK,EAAC,IAAI,EAAC,MAAM,EAAC,IAAI,EAAC,EAAE,EAAC,KAAK,EAAC,IAAI,EAAC,OAAO,EAAA,CAAG,EACrEA,GAAA,CAAA,MAAA,EAAA,EAAM,CAAC,EAAC,KAAK,EAAC,CAAC,EAAC,KAAK,EAAC,KAAK,EAAC,IAAI,EAAC,MAAM,EAAC,IAAI,EAAC,EAAE,EAAC,KAAK,EAAC,MAAM,EAAC,SAAS,GAAG,EACzEA,GAAA,CAAA,MAAA,EAAA,EACE,CAAC,EAAC,qbAAqb,EACvb,IAAI,EAAC,SAAS,EAAA,CACd,CAAA,EAAA,CACE;AAEV,CAAC;;;;"}
1
+ {"version":3,"file":"Slot.js","sources":["../../src/components/Slot.tsx"],"sourcesContent":["import {\n COMPOSABLE_DATA_ATTRIBUTES,\n type CompositionPlacement,\n COMPOSITION_PLACEMENT_OPTIONS,\n} from \"@contentstack/studio-client\";\nimport { SectionInstanceSlotsCtx } from \"@contentstack/studio-react-components/contexts\";\nimport { css } from \"goober\";\nimport { useContext } from \"react\";\nimport { styleFactory } from \"./styles\";\nimport { useSlotCopyColor } from \"../hooks/use-slot-copy-color.hook\";\nimport { StudioAttributes } from \"../types/renderer.type\";\nimport { WelcomeState } from \"./WelcomeState\";\nimport classNames from \"classnames\";\nimport { AddIcon } from \"./AddIcon\";\n\ninterface SlotProps extends StudioAttributes {\n slotUid: string;\n hint?: string;\n isRootSlot?: boolean;\n compositionPlacement?: CompositionPlacement;\n}\n\nexport default function Slot({\n studioAttributes,\n slotUid,\n hint,\n isRootSlot = false,\n compositionPlacement,\n}: SlotProps) {\n const dropCopyColor = useSlotCopyColor<HTMLSpanElement>();\n const hintCopyColor = useSlotCopyColor<HTMLParagraphElement>();\n\n // When a section is consumed inside another composition, only the section's\n // exposed `section-slot` placeholders are intended to be filled by the page\n // composer — the section's own internal Box/Row/Column slots are part of\n // its authored body and should NOT surface as page-level drop targets.\n // Suppress the drop UI for those internal slots in consumption mode.\n const inSectionConsumption = useContext(SectionInstanceSlotsCtx);\n if (inSectionConsumption) return null;\n\n const attributes = {\n [COMPOSABLE_DATA_ATTRIBUTES.SLOT]: true,\n [COMPOSABLE_DATA_ATTRIBUTES.SLOT_UID]: slotUid,\n };\n const styles = styleFactory(css);\n const slotClassName = classNames(styles.slotStyle, {\n [styles.slotColumnStyle]: hint,\n });\n\n // Render welcome state for root slots\n const renderWelcomeState = () => {\n if (!isRootSlot) return null;\n\n // Handle undefined, null, and empty string by defaulting to PAGE (backward compatibility)\n const placement =\n !compositionPlacement || (compositionPlacement as string) === \"\"\n ? COMPOSITION_PLACEMENT_OPTIONS.PAGE\n : compositionPlacement;\n\n return <WelcomeState compositionPlacement={placement} />;\n };\n\n const welcomeState = renderWelcomeState();\n\n return (\n <div {...attributes} className={slotClassName} {...studioAttributes}>\n {welcomeState ? (\n welcomeState\n ) : (\n <>\n <span\n ref={dropCopyColor.ref}\n className={classNames(\n styles.slotDropText,\n dropCopyColor.colorClassName,\n dropCopyColor.strokeClassName,\n )}\n >\n <AddIcon /> Drop Here\n </span>\n {hint && (\n <p\n ref={hintCopyColor.ref}\n className={classNames(\n styles.slotHintStyle,\n hintCopyColor.colorClassName,\n hintCopyColor.strokeClassName,\n )}\n >\n ({hint})\n </p>\n )}\n </>\n )}\n </div>\n );\n}\n"],"names":["_jsx","_jsxs","_Fragment"],"mappings":";;;;;;;;;;;AAsBc,SAAU,IAAI,CAAC,EAC3B,gBAAgB,EAChB,OAAO,EACP,IAAI,EACJ,UAAU,GAAG,KAAK,EAClB,oBAAoB,GACV,EAAA;AACV,IAAA,MAAM,aAAa,GAAG,gBAAgB,EAAmB;AACzD,IAAA,MAAM,aAAa,GAAG,gBAAgB,EAAwB;;;;;;AAO9D,IAAA,MAAM,oBAAoB,GAAG,UAAU,CAAC,uBAAuB,CAAC;AAChE,IAAA,IAAI,oBAAoB;AAAE,QAAA,OAAO,IAAI;AAErC,IAAA,MAAM,UAAU,GAAG;AACjB,QAAA,CAAC,0BAA0B,CAAC,IAAI,GAAG,IAAI;AACvC,QAAA,CAAC,0BAA0B,CAAC,QAAQ,GAAG,OAAO;KAC/C;AACD,IAAA,MAAM,MAAM,GAAG,YAAY,CAAC,GAAG,CAAC;AAChC,IAAA,MAAM,aAAa,GAAG,UAAU,CAAC,MAAM,CAAC,SAAS,EAAE;AACjD,QAAA,CAAC,MAAM,CAAC,eAAe,GAAG,IAAI;AAC/B,KAAA,CAAC;;IAGF,MAAM,kBAAkB,GAAG,MAAK;AAC9B,QAAA,IAAI,CAAC,UAAU;AAAE,YAAA,OAAO,IAAI;;AAG5B,QAAA,MAAM,SAAS,GACb,CAAC,oBAAoB,IAAK,oBAA+B,KAAK;cAC1D,6BAA6B,CAAC;cAC9B,oBAAoB;AAE1B,QAAA,OAAOA,IAAC,YAAY,EAAA,EAAC,oBAAoB,EAAE,SAAS,GAAI;AAC1D,IAAA,CAAC;AAED,IAAA,MAAM,YAAY,GAAG,kBAAkB,EAAE;AAEzC,IAAA,QACEA,GAAA,CAAA,KAAA,EAAA,EAAA,GAAS,UAAU,EAAE,SAAS,EAAE,aAAa,EAAA,GAAM,gBAAgB,EAAA,QAAA,EAChE,YAAY,IACX,YAAY,KAEZC,IAAA,CAAAC,QAAA,EAAA,EAAA,QAAA,EAAA,CACED,eACE,GAAG,EAAE,aAAa,CAAC,GAAG,EACtB,SAAS,EAAE,UAAU,CACnB,MAAM,CAAC,YAAY,EACnB,aAAa,CAAC,cAAc,EAC5B,aAAa,CAAC,eAAe,CAC9B,EAAA,QAAA,EAAA,CAEDD,GAAA,CAAC,OAAO,EAAA,EAAA,CAAG,EAAA,YAAA,CAAA,EAAA,CACN,EACN,IAAI,KACHC,IAAA,CAAA,GAAA,EAAA,EACE,GAAG,EAAE,aAAa,CAAC,GAAG,EACtB,SAAS,EAAE,UAAU,CACnB,MAAM,CAAC,aAAa,EACpB,aAAa,CAAC,cAAc,EAC5B,aAAa,CAAC,eAAe,CAC9B,EAAA,QAAA,EAAA,CAAA,GAAA,EAEC,IAAI,EAAA,GAAA,CAAA,EAAA,CACJ,CACL,IACA,CACJ,EAAA,CACG;AAEV;;;;"}
@@ -4,63 +4,80 @@ import { COMPOSITION_PLACEMENT_OPTIONS } from '@contentstack/studio-client';
4
4
  import { css } from 'goober';
5
5
  import { styleFactory } from './styles.js';
6
6
  import { BuildingIllustration } from './BuildingIllustration.js';
7
- import '../contexts/providers/renderer.provider.js';
7
+ import { useSlotCopyColor } from '../hooks/use-slot-copy-color.hook.js';
8
8
  import { editContext } from '../contexts/providers/edit-context.provider.js';
9
- import '../contexts/providers/active-node.provider.js';
10
- import { DataStepMode } from '@contentstack/studio-messenger';
11
- import '@contentstack/studio-react-components/contexts';
12
- import 'immer';
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 '@contentstack/studio-react-components/hooks';
18
- import './Element.js';
19
- import '../contexts/providers/section-mode.provider.js';
20
- import '@contentstack/studio-registry';
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';
25
9
  import classNames from 'classnames';
10
+ import { DataStepMode } from '@contentstack/studio-messenger';
26
11
 
27
- // Step 2 wording follows the data options the editor actually offers for this
12
+ // Data-step wording follows the options the editor actually offers for this
28
13
  // composition (composable-studio ADR 0008): a freeform page can only pin, a
29
14
  // linked page connects a schema (plus pin when the Freeform plan is on).
30
- const STEP2_BY_MODE = {
15
+ const DATA_STEP_BY_MODE = {
31
16
  [DataStepMode.PinOnly]: {
32
- heading: "Step 2: Pin data",
17
+ label: "Pin data",
33
18
  description: "Pin flexible content to your components.",
34
19
  },
35
20
  [DataStepMode.SchemaOrPin]: {
36
- heading: "Step 2: Connect a schema or pin data",
21
+ label: "Connect a schema or pin data",
37
22
  description: "Bind structured data or pin flexible content to your components.",
38
23
  },
39
24
  [DataStepMode.SchemaOnly]: {
40
- heading: "Step 2: Connect a schema",
25
+ label: "Connect a schema",
41
26
  description: "Bind structured data to your components.",
42
27
  },
43
28
  };
44
29
  const getWelcomeContent = (placement, dataStepMode) => {
45
- const step2 = STEP2_BY_MODE[dataStepMode];
30
+ const dataStep = DATA_STEP_BY_MODE[dataStepMode];
46
31
  const isPage = placement === COMPOSITION_PLACEMENT_OPTIONS.PAGE;
47
32
  return {
48
33
  title: isPage ? "Start Building Template" : "Start Building Section",
49
34
  subtitle: isPage
50
35
  ? "Add components and bind data to complete your setup."
51
36
  : "Add components and bind data to complete your section setup.",
52
- step1Description: isPage
37
+ dataStepLabel: dataStep.label,
38
+ dataStepDescription: dataStep.description,
39
+ componentsStepDescription: isPage
53
40
  ? "Drag and drop components from the LHS components panel to create your design."
54
41
  : "Drag and drop components from the LHS components panel to create your section design.",
55
- step2Heading: step2.heading,
56
- step2Description: step2.description,
57
42
  };
58
43
  };
59
44
  const WelcomeState = ({ compositionPlacement, }) => {
60
45
  const { dataStepMode } = useContext(editContext);
61
46
  const content = getWelcomeContent(compositionPlacement, dataStepMode);
62
47
  const styles = styleFactory(css);
63
- return (jsxs("div", { className: styles.welcomeContainer, children: [jsx(BuildingIllustration, {}), jsx("h2", { className: styles.welcomeTitle, children: content.title }), jsx("p", { className: styles.welcomeSubtitle, children: content.subtitle }), jsxs("div", { className: styles.welcomeSteps, children: [jsxs("div", { className: classNames(styles.welcomeStep, styles.activeWelcomeStep), children: [jsx("h3", { children: "Step 1: Add components to canvas" }), jsx("p", { children: content.step1Description })] }), jsxs("div", { className: styles.welcomeStep, children: [jsx("h3", { children: content.step2Heading }), jsx("p", { children: content.step2Description })] })] })] }));
48
+ // The whole panel is coloured from the page behind it. Unlike the one-line
49
+ // drop copy, this has a hierarchy to keep and two surfaces to fill, so it
50
+ // derives a secondary ink and a step tint from the same measurement. The
51
+ // illustration needs nothing of its own: its tone ramp is `currentColor`, so
52
+ // it follows the ink it is nested in.
53
+ const chrome = useSlotCopyColor();
54
+ // One mode, two colours, chosen from the page. The step cards take the
55
+ // mode's surface only where its ink cannot carry body copy on the page
56
+ // itself — a mid-tone page, where neither dark nor light ink separates
57
+ // enough. Everywhere else they stay surfaceless and the chrome sits directly
58
+ // on the customer's page. Both cards get it or neither does: Step 2's copy
59
+ // needs it exactly as much, and a fill on one card only would mark the active
60
+ // step by legibility. Which step is active is the purple border's job.
61
+ const tokens = chrome.tokens;
62
+ const surfaced = chrome.surfaceNeeded && tokens !== null;
63
+ const primary = tokens?.ink;
64
+ const secondary = tokens?.secondary;
65
+ const stepSurface = surfaced ? tokens.surface : "transparent";
66
+ // The active step keeps a purple tint, as it always has. It is the mode's
67
+ // own tint rather than a fixed pale one: a fixed #f9f8ff was invisible on a
68
+ // white page and, once the ink adapted pale on a dark page, swallowed its own
69
+ // copy at 1:1. The border alone marked the step but read as much weaker.
70
+ const activeStepSurface = tokens?.emphasisSurface ?? "transparent";
71
+ // An edge rather than elevation: a surface can sit under 2:1 against the page
72
+ // it is on, and a 1px token border marks it without a shadow. It goes on the
73
+ // inactive card in either mode, painted surface or not, so its edge belongs
74
+ // to the mode rather than being a fixed light grey. The active card is marked
75
+ // by the purple border instead.
76
+ const stepEdge = tokens?.surfaceEdge;
77
+ return (jsxs("div", { ref: chrome.ref, className: classNames(styles.welcomeContainer, tokens ? undefined : styles.slotCopyOverImage), style: primary ? { color: primary } : undefined, children: [jsx(BuildingIllustration, {}), jsx("h2", { className: styles.welcomeTitle, style: { color: primary }, children: content.title }), jsx("p", { className: styles.welcomeSubtitle, style: { color: secondary }, children: content.subtitle }), jsxs("div", { className: styles.welcomeSteps, children: [jsxs("div", { className: classNames(styles.welcomeStep, styles.activeWelcomeStep), style: { backgroundColor: activeStepSurface }, children: [jsxs("h3", { style: { color: primary }, children: ["Step 1: ", content.dataStepLabel] }), jsx("p", { style: { color: secondary }, children: content.dataStepDescription })] }), jsxs("div", { className: styles.welcomeStep, style: {
78
+ backgroundColor: stepSurface,
79
+ ...(stepEdge ? { borderColor: stepEdge } : {}),
80
+ }, children: [jsx("h3", { style: { color: primary }, children: "Step 2: Add components to canvas" }), jsx("p", { style: { color: secondary }, children: content.componentsStepDescription })] })] })] }));
64
81
  };
65
82
 
66
83
  export { WelcomeState };
@@ -1 +1 @@
1
- {"version":3,"file":"WelcomeState.js","sources":["../../src/components/WelcomeState.tsx"],"sourcesContent":["import React, { useContext } from \"react\";\nimport {\n type CompositionPlacement,\n COMPOSITION_PLACEMENT_OPTIONS,\n} from \"@contentstack/studio-client\";\nimport { css } from \"goober\";\nimport { styleFactory } from \"./styles\";\nimport { BuildingIllustration } from \"./BuildingIllustration\";\nimport { editContext, DataStepMode } from \"../contexts/providers\";\nimport classNames from \"classnames\";\n\ninterface WelcomeStateProps {\n compositionPlacement: CompositionPlacement;\n}\n\ninterface WelcomeContent {\n title: string;\n subtitle: string;\n step1Description: string;\n step2Heading: string;\n step2Description: string;\n}\n\n// Step 2 wording follows the data options the editor actually offers for this\n// composition (composable-studio ADR 0008): a freeform page can only pin, a\n// linked page connects a schema (plus pin when the Freeform plan is on).\nconst STEP2_BY_MODE: Record<\n DataStepMode,\n { heading: string; description: string }\n> = {\n [DataStepMode.PinOnly]: {\n heading: \"Step 2: Pin data\",\n description: \"Pin flexible content to your components.\",\n },\n [DataStepMode.SchemaOrPin]: {\n heading: \"Step 2: Connect a schema or pin data\",\n description:\n \"Bind structured data or pin flexible content to your components.\",\n },\n [DataStepMode.SchemaOnly]: {\n heading: \"Step 2: Connect a schema\",\n description: \"Bind structured data to your components.\",\n },\n};\n\nconst getWelcomeContent = (\n placement: CompositionPlacement,\n dataStepMode: DataStepMode,\n): WelcomeContent => {\n const step2 = STEP2_BY_MODE[dataStepMode];\n const isPage = placement === COMPOSITION_PLACEMENT_OPTIONS.PAGE;\n return {\n title: isPage ? \"Start Building Template\" : \"Start Building Section\",\n subtitle: isPage\n ? \"Add components and bind data to complete your setup.\"\n : \"Add components and bind data to complete your section setup.\",\n step1Description: isPage\n ? \"Drag and drop components from the LHS components panel to create your design.\"\n : \"Drag and drop components from the LHS components panel to create your section design.\",\n step2Heading: step2.heading,\n step2Description: step2.description,\n };\n};\n\nexport const WelcomeState: React.FC<WelcomeStateProps> = ({\n compositionPlacement,\n}) => {\n const { dataStepMode } = useContext(editContext);\n const content = getWelcomeContent(compositionPlacement, dataStepMode);\n const styles = styleFactory(css);\n\n return (\n <div className={styles.welcomeContainer}>\n <BuildingIllustration />\n <h2 className={styles.welcomeTitle}>{content.title}</h2>\n <p className={styles.welcomeSubtitle}>{content.subtitle}</p>\n <div className={styles.welcomeSteps}>\n <div\n className={classNames(styles.welcomeStep, styles.activeWelcomeStep)}\n >\n <h3>Step 1: Add components to canvas</h3>\n <p>{content.step1Description}</p>\n </div>\n <div className={styles.welcomeStep}>\n <h3>{content.step2Heading}</h3>\n <p>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EAAE,MAAM,CAAC,gBAAgB,EAAA,QAAA,EAAA,CACrCC,GAAA,CAAC,oBAAoB,EAAA,EAAA,CAAG,EACxBA,YAAI,SAAS,EAAE,MAAM,CAAC,YAAY,YAAG,OAAO,CAAC,KAAK,EAAA,CAAM,EACxDA,GAAA,CAAA,GAAA,EAAA,EAAG,SAAS,EAAE,MAAM,CAAC,eAAe,EAAA,QAAA,EAAG,OAAO,CAAC,QAAQ,EAAA,CAAK,EAC5DD,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,MAAM,CAAC,YAAY,EAAA,QAAA,EAAA,CACjCA,IAAA,CAAA,KAAA,EAAA,EACE,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,iBAAiB,CAAC,EAAA,QAAA,EAAA,CAEnEC,GAAA,CAAA,IAAA,EAAA,EAAA,QAAA,EAAA,kCAAA,EAAA,CAAyC,EACzCA,GAAA,CAAA,GAAA,EAAA,EAAA,QAAA,EAAI,OAAO,CAAC,gBAAgB,EAAA,CAAK,IAC7B,EACND,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,MAAM,CAAC,WAAW,aAChCC,GAAA,CAAA,IAAA,EAAA,EAAA,QAAA,EAAK,OAAO,CAAC,YAAY,EAAA,CAAM,EAC/BA,GAAA,CAAA,GAAA,EAAA,EAAA,QAAA,EAAI,OAAO,CAAC,gBAAgB,EAAA,CAAK,IAC7B,CAAA,EAAA,CACF,CAAA,EAAA,CACF;AAEV;;;;"}
1
+ {"version":3,"file":"WelcomeState.js","sources":["../../src/components/WelcomeState.tsx"],"sourcesContent":["import React, { useContext } from \"react\";\nimport {\n type CompositionPlacement,\n COMPOSITION_PLACEMENT_OPTIONS,\n} from \"@contentstack/studio-client\";\nimport { css } from \"goober\";\nimport { styleFactory } from \"./styles\";\nimport { BuildingIllustration } from \"./BuildingIllustration\";\nimport { useSlotCopyColor } from \"../hooks/use-slot-copy-color.hook\";\n\nimport {\n editContext,\n DataStepMode,\n} from \"../contexts/providers/edit-context.provider\";\nimport classNames from \"classnames\";\n\ninterface WelcomeStateProps {\n compositionPlacement: CompositionPlacement;\n}\n\ninterface WelcomeContent {\n title: string;\n subtitle: string;\n dataStepLabel: string;\n dataStepDescription: string;\n componentsStepDescription: string;\n}\n\n// Data-step wording follows the options the editor actually offers for this\n// composition (composable-studio ADR 0008): a freeform page can only pin, a\n// linked page connects a schema (plus pin when the Freeform plan is on).\nconst DATA_STEP_BY_MODE: Record<\n DataStepMode,\n { label: string; description: string }\n> = {\n [DataStepMode.PinOnly]: {\n label: \"Pin data\",\n description: \"Pin flexible content to your components.\",\n },\n [DataStepMode.SchemaOrPin]: {\n label: \"Connect a schema or pin data\",\n description:\n \"Bind structured data or pin flexible content to your components.\",\n },\n [DataStepMode.SchemaOnly]: {\n label: \"Connect a schema\",\n description: \"Bind structured data to your components.\",\n },\n};\n\nconst getWelcomeContent = (\n placement: CompositionPlacement,\n dataStepMode: DataStepMode,\n): WelcomeContent => {\n const dataStep = DATA_STEP_BY_MODE[dataStepMode];\n const isPage = placement === COMPOSITION_PLACEMENT_OPTIONS.PAGE;\n return {\n title: isPage ? \"Start Building Template\" : \"Start Building Section\",\n subtitle: isPage\n ? \"Add components and bind data to complete your setup.\"\n : \"Add components and bind data to complete your section setup.\",\n dataStepLabel: dataStep.label,\n dataStepDescription: dataStep.description,\n componentsStepDescription: isPage\n ? \"Drag and drop components from the LHS components panel to create your design.\"\n : \"Drag and drop components from the LHS components panel to create your section design.\",\n };\n};\n\nexport const WelcomeState: React.FC<WelcomeStateProps> = ({\n compositionPlacement,\n}) => {\n const { dataStepMode } = useContext(editContext);\n const content = getWelcomeContent(compositionPlacement, dataStepMode);\n const styles = styleFactory(css);\n\n // The whole panel is coloured from the page behind it. Unlike the one-line\n // drop copy, this has a hierarchy to keep and two surfaces to fill, so it\n // derives a secondary ink and a step tint from the same measurement. The\n // illustration needs nothing of its own: its tone ramp is `currentColor`, so\n // it follows the ink it is nested in.\n const chrome = useSlotCopyColor<HTMLDivElement>();\n\n // One mode, two colours, chosen from the page. The step cards take the\n // mode's surface only where its ink cannot carry body copy on the page\n // itself — a mid-tone page, where neither dark nor light ink separates\n // enough. Everywhere else they stay surfaceless and the chrome sits directly\n // on the customer's page. Both cards get it or neither does: Step 2's copy\n // needs it exactly as much, and a fill on one card only would mark the active\n // step by legibility. Which step is active is the purple border's job.\n const tokens = chrome.tokens;\n const surfaced = chrome.surfaceNeeded && tokens !== null;\n\n const primary = tokens?.ink;\n const secondary = tokens?.secondary;\n const stepSurface = surfaced ? tokens.surface : \"transparent\";\n // The active step keeps a purple tint, as it always has. It is the mode's\n // own tint rather than a fixed pale one: a fixed #f9f8ff was invisible on a\n // white page and, once the ink adapted pale on a dark page, swallowed its own\n // copy at 1:1. The border alone marked the step but read as much weaker.\n const activeStepSurface = tokens?.emphasisSurface ?? \"transparent\";\n // An edge rather than elevation: a surface can sit under 2:1 against the page\n // it is on, and a 1px token border marks it without a shadow. It goes on the\n // inactive card in either mode, painted surface or not, so its edge belongs\n // to the mode rather than being a fixed light grey. The active card is marked\n // by the purple border instead.\n const stepEdge = tokens?.surfaceEdge;\n\n return (\n <div\n ref={chrome.ref}\n className={classNames(\n styles.welcomeContainer,\n tokens ? undefined : styles.slotCopyOverImage,\n )}\n style={primary ? { color: primary } : undefined}\n >\n <BuildingIllustration />\n <h2 className={styles.welcomeTitle} style={{ color: primary }}>\n {content.title}\n </h2>\n <p className={styles.welcomeSubtitle} style={{ color: secondary }}>\n {content.subtitle}\n </p>\n <div className={styles.welcomeSteps}>\n <div\n className={classNames(styles.welcomeStep, styles.activeWelcomeStep)}\n style={{ backgroundColor: activeStepSurface }}\n >\n <h3 style={{ color: primary }}>Step 1: {content.dataStepLabel}</h3>\n <p style={{ color: secondary }}>{content.dataStepDescription}</p>\n </div>\n <div\n className={styles.welcomeStep}\n style={{\n backgroundColor: stepSurface,\n ...(stepEdge ? { borderColor: stepEdge } : {}),\n }}\n >\n <h3 style={{ color: primary }}>Step 2: Add components to canvas</h3>\n <p style={{ color: secondary }}>\n {content.componentsStepDescription}\n </p>\n </div>\n </div>\n </div>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;AA4BA;AACA;AACA;AACA,MAAM,iBAAiB,GAGnB;AACF,IAAA,CAAC,YAAY,CAAC,OAAO,GAAG;AACtB,QAAA,KAAK,EAAE,UAAU;AACjB,QAAA,WAAW,EAAE,0CAA0C;AACxD,KAAA;AACD,IAAA,CAAC,YAAY,CAAC,WAAW,GAAG;AAC1B,QAAA,KAAK,EAAE,8BAA8B;AACrC,QAAA,WAAW,EACT,kEAAkE;AACrE,KAAA;AACD,IAAA,CAAC,YAAY,CAAC,UAAU,GAAG;AACzB,QAAA,KAAK,EAAE,kBAAkB;AACzB,QAAA,WAAW,EAAE,0CAA0C;AACxD,KAAA;CACF;AAED,MAAM,iBAAiB,GAAG,CACxB,SAA+B,EAC/B,YAA0B,KACR;AAClB,IAAA,MAAM,QAAQ,GAAG,iBAAiB,CAAC,YAAY,CAAC;AAChD,IAAA,MAAM,MAAM,GAAG,SAAS,KAAK,6BAA6B,CAAC,IAAI;IAC/D,OAAO;QACL,KAAK,EAAE,MAAM,GAAG,yBAAyB,GAAG,wBAAwB;AACpE,QAAA,QAAQ,EAAE;AACR,cAAE;AACF,cAAE,8DAA8D;QAClE,aAAa,EAAE,QAAQ,CAAC,KAAK;QAC7B,mBAAmB,EAAE,QAAQ,CAAC,WAAW;AACzC,QAAA,yBAAyB,EAAE;AACzB,cAAE;AACF,cAAE,uFAAuF;KAC5F;AACH,CAAC;MAEY,YAAY,GAAgC,CAAC,EACxD,oBAAoB,GACrB,KAAI;IACH,MAAM,EAAE,YAAY,EAAE,GAAG,UAAU,CAAC,WAAW,CAAC;IAChD,MAAM,OAAO,GAAG,iBAAiB,CAAC,oBAAoB,EAAE,YAAY,CAAC;AACrE,IAAA,MAAM,MAAM,GAAG,YAAY,CAAC,GAAG,CAAC;;;;;;A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